summaryrefslogtreecommitdiff
path: root/tools
diff options
context:
space:
mode:
authorNiklas Cassel <cassel@kernel.org>2024-11-16 04:20:45 +0100
committerBjorn Helgaas <bhelgaas@google.com>2025-01-21 09:44:14 -0600
commitd6658d3338f84173fb55c9d6c6cdfa57f879712d (patch)
treeabf77eda6e1bff7309c53d27bd6a629953318289 /tools
parent0d292a1e6d90ff899342734d9ecfda59394daa42 (diff)
misc: pci_endpoint_test: Add consecutive BAR test
Add a more advanced BAR test that writes all BARs in one go, and then reads them back and verifies that the value matches the BAR number bitwise OR'ed with offset, this allows us to verify: - The BAR number was what we intended to read - The offset was what we intended to read This allows us to detect potential address translation issues on the EP. Reading back the BAR directly after writing will not allow us to detect the case where inbound address translation on the endpoint incorrectly causes multiple BARs to be redirected to the same memory region (within the EP). Link: https://lore.kernel.org/r/20241116032045.2574168-2-cassel@kernel.org Signed-off-by: Niklas Cassel <cassel@kernel.org> Signed-off-by: Krzysztof WilczyƄski <kwilczynski@kernel.org> Signed-off-by: Bjorn Helgaas <bhelgaas@google.com> Reviewed-by: Manivannan Sadhasivam <manivannan.sadhasivam@linaro.org>
Diffstat (limited to 'tools')
-rw-r--r--tools/pci/pcitest.c16
-rw-r--r--tools/pci/pcitest.sh1
2 files changed, 16 insertions, 1 deletions
diff --git a/tools/pci/pcitest.c b/tools/pci/pcitest.c
index 7b530d838d408..08f355083754c 100644
--- a/tools/pci/pcitest.c
+++ b/tools/pci/pcitest.c
@@ -22,6 +22,7 @@ static char *irq[] = { "LEGACY", "MSI", "MSI-X" };
struct pci_test {
char *device;
char barnum;
+ bool consecutive_bar_test;
bool legacyirq;
unsigned int msinum;
unsigned int msixnum;
@@ -57,6 +58,15 @@ static int run_test(struct pci_test *test)
fprintf(stdout, "%s\n", result[ret]);
}
+ if (test->consecutive_bar_test) {
+ ret = ioctl(fd, PCITEST_BARS);
+ fprintf(stdout, "Consecutive BAR test:\t\t");
+ if (ret < 0)
+ fprintf(stdout, "TEST FAILED\n");
+ else
+ fprintf(stdout, "%s\n", result[ret]);
+ }
+
if (test->set_irqtype) {
ret = ioctl(fd, PCITEST_SET_IRQTYPE, test->irqtype);
fprintf(stdout, "SET IRQ TYPE TO %s:\t\t", irq[test->irqtype]);
@@ -172,7 +182,7 @@ int main(int argc, char **argv)
/* set default endpoint device */
test->device = "/dev/pci-endpoint-test.0";
- while ((c = getopt(argc, argv, "D:b:m:x:i:deIlhrwcs:")) != EOF)
+ while ((c = getopt(argc, argv, "D:b:Cm:x:i:deIlhrwcs:")) != EOF)
switch (c) {
case 'D':
test->device = optarg;
@@ -182,6 +192,9 @@ int main(int argc, char **argv)
if (test->barnum < 0 || test->barnum > 5)
goto usage;
continue;
+ case 'C':
+ test->consecutive_bar_test = true;
+ continue;
case 'l':
test->legacyirq = true;
continue;
@@ -230,6 +243,7 @@ usage:
"Options:\n"
"\t-D <dev> PCI endpoint test device {default: /dev/pci-endpoint-test.0}\n"
"\t-b <bar num> BAR test (bar number between 0..5)\n"
+ "\t-C Consecutive BAR test\n"
"\t-m <msi num> MSI test (msi number between 1..32)\n"
"\t-x <msix num> \tMSI-X test (msix number between 1..2048)\n"
"\t-i <irq type> \tSet IRQ type (0 - Legacy, 1 - MSI, 2 - MSI-X)\n"
diff --git a/tools/pci/pcitest.sh b/tools/pci/pcitest.sh
index 75ed48ff29900..770f4d6df34b6 100644
--- a/tools/pci/pcitest.sh
+++ b/tools/pci/pcitest.sh
@@ -11,6 +11,7 @@ do
pcitest -b $bar
bar=`expr $bar + 1`
done
+pcitest -C
echo
echo "Interrupt tests"