AHCI(4)

πŸ¦‹ AHCI(4) β€” Serial ATA Advanced Host Controller Interface driver πŸ¦‹

okay so real talk: this is ahci(4), and it lives in the Kernel Interfaces Manual. it's the driver that gives you native access to your SATA ports, and honestly? it's kind of a big deal. let's get into it bestie πŸ’–


✨ NAME ✨

ahci β€” Serial ATA Advanced Host Controller Interface driver πŸŽ€


πŸ’« SYNOPSIS πŸ’«

wanna bake this driver right into your kernel? drop these lines in your kernel configuration file, no cap:

device pci
device scbus
device ahci

or, if you'd rather vibe with it as a module at boot time (so much easier fr fr), put this line in loader.conf(5):

ahci_load="YES"

the following tunables are settable from loader(8), and they're the little knobs that change how everything behaves:

  • hint.ahci.X.msi β€” controls Message Signaled Interrupts (MSI) usage by the specified controller. the values are:
    • 0 β€” MSI disabled, we're going old school;
    • 1 β€” single MSI vector used, if supported;
    • 2 β€” multiple MSI vectors used, if supported (this is the default, and it's iconic ✨).
  • hint.ahci.X.ccc β€” controls Command Completion Coalescing (CCC) usage by the specified controller. a non-zero value enables CCC and defines the maximum time (in ms) a request can wait for an interrupt, if there are some more requests present on the controller queue. CCC reduces the number of context switches on systems with many parallel requests, but heads up β€” it can decrease disk performance on some workloads because of the additional command latency. it's giving tradeoff πŸ’….
  • hint.ahci.X.direct β€” controls whether the driver should use direct command completion from interrupt thread(s), or queue them to CAM completion threads. the default value depends on the number of MSI interrupts supported and the number of implemented SATA ports. iykyk.
  • hint.ahcich.X.pm_level β€” controls SATA interface Power Management for the specified channel, which lets you save some power at the cost of additional command latency. possible values:
    • 0 β€” interface Power Management is disabled (default);
    • 1 β€” device is allowed to initiate PM state change, host is passive;
    • 2 β€” host initiates PARTIAL PM state transition every time the port becomes idle;
    • 3 β€” host initiates SLUMBER PM state transition every time the port becomes idle;
    • 4 β€” driver initiates PARTIAL PM state transition 1ms after the port becomes idle;
    • 5 β€” driver initiates SLUMBER PM state transition 125ms after the port becomes idle.

some controllers, such as ICH8, do not implement modes 2 and 3 with NCQ used. because of the artificial entering latency, performance degradation in modes 4 and 5 is much smaller than in modes 2 and 3.

note that interface Power Management complicates device presence detection. a manual bus reset/rescan may be needed after device hot-plug, unless the hardware implements Cold Presence Detection. so like, keep that in mind bestie 😭.
  • hint.ahcich.X.sata_rev β€” setting this to a nonzero value limits the maximum SATA revision (speed). the values 1, 2 and 3 are respectively 1.5, 3 and 6Gbps.
  • hw.ahci.force β€” setting this to a nonzero value forces the driver to attach to some known AHCI-capable chips even if they are configured for legacy IDE emulation. default is 1.

🫢 DESCRIPTION 🫢

this driver provides the CAM(4) subsystem with native access to the SATA ports of AHCI-compatible controllers. every SATA port it finds gets represented to CAM as a separate bus with one target β€” or, if the HBA supports Port Multipliers, 16 targets. most of the bus-management details are handled by the SATA-specific transport of CAM. connected ATA disks are handled by the ATA protocol disk peripheral driver ada(4). ATAPI devices are handled by the SCSI protocol peripheral drivers cd(4), da(4), sa(4), etc.

driver features include support for:

  • Serial ATA and ATAPI devices;
  • Port Multipliers (including FIS-based switching, when supported);
  • hardware command queues (up to 32 commands per port);
  • Native Command Queuing;
  • SATA interface Power Management;
  • device hot-plug;
  • Message Signaled Interrupts.

the driver also supports "LED" enclosure management messages, defined by the AHCI. when supported by hardware, it allows you to control per-port activity, locate and fault LEDs via the led(4) API or an emulated ses(4) device for localization and status reporting purposes. supporting AHCI controllers may transmit that information to the backplane controllers via the SGPIO interface. backplane controllers interpret the received statuses in some way (IBPI standard) to report them using present indicators. slay πŸ’…βœ¨


πŸ”₯ HARDWARE πŸ”₯

the ahci driver supports AHCI compatible controllers having PCI class 1 (mass storage), subclass 6 (SATA) and programming interface 1 (AHCI). yes, all three. periodt.

also, in cooperation with the atamarvell and atajmicron drivers of ata(4), it supports the AHCI part of legacy-PATA + AHCI-SATA combined controllers, such as JMicron JMB36x and Marvell 88SE61xx. iconic combo ngl.

the ahci driver also supports AHCI devices that act as PCI bridges for nvme(4) using Intel Rapid Storage Technology (RST). to use the nvme(4) device, either one must set the SATA mode in the BIOS to AHCI (from RST), or one must accept the performance with RST enabled due to interrupt sharing. FreeBSD will automatically detect AHCI devices with this extension that are in RST mode. when that happens, ahci will attach nvme(4) children to the ahci(4) device. main character energy fr fr πŸ‘‘


πŸŽ€ FILES πŸŽ€

  • /dev/led/ahci*.*.act β€” activity LED device nodes
  • /dev/led/ahci*.*.fault β€” fault LED device nodes
  • /dev/led/ahci*.*.locate β€” locate LED device nodes

πŸ’œ SYSCTL πŸ’œ

dev.ahcich.X.disable_phy

set to 1 to disable the phy for the drive on channel X. set to 0 to enable the phy. useful for turning off troublemakers πŸ™ˆ. also useful for debugging when you need the ada drive to come and go.


🌈 SEE ALSO 🌈

ada(4), ata(4), cam(4), cd(4), da(4), sa(4), ses(4)


⭐ HISTORY ⭐

the ahci driver first appeared in FreeBSD 8.0. a legend from day one, honestly.


πŸ‘‘ AUTHORS πŸ‘‘

Alexander Motin <mav@FreeBSD.org>


and that's the whole page bestie πŸ’– this lil writeup came from the Debian edition, dated August 21, 2019, and it's filed under AHCI(4). now go forth and queue some commands βœ¨πŸ¦‹

πŸ“¦ where this page comes from