From: Thinh Nguyen <Thinh.Nguyen@synopsys.com>
To: Sebastian Reichel <sebastian.reichel@collabora.com>
Cc: Thinh Nguyen <Thinh.Nguyen@synopsys.com>,
Greg Kroah-Hartman <gregkh@linuxfoundation.org>,
Heiko Stuebner <heiko@sntech.de>, Vinod Koul <vkoul@kernel.org>,
Neil Armstrong <neil.armstrong@linaro.org>,
Manivannan Sadhasivam <mani@kernel.org>,
"linux-kernel@vger.kernel.org" <linux-kernel@vger.kernel.org>,
"linux-usb@vger.kernel.org" <linux-usb@vger.kernel.org>,
"linux-arm-kernel@lists.infradead.org"
<linux-arm-kernel@lists.infradead.org>,
"linux-rockchip@lists.infradead.org"
<linux-rockchip@lists.infradead.org>,
"linux-phy@lists.infradead.org" <linux-phy@lists.infradead.org>,
"kernel@collabora.com" <kernel@collabora.com>
Subject: Re: [PATCH 5/5] usb: dwc3: rockchip: fix USB-C reconnect in gadget mode
Date: Wed, 23 Sep 2026 01:58:19 +0000 [thread overview]
Message-ID: <arMyLlcFKgtlwW_T@vbox> (raw)
In-Reply-To: <20260915-b4-rockchip-dwc3-rockchip-glue-v1-5-763bb546824e@collabora.com>
On Tue, Sep 15, 2026, Sebastian Reichel wrote:
> When USB-C is configured in gadget mode and the cable is unplugged
> the USB controller is suspended. After plugging in the cable again,
> the USB controller stays suspended and thus the port status remains
> not-attached.
>
> Fix this by triggering a runtime PM resume when the role is changed.
> The Runtime PM reference counter is immediately decreased again - the
> auto-suspend time is big enough to detect the connection status, which
> will then keep its own reference.
>
> Signed-off-by: Sebastian Reichel <sebastian.reichel@collabora.com>
> ---
> drivers/usb/dwc3/dwc3-rockchip.c | 23 +++++++++++++++++++++++
> 1 file changed, 23 insertions(+)
>
> diff --git a/drivers/usb/dwc3/dwc3-rockchip.c b/drivers/usb/dwc3/dwc3-rockchip.c
> index 7bdd6e2eb22d..bedec3295bb1 100644
> --- a/drivers/usb/dwc3/dwc3-rockchip.c
> +++ b/drivers/usb/dwc3/dwc3-rockchip.c
> @@ -25,8 +25,17 @@ struct dwc3_rockchip {
> struct dwc3 dwc;
> struct dwc3_rk_phy_nb usb3_phy_nb[DWC3_USB3_MAX_PORTS];
> u8 phy_reset_active;
> + enum usb_role role;
> };
>
> +static void dwc3_rockchip_vbus_handler(struct dwc3 *dwc, bool present)
> +{
> + if (!dwc->gadget || !dwc->gadget_driver)
> + return;
> +
> + usb_udc_vbus_handler(dwc->gadget, present);
> +}
> +
> static int dwc3_usb3_phy_notify(struct notifier_block *nb,
> unsigned long action, void *data)
> {
> @@ -57,6 +66,8 @@ static int dwc3_usb3_phy_notify(struct notifier_block *nb,
> if (!ret)
> return NOTIFY_OK;
>
> + dwc3_rockchip_vbus_handler(dwc, false);
> +
> /*
> * Assert USB3 PHY soft reset within DWC3 before the external
> * PHY resets. This disconnects the PIPE interface, preventing
> @@ -69,6 +80,7 @@ static int dwc3_usb3_phy_notify(struct notifier_block *nb,
> reg |= DWC3_GUSB3PIPECTL_PHYSOFTRST;
> dwc3_writel(dwc, DWC3_GUSB3PIPECTL(port), reg);
> spin_unlock_irqrestore(&dwc->lock, flags);
> +
> break;
>
> case PHY_NOTIFY_POST_RESET:
> @@ -89,6 +101,8 @@ static int dwc3_usb3_phy_notify(struct notifier_block *nb,
> dwc3_writel(dwc, DWC3_GUSB3PIPECTL(port), reg);
> spin_unlock_irqrestore(&dwc->lock, flags);
>
> + dwc3_rockchip_vbus_handler(dwc, dwc_rk->role == USB_ROLE_DEVICE);
> +
> pm_runtime_put_autosuspend(dwc->dev);
> break;
> }
> @@ -130,7 +144,16 @@ static int dwc3_rk_phy_register_notifiers(struct dwc3 *dwc)
> return devm_add_action_or_reset(dwc->dev, dwc3_rk_phy_unregister_notifiers, dwc_rk);
> }
>
> +static void dwc3_rockchip_set_role(struct dwc3 *dwc, enum usb_role role)
> +{
> + struct dwc3_rockchip *dwc_rk = container_of(dwc, struct dwc3_rockchip, dwc);
> +
> + dwc_rk->role = role;
> + dwc3_rockchip_vbus_handler(dwc, role == USB_ROLE_DEVICE);
> +}
> +
> static struct dwc3_glue_ops dwc3_rockchip_glue_ops = {
> + .pre_set_role = dwc3_rockchip_set_role,
> .post_phy_registration = dwc3_rk_phy_register_notifiers,
> };
>
>
> --
> 2.53.0
>
Acked-by: Thinh Nguyen <Thinh.Nguyen@synopsys.com>
Thanks,
Thinh
next prev parent reply other threads:[~2026-09-23 1:59 UTC|newest]
Thread overview: 15+ messages / expand[flat|nested] mbox.gz Atom feed top
2026-09-15 15:17 [PATCH 0/5] usb: dwc3: introduce Rockchip glue driver Sebastian Reichel
2026-09-15 15:17 ` [PATCH 1/5] phy: core: add notifier infrastructure Sebastian Reichel
2026-09-15 15:17 ` [PATCH 2/5] usb: dwc3: rockchip: introduce glue driver Sebastian Reichel
2026-09-23 1:31 ` Thinh Nguyen
2026-09-23 5:53 ` Krishna Kurapati
2026-09-15 15:17 ` [PATCH 3/5] usb: dwc3: core: add post PHY registration hook for platform glue Sebastian Reichel
2026-09-23 1:48 ` Thinh Nguyen
2026-09-23 5:54 ` Krishna Kurapati
2026-09-15 15:17 ` [PATCH 4/5] usb: dwc3: rockchip: support PHY reset notifications Sebastian Reichel
2026-09-23 1:56 ` Thinh Nguyen
2026-09-15 15:17 ` [PATCH 5/5] usb: dwc3: rockchip: fix USB-C reconnect in gadget mode Sebastian Reichel
2026-09-18 9:10 ` Igor Paunovic
2026-09-23 1:58 ` Thinh Nguyen [this message]
2026-09-23 8:59 ` Igor Paunovic
2026-09-24 1:47 ` Thinh Nguyen
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=arMyLlcFKgtlwW_T@vbox \
--to=thinh.nguyen@synopsys.com \
--cc=gregkh@linuxfoundation.org \
--cc=heiko@sntech.de \
--cc=kernel@collabora.com \
--cc=linux-arm-kernel@lists.infradead.org \
--cc=linux-kernel@vger.kernel.org \
--cc=linux-phy@lists.infradead.org \
--cc=linux-rockchip@lists.infradead.org \
--cc=linux-usb@vger.kernel.org \
--cc=mani@kernel.org \
--cc=neil.armstrong@linaro.org \
--cc=sebastian.reichel@collabora.com \
--cc=vkoul@kernel.org \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
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®