Skip to content

Commit 7e80bbe

Browse files
floatiouskwilczynski
authored andcommitted
misc: pci_endpoint_test: Give disabled BARs a distinct error code
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 <[email protected]> Reviewed-by: Manivannan Sadhasivam <[email protected]> Link: https://lore.kernel.org/r/[email protected] Signed-off-by: Manivannan Sadhasivam <[email protected]> [kwilczynski: commit log] Signed-off-by: Krzysztof Wilczyński <[email protected]>
1 parent c727ebe commit 7e80bbe

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
@@ -292,11 +292,13 @@ static int pci_endpoint_test_bar(struct pci_endpoint_test *test,
292292
void *read_buf __free(kfree) = NULL;
293293
struct pci_dev *pdev = test->pdev;
294294

295+
bar_size = pci_resource_len(pdev, barno);
296+
if (!bar_size)
297+
return -ENODATA;
298+
295299
if (!test->bar[barno])
296300
return -ENOMEM;
297301

298-
bar_size = pci_resource_len(pdev, barno);
299-
300302
if (barno == test->test_reg_bar)
301303
bar_size = 0x4;
302304

0 commit comments

Comments
 (0)