From: "Denis V. Lunev" <[email protected]>
test_write_engine_stop_in_flight() resumes the suspended backend write
and goes straight on to restart the command engine and read the second
sector back. Whether the write has retired by then is a race. While it
is still outstanding the drive is busy, and handle_cmd() drops a
command that arrives in that state instead of queueing it. Nothing
retries the drop, so the PxCI slot stays set and no D2H FIS is posted.
ahci_command_wait() polls both with no timeout, so the test deadlocks
until the harness kills it.
Drain the port before issuing the read, so the abandoned write has
retired and the engine is idle. Host load stretches the gap between the
resume and the write completing, which is why the deadlock only shows
up on a loaded machine.
Fixes: d05ae87e7a6a ("tests/qtest/ahci: regression test for a PIO write vs.
engine stop")
Signed-off-by: Denis V. Lunev <[email protected]>
Reviewed-by: Fabiano Rosas <[email protected]>
Signed-off-by: Fabiano Rosas <[email protected]>
---
tests/qtest/ahci-test.c | 6 ++++++
1 file changed, 6 insertions(+)
diff --git a/tests/qtest/ahci-test.c b/tests/qtest/ahci-test.c
index eb8d239997..c49aa61862 100644
--- a/tests/qtest/ahci-test.c
+++ b/tests/qtest/ahci-test.c
@@ -1912,6 +1912,12 @@ static void test_write_engine_stop_in_flight(void)
qtest_qemu_io(ahci->parent->qts, "drive0", "resume wr");
+ /*
+ * Retire the abandoned write. handle_cmd() drops a command that arrives
+ * while the drive is still busy and nothing retries it.
+ */
+ g_free(qtest_hmp(ahci->parent->qts, "qemu-io drive0 \"aio_flush\""));
+
/* Round-trip through the device to confirm qemu is still alive. */
ahci_px_rreg(ahci, port, AHCI_PX_TFD);
--
2.53.0