]> git.ipfire.org Git - thirdparty/kernel/linux.git/commitdiff
selftests: pci_endpoint: Add doorbell test case
authorFrank Li <Frank.Li@nxp.com>
Thu, 10 Jul 2025 19:13:54 +0000 (15:13 -0400)
committerBjorn Helgaas <bhelgaas@google.com>
Thu, 24 Jul 2025 21:51:47 +0000 (16:51 -0500)
Add doorbell test case.

Signed-off-by: Frank Li <Frank.Li@nxp.com>
[mani: Reworded the testcase description]
Signed-off-by: Manivannan Sadhasivam <mani@kernel.org>
Signed-off-by: Bjorn Helgaas <bhelgaas@google.com>
Tested-by: Niklas Cassel <cassel@kernel.org>
Link: https://patch.msgid.link/20250710-ep-msi-v21-8-57683fc7fb25@nxp.com
Documentation/PCI/endpoint/pci-test-howto.rst
tools/testing/selftests/pci_endpoint/pci_endpoint_test.c

index aafc17ef3fd31f6ada38c82c8df133b87f7a1ae1..dd66858cde46270a50b05050c6016f8e8704d469 100644 (file)
@@ -203,3 +203,18 @@ controllers, it is advisable to skip this testcase using this
 command::
 
        # pci_endpoint_test -f pci_ep_bar -f pci_ep_basic -v memcpy -T COPY_TEST -v dma
+
+Kselftest EP Doorbell
+~~~~~~~~~~~~~~~~~~~~~
+
+If the Endpoint MSI controller is used for the doorbell usecase, run below
+command for testing it:
+
+       # pci_endpoint_test -f pcie_ep_doorbell
+
+       # Starting 1 tests from 1 test cases.
+       #  RUN           pcie_ep_doorbell.DOORBELL_TEST ...
+       #            OK  pcie_ep_doorbell.DOORBELL_TEST
+       ok 1 pcie_ep_doorbell.DOORBELL_TEST
+       # PASSED: 1 / 1 tests passed.
+       # Totals: pass:1 fail:0 xfail:0 xpass:0 skip:0 error:0
index ac26481d29d9dce5d07de563048850c55c58c22d..da0db0e7c9693f11b4975ca0e6830174229983ba 100644 (file)
@@ -229,4 +229,32 @@ TEST_F(pci_ep_data_transfer, COPY_TEST)
                                         test_size[i]);
        }
 }
+
+FIXTURE(pcie_ep_doorbell)
+{
+       int fd;
+};
+
+FIXTURE_SETUP(pcie_ep_doorbell)
+{
+       self->fd = open(test_device, O_RDWR);
+
+       ASSERT_NE(-1, self->fd) TH_LOG("Can't open PCI Endpoint Test device");
+};
+
+FIXTURE_TEARDOWN(pcie_ep_doorbell)
+{
+       close(self->fd);
+};
+
+TEST_F(pcie_ep_doorbell, DOORBELL_TEST)
+{
+       int ret;
+
+       pci_ep_ioctl(PCITEST_SET_IRQTYPE, PCITEST_IRQ_TYPE_AUTO);
+       ASSERT_EQ(0, ret) TH_LOG("Can't set AUTO IRQ type");
+
+       pci_ep_ioctl(PCITEST_DOORBELL, 0);
+       EXPECT_FALSE(ret) TH_LOG("Test failed for Doorbell\n");
+}
 TEST_HARNESS_MAIN