* [PATCH] usb: xhci: Fix HCS_ERST_MAX conversion
@ 2026-08-20 9:57 Chen-Yu Tsai
2026-08-20 12:34 ` Mathias Nyman
0 siblings, 1 reply; 2+ messages in thread
From: Chen-Yu Tsai @ 2026-08-20 9:57 UTC (permalink / raw)
To: Mathias Nyman, Greg Kroah-Hartman
Cc: Chen-Yu Tsai, linux-usb, linux-kernel, Niklas Neronin
This partially reverts commit 6d45e9556d4a11b726e897d86e095b96db4550d8.
HCS_ERST_MAX holds power of 2 value for maximum number of segments.
In the culprit commit, this was incorrectly converted to "shift up 2".
On hardware where this field is zero, this results in xhci_alloc_erst()
calling dma_alloc_coherent() with size = 0, leading to a horrible splat
and non-usable XHCI.
Revert the shift-up-2 to the BIT() macro.
Fixes: 6d45e9556d4a ("usb: xhci: standardize multi bit-field macros")
Cc: Niklas Neronin <niklas.neronin@linux.intel.com>
Signed-off-by: Chen-Yu Tsai <wenst@chromium.org>
---
This immediately fixes XHCI for me. This was observed on next-20260818
and next-20260819.
---
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.860.g4b6b3295ed-goog
^ permalink raw reply related [flat|nested] 2+ messages in thread* Re: [PATCH] usb: xhci: Fix HCS_ERST_MAX conversion
2026-08-20 9:57 [PATCH] usb: xhci: Fix HCS_ERST_MAX conversion Chen-Yu Tsai
@ 2026-08-20 12:34 ` Mathias Nyman
0 siblings, 0 replies; 2+ messages in thread
From: Mathias Nyman @ 2026-08-20 12:34 UTC (permalink / raw)
To: Chen-Yu Tsai, Mathias Nyman, Greg Kroah-Hartman
Cc: linux-usb, linux-kernel, Niklas Neronin
On 8/20/26 12:57, Chen-Yu Tsai wrote:
> This partially reverts commit 6d45e9556d4a11b726e897d86e095b96db4550d8.
>
> HCS_ERST_MAX holds power of 2 value for maximum number of segments.
> In the culprit commit, this was incorrectly converted to "shift up 2".
> On hardware where this field is zero, this results in xhci_alloc_erst()
> calling dma_alloc_coherent() with size = 0, leading to a horrible splat
> and non-usable XHCI.
>
> Revert the shift-up-2 to the BIT() macro.
>
> Fixes: 6d45e9556d4a ("usb: xhci: standardize multi bit-field macros")
> Cc: Niklas Neronin <niklas.neronin@linux.intel.com>
> Signed-off-by: Chen-Yu Tsai <wenst@chromium.org>
> ---
Thanks
Adding to queue, will submit after rc1
-Mathias
^ permalink raw reply [flat|nested] 2+ messages in thread
end of thread, other threads:[~2026-08-20 12:34 UTC | newest]
Thread overview: 2+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2026-08-20 9:57 [PATCH] usb: xhci: Fix HCS_ERST_MAX conversion Chen-Yu Tsai
2026-08-20 12:34 ` Mathias Nyman
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox