Message ID | 20250408115752.1344901-2-niklas.neronin@linux.intel.com (mailing list archive) |
---|---|
State | New |
Headers | show |
Series | usb: xhci: enhancements to Interrupt Register Set code | expand |
On 8.4.2025 14.57, Niklas Neronin wrote: > 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> > --- > drivers/usb/host/xhci-mem.c | 5 +---- > drivers/usb/host/xhci.c | 7 +++++-- > 2 files changed, 6 insertions(+), 6 deletions(-) > This patch now conflicts with the recently accepted sideband series. Any chance you could respin this on top of that. Otherwise whole series looks good. Thanks Mathias
diff --git a/drivers/usb/host/xhci-mem.c b/drivers/usb/host/xhci-mem.c index d698095fc88d..ebbf5f039902 100644 --- a/drivers/usb/host/xhci-mem.c +++ b/drivers/usb/host/xhci-mem.c @@ -2359,10 +2359,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", i, xhci->max_interrupters); diff --git a/drivers/usb/host/xhci.c b/drivers/usb/host/xhci.c index 0452b8d65832..7a8c545b78b7 100644 --- a/drivers/usb/host/xhci.c +++ b/drivers/usb/host/xhci.c @@ -354,12 +354,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;
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> --- drivers/usb/host/xhci-mem.c | 5 +---- drivers/usb/host/xhci.c | 7 +++++-- 2 files changed, 6 insertions(+), 6 deletions(-)