linux-kselftest.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* [PATCH 0/3] Skip IRQ tests if irq legitimately is out of range
@ 2025-08-04 17:09 Christian Bruel
  2025-08-04 17:09 ` [PATCH 1/3] misc: pci_endpoint_test: Skip IRQ tests if irq " Christian Bruel
                   ` (3 more replies)
  0 siblings, 4 replies; 5+ messages in thread
From: Christian Bruel @ 2025-08-04 17:09 UTC (permalink / raw)
  To: mani, kwilczynski, kishon, arnd, gregkh, shuah
  Cc: linux-pci, linux-kernel, linux-kselftest, Christian Bruel

'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(-)

-- 
2.34.1


^ permalink raw reply	[flat|nested] 5+ messages in thread

* [PATCH 1/3] misc: pci_endpoint_test: Skip IRQ tests if irq is out of range
  2025-08-04 17:09 [PATCH 0/3] Skip IRQ tests if irq legitimately is out of range Christian Bruel
@ 2025-08-04 17:09 ` Christian Bruel
  2025-08-04 17:09 ` [PATCH 2/3] misc: pci_endpoint_test: Cleanup extra 0 initialization Christian Bruel
                   ` (2 subsequent siblings)
  3 siblings, 0 replies; 5+ messages in thread
From: Christian Bruel @ 2025-08-04 17:09 UTC (permalink / raw)
  To: mani, kwilczynski, kishon, arnd, gregkh, shuah
  Cc: linux-pci, linux-kernel, linux-kselftest, Christian Bruel

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;
-- 
2.34.1


^ permalink raw reply related	[flat|nested] 5+ messages in thread

* [PATCH 2/3] misc: pci_endpoint_test: Cleanup extra 0 initialization
  2025-08-04 17:09 [PATCH 0/3] Skip IRQ tests if irq legitimately is out of range Christian Bruel
  2025-08-04 17:09 ` [PATCH 1/3] misc: pci_endpoint_test: Skip IRQ tests if irq " Christian Bruel
@ 2025-08-04 17:09 ` Christian Bruel
  2025-08-04 17:09 ` [PATCH 3/3] selftests: pci_endpoint: Skip IRQ test if irq is out of range Christian Bruel
  2025-08-27 13:15 ` [PATCH 0/3] Skip IRQ tests if irq legitimately " Manivannan Sadhasivam
  3 siblings, 0 replies; 5+ messages in thread
From: Christian Bruel @ 2025-08-04 17:09 UTC (permalink / raw)
  To: mani, kwilczynski, kishon, arnd, gregkh, shuah
  Cc: linux-pci, linux-kernel, linux-kselftest, Christian Bruel

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;
 
-- 
2.34.1


^ permalink raw reply related	[flat|nested] 5+ messages in thread

* [PATCH 3/3] selftests: pci_endpoint: Skip IRQ test if irq is out of range.
  2025-08-04 17:09 [PATCH 0/3] Skip IRQ tests if irq legitimately is out of range Christian Bruel
  2025-08-04 17:09 ` [PATCH 1/3] misc: pci_endpoint_test: Skip IRQ tests if irq " Christian Bruel
  2025-08-04 17:09 ` [PATCH 2/3] misc: pci_endpoint_test: Cleanup extra 0 initialization Christian Bruel
@ 2025-08-04 17:09 ` Christian Bruel
  2025-08-27 13:15 ` [PATCH 0/3] Skip IRQ tests if irq legitimately " Manivannan Sadhasivam
  3 siblings, 0 replies; 5+ messages in thread
From: Christian Bruel @ 2025-08-04 17:09 UTC (permalink / raw)
  To: mani, kwilczynski, kishon, arnd, gregkh, shuah
  Cc: linux-pci, linux-kernel, linux-kselftest, Christian Bruel

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);
 	}
 }
-- 
2.34.1


^ permalink raw reply related	[flat|nested] 5+ messages in thread

* Re: [PATCH 0/3] Skip IRQ tests if irq legitimately is out of range
  2025-08-04 17:09 [PATCH 0/3] Skip IRQ tests if irq legitimately is out of range Christian Bruel
                   ` (2 preceding siblings ...)
  2025-08-04 17:09 ` [PATCH 3/3] selftests: pci_endpoint: Skip IRQ test if irq is out of range Christian Bruel
@ 2025-08-27 13:15 ` Manivannan Sadhasivam
  3 siblings, 0 replies; 5+ messages in thread
From: Manivannan Sadhasivam @ 2025-08-27 13:15 UTC (permalink / raw)
  To: kwilczynski, kishon, arnd, gregkh, shuah, Christian Bruel
  Cc: linux-pci, linux-kernel, linux-kselftest


On Mon, 04 Aug 2025 19:09:13 +0200, Christian Bruel wrote:
> '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
> 
> [...]

Applied, thanks!

[1/3] misc: pci_endpoint_test: Skip IRQ tests if irq is out of range
      commit: cc8e391067164f45f89b6132a5aaa18c33a0e32b
[2/3] misc: pci_endpoint_test: Cleanup extra 0 initialization
      commit: 384b1b29481e39aae8eb01240d1edf287c7a4145
[3/3] selftests: pci_endpoint: Skip IRQ test if irq is out of range.
      commit: 106fc08b30a2ece49a251b053165a83d41d50fd0

Best regards,
-- 
Manivannan Sadhasivam <mani@kernel.org>


^ permalink raw reply	[flat|nested] 5+ messages in thread

end of thread, other threads:[~2025-08-27 13:15 UTC | newest]

Thread overview: 5+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2025-08-04 17:09 [PATCH 0/3] Skip IRQ tests if irq legitimately is out of range Christian Bruel
2025-08-04 17:09 ` [PATCH 1/3] misc: pci_endpoint_test: Skip IRQ tests if irq " Christian Bruel
2025-08-04 17:09 ` [PATCH 2/3] misc: pci_endpoint_test: Cleanup extra 0 initialization Christian Bruel
2025-08-04 17:09 ` [PATCH 3/3] selftests: pci_endpoint: Skip IRQ test if irq is out of range Christian Bruel
2025-08-27 13:15 ` [PATCH 0/3] Skip IRQ tests if irq legitimately " Manivannan Sadhasivam

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).