- kvm-scsi-change-buf_size-to-unsigned-int-in-scsi_SG_IO.patch [RHEL-158244] - kvm-scsi-handle-reservation-changes-across-migration.patch [RHEL-158244] - kvm-blkdebug-Add-delay-ns-option.patch [RHEL-190701] - kvm-block-Add-blk_co_start-end_request-and-BDRV_REQ_NO_Q.patch [RHEL-190701] - kvm-block-Add-flags-parameter-to-blk_-_pdiscard.patch [RHEL-190701] - kvm-ide-Minimal-fix-for-deadlock-between-TRIM-and-drain.patch [RHEL-190701] - kvm-ide-Clean-up-ide_trim_co_entry-to-be-idiomatic-corou.patch [RHEL-190701] - kvm-ide-test-Factor-out-wait_dma_completion.patch [RHEL-190701] - kvm-ide-test-Test-reset-during-TRIM.patch [RHEL-190701] - kvm-spec-Install-qtests-into-qemu-kvm-tests-package.patch [RHEL-190701] - kvm-migration-introduce-MIGRATION_STATUS_FAILING.patch [RHEL-45628] - kvm-s390x-css-limit-number-of-CHPIDs-in-description.patch [RHEL-193033] - kvm-s390x-ioinst-Require-strict-length-and-format-for-SE.patch [RHEL-193033] - kvm-s390x-pci-Shrink-RPCIT-ranges-to-registered-window.patch [RHEL-193033] - kvm-s390x-pci-Tighten-region-detection-for-BAR-read-writ.patch [RHEL-193033] - kvm-s390x-sclp-reject-invalid-write-event-data-headers.patch [RHEL-193033] - kvm-s390x-kvm-clamp-stsi-3.2.2-size.patch [RHEL-193033] - kvm-s390x-sclp-prevent-re-reading-the-sclp-header.patch [RHEL-193033] - kvm-s390x-sclpcpi-check-event-length-field-before-readin.patch [RHEL-193033] - kvm-s390x-css-firm-up-handling-of-chained-TIC-CCWs.patch [RHEL-193033] - Resolves: RHEL-158244 (live migration failed or get failed WSFC test result during WSFC testing [rhel-9.9]) - Resolves: RHEL-190701 (qemu-kvm hung during drain after double pause [rhel-9]) - Resolves: RHEL-45628 (qemu-kvm crashes after kill virtproxyd on destination host during migration [RHEL-9.9]) - Resolves: RHEL-193033 (RHEL9.4 - qemu s390x: interface harding fixes)
182 lines
6.1 KiB
Diff
182 lines
6.1 KiB
Diff
From c693030f7fb450eec077bc4bf4384715aadde0a1 Mon Sep 17 00:00:00 2001
|
|
From: Kevin Wolf <kwolf@redhat.com>
|
|
Date: Tue, 21 Apr 2026 18:11:32 +0200
|
|
Subject: [PATCH 09/20] ide-test: Test reset during TRIM
|
|
|
|
RH-Author: Kevin Wolf <kwolf@redhat.com>
|
|
RH-MergeRequest: 507: ide: Fix deadlock between TRIM and drain
|
|
RH-Jira: RHEL-190701
|
|
RH-Acked-by: German Maglione <None>
|
|
RH-Acked-by: Hanna Czenczek <hreitz@redhat.com>
|
|
RH-Commit: [7/8] 9084a26352311ad7b4faeb9842efdfef5e6c9cdc (kmwolf/centos-qemu-kvm)
|
|
|
|
This is a regression test for the bug fixed in the previous commits, a
|
|
deadlock between the drain issued by an IDE reset and the TRIM state
|
|
machine.
|
|
|
|
Signed-off-by: Kevin Wolf <kwolf@redhat.com>
|
|
Message-ID: <20260421161132.99878-8-kwolf@redhat.com>
|
|
Signed-off-by: Kevin Wolf <kwolf@redhat.com>
|
|
(cherry picked from commit 2fa24e9755994f76f08ea2452215eb50f26f4c21)
|
|
Signed-off-by: Michael Tokarev <mjt@tls.msk.ru>
|
|
Signed-off-by: Kevin Wolf <kwolf@redhat.com>
|
|
---
|
|
tests/qtest/ide-test.c | 95 ++++++++++++++++++++++++++++++++++++++----
|
|
1 file changed, 87 insertions(+), 8 deletions(-)
|
|
|
|
diff --git a/tests/qtest/ide-test.c b/tests/qtest/ide-test.c
|
|
index c6dcb2c074..721e78170b 100644
|
|
--- a/tests/qtest/ide-test.c
|
|
+++ b/tests/qtest/ide-test.c
|
|
@@ -41,8 +41,11 @@
|
|
#define IDE_PCI_FUNC 1
|
|
|
|
#define IDE_BASE 0x1f0
|
|
+#define IDE_BASE2 0x3f6
|
|
#define IDE_PRIMARY_IRQ 14
|
|
|
|
+#define IDE_CTRL_RESET 0x04
|
|
+
|
|
#define ATAPI_BLOCK_SIZE 2048
|
|
|
|
/* How many bytes to receive via ATAPI PIO at one time.
|
|
@@ -99,6 +102,7 @@ enum {
|
|
|
|
CMDF_ABORT = 0x100,
|
|
CMDF_NO_BM = 0x200,
|
|
+ CMDF_NO_WAIT = 0x400,
|
|
};
|
|
|
|
enum {
|
|
@@ -228,21 +232,21 @@ static uint8_t wait_dma_completion(QTestState *qts, QPCIDevice *dev,
|
|
return status;
|
|
}
|
|
|
|
-static int send_dma_request(QTestState *qts, int cmd, uint64_t sector,
|
|
- int nb_sectors, PrdtEntry *prdt, int prdt_entries,
|
|
- void(*post_exec)(QPCIDevice *dev, QPCIBar ide_bar,
|
|
- uint64_t sector, int nb_sectors))
|
|
+static int send_dma_request_dev(QTestState *qts, QPCIDevice *dev,
|
|
+ QPCIBar bmdma_bar, QPCIBar ide_bar, int cmd,
|
|
+ uint64_t sector, int nb_sectors,
|
|
+ PrdtEntry *prdt, int prdt_entries,
|
|
+ void(*post_exec)(QPCIDevice *dev,
|
|
+ QPCIBar ide_bar,
|
|
+ uint64_t sector,
|
|
+ int nb_sectors))
|
|
{
|
|
- QPCIDevice *dev;
|
|
- QPCIBar bmdma_bar, ide_bar;
|
|
uintptr_t guest_prdt;
|
|
size_t len;
|
|
bool from_dev;
|
|
uint8_t status;
|
|
int flags;
|
|
|
|
- dev = get_pci_device(qts, &bmdma_bar, &ide_bar);
|
|
-
|
|
flags = cmd & ~0xff;
|
|
cmd &= 0xff;
|
|
|
|
@@ -308,8 +312,28 @@ static int send_dma_request(QTestState *qts, int cmd, uint64_t sector,
|
|
qpci_io_writeb(dev, bmdma_bar, bmreg_cmd, 0);
|
|
}
|
|
|
|
+ if (flags & CMDF_NO_WAIT) {
|
|
+ return 0;
|
|
+ }
|
|
+
|
|
status = wait_dma_completion(qts, dev, bmdma_bar, ide_bar);
|
|
|
|
+ return status;
|
|
+}
|
|
+
|
|
+static int send_dma_request(QTestState *qts, int cmd, uint64_t sector,
|
|
+ int nb_sectors, PrdtEntry *prdt, int prdt_entries,
|
|
+ void(*post_exec)(QPCIDevice *dev, QPCIBar ide_bar,
|
|
+ uint64_t sector, int nb_sectors))
|
|
+{
|
|
+ QPCIDevice *dev;
|
|
+ QPCIBar bmdma_bar, ide_bar;
|
|
+ uint8_t status;
|
|
+
|
|
+ dev = get_pci_device(qts, &bmdma_bar, &ide_bar);
|
|
+ status = send_dma_request_dev(qts, dev, bmdma_bar, ide_bar,
|
|
+ cmd, sector, nb_sectors, prdt, prdt_entries,
|
|
+ post_exec);
|
|
free_pci_device(dev);
|
|
|
|
return status;
|
|
@@ -457,6 +481,60 @@ static void test_bmdma_trim(void)
|
|
test_bmdma_teardown(qts);
|
|
}
|
|
|
|
+static void test_bmdma_trim_reset(void)
|
|
+{
|
|
+ QTestState *qts;
|
|
+ QPCIDevice *dev;
|
|
+ QPCIBar bmdma_bar, ide_bar, ide_bar2;
|
|
+ uint8_t status;
|
|
+ const uint64_t trim_range[] = {
|
|
+ trim_range_le(0, 2),
|
|
+ trim_range_le(6, 8),
|
|
+ };
|
|
+ size_t len = 512;
|
|
+ uint8_t *buf;
|
|
+ uintptr_t guest_buf;
|
|
+ PrdtEntry prdt[1];
|
|
+
|
|
+ qts = ide_test_start(
|
|
+ "-blockdev file,filename=%s,node-name=img "
|
|
+ "-blockdev blkdebug,image=img,node-name=dbg,discard=unmap,"
|
|
+ "inject-error.0.event=none,inject-error.0.iotype=discard,"
|
|
+ "inject-error.0.errno=0,inject-error.0.delay-ns=1000000 "
|
|
+ "-device ide-hd,drive=dbg,bus=ide.0",
|
|
+ tmp_path[0]);
|
|
+ qtest_irq_intercept_in(qts, "ioapic");
|
|
+
|
|
+ guest_buf = guest_alloc(&guest_malloc, len);
|
|
+ prdt[0].addr = cpu_to_le32(guest_buf),
|
|
+ prdt[0].size = cpu_to_le32(len | PRDT_EOT),
|
|
+
|
|
+ dev = get_pci_device(qts, &bmdma_bar, &ide_bar);
|
|
+ ide_bar2 = qpci_legacy_iomap(dev, IDE_BASE2);
|
|
+
|
|
+ buf = g_malloc(len);
|
|
+
|
|
+ /* TRIM request with two segments */
|
|
+ *((uint64_t *)buf) = trim_range[0];
|
|
+ *((uint64_t *)buf + 1) = trim_range[1];
|
|
+
|
|
+ qtest_memwrite(qts, guest_buf, buf, 2 * sizeof(uint64_t));
|
|
+
|
|
+ send_dma_request_dev(qts, dev, bmdma_bar, ide_bar, CMD_DSM | CMDF_NO_WAIT, 0, 1, prdt,
|
|
+ ARRAY_SIZE(prdt), NULL);
|
|
+
|
|
+ /* Reset the device while the first segment is in flight */
|
|
+ qpci_io_writeb(dev, ide_bar2, 0, IDE_CTRL_RESET);
|
|
+
|
|
+ status = wait_dma_completion(qts, dev, bmdma_bar, ide_bar);
|
|
+ g_assert_cmphex(status, ==, BM_STS_INTR);
|
|
+ assert_bit_clear(qpci_io_readb(dev, ide_bar, reg_status), DF | ERR);
|
|
+
|
|
+ free_pci_device(dev);
|
|
+ g_free(buf);
|
|
+ test_bmdma_teardown(qts);
|
|
+}
|
|
+
|
|
/*
|
|
* This test is developed according to the Programming Interface for
|
|
* Bus Master IDE Controller (Revision 1.0 5/16/94)
|
|
@@ -1138,6 +1216,7 @@ int main(int argc, char **argv)
|
|
|
|
qtest_add_func("/ide/bmdma/simple_rw", test_bmdma_simple_rw);
|
|
qtest_add_func("/ide/bmdma/trim", test_bmdma_trim);
|
|
+ qtest_add_func("/ide/bmdma/trim_reset", test_bmdma_trim_reset);
|
|
qtest_add_func("/ide/bmdma/various_prdts", test_bmdma_various_prdts);
|
|
qtest_add_func("/ide/bmdma/no_busmaster", test_bmdma_no_busmaster);
|
|
|
|
--
|
|
2.52.0
|
|
|