From: Niklas Cassel <cassel@kernel.org>
To: "Manivannan Sadhasivam" <mani@kernel.org>,
"Krzysztof Wilczyński" <kwilczynski@kernel.org>,
"Bjorn Helgaas" <bhelgaas@google.com>
Cc: linux-pci@vger.kernel.org, Koichiro Den <den@valinux.co.jp>,
Frank Li <Frank.Li@nxp.com>, Niklas Cassel <cassel@kernel.org>
Subject: [PATCH 2/2] misc: pci_endpoint_test: Improve logic to check status for doorbell test case
Date: Thu, 30 Jul 2026 14:20:48 +0200 [thread overview]
Message-ID: <20260730122045.1382749-6-cassel@kernel.org> (raw)
In-Reply-To: <20260730122045.1382749-4-cassel@kernel.org>
The EPF driver drivers/pci/endpoint/functions/pci-epf-test.c
only sets STATUS_DOORBELL_ENABLE_SUCCESS as the final step in
pci_epf_test_enable_doorbell()
Likewise it only sets STATUS_DOORBELL_DISABLE_SUCCESS as the final step in
pci_epf_test_disable_doorbell().
The safest way is therefore to check if the SUCCESS bit was set,
not to check if the FAIL bit was set.
Because, during a wait_for_completion_timeout() timeout, if we did not
receive an IRQ, obviously the FAIL bit will not be set.
For the STATUS_DOORBELL_ENABLE case, the if-statement also fails if there
was a timeout ('left' == 0). However, we've seen an issue where a buggy EPC
driver was sending two IRQs in response to a single DOORBELL_ENABLE
command, and in this case the second wait_for_completion() will return
immediately (i.e. no timeout - 'left' != zero) and the SUCCESS bit will not
be set. Thus, the safest way is to simply check if the SUCCESS bit is set.
Signed-off-by: Niklas Cassel <cassel@kernel.org>
---
drivers/misc/pci_endpoint_test.c | 4 ++--
1 file changed, 2 insertions(+), 2 deletions(-)
diff --git a/drivers/misc/pci_endpoint_test.c b/drivers/misc/pci_endpoint_test.c
index 26ab9252251f..1019bcd0628f 100644
--- a/drivers/misc/pci_endpoint_test.c
+++ b/drivers/misc/pci_endpoint_test.c
@@ -1094,7 +1094,7 @@ static int pci_endpoint_test_doorbell(struct pci_endpoint_test *test)
left = wait_for_completion_timeout(&test->irq_raised, msecs_to_jiffies(1000));
status = pci_endpoint_test_readl(test, PCI_ENDPOINT_TEST_STATUS);
- if (!left || (status & STATUS_DOORBELL_ENABLE_FAIL)) {
+ if (!left || !(status & STATUS_DOORBELL_ENABLE_SUCCESS)) {
dev_err(dev, "Failed to enable doorbell\n");
return -EINVAL;
}
@@ -1133,7 +1133,7 @@ static int pci_endpoint_test_doorbell(struct pci_endpoint_test *test)
status |= pci_endpoint_test_readl(test, PCI_ENDPOINT_TEST_STATUS);
- if (status & STATUS_DOORBELL_DISABLE_FAIL) {
+ if (!(status & STATUS_DOORBELL_DISABLE_SUCCESS)) {
dev_err(dev, "Failed to disable doorbell\n");
return -EINVAL;
}
--
2.55.0
next prev parent reply other threads:[~2026-07-30 12:21 UTC|newest]
Thread overview: 6+ messages / expand[flat|nested] mbox.gz Atom feed top
2026-07-30 12:20 [PATCH 0/2] misc: pci_endpoint_test: Doorbell fix and improvement Niklas Cassel
2026-07-30 12:20 ` [PATCH 1/2] misc: pci_endpoint_test: Fix doorbell success logic Niklas Cassel
2026-07-30 12:30 ` sashiko-bot
2026-07-30 12:20 ` Niklas Cassel [this message]
2026-07-30 12:33 ` [PATCH 2/2] misc: pci_endpoint_test: Improve logic to check status for doorbell test case sashiko-bot
2026-07-30 12:45 ` Niklas Cassel
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=20260730122045.1382749-6-cassel@kernel.org \
--to=cassel@kernel.org \
--cc=Frank.Li@nxp.com \
--cc=bhelgaas@google.com \
--cc=den@valinux.co.jp \
--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 a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox