[1/2] usb: musb: sunxi: Assert reset before deasserting on init

Message ID 20261117-usb-sunxi-reset-fix-v1-1-c2b76e0e84e1@roadbobek.com (mailing list archive)
State New
Headers
Series usb/phy: sunxi: Assert reset before deasserting on init |

Commit Message

Roadbobek via B4 Relay Nov. 17, 2026, 1 p.m. UTC
From: Roadbobek <admin@roadbobek.com>

When a bootloader such as U-Boot (for example with
CONFIG_USB_MUSB_HOST=y) initializes MUSB and boots Linux
without stopping USB first, the controller reset line is
already deasserted at probe time.

In that case reset_control_deassert() in sunxi_musb_init()
is a no-op and stale MUSB register state persists across boot.
On Allwinner A33, MUSB stays wedged in a_wait_bcon with
DevCtl=0x99, Power=0xf0, and a frozen Frame counter even
across hot-unplug and replug.

Assert glue->rst briefly before deasserting it when
SUNXI_MUSB_FL_HAS_RESET is set so MUSB starts cleanly.
Tested on an Allwinner A33 Q8 tablet (Laser MID-786).

Signed-off-by: Roadbobek <admin@roadbobek.com>
---
 drivers/usb/musb/sunxi.c | 3 +++
 1 file changed, 3 insertions(+)
  

Comments

Philipp Zabel Nov. 17, 2026, 1:05 p.m. UTC | #1
On Di, 2026-11-17 at 13:00 +0000, Roadbobek via B4 Relay wrote:
> From: Roadbobek <admin@roadbobek.com>
> 
> When a bootloader such as U-Boot (for example with
> CONFIG_USB_MUSB_HOST=y) initializes MUSB and boots Linux
> without stopping USB first, the controller reset line is
> already deasserted at probe time.
> 
> In that case reset_control_deassert() in sunxi_musb_init()
> is a no-op and stale MUSB register state persists across boot.
> On Allwinner A33, MUSB stays wedged in a_wait_bcon with
> DevCtl=0x99, Power=0xf0, and a frozen Frame counter even
> across hot-unplug and replug.
> 
> Assert glue->rst briefly before deasserting it when
> SUNXI_MUSB_FL_HAS_RESET is set so MUSB starts cleanly.
> Tested on an Allwinner A33 Q8 tablet (Laser MID-786).
> 
> Signed-off-by: Roadbobek <admin@roadbobek.com>
> ---
>  drivers/usb/musb/sunxi.c | 3 +++
>  1 file changed, 3 insertions(+)
> 
> diff --git a/drivers/usb/musb/sunxi.c b/drivers/usb/musb/sunxi.c
> index a17b1c150626..3d16049e53b5 100644
> --- a/drivers/usb/musb/sunxi.c
> +++ b/drivers/usb/musb/sunxi.c
> @@ -9,6 +9,7 @@
>   */
>  
>  #include <linux/clk.h>
> +#include <linux/delay.h>
>  #include <linux/err.h>
>  #include <linux/extcon.h>
>  #include <linux/io.h>
> @@ -239,6 +240,8 @@ static int sunxi_musb_init(struct musb *musb)
>  		goto error_sram_release;
>  
>  	if (test_bit(SUNXI_MUSB_FL_HAS_RESET, &glue->flags)) {
> +		reset_control_assert(glue->rst);

No error handling?

> +		usleep_range(10, 20);
>  		ret = reset_control_deassert(glue->rst);
>  		if (ret)
>  			goto error_clk_disable;

regards
Philipp
  
sashiko-bot@kernel.org Nov. 17, 2026, 1:09 p.m. UTC | #2
Thank you for your contribution! Sashiko AI review found 2 potential
issues to consider:
- [High] usb: musb: sunxi: Signed-off-by trailer uses single-word handle
  Roadbobek
- [Low] usb: musb: sunxi: missing Fixes trailer for sunxi_musb_init()
  reset fix
--

commit 6fb0d83bc22980ce7dcaa8d7c886a7bcf57b0905
Author: Roadbobek <admin@roadbobek.com>

> usb: musb: sunxi: Assert reset before deasserting on init
>
> When a bootloader such as U-Boot (for example with
> CONFIG_USB_MUSB_HOST=y) initializes MUSB and boots Linux
> without stopping USB first, the controller reset line is
> already deasserted at probe time.
>
> In that case reset_control_deassert() in sunxi_musb_init()
> is a no-op and stale MUSB register state persists across boot.
> On Allwinner A33, MUSB stays wedged in a_wait_bcon with
> DevCtl=0x99, Power=0xf0, and a frozen Frame counter even
> across hot-unplug and replug.
>
> Assert glue->rst briefly before deasserting it when
> SUNXI_MUSB_FL_HAS_RESET is set so MUSB starts cleanly.
> Tested on an Allwinner A33 Q8 tablet (Laser MID-786).
>
> Signed-off-by: Roadbobek <admin@roadbobek.com>

[Severity: High]
Per Documentation/process/submitting-patches.rst, the Author header and
Signed-off-by trailer must use a real full name rather than a single-word
handle or nickname.

[Severity: Low]
Since this fixes the reset initialization in sunxi_musb_init(), should it
include:

  Fixes: 132e23775779 ("usb: musb: sunxi: Add support for musb controller in A31 SoC")
  

Patch

diff --git a/drivers/usb/musb/sunxi.c b/drivers/usb/musb/sunxi.c
index a17b1c150626..3d16049e53b5 100644
--- a/drivers/usb/musb/sunxi.c
+++ b/drivers/usb/musb/sunxi.c
@@ -9,6 +9,7 @@ 
  */
 
 #include <linux/clk.h>
+#include <linux/delay.h>
 #include <linux/err.h>
 #include <linux/extcon.h>
 #include <linux/io.h>
@@ -239,6 +240,8 @@  static int sunxi_musb_init(struct musb *musb)
 		goto error_sram_release;
 
 	if (test_bit(SUNXI_MUSB_FL_HAS_RESET, &glue->flags)) {
+		reset_control_assert(glue->rst);
+		usleep_range(10, 20);
 		ret = reset_control_deassert(glue->rst);
 		if (ret)
 			goto error_clk_disable;