History log of /freebsd-10-stable/sys/dev/ahci/ahci.c
Revision Date Author Comments
# 315813 23-Mar-2017 mav

MFC r311305 (by asomers):
Always null-terminate ccb_pathinq.(sim_vid|hba_vid|dev_name)

The sim_vid, hba_vid, and dev_name fields of struct ccb_pathinq are
fixed-length strings. AFAICT the only place they're read is in
sbin/camcontrol/camcontrol.c, which assumes they'll be null-terminated.
However, the kernel doesn't null-terminate them. A bunch of copy-pasted code
uses strncpy to write them, and doesn't guarantee null-termination. For at
least 4 drivers (mpr, mps, ciss, and hyperv), the hba_vid field actually
overflows. You can see the result by doing "camcontrol negotiate da0 -v".

This change null-terminates those fields everywhere they're set in the
kernel. It also shortens a few strings to ensure they'll fit within the
16-character field.

PR: 215474
Reported by: Coverity
CID: 1009997 1010000 1010001 1010002 1010003 1010004 1010005
CID: 1331519 1010006 1215097 1010007 1288967 1010008 1306000
CID: 1211924 1010009 1010010 1010011 1010012 1010013 1010014
CID: 1147190 1010017 1010016 1010018 1216435 1010020 1010021
CID: 1010022 1009666 1018185 1010023 1010025 1010026 1010027
CID: 1010028 1010029 1010030 1010031 1010033 1018186 1018187
CID: 1010035 1010036 1010042 1010041 1010040 1010039


# 313446 08-Feb-2017 mav

MFC r312767: Partially workaround ASMedia HBA error recovery.

Taking closer look on my ASM1062 I found that it has bunch of issues around
error recovery: reported wrong CCS, failed commands reported as completed,
READ LOG EXT times out after NCQ error. This patch workarounds first two
problems, that were making ATAPI devices close to unusable on these HBAs.


# 311883 10-Jan-2017 mav

MFC r309251: Process port interrupt even is PxIS register is zero.

ASMedia ASM1062 AHCI chips with some fancy firmware handling PMP inside
seems sometimes forgeting to set bits in PxIS, causing command timeouts.
Removal of this check fixes the issue by the theoretical cost of slightly
higher CPU usage in some odd cases, but this is what Linux does too.


# 305798 14-Sep-2016 mav

MFC r305536: Fix channel initialization in FBS mode.

Due to reading initialized variable, FIS receive area was always allocated
as 256 bytes, suitable for command-based switching, instead of 4096 bytes,
required for FIS-based switching. This caused memory corruption in case of
MFC r305536: Fix channel initialization in FBS mode.

Due to reading initialized variable, FIS receive area was always allocated
as 256 bytes, suitable for command-based switching, instead of 4096 bytes,
required for FIS-based switching. This caused memory corruption in case of
port multipliers used on FBS-capable HBAs (Marvell).


# 304414 18-Aug-2016 mav

MFC r302947: In AHCI_IRQ_MODE_AFTER mode do not clear interrupts below.

This is probably a NOP change since IS register is not activery used for
interrupts below the shared, but it looked odd to clear interrupts we did
not handle.


# 304413 18-Aug-2016 mav

MFC r302946:
Do not consider the last interrupt shared if there are enough interrupts
for all channels.


# 302791 13-Jul-2016 mav

MFC r302402: Fix ahci(4) driver attach to controller with 32 ports.

Incorrect sign expansion in variables that supposed to be a bit fields
caused infinite loop. Fixing this allows system properly detect maximal
possible 32 devices configured on AHCI HBA of BHyVe. That case did not
happen in a wild before due to lack of hardware AHCI HBAs with 32 ports.


# 281140 06-Apr-2015 mav

MFC r280393: Reduce priority of ATA/SATA drivers.

Legacy ata(4) -> BUS_PROBE_LOW_PRIORITY; more functional ahci(4), siis(4),
mvs(4) -> BUS_PROBE_DEFAULT; BUS_PROBE_VENDOR leave for vendor drivers.


# 279918 12-Mar-2015 mav

MFC r271146,271201,271207,271261,271457,272606,277100,277126,278034,279320,
279573: Sync AHCI driver with HEAD.

Due to code reorganization in r271146 and many previous reordered merges it
is problematic to merge those revisions separately.


# 279917 12-Mar-2015 mav

MFC r270833 (by imp):
We were returning 20 bytes as the FIS size to send, but only
initializing 16. Initialize all 20 so we don't send garbage in the
Auxiliary register. The SATA standard mandates a 5 dword length for
the Host to Device FIS.


# 278405 08-Feb-2015 marius

MFC: r276344

- Const'ify the ahci_ids table.
- Use DEVMETHOD_END.
- Use NULL instead of 0 for pointers.


# 277061 12-Jan-2015 smh

MFC r276012:
Add a constant AHCI_MAX_IRQS removing magic number

MFC r276013:
Clamp ahci max irq's to AHCI_MAX_IRQS

MFC r276016:
Return the error from ahci_setup_interrupt in ahci_attach

MFC r276019:
style (9) nits

Sponsored by: Multiplay


# 276268 26-Dec-2014 ian

MFC r274188, r274189:
DMA tag alignment should be 1 (not 0) when a device can dma at any address.


# 276020 21-Dec-2014 smh

MFC r272223:
Prevent possible use after free in ahci direct mode

Sponsored by: Multiplay


# 275982 21-Dec-2014 smh

MFC r274819:
Prevent overflow issues in timeout processing

MFC r274852:
Fix build with asr driver

Sponsored by: Multiplay


# 275439 03-Dec-2014 mav

MFC r275101:
Add bunch of PCI IDs of Intel Wildcat Point (9 Series) chipsets.


# 271709 17-Sep-2014 mav

MFC r271403: Add PCI ID for Promise TX8660 8-port 3Gbps HBA.

This device reports RAID subclass, but appears to be AHCI compatible.

Submitted by: Yuri Perejilin <yuri@rivera.ru>
Approved by: re (gjb)


# 271523 13-Sep-2014 mav

MFC r271163, 271196:
Invert AHCI_Q_NOBSYRES quirk meaning, waiting for readiness by default.

I gave up to update list of Marvell chips that require this quirk.
The final nail was growing number of PCIe/M.2 SSDs where Marvell
chips have PCI IDs of different vendors.

Approved by: re (delphij)


# 266070 14-May-2014 ian

MFC r260161, r260163, r260165, r260166, r260189

Add polarity and level support to ARM GIC

Do not attach to PCI bridges in AHCI driver

Use only mapped BIOs on ARM

Fix race condition in DELAY for SP804 timer.


# 265430 06-May-2014 mav

MFC r264610:
Correct AMD chipsets identification.


# 265428 06-May-2014 mav

MFC r260830:
Add ID for one more ASMedia AHCI-compatible controller.


# 260387 06-Jan-2014 scottl

MFC Alexander Motin's direct dispatch, multi-queue, and finer-grained
locking support for CAM

r256826:
Fix several target mode SIMs to not blindly clear ccb_h.flags field of
ATIO CCBs. Not all CCB flags there belong to them.

r256836:
Remove hard limit on number of BIOs handled with one ATA TRIM request.

r256843:
Merge CAM locking changes from the projects/camlock branch to radically
reduce lock congestion and improve SMP scalability of the SCSI/ATA stack,
preparing the ground for the coming next GEOM direct dispatch support.

r256888:
Unconditionally acquire periph reference on CCB allocation failure.

r256895:
Fix memory and references leak due to unfreed path.

r256960:
Move CAM_UNQUEUED_INDEX setting to the last moment and under the periph lock.
This fixes race condition with cam_periph_ccbwait(), causing use-after-free.

r256975:
Minor (mostly cosmetical) addition to r256960.

r257054:
Some microoptimizations for da and ada drivers:
- Replace ordered_tag_count counter with single flag;
- From da remove outstanding_cmds counter, duplicating pending_ccbs list;
- From da_softc remove unused links field.

r257482:
Fix lock recursion, triggered by `smartctl -a /dev/adaX`.

r257501:
Make getenv_*() functions and respectively TUNABLE_*_FETCH() macros not
allocate memory and so not require sleepable environment. getenv() has
already used on-stack temporary storage, so just use it more rationally.
getenv_string() receives buffer as argument, so don't need another one.

r257914:
Some CAM locks polishing:
- Fix LOR and possible lock recursion when handling high-power commands.
Introduce new lock to protect left power quota and list of frozen devices.
- Correct locking around xpt periph creation.
- Remove seems never used XPT_FLAG_OPEN xpt periph flag.

Again, Netflix assisted with testing the merge, but all of the credit goes
to Alexander and iX Systems.

Submitted by: mav
Sponsored by: iX Systems


# 260353 05-Jan-2014 mav

MFC r258173:
Add few more minor parts of DevSleep support from AHCI 1.3.1 proposal.


# 260348 05-Jan-2014 mav

MFC r258162:
Add some more IDs for Intel ATA, AHCI and USB controllers.


# 281140 06-Apr-2015 mav

MFC r280393: Reduce priority of ATA/SATA drivers.

Legacy ata(4) -> BUS_PROBE_LOW_PRIORITY; more functional ahci(4), siis(4),
mvs(4) -> BUS_PROBE_DEFAULT; BUS_PROBE_VENDOR leave for vendor drivers.


# 279918 12-Mar-2015 mav

MFC r271146,271201,271207,271261,271457,272606,277100,277126,278034,279320,
279573: Sync AHCI driver with HEAD.

Due to code reorganization in r271146 and many previous reordered merges it
is problematic to merge those revisions separately.


# 279917 12-Mar-2015 mav

MFC r270833 (by imp):
We were returning 20 bytes as the FIS size to send, but only
initializing 16. Initialize all 20 so we don't send garbage in the
Auxiliary register. The SATA standard mandates a 5 dword length for
the Host to Device FIS.


# 278405 08-Feb-2015 marius

MFC: r276344

- Const'ify the ahci_ids table.
- Use DEVMETHOD_END.
- Use NULL instead of 0 for pointers.


# 277061 12-Jan-2015 smh

MFC r276012:
Add a constant AHCI_MAX_IRQS removing magic number

MFC r276013:
Clamp ahci max irq's to AHCI_MAX_IRQS

MFC r276016:
Return the error from ahci_setup_interrupt in ahci_attach

MFC r276019:
style (9) nits

Sponsored by: Multiplay


# 276268 26-Dec-2014 ian

MFC r274188, r274189:
DMA tag alignment should be 1 (not 0) when a device can dma at any address.


# 276020 21-Dec-2014 smh

MFC r272223:
Prevent possible use after free in ahci direct mode

Sponsored by: Multiplay


# 275982 21-Dec-2014 smh

MFC r274819:
Prevent overflow issues in timeout processing

MFC r274852:
Fix build with asr driver

Sponsored by: Multiplay


# 275439 03-Dec-2014 mav

MFC r275101:
Add bunch of PCI IDs of Intel Wildcat Point (9 Series) chipsets.


# 271709 17-Sep-2014 mav

MFC r271403: Add PCI ID for Promise TX8660 8-port 3Gbps HBA.

This device reports RAID subclass, but appears to be AHCI compatible.

Submitted by: Yuri Perejilin <yuri@rivera.ru>
Approved by: re (gjb)


# 271523 13-Sep-2014 mav

MFC r271163, 271196:
Invert AHCI_Q_NOBSYRES quirk meaning, waiting for readiness by default.

I gave up to update list of Marvell chips that require this quirk.
The final nail was growing number of PCIe/M.2 SSDs where Marvell
chips have PCI IDs of different vendors.

Approved by: re (delphij)


# 266070 14-May-2014 ian

MFC r260161, r260163, r260165, r260166, r260189

Add polarity and level support to ARM GIC

Do not attach to PCI bridges in AHCI driver

Use only mapped BIOs on ARM

Fix race condition in DELAY for SP804 timer.


# 265430 06-May-2014 mav

MFC r264610:
Correct AMD chipsets identification.


# 265428 06-May-2014 mav

MFC r260830:
Add ID for one more ASMedia AHCI-compatible controller.


# 260387 06-Jan-2014 scottl

MFC Alexander Motin's direct dispatch, multi-queue, and finer-grained
locking support for CAM

r256826:
Fix several target mode SIMs to not blindly clear ccb_h.flags field of
ATIO CCBs. Not all CCB flags there belong to them.

r256836:
Remove hard limit on number of BIOs handled with one ATA TRIM request.

r256843:
Merge CAM locking changes from the projects/camlock branch to radically
reduce lock congestion and improve SMP scalability of the SCSI/ATA stack,
preparing the ground for the coming next GEOM direct dispatch support.

r256888:
Unconditionally acquire periph reference on CCB allocation failure.

r256895:
Fix memory and references leak due to unfreed path.

r256960:
Move CAM_UNQUEUED_INDEX setting to the last moment and under the periph lock.
This fixes race condition with cam_periph_ccbwait(), causing use-after-free.

r256975:
Minor (mostly cosmetical) addition to r256960.

r257054:
Some microoptimizations for da and ada drivers:
- Replace ordered_tag_count counter with single flag;
- From da remove outstanding_cmds counter, duplicating pending_ccbs list;
- From da_softc remove unused links field.

r257482:
Fix lock recursion, triggered by `smartctl -a /dev/adaX`.

r257501:
Make getenv_*() functions and respectively TUNABLE_*_FETCH() macros not
allocate memory and so not require sleepable environment. getenv() has
already used on-stack temporary storage, so just use it more rationally.
getenv_string() receives buffer as argument, so don't need another one.

r257914:
Some CAM locks polishing:
- Fix LOR and possible lock recursion when handling high-power commands.
Introduce new lock to protect left power quota and list of frozen devices.
- Correct locking around xpt periph creation.
- Remove seems never used XPT_FLAG_OPEN xpt periph flag.

Again, Netflix assisted with testing the merge, but all of the credit goes
to Alexander and iX Systems.

Submitted by: mav
Sponsored by: iX Systems


# 260353 05-Jan-2014 mav

MFC r258173:
Add few more minor parts of DevSleep support from AHCI 1.3.1 proposal.


# 260348 05-Jan-2014 mav

MFC r258162:
Add some more IDs for Intel ATA, AHCI and USB controllers.