[LTP] [PATCH 2/2] tpci: accept ENOMEM resource failure with virtio-pci

Krzysztof Kozlowski krzysztof.kozlowski@canonical.com
Fri Jun 18 15:05:36 CEST 2021


Assigning the memory prefetch resource to virtio-pci might fail on VM
guests.  For example on Oracle cloud instance (describing itself as
"Hardware name: QEMU Standard PC (i440FX + PIIX, 1996), BIOS 1.4.1
12/03/2020"):

    test_pci   76  TFAIL  :  tpci.c:73: PCI bus 00 slot 20 : Test-case '12'

In dmesg:

    ltp_tpci: test-case 12
    ltp_tpci: assign resources
    ltp_tpci: assign resource #0
    ltp_tpci: name = 0000:00:04.0, flags = 262401, start 0xc000, end 0xc03f
    ltp_tpci: assign resource #1
    ltp_tpci: name = 0000:00:04.0, flags = 262656, start 0xc1010000, end 0xc1010fff
    ltp_tpci: assign resource #2
    ltp_tpci: name = 0000:00:04.0, flags = 0, start 0x0, end 0x0
    ltp_tpci: assign resource #3
    ltp_tpci: name = 0000:00:04.0, flags = 0, start 0x0, end 0x0
    ltp_tpci: assign resource #4
    ltp_tpci: name = 0000:00:04.0, flags = 538190348, start 0x800004000, end 0x800007fff
    virtio-pci 0000:00:04.0: BAR 4: no space for [mem size 0x00004000 64bit pref]
    virtio-pci 0000:00:04.0: BAR 4: failed to assign [mem size 0x00004000 64bit pref]

Signed-off-by: Krzysztof Kozlowski <krzysztof.kozlowski@canonical.com>

---

Found the failure on multiple different kernels in different cloud
providers (Oracle, AWS, Azure):
https://bugs.launchpad.net/ubuntu/+source/linux/+bug/1878389
---
 .../device-drivers/pci/tpci_kernel/ltp_tpci.c     | 15 ++++++++++++---
 1 file changed, 12 insertions(+), 3 deletions(-)

diff --git a/testcases/kernel/device-drivers/pci/tpci_kernel/ltp_tpci.c b/testcases/kernel/device-drivers/pci/tpci_kernel/ltp_tpci.c
index f2d4a4ba497c..41462d4ead6d 100644
--- a/testcases/kernel/device-drivers/pci/tpci_kernel/ltp_tpci.c
+++ b/testcases/kernel/device-drivers/pci/tpci_kernel/ltp_tpci.c
@@ -108,8 +108,9 @@ static int probe_pci_dev(unsigned int bus, unsigned int slot)
 	if (!dev || !dev->driver)
 		return -ENODEV;
 
-	prk_info("found pci_dev '%s', bus %u, devfn %u",
-		pci_name(dev), bus, slot);
+	prk_info("found pci_dev '%s', driver '%s', bus %u, devfn %u",
+		pci_name(dev), (dev->driver) ? dev->driver->name : "",
+		bus, slot);
 
 	ltp_pci.dev = dev;
 	ltp_pci.bus = dev->bus;
@@ -444,7 +445,15 @@ static int test_assign_resources(void)
 			r->flags & IORESOURCE_PREFETCH) {
 			ret = pci_assign_resource(dev, i);
 			prk_info("assign resource to '%d', ret '%d'", i, ret);
-			rc |= (ret < 0 && ret != -EBUSY) ? TFAIL : TPASS;
+			if (dev->driver && !strncmp(dev->driver->name, "virtio-pci",
+						    strlen("virtio-pci"))) {
+				if (ret < 0 && ret != -EBUSY && ret != -ENOMEM)
+					rc |= TFAIL;
+				else
+					rc |= TPASS;
+			} else {
+				rc |= (ret < 0 && ret != -EBUSY) ? TFAIL : TPASS;
+			}
 		}
 	}
 
-- 
2.27.0



More information about the ltp mailing list