Skip to content

Commit 2164767

Browse files
Koichiro Denbjorn-helgaas
authored andcommitted
PCI: endpoint: pci-epf-test: Roll back BAR mapping when subrange setup fails
When the BAR subrange mapping test on DWC-based platforms fails due to insufficient free inbound iATU regions, pci_epf_test_bar_subrange_setup() returns an error (-ENOSPC) but does not restore the original BAR mapping. This causes subsequent test runs to become confusing, since the failure may leave room for the next subrange mapping test to pass. Fix this by restoring the original BAR mapping when preparation of the subrange mapping fails, so that no side effect remains regardless of the test success or failure. Fixes: 6c5e610 ("PCI: endpoint: pci-epf-test: Add BAR subrange mapping test support") Reported-by: Christian Bruel <[email protected]> Closes: https://lore.kernel.org/linux-pci/[email protected]/ Signed-off-by: Koichiro Den <[email protected]> Signed-off-by: Bjorn Helgaas <[email protected]> Tested-by: Christian Bruel <[email protected]> Reviewed-by: Niklas Cassel <[email protected]> Reviewed-by: Manivannan Sadhasivam <[email protected]> Link: https://patch.msgid.link/[email protected]
1 parent ee22665 commit 2164767

1 file changed

Lines changed: 5 additions & 0 deletions

File tree

drivers/pci/endpoint/functions/pci-epf-test.c

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -894,6 +894,11 @@ static void pci_epf_test_bar_subrange_setup(struct pci_epf_test *epf_test,
894894
dev_err(&epf->dev, "pci_epc_set_bar() failed: %d\n", ret);
895895
bar->submap = old_submap;
896896
bar->num_submap = old_nsub;
897+
ret = pci_epc_set_bar(epc, epf->func_no, epf->vfunc_no, bar);
898+
if (ret)
899+
dev_warn(&epf->dev, "Failed to restore the original BAR mapping: %d\n",
900+
ret);
901+
897902
kfree(submap);
898903
goto err;
899904
}

0 commit comments

Comments
 (0)