Commit 84ac5e4f authored by Mathias Nyman's avatar Mathias Nyman Committed by Greg Kroah-Hartman

xhci: move event processing for one interrupter to a separate function

Split the main XHCI interrupt handler into a different API, so that other
potential interrupters can utilize similar event ring handling.  A scenario
would be if a secondary interrupter required to skip pending events in the
event ring, which would warrant a similar set of operations.
Signed-off-by: default avatarMathias Nyman <mathias.nyman@linux.intel.com>
Signed-off-by: default avatarWesley Cheng <quic_wcheng@quicinc.com>
Link: https://lore.kernel.org/r/20240217001017.29969-7-quic_wcheng@quicinc.comSigned-off-by: default avatarGreg Kroah-Hartman <gregkh@linuxfoundation.org>
parent e30e9ad9
...@@ -3069,6 +3069,46 @@ static void xhci_clear_interrupt_pending(struct xhci_hcd *xhci, ...@@ -3069,6 +3069,46 @@ static void xhci_clear_interrupt_pending(struct xhci_hcd *xhci,
} }
} }
static int xhci_handle_events(struct xhci_hcd *xhci, struct xhci_interrupter *ir)
{
int event_loop = 0;
u64 temp;
xhci_clear_interrupt_pending(xhci, ir);
if (xhci->xhc_state & XHCI_STATE_DYING ||
xhci->xhc_state & XHCI_STATE_HALTED) {
xhci_dbg(xhci, "xHCI dying, ignoring interrupt. Shouldn't IRQs be disabled?\n");
/* Clear the event handler busy flag (RW1C) */
temp = xhci_read_64(xhci, &ir->ir_set->erst_dequeue);
xhci_write_64(xhci, temp | ERST_EHB, &ir->ir_set->erst_dequeue);
return -ENODEV;
}
while (xhci_handle_event(xhci, ir) > 0) {
/*
* If half a segment of events have been handled in one go then
* update ERDP, and force isoc trbs to interrupt more often
*/
if (event_loop++ > TRBS_PER_SEGMENT / 2) {
xhci_update_erst_dequeue(xhci, ir, false);
if (ir->isoc_bei_interval > AVOID_BEI_INTERVAL_MIN)
ir->isoc_bei_interval = ir->isoc_bei_interval / 2;
event_loop = 0;
}
/* Update SW event ring dequeue pointer */
inc_deq(xhci, ir->event_ring);
}
xhci_update_erst_dequeue(xhci, ir, true);
return 0;
}
/* /*
* xHCI spec says we can get an interrupt, and if the HC has an error condition, * xHCI spec says we can get an interrupt, and if the HC has an error condition,
* we might get bad data out of the event ring. Section 4.10.2.7 has a list of * we might get bad data out of the event ring. Section 4.10.2.7 has a list of
...@@ -3077,11 +3117,8 @@ static void xhci_clear_interrupt_pending(struct xhci_hcd *xhci, ...@@ -3077,11 +3117,8 @@ static void xhci_clear_interrupt_pending(struct xhci_hcd *xhci,
irqreturn_t xhci_irq(struct usb_hcd *hcd) irqreturn_t xhci_irq(struct usb_hcd *hcd)
{ {
struct xhci_hcd *xhci = hcd_to_xhci(hcd); struct xhci_hcd *xhci = hcd_to_xhci(hcd);
struct xhci_interrupter *ir;
irqreturn_t ret = IRQ_NONE; irqreturn_t ret = IRQ_NONE;
u64 temp_64;
u32 status; u32 status;
int event_loop = 0;
spin_lock(&xhci->lock); spin_lock(&xhci->lock);
/* Check if the xHC generated the interrupt, or the irq is shared */ /* Check if the xHC generated the interrupt, or the irq is shared */
...@@ -3114,50 +3151,10 @@ irqreturn_t xhci_irq(struct usb_hcd *hcd) ...@@ -3114,50 +3151,10 @@ irqreturn_t xhci_irq(struct usb_hcd *hcd)
*/ */
status |= STS_EINT; status |= STS_EINT;
writel(status, &xhci->op_regs->status); writel(status, &xhci->op_regs->status);
/* This is the handler of the primary interrupter */
ir = xhci->interrupters[0];
xhci_clear_interrupt_pending(xhci, ir);
if (xhci->xhc_state & XHCI_STATE_DYING ||
xhci->xhc_state & XHCI_STATE_HALTED) {
xhci_dbg(xhci, "xHCI dying, ignoring interrupt. "
"Shouldn't IRQs be disabled?\n");
/* Clear the event handler busy flag (RW1C);
* the event ring should be empty.
*/
temp_64 = xhci_read_64(xhci, &ir->ir_set->erst_dequeue);
xhci_write_64(xhci, temp_64 | ERST_EHB,
&ir->ir_set->erst_dequeue);
ret = IRQ_HANDLED;
goto out;
}
/* FIXME this should be a delayed service routine
* that clears the EHB.
*/
while (xhci_handle_event(xhci, ir) > 0) {
/*
* If half a segment of events have been handled in one go then
* update ERDP, and force isoc trbs to interrupt more often
*/
if (event_loop++ > TRBS_PER_SEGMENT / 2) {
xhci_update_erst_dequeue(xhci, ir, false);
if (ir->isoc_bei_interval > AVOID_BEI_INTERVAL_MIN)
ir->isoc_bei_interval = ir->isoc_bei_interval / 2;
event_loop = 0;
}
/* Update SW event ring dequeue pointer */
inc_deq(xhci, ir->event_ring);
}
xhci_update_erst_dequeue(xhci, ir, true);
ret = IRQ_HANDLED; ret = IRQ_HANDLED;
/* This is the handler of the primary interrupter */
xhci_handle_events(xhci, xhci->interrupters[0]);
out: out:
spin_unlock(&xhci->lock); spin_unlock(&xhci->lock);
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment