Linux kernel mirror (for testing) git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
kernel os linux
1
fork

Configure Feed

Select the types of activity you want to include in your feed.

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: Mathias Nyman <mathias.nyman@linux.intel.com>
Signed-off-by: Wesley Cheng <quic_wcheng@quicinc.com>
Link: https://lore.kernel.org/r/20240217001017.29969-7-quic_wcheng@quicinc.com
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>

authored by

Mathias Nyman and committed by
Greg Kroah-Hartman
84ac5e4f e30e9ad9

+42 -45
+42 -45
drivers/usb/host/xhci-ring.c
··· 3069 3069 } 3070 3070 } 3071 3071 3072 + static int xhci_handle_events(struct xhci_hcd *xhci, struct xhci_interrupter *ir) 3073 + { 3074 + int event_loop = 0; 3075 + u64 temp; 3076 + 3077 + xhci_clear_interrupt_pending(xhci, ir); 3078 + 3079 + if (xhci->xhc_state & XHCI_STATE_DYING || 3080 + xhci->xhc_state & XHCI_STATE_HALTED) { 3081 + xhci_dbg(xhci, "xHCI dying, ignoring interrupt. Shouldn't IRQs be disabled?\n"); 3082 + 3083 + /* Clear the event handler busy flag (RW1C) */ 3084 + temp = xhci_read_64(xhci, &ir->ir_set->erst_dequeue); 3085 + xhci_write_64(xhci, temp | ERST_EHB, &ir->ir_set->erst_dequeue); 3086 + return -ENODEV; 3087 + } 3088 + 3089 + while (xhci_handle_event(xhci, ir) > 0) { 3090 + /* 3091 + * If half a segment of events have been handled in one go then 3092 + * update ERDP, and force isoc trbs to interrupt more often 3093 + */ 3094 + if (event_loop++ > TRBS_PER_SEGMENT / 2) { 3095 + xhci_update_erst_dequeue(xhci, ir, false); 3096 + 3097 + if (ir->isoc_bei_interval > AVOID_BEI_INTERVAL_MIN) 3098 + ir->isoc_bei_interval = ir->isoc_bei_interval / 2; 3099 + 3100 + event_loop = 0; 3101 + } 3102 + 3103 + /* Update SW event ring dequeue pointer */ 3104 + inc_deq(xhci, ir->event_ring); 3105 + } 3106 + 3107 + xhci_update_erst_dequeue(xhci, ir, true); 3108 + 3109 + return 0; 3110 + } 3111 + 3072 3112 /* 3073 3113 * xHCI spec says we can get an interrupt, and if the HC has an error condition, 3074 3114 * we might get bad data out of the event ring. Section 4.10.2.7 has a list of ··· 3117 3077 irqreturn_t xhci_irq(struct usb_hcd *hcd) 3118 3078 { 3119 3079 struct xhci_hcd *xhci = hcd_to_xhci(hcd); 3120 - struct xhci_interrupter *ir; 3121 3080 irqreturn_t ret = IRQ_NONE; 3122 - u64 temp_64; 3123 3081 u32 status; 3124 - int event_loop = 0; 3125 3082 3126 3083 spin_lock(&xhci->lock); 3127 3084 /* Check if the xHC generated the interrupt, or the irq is shared */ ··· 3151 3114 */ 3152 3115 status |= STS_EINT; 3153 3116 writel(status, &xhci->op_regs->status); 3154 - 3155 - /* This is the handler of the primary interrupter */ 3156 - ir = xhci->interrupters[0]; 3157 - 3158 - xhci_clear_interrupt_pending(xhci, ir); 3159 - 3160 - if (xhci->xhc_state & XHCI_STATE_DYING || 3161 - xhci->xhc_state & XHCI_STATE_HALTED) { 3162 - xhci_dbg(xhci, "xHCI dying, ignoring interrupt. " 3163 - "Shouldn't IRQs be disabled?\n"); 3164 - /* Clear the event handler busy flag (RW1C); 3165 - * the event ring should be empty. 3166 - */ 3167 - temp_64 = xhci_read_64(xhci, &ir->ir_set->erst_dequeue); 3168 - xhci_write_64(xhci, temp_64 | ERST_EHB, 3169 - &ir->ir_set->erst_dequeue); 3170 - ret = IRQ_HANDLED; 3171 - goto out; 3172 - } 3173 - 3174 - /* FIXME this should be a delayed service routine 3175 - * that clears the EHB. 3176 - */ 3177 - while (xhci_handle_event(xhci, ir) > 0) { 3178 - /* 3179 - * If half a segment of events have been handled in one go then 3180 - * update ERDP, and force isoc trbs to interrupt more often 3181 - */ 3182 - if (event_loop++ > TRBS_PER_SEGMENT / 2) { 3183 - xhci_update_erst_dequeue(xhci, ir, false); 3184 - 3185 - if (ir->isoc_bei_interval > AVOID_BEI_INTERVAL_MIN) 3186 - ir->isoc_bei_interval = ir->isoc_bei_interval / 2; 3187 - 3188 - event_loop = 0; 3189 - } 3190 - 3191 - /* Update SW event ring dequeue pointer */ 3192 - inc_deq(xhci, ir->event_ring); 3193 - } 3194 - 3195 - xhci_update_erst_dequeue(xhci, ir, true); 3196 3117 ret = IRQ_HANDLED; 3197 3118 3119 + /* This is the handler of the primary interrupter */ 3120 + xhci_handle_events(xhci, xhci->interrupters[0]); 3198 3121 out: 3199 3122 spin_unlock(&xhci->lock); 3200 3123