SPRUHZ7K August 2015 – April 2024 AM5706 , AM5708 , AM5716 , AM5718 , AM5718-HIREL
After user software instantiates the CL structures in host system memory, it must maintain them appropriately. The command list is advanced when the BSY, DRQ, and ERR bits of a serial ATA device task file are cleared, which is communicated through a D2H register FIS to HBA port. The HBA port 0 hardware clears the corresponding to the i-th completed command: SATA_PxCI [i] CI (SATA_PxCI [TAG] CI for NCQ) bit to notify user software that the next command FIS can be advanced into the CL. The software then builds the command slot components: CH fields, command table, and associated PRD data descriptors in system memory. Software asserts the SATA_PxCI[i+1] CI (or SATA_PxCI[TAG] CI bit for an NCQ indicated command) to activate the prepared CL command, which is possible only when SATA_PxCMD[0] ST = 0x1. The nonqueued commands in the CL are processed in ascending order of slots (linear processing). The SATA_PxCMD [12:8]CCS read-only field indicates the CL index of the command currently being issued by the HBA port.
The processing of NCQ command slots invokes additional register update/check steps. Before setting the SATA_PxCI[TAG] CI bit to 0b1 and posting an active NCQ command to the SATA HBA port, software must indicate an NCQ outstanding command at the position defined by the SATA peripheral device queue TAG by setting SATA_PxSACT[TAG] DS = 0x1. After the queued command is posted, the peripheral SATA device sends a Set Device Bits FIS to the HBA port to clear the SATA_PxSACT bits corresponding to the successfully completed NCQ commands.
Command-list processing is initially triggered by software setting SATA_PxCMD[0] ST = 0x1, which requires certain conditions to be satisfied.
There are some restrictions to setting SATA_PxCMD[0] ST to 0x1. For more information, see the AHCI specification (revision 1.1).
The SATA controller is capable of command list override (CLO) operation. CLO is activated by setting SATA_PxCMD[3] CLO = 0b1, which is expected only when SATA_PxCMD[0] ST = 0x0 (that is, the command list is not processed by the HBA) to avoid HBA-indeterminate behavior. As a consequence of a CLO operation, the SATA_PxTFD register STS_DRQ and STS_BSY flags are cleared. For example, CLO is necessary when the DRQ and BSY flags cannot be cleared by HBA before issuing a software reset (because of some hang condition). For more information on CLO behavior, see the AHCI standard specification.