From: Ajay Gupta <ajaykuee@gmail.com>
To: mathias.nyman@intel.com
Cc: linux-usb@vger.kernel.org, Ajay Gupta <ajayg@nvidia.com>
Subject: [PATCH] usb: xhci: enable interrupt only after xhci_start()
Date: Tue, 18 Feb 2020 15:50:24 -0800 [thread overview]
Message-ID: <20200218235024.15266-1-ajayg@nvidia.com> (raw)
From: Ajay Gupta <ajayg@nvidia.com>
Xhci interrupt must be enabled only after controller is
initialized and started. Currently interrupt is enabled
first in xhci_run() and later hcd state is set to running
in xhci_run_finished().
On a slow system (such as FPGA based platform) the time
difference between enabling interrupt and setting the hcd
state becomes huge enough where interrupt is triggered but
controller initialization is not complete yet.
Fixing the same by moving the interrupt enable (CMD_EIE)
part of code snippet from xhci_run() to xhci_run_finished().
Signed-off-by: Ajay Gupta <ajayg@nvidia.com>
---
drivers/usb/host/xhci.c | 16 +++++++++-------
1 file changed, 9 insertions(+), 7 deletions(-)
diff --git a/drivers/usb/host/xhci.c b/drivers/usb/host/xhci.c
index dbac0fa9748d..ee2877fe0a58 100644
--- a/drivers/usb/host/xhci.c
+++ b/drivers/usb/host/xhci.c
@@ -604,6 +604,8 @@ static int xhci_init(struct usb_hcd *hcd)
static int xhci_run_finished(struct xhci_hcd *xhci)
{
+ u32 temp;
+
if (xhci_start(xhci)) {
xhci_halt(xhci);
return -ENODEV;
@@ -611,6 +613,13 @@ static int xhci_run_finished(struct xhci_hcd *xhci)
xhci->shared_hcd->state = HC_STATE_RUNNING;
xhci->cmd_ring_state = CMD_RING_STATE_RUNNING;
+ /* Set the HCD state before we enable the irqs */
+ temp = readl(&xhci->op_regs->command);
+ temp |= (CMD_EIE);
+ xhci_dbg_trace(xhci, trace_xhci_dbg_init,
+ "// Enable interrupts, cmd = 0x%x.", temp);
+ writel(temp, &xhci->op_regs->command);
+
if (xhci->quirks & XHCI_NEC_HOST)
xhci_ring_cmd_db(xhci);
@@ -664,13 +673,6 @@ int xhci_run(struct usb_hcd *hcd)
temp |= (xhci->imod_interval / 250) & ER_IRQ_INTERVAL_MASK;
writel(temp, &xhci->ir_set->irq_control);
- /* Set the HCD state before we enable the irqs */
- temp = readl(&xhci->op_regs->command);
- temp |= (CMD_EIE);
- xhci_dbg_trace(xhci, trace_xhci_dbg_init,
- "// Enable interrupts, cmd = 0x%x.", temp);
- writel(temp, &xhci->op_regs->command);
-
temp = readl(&xhci->ir_set->irq_pending);
xhci_dbg_trace(xhci, trace_xhci_dbg_init,
"// Enabling event ring interrupter %p by writing 0x%x to irq_pending",
--
2.17.1
next reply other threads:[~2020-02-18 23:50 UTC|newest]
Thread overview: 3+ messages / expand[flat|nested] mbox.gz Atom feed top
2020-02-18 23:50 Ajay Gupta [this message]
2020-02-20 13:18 ` [PATCH] usb: xhci: enable interrupt only after xhci_start() Mathias Nyman
2020-02-20 18:01 ` Ajay Gupta
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=20200218235024.15266-1-ajayg@nvidia.com \
--to=ajaykuee@gmail.com \
--cc=ajayg@nvidia.com \
--cc=linux-usb@vger.kernel.org \
--cc=mathias.nyman@intel.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.