Linux USB
 help / color / mirror / Atom feed
* [PATCH 0/1] xhci fix for usb-linus
@ 2021-07-15 15:06 Mathias Nyman
  0 siblings, 0 replies; 7+ messages in thread
From: Mathias Nyman @ 2021-07-15 15:06 UTC (permalink / raw)
  To: gregkh; +Cc: linux-usb, Mathias Nyman

Hi Greg

One small xhci fix resolving a missed usb 2 device-intiated wake.

I'll be out on vacation for two weeks, starting monday, so any response
will be delayed.

Thanks
-Mathias

Mathias Nyman (1):
  xhci: Fix lost USB 2 remote wake

 drivers/usb/host/xhci-hub.c | 3 ++-
 1 file changed, 2 insertions(+), 1 deletion(-)

-- 
2.25.1


^ permalink raw reply	[flat|nested] 7+ messages in thread

* [PATCH 0/1] xhci fix for usb-linus
@ 2021-12-21 11:28 Mathias Nyman
  0 siblings, 0 replies; 7+ messages in thread
From: Mathias Nyman @ 2021-12-21 11:28 UTC (permalink / raw)
  To: gregkh; +Cc: linux-usb, Mathias Nyman

Hi Greg

One small patch, remove an extra quirk set for Fresco FL1100 controllers.
External docks with this controller have issues enumerating usb devices.

Nice if it could still make 5.16, if not then 5.17 is fine

Thanks
-Mathias

Mathias Nyman (1):
  xhci: Fresco FL1100 controller should not have BROKEN_MSI quirk set.

 drivers/usb/host/xhci-pci.c | 5 ++++-
 1 file changed, 4 insertions(+), 1 deletion(-)

-- 
2.25.1


^ permalink raw reply	[flat|nested] 7+ messages in thread

* [PATCH 0/1] xhci fix for usb-linus
@ 2024-08-15 14:11 Mathias Nyman
  0 siblings, 0 replies; 7+ messages in thread
From: Mathias Nyman @ 2024-08-15 14:11 UTC (permalink / raw)
  To: linux-usb, gregkh; +Cc: Mathias Nyman

Hi Greg

One xhci patch for usb-linus to solve a NULL pointer dereference found recently

Thanks
Mathias

Mathias Nyman (1):
  xhci: Fix Panther point NULL pointer deref at full-speed
    re-enumeration

 drivers/usb/host/xhci.c | 8 +++++---
 1 file changed, 5 insertions(+), 3 deletions(-)

-- 
2.25.1


^ permalink raw reply	[flat|nested] 7+ messages in thread

* [PATCH 0/1] xhci fix for usb-linus
@ 2025-02-25  9:59 Mathias Nyman
  0 siblings, 0 replies; 7+ messages in thread
From: Mathias Nyman @ 2025-02-25  9:59 UTC (permalink / raw)
  To: gregkh; +Cc: linux-usb, Mathias Nyman

Hi Greg

One small patch to cope with VIA VL805 xHC hosts reading past the DMA area
given to them.

Thanks
Mathias

Michal Pecio (1):
  usb: xhci: Enable the TRB overfetch quirk on VIA VL805

 drivers/usb/host/xhci-mem.c |  3 ++-
 drivers/usb/host/xhci-pci.c | 10 +++++++---
 drivers/usb/host/xhci.h     |  2 +-
 3 files changed, 10 insertions(+), 5 deletions(-)

-- 
2.43.0


^ permalink raw reply	[flat|nested] 7+ messages in thread

* [PATCH 0/1] xhci fix for usb-linus
@ 2025-03-04 11:31 Mathias Nyman
  0 siblings, 0 replies; 7+ messages in thread
From: Mathias Nyman @ 2025-03-04 11:31 UTC (permalink / raw)
  To: gregkh; +Cc: linux-usb, linux-kernel, Mathias Nyman

Hi Greg

Michal found and fixed a regression introduced in 6.13
If possible it would be nice to get this into 6.14 still

Thanks
Mathias

Michal Pecio (1):
  usb: xhci: Fix host controllers "dying" after suspend and resume

 drivers/usb/host/xhci.c | 6 +++++-
 1 file changed, 5 insertions(+), 1 deletion(-)

-- 
2.43.0


^ permalink raw reply	[flat|nested] 7+ messages in thread

* [PATCH 0/1] xhci fix for usb-linus
@ 2026-08-04  8:36 Mathias Nyman
  2026-08-04  8:36 ` [PATCH 1/1] usb: xhci: use BIT_ULL for CRCR bits to fix incorrect 64bit mask Mathias Nyman
  0 siblings, 1 reply; 7+ messages in thread
From: Mathias Nyman @ 2026-08-04  8:36 UTC (permalink / raw)
  To: gregkh; +Cc: linux-usb, Mathias Nyman

Hi Greg

xhci may be unusable on Raspberry Pi type arm32 devices since driver
swiched to BIT() macro in 7.1 kenel.

This one patch fixes it, hope it can still make 7.2

Thanks
Mathias

Lachlan Hodges (1):
  usb: xhci: use BIT_ULL for CRCR bits to fix incorrect 64bit mask

 drivers/usb/host/xhci.h | 12 ++++++------
 1 file changed, 6 insertions(+), 6 deletions(-)

-- 
2.43.0


^ permalink raw reply	[flat|nested] 7+ messages in thread

* [PATCH 1/1] usb: xhci: use BIT_ULL for CRCR bits to fix incorrect 64bit mask
  2026-08-04  8:36 [PATCH 0/1] xhci fix for usb-linus Mathias Nyman
@ 2026-08-04  8:36 ` Mathias Nyman
  0 siblings, 0 replies; 7+ messages in thread
From: Mathias Nyman @ 2026-08-04  8:36 UTC (permalink / raw)
  To: gregkh; +Cc: linux-usb, Lachlan Hodges, stable, Michal Pecio, Mathias Nyman

From: Lachlan Hodges <lachlan.hodges@morsemicro.com>

xhci is unusable on some systems after driver switched to BIT() macro.
Upper 32bits of 64bit CRCR command register are unintentionally cleared.

Seen on a raspberry pi 4B compiled for arm32.
The main symptoms were the following log message:

[    0.549897] raspberrypi-firmware soc:firmware: Attached to firmware from 2021-02-25T12:11:39
[    0.626859] xhci_hcd 0000:01:00.0: xHCI Host Controller
[    0.626889] xhci_hcd 0000:01:00.0: new USB bus registered, assigned bus number 1
[    0.812619] xhci_hcd 0000:01:00.0: hcc params 0x002841eb hci version 0x100 quirks 0x0000200000000890
[    0.813188] xhci_hcd 0000:01:00.0: xHCI Host Controller
[    0.813203] xhci_hcd 0000:01:00.0: new USB bus registered, assigned bus number 2
[    0.813219] xhci_hcd 0000:01:00.0: Host supports USB 3.0 SuperSpeed
[    0.813602] hub 1-0:1.0: USB hub found
[    0.814052] hub 2-0:1.0: USB hub found
[    0.952714] xhci_hcd 0000:01:00.0: ERROR mismatched command completion event

Additionally running lsusb just hangs. Running the same kernel compiled
for aarch64 worked fine. Bisected to the commit in the Fixes line.
Additionally a USB device plugged in to the USB3.0 (or 2.0) did not
enumerate. Once this patch is applied the USB device enumerates properly.

The CRCR register is 64 bits wide - commit abe93f27cdd7
("xhci: use BIT macro") changed the flag definitions from (1 << n),
a signed int, to BIT(n), an unsigned long. Within
xhci_set_cmd_ring_deq(), the following operation is performed on the
CRCR register:

...
	crcr &= ~CMD_RING_PTR_MASK;
	crcr |= deq_dma;
	crcr &= ~CMD_RING_CYCLE;
	crcr |= xhci->cmd_ring->cycle_state;
...

Previously, ~CMD_RING_CYCLE was ~(int)1, a negative signed value
(0xFFFFFFFE with the sign bit set). Widening a negative signed int to
u64 sign-extends it to 0xFFFFFFFFFFFFFFFE, correctly clearing only bit
0 and preserving the 64-bit pointer written two lines above.

After the change when running on 32 bit kernels, ~CMD_RING_CYCLE is
~(unsigned long)1UL. On a 32-bit host this is an unsigned 32-bit
value (0xFFFFFFFE, no sign bit). Widening an unsigned value to u64
zero-extends it instead (0x00000000FFFFFFFE), so the subsequent AND
silently clears bits 63:32 of crcr, truncating the command ring
pointer that was just written before the value reaches hardware.

To fix, similar to how CMD_RING_PTR_MASK is defined, make sure we
use the BIT_ULL variant when defining the CRCR bits.

[Mathias: use BIT_ULL() for ERST_EHB and EP_CTX_CYCLE_MASK as suggested
by Michal Pecio, also include raspberry case in commit message]

Fixes: abe93f27cdd7 ("xhci: use BIT macro")
Cc: stable@vger.kernel.org
Assisted-by: Claude:claude-sonnet-5
cc: Michal Pecio <michal.pecio@gmail.com>
Signed-off-by: Lachlan Hodges <lachlan.hodges@morsemicro.com>
Signed-off-by: Mathias Nyman <mathias.nyman@linux.intel.com>
---
 drivers/usb/host/xhci.h | 12 ++++++------
 1 file changed, 6 insertions(+), 6 deletions(-)

diff --git a/drivers/usb/host/xhci.h b/drivers/usb/host/xhci.h
index 2d3941b5e1e3..708e3ccc5d87 100644
--- a/drivers/usb/host/xhci.h
+++ b/drivers/usb/host/xhci.h
@@ -190,13 +190,13 @@ struct xhci_op_regs {
 
 /* CRCR - Command Ring Control Register - cmd_ring bitmasks */
 /* bit 0 - Cycle bit indicates the ownership of the command ring */
-#define CMD_RING_CYCLE		BIT(0)
+#define CMD_RING_CYCLE		BIT_ULL(0)
 /* stop ring operation after completion of the currently executing command */
-#define CMD_RING_PAUSE		BIT(1)
+#define CMD_RING_PAUSE		BIT_ULL(1)
 /* stop ring immediately - abort the currently executing command */
-#define CMD_RING_ABORT		BIT(2)
+#define CMD_RING_ABORT		BIT_ULL(2)
 /* true: command ring is running */
-#define CMD_RING_RUNNING	BIT(3)
+#define CMD_RING_RUNNING	BIT_ULL(3)
 /* bits 63:6 - Command Ring pointer */
 #define CMD_RING_PTR_MASK	GENMASK_ULL(63, 6)
 
@@ -271,7 +271,7 @@ struct xhci_intr_reg {
  * bit 3 - Event Handler Busy (EHB), whether the event ring is scheduled to be serviced by
  * a work queue (or delayed service routine)?
  */
-#define ERST_EHB		BIT(3)
+#define ERST_EHB		BIT_ULL(3)
 /* bits 63:4 - Event Ring Dequeue Pointer */
 #define ERST_PTR_MASK		GENMASK_ULL(63, 4)
 
@@ -502,7 +502,7 @@ struct xhci_ep_ctx {
 #define CTX_TO_MAX_ESIT_PAYLOAD(p)	(((p) >> 16) & 0xffff)
 
 /* deq bitmasks */
-#define EP_CTX_CYCLE_MASK		BIT(0)
+#define EP_CTX_CYCLE_MASK		BIT_ULL(0)
 /* bits 63:4 - TR Dequeue Pointer */
 #define TR_DEQ_PTR_MASK			GENMASK_ULL(63, 4)
 
-- 
2.43.0


^ permalink raw reply related	[flat|nested] 7+ messages in thread

end of thread, other threads:[~2026-08-04  8:36 UTC | newest]

Thread overview: 7+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2026-08-04  8:36 [PATCH 0/1] xhci fix for usb-linus Mathias Nyman
2026-08-04  8:36 ` [PATCH 1/1] usb: xhci: use BIT_ULL for CRCR bits to fix incorrect 64bit mask Mathias Nyman
  -- strict thread matches above, loose matches on Subject: below --
2025-03-04 11:31 [PATCH 0/1] xhci fix for usb-linus Mathias Nyman
2025-02-25  9:59 Mathias Nyman
2024-08-15 14:11 Mathias Nyman
2021-12-21 11:28 Mathias Nyman
2021-07-15 15:06 Mathias Nyman

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox