public inbox for linux-kernel@vger.kernel.org
 help / color / mirror / Atom feed
* [PATCH 0/3] Skip subrange map tests on DWC iATU allocation failure
@ 2026-03-18 14:46 Christian Bruel
  2026-03-18 14:46 ` [PATCH 1/3] selftests: pci_endpoint: Skip subrange map test if iATU allocation fails Christian Bruel
                   ` (2 more replies)
  0 siblings, 3 replies; 18+ messages in thread
From: Christian Bruel @ 2026-03-18 14:46 UTC (permalink / raw)
  To: Manivannan Sadhasivam, Krzysztof Wilczyński,
	Kishon Vijay Abraham I, Shuah Khan, Bjorn Helgaas, Arnd Bergmann,
	Greg Kroah-Hartman, Koichiro Den, Niklas Cassel
  Cc: fabrice.gasnier, linux-pci, linux-kselftest, linux-kernel,
	Christian Bruel

For platforms with a limited iATU inbound window entries, pci_epc_set_bar()
might fail to allocate the ATU entries for subrange maps requiring more
than 1 slot.
For the dwc controller, this failure is reported with -ENOSPC in
dw_pcie_ep_set_bar(). In this case, the epf test cannot be run and needs
to be skipped.

For other controllers (Rockchip, RCar, Cadence) the .set_bar functions do
not use this error.

Signed-off-by: Christian Bruel <christian.bruel@foss.st.com>
---
Christian Bruel (3):
      selftests: pci_endpoint: Skip subrange map test if iATU allocation fails
      PCI: endpoint: pci-epf-test: Handle -ENOSPC in subrange map test
      misc: pci_endpoint_test: Handle -ENOSPC in subrange mapping test case

 drivers/misc/pci_endpoint_test.c                         | 6 +++++-
 drivers/pci/endpoint/functions/pci-epf-test.c            | 3 +++
 tools/testing/selftests/pci_endpoint/pci_endpoint_test.c | 2 ++
 3 files changed, 10 insertions(+), 1 deletion(-)
---
base-commit: 8e5a478b6d6a5bb0a3d52147862b15e4d826af19
change-id: 20260318-skip-bar_subrange-tests-if-enospc-c26f03038e92

Best regards,
-- 
Christian Bruel <christian.bruel@foss.st.com>


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

* [PATCH 1/3] selftests: pci_endpoint: Skip subrange map test if iATU allocation fails
  2026-03-18 14:46 [PATCH 0/3] Skip subrange map tests on DWC iATU allocation failure Christian Bruel
@ 2026-03-18 14:46 ` Christian Bruel
  2026-03-18 15:32   ` Niklas Cassel
  2026-03-19  1:28   ` Koichiro Den
  2026-03-18 14:46 ` [PATCH 2/3] PCI: endpoint: pci-epf-test: Handle -ENOSPC in subrange map test Christian Bruel
  2026-03-18 14:46 ` [PATCH 3/3] misc: pci_endpoint_test: Handle -ENOSPC in subrange mapping test case Christian Bruel
  2 siblings, 2 replies; 18+ messages in thread
From: Christian Bruel @ 2026-03-18 14:46 UTC (permalink / raw)
  To: Manivannan Sadhasivam, Krzysztof Wilczyński,
	Kishon Vijay Abraham I, Shuah Khan, Bjorn Helgaas, Arnd Bergmann,
	Greg Kroah-Hartman, Koichiro Den, Niklas Cassel
  Cc: fabrice.gasnier, linux-pci, linux-kselftest, linux-kernel,
	Christian Bruel

Handle -ENOSPC error. If the number of available inbound ATU entries is
insufficient to map the subrange, skip the test instead of failing.

Link: https://lore.kernel.org/linux-pci/20260317152707.GA85951@bhelgaas/T/#m87e4c24173097a0ea70195b71aab294ad8d6c283
Signed-off-by: Christian Bruel <christian.bruel@foss.st.com>
---
 tools/testing/selftests/pci_endpoint/pci_endpoint_test.c | 2 ++
 1 file changed, 2 insertions(+)

diff --git a/tools/testing/selftests/pci_endpoint/pci_endpoint_test.c b/tools/testing/selftests/pci_endpoint/pci_endpoint_test.c
index c417fb3a198b2d92c3060938c23807cc8bea5573..8ea2fda4539d11eb22b22800a7cb8bbaa99c91ba 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 ATU entries to allocate subrange");
 	EXPECT_FALSE(ret) TH_LOG("Test failed for BAR%d", variant->barno);
 }
 

-- 
2.34.1


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

* [PATCH 2/3] PCI: endpoint: pci-epf-test: Handle -ENOSPC in subrange map test
  2026-03-18 14:46 [PATCH 0/3] Skip subrange map tests on DWC iATU allocation failure Christian Bruel
  2026-03-18 14:46 ` [PATCH 1/3] selftests: pci_endpoint: Skip subrange map test if iATU allocation fails Christian Bruel
@ 2026-03-18 14:46 ` Christian Bruel
  2026-03-18 15:50   ` Niklas Cassel
  2026-03-18 14:46 ` [PATCH 3/3] misc: pci_endpoint_test: Handle -ENOSPC in subrange mapping test case Christian Bruel
  2 siblings, 1 reply; 18+ messages in thread
From: Christian Bruel @ 2026-03-18 14:46 UTC (permalink / raw)
  To: Manivannan Sadhasivam, Krzysztof Wilczyński,
	Kishon Vijay Abraham I, Shuah Khan, Bjorn Helgaas, Arnd Bergmann,
	Greg Kroah-Hartman, Koichiro Den, Niklas Cassel
  Cc: fabrice.gasnier, linux-pci, linux-kselftest, linux-kernel,
	Christian Bruel

Report pci_epc_set_bar() -ENOSPC failure with the
STATUS_BAR_SUBRANGE_SETUP_NOSPC status bit. This can be used to
skip the subrange test if there is not enough iATU resources to
allocate it.

Link: https://lore.kernel.org/linux-pci/20260317152707.GA85951@bhelgaas/T/#m87e4c24173097a0ea70195b71aab294ad8d6c283
Signed-off-by: Christian Bruel <christian.bruel@foss.st.com>
---
 drivers/pci/endpoint/functions/pci-epf-test.c | 3 +++
 1 file changed, 3 insertions(+)

diff --git a/drivers/pci/endpoint/functions/pci-epf-test.c b/drivers/pci/endpoint/functions/pci-epf-test.c
index 14e61ebe1f116ce04789b6f4c3e965296701ec53..6437f08f0cd4bd4645e380c915b7cf81e66b7c35 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_BAR_SUBRANGE_SETUP_NOSPC		BIT(18)
 
 #define FLAG_USE_DMA			BIT(0)
 
@@ -903,6 +904,8 @@ static void pci_epf_test_bar_subrange_setup(struct pci_epf_test *epf_test,
 		dev_err(&epf->dev, "pci_epc_set_bar() failed: %d\n", ret);
 		bar->submap = old_submap;
 		bar->num_submap = old_nsub;
+		if (ret == -ENOSPC)
+			status |= STATUS_BAR_SUBRANGE_SETUP_NOSPC;
 		kfree(submap);
 		goto err;
 	}

-- 
2.34.1


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

* [PATCH 3/3] misc: pci_endpoint_test: Handle -ENOSPC in subrange mapping test case
  2026-03-18 14:46 [PATCH 0/3] Skip subrange map tests on DWC iATU allocation failure Christian Bruel
  2026-03-18 14:46 ` [PATCH 1/3] selftests: pci_endpoint: Skip subrange map test if iATU allocation fails Christian Bruel
  2026-03-18 14:46 ` [PATCH 2/3] PCI: endpoint: pci-epf-test: Handle -ENOSPC in subrange map test Christian Bruel
@ 2026-03-18 14:46 ` Christian Bruel
  2026-03-18 16:03   ` Niklas Cassel
  2 siblings, 1 reply; 18+ messages in thread
From: Christian Bruel @ 2026-03-18 14:46 UTC (permalink / raw)
  To: Manivannan Sadhasivam, Krzysztof Wilczyński,
	Kishon Vijay Abraham I, Shuah Khan, Bjorn Helgaas, Arnd Bergmann,
	Greg Kroah-Hartman, Koichiro Den, Niklas Cassel
  Cc: fabrice.gasnier, linux-pci, linux-kselftest, linux-kernel,
	Christian Bruel

Return -ENOSPC instead of -EOI when the status reports the NOSPC bit.
This signifies to the pci_endpoint test to skip this test instead of
reporting a failure.

Link: https://lore.kernel.org/linux-pci/20260317152707.GA85951@bhelgaas/T/#m87e4c24173097a0ea70195b71aab294ad8d6c283
Signed-off-by: Christian Bruel <christian.bruel@foss.st.com>
---
 drivers/misc/pci_endpoint_test.c | 6 +++++-
 1 file changed, 5 insertions(+), 1 deletion(-)

diff --git a/drivers/misc/pci_endpoint_test.c b/drivers/misc/pci_endpoint_test.c
index 55e128ed82f00ae13b6fe9768cdbe56adbe8f9da..34ba06fb53f04e48c1c05f4aae85e6ecd03ef447 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_BAR_SUBRANGE_SETUP_NOSPC		BIT(18)
 
 #define PCI_ENDPOINT_TEST_LOWER_SRC_ADDR	0x0c
 #define PCI_ENDPOINT_TEST_UPPER_SRC_ADDR	0x10
@@ -476,8 +477,11 @@ static int pci_endpoint_test_bar_subrange_cmd(struct pci_endpoint_test *test,
 		return -ETIMEDOUT;
 
 	status = pci_endpoint_test_readl(test, PCI_ENDPOINT_TEST_STATUS);
-	if (status & fail_bit)
+	if (status & fail_bit) {
+		if (status & STATUS_BAR_SUBRANGE_SETUP_NOSPC)
+			return -ENOSPC;
 		return -EIO;
+	}
 
 	if (!(status & ok_bit))
 		return -EIO;

-- 
2.34.1


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

* Re: [PATCH 1/3] selftests: pci_endpoint: Skip subrange map test if iATU allocation fails
  2026-03-18 14:46 ` [PATCH 1/3] selftests: pci_endpoint: Skip subrange map test if iATU allocation fails Christian Bruel
@ 2026-03-18 15:32   ` Niklas Cassel
  2026-03-19  1:28   ` Koichiro Den
  1 sibling, 0 replies; 18+ messages in thread
From: Niklas Cassel @ 2026-03-18 15:32 UTC (permalink / raw)
  To: Christian Bruel
  Cc: Manivannan Sadhasivam, Krzysztof Wilczyński,
	Kishon Vijay Abraham I, Shuah Khan, Bjorn Helgaas, Arnd Bergmann,
	Greg Kroah-Hartman, Koichiro Den, fabrice.gasnier, linux-pci,
	linux-kselftest, linux-kernel

On Wed, Mar 18, 2026 at 03:46:27PM +0100, Christian Bruel wrote:
> Handle -ENOSPC error. If the number of available inbound ATU entries is
> insufficient to map the subrange, skip the test instead of failing.
> 
> Link: https://lore.kernel.org/linux-pci/20260317152707.GA85951@bhelgaas/T/#m87e4c24173097a0ea70195b71aab294ad8d6c283

I would drop the link, it does not really add any value.

> Signed-off-by: Christian Bruel <christian.bruel@foss.st.com>
> ---
>  tools/testing/selftests/pci_endpoint/pci_endpoint_test.c | 2 ++
>  1 file changed, 2 insertions(+)
> 
> diff --git a/tools/testing/selftests/pci_endpoint/pci_endpoint_test.c b/tools/testing/selftests/pci_endpoint/pci_endpoint_test.c
> index c417fb3a198b2d92c3060938c23807cc8bea5573..8ea2fda4539d11eb22b22800a7cb8bbaa99c91ba 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 ATU entries to allocate subrange");

ATU is a DWC specific term.
I would use "inbound windows" instead.
E.g. "Not enough inbound windows to allocate subrange"


Considering that the selftests is highest up the stack, I would put this
patch as 3/3 and not 1/3.


Kind regards,
Niklas

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

* Re: [PATCH 2/3] PCI: endpoint: pci-epf-test: Handle -ENOSPC in subrange map test
  2026-03-18 14:46 ` [PATCH 2/3] PCI: endpoint: pci-epf-test: Handle -ENOSPC in subrange map test Christian Bruel
@ 2026-03-18 15:50   ` Niklas Cassel
  0 siblings, 0 replies; 18+ messages in thread
From: Niklas Cassel @ 2026-03-18 15:50 UTC (permalink / raw)
  To: Christian Bruel
  Cc: Manivannan Sadhasivam, Krzysztof Wilczyński,
	Kishon Vijay Abraham I, Shuah Khan, Bjorn Helgaas, Arnd Bergmann,
	Greg Kroah-Hartman, Koichiro Den, fabrice.gasnier, linux-pci,
	linux-kselftest, linux-kernel

On Wed, Mar 18, 2026 at 03:46:28PM +0100, Christian Bruel wrote:
> Report pci_epc_set_bar() -ENOSPC failure with the
> STATUS_BAR_SUBRANGE_SETUP_NOSPC status bit. This can be used to
> skip the subrange test if there is not enough iATU resources to
> allocate it.
> 
> Link: https://lore.kernel.org/linux-pci/20260317152707.GA85951@bhelgaas/T/#m87e4c24173097a0ea70195b71aab294ad8d6c283

I would drop the link.


> Signed-off-by: Christian Bruel <christian.bruel@foss.st.com>
> ---
>  drivers/pci/endpoint/functions/pci-epf-test.c | 3 +++
>  1 file changed, 3 insertions(+)
> 
> diff --git a/drivers/pci/endpoint/functions/pci-epf-test.c b/drivers/pci/endpoint/functions/pci-epf-test.c
> index 14e61ebe1f116ce04789b6f4c3e965296701ec53..6437f08f0cd4bd4645e380c915b7cf81e66b7c35 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_BAR_SUBRANGE_SETUP_NOSPC		BIT(18)

Perhaps STATUS_BAR_SUBRANGE_SETUP_SKIP ?

>  
>  #define FLAG_USE_DMA			BIT(0)
>  
> @@ -903,6 +904,8 @@ static void pci_epf_test_bar_subrange_setup(struct pci_epf_test *epf_test,
>  		dev_err(&epf->dev, "pci_epc_set_bar() failed: %d\n", ret);
>  		bar->submap = old_submap;
>  		bar->num_submap = old_nsub;
> +		if (ret == -ENOSPC)
> +			status |= STATUS_BAR_SUBRANGE_SETUP_NOSPC;
>  		kfree(submap);
>  		goto err;
>  	}

Here you will have both STATUS_BAR_SUBRANGE_SETUP_NOSPC and
STATUS_BAR_SUBRANGE_SETUP_FAIL set.

Usually, we only have one bit set.


Perhaps something like:

diff --git a/drivers/pci/endpoint/functions/pci-epf-test.c b/drivers/pci/endpoint/functions/pci-epf-test.c
index 582938b7b4f1..36e5d22f79ab 100644
--- a/drivers/pci/endpoint/functions/pci-epf-test.c
+++ b/drivers/pci/endpoint/functions/pci-epf-test.c
@@ -895,6 +895,10 @@ static void pci_epf_test_bar_subrange_setup(struct pci_epf_test *epf_test,
                bar->submap = old_submap;
                bar->num_submap = old_nsub;
                kfree(submap);
+               if (ret == -ENOSPC) {
+                       status |= STATUS_BAR_SUBRANGE_SETUP_SKIP;
+                       goto err_status_set;
+               }
                goto err;
        }
        kfree(old_submap);
@@ -918,6 +922,7 @@ static void pci_epf_test_bar_subrange_setup(struct pci_epf_test *epf_test,
 
 err:
        status |= STATUS_BAR_SUBRANGE_SETUP_FAIL;
+err_status_set:
        reg->status = cpu_to_le32(status);
 }



This patch should probably be 1/3.


Kind regards,
Niklas

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

* Re: [PATCH 3/3] misc: pci_endpoint_test: Handle -ENOSPC in subrange mapping test case
  2026-03-18 14:46 ` [PATCH 3/3] misc: pci_endpoint_test: Handle -ENOSPC in subrange mapping test case Christian Bruel
@ 2026-03-18 16:03   ` Niklas Cassel
  2026-03-20  9:35     ` Christian Bruel
  0 siblings, 1 reply; 18+ messages in thread
From: Niklas Cassel @ 2026-03-18 16:03 UTC (permalink / raw)
  To: Christian Bruel
  Cc: Manivannan Sadhasivam, Krzysztof Wilczyński,
	Kishon Vijay Abraham I, Shuah Khan, Bjorn Helgaas, Arnd Bergmann,
	Greg Kroah-Hartman, Koichiro Den, fabrice.gasnier, linux-pci,
	linux-kselftest, linux-kernel

On Wed, Mar 18, 2026 at 03:46:29PM +0100, Christian Bruel wrote:
> Return -ENOSPC instead of -EOI when the status reports the NOSPC bit.

s/EOI/EIO/


> This signifies to the pci_endpoint test to skip this test instead of
> reporting a failure.
> 
> Link: https://lore.kernel.org/linux-pci/20260317152707.GA85951@bhelgaas/T/#m87e4c24173097a0ea70195b71aab294ad8d6c283

I would drop the link.

I would put this patch after pci_epf_test.c patch and before selftest patch.


> Signed-off-by: Christian Bruel <christian.bruel@foss.st.com>
> ---
>  drivers/misc/pci_endpoint_test.c | 6 +++++-
>  1 file changed, 5 insertions(+), 1 deletion(-)
> 
> diff --git a/drivers/misc/pci_endpoint_test.c b/drivers/misc/pci_endpoint_test.c
> index 55e128ed82f00ae13b6fe9768cdbe56adbe8f9da..34ba06fb53f04e48c1c05f4aae85e6ecd03ef447 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_BAR_SUBRANGE_SETUP_NOSPC		BIT(18)
>  
>  #define PCI_ENDPOINT_TEST_LOWER_SRC_ADDR	0x0c
>  #define PCI_ENDPOINT_TEST_UPPER_SRC_ADDR	0x10
> @@ -476,8 +477,11 @@ static int pci_endpoint_test_bar_subrange_cmd(struct pci_endpoint_test *test,
>  		return -ETIMEDOUT;
>  
>  	status = pci_endpoint_test_readl(test, PCI_ENDPOINT_TEST_STATUS);
> -	if (status & fail_bit)
> +	if (status & fail_bit) {
> +		if (status & STATUS_BAR_SUBRANGE_SETUP_NOSPC)
> +			return -ENOSPC;

Perhaps this should be something like:

if (command == COMMAND_BAR_SUBRANGE_SETUP && status & STATUS_BAR_SUBRANGE_SETUP_SKIP)

Personally, I'm not a big fan of having a common function for both
pci_endpoint_test_bar_subrange_setup() and
pci_endpoint_test_bar_subrange_clear() and then sending in parameters
for which bits to check. It make it hard to have small differences
between them (like checking for an bit that is only valid for one of
the commands).

I can understand why Koichiro wrote it why he did, but since we now
want differences, perhaps add a preparation patch that makes it two
separate functions?

It is not like pci_endpoint_test_bar_subrange_cmd() is a big function
anyway.


Kind regards,
Niklas

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

* Re: [PATCH 1/3] selftests: pci_endpoint: Skip subrange map test if iATU allocation fails
  2026-03-18 14:46 ` [PATCH 1/3] selftests: pci_endpoint: Skip subrange map test if iATU allocation fails Christian Bruel
  2026-03-18 15:32   ` Niklas Cassel
@ 2026-03-19  1:28   ` Koichiro Den
  2026-03-19  8:47     ` Niklas Cassel
  2026-03-20 10:04     ` Christian Bruel
  1 sibling, 2 replies; 18+ messages in thread
From: Koichiro Den @ 2026-03-19  1:28 UTC (permalink / raw)
  To: Christian Bruel
  Cc: Manivannan Sadhasivam, Krzysztof Wilczyński,
	Kishon Vijay Abraham I, Shuah Khan, Bjorn Helgaas, Arnd Bergmann,
	Greg Kroah-Hartman, Niklas Cassel, fabrice.gasnier, linux-pci,
	linux-kselftest, linux-kernel

On Wed, Mar 18, 2026 at 03:46:27PM +0100, Christian Bruel wrote:
> Handle -ENOSPC error. If the number of available inbound ATU entries is
> insufficient to map the subrange, skip the test instead of failing.
> 
> Link: https://lore.kernel.org/linux-pci/20260317152707.GA85951@bhelgaas/T/#m87e4c24173097a0ea70195b71aab294ad8d6c283
> Signed-off-by: Christian Bruel <christian.bruel@foss.st.com>
> ---
>  tools/testing/selftests/pci_endpoint/pci_endpoint_test.c | 2 ++
>  1 file changed, 2 insertions(+)
> 
> diff --git a/tools/testing/selftests/pci_endpoint/pci_endpoint_test.c b/tools/testing/selftests/pci_endpoint/pci_endpoint_test.c
> index c417fb3a198b2d92c3060938c23807cc8bea5573..8ea2fda4539d11eb22b22800a7cb8bbaa99c91ba 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 ATU entries to allocate subrange");

Thank you for handling this!

pci_endpoint_test_bar_subrange() can also return -ENOSPC locally:
https://github.com/torvalds/linux/blob/v7.0-rc4/drivers/misc/pci_endpoint_test.c#L538
While that is a different resource limit case, I think it would still be
reasonable to treat it as SKIP as well.

If you agree and keep your current approach, then I think the SKIP message
might be better phrased more generically, e.g. "Insufficient resources".

If you prefer to keep that local case as FAIL (or at least distinguish it
with a different SKIP message), that would likely require a bit more
changes overall. Note: Niklas' earlier feedback on the SKIP message would
still apply.

Best regards,
Koichiro

>  	EXPECT_FALSE(ret) TH_LOG("Test failed for BAR%d", variant->barno);
>  }
>  
> 
> -- 
> 2.34.1
> 

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

* Re: [PATCH 1/3] selftests: pci_endpoint: Skip subrange map test if iATU allocation fails
  2026-03-19  1:28   ` Koichiro Den
@ 2026-03-19  8:47     ` Niklas Cassel
  2026-03-20 13:41       ` Koichiro Den
  2026-03-20 10:04     ` Christian Bruel
  1 sibling, 1 reply; 18+ messages in thread
From: Niklas Cassel @ 2026-03-19  8:47 UTC (permalink / raw)
  To: Koichiro Den
  Cc: Christian Bruel, Manivannan Sadhasivam, Krzysztof Wilczyński,
	Kishon Vijay Abraham I, Shuah Khan, Bjorn Helgaas, Arnd Bergmann,
	Greg Kroah-Hartman, fabrice.gasnier, linux-pci, linux-kselftest,
	linux-kernel

On Thu, Mar 19, 2026 at 10:28:41AM +0900, Koichiro Den wrote:
> On Wed, Mar 18, 2026 at 03:46:27PM +0100, Christian Bruel wrote:
> > Handle -ENOSPC error. If the number of available inbound ATU entries is
> > insufficient to map the subrange, skip the test instead of failing.
> >
> > Link: https://lore.kernel.org/linux-pci/20260317152707.GA85951@bhelgaas/T/#m87e4c24173097a0ea70195b71aab294ad8d6c283
> > Signed-off-by: Christian Bruel <christian.bruel@foss.st.com>
> > ---
> >  tools/testing/selftests/pci_endpoint/pci_endpoint_test.c | 2 ++
> >  1 file changed, 2 insertions(+)
> >
> > diff --git a/tools/testing/selftests/pci_endpoint/pci_endpoint_test.c b/tools/testing/selftests/pci_endpoint/pci_endpoint_test.c
> > index c417fb3a198b2d92c3060938c23807cc8bea5573..8ea2fda4539d11eb22b22800a7cb8bbaa99c91ba 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 ATU entries to allocate subrange");
>
> Thank you for handling this!
>
> pci_endpoint_test_bar_subrange() can also return -ENOSPC locally:
> https://github.com/torvalds/linux/blob/v7.0-rc4/drivers/misc/pci_endpoint_test.c#L538
> While that is a different resource limit case, I think it would still be
> reasonable to treat it as SKIP as well.

	sub_size = bar_size / nsub;
	if (sub_size < sizeof(u32)) {
		ret = -ENOSPC;
		goto out_clear;
	}

What is this test for anyway?

If sub_size < 4 ?
 return -ENOSPACE ?

ENOSPC seem like a weird return for this.

Wouldn't EINVAL be a better return code for this?


Kind regards,
Niklas

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

* Re: [PATCH 3/3] misc: pci_endpoint_test: Handle -ENOSPC in subrange mapping test case
  2026-03-18 16:03   ` Niklas Cassel
@ 2026-03-20  9:35     ` Christian Bruel
  2026-03-20 11:16       ` Niklas Cassel
  0 siblings, 1 reply; 18+ messages in thread
From: Christian Bruel @ 2026-03-20  9:35 UTC (permalink / raw)
  To: Niklas Cassel
  Cc: Manivannan Sadhasivam, Krzysztof Wilczyński,
	Kishon Vijay Abraham I, Shuah Khan, Bjorn Helgaas, Arnd Bergmann,
	Greg Kroah-Hartman, Koichiro Den, fabrice.gasnier, linux-pci,
	linux-kselftest, linux-kernel

Hello,

>>
>> diff --git a/drivers/misc/pci_endpoint_test.c b/drivers/misc/pci_endpoint_test.c
>> index 55e128ed82f00ae13b6fe9768cdbe56adbe8f9da..34ba06fb53f04e48c1c05f4aae85e6ecd03ef447 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_BAR_SUBRANGE_SETUP_NOSPC		BIT(18)
>>   
>>   #define PCI_ENDPOINT_TEST_LOWER_SRC_ADDR	0x0c
>>   #define PCI_ENDPOINT_TEST_UPPER_SRC_ADDR	0x10
>> @@ -476,8 +477,11 @@ static int pci_endpoint_test_bar_subrange_cmd(struct pci_endpoint_test *test,
>>   		return -ETIMEDOUT;
>>   
>>   	status = pci_endpoint_test_readl(test, PCI_ENDPOINT_TEST_STATUS);
>> -	if (status & fail_bit)
>> +	if (status & fail_bit) {
>> +		if (status & STATUS_BAR_SUBRANGE_SETUP_NOSPC)
>> +			return -ENOSPC;
> 
> Perhaps this should be something like:
> 
> if (command == COMMAND_BAR_SUBRANGE_SETUP && status & STATUS_BAR_SUBRANGE_SETUP_SKIP)

I'm not sure about replacing STATUS_BAR_SUBRANGE_SETUP_NOSPC by 
STATUS_BAR_SUBRANGE_SETUP_SKIP

The selftest will use if (ret == -ENOSPC), so we need to return this 
information (bellow). and semantically SKIP does not imply ENOPSC 
(instead of the contrary)

as you prefer,


> 
> Personally, I'm not a big fan of having a common function for both
> pci_endpoint_test_bar_subrange_setup() and
> pci_endpoint_test_bar_subrange_clear() and then sending in parameters
> for which bits to check. It make it hard to have small differences
> between them (like checking for an bit that is only valid for one of
> the commands).
> 
> I can understand why Koichiro wrote it why he did, but since we now
> want differences, perhaps add a preparation patch that makes it two
> separate functions?
> 
> It is not like pci_endpoint_test_bar_subrange_cmd() is a big function
> anyway.
> 

To minimize changes, what about something like:

  unsigned int fail_bit = status & fail_bits;

  if (fail_bit == STATUS_BAR_SUBRANGE_SETUP_NOSPC)
    return -ENOSPC;

  if (fail_bit == STATUS_BAR_SUBRANGE_SETUP_FAIL)
    return -EIO;

called with

        pci_endpoint_test_bar_subrange_cmd(...,
        STATUS_BAR_SUBRANGE_SETUP_FAIL | STATUS_BAR_SUBRANGE_SETUP_NOSPC);

replacing the fail_bit parameter with fail_bits.

Thus we don't need to specialize the test with 'command', But I prefer 
to let Koichiro refactor the function if it is better

thank you,

Christian

> 
> Kind regards,
> Niklas


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

* Re: [PATCH 1/3] selftests: pci_endpoint: Skip subrange map test if iATU allocation fails
  2026-03-19  1:28   ` Koichiro Den
  2026-03-19  8:47     ` Niklas Cassel
@ 2026-03-20 10:04     ` Christian Bruel
  2026-03-20 14:05       ` Koichiro Den
  1 sibling, 1 reply; 18+ messages in thread
From: Christian Bruel @ 2026-03-20 10:04 UTC (permalink / raw)
  To: Koichiro Den
  Cc: Manivannan Sadhasivam, Krzysztof Wilczyński,
	Kishon Vijay Abraham I, Shuah Khan, Bjorn Helgaas, Arnd Bergmann,
	Greg Kroah-Hartman, Niklas Cassel, fabrice.gasnier, linux-pci,
	linux-kselftest, linux-kernel

Hello Koichiro, thank you for your comment

On 3/19/26 02:28, Koichiro Den wrote:
> On Wed, Mar 18, 2026 at 03:46:27PM +0100, Christian Bruel wrote:
>> Handle -ENOSPC error. If the number of available inbound ATU entries is
>> insufficient to map the subrange, skip the test instead of failing.
>>
>> Link: https://lore.kernel.org/linux-pci/20260317152707.GA85951@bhelgaas/T/#m87e4c24173097a0ea70195b71aab294ad8d6c283
>> Signed-off-by: Christian Bruel <christian.bruel@foss.st.com>
>> ---
>>   tools/testing/selftests/pci_endpoint/pci_endpoint_test.c | 2 ++
>>   1 file changed, 2 insertions(+)
>>
>> diff --git a/tools/testing/selftests/pci_endpoint/pci_endpoint_test.c b/tools/testing/selftests/pci_endpoint/pci_endpoint_test.c
>> index c417fb3a198b2d92c3060938c23807cc8bea5573..8ea2fda4539d11eb22b22800a7cb8bbaa99c91ba 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 ATU entries to allocate subrange");
> 
> Thank you for handling this!
> 
> pci_endpoint_test_bar_subrange() can also return -ENOSPC locally:
> https://github.com/torvalds/linux/blob/v7.0-rc4/drivers/misc/pci_endpoint_test.c#L538
> While that is a different resource limit case, I think it would still be
> reasonable to treat it as SKIP as well.

Regarding Niklas's feedback to use the local EINVAL instead of ENOSPC in 
pci_endpoint_test_bar_subrange(), I prefer to leave this for you to 
handle. That will cover this case.

> 
> If you agree and keep your current approach, then I think the SKIP message
> might be better phrased more generically, e.g. "Insufficient resources".

OK I agree, the error message should be less specific to DWC 
terminology, even though this case can currently only occur on it.

> 
> If you prefer to keep that local case as FAIL (or at least distinguish it
> with a different SKIP message), that would likely require a bit more
> changes overall. Note: Niklas' earlier feedback on the SKIP message would
> still apply.

OK, as Niklas also suggested, I will not set an additional local bit 
besides the fail bit. The question is whether we should name it SKIP or 
NOSPC. I slightly prefer NOSPC, as this is what is used in the selftest 
to indicate skipping.

thank you

Christian

> 
> Best regards,
> Koichiro
> 
>>   	EXPECT_FALSE(ret) TH_LOG("Test failed for BAR%d", variant->barno);
>>   }
>>   
>>
>> -- 
>> 2.34.1
>>


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

* Re: [PATCH 3/3] misc: pci_endpoint_test: Handle -ENOSPC in subrange mapping test case
  2026-03-20  9:35     ` Christian Bruel
@ 2026-03-20 11:16       ` Niklas Cassel
  2026-03-20 13:25         ` Christian Bruel
  0 siblings, 1 reply; 18+ messages in thread
From: Niklas Cassel @ 2026-03-20 11:16 UTC (permalink / raw)
  To: Christian Bruel
  Cc: Manivannan Sadhasivam, Krzysztof Wilczyński,
	Kishon Vijay Abraham I, Shuah Khan, Bjorn Helgaas, Arnd Bergmann,
	Greg Kroah-Hartman, Koichiro Den, fabrice.gasnier, linux-pci,
	linux-kselftest, linux-kernel

On Fri, Mar 20, 2026 at 10:35:20AM +0100, Christian Bruel wrote:
> Hello,
> 
> > > 
> > > diff --git a/drivers/misc/pci_endpoint_test.c b/drivers/misc/pci_endpoint_test.c
> > > index 55e128ed82f00ae13b6fe9768cdbe56adbe8f9da..34ba06fb53f04e48c1c05f4aae85e6ecd03ef447 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_BAR_SUBRANGE_SETUP_NOSPC		BIT(18)
> > >   #define PCI_ENDPOINT_TEST_LOWER_SRC_ADDR	0x0c
> > >   #define PCI_ENDPOINT_TEST_UPPER_SRC_ADDR	0x10
> > > @@ -476,8 +477,11 @@ static int pci_endpoint_test_bar_subrange_cmd(struct pci_endpoint_test *test,
> > >   		return -ETIMEDOUT;
> > >   	status = pci_endpoint_test_readl(test, PCI_ENDPOINT_TEST_STATUS);
> > > -	if (status & fail_bit)
> > > +	if (status & fail_bit) {
> > > +		if (status & STATUS_BAR_SUBRANGE_SETUP_NOSPC)
> > > +			return -ENOSPC;
> > 
> > Perhaps this should be something like:
> > 
> > if (command == COMMAND_BAR_SUBRANGE_SETUP && status & STATUS_BAR_SUBRANGE_SETUP_SKIP)
> 
> I'm not sure about replacing STATUS_BAR_SUBRANGE_SETUP_NOSPC by
> STATUS_BAR_SUBRANGE_SETUP_SKIP
> 
> The selftest will use if (ret == -ENOSPC), so we need to return this
> information (bellow). and semantically SKIP does not imply ENOPSC (instead
> of the contrary)
> 
> as you prefer,

FWIW, I think an even better solution is to introduce a new register,
named e.g. errno in struct pci_epf_test_reg;

That way, we don't need to take a new bit, e.g.:
+#define STATUS_BAR_SUBRANGE_SETUP_NOSPC          BIT(18)

For every unique error code a command can return.

We would simply return STATUS_BAR_SUBRANGE_CLEAR_FAIL, and then the host
side driver looks at the errno register to see the specific error code.

This way, all other _FAIL commands could also return a more specific error
in case of failure.


> 
> To minimize changes, what about something like:
> 
>  unsigned int fail_bit = status & fail_bits;
> 
>  if (fail_bit == STATUS_BAR_SUBRANGE_SETUP_NOSPC)
>    return -ENOSPC;
> 
>  if (fail_bit == STATUS_BAR_SUBRANGE_SETUP_FAIL)
>    return -EIO;
> 
> called with
> 
>        pci_endpoint_test_bar_subrange_cmd(...,
>        STATUS_BAR_SUBRANGE_SETUP_FAIL | STATUS_BAR_SUBRANGE_SETUP_NOSPC);
> 
> replacing the fail_bit parameter with fail_bits.

Sounds okay to me, but I think the idea of adding an errno register is
more extensible.


Kind regards,
Niklas

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

* Re: [PATCH 3/3] misc: pci_endpoint_test: Handle -ENOSPC in subrange mapping test case
  2026-03-20 11:16       ` Niklas Cassel
@ 2026-03-20 13:25         ` Christian Bruel
  2026-03-20 13:43           ` Niklas Cassel
  0 siblings, 1 reply; 18+ messages in thread
From: Christian Bruel @ 2026-03-20 13:25 UTC (permalink / raw)
  To: Niklas Cassel
  Cc: Manivannan Sadhasivam, Krzysztof Wilczyński,
	Kishon Vijay Abraham I, Shuah Khan, Bjorn Helgaas, Arnd Bergmann,
	Greg Kroah-Hartman, Koichiro Den, fabrice.gasnier, linux-pci,
	linux-kselftest, linux-kernel



On 3/20/26 12:16, Niklas Cassel wrote:
> On Fri, Mar 20, 2026 at 10:35:20AM +0100, Christian Bruel wrote:
>> Hello,
>>
>>>>
>>>> diff --git a/drivers/misc/pci_endpoint_test.c b/drivers/misc/pci_endpoint_test.c
>>>> index 55e128ed82f00ae13b6fe9768cdbe56adbe8f9da..34ba06fb53f04e48c1c05f4aae85e6ecd03ef447 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_BAR_SUBRANGE_SETUP_NOSPC		BIT(18)
>>>>    #define PCI_ENDPOINT_TEST_LOWER_SRC_ADDR	0x0c
>>>>    #define PCI_ENDPOINT_TEST_UPPER_SRC_ADDR	0x10
>>>> @@ -476,8 +477,11 @@ static int pci_endpoint_test_bar_subrange_cmd(struct pci_endpoint_test *test,
>>>>    		return -ETIMEDOUT;
>>>>    	status = pci_endpoint_test_readl(test, PCI_ENDPOINT_TEST_STATUS);
>>>> -	if (status & fail_bit)
>>>> +	if (status & fail_bit) {
>>>> +		if (status & STATUS_BAR_SUBRANGE_SETUP_NOSPC)
>>>> +			return -ENOSPC;
>>>
>>> Perhaps this should be something like:
>>>
>>> if (command == COMMAND_BAR_SUBRANGE_SETUP && status & STATUS_BAR_SUBRANGE_SETUP_SKIP)
>>
>> I'm not sure about replacing STATUS_BAR_SUBRANGE_SETUP_NOSPC by
>> STATUS_BAR_SUBRANGE_SETUP_SKIP
>>
>> The selftest will use if (ret == -ENOSPC), so we need to return this
>> information (bellow). and semantically SKIP does not imply ENOPSC (instead
>> of the contrary)
>>
>> as you prefer,
> 
> FWIW, I think an even better solution is to introduce a new register,
> named e.g. errno in struct pci_epf_test_reg;
> 
> That way, we don't need to take a new bit, e.g.:
> +#define STATUS_BAR_SUBRANGE_SETUP_NOSPC          BIT(18)
> 
> For every unique error code a command can return.
> 
> We would simply return STATUS_BAR_SUBRANGE_CLEAR_FAIL, and then the host
> side driver looks at the errno register to see the specific error code.
> 
> This way, all other _FAIL commands could also return a more specific error
> in case of failure.
> 
> 
>>
>> To minimize changes, what about something like:
>>
>>   unsigned int fail_bit = status & fail_bits;
>>
>>   if (fail_bit == STATUS_BAR_SUBRANGE_SETUP_NOSPC)
>>     return -ENOSPC;
>>
>>   if (fail_bit == STATUS_BAR_SUBRANGE_SETUP_FAIL)
>>     return -EIO;
>>
>> called with
>>
>>         pci_endpoint_test_bar_subrange_cmd(...,
>>         STATUS_BAR_SUBRANGE_SETUP_FAIL | STATUS_BAR_SUBRANGE_SETUP_NOSPC);
>>
>> replacing the fail_bit parameter with fail_bits.
> 
> Sounds okay to me, but I think the idea of adding an errno register is
> more extensible.
> 

But it is not consistent with other tests that use the status field to 
carry error information. For example, pci_epf_test_read/write/copy, set 
the STATUS_SRC/DTS_ADDR_INVALID bit to distinguish these errors from 
other -EINVAL.

Introducing a new errno field would result in having two different APIs 
for returning failure status.

In light of the STATUS_SRC/DST_ADDR_INVALID usage, I wonder if my 
initial proposal to set a status bit along with the FAIL bit might 
actually be simpler and more consistent what is already done here.

thank you,

Christian

> 
> Kind regards,
> Niklas


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

* Re: [PATCH 1/3] selftests: pci_endpoint: Skip subrange map test if iATU allocation fails
  2026-03-19  8:47     ` Niklas Cassel
@ 2026-03-20 13:41       ` Koichiro Den
  0 siblings, 0 replies; 18+ messages in thread
From: Koichiro Den @ 2026-03-20 13:41 UTC (permalink / raw)
  To: Niklas Cassel
  Cc: Christian Bruel, Manivannan Sadhasivam, Krzysztof Wilczyński,
	Kishon Vijay Abraham I, Shuah Khan, Bjorn Helgaas, Arnd Bergmann,
	Greg Kroah-Hartman, fabrice.gasnier, linux-pci, linux-kselftest,
	linux-kernel

On Thu, Mar 19, 2026 at 09:47:15AM +0100, Niklas Cassel wrote:
> On Thu, Mar 19, 2026 at 10:28:41AM +0900, Koichiro Den wrote:
> > On Wed, Mar 18, 2026 at 03:46:27PM +0100, Christian Bruel wrote:
> > > Handle -ENOSPC error. If the number of available inbound ATU entries is
> > > insufficient to map the subrange, skip the test instead of failing.
> > >
> > > Link: https://lore.kernel.org/linux-pci/20260317152707.GA85951@bhelgaas/T/#m87e4c24173097a0ea70195b71aab294ad8d6c283
> > > Signed-off-by: Christian Bruel <christian.bruel@foss.st.com>
> > > ---
> > >  tools/testing/selftests/pci_endpoint/pci_endpoint_test.c | 2 ++
> > >  1 file changed, 2 insertions(+)
> > >
> > > diff --git a/tools/testing/selftests/pci_endpoint/pci_endpoint_test.c b/tools/testing/selftests/pci_endpoint/pci_endpoint_test.c
> > > index c417fb3a198b2d92c3060938c23807cc8bea5573..8ea2fda4539d11eb22b22800a7cb8bbaa99c91ba 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 ATU entries to allocate subrange");
> >
> > Thank you for handling this!
> >
> > pci_endpoint_test_bar_subrange() can also return -ENOSPC locally:
> > https://github.com/torvalds/linux/blob/v7.0-rc4/drivers/misc/pci_endpoint_test.c#L538
> > While that is a different resource limit case, I think it would still be
> > reasonable to treat it as SKIP as well.
> 
> 	sub_size = bar_size / nsub;
> 	if (sub_size < sizeof(u32)) {
> 		ret = -ENOSPC;
> 		goto out_clear;
> 	}
> 
> What is this test for anyway?
> 
> If sub_size < 4 ?
>  return -ENOSPACE ?
> 
> ENOSPC seem like a weird return for this.
> 
> Wouldn't EINVAL be a better return code for this?

Thanks, good point.

It is to ensure that each subrange is large enough for 32-bit accesses.
I must have used -ENOSPC here thinking of it as "no space for subrange
mapping".

However, subranges smaller than 32-bit do not make sense for this test, and
-EINVAL seems more appropriate here as you pointed out. Also, the PCIe spec
defines the minimum Memory Space BAR size as 128 bytes, so subranges
smaller than that would not normally exist in practice, which also aligns
better with -EINVAL than -ENOSPC.

That would keep -ENOSPC reserved for actual resource limitations (i.e.
inbound regions limitation).

Best regards,
Koichiro

> 
> 
> Kind regards,
> Niklas

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

* Re: [PATCH 3/3] misc: pci_endpoint_test: Handle -ENOSPC in subrange mapping test case
  2026-03-20 13:25         ` Christian Bruel
@ 2026-03-20 13:43           ` Niklas Cassel
  0 siblings, 0 replies; 18+ messages in thread
From: Niklas Cassel @ 2026-03-20 13:43 UTC (permalink / raw)
  To: Christian Bruel
  Cc: Manivannan Sadhasivam, Krzysztof Wilczyński,
	Kishon Vijay Abraham I, Shuah Khan, Bjorn Helgaas, Arnd Bergmann,
	Greg Kroah-Hartman, Koichiro Den, fabrice.gasnier, linux-pci,
	linux-kselftest, linux-kernel

On Fri, Mar 20, 2026 at 02:25:10PM +0100, Christian Bruel wrote:
> On 3/20/26 12:16, Niklas Cassel wrote:
> > 
> > FWIW, I think an even better solution is to introduce a new register,
> > named e.g. errno in struct pci_epf_test_reg;
> > 
> > That way, we don't need to take a new bit, e.g.:
> > +#define STATUS_BAR_SUBRANGE_SETUP_NOSPC          BIT(18)
> > 
> > For every unique error code a command can return.
> > 
> > We would simply return STATUS_BAR_SUBRANGE_CLEAR_FAIL, and then the host
> > side driver looks at the errno register to see the specific error code.
> > 
> > This way, all other _FAIL commands could also return a more specific error
> > in case of failure.

(snip)

> But it is not consistent with other tests that use the status field to carry
> error information. For example, pci_epf_test_read/write/copy, set the
> STATUS_SRC/DTS_ADDR_INVALID bit to distinguish these errors from other
> -EINVAL.
> 
> Introducing a new errno field would result in having two different APIs for
> returning failure status.
> 
> In light of the STATUS_SRC/DST_ADDR_INVALID usage, I wonder if my initial
> proposal to set a status bit along with the FAIL bit might actually be
> simpler and more consistent what is already done here.

You are right that the read/write/copy tests actually set two bits in the
status register.

With:
#define STATUS_SRC_ADDR_INVALID         BIT(7)
#define STATUS_DST_ADDR_INVALID         BIT(8)

Potentially being reused by the write/copy/read tests.

At least these bits are reuse for more than one test case.

So, perhaps to keep things in line with the existing design
perhaps just name the new bit something like:

#define STATUS_SKIP_INSUFFICIENT_RESOURCES	BIT(18)

or something like that.

At least then, other test cases will be able to reuse this status bit,
just like multiple test cases can use the STATUS_SRC_ADDR_INVALID status
bits.


And yes, I agree that, like you do in your initial proposal, having this
new STATUS_SKIP_INSUFFICIENT_RESOURCES bit set in addition to the
STATUS_BAR_SUBRANGE_CLEAR_FAIL bit, is probably the best way forward that
is in line with the current design.


Kind regards,
Niklas

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

* Re: [PATCH 1/3] selftests: pci_endpoint: Skip subrange map test if iATU allocation fails
  2026-03-20 10:04     ` Christian Bruel
@ 2026-03-20 14:05       ` Koichiro Den
  2026-03-20 14:19         ` Christian Bruel
  0 siblings, 1 reply; 18+ messages in thread
From: Koichiro Den @ 2026-03-20 14:05 UTC (permalink / raw)
  To: Christian Bruel
  Cc: Manivannan Sadhasivam, Krzysztof Wilczyński,
	Kishon Vijay Abraham I, Shuah Khan, Bjorn Helgaas, Arnd Bergmann,
	Greg Kroah-Hartman, Niklas Cassel, fabrice.gasnier, linux-pci,
	linux-kselftest, linux-kernel

On Fri, Mar 20, 2026 at 11:04:28AM +0100, Christian Bruel wrote:
> Hello Koichiro, thank you for your comment
> 
> On 3/19/26 02:28, Koichiro Den wrote:
> > On Wed, Mar 18, 2026 at 03:46:27PM +0100, Christian Bruel wrote:
> > > Handle -ENOSPC error. If the number of available inbound ATU entries is
> > > insufficient to map the subrange, skip the test instead of failing.
> > > 
> > > Link: https://lore.kernel.org/linux-pci/20260317152707.GA85951@bhelgaas/T/#m87e4c24173097a0ea70195b71aab294ad8d6c283
> > > Signed-off-by: Christian Bruel <christian.bruel@foss.st.com>
> > > ---
> > >   tools/testing/selftests/pci_endpoint/pci_endpoint_test.c | 2 ++
> > >   1 file changed, 2 insertions(+)
> > > 
> > > diff --git a/tools/testing/selftests/pci_endpoint/pci_endpoint_test.c b/tools/testing/selftests/pci_endpoint/pci_endpoint_test.c
> > > index c417fb3a198b2d92c3060938c23807cc8bea5573..8ea2fda4539d11eb22b22800a7cb8bbaa99c91ba 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 ATU entries to allocate subrange");
> > 
> > Thank you for handling this!
> > 
> > pci_endpoint_test_bar_subrange() can also return -ENOSPC locally:
> > https://github.com/torvalds/linux/blob/v7.0-rc4/drivers/misc/pci_endpoint_test.c#L538
> > While that is a different resource limit case, I think it would still be
> > reasonable to treat it as SKIP as well.
> 
> Regarding Niklas's feedback to use the local EINVAL instead of ENOSPC in
> pci_endpoint_test_bar_subrange(), I prefer to leave this for you to handle.
> That will cover this case.

So could you consider the following tiny patch as a prerequisite for your
series?
https://lore.kernel.org/linux-pci/20260320140139.2415480-1-den@valinux.co.jp/

> 
> > 
> > If you agree and keep your current approach, then I think the SKIP message
> > might be better phrased more generically, e.g. "Insufficient resources".
> 
> OK I agree, the error message should be less specific to DWC terminology,
> even though this case can currently only occur on it.

Yes, I agree. As mentioned in my reply to Niklas, the other -ENOSPC is better
replaced with -EINVAL, so I just submitted a tiny patch. That concern should be
resolved.

> 
> > 
> > If you prefer to keep that local case as FAIL (or at least distinguish it
> > with a different SKIP message), that would likely require a bit more
> > changes overall. Note: Niklas' earlier feedback on the SKIP message would
> > still apply.
> 
> OK, as Niklas also suggested, I will not set an additional local bit besides
> the fail bit. The question is whether we should name it SKIP or NOSPC. I
> slightly prefer NOSPC, as this is what is used in the selftest to indicate
> skipping.

Personally, Niklas' "errno in struct pci_epf_test_reg" idea sounds the best
among the options discussed so far.

Best regards,
Koichiro

> 
> thank you
> 
> Christian
> 
> > 
> > Best regards,
> > Koichiro
> > 
> > >   	EXPECT_FALSE(ret) TH_LOG("Test failed for BAR%d", variant->barno);
> > >   }
> > > 
> > > -- 
> > > 2.34.1
> > > 
> 

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

* Re: [PATCH 1/3] selftests: pci_endpoint: Skip subrange map test if iATU allocation fails
  2026-03-20 14:05       ` Koichiro Den
@ 2026-03-20 14:19         ` Christian Bruel
  2026-03-20 15:33           ` Koichiro Den
  0 siblings, 1 reply; 18+ messages in thread
From: Christian Bruel @ 2026-03-20 14:19 UTC (permalink / raw)
  To: Koichiro Den
  Cc: Manivannan Sadhasivam, Krzysztof Wilczyński,
	Kishon Vijay Abraham I, Shuah Khan, Bjorn Helgaas, Arnd Bergmann,
	Greg Kroah-Hartman, Niklas Cassel, fabrice.gasnier, linux-pci,
	linux-kselftest, linux-kernel



On 3/20/26 15:05, Koichiro Den wrote:
> On Fri, Mar 20, 2026 at 11:04:28AM +0100, Christian Bruel wrote:
>> Hello Koichiro, thank you for your comment
>>
>> On 3/19/26 02:28, Koichiro Den wrote:
>>> On Wed, Mar 18, 2026 at 03:46:27PM +0100, Christian Bruel wrote:
>>>> Handle -ENOSPC error. If the number of available inbound ATU entries is
>>>> insufficient to map the subrange, skip the test instead of failing.
>>>>
>>>> Link: https://lore.kernel.org/linux-pci/20260317152707.GA85951@bhelgaas/T/#m87e4c24173097a0ea70195b71aab294ad8d6c283
>>>> Signed-off-by: Christian Bruel <christian.bruel@foss.st.com>
>>>> ---
>>>>    tools/testing/selftests/pci_endpoint/pci_endpoint_test.c | 2 ++
>>>>    1 file changed, 2 insertions(+)
>>>>
>>>> diff --git a/tools/testing/selftests/pci_endpoint/pci_endpoint_test.c b/tools/testing/selftests/pci_endpoint/pci_endpoint_test.c
>>>> index c417fb3a198b2d92c3060938c23807cc8bea5573..8ea2fda4539d11eb22b22800a7cb8bbaa99c91ba 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 ATU entries to allocate subrange");
>>>
>>> Thank you for handling this!
>>>
>>> pci_endpoint_test_bar_subrange() can also return -ENOSPC locally:
>>> https://github.com/torvalds/linux/blob/v7.0-rc4/drivers/misc/pci_endpoint_test.c#L538
>>> While that is a different resource limit case, I think it would still be
>>> reasonable to treat it as SKIP as well.
>>
>> Regarding Niklas's feedback to use the local EINVAL instead of ENOSPC in
>> pci_endpoint_test_bar_subrange(), I prefer to leave this for you to handle.
>> That will cover this case.
> 
> So could you consider the following tiny patch as a prerequisite for your
> series?
> https://lore.kernel.org/linux-pci/20260320140139.2415480-1-den@valinux.co.jp/

sure, thank you

> 
>>
>>>
>>> If you agree and keep your current approach, then I think the SKIP message
>>> might be better phrased more generically, e.g. "Insufficient resources".
>>
>> OK I agree, the error message should be less specific to DWC terminology,
>> even though this case can currently only occur on it.
> 
> Yes, I agree. As mentioned in my reply to Niklas, the other -ENOSPC is better
> replaced with -EINVAL, so I just submitted a tiny patch. That concern should be
> resolved.
> 
>>
>>>
>>> If you prefer to keep that local case as FAIL (or at least distinguish it
>>> with a different SKIP message), that would likely require a bit more
>>> changes overall. Note: Niklas' earlier feedback on the SKIP message would
>>> still apply.
>>
>> OK, as Niklas also suggested, I will not set an additional local bit besides
>> the fail bit. The question is whether we should name it SKIP or NOSPC. I
>> slightly prefer NOSPC, as this is what is used in the selftest to indicate
>> skipping.
> 
> Personally, Niklas' "errno in struct pci_epf_test_reg" idea sounds the best
> among the options discussed so far.

It is a good solution but does not match very well with the other 
existing API (See the STATUS_SRC/DST_ADDR_INVALID bits). Thus, we will 
keep the existing method of reporting errors using a second bit 
alongside the FAIL bit.


> 
> Best regards,
> Koichiro
> 
>>
>> thank you
>>
>> Christian
>>
>>>
>>> Best regards,
>>> Koichiro
>>>
>>>>    	EXPECT_FALSE(ret) TH_LOG("Test failed for BAR%d", variant->barno);
>>>>    }
>>>>
>>>> -- 
>>>> 2.34.1
>>>>
>>


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

* Re: [PATCH 1/3] selftests: pci_endpoint: Skip subrange map test if iATU allocation fails
  2026-03-20 14:19         ` Christian Bruel
@ 2026-03-20 15:33           ` Koichiro Den
  0 siblings, 0 replies; 18+ messages in thread
From: Koichiro Den @ 2026-03-20 15:33 UTC (permalink / raw)
  To: Christian Bruel
  Cc: Manivannan Sadhasivam, Krzysztof Wilczyński,
	Kishon Vijay Abraham I, Shuah Khan, Bjorn Helgaas, Arnd Bergmann,
	Greg Kroah-Hartman, Niklas Cassel, fabrice.gasnier, linux-pci,
	linux-kselftest, linux-kernel

On Fri, Mar 20, 2026 at 03:19:15PM +0100, Christian Bruel wrote:
> 
> 
> On 3/20/26 15:05, Koichiro Den wrote:
> > On Fri, Mar 20, 2026 at 11:04:28AM +0100, Christian Bruel wrote:
> > > Hello Koichiro, thank you for your comment
> > > 
> > > On 3/19/26 02:28, Koichiro Den wrote:
> > > > On Wed, Mar 18, 2026 at 03:46:27PM +0100, Christian Bruel wrote:
> > > > > Handle -ENOSPC error. If the number of available inbound ATU entries is
> > > > > insufficient to map the subrange, skip the test instead of failing.
> > > > > 
> > > > > Link: https://lore.kernel.org/linux-pci/20260317152707.GA85951@bhelgaas/T/#m87e4c24173097a0ea70195b71aab294ad8d6c283
> > > > > Signed-off-by: Christian Bruel <christian.bruel@foss.st.com>
> > > > > ---
> > > > >    tools/testing/selftests/pci_endpoint/pci_endpoint_test.c | 2 ++
> > > > >    1 file changed, 2 insertions(+)
> > > > > 
> > > > > diff --git a/tools/testing/selftests/pci_endpoint/pci_endpoint_test.c b/tools/testing/selftests/pci_endpoint/pci_endpoint_test.c
> > > > > index c417fb3a198b2d92c3060938c23807cc8bea5573..8ea2fda4539d11eb22b22800a7cb8bbaa99c91ba 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 ATU entries to allocate subrange");
> > > > 
> > > > Thank you for handling this!
> > > > 
> > > > pci_endpoint_test_bar_subrange() can also return -ENOSPC locally:
> > > > https://github.com/torvalds/linux/blob/v7.0-rc4/drivers/misc/pci_endpoint_test.c#L538
> > > > While that is a different resource limit case, I think it would still be
> > > > reasonable to treat it as SKIP as well.
> > > 
> > > Regarding Niklas's feedback to use the local EINVAL instead of ENOSPC in
> > > pci_endpoint_test_bar_subrange(), I prefer to leave this for you to handle.
> > > That will cover this case.
> > 
> > So could you consider the following tiny patch as a prerequisite for your
> > series?
> > https://lore.kernel.org/linux-pci/20260320140139.2415480-1-den@valinux.co.jp/
> 
> sure, thank you
> 
> > 
> > > 
> > > > 
> > > > If you agree and keep your current approach, then I think the SKIP message
> > > > might be better phrased more generically, e.g. "Insufficient resources".
> > > 
> > > OK I agree, the error message should be less specific to DWC terminology,
> > > even though this case can currently only occur on it.
> > 
> > Yes, I agree. As mentioned in my reply to Niklas, the other -ENOSPC is better
> > replaced with -EINVAL, so I just submitted a tiny patch. That concern should be
> > resolved.
> > 
> > > 
> > > > 
> > > > If you prefer to keep that local case as FAIL (or at least distinguish it
> > > > with a different SKIP message), that would likely require a bit more
> > > > changes overall. Note: Niklas' earlier feedback on the SKIP message would
> > > > still apply.
> > > 
> > > OK, as Niklas also suggested, I will not set an additional local bit besides
> > > the fail bit. The question is whether we should name it SKIP or NOSPC. I
> > > slightly prefer NOSPC, as this is what is used in the selftest to indicate
> > > skipping.
> > 
> > Personally, Niklas' "errno in struct pci_epf_test_reg" idea sounds the best
> > among the options discussed so far.
> 
> It is a good solution but does not match very well with the other existing
> API (See the STATUS_SRC/DST_ADDR_INVALID bits). Thus, we will keep the
> existing method of reporting errors using a second bit alongside the FAIL
> bit.

Understood. Thank you!

Koichiro

> 
> 
> > 
> > Best regards,
> > Koichiro
> > 
> > > 
> > > thank you
> > > 
> > > Christian
> > > 
> > > > 
> > > > Best regards,
> > > > Koichiro
> > > > 
> > > > >    	EXPECT_FALSE(ret) TH_LOG("Test failed for BAR%d", variant->barno);
> > > > >    }
> > > > > 
> > > > > -- 
> > > > > 2.34.1
> > > > > 
> > > 
> 

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

end of thread, other threads:[~2026-03-20 15:33 UTC | newest]

Thread overview: 18+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2026-03-18 14:46 [PATCH 0/3] Skip subrange map tests on DWC iATU allocation failure Christian Bruel
2026-03-18 14:46 ` [PATCH 1/3] selftests: pci_endpoint: Skip subrange map test if iATU allocation fails Christian Bruel
2026-03-18 15:32   ` Niklas Cassel
2026-03-19  1:28   ` Koichiro Den
2026-03-19  8:47     ` Niklas Cassel
2026-03-20 13:41       ` Koichiro Den
2026-03-20 10:04     ` Christian Bruel
2026-03-20 14:05       ` Koichiro Den
2026-03-20 14:19         ` Christian Bruel
2026-03-20 15:33           ` Koichiro Den
2026-03-18 14:46 ` [PATCH 2/3] PCI: endpoint: pci-epf-test: Handle -ENOSPC in subrange map test Christian Bruel
2026-03-18 15:50   ` Niklas Cassel
2026-03-18 14:46 ` [PATCH 3/3] misc: pci_endpoint_test: Handle -ENOSPC in subrange mapping test case Christian Bruel
2026-03-18 16:03   ` Niklas Cassel
2026-03-20  9:35     ` Christian Bruel
2026-03-20 11:16       ` Niklas Cassel
2026-03-20 13:25         ` Christian Bruel
2026-03-20 13:43           ` Niklas Cassel

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox