mirror of
https://git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
synced 2026-05-16 03:11:11 -04:00
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
This commit is contained in:
committed by
Manivannan Sadhasivam
parent
50a1fd6e5e
commit
c3f33af67e
@@ -85,6 +85,12 @@
|
||||
#define CAP_INTX BIT(3)
|
||||
#define CAP_SUBRANGE_MAPPING BIT(4)
|
||||
#define CAP_DYNAMIC_INBOUND_MAPPING BIT(5)
|
||||
#define CAP_BAR0_RESERVED BIT(6)
|
||||
#define CAP_BAR1_RESERVED BIT(7)
|
||||
#define CAP_BAR2_RESERVED BIT(8)
|
||||
#define CAP_BAR3_RESERVED BIT(9)
|
||||
#define CAP_BAR4_RESERVED BIT(10)
|
||||
#define CAP_BAR5_RESERVED BIT(11)
|
||||
|
||||
#define PCI_ENDPOINT_TEST_DB_BAR 0x34
|
||||
#define PCI_ENDPOINT_TEST_DB_OFFSET 0x38
|
||||
@@ -276,6 +282,11 @@ static int pci_endpoint_test_request_irq(struct pci_endpoint_test *test)
|
||||
return ret;
|
||||
}
|
||||
|
||||
static bool bar_is_reserved(struct pci_endpoint_test *test, enum pci_barno bar)
|
||||
{
|
||||
return test->ep_caps & BIT(bar + __fls(CAP_BAR0_RESERVED));
|
||||
}
|
||||
|
||||
static const u32 bar_test_pattern[] = {
|
||||
0xA0A0A0A0,
|
||||
0xA1A1A1A1,
|
||||
@@ -404,7 +415,7 @@ static int pci_endpoint_test_bars(struct pci_endpoint_test *test)
|
||||
|
||||
/* Write all BARs in order (without reading). */
|
||||
for (bar = 0; bar < PCI_STD_NUM_BARS; bar++)
|
||||
if (test->bar[bar])
|
||||
if (test->bar[bar] && !bar_is_reserved(test, bar))
|
||||
pci_endpoint_test_bars_write_bar(test, bar);
|
||||
|
||||
/*
|
||||
@@ -414,7 +425,7 @@ static int pci_endpoint_test_bars(struct pci_endpoint_test *test)
|
||||
* (Reading back the BAR directly after writing can not detect this.)
|
||||
*/
|
||||
for (bar = 0; bar < PCI_STD_NUM_BARS; bar++) {
|
||||
if (test->bar[bar]) {
|
||||
if (test->bar[bar] && !bar_is_reserved(test, bar)) {
|
||||
ret = pci_endpoint_test_bars_read_bar(test, bar);
|
||||
if (ret)
|
||||
return ret;
|
||||
@@ -1143,6 +1154,11 @@ static long pci_endpoint_test_ioctl(struct file *file, unsigned int cmd,
|
||||
if (is_am654_pci_dev(pdev) && bar == BAR_0)
|
||||
goto ret;
|
||||
|
||||
if (bar_is_reserved(test, bar)) {
|
||||
ret = -ENOBUFS;
|
||||
goto ret;
|
||||
}
|
||||
|
||||
if (cmd == PCITEST_BAR)
|
||||
ret = pci_endpoint_test_bar(test, bar);
|
||||
else
|
||||
|
||||
Reference in New Issue
Block a user