* [PATCH 0/4] usb: imx8mp: collect some improvement
@ 2024-07-12 15:40 Frank Li
2024-07-12 15:40 ` [PATCH 1/4] usb: host: xhci-plat: Parse xhci-missing_cas_quirk and apply quirk Frank Li
` (3 more replies)
0 siblings, 4 replies; 12+ messages in thread
From: Frank Li @ 2024-07-12 15:40 UTC (permalink / raw)
To: Mathias Nyman, Greg Kroah-Hartman, Thinh Nguyen, Shawn Guo,
Sascha Hauer, Pengutronix Kernel Team, Fabio Estevam
Cc: linux-usb, linux-kernel, imx, linux-arm-kernel, jun.li, Frank Li,
Peter Chen, Xu Yang
Apply two quirk for imx8mp dwc3 host controller:
usb: host: xhci-plat: Parse xhci-missing_cas_quirk and apply quirk
usb: dwc3: imx8mp: add 2 software managed quirk properties for host mode
Runtime pm and wakeup:
usb: dwc3: imx8mp: disable SS_CON and U3 wakeup for system sleep
dwc3: core: add a core init flag for device mode resume
Signed-off-by: Frank Li <Frank.Li@nxp.com>
---
Frank Li (2):
usb: host: xhci-plat: Parse xhci-missing_cas_quirk and apply quirk
usb: dwc3: imx8mp: add 2 software managed quirk properties for host mode
Li Jun (2):
usb: dwc3: core: add a core init flag for device mode resume
usb: dwc3: imx8mp: disable SS_CON and U3 wakeup for system sleep
drivers/usb/dwc3/core.c | 13 +++++++++++++
drivers/usb/dwc3/core.h | 1 +
drivers/usb/dwc3/dwc3-imx8mp.c | 33 +++++++++++++++++++++++++++------
drivers/usb/host/xhci-plat.c | 6 ++++++
4 files changed, 47 insertions(+), 6 deletions(-)
---
base-commit: e60284b63245b84c3ae352427ed5ff8b79266b91
change-id: 20240711-dwc-mp-d1564eec57b1
Best regards,
---
Frank Li <Frank.Li@nxp.com>
^ permalink raw reply [flat|nested] 12+ messages in thread
* [PATCH 1/4] usb: host: xhci-plat: Parse xhci-missing_cas_quirk and apply quirk
2024-07-12 15:40 [PATCH 0/4] usb: imx8mp: collect some improvement Frank Li
@ 2024-07-12 15:40 ` Frank Li
2024-07-12 15:40 ` [PATCH 2/4] usb: dwc3: imx8mp: add 2 software managed quirk properties for host mode Frank Li
` (2 subsequent siblings)
3 siblings, 0 replies; 12+ messages in thread
From: Frank Li @ 2024-07-12 15:40 UTC (permalink / raw)
To: Mathias Nyman, Greg Kroah-Hartman, Thinh Nguyen, Shawn Guo,
Sascha Hauer, Pengutronix Kernel Team, Fabio Estevam
Cc: linux-usb, linux-kernel, imx, linux-arm-kernel, jun.li, Frank Li
Parse software managed property 'xhci-skip-phy-init-quirk' and
'xhci-skip-phy-init-quirk' to apply related quirk. It allows usb glue layer
driver apply these quirk.
Signed-off-by: Frank Li <Frank.Li@nxp.com>
---
drivers/usb/host/xhci-plat.c | 6 ++++++
1 file changed, 6 insertions(+)
diff --git a/drivers/usb/host/xhci-plat.c b/drivers/usb/host/xhci-plat.c
index 31bdfa52eeb25..ecaa75718e592 100644
--- a/drivers/usb/host/xhci-plat.c
+++ b/drivers/usb/host/xhci-plat.c
@@ -259,6 +259,12 @@ int xhci_plat_probe(struct platform_device *pdev, struct device *sysdev, const s
if (device_property_read_bool(tmpdev, "write-64-hi-lo-quirk"))
xhci->quirks |= XHCI_WRITE_64_HI_LO;
+ if (device_property_read_bool(tmpdev, "xhci-missing-cas-quirk"))
+ xhci->quirks |= XHCI_MISSING_CAS;
+
+ if (device_property_read_bool(tmpdev, "xhci-skip-phy-init-quirk"))
+ xhci->quirks |= XHCI_SKIP_PHY_INIT;
+
device_property_read_u32(tmpdev, "imod-interval-ns",
&xhci->imod_interval);
}
--
2.34.1
^ permalink raw reply related [flat|nested] 12+ messages in thread
* [PATCH 2/4] usb: dwc3: imx8mp: add 2 software managed quirk properties for host mode
2024-07-12 15:40 [PATCH 0/4] usb: imx8mp: collect some improvement Frank Li
2024-07-12 15:40 ` [PATCH 1/4] usb: host: xhci-plat: Parse xhci-missing_cas_quirk and apply quirk Frank Li
@ 2024-07-12 15:40 ` Frank Li
2024-08-07 1:08 ` Thinh Nguyen
2024-07-12 15:40 ` [PATCH 3/4] usb: dwc3: core: add a core init flag for device mode resume Frank Li
2024-07-12 15:40 ` [PATCH 4/4] usb: dwc3: imx8mp: disable SS_CON and U3 wakeup for system sleep Frank Li
3 siblings, 1 reply; 12+ messages in thread
From: Frank Li @ 2024-07-12 15:40 UTC (permalink / raw)
To: Mathias Nyman, Greg Kroah-Hartman, Thinh Nguyen, Shawn Guo,
Sascha Hauer, Pengutronix Kernel Team, Fabio Estevam
Cc: linux-usb, linux-kernel, imx, linux-arm-kernel, jun.li, Frank Li
Add 2 software manage quirk properites (xhci-missing-cas-quirk and
xhci-skip-phy-init-quirk) for xhci host.
Signed-off-by: Frank Li <Frank.Li@nxp.com>
---
drivers/usb/dwc3/dwc3-imx8mp.c | 18 ++++++++++++++++++
1 file changed, 18 insertions(+)
diff --git a/drivers/usb/dwc3/dwc3-imx8mp.c b/drivers/usb/dwc3/dwc3-imx8mp.c
index 8ee4480685031..5794bb75f7604 100644
--- a/drivers/usb/dwc3/dwc3-imx8mp.c
+++ b/drivers/usb/dwc3/dwc3-imx8mp.c
@@ -144,6 +144,17 @@ static irqreturn_t dwc3_imx8mp_interrupt(int irq, void *_dwc3_imx)
return IRQ_HANDLED;
}
+static int dwc3_imx8mp_set_software_node(struct device *dev)
+{
+ struct property_entry props[3] = {};
+ int prop_idx = 0;
+
+ props[prop_idx++] = PROPERTY_ENTRY_BOOL("xhci-missing-cas-quirk");
+ props[prop_idx++] = PROPERTY_ENTRY_BOOL("xhci-skip-phy-init-quirk");
+
+ return device_create_managed_software_node(dev, props, NULL);
+}
+
static int dwc3_imx8mp_probe(struct platform_device *pdev)
{
struct device *dev = &pdev->dev;
@@ -226,6 +237,13 @@ static int dwc3_imx8mp_probe(struct platform_device *pdev)
goto disable_rpm;
}
+ err = dwc3_imx8mp_set_software_node(dev);
+ if (err) {
+ err = -ENODEV;
+ dev_err(dev, "failed to create software node\n");
+ goto disable_rpm;
+ }
+
err = of_platform_populate(node, NULL, NULL, dev);
if (err) {
dev_err(&pdev->dev, "failed to create dwc3 core\n");
--
2.34.1
^ permalink raw reply related [flat|nested] 12+ messages in thread
* [PATCH 3/4] usb: dwc3: core: add a core init flag for device mode resume
2024-07-12 15:40 [PATCH 0/4] usb: imx8mp: collect some improvement Frank Li
2024-07-12 15:40 ` [PATCH 1/4] usb: host: xhci-plat: Parse xhci-missing_cas_quirk and apply quirk Frank Li
2024-07-12 15:40 ` [PATCH 2/4] usb: dwc3: imx8mp: add 2 software managed quirk properties for host mode Frank Li
@ 2024-07-12 15:40 ` Frank Li
2024-08-07 1:13 ` Thinh Nguyen
2024-07-12 15:40 ` [PATCH 4/4] usb: dwc3: imx8mp: disable SS_CON and U3 wakeup for system sleep Frank Li
3 siblings, 1 reply; 12+ messages in thread
From: Frank Li @ 2024-07-12 15:40 UTC (permalink / raw)
To: Mathias Nyman, Greg Kroah-Hartman, Thinh Nguyen, Shawn Guo,
Sascha Hauer, Pengutronix Kernel Team, Fabio Estevam
Cc: linux-usb, linux-kernel, imx, linux-arm-kernel, jun.li, Frank Li,
Peter Chen
From: Li Jun <jun.li@nxp.com>
The runtime resume will happen before system resume if system wakeup by
device mode wakeup event(e.g, VBUS). Add a flag to avoid init twice.
Reviewed-by: Peter Chen <peter.chen@nxp.com>
Signed-off-by: Li Jun <jun.li@nxp.com>
Signed-off-by: Frank Li <Frank.Li@nxp.com>
---
drivers/usb/dwc3/core.c | 13 +++++++++++++
drivers/usb/dwc3/core.h | 1 +
2 files changed, 14 insertions(+)
diff --git a/drivers/usb/dwc3/core.c b/drivers/usb/dwc3/core.c
index 734de2a8bd212..d60917fad8c52 100644
--- a/drivers/usb/dwc3/core.c
+++ b/drivers/usb/dwc3/core.c
@@ -950,6 +950,8 @@ static void dwc3_core_exit(struct dwc3 *dwc)
dwc3_phy_exit(dwc);
dwc3_clk_disable(dwc);
reset_control_assert(dwc->reset);
+
+ dwc->core_inited = false;
}
static bool dwc3_core_is_valid(struct dwc3 *dwc)
@@ -1446,6 +1448,8 @@ static int dwc3_core_init(struct dwc3 *dwc)
dwc3_writel(dwc->regs, DWC3_LLUCTL, reg);
}
+ dwc->core_inited = true;
+
return 0;
err_power_off_phy:
@@ -2375,6 +2379,15 @@ static int dwc3_resume_common(struct dwc3 *dwc, pm_message_t msg)
switch (dwc->current_dr_role) {
case DWC3_GCTL_PRTCAP_DEVICE:
+ /*
+ * system resume may come after runtime resume
+ * e.g. rpm suspend -> pm suspend -> wakeup
+ * -> rpm resume -> system resume, so if already
+ * runtime resumed, system resume should skip it.
+ */
+ if (dwc->core_inited)
+ break;
+
ret = dwc3_core_init_for_resume(dwc);
if (ret)
return ret;
diff --git a/drivers/usb/dwc3/core.h b/drivers/usb/dwc3/core.h
index 1e561fd8b86e2..8a4bfd9a25b19 100644
--- a/drivers/usb/dwc3/core.h
+++ b/drivers/usb/dwc3/core.h
@@ -1195,6 +1195,7 @@ struct dwc3 {
struct clk *utmi_clk;
struct clk *pipe_clk;
+ bool core_inited;
struct reset_control *reset;
struct usb_phy *usb2_phy;
--
2.34.1
^ permalink raw reply related [flat|nested] 12+ messages in thread
* [PATCH 4/4] usb: dwc3: imx8mp: disable SS_CON and U3 wakeup for system sleep
2024-07-12 15:40 [PATCH 0/4] usb: imx8mp: collect some improvement Frank Li
` (2 preceding siblings ...)
2024-07-12 15:40 ` [PATCH 3/4] usb: dwc3: core: add a core init flag for device mode resume Frank Li
@ 2024-07-12 15:40 ` Frank Li
2024-08-07 1:20 ` Thinh Nguyen
3 siblings, 1 reply; 12+ messages in thread
From: Frank Li @ 2024-07-12 15:40 UTC (permalink / raw)
To: Mathias Nyman, Greg Kroah-Hartman, Thinh Nguyen, Shawn Guo,
Sascha Hauer, Pengutronix Kernel Team, Fabio Estevam
Cc: linux-usb, linux-kernel, imx, linux-arm-kernel, jun.li, Frank Li,
Xu Yang
From: Li Jun <jun.li@nxp.com>
SS_CON and U3 wakeup need 'ref_clk' on. iMX8MP turn off it while system
sleep, So disable these wakeup source and only enable DP/DM wakeup source
for host mode.
Reviewed-by: Xu Yang <xu.yang_2@nxp.com>
Signed-off-by: Li Jun <jun.li@nxp.com>
Signed-off-by: Frank Li <Frank.Li@nxp.com>
---
drivers/usb/dwc3/dwc3-imx8mp.c | 15 +++++++++------
1 file changed, 9 insertions(+), 6 deletions(-)
diff --git a/drivers/usb/dwc3/dwc3-imx8mp.c b/drivers/usb/dwc3/dwc3-imx8mp.c
index 5794bb75f7604..9f8c34d09a8e9 100644
--- a/drivers/usb/dwc3/dwc3-imx8mp.c
+++ b/drivers/usb/dwc3/dwc3-imx8mp.c
@@ -96,7 +96,8 @@ static void imx8mp_configure_glue(struct dwc3_imx8mp *dwc3_imx)
writel(value, dwc3_imx->glue_base + USB_CTRL1);
}
-static void dwc3_imx8mp_wakeup_enable(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);
u32 val;
@@ -106,12 +107,14 @@ static void dwc3_imx8mp_wakeup_enable(struct dwc3_imx8mp *dwc3_imx)
val = readl(dwc3_imx->hsio_blk_base + USB_WAKEUP_CTRL);
- if ((dwc3->current_dr_role == DWC3_GCTL_PRTCAP_HOST) && dwc3->xhci)
- val |= USB_WAKEUP_EN | USB_WAKEUP_SS_CONN |
- USB_WAKEUP_U3_EN | USB_WAKEUP_DPDM_EN;
- else if (dwc3->current_dr_role == DWC3_GCTL_PRTCAP_DEVICE)
+ if ((dwc3->current_dr_role == DWC3_GCTL_PRTCAP_HOST) && dwc3->xhci) {
+ val |= USB_WAKEUP_EN | USB_WAKEUP_DPDM_EN;
+ if (PMSG_IS_AUTO(msg))
+ val |= USB_WAKEUP_SS_CONN | USB_WAKEUP_U3_EN;
+ } else {
val |= USB_WAKEUP_EN | USB_WAKEUP_VBUS_EN |
USB_WAKEUP_VBUS_SRC_SESS_VAL;
+ }
writel(val, dwc3_imx->hsio_blk_base + USB_WAKEUP_CTRL);
}
@@ -308,7 +311,7 @@ static int __maybe_unused dwc3_imx8mp_suspend(struct dwc3_imx8mp *dwc3_imx,
/* Wakeup enable */
if (PMSG_IS_AUTO(msg) || device_may_wakeup(dwc3_imx->dev))
- dwc3_imx8mp_wakeup_enable(dwc3_imx);
+ dwc3_imx8mp_wakeup_enable(dwc3_imx, msg);
dwc3_imx->pm_suspended = true;
--
2.34.1
^ permalink raw reply related [flat|nested] 12+ messages in thread
* Re: [PATCH 2/4] usb: dwc3: imx8mp: add 2 software managed quirk properties for host mode
2024-07-12 15:40 ` [PATCH 2/4] usb: dwc3: imx8mp: add 2 software managed quirk properties for host mode Frank Li
@ 2024-08-07 1:08 ` Thinh Nguyen
0 siblings, 0 replies; 12+ messages in thread
From: Thinh Nguyen @ 2024-08-07 1:08 UTC (permalink / raw)
To: Frank Li
Cc: Mathias Nyman, Greg Kroah-Hartman, Thinh Nguyen, Shawn Guo,
Sascha Hauer, Pengutronix Kernel Team, Fabio Estevam,
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, Jul 12, 2024, Frank Li wrote:
> Add 2 software manage quirk properites (xhci-missing-cas-quirk and
> xhci-skip-phy-init-quirk) for xhci host.
>
> Signed-off-by: Frank Li <Frank.Li@nxp.com>
> ---
> drivers/usb/dwc3/dwc3-imx8mp.c | 18 ++++++++++++++++++
> 1 file changed, 18 insertions(+)
>
> diff --git a/drivers/usb/dwc3/dwc3-imx8mp.c b/drivers/usb/dwc3/dwc3-imx8mp.c
> index 8ee4480685031..5794bb75f7604 100644
> --- a/drivers/usb/dwc3/dwc3-imx8mp.c
> +++ b/drivers/usb/dwc3/dwc3-imx8mp.c
> @@ -144,6 +144,17 @@ static irqreturn_t dwc3_imx8mp_interrupt(int irq, void *_dwc3_imx)
> return IRQ_HANDLED;
> }
>
> +static int dwc3_imx8mp_set_software_node(struct device *dev)
> +{
> + struct property_entry props[3] = {};
To be safe, use props[3] = { 0 } initialization sematic so to keep
compatibility.
> + int prop_idx = 0;
> +\x1a
> + props[prop_idx++] = PROPERTY_ENTRY_BOOL("xhci-missing-cas-quirk");
> + props[prop_idx++] = PROPERTY_ENTRY_BOOL("xhci-skip-phy-init-quirk");
> +
> + return device_create_managed_software_node(dev, props, NULL);
> +}
> +
> static int dwc3_imx8mp_probe(struct platform_device *pdev)
> {
> struct device *dev = &pdev->dev;
> @@ -226,6 +237,13 @@ static int dwc3_imx8mp_probe(struct platform_device *pdev)
> goto disable_rpm;
> }
>
> + err = dwc3_imx8mp_set_software_node(dev);
> + if (err) {
> + err = -ENODEV;
> + dev_err(dev, "failed to create software node\n");
> + goto disable_rpm;
> + }
> +
> err = of_platform_populate(node, NULL, NULL, dev);
> if (err) {
> dev_err(&pdev->dev, "failed to create dwc3 core\n");
>
> --
> 2.34.1
>
The rest looks fine to me.
BR,
Thinh
^ permalink raw reply [flat|nested] 12+ messages in thread
* Re: [PATCH 3/4] usb: dwc3: core: add a core init flag for device mode resume
2024-07-12 15:40 ` [PATCH 3/4] usb: dwc3: core: add a core init flag for device mode resume Frank Li
@ 2024-08-07 1:13 ` Thinh Nguyen
2024-08-09 16:25 ` Frank Li
0 siblings, 1 reply; 12+ messages in thread
From: Thinh Nguyen @ 2024-08-07 1:13 UTC (permalink / raw)
To: Frank Li
Cc: Mathias Nyman, Greg Kroah-Hartman, Thinh Nguyen, Shawn Guo,
Sascha Hauer, Pengutronix Kernel Team, Fabio Estevam,
linux-usb@vger.kernel.org, linux-kernel@vger.kernel.org,
imx@lists.linux.dev, linux-arm-kernel@lists.infradead.org,
jun.li@nxp.com, Peter Chen
On Fri, Jul 12, 2024, Frank Li wrote:
> From: Li Jun <jun.li@nxp.com>
>
> The runtime resume will happen before system resume if system wakeup by
> device mode wakeup event(e.g, VBUS). Add a flag to avoid init twice.
What's the consequence of going through the resuming sequence twice?
Will this cause any functional issue?
Thanks,
Thinh
>
> Reviewed-by: Peter Chen <peter.chen@nxp.com>
> Signed-off-by: Li Jun <jun.li@nxp.com>
> Signed-off-by: Frank Li <Frank.Li@nxp.com>
> ---
> drivers/usb/dwc3/core.c | 13 +++++++++++++
> drivers/usb/dwc3/core.h | 1 +
> 2 files changed, 14 insertions(+)
>
> diff --git a/drivers/usb/dwc3/core.c b/drivers/usb/dwc3/core.c
> index 734de2a8bd212..d60917fad8c52 100644
> --- a/drivers/usb/dwc3/core.c
> +++ b/drivers/usb/dwc3/core.c
> @@ -950,6 +950,8 @@ static void dwc3_core_exit(struct dwc3 *dwc)
> dwc3_phy_exit(dwc);
> dwc3_clk_disable(dwc);
> reset_control_assert(dwc->reset);
> +
> + dwc->core_inited = false;
> }
>
> static bool dwc3_core_is_valid(struct dwc3 *dwc)
> @@ -1446,6 +1448,8 @@ static int dwc3_core_init(struct dwc3 *dwc)
> dwc3_writel(dwc->regs, DWC3_LLUCTL, reg);
> }
>
> + dwc->core_inited = true;
> +
> return 0;
>
> err_power_off_phy:
> @@ -2375,6 +2379,15 @@ static int dwc3_resume_common(struct dwc3 *dwc, pm_message_t msg)
>
> switch (dwc->current_dr_role) {
> case DWC3_GCTL_PRTCAP_DEVICE:
> + /*
> + * system resume may come after runtime resume
> + * e.g. rpm suspend -> pm suspend -> wakeup
> + * -> rpm resume -> system resume, so if already
> + * runtime resumed, system resume should skip it.
> + */
> + if (dwc->core_inited)
> + break;
> +
> ret = dwc3_core_init_for_resume(dwc);
> if (ret)
> return ret;
> diff --git a/drivers/usb/dwc3/core.h b/drivers/usb/dwc3/core.h
> index 1e561fd8b86e2..8a4bfd9a25b19 100644
> --- a/drivers/usb/dwc3/core.h
> +++ b/drivers/usb/dwc3/core.h
> @@ -1195,6 +1195,7 @@ struct dwc3 {
> struct clk *utmi_clk;
> struct clk *pipe_clk;
>
> + bool core_inited;
> struct reset_control *reset;
>
> struct usb_phy *usb2_phy;
>
> --
> 2.34.1
>
^ permalink raw reply [flat|nested] 12+ messages in thread
* Re: [PATCH 4/4] usb: dwc3: imx8mp: disable SS_CON and U3 wakeup for system sleep
2024-07-12 15:40 ` [PATCH 4/4] usb: dwc3: imx8mp: disable SS_CON and U3 wakeup for system sleep Frank Li
@ 2024-08-07 1:20 ` Thinh Nguyen
0 siblings, 0 replies; 12+ messages in thread
From: Thinh Nguyen @ 2024-08-07 1:20 UTC (permalink / raw)
To: Frank Li
Cc: Mathias Nyman, Greg Kroah-Hartman, Thinh Nguyen, Shawn Guo,
Sascha Hauer, Pengutronix Kernel Team, Fabio Estevam,
linux-usb@vger.kernel.org, linux-kernel@vger.kernel.org,
imx@lists.linux.dev, linux-arm-kernel@lists.infradead.org,
jun.li@nxp.com, Xu Yang
On Fri, Jul 12, 2024, Frank Li wrote:
> From: Li Jun <jun.li@nxp.com>
>
> SS_CON and U3 wakeup need 'ref_clk' on. iMX8MP turn off it while system
> sleep, So disable these wakeup source and only enable DP/DM wakeup source
> for host mode.
>
> Reviewed-by: Xu Yang <xu.yang_2@nxp.com>
> Signed-off-by: Li Jun <jun.li@nxp.com>
> Signed-off-by: Frank Li <Frank.Li@nxp.com>
> ---
> drivers/usb/dwc3/dwc3-imx8mp.c | 15 +++++++++------
> 1 file changed, 9 insertions(+), 6 deletions(-)
>
> diff --git a/drivers/usb/dwc3/dwc3-imx8mp.c b/drivers/usb/dwc3/dwc3-imx8mp.c
> index 5794bb75f7604..9f8c34d09a8e9 100644
> --- a/drivers/usb/dwc3/dwc3-imx8mp.c
> +++ b/drivers/usb/dwc3/dwc3-imx8mp.c
> @@ -96,7 +96,8 @@ static void imx8mp_configure_glue(struct dwc3_imx8mp *dwc3_imx)
> writel(value, dwc3_imx->glue_base + USB_CTRL1);
> }
>
> -static void dwc3_imx8mp_wakeup_enable(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);
> u32 val;
> @@ -106,12 +107,14 @@ static void dwc3_imx8mp_wakeup_enable(struct dwc3_imx8mp *dwc3_imx)
>
> val = readl(dwc3_imx->hsio_blk_base + USB_WAKEUP_CTRL);
>
> - if ((dwc3->current_dr_role == DWC3_GCTL_PRTCAP_HOST) && dwc3->xhci)
> - val |= USB_WAKEUP_EN | USB_WAKEUP_SS_CONN |
> - USB_WAKEUP_U3_EN | USB_WAKEUP_DPDM_EN;
> - else if (dwc3->current_dr_role == DWC3_GCTL_PRTCAP_DEVICE)
> + if ((dwc3->current_dr_role == DWC3_GCTL_PRTCAP_HOST) && dwc3->xhci) {
> + val |= USB_WAKEUP_EN | USB_WAKEUP_DPDM_EN;
> + if (PMSG_IS_AUTO(msg))
> + val |= USB_WAKEUP_SS_CONN | USB_WAKEUP_U3_EN;
> + } else {
> val |= USB_WAKEUP_EN | USB_WAKEUP_VBUS_EN |
> USB_WAKEUP_VBUS_SRC_SESS_VAL;
> + }
>
> writel(val, dwc3_imx->hsio_blk_base + USB_WAKEUP_CTRL);
> }
> @@ -308,7 +311,7 @@ static int __maybe_unused dwc3_imx8mp_suspend(struct dwc3_imx8mp *dwc3_imx,
>
> /* Wakeup enable */
> if (PMSG_IS_AUTO(msg) || device_may_wakeup(dwc3_imx->dev))
> - dwc3_imx8mp_wakeup_enable(dwc3_imx);
> + dwc3_imx8mp_wakeup_enable(dwc3_imx, msg);
>
> dwc3_imx->pm_suspended = true;
>
>
> --
> 2.34.1
>
Acked-by: Thinh Nguyen <Thinh.Nguyen@synopsys.com>
Thanks,
Thinh
^ permalink raw reply [flat|nested] 12+ messages in thread
* Re: [PATCH 3/4] usb: dwc3: core: add a core init flag for device mode resume
2024-08-07 1:13 ` Thinh Nguyen
@ 2024-08-09 16:25 ` Frank Li
2024-08-09 23:18 ` Thinh Nguyen
0 siblings, 1 reply; 12+ messages in thread
From: Frank Li @ 2024-08-09 16:25 UTC (permalink / raw)
To: Thinh Nguyen
Cc: Mathias Nyman, Greg Kroah-Hartman, Shawn Guo, Sascha Hauer,
Pengutronix Kernel Team, Fabio Estevam, linux-usb@vger.kernel.org,
linux-kernel@vger.kernel.org, imx@lists.linux.dev,
linux-arm-kernel@lists.infradead.org, jun.li@nxp.com, Peter Chen
On Wed, Aug 07, 2024 at 01:13:52AM +0000, Thinh Nguyen wrote:
> On Fri, Jul 12, 2024, Frank Li wrote:
> > From: Li Jun <jun.li@nxp.com>
> >
> > The runtime resume will happen before system resume if system wakeup by
> > device mode wakeup event(e.g, VBUS). Add a flag to avoid init twice.
>
> What's the consequence of going through the resuming sequence twice?
> Will this cause any functional issue?
static int dwc3_core_init_for_resume(struct dwc3 *dwc)
{
...
ret = dwc3_clk_enable(dwc);
if (ret)
goto assert_reset;
...
}
clk will be enabled twice, the reference count in clk will be wrong because
clk_disable() only once at suspend.
So clk will be always ON at next suspend.
Frank Li
>
> Thanks,
> Thinh
>
> >
> > Reviewed-by: Peter Chen <peter.chen@nxp.com>
> > Signed-off-by: Li Jun <jun.li@nxp.com>
> > Signed-off-by: Frank Li <Frank.Li@nxp.com>
> > ---
> > drivers/usb/dwc3/core.c | 13 +++++++++++++
> > drivers/usb/dwc3/core.h | 1 +
> > 2 files changed, 14 insertions(+)
> >
> > diff --git a/drivers/usb/dwc3/core.c b/drivers/usb/dwc3/core.c
> > index 734de2a8bd212..d60917fad8c52 100644
> > --- a/drivers/usb/dwc3/core.c
> > +++ b/drivers/usb/dwc3/core.c
> > @@ -950,6 +950,8 @@ static void dwc3_core_exit(struct dwc3 *dwc)
> > dwc3_phy_exit(dwc);
> > dwc3_clk_disable(dwc);
> > reset_control_assert(dwc->reset);
> > +
> > + dwc->core_inited = false;
> > }
> >
> > static bool dwc3_core_is_valid(struct dwc3 *dwc)
> > @@ -1446,6 +1448,8 @@ static int dwc3_core_init(struct dwc3 *dwc)
> > dwc3_writel(dwc->regs, DWC3_LLUCTL, reg);
> > }
> >
> > + dwc->core_inited = true;
> > +
> > return 0;
> >
> > err_power_off_phy:
> > @@ -2375,6 +2379,15 @@ static int dwc3_resume_common(struct dwc3 *dwc, pm_message_t msg)
> >
> > switch (dwc->current_dr_role) {
> > case DWC3_GCTL_PRTCAP_DEVICE:
> > + /*
> > + * system resume may come after runtime resume
> > + * e.g. rpm suspend -> pm suspend -> wakeup
> > + * -> rpm resume -> system resume, so if already
> > + * runtime resumed, system resume should skip it.
> > + */
> > + if (dwc->core_inited)
> > + break;
> > +
> > ret = dwc3_core_init_for_resume(dwc);
> > if (ret)
> > return ret;
> > diff --git a/drivers/usb/dwc3/core.h b/drivers/usb/dwc3/core.h
> > index 1e561fd8b86e2..8a4bfd9a25b19 100644
> > --- a/drivers/usb/dwc3/core.h
> > +++ b/drivers/usb/dwc3/core.h
> > @@ -1195,6 +1195,7 @@ struct dwc3 {
> > struct clk *utmi_clk;
> > struct clk *pipe_clk;
> >
> > + bool core_inited;
> > struct reset_control *reset;
> >
> > struct usb_phy *usb2_phy;
> >
> > --
> > 2.34.1
> >
^ permalink raw reply [flat|nested] 12+ messages in thread
* Re: [PATCH 3/4] usb: dwc3: core: add a core init flag for device mode resume
2024-08-09 16:25 ` Frank Li
@ 2024-08-09 23:18 ` Thinh Nguyen
2024-08-13 16:57 ` Frank Li
0 siblings, 1 reply; 12+ messages in thread
From: Thinh Nguyen @ 2024-08-09 23:18 UTC (permalink / raw)
To: Frank Li
Cc: Thinh Nguyen, Mathias Nyman, Greg Kroah-Hartman, Shawn Guo,
Sascha Hauer, Pengutronix Kernel Team, Fabio Estevam,
linux-usb@vger.kernel.org, linux-kernel@vger.kernel.org,
imx@lists.linux.dev, linux-arm-kernel@lists.infradead.org,
jun.li@nxp.com, Peter Chen
On Fri, Aug 09, 2024, Frank Li wrote:
> On Wed, Aug 07, 2024 at 01:13:52AM +0000, Thinh Nguyen wrote:
> > On Fri, Jul 12, 2024, Frank Li wrote:
> > > From: Li Jun <jun.li@nxp.com>
> > >
> > > The runtime resume will happen before system resume if system wakeup by
> > > device mode wakeup event(e.g, VBUS). Add a flag to avoid init twice.
> >
> > What's the consequence of going through the resuming sequence twice?
> > Will this cause any functional issue?
>
> static int dwc3_core_init_for_resume(struct dwc3 *dwc)
> {
>
> ...
> ret = dwc3_clk_enable(dwc);
> if (ret)
> goto assert_reset;
>
> ...
> }
>
> clk will be enabled twice, the reference count in clk will be wrong because
> clk_disable() only once at suspend.
Please capture these info in the commit message.
>
> So clk will be always ON at next suspend.
>
> Frank Li
>
dwc3_clk_enable() happens in probe() and dwc3_core_init_for_resume(),
but you're checking dwc->core_inited in dwc3_core_init(). Why?
If the issue is only related to clk_enable(), perhaps just check that?
(minor nit: rename core_inited to core_initialized if you plan to do
that)
Thanks,
Thinh
> > >
> > > Reviewed-by: Peter Chen <peter.chen@nxp.com>
> > > Signed-off-by: Li Jun <jun.li@nxp.com>
> > > Signed-off-by: Frank Li <Frank.Li@nxp.com>
> > > ---
> > > drivers/usb/dwc3/core.c | 13 +++++++++++++
> > > drivers/usb/dwc3/core.h | 1 +
> > > 2 files changed, 14 insertions(+)
> > >
> > > diff --git a/drivers/usb/dwc3/core.c b/drivers/usb/dwc3/core.c
> > > index 734de2a8bd212..d60917fad8c52 100644
> > > --- a/drivers/usb/dwc3/core.c
> > > +++ b/drivers/usb/dwc3/core.c
> > > @@ -950,6 +950,8 @@ static void dwc3_core_exit(struct dwc3 *dwc)
> > > dwc3_phy_exit(dwc);
> > > dwc3_clk_disable(dwc);
> > > reset_control_assert(dwc->reset);
> > > +
> > > + dwc->core_inited = false;
> > > }
> > >
> > > static bool dwc3_core_is_valid(struct dwc3 *dwc)
> > > @@ -1446,6 +1448,8 @@ static int dwc3_core_init(struct dwc3 *dwc)
> > > dwc3_writel(dwc->regs, DWC3_LLUCTL, reg);
> > > }
> > >
> > > + dwc->core_inited = true;
> > > +
> > > return 0;
> > >
> > > err_power_off_phy:
> > > @@ -2375,6 +2379,15 @@ static int dwc3_resume_common(struct dwc3 *dwc, pm_message_t msg)
> > >
> > > switch (dwc->current_dr_role) {
> > > case DWC3_GCTL_PRTCAP_DEVICE:
> > > + /*
> > > + * system resume may come after runtime resume
> > > + * e.g. rpm suspend -> pm suspend -> wakeup
> > > + * -> rpm resume -> system resume, so if already
> > > + * runtime resumed, system resume should skip it.
> > > + */
> > > + if (dwc->core_inited)
> > > + break;
> > > +
> > > ret = dwc3_core_init_for_resume(dwc);
> > > if (ret)
> > > return ret;
> > > diff --git a/drivers/usb/dwc3/core.h b/drivers/usb/dwc3/core.h
> > > index 1e561fd8b86e2..8a4bfd9a25b19 100644
> > > --- a/drivers/usb/dwc3/core.h
> > > +++ b/drivers/usb/dwc3/core.h
> > > @@ -1195,6 +1195,7 @@ struct dwc3 {
> > > struct clk *utmi_clk;
> > > struct clk *pipe_clk;
> > >
> > > + bool core_inited;
> > > struct reset_control *reset;
> > >
> > > struct usb_phy *usb2_phy;
> > >
> > > --
> > > 2.34.1
> > >
^ permalink raw reply [flat|nested] 12+ messages in thread
* Re: [PATCH 3/4] usb: dwc3: core: add a core init flag for device mode resume
2024-08-09 23:18 ` Thinh Nguyen
@ 2024-08-13 16:57 ` Frank Li
2024-08-13 23:56 ` Thinh Nguyen
0 siblings, 1 reply; 12+ messages in thread
From: Frank Li @ 2024-08-13 16:57 UTC (permalink / raw)
To: Thinh Nguyen
Cc: Mathias Nyman, Greg Kroah-Hartman, Shawn Guo, Sascha Hauer,
Pengutronix Kernel Team, Fabio Estevam, linux-usb@vger.kernel.org,
linux-kernel@vger.kernel.org, imx@lists.linux.dev,
linux-arm-kernel@lists.infradead.org, jun.li@nxp.com, Peter Chen
On Fri, Aug 09, 2024 at 11:18:53PM +0000, Thinh Nguyen wrote:
> On Fri, Aug 09, 2024, Frank Li wrote:
> > On Wed, Aug 07, 2024 at 01:13:52AM +0000, Thinh Nguyen wrote:
> > > On Fri, Jul 12, 2024, Frank Li wrote:
> > > > From: Li Jun <jun.li@nxp.com>
> > > >
> > > > The runtime resume will happen before system resume if system wakeup by
> > > > device mode wakeup event(e.g, VBUS). Add a flag to avoid init twice.
> > >
> > > What's the consequence of going through the resuming sequence twice?
> > > Will this cause any functional issue?
> >
> > static int dwc3_core_init_for_resume(struct dwc3 *dwc)
> > {
> >
> > ...
> > ret = dwc3_clk_enable(dwc);
> > if (ret)
> > goto assert_reset;
> >
> > ...
> > }
> >
> > clk will be enabled twice, the reference count in clk will be wrong because
> > clk_disable() only once at suspend.
>
> Please capture these info in the commit message.
>
> >
> > So clk will be always ON at next suspend.
> >
> > Frank Li
> >
>
> dwc3_clk_enable() happens in probe() and dwc3_core_init_for_resume(),
> but you're checking dwc->core_inited in dwc3_core_init(). Why?
I have not check dwc->core_inited in dwc3_core_init(). Just set init value
dwc->core_inited = true
Do you means dwc3_core_init() as dwc3_resume_common()?
>
> If the issue is only related to clk_enable(), perhaps just check that?
This should be major one. Any paired operator between suspend/resume should
have issue.
Frank
>
> (minor nit: rename core_inited to core_initialized if you plan to do
> that)
>
> Thanks,
> Thinh
>
> > > >
> > > > Reviewed-by: Peter Chen <peter.chen@nxp.com>
> > > > Signed-off-by: Li Jun <jun.li@nxp.com>
> > > > Signed-off-by: Frank Li <Frank.Li@nxp.com>
> > > > ---
> > > > drivers/usb/dwc3/core.c | 13 +++++++++++++
> > > > drivers/usb/dwc3/core.h | 1 +
> > > > 2 files changed, 14 insertions(+)
> > > >
> > > > diff --git a/drivers/usb/dwc3/core.c b/drivers/usb/dwc3/core.c
> > > > index 734de2a8bd212..d60917fad8c52 100644
> > > > --- a/drivers/usb/dwc3/core.c
> > > > +++ b/drivers/usb/dwc3/core.c
> > > > @@ -950,6 +950,8 @@ static void dwc3_core_exit(struct dwc3 *dwc)
> > > > dwc3_phy_exit(dwc);
> > > > dwc3_clk_disable(dwc);
> > > > reset_control_assert(dwc->reset);
> > > > +
> > > > + dwc->core_inited = false;
> > > > }
> > > >
> > > > static bool dwc3_core_is_valid(struct dwc3 *dwc)
> > > > @@ -1446,6 +1448,8 @@ static int dwc3_core_init(struct dwc3 *dwc)
> > > > dwc3_writel(dwc->regs, DWC3_LLUCTL, reg);
> > > > }
> > > >
> > > > + dwc->core_inited = true;
> > > > +
> > > > return 0;
> > > >
> > > > err_power_off_phy:
> > > > @@ -2375,6 +2379,15 @@ static int dwc3_resume_common(struct dwc3 *dwc, pm_message_t msg)
> > > >
> > > > switch (dwc->current_dr_role) {
> > > > case DWC3_GCTL_PRTCAP_DEVICE:
> > > > + /*
> > > > + * system resume may come after runtime resume
> > > > + * e.g. rpm suspend -> pm suspend -> wakeup
> > > > + * -> rpm resume -> system resume, so if already
> > > > + * runtime resumed, system resume should skip it.
> > > > + */
> > > > + if (dwc->core_inited)
> > > > + break;
> > > > +
> > > > ret = dwc3_core_init_for_resume(dwc);
> > > > if (ret)
> > > > return ret;
> > > > diff --git a/drivers/usb/dwc3/core.h b/drivers/usb/dwc3/core.h
> > > > index 1e561fd8b86e2..8a4bfd9a25b19 100644
> > > > --- a/drivers/usb/dwc3/core.h
> > > > +++ b/drivers/usb/dwc3/core.h
> > > > @@ -1195,6 +1195,7 @@ struct dwc3 {
> > > > struct clk *utmi_clk;
> > > > struct clk *pipe_clk;
> > > >
> > > > + bool core_inited;
> > > > struct reset_control *reset;
> > > >
> > > > struct usb_phy *usb2_phy;
> > > >
> > > > --
> > > > 2.34.1
> > > >
^ permalink raw reply [flat|nested] 12+ messages in thread
* Re: [PATCH 3/4] usb: dwc3: core: add a core init flag for device mode resume
2024-08-13 16:57 ` Frank Li
@ 2024-08-13 23:56 ` Thinh Nguyen
0 siblings, 0 replies; 12+ messages in thread
From: Thinh Nguyen @ 2024-08-13 23:56 UTC (permalink / raw)
To: Frank Li
Cc: Thinh Nguyen, Mathias Nyman, Greg Kroah-Hartman, Shawn Guo,
Sascha Hauer, Pengutronix Kernel Team, Fabio Estevam,
linux-usb@vger.kernel.org, linux-kernel@vger.kernel.org,
imx@lists.linux.dev, linux-arm-kernel@lists.infradead.org,
jun.li@nxp.com, Peter Chen
On Tue, Aug 13, 2024, Frank Li wrote:
> On Fri, Aug 09, 2024 at 11:18:53PM +0000, Thinh Nguyen wrote:
> > On Fri, Aug 09, 2024, Frank Li wrote:
> > > On Wed, Aug 07, 2024 at 01:13:52AM +0000, Thinh Nguyen wrote:
> > > > On Fri, Jul 12, 2024, Frank Li wrote:
> > > > > From: Li Jun <jun.li@nxp.com>
> > > > >
> > > > > The runtime resume will happen before system resume if system wakeup by
> > > > > device mode wakeup event(e.g, VBUS). Add a flag to avoid init twice.
> > > >
> > > > What's the consequence of going through the resuming sequence twice?
> > > > Will this cause any functional issue?
> > >
> > > static int dwc3_core_init_for_resume(struct dwc3 *dwc)
> > > {
> > >
> > > ...
> > > ret = dwc3_clk_enable(dwc);
> > > if (ret)
> > > goto assert_reset;
> > >
> > > ...
> > > }
> > >
> > > clk will be enabled twice, the reference count in clk will be wrong because
> > > clk_disable() only once at suspend.
> >
> > Please capture these info in the commit message.
> >
> > >
> > > So clk will be always ON at next suspend.
> > >
> > > Frank Li
> > >
> >
> > dwc3_clk_enable() happens in probe() and dwc3_core_init_for_resume(),
> > but you're checking dwc->core_inited in dwc3_core_init(). Why?
>
> I have not check dwc->core_inited in dwc3_core_init(). Just set init value
> dwc->core_inited = true
>
> Do you means dwc3_core_init() as dwc3_resume_common()?
>
You set the dwc->core_inited in dwc3_core_init(). However, you use this
flag to also check if dwc3_clk_enable() is done. dwc3_clk_enable() is
not done in dwc3_core_init().
> >
> > If the issue is only related to clk_enable(), perhaps just check that?
>
> This should be major one. Any paired operator between suspend/resume should
> have issue.
>
I don't know what else could be a problem in dwc3_core_init(). As far as
I know, it's only dwc3_clk_enable().
I questioned because of the mismatch use of the check, where the issue
you mentioned is outside of dwc3_core_init(). Perhaps the flag should
not be set there. If that's the case, rename the flag to match the check
condition (if necessary).
>
> >
> > (minor nit: rename core_inited to core_initialized if you plan to do
> > that)
> >
> > Thanks,
> > Thinh
> >
> > > > >
> > > > > Reviewed-by: Peter Chen <peter.chen@nxp.com>
> > > > > Signed-off-by: Li Jun <jun.li@nxp.com>
> > > > > Signed-off-by: Frank Li <Frank.Li@nxp.com>
> > > > > ---
> > > > > drivers/usb/dwc3/core.c | 13 +++++++++++++
> > > > > drivers/usb/dwc3/core.h | 1 +
> > > > > 2 files changed, 14 insertions(+)
> > > > >
> > > > > diff --git a/drivers/usb/dwc3/core.c b/drivers/usb/dwc3/core.c
> > > > > index 734de2a8bd212..d60917fad8c52 100644
> > > > > --- a/drivers/usb/dwc3/core.c
> > > > > +++ b/drivers/usb/dwc3/core.c
> > > > > @@ -950,6 +950,8 @@ static void dwc3_core_exit(struct dwc3 *dwc)
> > > > > dwc3_phy_exit(dwc);
> > > > > dwc3_clk_disable(dwc);
> > > > > reset_control_assert(dwc->reset);
> > > > > +
> > > > > + dwc->core_inited = false;
> > > > > }
> > > > >
> > > > > static bool dwc3_core_is_valid(struct dwc3 *dwc)
> > > > > @@ -1446,6 +1448,8 @@ static int dwc3_core_init(struct dwc3 *dwc)
> > > > > dwc3_writel(dwc->regs, DWC3_LLUCTL, reg);
> > > > > }
> > > > >
> > > > > + dwc->core_inited = true;
> > > > > +
> > > > > return 0;
> > > > >
> > > > > err_power_off_phy:
> > > > > @@ -2375,6 +2379,15 @@ static int dwc3_resume_common(struct dwc3 *dwc, pm_message_t msg)
> > > > >
> > > > > switch (dwc->current_dr_role) {
> > > > > case DWC3_GCTL_PRTCAP_DEVICE:
> > > > > + /*
> > > > > + * system resume may come after runtime resume
> > > > > + * e.g. rpm suspend -> pm suspend -> wakeup
> > > > > + * -> rpm resume -> system resume, so if already
> > > > > + * runtime resumed, system resume should skip it.
> > > > > + */
> > > > > + if (dwc->core_inited)
> > > > > + break;
> > > > > +
> > > > > ret = dwc3_core_init_for_resume(dwc);
> > > > > if (ret)
> > > > > return ret;
> > > > > diff --git a/drivers/usb/dwc3/core.h b/drivers/usb/dwc3/core.h
> > > > > index 1e561fd8b86e2..8a4bfd9a25b19 100644
> > > > > --- a/drivers/usb/dwc3/core.h
> > > > > +++ b/drivers/usb/dwc3/core.h
> > > > > @@ -1195,6 +1195,7 @@ struct dwc3 {
> > > > > struct clk *utmi_clk;
> > > > > struct clk *pipe_clk;
> > > > >
> > > > > + bool core_inited;
Document new member of the struct.
> > > > > struct reset_control *reset;
> > > > >
> > > > > struct usb_phy *usb2_phy;
> > > > >
> > > > > --
> > > > > 2.34.1
> > > > >
Thanks,
Thinh
^ permalink raw reply [flat|nested] 12+ messages in thread
end of thread, other threads:[~2024-08-13 23:57 UTC | newest]
Thread overview: 12+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2024-07-12 15:40 [PATCH 0/4] usb: imx8mp: collect some improvement Frank Li
2024-07-12 15:40 ` [PATCH 1/4] usb: host: xhci-plat: Parse xhci-missing_cas_quirk and apply quirk Frank Li
2024-07-12 15:40 ` [PATCH 2/4] usb: dwc3: imx8mp: add 2 software managed quirk properties for host mode Frank Li
2024-08-07 1:08 ` Thinh Nguyen
2024-07-12 15:40 ` [PATCH 3/4] usb: dwc3: core: add a core init flag for device mode resume Frank Li
2024-08-07 1:13 ` Thinh Nguyen
2024-08-09 16:25 ` Frank Li
2024-08-09 23:18 ` Thinh Nguyen
2024-08-13 16:57 ` Frank Li
2024-08-13 23:56 ` Thinh Nguyen
2024-07-12 15:40 ` [PATCH 4/4] usb: dwc3: imx8mp: disable SS_CON and U3 wakeup for system sleep Frank Li
2024-08-07 1:20 ` Thinh Nguyen
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).