summaryrefslogtreecommitdiff
path: root/sys/dev/ic/ahcisata_core.c
AgeCommit message (Collapse)Author
2022-08-01Revert last accidental commits.mlelstv
2022-08-01Also fix shift values for SCT constants.mlelstv
2021-11-19ahcisata(4): Introduce AHCI_QUIRK_EXTRA_DELAY quirk for devices thatrin
need extra delays as done by AHCISATA_EXTRA_DELAY option. Enable this quirk for "C600/X79 AHCI". Also add commented out quirk entries for "Bay Trail SATA (AHCI)" and "Mobile AHCI SATA Controller", for which non-reproducible failures worked around by extra delays have been reported. 500 ms of delays inserted by these option/quirk may be too much. Add AHCISATA_EXTRA_DELAY_MS option to adjust number of delays in ms, like: ---- options AHCISATA_EXTRA_DELAY_MS=200 ---- Thanks prlw1@ and jun@ for testing!
2021-11-10s/endianess/endianness/msaitoh
2021-10-11ahcisata: remove excessive delays from drive probe pathjmcneill
There are a handful of inexplicable 500ms delays introduced to the drive detect path in this driver, slowing boot. They can be re-enabled with options AHCISATA_EXTRA_DELAY, but should not be enabled for normal kernels. If a delay does need to be introduced in these places, the value should either be more carefully selected or the scope limited to hardware that requires the extra delay.
2021-10-05PR kern/56403rin
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@.
2021-09-03revert "make ahcisata(4) work on rk3399 (rockpro64)" from 23-06-2021.mrg
this problem is known to affect more than AHCI, and a more general solution has been commited now.
2021-08-07Merge thorpej-cfargs2.thorpej
2021-06-23make ahcisata(4) work on rk3399 (rockpro64)mrg
on rk3399, a marvell 9230 ahci sata card consistently takes between 1213 and 1216 milliseconds, the ahci spec says this should complete in 1000 or fewer. add a "pcie-reset-ms" uint32 property that ahcisata defaults to 1000 if not set, and the rockchip platform code sets to 2000. ok @jmcneill
2021-04-24Merge thorpej-cfargs branch:thorpej
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?).
2021-03-04Use BUS_ADDR_{LO,HI}32. NFC.skrll
2021-03-04Use __BIT(). NFC.skrll
2021-01-11KNFskrll
2020-12-29Some more whitespace consistency / KNFskrll
2020-12-29Function declaration formating whitespace consistency. NFCI.skrll
2020-12-28Remove the AHCI_QUIRK_SKIP_RESET quirk now that the underlying issue isjmcneill
fixed.
2020-12-28Make sure to ack IS after PxIS when polling and when using multiple MSI-Xjmcneill
messages.
2020-12-27AHCI 1.3.1 section 5.5.3 "Processing Completed Commands" says that wejmcneill
should clear PxIS before IS.IPS.
2020-12-26ahci_intr: use ffs in the port bitmask instead of looping over all 32 bitsjmcneill
2020-12-26AHCI 1.3.1 specification says that it is good practice for system softwarejmcneill
to 'zero-out' the memory allocated and referenced by PxCLB and PxFB.
2020-12-25Trailing whitespaceskrll
2020-12-25Use designated initializers for struct ata_bustypeskrll
2020-12-20Retry clearing WDCTL_RST a few times before giving up. Makes SATA work injmcneill
Solidrun Honeycomb LX2K.
2020-12-19ahci_exec_fis: wait for the correct amount of time when AT_WAIT is setjmcneill
2020-04-13fix use-after-free for ata xfer on bio submission found by KASANjdolecek
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
2020-02-19C99 initializers for scsipi_bustype. No functional change intended.riastradh
2020-01-18Add new AHCI_QUIRK_BADNCQ quick for controllers that have issues withsimonb
NCQ on (some) drives. Enable this quirk for ATI (AMD) SB600/SB700 controllers. Alternate fix for kern/54790 and kern/54855. ok jdolecek@, tested on my SB700 chipset and tsutsui's SB600 chipset.
2019-12-27s/transfered/transferred/msaitoh
2019-12-22When resetting a drive, if the command list is running and CLO is notjmcneill
supported, attempt to stop the drive first and fail gracefully if that fails instead of triggering a KASSERT on DIAGNOSTIC kernels.
2019-09-29Use AHCI_RFIS_SYNC in ahci_cmd_complete() AT_READREG case.jakllsch
Ensures CPU sees the current device to host FIS before parsing.
2019-09-29Use AHCI_CMDTBL_SYNC in ahci_exec_fis() to ensure hardware sees thejakllsch
command FIS.
2019-09-29Ensure cmdh_prdtl is 0 in ahci_do_reset_drive().jakllsch
(I'm probably just being paranoid here.)
2019-04-07If Command List Override is not supported by the controller, the FIS settingbouyer
the WDC_RST bit will fail if the drive already has BSY or DRQ set. In this case, reset the channel and retry the drive reset. With this, the drive reset will succeed after a atactl sleep command on a controller without the CLO feature.
2019-01-18revert rev 1.73 - while it apparently helped Christos case, it re-brokejdolecek
the disk detection on several other systems, so need something else
2019-01-12partially back-off rev. 1.68 - when the drive reset for port 15 fails,jdolecek
on some systems controller isn't actually able to process further commands, it's really necessary to do explicitely reset for drive 0 too towards resolution of PR kern/53307
2018-12-07add optional hook for intr establish when active port is attached, exportjdolecek
ahci_intr_port() in form suitable for interrupt hanlder, and probe for GHC MRSM flag as courtesy for use by the intr hook towards multi-vector MSI/MSI-X support
2018-11-20s/failing/failed/ for the aprint_error()jdolecek
2018-11-20also set WDCTL_4BIT for the softreset, seems this one is actually alsojdolecek
required to fully resolve the problem PR kern/48214 PR kern/53307 PR kern/53524
2018-11-19during SRST (softreset), make a short delay between the RST set andjdolecek
clear; SATA specifies minimum 5 usec for the toggle period, and some controllers (seems usually on AMD motherboards) actually require it this fixes the 'clearing WDCTL_RST failed' error in PR kern/53307 and PR kern/53524 confirmed working on a ASUS Prime A320M-K mainboard by me, and by Patrick Welche on another Ryzen system XXX pullup-8
2018-11-19if softreset during PMP detection fails, disable PMP, reset port and continuejdolecek
with sig detected after the initial COMRESET this does not yet fix the infamous 'clearing WDCTL_RST failed', but at least now the disk is detected and usable when it happens tested on AMD system with ASUS Prime A320M-K, similar to one from PR kern/53524
2018-11-19consistently use the SATA correct 'port %d' instead of 'channel', somejdolecek
whitespace fixes
2018-11-02fix ahci_detach() to count the ports propertly (same as attach), to avoidjdolecek
triggerring panic when disks are plugged to non-adjacent ports - this should fix panic reported by Masanobu SAITOH on current-users also fix different miscounting of ports in ahci_setup_ports() and ahci_reprobe_drives()
2018-10-24detach the controller itself on shutdown; adjust to not detach alreadyjdolecek
detached atabus/channel
2018-10-22Merge jdolecek-ncqfixes branchjdolecek
- 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
2018-09-18fix ata_xfer leak on drive probejdolecek
2018-07-09Avoid undefined behavior of signedness bit shift in ahcisata_core.ckamil
sys/dev/ic/ahcisata_core.c:365:31, left shift of 1 by 31 places cannot be represented in type 'int' sys/dev/ic/ahcisata_core.c:558:16, left shift of 1 by 31 places cannot be represented in type 'int' Detected with Kernel Undefined Behavior Sanitizer. This code could be refactored in future and switched to ISSET(9) API, instead of reinventing the common functionality.
2018-07-08whitespace fixjdolecek
2017-11-11change several of error logs in ahci_intr_port() to use AHCIDEBUG_PRINT()jdolecek
so they don't show unless debugging; e.g. the AHCI_P_IX_TFES seems to be triggered normally by ATAPI with 'Media Change' error adresses 'dmesg spam: ahcisata0 port 1: active 2 is 0x40000001 tfd 0x2051' thread by Stefan Hertenberger on current-users@
2017-10-20move ata_queue_alloc(1) and ata_queue_free() calls to ata_channel_init()jdolecek
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
2017-10-07Merge support for SATA NCQ (Native Command Queueing) from jdolecek-ncq branchjdolecek
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)