Skip to content

Commit f615e8d

Browse files
floatiousgregkh
authored andcommitted
misc: pci_endpoint_test: Give disabled BARs a distinct error code
[ Upstream commit 7e80bbe ] The current code returns -ENOMEM if test->bar[barno] is NULL. There can be two reasons why test->bar[barno] is NULL: 1) The pci_ioremap_bar() call in pci_endpoint_test_probe() failed. 2) The BAR was skipped, because it is disabled by the endpoint. Many PCI endpoint controller drivers will disable all BARs in their init function. A disabled BAR will have a size of 0. A PCI endpoint function driver will be able to enable any BAR that is not marked as BAR_RESERVED (which means that the BAR should not be touched by the EPF driver). Thus, perform check if the size is 0, before checking if test->bar[barno] is NULL, such that we can return different errors. This will allow the selftests to return SKIP instead of FAIL for disabled BARs. Signed-off-by: Niklas Cassel <cassel@kernel.org> Reviewed-by: Manivannan Sadhasivam <manivannan.sadhasivam@linaro.org> Link: https://lore.kernel.org/r/20250123120147.3603409-3-cassel@kernel.org Signed-off-by: Manivannan Sadhasivam <manivannan.sadhasivam@linaro.org> [kwilczynski: commit log] Signed-off-by: Krzysztof Wilczyński <kwilczynski@kernel.org> Signed-off-by: Sasha Levin <sashal@kernel.org>
1 parent fe2329e commit f615e8d

File tree

1 file changed

+4
-2
lines changed

1 file changed

+4
-2
lines changed

drivers/misc/pci_endpoint_test.c

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -287,11 +287,13 @@ static bool pci_endpoint_test_bar(struct pci_endpoint_test *test,
287287
void *read_buf __free(kfree) = NULL;
288288
struct pci_dev *pdev = test->pdev;
289289

290+
bar_size = pci_resource_len(pdev, barno);
291+
if (!bar_size)
292+
return -ENODATA;
293+
290294
if (!test->bar[barno])
291295
return false;
292296

293-
bar_size = pci_resource_len(pdev, barno);
294-
295297
if (barno == test->test_reg_bar)
296298
bar_size = 0x4;
297299

0 commit comments

Comments
 (0)