* [PATCH] usb: xhci: fix ERST max field conversion
@ 2026-08-27 5:37 Youngjoon Lee
2026-08-27 6:34 ` Neronin, Niklas
0 siblings, 1 reply; 2+ messages in thread
From: Youngjoon Lee @ 2026-08-27 5:37 UTC (permalink / raw)
To: Mathias Nyman; +Cc: Greg Kroah-Hartman, Niklas Neronin, linux-usb, linux-kernel
Commit 6d45e9556d4a ("usb: xhci: standardize multi bit-field
macros") converted the ERST maximum calculation from BIT() to a
left shift. These operations are not equivalent because the
HCS_ERST_MAX field contains an exponent.
On an MT8173 xHCI controller where HCS_ERST_MAX is zero, the new
calculation produces zero event ring segments. This reaches
dma_alloc_coherent() with a zero size, triggers a page allocator
warning, and prevents xHCI from probing with -ENOMEM.
Preserve the original calculation by applying BIT() to the value
extracted with FIELD_GET().
This restores the USB 2.0 and USB 3.0 root hubs on MT8173. A USB
webcam and both USB 2.0 and USB 3.0 hubs enumerate successfully,
and the previous ERST allocation failure is no longer present.
Fixes: 6d45e9556d4a ("usb: xhci: standardize multi bit-field macros")
Signed-off-by: Youngjoon Lee <getfeus@gmail.com>
---
drivers/usb/host/xhci-mem.c | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
diff --git a/drivers/usb/host/xhci-mem.c b/drivers/usb/host/xhci-mem.c
index 7a21ac81f9c8..af8d4b74c4ba 100644
--- a/drivers/usb/host/xhci-mem.c
+++ b/drivers/usb/host/xhci-mem.c
@@ -2301,7 +2301,7 @@ xhci_alloc_interrupter(struct xhci_hcd *xhci, unsigned int segs, gfp_t flags)
if (!segs)
segs = ERST_DEFAULT_SEGS;
- max_segs = FIELD_GET(HCS_ERST_MAX, xhci->hcs_params2) << 2;
+ max_segs = BIT(FIELD_GET(HCS_ERST_MAX, xhci->hcs_params2));
segs = min(segs, max_segs);
ir = kzalloc_node(sizeof(*ir), flags, dev_to_node(dev));
--
2.55.0
^ permalink raw reply [flat|nested] 2+ messages in thread* Re: [PATCH] usb: xhci: fix ERST max field conversion
2026-08-27 5:37 [PATCH] usb: xhci: fix ERST max field conversion Youngjoon Lee
@ 2026-08-27 6:34 ` Neronin, Niklas
0 siblings, 0 replies; 2+ messages in thread
From: Neronin, Niklas @ 2026-08-27 6:34 UTC (permalink / raw)
To: Youngjoon Lee, Mathias Nyman; +Cc: Greg Kroah-Hartman, linux-usb, linux-kernel
On 27/08/2026 8.37, Youngjoon Lee wrote:
> Commit 6d45e9556d4a ("usb: xhci: standardize multi bit-field
> macros") converted the ERST maximum calculation from BIT() to a
> left shift. These operations are not equivalent because the
> HCS_ERST_MAX field contains an exponent.
>
> On an MT8173 xHCI controller where HCS_ERST_MAX is zero, the new
> calculation produces zero event ring segments. This reaches
> dma_alloc_coherent() with a zero size, triggers a page allocator
> warning, and prevents xHCI from probing with -ENOMEM.
>
> Preserve the original calculation by applying BIT() to the value
> extracted with FIELD_GET().
>
> This restores the USB 2.0 and USB 3.0 root hubs on MT8173. A USB
> webcam and both USB 2.0 and USB 3.0 hubs enumerate successfully,
> and the previous ERST allocation failure is no longer present.
>
> Fixes: 6d45e9556d4a ("usb: xhci: standardize multi bit-field macros")
> Signed-off-by: Youngjoon Lee <getfeus@gmail.com>
Thanks for the report and patch.
This issue has already been addressed in:
https://lore.kernel.org/linux-usb/7e6648ad-7459-4248-8c6c-227cfc2586d8@linux.intel.com/
-Niklas
^ permalink raw reply [flat|nested] 2+ messages in thread
end of thread, other threads:[~2026-08-27 6:35 UTC | newest]
Thread overview: 2+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2026-08-27 5:37 [PATCH] usb: xhci: fix ERST max field conversion Youngjoon Lee
2026-08-27 6:34 ` Neronin, Niklas
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox
all inboxes | Powered by JetHome®