History log of /freebsd-current/sys/dev/ata/ata-lowlevel.c
Revision Date Author Comments
# fdafd315 24-Nov-2023 Warner Losh <imp@FreeBSD.org>

sys: Automated cleanup of cdefs and other formatting

Apply the following automated changes to try to eliminate
no-longer-needed sys/cdefs.h includes as well as now-empty
blank lines in a row.

Remove /^#if.*\n#endif.*\n#include\s+<sys/cdefs.h>.*\n/
Remove /\n+#include\s+<sys/cdefs.h>.*\n+#if.*\n#endif.*\n+/
Remove /\n+#if.*\n#endif.*\n+/
Remove /^#if.*\n#endif.*\n/
Remove /\n+#include\s+<sys/cdefs.h>\n#include\s+<sys/types.h>/
Remove /\n+#include\s+<sys/cdefs.h>\n#include\s+<sys/param.h>/
Remove /\n+#include\s+<sys/cdefs.h>\n#include\s+<sys/capsicum.h>/

Sponsored by: Netflix


# 685dc743 16-Aug-2023 Warner Losh <imp@FreeBSD.org>

sys: Remove $FreeBSD$: one-line .c pattern

Remove /^[\s*]*__FBSDID\("\$FreeBSD\$"\);?\s*\n/


# 4d846d26 10-May-2023 Warner Losh <imp@FreeBSD.org>

spdx: The BSD-2-Clause-FreeBSD identifier is obsolete, drop -FreeBSD

The SPDX folks have obsoleted the BSD-2-Clause-FreeBSD identifier. Catch
up to that fact and revert to their recommended match of BSD-2-Clause.

Discussed with: pfg
MFC After: 3 days
Sponsored by: Netflix


# 1529c509 01-Sep-2020 Mateusz Guzik <mjg@FreeBSD.org>

ata: clean up empty lines in .c and .h files


# 65d2f9c1 05-Dec-2019 John Baldwin <jhb@FreeBSD.org>

Use a void * argument to callout handlers instead of timeout_t casts.

Reviewed by: kib
Differential Revision: https://reviews.freebsd.org/D22684


# 718cf2cc 27-Nov-2017 Pedro F. Giffuni <pfg@FreeBSD.org>

sys/dev: further adoption of SPDX licensing ID tags.

Mainly focus on files that use BSD 2-Clause license, however the tool I
was using misidentified many licenses so this was mostly a manual - error
prone - task.

The Software Package Data Exchange (SPDX) group provides a specification
to make it easier for automated tools to detect and summarize well known
opensource licenses. We are gradually adopting the specification, noting
that the tags are considered only advisory and do not, in any way,
superceed or replace the license texts.


# 9c2ceeaf 29-Mar-2016 Pedro F. Giffuni <pfg@FreeBSD.org>

Small typo.


# ebef81ec 07-Aug-2015 Alexander Motin <mav@FreeBSD.org>

Add unmapped I/O support to ata(4) driver.

Main problem there was PIO mode support, that required KVA mapping.
Handle that case using recently added pmap_quick_enter_page(9) KPI,
mapping data pages to KVA one at a time.


# a164074f 12-May-2013 Eitan Adler <eadler@FreeBSD.org>

Fix several typos

PR: kern/176054
Submitted by: Christoph Mallon <christoph.mallon@gmx.de>
MFC after: 3 days


# d2ce15bd 06-Apr-2013 Marius Strobl <marius@FreeBSD.org>

- With the demise of !ATA_CAM, ATA_STATIC_ID is the only ata(4) related
option left but actually consumed by ada(4), so move it to opt_ada.h
and get rid of opt_ata.h.
- Fix stand-alone build of atacore(4) by adding opt_cam.h.
- Use __FBSDID.
- Use DEVMETHOD_END.
- Use NULL instead of 0 for pointers.


# f924768c 06-Apr-2013 Marius Strobl <marius@FreeBSD.org>

- Make ata_str2mode() static, it's not used outside of ata-all.c.
- Move ata_timeout() to ata-all.c so we don't need to expose both this
function and ata_cam_end_transaction() but only the former.
- Move ata_cmd2str() from ata-queue.c to ata-all.c so we can get rid of
the former.
- Add some missing prototypes.

MFC after: 3 days


# 45f6d665 04-Apr-2013 Alexander Motin <mav@FreeBSD.org>

Remove all legacy ATA code parts, not used since options ATA_CAM enabled in
most kernels before FreeBSD 9.0. Remove such modules and respective kernel
options: atadisk, ataraid, atapicd, atapifd, atapist, atapicam. Remove the
atacontrol utility and some man pages. Remove useless now options ATA_CAM.

No objections: current@, stable@
MFC after: never


# ba514351 02-Feb-2013 Marius Strobl <marius@FreeBSD.org>

Improve r238673 to additionally allow for odd-aligned buffers as
passed in by smartd of smartmontools.
While at it, hint the compiler that 32-bit PIO is the most likely
case (idea from Linux) and use bus_{read,write}_stream_2(9) instead
of bus_{read,write}_multi_stream_2(9) for single count reads/writes.

MFC after: 1 week


# 23d9e39c 26-Oct-2012 Alexander Motin <mav@FreeBSD.org>

Implement CAM_ATAIO_NEEDRESULT (fetching full set of result registers) for
ata(4) driver in ATA_CAM mode. That slighty improves error reporting and
also should fix `smartctl -l scterc /dev/adaX` operation.

MFC after: 3 weeks


# 08466b02 17-Sep-2012 Kevin Lo <kevlo@FreeBSD.org>

Remove bogus break statements.

Obtained from: DragonFly


# b8aff31b 21-Jul-2012 Alexander Motin <mav@FreeBSD.org>

Use 16bit PIO instead of 32bit in case of misaligned buffer.
It fixes kernel panic during CD write with cdrecord on sparc64.


# 9a14aa01 15-Jan-2012 Ulrich Spörlein <uqs@FreeBSD.org>

Convert files to UTF-8


# 2ef549f3 21-Apr-2011 Alexander Motin <mav@FreeBSD.org>

Make PATA-like soft-reset in ata(4) more strict in checking disk signature.
It allows to avoid false positive device detection under Xen, that caused
long probe delays due to subsequent IDENTIFY command timeouts.

MFC after: 1 month


# 285ba173 06-Nov-2010 Alexander Motin <mav@FreeBSD.org>

Mark command submission timeouts as timeouts. This should trigger device
resets and increase chances of getting device back again.


# 618c8d01 06-Nov-2010 Alexander Motin <mav@FreeBSD.org>

Add support for odd-sized PIO transfers, sometimes used by ATAPI.


# a7d5f7eb 19-Oct-2010 Jamie Gritton <jamie@FreeBSD.org>

A new jail(8) with a configuration file, to replace the work currently done
by /etc/rc.d/jail.


# c14e163a 09-Sep-2010 Nathan Whitehorn <nwhitehorn@FreeBSD.org>

Fix a problem where device detection would work unreliably on Serverworks
K2 SATA controllers. The chip's status register must be read first, and
as a long, for other registers to be correctly updated after a command, and
this includes the command sequence in device detection as well as the
previously handled case after interrupts. While here, clean up some
previous hacks related to this controller.

Reported by: many
Reviewed by: mav
MFC after: 3 weeks


# a250a687 02-Sep-2010 Alexander Motin <mav@FreeBSD.org>

SATA1.x SiliconImage controllers on power-on reset TFD Status register into
value 0xff. On hot-plug this value confuses ata_generic_reset() device
presence detection logic. As soon as we already know drive presence from
SATA hard reset, hint ata_generic_reset() to wait for device signature
until success or full timeout.


# 972b06a7 11-Jun-2010 Nathan Whitehorn <nwhitehorn@FreeBSD.org>

MFC r208870:
Some revisions of the Serverworks K2 SATA controller have a data
corruption bug where if an ATA command is issued before DMA is started,
data will become available to the controller before it knows what to do
with it. This results in either data corruption or a controller crash.

This patch remedies the problem by adopting the workaround employed
by Linux and Darwin: starting the DMA engine prior to sending the ATA
command.

Reviewed by: mav
Approved by: re (kib)


# 351129c7 06-Jun-2010 Nathan Whitehorn <nwhitehorn@FreeBSD.org>

Some revisions of the Serverworks K2 SATA controller have a data
corruption bug where if an ATA command is issued before DMA is started,
data will become available to the controller before it knows what to do
with it. This results in either data corruption or a controller crash.

This patch remedies the problem by adopting the workaround employed
by Linux and Darwin: starting the DMA engine prior to sending the ATA
command.

Observer on: Xserve G5
Reviewed by: mav
MFC after: 1 week


# 71e7360e 12-Dec-2009 Alexander Motin <mav@FreeBSD.org>

MFC r200171, r200182, r200275, r200295, r200359:
Introduce ATA_CAM kernel option, turning ata(4) controller drivers into
cam(4) interface modules. When enabled, this option deprecates all ata(4)
peripheral drivers (ad, acd, ...) and interfaces and allows cam(4) drivers
(ada, cd, ...) and interfaces to be natively used instead.

As side effect of this, ata(4) mode setting code was completely rewritten
to make controller API more strict and permit above change. While doing
this, SATA revision was separated from PATA mode. It allows DMA-incapable
SATA devices to operate and makes hw.ata.(ata|atapi)_dma tunable work again.

Also allow ata(4) controller drivers (except some specific or broken ones)
to handle larger data transfers. Previous constraint of 64K was artificial
and is not really required by PCI ATA BM specification or hardware.

Submitted by: nwitehorn (powerpc part)


# 066f913a 05-Dec-2009 Alexander Motin <mav@FreeBSD.org>

MFp4:
Introduce ATA_CAM kernel option, turning ata(4) controller drivers into
cam(4) interface modules. When enabled, this options deprecates all ata(4)
peripheral drivers (ad, acd, ...) and interfaces and allows cam(4) drivers
(ada, cd, ...) and interfaces to be natively used instead.

As side effect of this, ata(4) mode setting code was completely rewritten
to make controller API more strict and permit above change. While doing
this, SATA revision was separated from PATA mode. It allows DMA-incapable
SATA devices to operate and makes hw.ata.atapi_dma tunable work again.

Also allow ata(4) controller drivers (except some specific or broken ones)
to handle larger data transfers. Previous constraint of 64K was artificial
and is not really required by PCI ATA BM specification or hardware.

Submitted by: nwitehorn (powerpc part)


# 555a8009 23-Nov-2009 Alexander Motin <mav@FreeBSD.org>

MFC r198717:
- Remove most of direct relations between ATA(4) peripherial and controller
levels. It makes logic more transparent and is a mandatory step to wrap
ATA(4) controller level into ATA-native CAM SIM.
- Tune AHCI and SATA2 SiI drivers memory allocation a bit to allow bigger
I/O transaction sizes without additional cost.


# ebbb35ba 31-Oct-2009 Alexander Motin <mav@FreeBSD.org>

MFp4:
- Remove most of direct relations between ATA(4) peripherial and controller
levels. It makes logic more transparent and is a mandatory step to wrap
ATA(4) controller level into ATA-native CAM SIM.
- Tune AHCI and SATA2 SiI drivers memory allocation a bit to allow bigger
I/O transaction sizes without additional cost.


# d7f03759 19-Oct-2008 Ulf Lilleengen <lulf@FreeBSD.org>

- Import the HEAD csup code which is the basis for the cvsmode work.


# a384947e 08-May-2008 Peter Grehan <grehan@FreeBSD.org>

Fix panic and breakage for non-DMA ATA devices e.g. powermac macio cells.
Handle cases where dma function pointers may be NULL, and where
the max_iosize can't be derived from a DMA data structure. For
the latter, revert to the prior behaviour of using DFLTPHYS for
the max i/o size when there is no other data.

Reviewed by: marcel
No objection by: sos


# 104c094e 16-Apr-2008 Søren Schmidt <sos@FreeBSD.org>

Go back to preallocating everything possible on init.
This avoids calling busdma in the request processing path which caused a traumatic performance degradation.
Allocation has be postponed to after we know how many devices we possible can have on portmulitpliers to save some space.


# d90a6aae 14-Apr-2008 Søren Schmidt <sos@FreeBSD.org>

Fix problem with slave devices.
Fix or rather bring ENOMEM problems back to the state it was before.
Temporarily disable PortMultipliers on AHCI devices.


# 9f82379c 10-Apr-2008 Søren Schmidt <sos@FreeBSD.org>

Add experimental support for SATA Port Multipliers

Support is working on the Silicon Image SiI3124/3132.
Support is working on some AHCI chips but far from all.

Remember this is WIP, so test reports and (constructive) suggestions are welcome!


# 4c088dcd 13-Dec-2007 Søren Schmidt <sos@FreeBSD.org>

Implement a workaround of the datacorruption problem on serverworks HT1000 chipsets.
The HT1000 DMA engine seems to not always like 64K transfers and sometimes barfs data all over memory leading to instant chrash and burn.
Also fix 48bit adressing issues, apparently newer chips needs 16bit writes and not the usual fifo thing.

HW donated by: Travis Mikalson at TerraNovaNet


# 16194fc4 06-Apr-2007 Søren Schmidt <sos@FreeBSD.org>

Add support for 64bit addressing to AHCI and Marvell controllers.
Munged into ATA shape and Marvell specifics my yours truely.

Submitted by: jhb


# 129230b8 21-Feb-2007 Søren Schmidt <sos@FreeBSD.org>

Update copyright headers.


# 891abbfa 04-Jul-2006 Søren Schmidt <sos@FreeBSD.org>

Add preliminary support for the Serverworks HT1000 chip.

HW sponsored by: Yahoo!


# f5f55db3 18-Jan-2006 Søren Schmidt <sos@FreeBSD.org>

Add support for using DMA on dump, greatly speeds up the dump process.
Add dump support in ataraid.


# e2bf77c5 05-Jan-2006 Søren Schmidt <sos@FreeBSD.org>

Get rid of the advertising clause in the copyright.


# b39424ba 05-Dec-2005 Søren Schmidt <sos@FreeBSD.org>

Dont use the BUS_DMA_ALLOCNOW flag. Instead use BUS_DMA_NOWAIT and return
ENOMEM to the upper layers if we run out of memory.

This solves part of the trouble with running on >4GB memory systems.


# 6f26936c 28-Nov-2005 Giorgos Keramidas <keramida@FreeBSD.org>

Fix two identical harmless typos in ata error messages:
s/issueing/issuing/

PR: kern/89481
Submitted by: John Nielsen
Approved by: sos
MFC after: 1 week


# 3d42c6d1 19-Sep-2005 Søren Schmidt <sos@FreeBSD.org>

Dont wait for READY on ATAPI_IDENTIFY.
Fixes the losage of some ATAPI device that reported failed probing with
"timeout waiting for read DRQ".


# 0387836d 13-Sep-2005 Søren Schmidt <sos@FreeBSD.org>

Harden the hotplug support for SATA devices.
This also fixes a few races that was present in the timeout/detach code.

Sponsored by: pair.com


# 85047b1b 17-Aug-2005 Søren Schmidt <sos@FreeBSD.org>

Add support for working around controllers that cannot do DMA in 48bit mode.
The workaround use PIO mode above ~137GB to allow using the disk.
Add the Acer chips with rev < 0xc4 as first candidate.


# 6667b30d 16-May-2005 Søren Schmidt <sos@FreeBSD.org>

Change the way ioctls are issue to ATA.
The most prominent part is that its now possible to issue ata_requests
directly to say acd0, instead of going through the cumbersome /dev/ata
device.


# bb8a0cf2 13-May-2005 Søren Schmidt <sos@FreeBSD.org>

Fix more ATAPI breakage.
Apparently some devices are very picky on details :)


# faca873f 10-May-2005 Søren Schmidt <sos@FreeBSD.org>

Fix ATAPI DMA. We need to set the proper flags for DMA modes.


# eeda55ce 03-May-2005 Søren Schmidt <sos@FreeBSD.org>

Reshape the dma code to be a bit more flexible so it can cope with
new HW that has new and different demands.
Fix a few nits in former commit in this cleanup crusade.

Sponsored by: pair.com


# 9ec5e87f 30-Apr-2005 Søren Schmidt <sos@FreeBSD.org>

Update on the last commit, the dma* funciton needs to be called with
a channel device, not an ata device, or we'll be out of luck in
reset/timeout where we dont have a device.


# 0068f98f 30-Apr-2005 Søren Schmidt <sos@FreeBSD.org>

Take newbusification one step further, ie use the device_t more consequently
all way through the code down the layers, instead of the mix'n'match that
resulted from the conversion done earlier.

Sponsored by: pair.com


# e4709959 29-Apr-2005 Søren Schmidt <sos@FreeBSD.org>

Now that probing is working in the new fashion, we need to go back to
having ata_getparm issue an ata_request and not fool around with the HW
on its own.
Needed for new HW support.


# 8dad6b7b 28-Apr-2005 Søren Schmidt <sos@FreeBSD.org>

Rearrange the way the reset code is called.
Prepare for different looking controllers.


# 1d968d22 21-Apr-2005 Søren Schmidt <sos@FreeBSD.org>

Rehash the timeout code to make it more simple.
This also removes the warning timeout on the taskqueues stalling as
I'm tired of getting ATA error reports for problems in other parts ;)
Misc cosmetic and comment cleanups now we are here.


# a6e97ccf 14-Apr-2005 Søren Schmidt <sos@FreeBSD.org>

Read back the real taskfile register values when in 48BIT mode.


# b0a7e6a5 08-Apr-2005 Søren Schmidt <sos@FreeBSD.org>

Generalise the SATA PHY handling code so it wont be duplicated for
each SATA chip.
Promise and Silicon Image are the current candidates for this.


# 0e1eb682 06-Apr-2005 Søren Schmidt <sos@FreeBSD.org>

Add support for controllers that doesn't have the usual taskfile
layout. No functional changes.


# fa13a39e 03-Apr-2005 Søren Schmidt <sos@FreeBSD.org>

Fix a buglet that caused slaves to be nondetected.


# 5a5b148d 31-Mar-2005 Søren Schmidt <sos@FreeBSD.org>

Change the ata_* methods to use a channel device instead of a
controller device. This helps when there is no controller parent
to a channel (PPC port).


# 8ca4df32 29-Mar-2005 Søren Schmidt <sos@FreeBSD.org>

This is the much rumoured ATA mkIII update that I've been working on.

o ATA is now fully newbus'd and split into modules.
This means that on a modern system you just load "atapci and ata"
to get the base support, and then one or more of the device
subdrivers "atadisk atapicd atapifd atapist ataraid".
All can be loaded/unloaded anytime, but for obvious reasons you
dont want to unload atadisk when you have mounted filesystems.

o The device identify part of the probe has been rewritten to fix
the problems with odd devices the old had, and to try to remove
so of the long delays some HW could provoke. Also probing is done
without the need for interrupts, making earlier probing possible.

o SATA devices can be hot inserted/removed and devices will be created/
removed in /dev accordingly.
NOTE: only supported on controllers that has this feature:
Promise and Silicon Image for now.
On other controllers the usual atacontrol detach/attach dance is
still needed.

o Support for "atomic" composite ATA requests used for RAID.

o ATA RAID support has been rewritten and and now supports these
metadata formats:
"Adaptec HostRAID"
"Highpoint V2 RocketRAID"
"Highpoint V3 RocketRAID"
"Intel MatrixRAID"
"Integrated Technology Express"
"LSILogic V2 MegaRAID"
"LSILogic V3 MegaRAID"
"Promise FastTrak"
"Silicon Image Medley"
"FreeBSD PseudoRAID"

o Update the ioctl API to match new RAID levels etc.

o Update atacontrol to know about the new RAID levels etc
NOTE: you need to recompile atacontrol with the new sys/ata.h,
make world will take care of that.
NOTE2: that rebuild is done differently from the old system as
the rebuild is now done piggybacked on read requests to the
array, so atacontrol simply starts a background "dd" to rebuild
the array.

o The reinit code has been worked over to be much more robust.

o The timeout code has been overhauled for races.

o Support of new chipsets.

o Lots of fixes for bugs found while doing the modulerization and
reviewing the old code.

Missing or changed features from current ATA:

o atapi-cd no longer has support for ATAPI changers. Todays its
much cheaper and alot faster to copy those CD images to disk
and serve them from there. Besides they dont seem to be made
anymore, maybe for that exact reason.

o ATA RAID can only read metadata from all the above metadata formats,
not write all of them (Promise and Highpoint V2 so far). This means
that arrays can be picked up from the BIOS, but they cannot be
created from FreeBSD. There is more to it than just the missing
write metadata support, those formats are not unique to a given
controller like Promise and Highpoint formats, instead they exist
for several types, and even worse, some controllers can have
different formats and its impossible to tell which one.
The outcome is that we cannot reliably create the metadata of those
formats and be sure the controller BIOS will understand it.
However write support is needed to update/fail/rebuild the arrays
properly so it sits fairly high on the TODO list.

o So far atapicam is not supported with these changes. When/if this
will change is up to the maintainer of atapi-cam so go there for
questions.

HW donated by: Webveveriet AS
HW donated by: Frode Nordahl
HW donated by: Yahoo!
HW donated by: Sentex
Patience by: Vife and my boys (and even the cats)


# 9956392d 06-Mar-2005 Nate Lawson <njl@FreeBSD.org>

Whitespace nit. Clarifies which body this line belongs to.


# a50519ed 01-Mar-2005 Matthew N. Dodd <mdodd@FreeBSD.org>

Handle PIO timeouts in ata_end_transaction() by immediately returning.
Failure to do this will result in following ata_pio_read() calls walking
off the end of the read buffer.

This resolves the "memory modified after free" panics common with Thinkpads
and CD/DVD drives.

Submitted by: Nate Lawson <nate AT root.org>


# 6bacdeb7 01-Mar-2005 Matthew N. Dodd <mdodd@FreeBSD.org>

In ata_generic_reset() while waiting for both master & slave to become
idle the 'mask' variable could be set to 0, resulting in the timeout loop
running for the full 31 seconds.

Handling this case eliminates long hangs on resume on some systems.

Submitted by: Nate Lawson <nate AT root.org>


# 5bcdf700 24-Dec-2004 Søren Schmidt <sos@FreeBSD.org>

Loosen the probe a bit.
Try to get out of probing as early as possible on (hopefully) vacant
channels.


# 241ce89e 09-Dec-2004 Søren Schmidt <sos@FreeBSD.org>

Compensate for off by one bugs in disk firmware for 48BIT addressing cutover.


# 39c7a710 24-Nov-2004 Søren Schmidt <sos@FreeBSD.org>

Return ATA register values in the request struct when ATAREQUEST returns.


# b5dee91f 26-Sep-2004 Søren Schmidt <sos@FreeBSD.org>

Remove the old ATA_*LOCK_CH macros that used atomic ops and use
mutexes instead.
This closes the last (known) race issues in ATA which should fix
the various hangs etc seen on heavy loaded systems.

Change from using timeout functions to using callout functions in
the timeout code. This together with above closes the race that could
happen if timeout and device interrupt occured simultaniously.

Also fix the possible recursion in ata_reinit() on very dodgy
devices that could take us down in the probe.


# 0f7cfb84 02-Sep-2004 Søren Schmidt <sos@FreeBSD.org>

Introduce ata_udelay() that uses tsleep instead of DELAY if possible.
In places where we have long delays that doesn't depend on too accurate
timing, use ata_udelay() instead of DELAY() so we dont uselessly spin
the CPU if not nessesary;


# d3ef327c 27-Aug-2004 Søren Schmidt <sos@FreeBSD.org>

remove unused prototype


# dc26948b 27-Aug-2004 Søren Schmidt <sos@FreeBSD.org>

Fix the handling of "inflight" requests when doing reinit's.
Add missing untimeout that would get lost in handling of some
error situations, and caused what looked like random timeouts
afterwards when the timeout fired.


# 5f7a48ef 16-Aug-2004 Søren Schmidt <sos@FreeBSD.org>

Improve (hopefully) on the workaround code for devices that doesn't
interrupt when command is done, ie some ATAPI CD drives with no
media loaded.


# ba0b5c1c 06-Aug-2004 Søren Schmidt <sos@FreeBSD.org>

Correct the last commit so it works in error situations as well.


# c68afc9d 06-Aug-2004 Nate Lawson <njl@FreeBSD.org>

Fix a panic in ata_generic_transaction(). The DMA pointer of the channel
was being unconditionally dereferenced but was NULL for PIO requests.
Check the request flags for a DMA transaction before dereferencing.

Reported by: ceri
Tested by: Radek Kozlowski <radek -at- raadradd.com>


# 7e6d7588 05-Aug-2004 Søren Schmidt <sos@FreeBSD.org>

Try to narrow down the race window on HW that does not have ways to
poll for which channel actually pulled the irq line.


# a4c3e742 24-Jul-2004 Søren Schmidt <sos@FreeBSD.org>

Refine the wait for ATAPI_RESET.
Properly wait for not busy and introduce a timeout for devices not
setting busy (as they should).
Leave a printf in there that states how long the wait was, as I'd like
to get an idea of the variations here. The time needed seems also to be
affected by whether a medium is present or not.


# 426fc845 23-Jul-2004 Søren Schmidt <sos@FreeBSD.org>

Dont expect interrupt from ATAPI_RESET, it doesn't deliver one.


# 68599b78 11-Jun-2004 Søren Schmidt <sos@FreeBSD.org>

Back out the last change as that broke some SATA devices.
Now we are cleaing up remove a few lines of unused code.


# 541cd509 01-Jun-2004 Søren Schmidt <sos@FreeBSD.org>

Dont retry on devices that left the system.
Ignore "fake" devices that has 0x7f status.


# 263b4cde 17-May-2004 Søren Schmidt <sos@FreeBSD.org>

Rip out the too verbose "spurious interrupt" printf's, they dont serve
a purpose any longer.


# ad452ba4 30-Apr-2004 Søren Schmidt <sos@FreeBSD.org>

Spring cleanup of macros


# 1e311c18 27-Apr-2004 Søren Schmidt <sos@FreeBSD.org>

Reduce the time spent looking for devices on channels that return
what looks like garbage.


# 9036df11 19-Apr-2004 Søren Schmidt <sos@FreeBSD.org>

Move a verbose printf before the first exit so we get a chance
to see what was there.


# f2972d7e 13-Apr-2004 Søren Schmidt <sos@FreeBSD.org>

Add support for the Promise command sequencer present on all modern Promise
controllers (PDC203** PDC206**).

This also adds preliminary support for the Promise SX4/SX4000 but *only*
as a "normal" Promise ATA controller (ATA RAID's are supported though
but only RAID0, RAID1 and RAID0+1).

This cuts off yet another 5-8% of the command overhead on promise controllers,
making them the fastest we have ever had support for.

Work is now continuing to add support for this in ATA RAID, to accellerate
ATA RAID quite a bit on these controllers, and especially the SX4/SX4000
series as they have quite a few tricks in there..

This commit also adds a few fixes to the SATA code needed for proper support.


# 498e5543 14-Mar-2004 Søren Schmidt <sos@FreeBSD.org>

Add support for detaching PCI controllers.

This adds support for cardbus ATA/SATA controllers. I get roughly the
same transfer speeds as on true PCI controllers. Nice to be able to add
a couble of "real" disks to a laptop :)


# 0c7ab114 21-Feb-2004 Søren Schmidt <sos@FreeBSD.org>

Only register interrupt as seen if it was a real HW interrupt.


# b8f6dec4 02-Feb-2004 Søren Schmidt <sos@FreeBSD.org>

Move the enabling of interrupt back to where it was some time ago.
This apparently was what broke the boot with some devices (liteon).


# 816994cc 28-Jan-2004 Søren Schmidt <sos@FreeBSD.org>

Use the biotask functionality in GEOM to put finished requests on
instead of taskqueue_swi. This shaves from 1 to 10% of the overhead.

Overhaul the locking once more, there was a few possible races that
are now closed.


# 5df3ca78 14-Jan-2004 Søren Schmidt <sos@FreeBSD.org>

Use UMA instead of plain malloc for getting ATA request storage.
This gives +10% performance on simple tests, so definitly worth it.
A few percent more could be had by not using M_ZERO'd alloc's, but
we then need to clear fields all over the place to be safe, and
that was deemed not worth the trouble (and it makes life dangerous).


# a7a120f6 11-Jan-2004 Søren Schmidt <sos@FreeBSD.org>

Overhaul of the timeout/reinit framework. This should clear up most
of the leftovers from the old version that really doesn't work anymore.

Add a reset function for host-end of the ATA channel. This is needed
for the SiI3112 in order to whack it back to reality if a device
locks up the SATA interface (thereby preventing that we can reset the
device). The result is that ATA now recovers from the timeouts that
happens with the SiI3112A and more or less all disks based on old
PATA electronics with a Marvell PATA->SATA converter. This includes
lots of the popular SATA dongles and the WDC Raptor disks..


# b9e240fa 10-Dec-2003 Søren Schmidt <sos@FreeBSD.org>

Finetune last commit, we need to take care of empty channels.


# b4485f7a 03-Dec-2003 Søren Schmidt <sos@FreeBSD.org>

Fix for the missing slave problem.

Approved by: re@


# 375e076b 02-Nov-2003 Søren Schmidt <sos@FreeBSD.org>

On ATA control commands return the registers in the request.


# 4788059c 21-Oct-2003 Søren Schmidt <sos@FreeBSD.org>

Properly unload the DMA SG list on errors.


# 80344be5 21-Oct-2003 Søren Schmidt <sos@FreeBSD.org>

Fix the DMA problem that most severely hit on the DS3112a SATA chip
in connection with Marvell based SATA->PATA dongles.

The problem was caused by a combination of things working
together to make it hard to spot...

The ATA driver has always started the ATA command, then build
the SG list for DMA and then finally started the DMA engine.
While this is according to specs, it poses a potential
problem as some controllers apparently do not allow for unlimitted
time between starting the ATA command and starting the DMA engine.

At about the same time as ATAng was committed there were lots
of other changes applied, some of which was locking in parts
that causes the busdma load functions to take significantly
longer to load the SG list.

This pushed the time spent between starting the ATA command and
starting the DMA engine over the hill for some controllers
(especially the Silicon Image DS3112a) and caused what looked
like lost interrupts.

The solution is to get all the SG list work or rather all
busdma related stuff done before we even try to start anything.

This has the nice side effect of seperating busdma out the
way it should be, so the working of the ATA machinery is not
cluttered up with busdma droppings, making the code easier
to read and understand.


# 5b2b2eba 20-Oct-2003 Søren Schmidt <sos@FreeBSD.org>

Up delay from 10 to 100ms after reset, this helps some slow devices
get their act together before we start probing.


# fa9dc8d0 09-Oct-2003 Søren Schmidt <sos@FreeBSD.org>

Fix the bug that prevented DMA from working on old Acer chips.

Found by: Andrew Gallatin <gallatin@cs.duke.edu>
Pointy hat to: sos


# f313fea9 07-Oct-2003 Søren Schmidt <sos@FreeBSD.org>

Properly get out of transaction() if setting up the transfer fails.


# 6d92de35 01-Oct-2003 Søren Schmidt <sos@FreeBSD.org>

Fix the problem with accessing certain FLASH devices. The problem
was that accessing the status reg could occour too fast, confusing
the logic in the flash part. Could not have been located without:

HW donated by: Jonas Bülow <jonas@servicefactory.se>


# bcf5e4d6 20-Sep-2003 Søren Schmidt <sos@FreeBSD.org>

Dont reject a master device if it said slave failed.


# 015aa737 18-Sep-2003 Søren Schmidt <sos@FreeBSD.org>

Cosmetics


# 228800a5 18-Sep-2003 Søren Schmidt <sos@FreeBSD.org>

Be a bit more restrictive in the probe so we dont hang around
on empty channels in most cases.


# 855deec4 16-Sep-2003 Søren Schmidt <sos@FreeBSD.org>

When ignoring interrupts (due to no running request set) then try
to grap the channel so we can read status (and clear an evt pending
interrupt).


# 853c84dd 16-Sep-2003 Søren Schmidt <sos@FreeBSD.org>

Rearrange the probe a bit first try ATAPI signatures then ATA.


# 2194b6a4 10-Sep-2003 Søren Schmidt <sos@FreeBSD.org>

Try a bit harder to probe disks that doesn't quite set BUSY right.


# 4514dcad 08-Sep-2003 Søren Schmidt <sos@FreeBSD.org>

#ifdef out the vague ATA disk detection code causing fake ATA disks
to be found on some systems.
Hopefully this doesn't loose any real ATA disks...


# 08c26854 08-Sep-2003 Søren Schmidt <sos@FreeBSD.org>

Handle shared channels better.
Try to avoid the spurios interrupts better.


# 7c788805 01-Sep-2003 Søren Schmidt <sos@FreeBSD.org>

Rearrange the probe code yet again.


# d7e9ef77 28-Aug-2003 Søren Schmidt <sos@FreeBSD.org>

Be more carefull on nulling the ATAPI magic for fake slave.
Skip polling devices that keeps returning 0xff early (ie no HW there).


# 1d68703f 27-Aug-2003 Søren Schmidt <sos@FreeBSD.org>

Hopefully Fix problem with probing some ATAPI devices, while still
trying to avoid the "fake slave" problem.


# 3a83be8e 25-Aug-2003 Søren Schmidt <sos@FreeBSD.org>

Try to get rid of the fake slave problem.


# 9f06a427 25-Aug-2003 Søren Schmidt <sos@FreeBSD.org>

Unify prototypes.
Cosmetics.


# bcebaec6 24-Aug-2003 Søren Schmidt <sos@FreeBSD.org>

Sync with local version (cosmetics)


# aad970f1 24-Aug-2003 David E. O'Brien <obrien@FreeBSD.org>

Use __FBSDID().
Also some minor style cleanups.


# 5fdbb0d2 24-Aug-2003 Søren Schmidt <sos@FreeBSD.org>

This is a major rework of the ATA driver (ATAng)

Restructure the way ATA/ATAPI commands are processed, use a common
ata_request structure for both. This centralises the way requests
are handled so locking is much easier to handle.

The driver is now layered much more cleanly to seperate the lowlevel
HW access so it can be tailored to specific controllers without touching
the upper layers. This is needed to support some of the newer
semi-intelligent ATA controllers showing up.

The top level drivers (disk, ATAPI devices) are more or less still
the same with just corrections to use the new interface.

Pull ATA out from under Gaint now that locking can be done in a sane way.

Add support for a the National Geode SC1100. Thanks to Soekris engineering
for sponsoring a Soekris 4801 to make this support.

Fixed alot of small bugs in the chipset code for various chips now
we are around in that corner anyways.