'pci_endpoint_test' fails for architectures allowing less than 32 MSI registers and that doesnt support MSI-X, avoid reporting false errors because of out-of-range irqs.
e.g for an EP configured with 8 msi_interrupts and no msix we can have
./pci_endpoint_test -t MSI_TEST
# PASSED: 1 / 1 tests passed. # 1 skipped test(s) detected. Consider enabling relevant config options to improve coverage. # Totals: pass:0 fail:0 xfail:0 xpass:0 skip:1 error:0
instead of
# FAILED: 0 / 1 tests passed # Totals: pass:0 fail:1 xfail:0 xpass:0 skip:0 error:0
An alternative could have been to implement VARIANTs so that the harness runs only the supported tests, but that seems quite heavy considering the huge number of possible interrupts.
Another alternative could also have been to use a new ioctl to get the allocated number of irqs from the driver, but that doesn't seem to be more efficient than just using -EINVAL when the irq is out of range.
thank you for your feedback
Christian Bruel (3): misc: pci_endpoint_test: Skip IRQ tests if irq is out of range misc: pci_endpoint_test: Cleanup extra 0 initialization selftests: pci_endpoint: Skip IRQ test if irq is out of range.
drivers/misc/pci_endpoint_test.c | 14 ++++++-------- .../selftests/pci_endpoint/pci_endpoint_test.c | 4 ++++ 2 files changed, 10 insertions(+), 8 deletions(-)
The pci_endpoint_test tests the 32-bit MSI range. However, the device might not have all vectors configured. For example, if msi_interrupts is 8 in the ep function space or if the MSI Multiple Message Capable value is configured as 4 (maximum 16 vectors). In this case, do not attempt to run the test to avoid timeouts and directly return the error value.
Signed-off-by: Christian Bruel christian.bruel@foss.st.com --- drivers/misc/pci_endpoint_test.c | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-)
diff --git a/drivers/misc/pci_endpoint_test.c b/drivers/misc/pci_endpoint_test.c index 1c156a3f845e..54f66ece25cd 100644 --- a/drivers/misc/pci_endpoint_test.c +++ b/drivers/misc/pci_endpoint_test.c @@ -436,7 +436,11 @@ static int pci_endpoint_test_msi_irq(struct pci_endpoint_test *test, { struct pci_dev *pdev = test->pdev; u32 val; - int ret; + int irq; + + irq = pci_irq_vector(pdev, msi_num - 1); + if (irq < 0) + return irq;
pci_endpoint_test_writel(test, PCI_ENDPOINT_TEST_IRQ_TYPE, msix ? PCITEST_IRQ_TYPE_MSIX : @@ -450,11 +454,7 @@ static int pci_endpoint_test_msi_irq(struct pci_endpoint_test *test, if (!val) return -ETIMEDOUT;
- ret = pci_irq_vector(pdev, msi_num - 1); - if (ret < 0) - return ret; - - if (ret != test->last_irq) + if (irq != test->last_irq) return -EIO;
return 0;
NIT, memory is already set to 0 by devm_kzalloc.
Signed-off-by: Christian Bruel christian.bruel@foss.st.com --- drivers/misc/pci_endpoint_test.c | 2 -- 1 file changed, 2 deletions(-)
diff --git a/drivers/misc/pci_endpoint_test.c b/drivers/misc/pci_endpoint_test.c index 54f66ece25cd..fbdffe7bb739 100644 --- a/drivers/misc/pci_endpoint_test.c +++ b/drivers/misc/pci_endpoint_test.c @@ -1020,8 +1020,6 @@ static int pci_endpoint_test_probe(struct pci_dev *pdev, if (!test) return -ENOMEM;
- test->test_reg_bar = 0; - test->alignment = 0; test->pdev = pdev; test->irq_type = PCITEST_IRQ_TYPE_UNDEFINED;
The pcie_endpoint_framework tests the entire MSI(x) range, which generate false errors on platforms that do not support the whole range.
This patch skips the test in such cases and reports accordingly.
Signed-off-by: Christian Bruel christian.bruel@foss.st.com --- tools/testing/selftests/pci_endpoint/pci_endpoint_test.c | 4 ++++ 1 file changed, 4 insertions(+)
diff --git a/tools/testing/selftests/pci_endpoint/pci_endpoint_test.c b/tools/testing/selftests/pci_endpoint/pci_endpoint_test.c index da0db0e7c969..cd9075444c32 100644 --- a/tools/testing/selftests/pci_endpoint/pci_endpoint_test.c +++ b/tools/testing/selftests/pci_endpoint/pci_endpoint_test.c @@ -121,6 +121,8 @@ TEST_F(pci_ep_basic, MSI_TEST)
for (i = 1; i <= 32; i++) { pci_ep_ioctl(PCITEST_MSI, i); + if (ret == -EINVAL) + SKIP(return, "MSI%d is disabled", i); EXPECT_FALSE(ret) TH_LOG("Test failed for MSI%d", i); } } @@ -137,6 +139,8 @@ TEST_F(pci_ep_basic, MSIX_TEST)
for (i = 1; i <= 2048; i++) { pci_ep_ioctl(PCITEST_MSIX, i); + if (ret == -EINVAL) + SKIP(return, "MSI-X%d is disabled", i); EXPECT_FALSE(ret) TH_LOG("Test failed for MSI-X%d", i); } }
linux-kselftest-mirror@lists.linaro.org