PCI: endpoint: pci-epf-test: Add doorbell test support
authorFrank Li <Frank.Li@nxp.com>
Thu, 10 Jul 2025 19:13:52 +0000 (15:13 -0400)
committerBjorn Helgaas <bhelgaas@google.com>
Thu, 24 Jul 2025 21:51:43 +0000 (16:51 -0500)
commiteff0c286aa916221a69126a43eee7c218d6f4011
treee024f5b08712dec8bb14d15431dd96fb37b32097
parent4ff4252a2355f585c5cad8dc959ff1097300aa47
PCI: endpoint: pci-epf-test: Add doorbell test support

Add doorbell support by allocating a dedicated BAR using the
pci_epf_alloc_doorbell() API and mapping the Endpoint MSI controller
message data address to it. The data to be written in the message address
is stored in the 'pci_epf_test_reg::doorbell_data' register. Finally, the
RC can trigger doorbell in the Endpoint by writing the content of
'doorbell_data' register to the offset specified in 'doorbell_offset' of
the 'doorbell_bar' BAR.

Triggering of the doorbell is detected by pci_epf_test_doorbell_handler(),
which is bound to the doorbell IRQ. On successful completion,
STATUS_DOORBELL_SUCCESS status is set in the above mentioned handler.

To avoid breaking compatibility between host and endpoint, add two new
commands: COMMAND_ENABLE_DOORBELL and COMMAND_DISABLE_DOORBELL.

The doorbell is allocated when COMMAND_ENABLE_DOORBELL command is called
and destroyed when COMMAND_DISABLE_DOORBELL is called.

This doorbell feature only works when both RC and EP drivers support it.
If one of them doesn't support the feature, the testcase will fail.

Signed-off-by: Frank Li <Frank.Li@nxp.com>
[mani: code cleanups and reworded commit message]
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-6-57683fc7fb25@nxp.com
drivers/pci/endpoint/functions/pci-epf-test.c