@@ -409,13 +409,19 @@ void ahci_port_check_error(AHCIQState *ahci, AHCICommand *cmd)
uint8_t port = cmd->port;
uint32_t reg;
- /* The upper 9 bits of the IS register all indicate errors. */
- reg = ahci_px_rreg(ahci, port, AHCI_PX_IS);
- reg &= ~cmd->interrupts;
- reg >>= 23;
- g_assert_cmphex(reg, ==, 0);
+ /* If expecting TF error, ensure that TFES is set. */
+ if (cmd->errors) {
+ reg = ahci_px_rreg(ahci, port, AHCI_PX_IS);
+ ASSERT_BIT_SET(reg, AHCI_PX_IS_TFES);
+ } else {
+ /* The upper 9 bits of the IS register all indicate errors. */
+ reg = ahci_px_rreg(ahci, port, AHCI_PX_IS);
+ reg &= ~cmd->interrupts;
+ reg >>= 23;
+ g_assert_cmphex(reg, ==, 0);
+ }
- /* The Sata Error Register should be empty. */
+ /* The Sata Error Register should be empty, even when expecting TF error. */
reg = ahci_px_rreg(ahci, port, AHCI_PX_SERR);
g_assert_cmphex(reg, ==, 0);