]> git.proxmox.com Git - mirror_qemu.git/commit
hw/ide/ahci: write D2H FIS when processing NCQ command
authorNiklas Cassel <niklas.cassel@wdc.com>
Fri, 9 Jun 2023 14:08:39 +0000 (16:08 +0200)
committerJohn Snow <jsnow@redhat.com>
Thu, 7 Sep 2023 02:48:04 +0000 (22:48 -0400)
commit2967dc8209dd27b61a6ab7bad78cf7c6ec58ddb4
treec6609c7809f936675f289ad69c17dd7ab74aad84
parentc3461c6264a7c8ca15b117e91fe5da786924a784
hw/ide/ahci: write D2H FIS when processing NCQ command

The way that BUSY + PxCI is cleared for NCQ (FPDMA QUEUED) commands is
described in SATA 3.5a Gold:

11.15 FPDMA QUEUED command protocol
DFPDMAQ2: ClearInterfaceBsy
"Transmit Register Device to Host FIS with the BSY bit cleared to zero
and the DRQ bit cleared to zero and Interrupt bit cleared to zero to
mark interface ready for the next command."

PxCI is currently cleared by handle_cmd(), but we don't write the D2H
FIS to the FIS Receive Area that actually caused PxCI to be cleared.

Similar to how ahci_pio_transfer() calls ahci_write_fis_pio() with an
additional parameter to write a PIO Setup FIS without raising an IRQ,
add a parameter to ahci_write_fis_d2h() so that ahci_write_fis_d2h()
also can write the FIS to the FIS Receive Area without raising an IRQ.

Change process_ncq_command() to call ahci_write_fis_d2h() without
raising an IRQ (similar to ahci_pio_transfer()), such that the FIS
Receive Area is in sync with the PxTFD shadow register.

E.g. Linux reads status and error fields from the FIS Receive Area
directly, so it is wise to keep the FIS Receive Area and the PxTFD
shadow register in sync.

Signed-off-by: Niklas Cassel <niklas.cassel@wdc.com>
Message-id: 20230609140844.202795-4-nks@flawful.org
Signed-off-by: John Snow <jsnow@redhat.com>
hw/ide/ahci.c