From: David Jeffery <djeffery@redhat.com>
To: linux-usb@vger.kernel.org
Cc: loberman@redhat.com, andriy.shevchenko@linux.intel.com,
emilne@redhat.com, apanagio@redhat.com, torez@redhat.com
Subject: [PATCH] usb: ehci: Prevent missed ehci interrupts with edge-triggered MSI
Date: Wed, 14 Jul 2021 10:03:09 -0400 [thread overview]
Message-ID: <20210714140309.GA27799@redhat> (raw)
When MSI is used by the ehci driver, it can cause interrupts to be lost which
results in ehci only continuing to work due to its polling fallback. But the
reliance of polling drasticly reduces performance of any I/O through ehci.
Interrupts are lost as ehci's interrupt handler does not safely handle
edge-triggered interrupts. It fails to ensure all interrupt status bits are
cleared, which works with level-triggered interrupts but not the
edge-triggered interrupts typical from using MSI.
To fix this problem, check if the driver may have raced with the hardware
setting additional interrupt status bits and clear status until it is in a
stable state.
Signed-off-by: David Jeffery <djeffery@redhat.com>
Tested-by: Laurence Oberman <loberman@redhat.com>
---
This is an alternative to reverting 306c54d0edb6ba94d39877524dddebaad7770cf2
which is the patch that allowed MSI to be used with ehci.
ehci-hcd.c | 16 +++++++++++++---
1 file changed, 13 insertions(+), 3 deletions(-)
diff --git a/drivers/usb/host/ehci-hcd.c b/drivers/usb/host/ehci-hcd.c
index 36f5bf6a0752..2283205d4b40 100644
--- a/drivers/usb/host/ehci-hcd.c
+++ b/drivers/usb/host/ehci-hcd.c
@@ -704,14 +704,18 @@ static irqreturn_t ehci_irq (struct usb_hcd *hcd)
{
struct ehci_hcd *ehci = hcd_to_ehci (hcd);
u32 status, masked_status, pcd_status = 0, cmd;
+ u32 current_status;
int bh;
spin_lock(&ehci->lock);
- status = ehci_readl(ehci, &ehci->regs->status);
+ status = 0;
+ current_status = ehci_readl(ehci, &ehci->regs->status);
+restart:
+ status |= current_status;
/* e.g. cardbus physical eject */
- if (status == ~(u32) 0) {
+ if (current_status == ~(u32) 0) {
ehci_dbg (ehci, "device removed\n");
goto dead;
}
@@ -720,7 +724,7 @@ static irqreturn_t ehci_irq (struct usb_hcd *hcd)
* We don't use STS_FLR, but some controllers don't like it to
* remain on, so mask it out along with the other status bits.
*/
- masked_status = status & (INTR_MASK | STS_FLR);
+ masked_status = current_status & (INTR_MASK | STS_FLR);
/* Shared IRQ? */
if (!masked_status || unlikely(ehci->rh_state == EHCI_RH_HALTED)) {
@@ -730,6 +734,12 @@ static irqreturn_t ehci_irq (struct usb_hcd *hcd)
/* clear (just) interrupts */
ehci_writel(ehci, masked_status, &ehci->regs->status);
+
+ /* for edge interrupts, don't race with an interrupt bit being raised */
+ current_status = ehci_readl(ehci, &ehci->regs->status);
+ if (current_status & INTR_MASK)
+ goto restart;
+
cmd = ehci_readl(ehci, &ehci->regs->command);
bh = 0;
next reply other threads:[~2021-07-14 14:03 UTC|newest]
Thread overview: 7+ messages / expand[flat|nested] mbox.gz Atom feed top
2021-07-14 14:03 David Jeffery [this message]
2021-07-14 14:27 ` [PATCH] usb: ehci: Prevent missed ehci interrupts with edge-triggered MSI Andy Shevchenko
2021-07-14 15:55 ` David Jeffery
2021-07-14 19:35 ` Andy Shevchenko
2021-07-14 14:29 ` Alan Stern
2021-07-14 16:10 ` David Jeffery
2021-07-14 16:27 ` Alan Stern
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=20210714140309.GA27799@redhat \
--to=djeffery@redhat.com \
--cc=andriy.shevchenko@linux.intel.com \
--cc=apanagio@redhat.com \
--cc=emilne@redhat.com \
--cc=linux-usb@vger.kernel.org \
--cc=loberman@redhat.com \
--cc=torez@redhat.com \
/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.