From b4a31737679576dc8aa6de43d3c10bfad7d3f57e Mon Sep 17 00:00:00 2001 From: Koichiro Den Date: Mon, 16 Feb 2026 00:03:34 +0900 Subject: selftests: pci_endpoint: Skip doorbell test when unsupported PCITEST_DOORBELL may return -EOPNOTSUPP when the endpoint does not advertise CAP_DYNAMIC_INBOUND_MAPPING. Treat this like other optional capabilities and skip the doorbell test instead of reporting a failure. Suggested-by: Niklas Cassel Signed-off-by: Koichiro Den Signed-off-by: Manivannan Sadhasivam Reviewed-by: Niklas Cassel Link: https://patch.msgid.link/20260215150334.3391943-4-den@valinux.co.jp --- tools/testing/selftests/pci_endpoint/pci_endpoint_test.c | 2 ++ 1 file changed, 2 insertions(+) (limited to 'tools/testing') diff --git a/tools/testing/selftests/pci_endpoint/pci_endpoint_test.c b/tools/testing/selftests/pci_endpoint/pci_endpoint_test.c index eecb776c33af..e0dbbb2af8c7 100644 --- a/tools/testing/selftests/pci_endpoint/pci_endpoint_test.c +++ b/tools/testing/selftests/pci_endpoint/pci_endpoint_test.c @@ -276,6 +276,8 @@ TEST_F(pcie_ep_doorbell, DOORBELL_TEST) ASSERT_EQ(0, ret) TH_LOG("Can't set AUTO IRQ type"); pci_ep_ioctl(PCITEST_DOORBELL, 0); + if (ret == -EOPNOTSUPP) + SKIP(return, "Doorbell test is not supported"); EXPECT_FALSE(ret) TH_LOG("Test failed for Doorbell\n"); } TEST_HARNESS_MAIN -- cgit v1.2.3 From e022f0c72c7f67fe79de03e71d839418073490a5 Mon Sep 17 00:00:00 2001 From: Niklas Cassel Date: Thu, 12 Mar 2026 14:02:38 +0100 Subject: selftests: pci_endpoint: Skip reserved BARs Running a test against a reserved BAR will result in the pci-epf-test driver returning -ENOBUFS. Make sure that the pci_endpoint_test selftest will return skip instead of failure or success for reserved BARs. Signed-off-by: Niklas Cassel Signed-off-by: Manivannan Sadhasivam Tested-by: Manikanta Maddireddy Tested-by: Koichiro Den Reviewed-by: Manikanta Maddireddy Reviewed-by: Frank Li Link: https://patch.msgid.link/20260312130229.2282001-22-cassel@kernel.org --- tools/testing/selftests/pci_endpoint/pci_endpoint_test.c | 4 ++++ 1 file changed, 4 insertions(+) (limited to 'tools/testing') diff --git a/tools/testing/selftests/pci_endpoint/pci_endpoint_test.c b/tools/testing/selftests/pci_endpoint/pci_endpoint_test.c index e0dbbb2af8c7..c417fb3a198b 100644 --- a/tools/testing/selftests/pci_endpoint/pci_endpoint_test.c +++ b/tools/testing/selftests/pci_endpoint/pci_endpoint_test.c @@ -67,6 +67,8 @@ TEST_F(pci_ep_bar, BAR_TEST) pci_ep_ioctl(PCITEST_BAR, variant->barno); if (ret == -ENODATA) SKIP(return, "BAR is disabled"); + if (ret == -ENOBUFS) + SKIP(return, "BAR is reserved"); EXPECT_FALSE(ret) TH_LOG("Test failed for BAR%d", variant->barno); } @@ -84,6 +86,8 @@ TEST_F(pci_ep_bar, BAR_SUBRANGE_TEST) SKIP(return, "BAR is test register space"); if (ret == -EOPNOTSUPP) SKIP(return, "Subrange map is not supported"); + if (ret == -ENOBUFS) + SKIP(return, "BAR is reserved"); EXPECT_FALSE(ret) TH_LOG("Test failed for BAR%d", variant->barno); } -- cgit v1.2.3 From 1d3225cb5d82680143ffd705088199917ceafd76 Mon Sep 17 00:00:00 2001 From: Christian Bruel Date: Tue, 7 Apr 2026 14:04:08 +0200 Subject: selftests: pci_endpoint: Skip BAR subrange test on -ENOSPC 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 [mani: commit log] Signed-off-by: Manivannan Sadhasivam [bhelgaas: squash related commits] Signed-off-by: Bjorn Helgaas Reviewed-by: Niklas Cassel Reviewed-by: Frank Li Reviewed-by: Koichiro Den 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 | 3 ++- drivers/pci/endpoint/functions/pci-epf-test.c | 3 +++ tools/testing/selftests/pci_endpoint/pci_endpoint_test.c | 2 ++ 3 files changed, 7 insertions(+), 1 deletion(-) (limited to 'tools/testing') diff --git a/drivers/misc/pci_endpoint_test.c b/drivers/misc/pci_endpoint_test.c index 38679dfb1f9b..dbd017cabbb9 100644 --- a/drivers/misc/pci_endpoint_test.c +++ b/drivers/misc/pci_endpoint_test.c @@ -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; diff --git a/drivers/pci/endpoint/functions/pci-epf-test.c b/drivers/pci/endpoint/functions/pci-epf-test.c index 14e61ebe1f11..7eb94dffac2d 100644 --- a/drivers/pci/endpoint/functions/pci-epf-test.c +++ b/drivers/pci/endpoint/functions/pci-epf-test.c @@ -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); diff --git a/tools/testing/selftests/pci_endpoint/pci_endpoint_test.c b/tools/testing/selftests/pci_endpoint/pci_endpoint_test.c index c417fb3a198b..588d75c97ad1 100644 --- a/tools/testing/selftests/pci_endpoint/pci_endpoint_test.c +++ b/tools/testing/selftests/pci_endpoint/pci_endpoint_test.c @@ -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); } -- cgit v1.2.3