AHCI(4)

πŸ“¦
version 15.1 Β· 2 versions
, in freebsd 14.5, freebsd 15.1, nixpkgs unstable

✨ AHCI(4) ✨

the Serial ATA Advanced Host Controller Interface driver, bestie πŸ’…

okay so like, this is the ahci driver manual page from the Kernel Interfaces Manual, and I'm gonna walk you through it because it's honestly iconic and you deserve to know ✨


🌸 NAME 🌸

ahci β€” Serial ATA Advanced Host Controller Interface driver

like, it's the driver that talks to your SATA stuff, no cap 🫢


πŸŽ€ SYNOPSIS πŸŽ€

so to compile this driver into the kernel (very main character energy), you put these lines in your kernel configuration file:

device pci
device scbus
device ahci

alternatively, if you wanna load it as a module at boot time (lowkey easier), you put this line in loader.conf(5):

ahci_load="YES"

the following tunables are settable from the loader(8):

⭐ hint.ahci.X.msi

controls Message Signaled Interrupts (MSI) usage by the specified controller. the values are:

  • 0 β€” MSI disabled;
  • 1 β€” single MSI vector used, if supported;
  • 2 β€” multiple MSI vectors used, if supported (this is the default, slay);

πŸ¦‹ hint.ahci.X.ccc

controls Command Completion Coalescing (CCC) usage by the specified controller. a non-zero value enables CCC and defines maximum time (in ms) a request can wait for interrupt, if there are some more requests present on controller queue. CCC reduces number of context switches on systems with many parallel requests, but ngl it can decrease disk performance on some workloads due to additional command latency. it's giving tradeoffs πŸ’€

🌈 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 number of MSI interrupts supported and number of implemented SATA ports. iykyk

πŸ“ hint.ahci.X.em

controls whether the driver should implement virtual enclosure management device on top of SGPIO or other interface. default value depends on controller capabilities. very demure, very mindful ✨

πŸ’œ hint.ahcich.X.pm_level

controls SATA interface Power Management for the specified channel, allowing some power to be saved at the cost of additional command latency. the possible values are:

  • 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 port becomes idle;
  • 3 β€” host initiates SLUMBER PM state transition every time port becomes idle.
  • 4 β€” driver initiates PARTIAL PM state transition 1ms after port becomes idle;
  • 5 β€” driver initiates SLUMBER PM state transition 125ms after port becomes idle.

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

note that interface Power Management complicates device presence detection. a manual bus reset/rescan may be needed after device hot-plug, unless hardware implements Cold Presence Detection. you've been warned bestie πŸ™ˆ

🧚 hint.ahcich.X.sata_rev

setting to nonzero value limits maximum SATA revision (speed). values 1, 2 and 3 are respectively 1.5, 3 and 6Gbps. love that for us πŸ’…

πŸ‘‘ hw.ahci.force

setting to nonzero value forces driver attach to some known AHCI-capable chips even if they are configured for legacy IDE emulation. default is 1. it's giving persistence πŸ”₯


πŸ’– DESCRIPTION πŸ’–

okay so this driver provides the CAM(4) subsystem with native access to the SATA ports of AHCI-compatible controllers. every SATA port found is represented to CAM as a separate bus with one target, or, if 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. it's literally the whole ecosystem 🫢

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

that's a lot of features and honestly? we're obsessed πŸ’…βœ¨


driver supports "LED" enclosure management messages, defined by the AHCI. when supported by hardware, it allows to control per-port activity, locate and fault LEDs via the led(4) API or emulated ses(4) device for localization and status reporting purposes. supporting AHCI controllers may transmit that information to the backplane controllers via SGPIO interface. backplane controllers interpret received statuses in some way (IBPI standard) to report them using present indicators. it's giving communication, networking, friendship 🌈


πŸ¦„ HARDWARE πŸ¦„

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

also, in cooperation with atamarvell and atajmicron drivers of ata(4), it supports AHCI part of legacy-PATA + AHCI-SATA combined controllers, such as JMicron JMB36x and Marvell 88SE61xx. teamwork makes the dream work fr 🫢

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 device. it's giving family tree πŸ˜­πŸ’€


πŸŽ€ 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

the LED files, they're iconic ✨


πŸ’… 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. very "block and unblock" energy, we've all been there πŸ™ˆ


πŸ‘‘ SEE ALSO πŸ‘‘

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

go read them bestie, they're all connected 🫢


🌸 HISTORY 🌸

the ahci driver first appeared in FreeBSD 8.0. a classic, a legend, an icon πŸ’…


πŸ¦‹ AUTHORS πŸ¦‹

Alexander Motin <mav@FreeBSD.org>

we love a credited icon πŸ‘‘


and that's the whole thing! this absolute slay of a manpage was brought to you by Debian, dated December 17, 2021 β€” like the whole page is giving vintage but make it fresh βœ¨πŸ’–πŸŽ€

πŸ“¦ where this page comes from