Currently, the test allocates BAR sizes according to fixed table bar_size[] = { 512, 512, 1024, 16384, 131072, 1048576 } . This does not work with controllers which have fixed size BARs, like Renesas R-Car V4H PCIe controller, which has BAR4 size limited to 256 Bytes, which is much less than 131072 currently requested by this test. Adjust the test such, that in case a fixed size BAR is detected on a controller, minimum of requested size and fixed size BAR size is used during the test instead. This helps with test failures reported as follows: " pci_epf_test pci_epf_test.0: requested BAR size is larger than fixed size pci_epf_test pci_epf_test.0: Failed to allocate space for BAR4 " Signed-off-by: Marek Vasut <marek.vasut+renesas@xxxxxxxxxxx> --- Cc: "Krzysztof Wilczyński" <kwilczynski@xxxxxxxxxx> Cc: Bjorn Helgaas <bhelgaas@xxxxxxxxxx> Cc: Damien Le Moal <dlemoal@xxxxxxxxxx> Cc: Frank Li <Frank.Li@xxxxxxx> Cc: Jerome Brunet <jbrunet@xxxxxxxxxxxx> Cc: Kishon Vijay Abraham I <kishon@xxxxxxxxxx> Cc: Manivannan Sadhasivam <mani@xxxxxxxxxx> Cc: Niklas Cassel <cassel@xxxxxxxxxx> Cc: Wang Jiang <jiangwang@xxxxxxxxxx> Cc: linux-kernel@xxxxxxxxxxxxxxx Cc: linux-pci@xxxxxxxxxxxxxxx Cc: linux-renesas-soc@xxxxxxxxxxxxxxx --- V2: Simplify the conditional to always use fixed size BAR size for test --- drivers/pci/endpoint/functions/pci-epf-test.c | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/drivers/pci/endpoint/functions/pci-epf-test.c b/drivers/pci/endpoint/functions/pci-epf-test.c index e091193bd8a8a..2418add64104a 100644 --- a/drivers/pci/endpoint/functions/pci-epf-test.c +++ b/drivers/pci/endpoint/functions/pci-epf-test.c @@ -1050,7 +1050,12 @@ static int pci_epf_test_alloc_space(struct pci_epf *epf) if (bar == test_reg_bar) continue; - base = pci_epf_alloc_space(epf, bar_size[bar], bar, + if (epc_features->bar[bar].type == BAR_FIXED) + test_reg_size = epc_features->bar[bar].fixed_size; + else + test_reg_size = bar_size[bar]; + + base = pci_epf_alloc_space(epf, test_reg_size, bar, epc_features, PRIMARY_INTERFACE); if (!base) dev_err(dev, "Failed to allocate space for BAR%d\n", -- 2.50.1