questions about AHCI/SATA
Posted: Sat Jul 09, 2022 10:51 pm
Hello everyone, have some questions about AHCI/SATA that I didn't find good answers for from the AHCI, SATA and ATA spec drafts.
1. Wiki's ATA article says "On some drives it is necessary to "manually" flush the hardware write cache after every write command.", is this still the case for SATA drives?
2. What are the differences between DMA and PIO cmds? Doesn't data always move inside data FISes on the sata bus and are DMAed to/from system memory by the HBA? There might be minor differences like PIO vs. DMA setup FISes but are there good reasons to use one vs. the other?
3. What should the direction (command header DW0 bit 6) be for cmds that don't move data between the device and system memory such as 0xE7? Is there a spec with these details?
4. Are the bits in port command issue (PxCI) register ORed together with the value written by the CPU? Or can the CPU clear bits there as well by writing 0?
5. I assume that the HBA doesn't detect data hazard among different cmds in different slots and the software is supposed to keep track of that?
If that's true, how should software enforce the ordering?
If the software always sets 1 bit at a time in CI (in quick succession without waiting for the the set bits to clear), would the order of completion be the same and the cmd whose bit is set earlier always completes earlier?
What if the software sets multiple bits in CI with a single one write? Does the HBA have any preference or the commands could complete in any order? There's a priority field in queued cmds but it's either high or low and seems to be quite coarse grained for a total of 32 slots?
Thanks!
1. Wiki's ATA article says "On some drives it is necessary to "manually" flush the hardware write cache after every write command.", is this still the case for SATA drives?
2. What are the differences between DMA and PIO cmds? Doesn't data always move inside data FISes on the sata bus and are DMAed to/from system memory by the HBA? There might be minor differences like PIO vs. DMA setup FISes but are there good reasons to use one vs. the other?
3. What should the direction (command header DW0 bit 6) be for cmds that don't move data between the device and system memory such as 0xE7? Is there a spec with these details?
4. Are the bits in port command issue (PxCI) register ORed together with the value written by the CPU? Or can the CPU clear bits there as well by writing 0?
5. I assume that the HBA doesn't detect data hazard among different cmds in different slots and the software is supposed to keep track of that?
If that's true, how should software enforce the ordering?
If the software always sets 1 bit at a time in CI (in quick succession without waiting for the the set bits to clear), would the order of completion be the same and the cmd whose bit is set earlier always completes earlier?
What if the software sets multiple bits in CI with a single one write? Does the HBA have any preference or the commands could complete in any order? There's a priority field in queued cmds but it's either high or low and seems to be quite coarse grained for a total of 32 slots?
Thanks!