Home | History | Annotate | Download | only in ic
History log of /src/sys/dev/ic/siisata.c
RevisionDateAuthorComments
 1.51  02-Feb-2024  andvar fix various typos in comments.
 1.50  10-Nov-2021  msaitoh s/endianess/endianness/
 1.49  05-Oct-2021  rin PR kern/56403

Fix kernel freeze for wdc(4) variants with ATAC_CAP_NOIRQ:

(1) Change ata_xfer_ops:c_poll from void to int function. When it returns
ATAPOLL_AGAIN, let ata_xfer_start() iterate itself again.

(2) Let wdc_ata_bio_poll() return ATAPOLL_AGAIN until ATA_ITSDONE is
achieved.

A similar change has been made for mvsata(4) (see mvsata_bio_poll()),
and no functional changes for other devices.

This is how the drivers worked before jdolecek-ncq branch was merged.

Note that this changes are less likely to cause infinite recursion:

(1) wdc_ata_bio_intr() called from wdc_ata_bio_poll() asserts ATA_ITSDONE
in its error handling paths via wdc_ata_bio_done().

(2) Return value from c_start (= wdc_ata_bio_start()) is checked in
ata_xfer_start().

Therefore, errors encountered in ata_xfer_ops:c_poll and c_start routines
terminate the recursion for wdc(4). The situation is similar for mvsata(4).

Still, there is a possibility where ata_xfer_start() takes long time to
finish a normal operation. This can result in a delayed response for lower
priority interrupts. But, I've never observed such a situation, even when
heavy thrashing takes place for swap partition in wd(4).

"Go ahead" by jdolecek@.
 1.48  07-Aug-2021  thorpej Merge thorpej-cfargs2.
 1.47  24-Apr-2021  thorpej branches: 1.47.8;
Merge thorpej-cfargs branch:

Simplify and make extensible the config_search() / config_found() /
config_attach() interfaces: rather than having different variants for
which arguments you want pass along, just have a single call that
takes a variadic list of tag-value arguments.

Adjust all call sites:
- Simplify wherever possible; don't pass along arguments that aren't
actually needed.
- Don't be explicit about what interface attribute is attaching if
the device only has one. (More simplification.)
- Add a config_probe() function to be used in indirect configuiration
situations, making is visibly easier to see when indirect config is
in play, and allowing for future change in semantics. (As of now,
this is just a wrapper around config_match(), but that is an
implementation detail.)

Remove unnecessary or redundant interface attributes where they're not
needed.

There are currently 5 "cfargs" defined:
- CFARG_SUBMATCH (submatch function for direct config)
- CFARG_SEARCH (search function for indirect config)
- CFARG_IATTR (interface attribte)
- CFARG_LOCATORS (locators array)
- CFARG_DEVHANDLE (devhandle_t - wraps OFW, ACPI, etc. handles)

...and a sentinel value CFARG_EOL.

Add some extra sanity checking to ensure that interface attributes
aren't ambiguous.

Use CFARG_DEVHANDLE in MI FDT, OFW, and ACPI code, and macppc and shark
ports to associate those device handles with device_t instance. This
will trickle trough to more places over time (need back-end for pre-OFW
Sun OBP; any others?).
 1.46  11-Jan-2021  skrll branches: 1.46.2;
KNF
 1.45  11-Jan-2021  skrll Trailing whitespace
 1.44  25-Dec-2020  skrll Use designated initializers for struct ata_bustype
 1.43  10-Oct-2020  thorpej branches: 1.43.2;
In siisata_intr_port(), skip reading the error condition if
ata_queue_get_active_xfer() returns NULL.

PR kern/55682. Fix suggested by mlelstv@.
 1.42  13-Apr-2020  jdolecek fix use-after-free for ata xfer on bio submission found by KASAN

driver ata_bio hooks read parts of the xfer after ata_exec_xfer()
call in order to determine return value, change so that the hook
doesn't return any value - callers do not care already,
as all I/O requests are asynchronous

this problem was uncovered by recent change for wd(4) to not hold
wd mutex during ata_bio call, the interrupt for the xfer might
thus actually fire immediately

adjust also ata_exec_command driver hooks similarily - remove all
completion and waiting logic from drivers, upper layer ata code
using AT_WAIT/AT_POLL changed to call ata_wait_cmd() itself

PR kern/55169 by Nick Hudson
 1.41  19-Feb-2020  riastradh branches: 1.41.4;
C99 initializers for scsipi_bustype. No functional change intended.
 1.40  10-Nov-2019  chs branches: 1.40.2;
in many device attach paths, allocate memory with M_WAITOK instead of M_NOWAIT
and remove code to handle failures that can no longer happen.
 1.39  19-Nov-2018  jdolecek branches: 1.39.4;
consistently use the SATA correct 'port %d' instead of 'channel', some
whitespace fixes
 1.38  24-Oct-2018  jdolecek need now channel lock around siisata_device_reset() executed for fatal error
 1.37  24-Oct-2018  jdolecek detach the controller itself on shutdown; adjust to not detach already
detached atabus/channel
 1.36  22-Oct-2018  jdolecek Merge jdolecek-ncqfixes branch

- ata_xfer's are dynamicall allocated as needed using a pool, no longer
limited to number of possible openings supported by controller; dump
and recovery paths use dedicated pre-allocated storage
- moved callouts and condvars from ata_xfer to queue or channel, so that
ata_xfer does not need special initialization
- slot allocation now done when xfer is being activated, uncoupled
from memory allocation; active slots are no longer tracked by controller
code
- channel and drive reset is done always via the atabus thread, and
now executes with channel locked the whole time
- NCQ recovery moved to shared function, and run via the thread also
- added some workarounds for buggy error recovery AHCI emulation in QEMU
and Parallels

designed to primarily fix kern/52614, but might also help with kern/47041
and kern/53183
 1.35  20-Oct-2017  jdolecek branches: 1.35.2; 1.35.4; 1.35.6;
move ata_queue_alloc(1) and ata_queue_free() calls to ata_channel_init()
and ata_channel_destroy() respectively, to make attachment code simpler,
and to make it easier to spot special queue manipulation like cmdide(4)

on topic of PR kern/52606
 1.34  07-Oct-2017  jdolecek Merge support for SATA NCQ (Native Command Queueing) from jdolecek-ncq branch

ATA subsystem was changed to support several outstanding commands, and use
NCQ xfers if supported by both the controller and the disk, including NCQ
error recovery. Set NCQ high priority for BPRIO_TIMECRITICAL xfers
if supported. Added FUA support.

Done some work towards MP-safe, all ATA code tsleep()/wakeup() replaced
by condvars, and switched most code from spl* to mutexes (separate
wd(4) and ata channel lock).

Introduced new option WD_CHAOS_MONKEY to facilitate testing of error
handling, fixed several uncovered issues. Also fixed several problems
with kernel dump to wd(4) disk.

Tested with ahcisata(4), mvsata(4), siisata(4), piixide(4) on amd64,
with and without port multiplier, both disk and ATAPI devices; other
drivers and archs mechanically adjusted and compile-tested. NCQ is
supported for ahcisata(4) and siisata(4) for any controller, for
mvsata(4) only Gen IIe ones for now. Also enabled ATAPI support in
mvsata(4).

Thanks to Matt Thomas for initial ATA infrastructure patch, and
Jonathan A.Kollasch for siisata(4) NCQ changes and general testing.

Also fixes PR kern/43169 (wd(4)); and PR kern/11811, PR kern/47041,
PR kern/51979 (kernel dump)
 1.33  24-Apr-2017  jakllsch Fix PRB blanking, so as not to stomp on the feet of neighboring slots.
Also, don't blank some PRB fields twice.

[:U+1F633:]
 1.32  24-Apr-2017  jakllsch Fix typo in comment.
 1.31  24-Apr-2017  jakllsch Drop unused prototype. Whitespace fixes. Wrap/re-wrap long lines.
 1.30  03-Jan-2017  jakllsch branches: 1.30.4;
The SiI3124 was implemented at a time when the ATA/ACS2
DATA SET MANAGEMENT/TRIM command did not exist. As such, the (presumably
immutable) lookup table in the chip does not know that this command
indicates a data write to follow. Use the PRB Protocol Override
functionality to tell the chip the protocol we need for this command.

For PR kern/51756.
 1.29  19-Sep-2016  jakllsch Don't permanantly disable port if drive probe times out,
reinitialize port instead.
 1.28  02-May-2016  christos branches: 1.28.2;
move scsipi_strvis -> libkern:strnvisx()
change the prototype to match userland
fix sizes of strings passed to it
 1.27  08-Aug-2013  bouyer branches: 1.27.6;
Fix reverted condition. Fix panic reported by Patrick Welche on
current-users with an ATAPI device connected to siisata.
 1.26  22-Jun-2013  matt branches: 1.26.2;
Make sure dynamically allocated channel_queue struct are zero-filled.
 1.25  09-Jun-2013  njoly Add missing parenthesis.
 1.24  03-Apr-2013  bouyer Fix kernel dump on ahci controller, by making sure we won't sleep
while dumping:
- introduce ata_delay() which either use delay() or kpause()
depending on flags. use it in sata_reset_interface() and
some ahci functions
- kill ATA_NOSLEEP, it was tested but never set. use ATA_POLL instead.
- reduce delay while polling in ahci, to speed up the dump

Should fix PR kern/41095
 1.23  22-Oct-2012  jakllsch Work around missing __BUS_SPACE_HAS_STREAM_METHODS on some ports.
 1.22  31-Jul-2012  bouyer branches: 1.22.2;
Apply back changes that were reverted on Jul 24 and Jul 26 (general ata/wdc
cleanup and SATA PMP support), now that I'm back to fix the fallouts.
 1.21  26-Jul-2012  jakllsch Revert, with intention of restoring in a less invasive way, the SATA Port
Multiplier code.

ok christos@
 1.20  24-Jul-2012  jakllsch Revert dsl@'s changes of Sun, 15 Jul 2012 10:55:35 +0000 and
Sun, 15 Jul 2012 10:56:50 +0000, excepting the kernel version bump.
First step in reverting regressions to ata(4) subsystem during the addition of
port multiplier support.
 1.19  15-Jul-2012  dsl Some namespace protection (and add greppablity).
Prefix the DRIVE_ and DRIVET_ constants from atavar.h with ATA_.
Don't use an enum for drive_type - you don't know how big it will be.
Move driver_type to avoid implicit structure padding (esp on arm).
This change is purely lexical and mechanical.

Update to 6.99.9 - this wasn't done when the SATA PMP changes
were made - I'm sure they warranted a bump.
 1.18  02-Jul-2012  bouyer Add sata Port MultiPlier (PMP) support to the ata bus layer,
as described in
http://mail-index.netbsd.org/tech-kern/2012/06/23/msg013442.html
PMP support in integrated to the atabus layer.
struct ata_channel's ch_drive[] is not dynamically allocated, and ch_ndrive
(renamed to ch_ndrives) closely reflects the size of the ch_drive[] array.
Add helper functions atabus_alloc_drives() and atabus_free_drives()
to manage ch_drive[]/ch_ndrives.
Add wdc_maxdrives to struct wdc_softc so that bus front-end can specify
how much drive they really support (master/slave or single).
ata_reset_drive() callback gains a uint32_t *sigp argument which,
when not NULL, will contain the signature of the device being reset.
While there, some cosmetic changes:
- added a drive_type enum to ata_drive_datas, and stop encoding the
probed drive type in drive_flags (we were out of drive flags anyway).
- rename DRIVE_ATAPIST to DRIVE_ATAPIDSCW to better reflect what this
really is
- remove ata_channel->ata_drives, it's redundant with the pointer in
ata_drive_datas
- factor out the interpretation of SATA signatures in sata_interpet_sig()

propagate these changes to the ATA HBA drivers, and add support for PMP
to ahcisata(4) and siisata(4).

Thanks to:
- Protocase (http://www.protocase.com/) which provided a system
with lots of controllers, SATA PMP and drive slots
- Conservation Genomics Laboratory, Department of Biology, New Mexico State
University for hosting the above system
- Brook Milligan, who set up remote access and has been very responsive
when SATA cable move was needed
 1.17  15-May-2012  bouyer Gather disable/enable interruptst at the Port Interrupt Enable level in
2 functions, and use them to disable interrupts for polled commands.
In siisata_probe_drive(), disable interrupt while resetting the PHY and
sending the SOFT_RESET FIS. Also dectect timeout/errors at this level and
disable the port if needed.
Make siisata_intr_port() more resistent to interrupts without xfer (especially
error interrupts which can be asynchrounous, but can also happen for
timed out xfer).

With this, the kernel doesn't pannic when a siisata controller is connected
to a SATA port multiplier. More work is needed to support port multiplier
though.
 1.16  20-Apr-2012  bouyer Add a bustype_async_event_xfer_mode() callback to scsipi_bustype (which can
be NULL), so that transport-specific details of transfer mode setting/printing
can be handled more easily.
Move scsipi_async_event_xfer_mode() and scsipi_print_xfer_mode() to
scsi_base.c and split in parallel scsi and FC/SAS parts.
size of struct scsipi_bustype has changed, welcome to 6.99.5
 1.15  27-Sep-2011  jym branches: 1.15.2; 1.15.6;
Modify *ASSERTMSG() so they are now used as variadic macros. The main goal
is to provide routines that do as KASSERT(9) says: append a message
to the panic format string when the assertion triggers, with optional
arguments.

Fix call sites to reflect the new definition.

Discussed on tech-kern@. See
http://mail-index.netbsd.org/tech-kern/2011/09/07/msg011427.html
 1.14  13-Feb-2011  jakllsch Treat unexpected command completions a little more like regular completions.
Slight chance this might prevent some occasional log spew trouble at shutdown
time.
 1.13  13-Nov-2010  uebayasi branches: 1.13.2; 1.13.4;
Include sys/proc.h for tsleep, wakeup.
 1.12  26-Jul-2010  jakllsch Store information for bus_dmamem_unmap() and bus_dmamem_free()
somewhere outside the bus_dmamap_t. The bus_dmamap_t has already
been destroyed by this time.

Fixes DMA memory leak at siisata_detach() time.
 1.11  25-Apr-2010  rmind Fix KASSERTMSG() to be consistent with KASSERT() logic, not inverted.
Hi matt@!
 1.10  07-Apr-2010  jakllsch satafis:
- Add function to parse RDH FIS for use in implementing AT_READREG.
- Correct and clean up some structure definitions.
- Sprinkle a bit of const.
- Remove dependency on <dev/ic/wdcreg.h>, WDCTL_4BIT doesn't seem
to be specified by any recent ATA standard, and it seems to make
no difference in practice.
- Stop using WDSD_IBM, these bits have been obsolete since before SATA.

siisata:
- Implement AT_READREG.
- Reap now-unneeded <dev/ic/wdcreg.h>.
- Whitespace and slight debug code cleanup.
- Some possibly-uncessary code reordering.

ahcisata:
- Implement AT_READREG.
- Reap now-unneeded <dev/ic/wdcreg.h>.
 1.9  30-Jan-2010  jakllsch branches: 1.9.2; 1.9.4;
Sprinkle __KERNEL_RCSID() into siisata(4).
Slightly adjust some comment styling.
 1.8  19-Oct-2009  bouyer Remove closes 3 & 4 from my licence. Lots of thanks to Soren Jacobsen
for the booring work !
 1.7  04-Jul-2009  jakllsch Further corrections for siisata.

Reset ch_status and ch_error at the beginning of any operation.

The chip only writes the RDH FIS to the SRAM when the error bit is
set in a RDH FIS (per the datasheet). Thus, satafis_sdb_parse() is
replaced with satafis_rhd_parse(). A valid FIS type field seems to
not be written to the SRAM, so don't bother checking it for the
correct magic.

Additionally, append 2009 to copyright year set, and remove
obsolete CVS Id lines from when this was in my repository.
 1.6  27-Jun-2009  jakllsch Correct various siisata bugs, some old, some new.

- Move clearing of interrupts to before atastart() is called in the
xfer interrupt handler. Should fix kern/41579.
- Using cv_timedwait(9) is not possible in code that can be called from
interrupt context, fall back to DELAY(9).
- Correctly poll Port Slot Status register for soft reset PRBs.
- Only use the Recive Transfer Count register on reads, when it is valid.
- Activate PRBs in a way that takes the whole physical address into account,
even when the PRB is beyond 4GiB.
- consistently use DELAY(9)
- Use DELAY() constants in completion polling loops that are consistent with
the loop count limit. (i.e. timeout in 10 rather than 100 seconds)
 1.5  21-Jun-2009  jakllsch Use PRO_PS and PRO_PCS correctly.
From Wolfgang Stukenbrock as part of kern/41579.

While here, remove a line of whitespace, and add an else case to
the ATAPI command length toggle.
 1.4  17-Jun-2009  cegger make this build w/o SIISATA_DEBUG
 1.3  17-Jun-2009  jakllsch A few changes for siisata(4):

- Support detachment. From KIYOHARA Takashi.
- Add PCI detachment functionality (albeit not very interesting when
the bus can not yet be rescanned).
- Rework interrupt handlers to reduce near-duplicate code.
Borrowed from ahcisata(4).
- Attempt to make polled I/O work. Untested.
- Fix formatting of some messages.
- For always-polled commands, disable interrupt
at slot level rather than port level.
- Instead of busy-waiting indefinitely for completion of some commands
move on after 31 seconds. Use cv_timedwait(9) instead of DELAY(9).
- Use abstracted SATA FIS code.
- Enable use of disks that don't respond with the standard signature.
 1.2  14-Sep-2008  jakllsch branches: 1.2.4; 1.2.8; 1.2.12; 1.2.14;
A few cleanups for siisata(4)

No functional changes intended (except maybe un-reseting the chip a bit later
in attach).

- pass fewer arguments to local functions where arguments can be derived from
an existing argument
- some coding style fixes
- more abstraction for PRB activation and deactivation
- bus_dma(9) properification in error cases
- undefine SIISATA_DEBUG, and cleanup variables used only for DEBUG_PRINT()s
 1.1  23-May-2008  jnemeth branches: 1.1.2; 1.1.4; 1.1.8; 1.1.10;
Import siisata(4) by Jonathan A. Kollasch.

The siisata driver supports the Silicon Image SteelVine family of SATA-II
controllers, interfacing the hardware with the ata(4) and atapi(4) sub-
systems.

The following controllers are supported by the siisata driver:

Silicon Image SiI3124 4-port PCI/PCI-X
Silicon Image SiI3132 2-port PCI-Express x1
Silicon Image SiI3531 1-port PCI-Express x1

SATA Native Command Queueing is not yet supported.
Device hot swapping is not yet supported.
Silicon Image's Software RAID is not yet supported by the
ataraid(4) driver.

Approved by: core (christos), releng (bouyer)
 1.1.10.1  19-Oct-2008  haad Sync with HEAD.
 1.1.8.3  24-Sep-2008  wrstuden Merge in changes between wrstuden-revivesa-base-2 and
wrstuden-revivesa-base-3.
 1.1.8.2  23-Jun-2008  wrstuden Add files to branch that were added on -current.

After this, all that's left of update is to merge some changes
that had conflicts.
 1.1.8.1  23-May-2008  wrstuden file siisata.c was added on branch wrstuden-revivesa on 2008-06-23 05:02:13 +0000
 1.1.4.2  04-Jun-2008  yamt sync with head
 1.1.4.1  23-May-2008  yamt file siisata.c was added on branch yamt-pf42 on 2008-06-04 02:05:10 +0000
 1.1.2.3  28-Sep-2008  mjf Sync with HEAD.
 1.1.2.2  02-Jun-2008  mjf Sync with HEAD.
 1.1.2.1  23-May-2008  mjf file siisata.c was added on branch mjf-devfs2 on 2008-06-02 13:23:27 +0000
 1.2.14.3  14-Feb-2014  matt Change KASSERTMSG/KDASSERTMSG to use varadic arguments like HEAD.
panic -> vpanic, add panic wrapper to vpanic.
 1.2.14.2  29-Apr-2011  matt Fix sense of KASSERTMSGs
 1.2.14.1  21-Apr-2010  matt sync to netbsd-5
 1.2.12.6  11-Aug-2010  yamt sync with head.
 1.2.12.5  11-Mar-2010  yamt sync with head
 1.2.12.4  18-Jul-2009  yamt sync with head.
 1.2.12.3  20-Jun-2009  yamt sync with head
 1.2.12.2  04-May-2009  yamt sync with head.
 1.2.12.1  14-Sep-2008  yamt file siisata.c was added on branch yamt-nfs-mp on 2009-05-04 08:12:44 +0000
 1.2.8.1  23-Jul-2009  jym Sync with HEAD.
 1.2.4.5  28-Sep-2009  snj Pull up following revision(s) (requested by jakllsch in ticket #1023):
sys/dev/ata/satafis_subr.c: revision 1.3
sys/dev/ata/satafisvar.h: revision 1.2
sys/dev/ic/siisata.c: revision 1.7
sys/dev/ic/siisatareg.h: revision 1.4
Further corrections for siisata.
Reset ch_status and ch_error at the beginning of any operation.
The chip only writes the RDH FIS to the SRAM when the error bit is
set in a RDH FIS (per the datasheet). Thus, satafis_sdb_parse() is
replaced with satafis_rhd_parse(). A valid FIS type field seems to
not be written to the SRAM, so don't bother checking it for the
correct magic.
Additionally, append 2009 to copyright year set, and remove
obsolete CVS Id lines from when this was in my repository.
 1.2.4.4  28-Sep-2009  snj Pull up following revision(s) (requested by jakllsch in ticket #1023):
sys/dev/ic/siisata.c: revision 1.6
Correct various siisata bugs, some old, some new.
- Move clearing of interrupts to before atastart() is called in the
xfer interrupt handler. Should fix kern/41579.
- Using cv_timedwait(9) is not possible in code that can be called from
interrupt context, fall back to DELAY(9).
- Correctly poll Port Slot Status register for soft reset PRBs.
- Only use the Recive Transfer Count register on reads, when it is valid.
- Activate PRBs in a way that takes the whole physical address into account,
even when the PRB is beyond 4GiB.
- consistently use DELAY(9)
- Use DELAY() constants in completion polling loops that are consistent with
the loop count limit. (i.e. timeout in 10 rather than 100 seconds)
 1.2.4.3  28-Sep-2009  snj Pull up following revision(s) (requested by jakllsch in ticket #1023):
sys/dev/ic/siisata.c: revision 1.5
Use PRO_PS and PRO_PCS correctly.
From Wolfgang Stukenbrock as part of kern/41579.
While here, remove a line of whitespace, and add an else case to
the ATAPI command length toggle.
 1.2.4.2  28-Sep-2009  snj Pull up following revision(s) (requested by jakllsch in ticket #1023):
sys/dev/ic/siisata.c: revision 1.4
make this build w/o SIISATA_DEBUG
 1.2.4.1  28-Sep-2009  snj Pull up following revision(s) (requested by jakllsch in ticket #1023):
sys/dev/ic/siisata.c: revision 1.3
sys/dev/ic/siisatareg.h: revision 1.3
sys/dev/ic/siisatavar.h: revision 1.3
sys/dev/pci/files.pci: revision 1.315
sys/dev/pci/siisata_pci.c: revision 1.3
A few changes for siisata(4):
- Support detachment. From KIYOHARA Takashi.
- Add PCI detachment functionality (albeit not very interesting when
the bus can not yet be rescanned).
- Rework interrupt handlers to reduce near-duplicate code.
Borrowed from ahcisata(4).
- Attempt to make polled I/O work. Untested.
- Fix formatting of some messages.
- For always-polled commands, disable interrupt
at slot level rather than port level.
- Instead of busy-waiting indefinitely for completion of some commands
move on after 31 seconds. Use cv_timedwait(9) instead of DELAY(9).
- Use abstracted SATA FIS code.
- Enable use of disks that don't respond with the standard signature.
 1.9.4.2  05-Mar-2011  rmind sync with head
 1.9.4.1  30-May-2010  rmind sync with head
 1.9.2.2  17-Aug-2010  uebayasi Sync with HEAD.
 1.9.2.1  30-Apr-2010  uebayasi Sync with HEAD.
 1.13.4.1  17-Feb-2011  bouyer Sync with HEAD
 1.13.2.1  06-Jun-2011  jruoho Sync with HEAD.
 1.15.6.2  02-Jun-2012  mrg sync to latest -current.
 1.15.6.1  29-Apr-2012  mrg sync to latest -current.
 1.15.2.3  22-May-2014  yamt sync with head.

for a reference, the tree before this commit was tagged
as yamt-pagecache-tag8.

this commit was splitted into small chunks to avoid
a limitation of cvs. ("Protocol error: too many arguments")
 1.15.2.2  30-Oct-2012  yamt sync with head
 1.15.2.1  23-May-2012  yamt sync with head.
 1.22.2.4  03-Dec-2017  jdolecek update from HEAD
 1.22.2.3  20-Aug-2014  tls Rebase to HEAD as of a few days ago.
 1.22.2.2  23-Jun-2013  tls resync from head
 1.22.2.1  20-Nov-2012  tls Resync to 2012-11-19 00:00:00 UTC
 1.26.2.1  28-Aug-2013  rmind sync with head
 1.27.6.4  28-Aug-2017  skrll Sync with HEAD
 1.27.6.3  05-Feb-2017  skrll Sync with HEAD
 1.27.6.2  05-Oct-2016  skrll Sync with HEAD
 1.27.6.1  29-May-2016  skrll Sync with HEAD
 1.28.2.3  26-Apr-2017  pgoyette Sync with HEAD
 1.28.2.2  07-Jan-2017  pgoyette Sync with HEAD. (Note that most of these changes are simply $NetBSD$
tag issues.)
 1.28.2.1  04-Nov-2016  pgoyette Sync with HEAD
 1.30.4.38  19-Sep-2017  jdolecek replace all remaining tsleep()/wakeup() calls with condition variables, or
calls to ata_delay(), as appropriate; change ata_delay() to require the
channel lock on entry, and pass the lock to kpause() for unlocking while
sleeping
 1.30.4.37  10-Sep-2017  jdolecek refactor code so that xfer c_start() hook is called with channel mutex held,
and hence the controller submit code no longer relies on spl

tested all the affected drivers - wdc (via piixide), ahci, mvsata, siisata,
both disk and atapi I/O
 1.30.4.36  15-Aug-2017  jakllsch Use ata_queue_free() instead of free() to deallocate chp->ch_queue during detach.
 1.30.4.35  12-Aug-2017  jdolecek do not reset drive after successful NCQ error recovery
 1.30.4.34  11-Aug-2017  jdolecek replace magic 3100 with locall defined WDC_RESET_WAIT
 1.30.4.33  04-Aug-2017  jdolecek prb_control need to add (or) PRB_CF_INTERRUPT_MASK for polled commands,
rather that set - the field may be nonzero for ATAPI or for protocol override
 1.30.4.32  04-Aug-2017  jdolecek restore part of what was removed in 1.30.4.30 - the success of command
needs to be driven by PSS so that it works also for polled commands, apparently
PR_PIS_CMDCMPL is not set in that case; now do error handling again only when
PSS_ATTENTION is set

this fixes timeout for polled commands like standby on shutdown,
and (ehm ehm), READ LOG EXT on NCQ error recovery
 1.30.4.31  01-Aug-2017  jdolecek fix logic bug in processing of finished commands - mask of active
commands can change during the loop as c_intr() callback can queue
new commands, so the interrupt routine should only mark as finished
those which were actually active before the loop started; otherwise
the code marked as finished commands which were just started, and
being executed by HBA, leading to all sorts of data corruption

while here mark the active mask volatile, as it is modified from
interrupt context

this fixes for good the random crashes, short reads, and fatal command
errors which I've been tracing down for past couple weeks

thanks to Jonathan (jakllsch@) for testing, and a script to easily
triggered the condition, and led to this bug being finally found and squashed
 1.30.4.30  01-Aug-2017  jdolecek adjust code to be closer to HEAD to it's easier to compare and find
regressions, undoing some changes which were actually not necessary
 1.30.4.29  30-Jul-2017  jdolecek undo debug code
 1.30.4.28  30-Jul-2017  jdolecek adjust error recovery to similar shape as ahcisata; also switch to using
siisata_reset_channel(), as that seems more reliably get the HBA to running
state again after some errors

besides this, change several places checking PORT_READY to use
siisata_reinit_port() and properly timeout - seen several cases
where it would just loop there indefinitely on some errors with no
way to get into ddb and no error message, due to the tight DELAY() loop
 1.30.4.27  19-Jul-2017  jdolecek forced commit to get into history - previous commit removed also
the siisata-specific downgrade of SATA channel speed on CRC, as it
doesn't really fit with error/state not being available after
c_intr(); as noted this handling should be in generic code, and
it's overly harsh to do this after single error anyway, particularly
since there is no way to get back
 1.30.4.26  19-Jul-2017  jdolecek convert over to new error handling world order:
- switch to ata_timeout()
- stop using ch_status/ch_error for passing state/error, stop setting
ATACH_IRQ_WAIT in ch_flags; pass the state via the last parameter
to c_intr() routine
- add NCQ recovery and KILL_REQUEUE
- only call atastart() in c_intr() if there was no error

several siisata specific tweaks:
- improve reset to better handle PM - need to reset couple more registers
- add timeouts for unbusy wait - ATA_DELAY (10s)
- siisata_bio_complete() do not use PRSO_RTC for byte count for NCQ transfers,
they never return partial reads; and that register might contain some random
junk, at least that's the case with ahcisata cmdh_prdbc
 1.30.4.25  27-Jun-2017  jdolecek need to explicitely call siisata_timeout() also for polled bio command when
it times out to clean up; this should avoid the 'polled command has been
queued' panic from wddump()
 1.30.4.24  27-Jun-2017  jdolecek attend error paths, more strict asserts and code consistency

- atastart() and ata_kill_pending() now KASSERT() that all xfers on queue
have same channel
- inactive xfers are killed via new reason KILL_GONE_INACTIVE, controller
code must not call any resource deactivation in that case
- c_intr() must call ata_waitdrain_xfer_check() as first thing, and must not
further touch any xfer structures on exit path; any resource cleanup
is supposed to be done in c_kill_xfer()
- c_kill_xfer() should never call atastart()
- ata_waitdrain_check() removed, replaced by ata_waitdrain_xfer_check()
- ATA_DRIVE_WAITDRAIN handling converted to use condvar
- removed unused ata_c callback
 1.30.4.23  26-Jun-2017  jdolecek when reducing DELAY(), it's necessary to appropriately increase number
of iteration, or command can timeout too soon

adjust also siisata_atapi_start() to use DELAY(100) for the polled command,
mostly for consistency, ATAPI devices are quite slow so likely won't have
real effect
 1.30.4.22  24-Jun-2017  jdolecek reduce the polling interval also for siisata_cmd_start()
 1.30.4.21  23-Jun-2017  jdolecek fix dump for siisata(4) to work - need to call drv_done() callback in order to
not leak xfers

while here, reduce the DELAY() for polled bio to make it go much faster,
same value as used in ahcisata(4)

needs also rev. 1.252 src/sys/arch/x86/x86/pmap.c to not trigger the
assertion, the pmap.c fix committed only on HEAD
 1.30.4.20  23-Jun-2017  jdolecek ata/TODO.ncq
 1.30.4.19  21-Jun-2017  jdolecek change ata_queue_hwslot_to_xfer() and ata_queue_get_active_xfer() to take
ata_channel instead of ata_queue as parameter, and lock the channel while
traversing the queue
 1.30.4.18  20-Jun-2017  jdolecek remove ata queue downsizing - every device, attached to the same channel,
uses slots according to it's own limits

wdc code changed to expect maximum one active xfer, and not check number
of openings in the channel; this is to facilitate using wdc functions
for e.g. handling of atapi commands for drivers which support both ATAPI
and NCQ

siisata(4) part, including fix to hang on drive probe (missing ata_free_xfer())
 1.30.4.17  19-Jun-2017  jdolecek add ata_channel lock, use it to protect queue manipulation (only that for now);
add ata_channel_detach() to destroy the locks

change ata_get_xfer() so that it can wait for xfer, convert all on-stack
xfer code to use the blocking variant

fix siisata_reset_drive() to use polled reset and not try ata_activate_xfer(),
convert drive probe code also over from slot0 XXX to ata_get_xfer()

drive reset and PMP now works on siisata(4) too; changes tested also
on piixide(4), ahci(4), mvsata(4)
 1.30.4.16  16-Jun-2017  jdolecek adjust reset channel and dump paths
- channel reset now always kills active transfer, even on dump path, but
now doesn't touch the queued waiting transfers; also kill_xfer hook is
always called, so that HBA can free any private xfer resources and thus
the dump request has chance to work
- kill_xfer routines now always call ata_deactivate_xfer(); added KASSERT()s
to ata_free_xfer() to expect deactivated xfer
- when called during channel reset before dump, ata_kill_active() drops
any queued waiting transfers without processing
- do not (re)queue any transfers in wddone() when dumping
- kill AT_RST_NOCMD flag

This should also hopefully fix the 'polled command has been queued' panic
as reported in:
PR kern/11811 by John Hawkinson
PR kern/47041 by Taylor R Campbell
PR kern/51979 by Martin Husemann

dump tested working with piixide(4) and ahci(4). mvsata(4) dump times out,
but otherwise tested working, will be fixed separately. siisata(4) mechanically
changed and not tested.
 1.30.4.15  13-Jun-2017  jakllsch Add NCQ support to siisata(4).

There are still issues that need to be address before I consider this
mergable.
 1.30.4.14  24-Apr-2017  jakllsch Merge HEAD.
 1.30.4.13  24-Apr-2017  jakllsch Merge HEAD.
 1.30.4.12  24-Apr-2017  jakllsch Merge HEAD.
 1.30.4.11  23-Apr-2017  jakllsch Allocate a full compliment of queue slots for each channel.
 1.30.4.10  23-Apr-2017  jakllsch Use ata_kill_active() in siisata_reset_channel() so as to ensure all
in-flight xfers are taken care of.
 1.30.4.9  23-Apr-2017  jakllsch Fix inverted ata_waitdrain_xfer_check() logic in siisata_atapi_complete().
 1.30.4.8  22-Apr-2017  jakllsch Another one missed in previous.
 1.30.4.7  22-Apr-2017  jakllsch 3rd xfer interrupt argument fix change missed in previous.
 1.30.4.6  22-Apr-2017  jakllsch Don't use the third argument of the xfer interrupt functions to pass the slot number in siisata(4).

This (abuse) is redundant because we are now storing the slot in the xfer structure.
 1.30.4.5  19-Apr-2017  jdolecek adjust ata code to support more than one active command, including the
timeout handling, add support for NCQ commands

move probe for NCQ and number of tags to middle layer, negotiate mutual
support between drive and controller

implement NCQ support in ahci(4)
 1.30.4.4  15-Apr-2017  jdolecek pass also ata_command via ata_xfer, callers of ata_exec_command() is now
responsible for allocation/disposal of the structure

change code to allocate ata_xfer for commands on stack same way as previously
the ata_command were, using c_slot 0; adjust asserts so that it would allow
several xfers with same c_slot, as long as only one such transfer is active
at a time
 1.30.4.3  15-Apr-2017  jdolecek make ata_xfer's allocated as part of ata_queue and make it include ata_bio;
they are pre-allocated on attach and ata_get_xfer() now never sleep, drop the
pool

modify wd(4) to file the bio requests using the xfers and hence
make it possible to have more than one active I/O request in flight;
ata_bio callback doesn't need to allocate any memory any more,
require it to never return ATACMD_TRY_AGAIN

move lp, badsect, multi from ata_bio to ata_drive_datas, as they are per-drive,
not per transfer

drop unused drv atac_claim_hw/atac_free_hw hooks, and also drop again ata_bio
c_hwslot
 1.30.4.2  11-Apr-2017  jdolecek fix to not access active_xfer directly
 1.30.4.1  10-Apr-2017  jdolecek ATA infrastructure improvements to eventually support more outstanding
commands

patch by Matt Thomas
 1.35.6.11  21-Oct-2018  jdolecek decouple siisata_reset_channel() from siisata_reinit_port(); the former
now needs channel lock, but we don't have it in siisata_init_port()
during attach

instead call siisata_reset_channel() when siisata_reinit_port() fails,
and ignore the error during attach
 1.35.6.10  15-Oct-2018  jdolecek change the SATA/NCQ recovery to run in the atabus thread
 1.35.6.9  11-Oct-2018  jdolecek refactor shared parts of the SATA error recovery into new function
ata_recovery_resume() and use for ahcisata/siisata/mvsata, also replace
per-controller hold/unhold with generic version

move the shared recovery code into separate file ata_recovery.c
 1.35.6.8  07-Oct-2018  jdolecek call atastart() when ATA command completes without timeout or error, similar
to AHCI
 1.35.6.7  04-Oct-2018  jdolecek further channel locking pass for reset
 1.35.6.6  03-Oct-2018  jdolecek change channel reset and drive reset for all ATA controllers to always
run via thread, and with channel lock held the whole time; the queue is
frozen while reset is pending

for this repurpose ata_reset_channel() into new ata_thread_run()

also adjust some device printfs to not leak xfer pointer, and avoid
aprint_* for non-autoconf messages
 1.35.6.5  22-Sep-2018  jdolecek separate ata_xfer slot allocation and the memory allocation, so that
there can be more queued xfers than number of supported slots by controller,
and use a pool instead of custom pre-allocation

primarily to help PR kern/52614

remove no longer needed custom wd(4) logic for flush cache

switch also wd(4) trim/suspend/setcache/wdioctlstrategy to sleep waiting
for the memory, they are all called from process context and this
avoids spurious failures
 1.35.6.4  17-Sep-2018  jdolecek move ATAPI-only members of ata_xfer to an union struct to further save space
 1.35.6.3  17-Sep-2018  jdolecek move low-level protocol handlers hooks from ata_xfer to separate struct,
initialized statically

primarily to reduce ata_xfer struct size, but also improves readibility,
and enforces consistency
 1.35.6.2  01-Sep-2018  jdolecek only call ata_deactivate_xfer() once completely done with the active
xfer in controller code (i.e. after bus_dmamap_sync() et.al.), so that
the command slot is safe to be reused immediatelly after deactivate
 1.35.6.1  31-Aug-2018  jdolecek refactor ata_xfer to be just dumb structure; move all callouts/condvars out

retry callout to wd(4); reset callout and the active/cmd finish condvars
to channel queue; change code using the condvars so it works if there
are multiple waiters

simplify the async wait code for cmds, replace ata_wait_xfer()/ata_wake_xfer()
with ata_wait_cmd()

fix the callout_invoking/ack race handling code for timeouts to
actually have chance to work; change mvsata(4) to use generic timeout func

towards resolution of kern/52614
 1.35.4.4  21-Apr-2020  martin Sync with HEAD
 1.35.4.3  13-Apr-2020  martin Mostly merge changes from HEAD upto 20200411
 1.35.4.2  08-Apr-2020  martin Merge changes from current as of 20200406
 1.35.4.1  10-Jun-2019  christos Sync with HEAD
 1.35.2.1  26-Nov-2018  pgoyette Sync with HEAD, resolve a couple of conflicts
 1.39.4.1  30-Dec-2022  martin Pull up following revision(s) (requested by tsutsui in ticket #1557):

sys/dev/ic/ahcisata_core.c: revision 1.83
sys/dev/ic/ahcisata_core.c: revision 1.102
sys/dev/ata/ata.c: revision 1.164
sys/dev/ata/ata_wdc.c: revision 1.115
sys/dev/ata/ata_recovery.c: revision 1.4
sys/dev/ic/siisata.c: revision 1.42
sys/dev/ic/wdc.c: revision 1.308
sys/dev/ic/mvsata.c: revision 1.56
sys/dev/scsipi/atapi_wdc.c: revision 1.138
sys/dev/ic/siisata.c: revision 1.49
sys/dev/ata/atavar.h: revision 1.105
sys/dev/ata/wd.c: revision 1.460
sys/dev/ata/ata.c: revision 1.155
sys/dev/ata/wd.c: revision 1.462
sys/dev/ata/atavar.h: revision 1.109
sys/dev/ata/satapmp_subr.c: revision 1.16
sys/dev/ic/wdc.c: revision 1.299
sys/dev/ic/ahcisata_core.c: revision 1.93
sys/dev/ata/ata_wdc.c: revision 1.120
sys/dev/ic/wdcvar.h: revision 1.100
sys/dev/scsipi/atapi_wdc.c: revision 1.141
sys/dev/ic/mvsata.c: revision 1.61
sys/dev/usb/umass_isdata.c (apply patch)

drop wd lock in wdstart1() before calling the ata_bio hook; when called
from ata thread context, that can still need to sleep for wdc attachments
in wdcwait()

fix use-after-free for ata xfer on bio submission found by KASAN
driver ata_bio hooks read parts of the xfer after ata_exec_xfer()
call in order to determine return value, change so that the hook
doesn't return any value - callers do not care already,
as all I/O requests are asynchronous

this problem was uncovered by recent change for wd(4) to not hold
wd mutex during ata_bio call, the interrupt for the xfer might
thus actually fire immediately

adjust also ata_exec_command driver hooks similarily - remove all
completion and waiting logic from drivers, upper layer ata code
using AT_WAIT/AT_POLL changed to call ata_wait_cmd() itself
PR kern/55169 by Nick Hudson

Function declaration formating whitespace consistency. NFCI.

PR kern/56403
Fix kernel freeze for wdc(4) variants with ATAC_CAP_NOIRQ:

(1) Change ata_xfer_ops:c_poll from void to int function. When it returns
ATAPOLL_AGAIN, let ata_xfer_start() iterate itself again.
(2) Let wdc_ata_bio_poll() return ATAPOLL_AGAIN until ATA_ITSDONE is
achieved.

A similar change has been made for mvsata(4) (see mvsata_bio_poll()),
and no functional changes for other devices.

This is how the drivers worked before jdolecek-ncq branch was merged.
Note that this changes are less likely to cause infinite recursion:

(1) wdc_ata_bio_intr() called from wdc_ata_bio_poll() asserts ATA_ITSDONE
in its error handling paths via wdc_ata_bio_done().
(2) Return value from c_start (= wdc_ata_bio_start()) is checked in
ata_xfer_start().

Therefore, errors encountered in ata_xfer_ops:c_poll and c_start routines
terminate the recursion for wdc(4). The situation is similar for mvsata(4).

Still, there is a possibility where ata_xfer_start() takes long time to
finish a normal operation. This can result in a delayed response for lower
priority interrupts. But, I've never observed such a situation, even when
heavy thrashing takes place for swap partition in wd(4).
"Go ahead" by jdolecek@.
 1.40.2.1  29-Feb-2020  ad Sync with head.
 1.41.4.1  20-Apr-2020  bouyer Sync with HEAD
 1.43.2.2  03-Apr-2021  thorpej Sync with HEAD.
 1.43.2.1  03-Jan-2021  thorpej Sync w/ HEAD.
 1.46.2.1  02-Apr-2021  thorpej config_found_ia() -> config_found() w/ CFARG_IATTR.
 1.47.8.1  04-Aug-2021  thorpej Adapt to CFARGS().

RSS XML Feed