Skip to content

Commit f272210

Browse files
floatiousbjorn-helgaas
authored andcommitted
PCI: endpoint: pci-epf-test: Fix doorbell test support
The doorbell feature temporarily overrides the inbound translation to point to the address stored in epf_test->db_bar.phys_addr, i.e., it calls set_bar() twice without ever calling clear_bar(), as calling clear_bar() would clear the BAR's PCI address assigned by the host. Thus, when disabling the doorbell, restore the inbound translation to point to the memory allocated for the BAR. Without this, running the PCI endpoint kselftest doorbell test case more than once would fail. Fixes: eff0c28 ("PCI: endpoint: pci-epf-test: Add doorbell test support") Signed-off-by: Niklas Cassel <cassel@kernel.org> Signed-off-by: Manivannan Sadhasivam <mani@kernel.org> Signed-off-by: Bjorn Helgaas <bhelgaas@google.com> Reviewed-by: Frank Li <Frank.Li@nxp.com> Link: https://patch.msgid.link/20250908161942.534799-2-cassel@kernel.org
1 parent d5f6bd3 commit f272210

1 file changed

Lines changed: 13 additions & 1 deletion

File tree

drivers/pci/endpoint/functions/pci-epf-test.c

Lines changed: 13 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -772,12 +772,24 @@ static void pci_epf_test_disable_doorbell(struct pci_epf_test *epf_test,
772772
u32 status = le32_to_cpu(reg->status);
773773
struct pci_epf *epf = epf_test->epf;
774774
struct pci_epc *epc = epf->epc;
775+
int ret;
775776

776777
if (bar < BAR_0)
777778
goto set_status_err;
778779

779780
pci_epf_test_doorbell_cleanup(epf_test);
780-
pci_epc_clear_bar(epc, epf->func_no, epf->vfunc_no, &epf_test->db_bar);
781+
782+
/*
783+
* The doorbell feature temporarily overrides the inbound translation
784+
* to point to the address stored in epf_test->db_bar.phys_addr, i.e.,
785+
* it calls set_bar() twice without ever calling clear_bar(), as
786+
* calling clear_bar() would clear the BAR's PCI address assigned by
787+
* the host. Thus, when disabling the doorbell, restore the inbound
788+
* translation to point to the memory allocated for the BAR.
789+
*/
790+
ret = pci_epc_set_bar(epc, epf->func_no, epf->vfunc_no, &epf->bar[bar]);
791+
if (ret)
792+
goto set_status_err;
781793

782794
status |= STATUS_DOORBELL_DISABLE_SUCCESS;
783795
reg->status = cpu_to_le32(status);

0 commit comments

Comments
 (0)