]> git.ipfire.org Git - thirdparty/kernel/stable.git/commitdiff
PCI: endpoint: pci-epf-test: Limit PCIe BAR size for fixed BARs
authorMarek Vasut <marek.vasut+renesas@mailbox.org>
Fri, 5 Sep 2025 18:42:10 +0000 (20:42 +0200)
committerGreg Kroah-Hartman <gregkh@linuxfoundation.org>
Thu, 13 Nov 2025 20:37:16 +0000 (15:37 -0500)
[ Upstream commit d5f6bd3ee3f5048f272182dc91675c082773999e ]

Currently, the test allocates BAR sizes according to fixed table bar_size.
This does not work with controllers which have fixed size BARs that are
smaller than the requested BAR size. One such controller is Renesas R-Car
V4H PCIe controller, which has BAR4 size limited to 256 bytes, which is
much less than one of the BAR size, 131072 currently requested by this
test. A lot of controllers drivers in-tree have fixed size BARs, and they
do work perfectly fine, but it is only because their fixed size is larger
than the size requested by pci-epf-test.c

Adjust the test such that in case a fixed size BAR is detected, the fixed
BAR size is used, as that is the only possible option.

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@mailbox.org>
[mani: reworded description]
Signed-off-by: Manivannan Sadhasivam <mani@kernel.org>
Signed-off-by: Bjorn Helgaas <bhelgaas@google.com>
Reviewed-by: Niklas Cassel <cassel@kernel.org>
Link: https://patch.msgid.link/20250905184240.144431-1-marek.vasut+renesas@mailbox.org
Signed-off-by: Sasha Levin <sashal@kernel.org>
drivers/pci/endpoint/functions/pci-epf-test.c

index 044f5ea0716d1f6812e4d5f6338cc7dc8134a969..31617772ad5165e3d2f156c327a18179f3b8aa07 100644 (file)
@@ -1067,7 +1067,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",