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 <[email protected]>
Reviewed-by: Niklas Cassel <[email protected]>
Reviewed-by: Frank Li <[email protected]>
Reviewed-by: Koichiro Den <[email protected]>
---
 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..7eb94dffac2d193477a43decd7b952c78b99eb5f
 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);

-- 
2.34.1


Reply via email to