From: Nicholas Piggin <[email protected]> ahci-test double-maps the hba bar in the pending_callback test. Unmap it first, to keep iomaps balanced.
Cc: Michael S. Tsirkin <[email protected]> Cc: Marcel Apfelbaum <[email protected]> Cc: Akihiko Odaki <[email protected]> Reviewed-by: Akihiko Odaki <[email protected]> Reviewed-by: Fabiano Rosas <[email protected]> Signed-off-by: Nicholas Piggin <[email protected]> Signed-off-by: Jishnu Warrier <[email protected]> Signed-off-by: Utkarsh Verma <[email protected]> --- tests/qtest/ahci-test.c | 6 ++++++ tests/qtest/libqos/ahci.c | 11 +++++++++++ tests/qtest/libqos/ahci.h | 2 ++ 3 files changed, 19 insertions(+) diff --git a/tests/qtest/ahci-test.c b/tests/qtest/ahci-test.c index c49aa61862..043a916fdd 100644 --- a/tests/qtest/ahci-test.c +++ b/tests/qtest/ahci-test.c @@ -85,6 +85,8 @@ static void verify_state(AHCIQState *ahci, uint64_t hba_old) uint64_t hba_base; AHCICommandHeader cmd; + g_assert_cmphex(ahci->hba_bar.addr, ==, hba_old); + ahci_fingerprint = qpci_config_readl(ahci->dev, PCI_VENDOR_ID); g_assert_cmphex(ahci_fingerprint, ==, ahci->fingerprint); @@ -198,6 +200,7 @@ static void ahci_shutdown(AHCIQState *ahci) { QOSState *qs = ahci->parent; + ahci_pci_disable(ahci); ahci_clean_mem(ahci); free_ahci_device(ahci->dev); g_free(ahci); @@ -1457,7 +1460,9 @@ static void test_reset(void) CMD_READ_DMA_EXT, CMD_WRITE_DMA_EXT); ahci_set(ahci, AHCI_GHC, AHCI_GHC_HR); + stop_ahci_device(ahci); ahci_clean_mem(ahci); + start_ahci_device(ahci); } ahci_shutdown(ahci); @@ -1523,6 +1528,7 @@ static void test_reset_pending_callback(void) sleep(1); /* Start again. */ + stop_ahci_device(ahci); ahci_clean_mem(ahci); ahci_pci_enable(ahci); ahci_hba_enable(ahci); diff --git a/tests/qtest/libqos/ahci.c b/tests/qtest/libqos/ahci.c index 50b63239c2..a709558aac 100644 --- a/tests/qtest/libqos/ahci.c +++ b/tests/qtest/libqos/ahci.c @@ -206,6 +206,11 @@ void ahci_pci_enable(AHCIQState *ahci) } +void ahci_pci_disable(AHCIQState *ahci) +{ + stop_ahci_device(ahci); +} + /** * Map BAR5/ABAR, and engage the PCI device. */ @@ -218,6 +223,12 @@ void start_ahci_device(AHCIQState *ahci) qpci_device_enable(ahci->dev); } +void stop_ahci_device(AHCIQState *ahci) +{ + /* Unmap AHCI's ABAR */ + qpci_iounmap(ahci->dev, ahci->hba_bar); +} + /** * Test and initialize the AHCI's HBA memory areas. * Initialize and start any ports with devices attached. diff --git a/tests/qtest/libqos/ahci.h b/tests/qtest/libqos/ahci.h index 6d861c79ee..f098c91b47 100644 --- a/tests/qtest/libqos/ahci.h +++ b/tests/qtest/libqos/ahci.h @@ -580,7 +580,9 @@ void ahci_clean_mem(AHCIQState *ahci); QPCIDevice *get_ahci_device(QTestState *qts, uint32_t *fingerprint); void free_ahci_device(QPCIDevice *dev); void ahci_pci_enable(AHCIQState *ahci); +void ahci_pci_disable(AHCIQState *ahci); void start_ahci_device(AHCIQState *ahci); +void stop_ahci_device(AHCIQState *ahci); void ahci_hba_enable(AHCIQState *ahci); /* Port Management */ -- 2.55.0
