* [PATCH v2 2/3] usb: dwc3: imx8mp: rename dwc3 to dwc3_pdev in struct dwc3_imx8mp
2025-12-05 3:29 [PATCH v2 1/3] usb: dwc3: drd: extend dwc3_pre_set_role() to extcon and otg usecase Xu Yang
@ 2025-12-05 3:29 ` Xu Yang
2025-12-05 15:12 ` Frank Li
2025-12-16 23:19 ` Thinh Nguyen
2025-12-05 3:29 ` [PATCH v2 3/3] usb: dwc3: imx8mp: disable auto suspend for host role Xu Yang
2025-12-16 23:18 ` [PATCH v2 1/3] usb: dwc3: drd: extend dwc3_pre_set_role() to extcon and otg usecase Thinh Nguyen
2 siblings, 2 replies; 9+ messages in thread
From: Xu Yang @ 2025-12-05 3:29 UTC (permalink / raw)
To: Thinh.Nguyen, gregkh, shawnguo, s.hauer, kernel, festevam
Cc: linux-usb, linux-kernel, imx, linux-arm-kernel, jun.li
It's confuse to let "dwc3" represent a platform_device, because "dwc3"
may also represent a dwc3 core structure. Rename it for better
distinction.
Signed-off-by: Xu Yang <xu.yang_2@nxp.com>
---
Changes in v2:
- new patch
---
drivers/usb/dwc3/dwc3-imx8mp.c | 16 ++++++++--------
1 file changed, 8 insertions(+), 8 deletions(-)
diff --git a/drivers/usb/dwc3/dwc3-imx8mp.c b/drivers/usb/dwc3/dwc3-imx8mp.c
index 050da327f785..8bece4baecbf 100644
--- a/drivers/usb/dwc3/dwc3-imx8mp.c
+++ b/drivers/usb/dwc3/dwc3-imx8mp.c
@@ -51,7 +51,7 @@
struct dwc3_imx8mp {
struct device *dev;
- struct platform_device *dwc3;
+ struct platform_device *dwc3_pdev;
void __iomem *hsio_blk_base;
void __iomem *glue_base;
struct clk *hsio_clk;
@@ -100,7 +100,7 @@ static void imx8mp_configure_glue(struct dwc3_imx8mp *dwc3_imx)
static void dwc3_imx8mp_wakeup_enable(struct dwc3_imx8mp *dwc3_imx,
pm_message_t msg)
{
- struct dwc3 *dwc3 = platform_get_drvdata(dwc3_imx->dwc3);
+ struct dwc3 *dwc3 = platform_get_drvdata(dwc3_imx->dwc3_pdev);
u32 val;
if (!dwc3)
@@ -142,7 +142,7 @@ static const struct software_node dwc3_imx8mp_swnode = {
static irqreturn_t dwc3_imx8mp_interrupt(int irq, void *_dwc3_imx)
{
struct dwc3_imx8mp *dwc3_imx = _dwc3_imx;
- struct dwc3 *dwc = platform_get_drvdata(dwc3_imx->dwc3);
+ struct dwc3 *dwc = platform_get_drvdata(dwc3_imx->dwc3_pdev);
if (!dwc3_imx->pm_suspended)
return IRQ_HANDLED;
@@ -233,8 +233,8 @@ static int dwc3_imx8mp_probe(struct platform_device *pdev)
goto remove_swnode;
}
- dwc3_imx->dwc3 = of_find_device_by_node(dwc3_np);
- if (!dwc3_imx->dwc3) {
+ dwc3_imx->dwc3_pdev = of_find_device_by_node(dwc3_np);
+ if (!dwc3_imx->dwc3_pdev) {
dev_err(dev, "failed to get dwc3 platform device\n");
err = -ENODEV;
goto depopulate;
@@ -253,7 +253,7 @@ static int dwc3_imx8mp_probe(struct platform_device *pdev)
return 0;
put_dwc3:
- put_device(&dwc3_imx->dwc3->dev);
+ put_device(&dwc3_imx->dwc3_pdev->dev);
depopulate:
of_platform_depopulate(dev);
remove_swnode:
@@ -270,7 +270,7 @@ static void dwc3_imx8mp_remove(struct platform_device *pdev)
struct dwc3_imx8mp *dwc3_imx = platform_get_drvdata(pdev);
struct device *dev = &pdev->dev;
- put_device(&dwc3_imx->dwc3->dev);
+ put_device(&dwc3_imx->dwc3_pdev->dev);
pm_runtime_get_sync(dev);
of_platform_depopulate(dev);
@@ -296,7 +296,7 @@ static int dwc3_imx8mp_suspend(struct dwc3_imx8mp *dwc3_imx, pm_message_t msg)
static int dwc3_imx8mp_resume(struct dwc3_imx8mp *dwc3_imx, pm_message_t msg)
{
- struct dwc3 *dwc = platform_get_drvdata(dwc3_imx->dwc3);
+ struct dwc3 *dwc = platform_get_drvdata(dwc3_imx->dwc3_pdev);
int ret = 0;
if (!dwc3_imx->pm_suspended)
--
2.34.1
^ permalink raw reply related [flat|nested] 9+ messages in thread* Re: [PATCH v2 2/3] usb: dwc3: imx8mp: rename dwc3 to dwc3_pdev in struct dwc3_imx8mp
2025-12-05 3:29 ` [PATCH v2 2/3] usb: dwc3: imx8mp: rename dwc3 to dwc3_pdev in struct dwc3_imx8mp Xu Yang
@ 2025-12-05 15:12 ` Frank Li
2025-12-16 23:19 ` Thinh Nguyen
1 sibling, 0 replies; 9+ messages in thread
From: Frank Li @ 2025-12-05 15:12 UTC (permalink / raw)
To: Xu Yang
Cc: Thinh.Nguyen, gregkh, shawnguo, s.hauer, kernel, festevam,
linux-usb, linux-kernel, imx, linux-arm-kernel, jun.li
On Fri, Dec 05, 2025 at 11:29:41AM +0800, Xu Yang wrote:
> It's confuse to let "dwc3" represent a platform_device, because "dwc3"
> may also represent a dwc3 core structure. Rename it for better
> distinction.
>
> Signed-off-by: Xu Yang <xu.yang_2@nxp.com>
>
Reviewed-by: Frank Li <Frank.Li@nxp.com>
> ---
> Changes in v2:
> - new patch
> ---
> drivers/usb/dwc3/dwc3-imx8mp.c | 16 ++++++++--------
> 1 file changed, 8 insertions(+), 8 deletions(-)
>
> diff --git a/drivers/usb/dwc3/dwc3-imx8mp.c b/drivers/usb/dwc3/dwc3-imx8mp.c
> index 050da327f785..8bece4baecbf 100644
> --- a/drivers/usb/dwc3/dwc3-imx8mp.c
> +++ b/drivers/usb/dwc3/dwc3-imx8mp.c
> @@ -51,7 +51,7 @@
>
> struct dwc3_imx8mp {
> struct device *dev;
> - struct platform_device *dwc3;
> + struct platform_device *dwc3_pdev;
> void __iomem *hsio_blk_base;
> void __iomem *glue_base;
> struct clk *hsio_clk;
> @@ -100,7 +100,7 @@ static void imx8mp_configure_glue(struct dwc3_imx8mp *dwc3_imx)
> static void dwc3_imx8mp_wakeup_enable(struct dwc3_imx8mp *dwc3_imx,
> pm_message_t msg)
> {
> - struct dwc3 *dwc3 = platform_get_drvdata(dwc3_imx->dwc3);
> + struct dwc3 *dwc3 = platform_get_drvdata(dwc3_imx->dwc3_pdev);
> u32 val;
>
> if (!dwc3)
> @@ -142,7 +142,7 @@ static const struct software_node dwc3_imx8mp_swnode = {
> static irqreturn_t dwc3_imx8mp_interrupt(int irq, void *_dwc3_imx)
> {
> struct dwc3_imx8mp *dwc3_imx = _dwc3_imx;
> - struct dwc3 *dwc = platform_get_drvdata(dwc3_imx->dwc3);
> + struct dwc3 *dwc = platform_get_drvdata(dwc3_imx->dwc3_pdev);
>
> if (!dwc3_imx->pm_suspended)
> return IRQ_HANDLED;
> @@ -233,8 +233,8 @@ static int dwc3_imx8mp_probe(struct platform_device *pdev)
> goto remove_swnode;
> }
>
> - dwc3_imx->dwc3 = of_find_device_by_node(dwc3_np);
> - if (!dwc3_imx->dwc3) {
> + dwc3_imx->dwc3_pdev = of_find_device_by_node(dwc3_np);
> + if (!dwc3_imx->dwc3_pdev) {
> dev_err(dev, "failed to get dwc3 platform device\n");
> err = -ENODEV;
> goto depopulate;
> @@ -253,7 +253,7 @@ static int dwc3_imx8mp_probe(struct platform_device *pdev)
> return 0;
>
> put_dwc3:
> - put_device(&dwc3_imx->dwc3->dev);
> + put_device(&dwc3_imx->dwc3_pdev->dev);
> depopulate:
> of_platform_depopulate(dev);
> remove_swnode:
> @@ -270,7 +270,7 @@ static void dwc3_imx8mp_remove(struct platform_device *pdev)
> struct dwc3_imx8mp *dwc3_imx = platform_get_drvdata(pdev);
> struct device *dev = &pdev->dev;
>
> - put_device(&dwc3_imx->dwc3->dev);
> + put_device(&dwc3_imx->dwc3_pdev->dev);
>
> pm_runtime_get_sync(dev);
> of_platform_depopulate(dev);
> @@ -296,7 +296,7 @@ static int dwc3_imx8mp_suspend(struct dwc3_imx8mp *dwc3_imx, pm_message_t msg)
>
> static int dwc3_imx8mp_resume(struct dwc3_imx8mp *dwc3_imx, pm_message_t msg)
> {
> - struct dwc3 *dwc = platform_get_drvdata(dwc3_imx->dwc3);
> + struct dwc3 *dwc = platform_get_drvdata(dwc3_imx->dwc3_pdev);
> int ret = 0;
>
> if (!dwc3_imx->pm_suspended)
> --
> 2.34.1
>
^ permalink raw reply [flat|nested] 9+ messages in thread* Re: [PATCH v2 2/3] usb: dwc3: imx8mp: rename dwc3 to dwc3_pdev in struct dwc3_imx8mp
2025-12-05 3:29 ` [PATCH v2 2/3] usb: dwc3: imx8mp: rename dwc3 to dwc3_pdev in struct dwc3_imx8mp Xu Yang
2025-12-05 15:12 ` Frank Li
@ 2025-12-16 23:19 ` Thinh Nguyen
1 sibling, 0 replies; 9+ messages in thread
From: Thinh Nguyen @ 2025-12-16 23:19 UTC (permalink / raw)
To: Xu Yang
Cc: Thinh Nguyen, gregkh@linuxfoundation.org, shawnguo@kernel.org,
s.hauer@pengutronix.de, kernel@pengutronix.de, festevam@gmail.com,
linux-usb@vger.kernel.org, linux-kernel@vger.kernel.org,
imx@lists.linux.dev, linux-arm-kernel@lists.infradead.org,
jun.li@nxp.com
On Fri, Dec 05, 2025, Xu Yang wrote:
> It's confuse to let "dwc3" represent a platform_device, because "dwc3"
> may also represent a dwc3 core structure. Rename it for better
> distinction.
>
> Signed-off-by: Xu Yang <xu.yang_2@nxp.com>
>
> ---
> Changes in v2:
> - new patch
> ---
> drivers/usb/dwc3/dwc3-imx8mp.c | 16 ++++++++--------
> 1 file changed, 8 insertions(+), 8 deletions(-)
>
> diff --git a/drivers/usb/dwc3/dwc3-imx8mp.c b/drivers/usb/dwc3/dwc3-imx8mp.c
> index 050da327f785..8bece4baecbf 100644
> --- a/drivers/usb/dwc3/dwc3-imx8mp.c
> +++ b/drivers/usb/dwc3/dwc3-imx8mp.c
> @@ -51,7 +51,7 @@
>
> struct dwc3_imx8mp {
> struct device *dev;
> - struct platform_device *dwc3;
> + struct platform_device *dwc3_pdev;
> void __iomem *hsio_blk_base;
> void __iomem *glue_base;
> struct clk *hsio_clk;
> @@ -100,7 +100,7 @@ static void imx8mp_configure_glue(struct dwc3_imx8mp *dwc3_imx)
> static void dwc3_imx8mp_wakeup_enable(struct dwc3_imx8mp *dwc3_imx,
> pm_message_t msg)
> {
> - struct dwc3 *dwc3 = platform_get_drvdata(dwc3_imx->dwc3);
> + struct dwc3 *dwc3 = platform_get_drvdata(dwc3_imx->dwc3_pdev);
> u32 val;
>
> if (!dwc3)
> @@ -142,7 +142,7 @@ static const struct software_node dwc3_imx8mp_swnode = {
> static irqreturn_t dwc3_imx8mp_interrupt(int irq, void *_dwc3_imx)
> {
> struct dwc3_imx8mp *dwc3_imx = _dwc3_imx;
> - struct dwc3 *dwc = platform_get_drvdata(dwc3_imx->dwc3);
> + struct dwc3 *dwc = platform_get_drvdata(dwc3_imx->dwc3_pdev);
>
> if (!dwc3_imx->pm_suspended)
> return IRQ_HANDLED;
> @@ -233,8 +233,8 @@ static int dwc3_imx8mp_probe(struct platform_device *pdev)
> goto remove_swnode;
> }
>
> - dwc3_imx->dwc3 = of_find_device_by_node(dwc3_np);
> - if (!dwc3_imx->dwc3) {
> + dwc3_imx->dwc3_pdev = of_find_device_by_node(dwc3_np);
> + if (!dwc3_imx->dwc3_pdev) {
> dev_err(dev, "failed to get dwc3 platform device\n");
> err = -ENODEV;
> goto depopulate;
> @@ -253,7 +253,7 @@ static int dwc3_imx8mp_probe(struct platform_device *pdev)
> return 0;
>
> put_dwc3:
> - put_device(&dwc3_imx->dwc3->dev);
> + put_device(&dwc3_imx->dwc3_pdev->dev);
> depopulate:
> of_platform_depopulate(dev);
> remove_swnode:
> @@ -270,7 +270,7 @@ static void dwc3_imx8mp_remove(struct platform_device *pdev)
> struct dwc3_imx8mp *dwc3_imx = platform_get_drvdata(pdev);
> struct device *dev = &pdev->dev;
>
> - put_device(&dwc3_imx->dwc3->dev);
> + put_device(&dwc3_imx->dwc3_pdev->dev);
>
> pm_runtime_get_sync(dev);
> of_platform_depopulate(dev);
> @@ -296,7 +296,7 @@ static int dwc3_imx8mp_suspend(struct dwc3_imx8mp *dwc3_imx, pm_message_t msg)
>
> static int dwc3_imx8mp_resume(struct dwc3_imx8mp *dwc3_imx, pm_message_t msg)
> {
> - struct dwc3 *dwc = platform_get_drvdata(dwc3_imx->dwc3);
> + struct dwc3 *dwc = platform_get_drvdata(dwc3_imx->dwc3_pdev);
> int ret = 0;
>
> if (!dwc3_imx->pm_suspended)
> --
> 2.34.1
>
Acked-by: Thinh Nguyen <Thinh.Nguyen@synopsys.com>
Thanks,
Thinh
^ permalink raw reply [flat|nested] 9+ messages in thread
* [PATCH v2 3/3] usb: dwc3: imx8mp: disable auto suspend for host role
2025-12-05 3:29 [PATCH v2 1/3] usb: dwc3: drd: extend dwc3_pre_set_role() to extcon and otg usecase Xu Yang
2025-12-05 3:29 ` [PATCH v2 2/3] usb: dwc3: imx8mp: rename dwc3 to dwc3_pdev in struct dwc3_imx8mp Xu Yang
@ 2025-12-05 3:29 ` Xu Yang
2025-12-16 23:26 ` Thinh Nguyen
2025-12-16 23:18 ` [PATCH v2 1/3] usb: dwc3: drd: extend dwc3_pre_set_role() to extcon and otg usecase Thinh Nguyen
2 siblings, 1 reply; 9+ messages in thread
From: Xu Yang @ 2025-12-05 3:29 UTC (permalink / raw)
To: Thinh.Nguyen, gregkh, shawnguo, s.hauer, kernel, festevam
Cc: linux-usb, linux-kernel, imx, linux-arm-kernel, jun.li
Do dwc3 core auto suspend enable for device and disable for host
, this can make sure dwc3 core device auto suspend setting is
correct all the time, the background of disable dwc3 core device
auto suspend is to make its parent device suspend immediately
(so wakeup enable can be enabled) after xhci-plat device suspended,
for device mode, we keep the dwc3 core device auto suspend is to
give some wait for gadget to be enumerated.
Note: It's a temporary solution until we switch to using the new
flatten model.
Signed-off-by: Xu Yang <xu.yang_2@nxp.com>
---
Changes in v2:
- add a note suggested by Thinh
---
drivers/usb/dwc3/dwc3-imx8mp.c | 31 +++++++++++++++++++++++++++++++
1 file changed, 31 insertions(+)
diff --git a/drivers/usb/dwc3/dwc3-imx8mp.c b/drivers/usb/dwc3/dwc3-imx8mp.c
index 8bece4baecbf..2e13ca588f42 100644
--- a/drivers/usb/dwc3/dwc3-imx8mp.c
+++ b/drivers/usb/dwc3/dwc3-imx8mp.c
@@ -158,11 +158,31 @@ static irqreturn_t dwc3_imx8mp_interrupt(int irq, void *_dwc3_imx)
return IRQ_HANDLED;
}
+static void dwc3_imx_pre_set_role(struct dwc3 *dwc, enum usb_role role)
+{
+ if (role == USB_ROLE_HOST)
+ /*
+ * For xhci host, we need disable dwc core auto
+ * suspend, because during this auto suspend delay(5s),
+ * xhci host RUN_STOP is cleared and wakeup is not
+ * enabled, if device is inserted, xhci host can't
+ * response the connection.
+ */
+ pm_runtime_dont_use_autosuspend(dwc->dev);
+ else
+ pm_runtime_use_autosuspend(dwc->dev);
+}
+
+struct dwc3_glue_ops dwc3_imx_glue_ops = {
+ .pre_set_role = dwc3_imx_pre_set_role,
+};
+
static int dwc3_imx8mp_probe(struct platform_device *pdev)
{
struct device *dev = &pdev->dev;
struct device_node *node = dev->of_node;
struct dwc3_imx8mp *dwc3_imx;
+ struct dwc3 *dwc3;
struct resource *res;
int err, irq;
@@ -240,6 +260,17 @@ static int dwc3_imx8mp_probe(struct platform_device *pdev)
goto depopulate;
}
+ dwc3 = platform_get_drvdata(dwc3_imx->dwc3_pdev);
+ if (!dwc3) {
+ err = dev_err_probe(dev, -EPROBE_DEFER, "failed to get dwc3 platform data\n");
+ goto depopulate;
+ }
+
+ dwc3->glue_ops = &dwc3_imx_glue_ops;
+
+ if (dwc3->dr_mode == USB_DR_MODE_HOST)
+ pm_runtime_dont_use_autosuspend(dwc3->dev);
+
err = devm_request_threaded_irq(dev, irq, NULL, dwc3_imx8mp_interrupt,
IRQF_ONESHOT, dev_name(dev), dwc3_imx);
if (err) {
--
2.34.1
^ permalink raw reply related [flat|nested] 9+ messages in thread* Re: [PATCH v2 3/3] usb: dwc3: imx8mp: disable auto suspend for host role
2025-12-05 3:29 ` [PATCH v2 3/3] usb: dwc3: imx8mp: disable auto suspend for host role Xu Yang
@ 2025-12-16 23:26 ` Thinh Nguyen
2026-01-08 8:00 ` Xu Yang
0 siblings, 1 reply; 9+ messages in thread
From: Thinh Nguyen @ 2025-12-16 23:26 UTC (permalink / raw)
To: Xu Yang
Cc: Thinh Nguyen, gregkh@linuxfoundation.org, shawnguo@kernel.org,
s.hauer@pengutronix.de, kernel@pengutronix.de, festevam@gmail.com,
linux-usb@vger.kernel.org, linux-kernel@vger.kernel.org,
imx@lists.linux.dev, linux-arm-kernel@lists.infradead.org,
jun.li@nxp.com
On Fri, Dec 05, 2025, Xu Yang wrote:
> Do dwc3 core auto suspend enable for device and disable for host
> , this can make sure dwc3 core device auto suspend setting is
> correct all the time, the background of disable dwc3 core device
> auto suspend is to make its parent device suspend immediately
> (so wakeup enable can be enabled) after xhci-plat device suspended,
> for device mode, we keep the dwc3 core device auto suspend is to
> give some wait for gadget to be enumerated.
>
> Note: It's a temporary solution until we switch to using the new
> flatten model.
>
> Signed-off-by: Xu Yang <xu.yang_2@nxp.com>
>
> ---
> Changes in v2:
> - add a note suggested by Thinh
> ---
> drivers/usb/dwc3/dwc3-imx8mp.c | 31 +++++++++++++++++++++++++++++++
> 1 file changed, 31 insertions(+)
>
> diff --git a/drivers/usb/dwc3/dwc3-imx8mp.c b/drivers/usb/dwc3/dwc3-imx8mp.c
> index 8bece4baecbf..2e13ca588f42 100644
> --- a/drivers/usb/dwc3/dwc3-imx8mp.c
> +++ b/drivers/usb/dwc3/dwc3-imx8mp.c
> @@ -158,11 +158,31 @@ static irqreturn_t dwc3_imx8mp_interrupt(int irq, void *_dwc3_imx)
> return IRQ_HANDLED;
> }
>
> +static void dwc3_imx_pre_set_role(struct dwc3 *dwc, enum usb_role role)
> +{
> + if (role == USB_ROLE_HOST)
> + /*
> + * For xhci host, we need disable dwc core auto
> + * suspend, because during this auto suspend delay(5s),
> + * xhci host RUN_STOP is cleared and wakeup is not
> + * enabled, if device is inserted, xhci host can't
> + * response the connection.
> + */
> + pm_runtime_dont_use_autosuspend(dwc->dev);
As noted previously, don't we need to unwind this in dwc3_imx8mp_remove
if the current mode device?
> + else
> + pm_runtime_use_autosuspend(dwc->dev);
> +}
> +
> +struct dwc3_glue_ops dwc3_imx_glue_ops = {
> + .pre_set_role = dwc3_imx_pre_set_role,
> +};
> +
> static int dwc3_imx8mp_probe(struct platform_device *pdev)
> {
> struct device *dev = &pdev->dev;
> struct device_node *node = dev->of_node;
> struct dwc3_imx8mp *dwc3_imx;
> + struct dwc3 *dwc3;
> struct resource *res;
> int err, irq;
>
> @@ -240,6 +260,17 @@ static int dwc3_imx8mp_probe(struct platform_device *pdev)
> goto depopulate;
> }
>
> + dwc3 = platform_get_drvdata(dwc3_imx->dwc3_pdev);
> + if (!dwc3) {
> + err = dev_err_probe(dev, -EPROBE_DEFER, "failed to get dwc3 platform data\n");
> + goto depopulate;
> + }
> +
> + dwc3->glue_ops = &dwc3_imx_glue_ops;
> +
> + if (dwc3->dr_mode == USB_DR_MODE_HOST)
> + pm_runtime_dont_use_autosuspend(dwc3->dev);
> +
> err = devm_request_threaded_irq(dev, irq, NULL, dwc3_imx8mp_interrupt,
> IRQF_ONESHOT, dev_name(dev), dwc3_imx);
> if (err) {
> --
> 2.34.1
>
The question above is trivial. You can add this in v3:
Acked-by: Thinh Nguyen <Thinh.Nguyen@synopsys.com>
Thanks,
Thinh
^ permalink raw reply [flat|nested] 9+ messages in thread* Re: [PATCH v2 3/3] usb: dwc3: imx8mp: disable auto suspend for host role
2025-12-16 23:26 ` Thinh Nguyen
@ 2026-01-08 8:00 ` Xu Yang
2026-01-09 0:45 ` Thinh Nguyen
0 siblings, 1 reply; 9+ messages in thread
From: Xu Yang @ 2026-01-08 8:00 UTC (permalink / raw)
To: Thinh Nguyen
Cc: gregkh@linuxfoundation.org, shawnguo@kernel.org,
s.hauer@pengutronix.de, kernel@pengutronix.de, festevam@gmail.com,
linux-usb@vger.kernel.org, linux-kernel@vger.kernel.org,
imx@lists.linux.dev, linux-arm-kernel@lists.infradead.org,
jun.li@nxp.com
On Tue, Dec 16, 2025 at 11:26:40PM +0000, Thinh Nguyen wrote:
> On Fri, Dec 05, 2025, Xu Yang wrote:
> > Do dwc3 core auto suspend enable for device and disable for host
> > , this can make sure dwc3 core device auto suspend setting is
> > correct all the time, the background of disable dwc3 core device
> > auto suspend is to make its parent device suspend immediately
> > (so wakeup enable can be enabled) after xhci-plat device suspended,
> > for device mode, we keep the dwc3 core device auto suspend is to
> > give some wait for gadget to be enumerated.
> >
> > Note: It's a temporary solution until we switch to using the new
> > flatten model.
> >
> > Signed-off-by: Xu Yang <xu.yang_2@nxp.com>
> >
> > ---
> > Changes in v2:
> > - add a note suggested by Thinh
> > ---
> > drivers/usb/dwc3/dwc3-imx8mp.c | 31 +++++++++++++++++++++++++++++++
> > 1 file changed, 31 insertions(+)
> >
> > diff --git a/drivers/usb/dwc3/dwc3-imx8mp.c b/drivers/usb/dwc3/dwc3-imx8mp.c
> > index 8bece4baecbf..2e13ca588f42 100644
> > --- a/drivers/usb/dwc3/dwc3-imx8mp.c
> > +++ b/drivers/usb/dwc3/dwc3-imx8mp.c
> > @@ -158,11 +158,31 @@ static irqreturn_t dwc3_imx8mp_interrupt(int irq, void *_dwc3_imx)
> > return IRQ_HANDLED;
> > }
> >
> > +static void dwc3_imx_pre_set_role(struct dwc3 *dwc, enum usb_role role)
> > +{
> > + if (role == USB_ROLE_HOST)
> > + /*
> > + * For xhci host, we need disable dwc core auto
> > + * suspend, because during this auto suspend delay(5s),
> > + * xhci host RUN_STOP is cleared and wakeup is not
> > + * enabled, if device is inserted, xhci host can't
> > + * response the connection.
> > + */
> > + pm_runtime_dont_use_autosuspend(dwc->dev);
>
> As noted previously, don't we need to unwind this in dwc3_imx8mp_remove
> if the current mode device?
Thanks for the reminder. I check it, dwc3_core_remove() will call
pm_runtime_dont_use_autosuspend(). So it seems unnecessary to unwind it
again in dwc3_imx8mp_remove().
>
> > + else
> > + pm_runtime_use_autosuspend(dwc->dev);
> > +}
> > +
> > +struct dwc3_glue_ops dwc3_imx_glue_ops = {
> > + .pre_set_role = dwc3_imx_pre_set_role,
> > +};
> > +
> > static int dwc3_imx8mp_probe(struct platform_device *pdev)
> > {
> > struct device *dev = &pdev->dev;
> > struct device_node *node = dev->of_node;
> > struct dwc3_imx8mp *dwc3_imx;
> > + struct dwc3 *dwc3;
> > struct resource *res;
> > int err, irq;
> >
> > @@ -240,6 +260,17 @@ static int dwc3_imx8mp_probe(struct platform_device *pdev)
> > goto depopulate;
> > }
> >
> > + dwc3 = platform_get_drvdata(dwc3_imx->dwc3_pdev);
> > + if (!dwc3) {
> > + err = dev_err_probe(dev, -EPROBE_DEFER, "failed to get dwc3 platform data\n");
> > + goto depopulate;
> > + }
> > +
> > + dwc3->glue_ops = &dwc3_imx_glue_ops;
> > +
> > + if (dwc3->dr_mode == USB_DR_MODE_HOST)
> > + pm_runtime_dont_use_autosuspend(dwc3->dev);
> > +
> > err = devm_request_threaded_irq(dev, irq, NULL, dwc3_imx8mp_interrupt,
> > IRQF_ONESHOT, dev_name(dev), dwc3_imx);
> > if (err) {
> > --
> > 2.34.1
> >
>
> The question above is trivial. You can add this in v3:
>
> Acked-by: Thinh Nguyen <Thinh.Nguyen@synopsys.com>
OK.
Thanks,
Xu Yang
^ permalink raw reply [flat|nested] 9+ messages in thread* Re: [PATCH v2 3/3] usb: dwc3: imx8mp: disable auto suspend for host role
2026-01-08 8:00 ` Xu Yang
@ 2026-01-09 0:45 ` Thinh Nguyen
0 siblings, 0 replies; 9+ messages in thread
From: Thinh Nguyen @ 2026-01-09 0:45 UTC (permalink / raw)
To: Xu Yang
Cc: Thinh Nguyen, gregkh@linuxfoundation.org, shawnguo@kernel.org,
s.hauer@pengutronix.de, kernel@pengutronix.de, festevam@gmail.com,
linux-usb@vger.kernel.org, linux-kernel@vger.kernel.org,
imx@lists.linux.dev, linux-arm-kernel@lists.infradead.org,
jun.li@nxp.com
On Thu, Jan 08, 2026, Xu Yang wrote:
> On Tue, Dec 16, 2025 at 11:26:40PM +0000, Thinh Nguyen wrote:
> > On Fri, Dec 05, 2025, Xu Yang wrote:
> > > Do dwc3 core auto suspend enable for device and disable for host
> > > , this can make sure dwc3 core device auto suspend setting is
> > > correct all the time, the background of disable dwc3 core device
> > > auto suspend is to make its parent device suspend immediately
> > > (so wakeup enable can be enabled) after xhci-plat device suspended,
> > > for device mode, we keep the dwc3 core device auto suspend is to
> > > give some wait for gadget to be enumerated.
> > >
> > > Note: It's a temporary solution until we switch to using the new
> > > flatten model.
> > >
> > > Signed-off-by: Xu Yang <xu.yang_2@nxp.com>
> > >
> > > ---
> > > Changes in v2:
> > > - add a note suggested by Thinh
> > > ---
> > > drivers/usb/dwc3/dwc3-imx8mp.c | 31 +++++++++++++++++++++++++++++++
> > > 1 file changed, 31 insertions(+)
> > >
> > > diff --git a/drivers/usb/dwc3/dwc3-imx8mp.c b/drivers/usb/dwc3/dwc3-imx8mp.c
> > > index 8bece4baecbf..2e13ca588f42 100644
> > > --- a/drivers/usb/dwc3/dwc3-imx8mp.c
> > > +++ b/drivers/usb/dwc3/dwc3-imx8mp.c
> > > @@ -158,11 +158,31 @@ static irqreturn_t dwc3_imx8mp_interrupt(int irq, void *_dwc3_imx)
> > > return IRQ_HANDLED;
> > > }
> > >
> > > +static void dwc3_imx_pre_set_role(struct dwc3 *dwc, enum usb_role role)
> > > +{
> > > + if (role == USB_ROLE_HOST)
> > > + /*
> > > + * For xhci host, we need disable dwc core auto
> > > + * suspend, because during this auto suspend delay(5s),
> > > + * xhci host RUN_STOP is cleared and wakeup is not
> > > + * enabled, if device is inserted, xhci host can't
> > > + * response the connection.
> > > + */
> > > + pm_runtime_dont_use_autosuspend(dwc->dev);
> >
> > As noted previously, don't we need to unwind this in dwc3_imx8mp_remove
> > if the current mode device?
>
> Thanks for the reminder. I check it, dwc3_core_remove() will call
> pm_runtime_dont_use_autosuspend(). So it seems unnecessary to unwind it
> again in dwc3_imx8mp_remove().
>
Thanks for checking.
BR,
Thinh
^ permalink raw reply [flat|nested] 9+ messages in thread
* Re: [PATCH v2 1/3] usb: dwc3: drd: extend dwc3_pre_set_role() to extcon and otg usecase
2025-12-05 3:29 [PATCH v2 1/3] usb: dwc3: drd: extend dwc3_pre_set_role() to extcon and otg usecase Xu Yang
2025-12-05 3:29 ` [PATCH v2 2/3] usb: dwc3: imx8mp: rename dwc3 to dwc3_pdev in struct dwc3_imx8mp Xu Yang
2025-12-05 3:29 ` [PATCH v2 3/3] usb: dwc3: imx8mp: disable auto suspend for host role Xu Yang
@ 2025-12-16 23:18 ` Thinh Nguyen
2 siblings, 0 replies; 9+ messages in thread
From: Thinh Nguyen @ 2025-12-16 23:18 UTC (permalink / raw)
To: Xu Yang
Cc: Thinh Nguyen, gregkh@linuxfoundation.org, shawnguo@kernel.org,
s.hauer@pengutronix.de, kernel@pengutronix.de, festevam@gmail.com,
linux-usb@vger.kernel.org, linux-kernel@vger.kernel.org,
imx@lists.linux.dev, linux-arm-kernel@lists.infradead.org,
jun.li@nxp.com
On Fri, Dec 05, 2025, Xu Yang wrote:
> Call dwc3_pre_set_role() to support both extcon and otg usecase, so that
> the glue driver can do proper action in case of role changes.
>
> Reviewed-by: Frank Li <Frank.Li@nxp.com>
> Acked-by: Thinh Nguyen <Thinh.Nguyen@synopsys.com>
> Signed-off-by: Xu Yang <xu.yang_2@nxp.com>
>
> ---
> Changes in v2:
> - improve commit message
> - add Rb and Ab tag
> ---
> drivers/usb/dwc3/drd.c | 10 +++++++---
> 1 file changed, 7 insertions(+), 3 deletions(-)
>
> diff --git a/drivers/usb/dwc3/drd.c b/drivers/usb/dwc3/drd.c
> index 589bbeb27454..031cfd12300a 100644
> --- a/drivers/usb/dwc3/drd.c
> +++ b/drivers/usb/dwc3/drd.c
> @@ -381,6 +381,7 @@ void dwc3_otg_update(struct dwc3 *dwc, bool ignore_idstatus)
> dwc3_otgregs_init(dwc);
> dwc3_otg_host_init(dwc);
> spin_unlock_irqrestore(&dwc->lock, flags);
> + dwc3_pre_set_role(dwc, USB_ROLE_HOST);
> ret = dwc3_host_init(dwc);
> if (ret) {
> dev_err(dwc->dev, "failed to initialize host\n");
> @@ -406,6 +407,7 @@ void dwc3_otg_update(struct dwc3 *dwc, bool ignore_idstatus)
> otg_set_vbus(dwc->usb2_phy->otg, false);
> if (dwc->usb2_generic_phy[0])
> phy_set_mode(dwc->usb2_generic_phy[0], PHY_MODE_USB_DEVICE);
> + dwc3_pre_set_role(dwc, USB_ROLE_DEVICE);
> ret = dwc3_gadget_init(dwc);
> if (ret)
> dev_err(dwc->dev, "failed to initialize peripheral\n");
> @@ -433,10 +435,12 @@ static int dwc3_drd_notifier(struct notifier_block *nb,
> unsigned long event, void *ptr)
> {
> struct dwc3 *dwc = container_of(nb, struct dwc3, edev_nb);
> + u32 mode = event ? DWC3_GCTL_PRTCAP_HOST : DWC3_GCTL_PRTCAP_DEVICE;
> + enum usb_role role = mode == DWC3_GCTL_PRTCAP_HOST ?
> + USB_ROLE_HOST : USB_ROLE_DEVICE;
>
> - dwc3_set_mode(dwc, event ?
> - DWC3_GCTL_PRTCAP_HOST :
> - DWC3_GCTL_PRTCAP_DEVICE);
> + dwc3_pre_set_role(dwc, role);
> + dwc3_set_mode(dwc, mode);
>
> return NOTIFY_DONE;
> }
> --
> 2.34.1
>
This patch series should be v3.
BR,
Thinh
^ permalink raw reply [flat|nested] 9+ messages in thread