]> git.ipfire.org Git - thirdparty/kernel/linux.git/commitdiff
selftests: pci_endpoint: Skip BAR subrange test on -ENOSPC
authorChristian Bruel <christian.bruel@foss.st.com>
Tue, 7 Apr 2026 12:04:08 +0000 (14:04 +0200)
committerBjorn Helgaas <bhelgaas@google.com>
Wed, 8 Apr 2026 19:41:39 +0000 (14:41 -0500)
In pci-epf-test.c, set the STATUS_NO_RESOURCE status bit if
pci_epc_set_bar() returns -ENOSPC.  This status bit is used to indicate
that there are not enough inbound window resources to allocate the
subrange.

In pci_endpoint_test.c, return -ENOSPC instead of -EIO when
STATUS_NO_RESOURCE is set.

In pci_endpoint_test.c, skip the BAR subrange test if -ENOSPC, i.e., there
are not enough inbound window resources to run the test.

Signed-off-by: Christian Bruel <christian.bruel@foss.st.com>
[mani: commit log]
Signed-off-by: Manivannan Sadhasivam <mani@kernel.org>
[bhelgaas: squash related commits]
Signed-off-by: Bjorn Helgaas <bhelgaas@google.com>
Reviewed-by: Niklas Cassel <cassel@kernel.org>
Reviewed-by: Frank Li <Frank.Li@nxp.com>
Reviewed-by: Koichiro Den <den@valinux.co.jp>
Link: https://patch.msgid.link/20260407-skip-bar_subrange-tests-if-enospc-v4-1-6f2e65f2298c@foss.st.com
Link: https://patch.msgid.link/20260407-skip-bar_subrange-tests-if-enospc-v4-2-6f2e65f2298c@foss.st.com
Link: https://patch.msgid.link/20260407-skip-bar_subrange-tests-if-enospc-v4-3-6f2e65f2298c@foss.st.com
drivers/misc/pci_endpoint_test.c
drivers/pci/endpoint/functions/pci-epf-test.c
tools/testing/selftests/pci_endpoint/pci_endpoint_test.c

index 38679dfb1f9b67d92a2d0d90a1a58b72ea9fde6b..dbd017cabbb92394c20d07c478518f5fefe2067e 100644 (file)
@@ -61,6 +61,7 @@
 #define STATUS_BAR_SUBRANGE_SETUP_FAIL         BIT(15)
 #define STATUS_BAR_SUBRANGE_CLEAR_SUCCESS      BIT(16)
 #define STATUS_BAR_SUBRANGE_CLEAR_FAIL         BIT(17)
+#define STATUS_NO_RESOURCE                     BIT(18)
 
 #define PCI_ENDPOINT_TEST_LOWER_SRC_ADDR       0x0c
 #define PCI_ENDPOINT_TEST_UPPER_SRC_ADDR       0x10
@@ -480,7 +481,7 @@ static int pci_endpoint_test_bar_subrange_cmd(struct pci_endpoint_test *test,
 
        status = pci_endpoint_test_readl(test, PCI_ENDPOINT_TEST_STATUS);
        if (status & fail_bit)
-               return -EIO;
+               return (status & STATUS_NO_RESOURCE) ? -ENOSPC : -EIO;
 
        if (!(status & ok_bit))
                return -EIO;
index 14e61ebe1f116ce04789b6f4c3e965296701ec53..7eb94dffac2d193477a43decd7b952c78b99eb5f 100644 (file)
@@ -54,6 +54,7 @@
 #define STATUS_BAR_SUBRANGE_SETUP_FAIL         BIT(15)
 #define STATUS_BAR_SUBRANGE_CLEAR_SUCCESS      BIT(16)
 #define STATUS_BAR_SUBRANGE_CLEAR_FAIL         BIT(17)
+#define STATUS_NO_RESOURCE             BIT(18)
 
 #define FLAG_USE_DMA                   BIT(0)
 
@@ -901,6 +902,8 @@ static void pci_epf_test_bar_subrange_setup(struct pci_epf_test *epf_test,
        ret = pci_epc_set_bar(epc, epf->func_no, epf->vfunc_no, bar);
        if (ret) {
                dev_err(&epf->dev, "pci_epc_set_bar() failed: %d\n", ret);
+               if (ret == -ENOSPC)
+                       status |= STATUS_NO_RESOURCE;
                bar->submap = old_submap;
                bar->num_submap = old_nsub;
                kfree(submap);
index c417fb3a198b2d92c3060938c23807cc8bea5573..588d75c97ad181d2f8e84c9b86b865439152e20d 100644 (file)
@@ -88,6 +88,8 @@ TEST_F(pci_ep_bar, BAR_SUBRANGE_TEST)
                SKIP(return, "Subrange map is not supported");
        if (ret == -ENOBUFS)
                SKIP(return, "BAR is reserved");
+       if (ret == -ENOSPC)
+               SKIP(return, "Not enough inbound windows");
        EXPECT_FALSE(ret) TH_LOG("Test failed for BAR%d", variant->barno);
 }