* [PATCH] usb: dwc3: apple: Ignore USB role switches to the active role
@ 2026-01-09 10:13 Janne Grunau
2026-01-13 0:52 ` Thinh Nguyen
2026-01-13 6:58 ` Sven Peter
0 siblings, 2 replies; 3+ messages in thread
From: Janne Grunau @ 2026-01-09 10:13 UTC (permalink / raw)
To: Sven Peter, Neal Gompa, Thinh Nguyen, Greg Kroah-Hartman
Cc: asahi, linux-arm-kernel, linux-usb, linux-kernel, stable,
Janne Grunau
Ignore USB role switches if dwc3-apple is already in the desired state.
The USB-C port controller on M2 and M1/M2 Pro/Max/Ultra devices issues
additional interrupts which result in USB role switches to the already
active role.
Ignore these USB role switches to ensure the USB-C port controller and
dwc3-apple are always in a consistent state. This matches the behaviour
in __dwc3_set_mode() in core.c.
Fixes detecting USB 2.0 and 3.x devices on the affected systems. The
reset caused by the additional role switch appears to leave the USB
devices in a state which prevents detection when the phy and dwc3 is
brought back up again.
Fixes: 0ec946d32ef7 ("usb: dwc3: Add Apple Silicon DWC3 glue layer driver")
Cc: stable@vger.kernel.org
Signed-off-by: Janne Grunau <j@jannau.net>
---
drivers/usb/dwc3/dwc3-apple.c | 16 ++++++++++++++++
1 file changed, 16 insertions(+)
diff --git a/drivers/usb/dwc3/dwc3-apple.c b/drivers/usb/dwc3/dwc3-apple.c
index cc47cad232e397ac4498b09165dfdb5bd215ded7..35eadd1fa08049829ba40651a96eb122ed55460f 100644
--- a/drivers/usb/dwc3/dwc3-apple.c
+++ b/drivers/usb/dwc3/dwc3-apple.c
@@ -339,6 +339,22 @@ static int dwc3_usb_role_switch_set(struct usb_role_switch *sw, enum usb_role ro
guard(mutex)(&appledwc->lock);
+ /*
+ * Skip role switches if appledwc is already in the desired state. The
+ * USB-C port controller on M2 and M1/M2 Pro/Max/Ultra devices issues
+ * additional interrupts which results in usb_role_switch_set_role()
+ * calls with the current role.
+ * Ignore those calls here to ensure the USB-C port controller and
+ * appledwc are in a consistent state.
+ * This matches the behaviour in __dwc3_set_mode().
+ * Do no handle USB_ROLE_NONE for DWC3_APPLE_NO_CABLE and
+ * DWC3_APPLE_PROBE_PENDING since that is no-op anyway.
+ */
+ if (appledwc->state == DWC3_APPLE_HOST && role == USB_ROLE_HOST)
+ return 0;
+ if (appledwc->state == DWC3_APPLE_DEVICE && role == USB_ROLE_DEVICE)
+ return 0;
+
/*
* We need to tear all of dwc3 down and re-initialize it every time a cable is
* connected or disconnected or when the mode changes. See the documentation for enum
---
base-commit: 8f0b4cce4481fb22653697cced8d0d04027cb1e8
change-id: 20260109-apple-dwc3-role-switch-1b684f73860c
Best regards,
--
Janne Grunau <j@jannau.net>
^ permalink raw reply related [flat|nested] 3+ messages in thread
* Re: [PATCH] usb: dwc3: apple: Ignore USB role switches to the active role
2026-01-09 10:13 [PATCH] usb: dwc3: apple: Ignore USB role switches to the active role Janne Grunau
@ 2026-01-13 0:52 ` Thinh Nguyen
2026-01-13 6:58 ` Sven Peter
1 sibling, 0 replies; 3+ messages in thread
From: Thinh Nguyen @ 2026-01-13 0:52 UTC (permalink / raw)
To: Janne Grunau
Cc: Sven Peter, Neal Gompa, Thinh Nguyen, Greg Kroah-Hartman,
asahi@lists.linux.dev, linux-arm-kernel@lists.infradead.org,
linux-usb@vger.kernel.org, linux-kernel@vger.kernel.org,
stable@vger.kernel.org
On Fri, Jan 09, 2026, Janne Grunau wrote:
> Ignore USB role switches if dwc3-apple is already in the desired state.
> The USB-C port controller on M2 and M1/M2 Pro/Max/Ultra devices issues
> additional interrupts which result in USB role switches to the already
> active role.
> Ignore these USB role switches to ensure the USB-C port controller and
> dwc3-apple are always in a consistent state. This matches the behaviour
> in __dwc3_set_mode() in core.c.
> Fixes detecting USB 2.0 and 3.x devices on the affected systems. The
> reset caused by the additional role switch appears to leave the USB
> devices in a state which prevents detection when the phy and dwc3 is
> brought back up again.
>
> Fixes: 0ec946d32ef7 ("usb: dwc3: Add Apple Silicon DWC3 glue layer driver")
> Cc: stable@vger.kernel.org
> Signed-off-by: Janne Grunau <j@jannau.net>
> ---
> drivers/usb/dwc3/dwc3-apple.c | 16 ++++++++++++++++
> 1 file changed, 16 insertions(+)
>
> diff --git a/drivers/usb/dwc3/dwc3-apple.c b/drivers/usb/dwc3/dwc3-apple.c
> index cc47cad232e397ac4498b09165dfdb5bd215ded7..35eadd1fa08049829ba40651a96eb122ed55460f 100644
> --- a/drivers/usb/dwc3/dwc3-apple.c
> +++ b/drivers/usb/dwc3/dwc3-apple.c
> @@ -339,6 +339,22 @@ static int dwc3_usb_role_switch_set(struct usb_role_switch *sw, enum usb_role ro
>
> guard(mutex)(&appledwc->lock);
>
> + /*
> + * Skip role switches if appledwc is already in the desired state. The
> + * USB-C port controller on M2 and M1/M2 Pro/Max/Ultra devices issues
> + * additional interrupts which results in usb_role_switch_set_role()
> + * calls with the current role.
> + * Ignore those calls here to ensure the USB-C port controller and
> + * appledwc are in a consistent state.
> + * This matches the behaviour in __dwc3_set_mode().
> + * Do no handle USB_ROLE_NONE for DWC3_APPLE_NO_CABLE and
> + * DWC3_APPLE_PROBE_PENDING since that is no-op anyway.
> + */
> + if (appledwc->state == DWC3_APPLE_HOST && role == USB_ROLE_HOST)
> + return 0;
> + if (appledwc->state == DWC3_APPLE_DEVICE && role == USB_ROLE_DEVICE)
> + return 0;
> +
> /*
> * We need to tear all of dwc3 down and re-initialize it every time a cable is
> * connected or disconnected or when the mode changes. See the documentation for enum
>
> ---
> base-commit: 8f0b4cce4481fb22653697cced8d0d04027cb1e8
> change-id: 20260109-apple-dwc3-role-switch-1b684f73860c
>
> Best regards,
> --
> Janne Grunau <j@jannau.net>
>
Acked-by: Thinh Nguyen <Thinh.Nguyen@synopsys.com>
Thanks,
Thinh
^ permalink raw reply [flat|nested] 3+ messages in thread
* Re: [PATCH] usb: dwc3: apple: Ignore USB role switches to the active role
2026-01-09 10:13 [PATCH] usb: dwc3: apple: Ignore USB role switches to the active role Janne Grunau
2026-01-13 0:52 ` Thinh Nguyen
@ 2026-01-13 6:58 ` Sven Peter
1 sibling, 0 replies; 3+ messages in thread
From: Sven Peter @ 2026-01-13 6:58 UTC (permalink / raw)
To: Janne Grunau, Neal Gompa, Thinh Nguyen, Greg Kroah-Hartman
Cc: asahi, linux-arm-kernel, linux-usb, linux-kernel, stable
On 09.01.26 11:13, Janne Grunau wrote:
> Ignore USB role switches if dwc3-apple is already in the desired state.
> The USB-C port controller on M2 and M1/M2 Pro/Max/Ultra devices issues
> additional interrupts which result in USB role switches to the already
> active role.
> Ignore these USB role switches to ensure the USB-C port controller and
> dwc3-apple are always in a consistent state. This matches the behaviour
> in __dwc3_set_mode() in core.c.
> Fixes detecting USB 2.0 and 3.x devices on the affected systems. The
> reset caused by the additional role switch appears to leave the USB
> devices in a state which prevents detection when the phy and dwc3 is
> brought back up again.
>
> Fixes: 0ec946d32ef7 ("usb: dwc3: Add Apple Silicon DWC3 glue layer driver")
> Cc: stable@vger.kernel.org
> Signed-off-by: Janne Grunau <j@jannau.net>
> ---
Reviewed-by: Sven Peter <sven@kernel.org>
Tested-by: Sven Peter <sven@kernel.org> # M1 mac mini and macbook air
thanks,
Sven
^ permalink raw reply [flat|nested] 3+ messages in thread
end of thread, other threads:[~2026-01-13 6:59 UTC | newest]
Thread overview: 3+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2026-01-09 10:13 [PATCH] usb: dwc3: apple: Ignore USB role switches to the active role Janne Grunau
2026-01-13 0:52 ` Thinh Nguyen
2026-01-13 6:58 ` Sven Peter
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox