From: Niklas Cassel <cassel@kernel.org>
To: "Manivannan Sadhasivam" <mani@kernel.org>,
"Krzysztof Wilczyński" <kwilczynski@kernel.org>,
"Kishon Vijay Abraham I" <kishon@kernel.org>,
"Bjorn Helgaas" <bhelgaas@google.com>,
"Frank Li" <Frank.Li@nxp.com>
Cc: Niklas Cassel <cassel@kernel.org>, linux-pci@vger.kernel.org
Subject: [PATCH] PCI: endpoint: pci-epf-test: Fix doorbell test support
Date: Mon, 8 Sep 2025 18:19:42 +0200 [thread overview]
Message-ID: <20250908161942.534799-2-cassel@kernel.org> (raw)
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.
Cc: Frank Li <Frank.Li@nxp.com>
Fixes: eff0c286aa91 ("PCI: endpoint: pci-epf-test: Add doorbell test support")
Signed-off-by: Niklas Cassel <cassel@kernel.org>
---
Note: this is actually how the code looked like when it was submitted by
Frank, see pci_epf_test_disable_doorbell() in:
https://lore.kernel.org/linux-pci/20250710-ep-msi-v21-6-57683fc7fb25@nxp.com/
However, the code was modified, without notifying the list of this
non-trivial logical change, before being applied.
drivers/pci/endpoint/functions/pci-epf-test.c | 14 +++++++++++++-
1 file changed, 13 insertions(+), 1 deletion(-)
diff --git a/drivers/pci/endpoint/functions/pci-epf-test.c b/drivers/pci/endpoint/functions/pci-epf-test.c
index e091193bd8a8a..b6ca1766a4ca9 100644
--- a/drivers/pci/endpoint/functions/pci-epf-test.c
+++ b/drivers/pci/endpoint/functions/pci-epf-test.c
@@ -772,12 +772,24 @@ static void pci_epf_test_disable_doorbell(struct pci_epf_test *epf_test,
u32 status = le32_to_cpu(reg->status);
struct pci_epf *epf = epf_test->epf;
struct pci_epc *epc = epf->epc;
+ int ret;
if (bar < BAR_0)
goto set_status_err;
pci_epf_test_doorbell_cleanup(epf_test);
- pci_epc_clear_bar(epc, epf->func_no, epf->vfunc_no, &epf_test->db_bar);
+
+ /*
+ * 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.
+ */
+ ret = pci_epc_set_bar(epc, epf->func_no, epf->vfunc_no, &epf->bar[bar]);
+ if (ret)
+ goto set_status_err;
status |= STATUS_DOORBELL_DISABLE_SUCCESS;
reg->status = cpu_to_le32(status);
--
2.51.0
next reply other threads:[~2025-09-08 16:19 UTC|newest]
Thread overview: 4+ messages / expand[flat|nested] mbox.gz Atom feed top
2025-09-08 16:19 Niklas Cassel [this message]
2025-09-08 21:28 ` [PATCH] PCI: endpoint: pci-epf-test: Fix doorbell test support Frank Li
2025-09-11 17:20 ` Manivannan Sadhasivam
2025-09-11 17:28 ` Manivannan Sadhasivam
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=20250908161942.534799-2-cassel@kernel.org \
--to=cassel@kernel.org \
--cc=Frank.Li@nxp.com \
--cc=bhelgaas@google.com \
--cc=kishon@kernel.org \
--cc=kwilczynski@kernel.org \
--cc=linux-pci@vger.kernel.org \
--cc=mani@kernel.org \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.