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

selftests: pci_endpoint: Add doorbell test case

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

authored by

Frank Li and committed by
Bjorn Helgaas
b351e9c9 eefb8379

+43
+15
Documentation/PCI/endpoint/pci-test-howto.rst
··· 203 203 command:: 204 204 205 205 # pci_endpoint_test -f pci_ep_bar -f pci_ep_basic -v memcpy -T COPY_TEST -v dma 206 + 207 + Kselftest EP Doorbell 208 + ~~~~~~~~~~~~~~~~~~~~~ 209 + 210 + If the Endpoint MSI controller is used for the doorbell usecase, run below 211 + command for testing it: 212 + 213 + # pci_endpoint_test -f pcie_ep_doorbell 214 + 215 + # Starting 1 tests from 1 test cases. 216 + # RUN pcie_ep_doorbell.DOORBELL_TEST ... 217 + # OK pcie_ep_doorbell.DOORBELL_TEST 218 + ok 1 pcie_ep_doorbell.DOORBELL_TEST 219 + # PASSED: 1 / 1 tests passed. 220 + # Totals: pass:1 fail:0 xfail:0 xpass:0 skip:0 error:0
+28
tools/testing/selftests/pci_endpoint/pci_endpoint_test.c
··· 229 229 test_size[i]); 230 230 } 231 231 } 232 + 233 + FIXTURE(pcie_ep_doorbell) 234 + { 235 + int fd; 236 + }; 237 + 238 + FIXTURE_SETUP(pcie_ep_doorbell) 239 + { 240 + self->fd = open(test_device, O_RDWR); 241 + 242 + ASSERT_NE(-1, self->fd) TH_LOG("Can't open PCI Endpoint Test device"); 243 + }; 244 + 245 + FIXTURE_TEARDOWN(pcie_ep_doorbell) 246 + { 247 + close(self->fd); 248 + }; 249 + 250 + TEST_F(pcie_ep_doorbell, DOORBELL_TEST) 251 + { 252 + int ret; 253 + 254 + pci_ep_ioctl(PCITEST_SET_IRQTYPE, PCITEST_IRQ_TYPE_AUTO); 255 + ASSERT_EQ(0, ret) TH_LOG("Can't set AUTO IRQ type"); 256 + 257 + pci_ep_ioctl(PCITEST_DOORBELL, 0); 258 + EXPECT_FALSE(ret) TH_LOG("Test failed for Doorbell\n"); 259 + } 232 260 TEST_HARNESS_MAIN