mirror of
https://github.com/torvalds/linux.git
synced 2026-05-24 07:03:03 +02:00
usb: xhci: set requested IMODI to the closest supported value
The function configures the Interrupt Moderation Interval (IMODI) via bits 15:0 in the Interrupt Moderation Register. The IMODI value is specified in increments of 250 nanoseconds. For instance, an IMODI register value of 16 corresponds to 4000 nanoseconds, resulting in an interrupt every ~1ms. Currently, the function fails when a requested IMODI value is too large, only logging a warning message for secondary interrupters. Prevent this by automatically adjusting the IMODI value to the nearest supported value. Signed-off-by: Niklas Neronin <niklas.neronin@linux.intel.com> Signed-off-by: Mathias Nyman <mathias.nyman@linux.intel.com> Link: https://lore.kernel.org/r/20250515135621.335595-15-mathias.nyman@linux.intel.com Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
This commit is contained in:
parent
3d5b8a0e0a
commit
1fdeb06905
|
|
@ -2393,10 +2393,7 @@ xhci_create_secondary_interrupter(struct usb_hcd *hcd, unsigned int segs,
|
|||
return NULL;
|
||||
}
|
||||
|
||||
err = xhci_set_interrupter_moderation(ir, imod_interval);
|
||||
if (err)
|
||||
xhci_warn(xhci, "Failed to set interrupter %d moderation to %uns\n",
|
||||
i, imod_interval);
|
||||
xhci_set_interrupter_moderation(ir, imod_interval);
|
||||
|
||||
xhci_dbg(xhci, "Add secondary interrupter %d, max interrupters %d\n",
|
||||
ir->intr_num, xhci->max_interrupters);
|
||||
|
|
|
|||
|
|
@ -355,12 +355,15 @@ int xhci_set_interrupter_moderation(struct xhci_interrupter *ir,
|
|||
{
|
||||
u32 imod;
|
||||
|
||||
if (!ir || !ir->ir_set || imod_interval > U16_MAX * 250)
|
||||
if (!ir || !ir->ir_set)
|
||||
return -EINVAL;
|
||||
|
||||
/* IMODI value in IMOD register is in 250ns increments */
|
||||
imod_interval = umin(imod_interval / 250, ER_IRQ_INTERVAL_MASK);
|
||||
|
||||
imod = readl(&ir->ir_set->irq_control);
|
||||
imod &= ~ER_IRQ_INTERVAL_MASK;
|
||||
imod |= (imod_interval / 250) & ER_IRQ_INTERVAL_MASK;
|
||||
imod |= imod_interval;
|
||||
writel(imod, &ir->ir_set->irq_control);
|
||||
|
||||
return 0;
|
||||
|
|
|
|||
Loading…
Reference in New Issue
Block a user