Linux kernel mirror (for testing) git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
kernel os linux
1
fork

Configure Feed

Select the types of activity you want to include in your feed.

misc: pci_endpoint_test: Give reserved BARs a distinct error code

Give reserved BARs a distinct error code, such that the pci_endpoint_test
selftest will be able to skip test cases that are run against reserved
BARs.

Signed-off-by: Niklas Cassel <cassel@kernel.org>
[mani: Used __fls(CAP_BAR0_RESERVED) instead of PCI_ENDPOINT_CAP_BAR0_RESERVED_BIT]
Signed-off-by: Manivannan Sadhasivam <mani@kernel.org>
Tested-by: Manikanta Maddireddy <mmaddireddy@nvidia.com>
Tested-by: Koichiro Den <den@valinux.co.jp>
Reviewed-by: Frank Li <Frank.Li@nxp.com>
Link: https://patch.msgid.link/20260312130229.2282001-21-cassel@kernel.org

authored by

Niklas Cassel and committed by
Manivannan Sadhasivam
c3f33af6 50a1fd6e

+18 -2
+18 -2
drivers/misc/pci_endpoint_test.c
··· 85 85 #define CAP_INTX BIT(3) 86 86 #define CAP_SUBRANGE_MAPPING BIT(4) 87 87 #define CAP_DYNAMIC_INBOUND_MAPPING BIT(5) 88 + #define CAP_BAR0_RESERVED BIT(6) 89 + #define CAP_BAR1_RESERVED BIT(7) 90 + #define CAP_BAR2_RESERVED BIT(8) 91 + #define CAP_BAR3_RESERVED BIT(9) 92 + #define CAP_BAR4_RESERVED BIT(10) 93 + #define CAP_BAR5_RESERVED BIT(11) 88 94 89 95 #define PCI_ENDPOINT_TEST_DB_BAR 0x34 90 96 #define PCI_ENDPOINT_TEST_DB_OFFSET 0x38 ··· 282 276 return ret; 283 277 } 284 278 279 + static bool bar_is_reserved(struct pci_endpoint_test *test, enum pci_barno bar) 280 + { 281 + return test->ep_caps & BIT(bar + __fls(CAP_BAR0_RESERVED)); 282 + } 283 + 285 284 static const u32 bar_test_pattern[] = { 286 285 0xA0A0A0A0, 287 286 0xA1A1A1A1, ··· 415 404 416 405 /* Write all BARs in order (without reading). */ 417 406 for (bar = 0; bar < PCI_STD_NUM_BARS; bar++) 418 - if (test->bar[bar]) 407 + if (test->bar[bar] && !bar_is_reserved(test, bar)) 419 408 pci_endpoint_test_bars_write_bar(test, bar); 420 409 421 410 /* ··· 425 414 * (Reading back the BAR directly after writing can not detect this.) 426 415 */ 427 416 for (bar = 0; bar < PCI_STD_NUM_BARS; bar++) { 428 - if (test->bar[bar]) { 417 + if (test->bar[bar] && !bar_is_reserved(test, bar)) { 429 418 ret = pci_endpoint_test_bars_read_bar(test, bar); 430 419 if (ret) 431 420 return ret; ··· 1153 1142 goto ret; 1154 1143 if (is_am654_pci_dev(pdev) && bar == BAR_0) 1155 1144 goto ret; 1145 + 1146 + if (bar_is_reserved(test, bar)) { 1147 + ret = -ENOBUFS; 1148 + goto ret; 1149 + } 1156 1150 1157 1151 if (cmd == PCITEST_BAR) 1158 1152 ret = pci_endpoint_test_bar(test, bar);