From: Niklas Cassel <cassel@kernel.org>
To: "Manivannan Sadhasivam" <mani@kernel.org>,
"Krzysztof Wilczyński" <kwilczynski@kernel.org>,
"Kishon Vijay Abraham I" <kishon@kernel.org>,
"Arnd Bergmann" <arnd@arndb.de>,
"Greg Kroah-Hartman" <gregkh@linuxfoundation.org>
Cc: Manikanta Maddireddy <mmaddireddy@nvidia.com>,
Koichiro Den <den@valinux.co.jp>,
Damien Le Moal <dlemoal@kernel.org>,
Niklas Cassel <cassel@kernel.org>, Frank Li <Frank.Li@nxp.com>,
linux-pci@vger.kernel.org
Subject: [PATCH v3 8/9] misc: pci_endpoint_test: Give reserved BARs a distinct error code
Date: Mon, 2 Mar 2026 10:59:20 +0100 [thread overview]
Message-ID: <20260302095913.48155-19-cassel@kernel.org> (raw)
In-Reply-To: <20260302095913.48155-11-cassel@kernel.org>
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.
Tested-by: Manikanta Maddireddy <mmaddireddy@nvidia.com>
Reviewed-by: Frank Li <Frank.Li@nxp.com>
Tested-by: Koichiro Den <den@valinux.co.jp>
Signed-off-by: Niklas Cassel <cassel@kernel.org>
---
drivers/misc/pci_endpoint_test.c | 21 +++++++++++++++++++--
1 file changed, 19 insertions(+), 2 deletions(-)
diff --git a/drivers/misc/pci_endpoint_test.c b/drivers/misc/pci_endpoint_test.c
index 93cd57d20881..89d0aba059da 100644
--- a/drivers/misc/pci_endpoint_test.c
+++ b/drivers/misc/pci_endpoint_test.c
@@ -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
@@ -109,6 +115,7 @@
#define PCI_DEVICE_ID_ROCKCHIP_RK3588 0x3588
#define PCI_ENDPOINT_TEST_BAR_SUBRANGE_NSUB 2
+#define PCI_ENDPOINT_CAP_BAR0_RESERVED_BIT 6
static DEFINE_IDA(pci_endpoint_test_ida);
@@ -276,6 +283,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 + PCI_ENDPOINT_CAP_BAR0_RESERVED_BIT);
+}
+
static const u32 bar_test_pattern[] = {
0xA0A0A0A0,
0xA1A1A1A1,
@@ -404,7 +416,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 +426,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 +1155,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
--
2.53.0
next prev parent reply other threads:[~2026-03-02 10:00 UTC|newest]
Thread overview: 17+ messages / expand[flat|nested] mbox.gz Atom feed top
2026-03-02 9:59 [PATCH v3 0/9] PCI: endpoint: Differentiate between disabled and reserved BARs Niklas Cassel
2026-03-02 9:59 ` Niklas Cassel
2026-03-02 9:59 ` [PATCH v3 1/9] PCI: endpoint: Introduce pci_epc_bar_type BAR_64BIT_UPPER Niklas Cassel
2026-03-11 6:35 ` Manivannan Sadhasivam
2026-03-11 10:38 ` Niklas Cassel
2026-03-11 17:12 ` Manivannan Sadhasivam
2026-03-02 9:59 ` [PATCH v3 2/9] PCI: endpoint: Describe reserved subregions within BARs Niklas Cassel
2026-03-02 9:59 ` [PATCH v3 3/9] PCI: dw-rockchip: Describe RK3588 BAR4 DMA ctrl window Niklas Cassel
2026-03-02 9:59 ` Niklas Cassel
2026-03-02 9:59 ` [PATCH v3 4/9] PCI: endpoint: Introduce pci_epc_bar_type BAR_DISABLED Niklas Cassel
2026-03-02 9:59 ` [PATCH v3 5/9] PCI: dwc: Replace certain BAR_RESERVED with BAR_DISABLED in glue drivers Niklas Cassel
2026-03-02 9:59 ` [PATCH v3 6/9] PCI: dwc: Disable BARs in common code instead of in each glue driver Niklas Cassel
2026-03-02 9:59 ` Niklas Cassel
2026-03-02 9:59 ` [PATCH v3 7/9] PCI: endpoint: pci-epf-test: Advertise reserved BARs Niklas Cassel
2026-03-02 9:59 ` Niklas Cassel [this message]
2026-03-02 9:59 ` [PATCH v3 9/9] selftests: pci_endpoint: Skip " Niklas Cassel
2026-03-10 9:54 ` [PATCH v3 0/9] PCI: endpoint: Differentiate between disabled and " Niklas Cassel
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=20260302095913.48155-19-cassel@kernel.org \
--to=cassel@kernel.org \
--cc=Frank.Li@nxp.com \
--cc=arnd@arndb.de \
--cc=den@valinux.co.jp \
--cc=dlemoal@kernel.org \
--cc=gregkh@linuxfoundation.org \
--cc=kishon@kernel.org \
--cc=kwilczynski@kernel.org \
--cc=linux-pci@vger.kernel.org \
--cc=mani@kernel.org \
--cc=mmaddireddy@nvidia.com \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.