[PATCH v3 1/3] PCI: endpoint: pci-epf-test: Handle -ENOSPC in subrange_setup

From: Christian Bruel

Date: Mon Mar 23 2026 - 08:01:47 EST


Set the STATUS_NO_RESOURCE status bit on pci_epc_set_bar() -ENOSPC.
Here this is used to indicate there are not enough inbound window resources
to allocate the subrange.

Signed-off-by: Christian Bruel <christian.bruel@xxxxxxxxxxx>
Reviewed-by: Niklas Cassel <cassel@xxxxxxxxxx>
---
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 06bf53b28fb7ae2244a6d82bd5fe76d40db830b7..591d301fa89d89addf5df16e775e80460b689589 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;
ret = pci_epc_set_bar(epc, epf->func_no, epf->vfunc_no, bar);

--
2.34.1