* [PATCH v5 01/11] usb: dwc3: qcom: Distinguish PM and runtime suspend/resume paths
2026-11-23 10:47 [PATCH v5 00/11] usb: dwc3: qcom: Add firmware-managed resource support for SA8255P Faisal Hassan
@ 2026-11-23 10:47 ` Faisal Hassan
2026-11-26 7:40 ` Peter Chen
2026-11-23 10:47 ` [PATCH v5 02/11] usb: dwc3: qcom: Disarm wakeup IRQs on system suspend without wakeup Faisal Hassan
` (9 subsequent siblings)
10 siblings, 1 reply; 23+ messages in thread
From: Faisal Hassan @ 2026-11-23 10:47 UTC (permalink / raw)
To: Thinh.Nguyen, gregkh
Cc: linux-usb, linux-arm-msm, linux-kernel, devicetree,
krishna.kurapati, peter.chen, krzysztof.kozlowski, Faisal Hassan,
Sriram Dash
The dwc3_qcom_suspend() and dwc3_qcom_resume() functions
handle both system PM and runtime PM paths but cannot
differentiate between them, preventing distinct power
management strategies.
Refactor suspend/resume functions to accept pm_message_t
instead of boolean wakeup flags. Use PMSG_IS_AUTO()
to identify runtime PM (PMSG_AUTO_SUSPEND/RESUME) versus
system PM (PMSG_SUSPEND/RESUME) paths.
Preserve existing wakeup behavior: always enable wakeup
for runtime suspend, check device_may_wakeup() for system
suspend.
Follow dwc3/core.c pattern to enable future per-path
strategies like differentiated power states.
Co-developed-by: Sriram Dash <sriram.dash@oss.qualcomm.com>
Signed-off-by: Sriram Dash <sriram.dash@oss.qualcomm.com>
Signed-off-by: Faisal Hassan <faisal.hassan@oss.qualcomm.com>
Acked-by: Thinh Nguyen <Thinh.Nguyen@synopsys.com>
Reviewed-by: Krishna Kurapati <krishna.kurapati@oss.qualcomm.com>
---
drivers/usb/dwc3/dwc3-qcom.c | 25 +++++++++++++++++--------
1 file changed, 17 insertions(+), 8 deletions(-)
diff --git a/drivers/usb/dwc3/dwc3-qcom.c b/drivers/usb/dwc3/dwc3-qcom.c
index d44f093ac243..7a7225b900b3 100644
--- a/drivers/usb/dwc3/dwc3-qcom.c
+++ b/drivers/usb/dwc3/dwc3-qcom.c
@@ -335,8 +335,18 @@ static void dwc3_qcom_enable_interrupts(struct dwc3_qcom *qcom)
dwc3_qcom_enable_port_interrupts(&qcom->ports[i]);
}
-static int dwc3_qcom_suspend(struct dwc3_qcom *qcom, bool wakeup)
+/*
+ * For runtime PM, always enable wakeup.
+ * For system PM, check device wakeup capability.
+ */
+static bool dwc3_qcom_wakeup_enabled(struct dwc3_qcom *qcom, pm_message_t msg)
+{
+ return PMSG_IS_AUTO(msg) || device_may_wakeup(qcom->dev);
+}
+
+static int dwc3_qcom_suspend(struct dwc3_qcom *qcom, pm_message_t msg)
{
+ bool wakeup = dwc3_qcom_wakeup_enabled(qcom, msg);
u32 val;
int i, ret;
@@ -369,8 +379,9 @@ static int dwc3_qcom_suspend(struct dwc3_qcom *qcom, bool wakeup)
return 0;
}
-static int dwc3_qcom_resume(struct dwc3_qcom *qcom, bool wakeup)
+static int dwc3_qcom_resume(struct dwc3_qcom *qcom, pm_message_t msg)
{
+ bool wakeup = dwc3_qcom_wakeup_enabled(qcom, msg);
int ret;
int i;
@@ -750,14 +761,13 @@ static int dwc3_qcom_pm_suspend(struct device *dev)
{
struct dwc3 *dwc = dev_get_drvdata(dev);
struct dwc3_qcom *qcom = to_dwc3_qcom(dwc);
- bool wakeup = device_may_wakeup(dev);
int ret;
ret = dwc3_pm_suspend(&qcom->dwc);
if (ret)
return ret;
- ret = dwc3_qcom_suspend(qcom, wakeup);
+ ret = dwc3_qcom_suspend(qcom, PMSG_SUSPEND);
if (ret)
return ret;
@@ -770,10 +780,9 @@ static int dwc3_qcom_pm_resume(struct device *dev)
{
struct dwc3 *dwc = dev_get_drvdata(dev);
struct dwc3_qcom *qcom = to_dwc3_qcom(dwc);
- bool wakeup = device_may_wakeup(dev);
int ret;
- ret = dwc3_qcom_resume(qcom, wakeup);
+ ret = dwc3_qcom_resume(qcom, PMSG_RESUME);
if (ret)
return ret;
@@ -810,7 +819,7 @@ static int dwc3_qcom_runtime_suspend(struct device *dev)
if (ret)
return ret;
- return dwc3_qcom_suspend(qcom, true);
+ return dwc3_qcom_suspend(qcom, PMSG_AUTO_SUSPEND);
}
static int dwc3_qcom_runtime_resume(struct device *dev)
@@ -819,7 +828,7 @@ static int dwc3_qcom_runtime_resume(struct device *dev)
struct dwc3_qcom *qcom = to_dwc3_qcom(dwc);
int ret;
- ret = dwc3_qcom_resume(qcom, true);
+ ret = dwc3_qcom_resume(qcom, PMSG_AUTO_RESUME);
if (ret)
return ret;
--
2.34.1
^ permalink raw reply [flat|nested] 23+ messages in thread* Re: [PATCH v5 01/11] usb: dwc3: qcom: Distinguish PM and runtime suspend/resume paths
2026-11-23 10:47 ` [PATCH v5 01/11] usb: dwc3: qcom: Distinguish PM and runtime suspend/resume paths Faisal Hassan
@ 2026-11-26 7:40 ` Peter Chen
0 siblings, 0 replies; 23+ messages in thread
From: Peter Chen @ 2026-11-26 7:40 UTC (permalink / raw)
To: Faisal Hassan
Cc: Thinh.Nguyen, gregkh, linux-usb, linux-arm-msm, linux-kernel,
devicetree, krishna.kurapati, krzysztof.kozlowski, Sriram Dash
On 26-11-23 16:17:16, Faisal Hassan wrote:
> The dwc3_qcom_suspend() and dwc3_qcom_resume() functions
> handle both system PM and runtime PM paths but cannot
> differentiate between them, preventing distinct power
> management strategies.
>
> Refactor suspend/resume functions to accept pm_message_t
> instead of boolean wakeup flags. Use PMSG_IS_AUTO()
> to identify runtime PM (PMSG_AUTO_SUSPEND/RESUME) versus
> system PM (PMSG_SUSPEND/RESUME) paths.
>
> Preserve existing wakeup behavior: always enable wakeup
> for runtime suspend, check device_may_wakeup() for system
> suspend.
>
> Follow dwc3/core.c pattern to enable future per-path
> strategies like differentiated power states.
>
> Co-developed-by: Sriram Dash <sriram.dash@oss.qualcomm.com>
> Signed-off-by: Sriram Dash <sriram.dash@oss.qualcomm.com>
> Signed-off-by: Faisal Hassan <faisal.hassan@oss.qualcomm.com>
> Acked-by: Thinh Nguyen <Thinh.Nguyen@synopsys.com>
> Reviewed-by: Krishna Kurapati <krishna.kurapati@oss.qualcomm.com>
Reviewed-by: Peter Chen <peter.chen@oss.qualcomm.com>
Peter
> ---
> drivers/usb/dwc3/dwc3-qcom.c | 25 +++++++++++++++++--------
> 1 file changed, 17 insertions(+), 8 deletions(-)
>
> diff --git a/drivers/usb/dwc3/dwc3-qcom.c b/drivers/usb/dwc3/dwc3-qcom.c
> index d44f093ac243..7a7225b900b3 100644
> --- a/drivers/usb/dwc3/dwc3-qcom.c
> +++ b/drivers/usb/dwc3/dwc3-qcom.c
> @@ -335,8 +335,18 @@ static void dwc3_qcom_enable_interrupts(struct dwc3_qcom *qcom)
> dwc3_qcom_enable_port_interrupts(&qcom->ports[i]);
> }
>
> -static int dwc3_qcom_suspend(struct dwc3_qcom *qcom, bool wakeup)
> +/*
> + * For runtime PM, always enable wakeup.
> + * For system PM, check device wakeup capability.
> + */
> +static bool dwc3_qcom_wakeup_enabled(struct dwc3_qcom *qcom, pm_message_t msg)
> +{
> + return PMSG_IS_AUTO(msg) || device_may_wakeup(qcom->dev);
> +}
> +
> +static int dwc3_qcom_suspend(struct dwc3_qcom *qcom, pm_message_t msg)
> {
> + bool wakeup = dwc3_qcom_wakeup_enabled(qcom, msg);
> u32 val;
> int i, ret;
>
> @@ -369,8 +379,9 @@ static int dwc3_qcom_suspend(struct dwc3_qcom *qcom, bool wakeup)
> return 0;
> }
>
> -static int dwc3_qcom_resume(struct dwc3_qcom *qcom, bool wakeup)
> +static int dwc3_qcom_resume(struct dwc3_qcom *qcom, pm_message_t msg)
> {
> + bool wakeup = dwc3_qcom_wakeup_enabled(qcom, msg);
> int ret;
> int i;
>
> @@ -750,14 +761,13 @@ static int dwc3_qcom_pm_suspend(struct device *dev)
> {
> struct dwc3 *dwc = dev_get_drvdata(dev);
> struct dwc3_qcom *qcom = to_dwc3_qcom(dwc);
> - bool wakeup = device_may_wakeup(dev);
> int ret;
>
> ret = dwc3_pm_suspend(&qcom->dwc);
> if (ret)
> return ret;
>
> - ret = dwc3_qcom_suspend(qcom, wakeup);
> + ret = dwc3_qcom_suspend(qcom, PMSG_SUSPEND);
> if (ret)
> return ret;
>
> @@ -770,10 +780,9 @@ static int dwc3_qcom_pm_resume(struct device *dev)
> {
> struct dwc3 *dwc = dev_get_drvdata(dev);
> struct dwc3_qcom *qcom = to_dwc3_qcom(dwc);
> - bool wakeup = device_may_wakeup(dev);
> int ret;
>
> - ret = dwc3_qcom_resume(qcom, wakeup);
> + ret = dwc3_qcom_resume(qcom, PMSG_RESUME);
> if (ret)
> return ret;
>
> @@ -810,7 +819,7 @@ static int dwc3_qcom_runtime_suspend(struct device *dev)
> if (ret)
> return ret;
>
> - return dwc3_qcom_suspend(qcom, true);
> + return dwc3_qcom_suspend(qcom, PMSG_AUTO_SUSPEND);
> }
>
> static int dwc3_qcom_runtime_resume(struct device *dev)
> @@ -819,7 +828,7 @@ static int dwc3_qcom_runtime_resume(struct device *dev)
> struct dwc3_qcom *qcom = to_dwc3_qcom(dwc);
> int ret;
>
> - ret = dwc3_qcom_resume(qcom, true);
> + ret = dwc3_qcom_resume(qcom, PMSG_AUTO_RESUME);
> if (ret)
> return ret;
>
> --
> 2.34.1
>
--
Thanks,
Peter Chen
^ permalink raw reply [flat|nested] 23+ messages in thread
* [PATCH v5 02/11] usb: dwc3: qcom: Disarm wakeup IRQs on system suspend without wakeup
2026-11-23 10:47 [PATCH v5 00/11] usb: dwc3: qcom: Add firmware-managed resource support for SA8255P Faisal Hassan
2026-11-23 10:47 ` [PATCH v5 01/11] usb: dwc3: qcom: Distinguish PM and runtime suspend/resume paths Faisal Hassan
@ 2026-11-23 10:47 ` Faisal Hassan
2026-11-26 7:44 ` Peter Chen
2026-11-23 10:47 ` [PATCH v5 03/11] usb: dwc3: qcom: Keep wakeup IRQ enable/disable balanced on failed resume Faisal Hassan
` (8 subsequent siblings)
10 siblings, 1 reply; 23+ messages in thread
From: Faisal Hassan @ 2026-11-23 10:47 UTC (permalink / raw)
To: Thinh.Nguyen, gregkh
Cc: linux-usb, linux-arm-msm, linux-kernel, devicetree,
krishna.kurapati, peter.chen, krzysztof.kozlowski, Faisal Hassan
Runtime suspend always arms the wakeup interrupts in host mode, even if
the device is not wakeup capable. If the controller is still runtime
suspended when system suspend runs without wakeup enabled, the
interrupts stay armed as wakeup sources, so they can still wake the
system. System resume does not disarm them either, as it only does so
when wakeup is enabled, so they remain armed after resume and the next
runtime suspend arms them a second time.
Disarm them in system suspend when the controller is already runtime
suspended and wakeup is not enabled, so the state matches what a system
suspend without a preceding runtime suspend would have left.
Signed-off-by: Faisal Hassan <faisal.hassan@oss.qualcomm.com>
---
drivers/usb/dwc3/dwc3-qcom.c | 10 +++++++++-
1 file changed, 9 insertions(+), 1 deletion(-)
diff --git a/drivers/usb/dwc3/dwc3-qcom.c b/drivers/usb/dwc3/dwc3-qcom.c
index 7a7225b900b3..18db19cf2065 100644
--- a/drivers/usb/dwc3/dwc3-qcom.c
+++ b/drivers/usb/dwc3/dwc3-qcom.c
@@ -350,8 +350,16 @@ static int dwc3_qcom_suspend(struct dwc3_qcom *qcom, pm_message_t msg)
u32 val;
int i, ret;
- if (qcom->is_suspended)
+ if (qcom->is_suspended) {
+ /*
+ * Runtime suspend arms the wakeup interrupts in host mode
+ * regardless of the device wakeup setting. If system suspend
+ * runs without wakeup, disarm them here, as resume will not.
+ */
+ if (dwc3_qcom_is_host(qcom) && !wakeup)
+ dwc3_qcom_disable_interrupts(qcom);
return 0;
+ }
for (i = 0; i < qcom->num_ports; i++) {
val = readl(qcom->qscratch_base + pwr_evnt_irq_stat_reg[i]);
--
2.34.1
^ permalink raw reply [flat|nested] 23+ messages in thread* Re: [PATCH v5 02/11] usb: dwc3: qcom: Disarm wakeup IRQs on system suspend without wakeup
2026-11-23 10:47 ` [PATCH v5 02/11] usb: dwc3: qcom: Disarm wakeup IRQs on system suspend without wakeup Faisal Hassan
@ 2026-11-26 7:44 ` Peter Chen
0 siblings, 0 replies; 23+ messages in thread
From: Peter Chen @ 2026-11-26 7:44 UTC (permalink / raw)
To: Faisal Hassan
Cc: Thinh.Nguyen, gregkh, linux-usb, linux-arm-msm, linux-kernel,
devicetree, krishna.kurapati, krzysztof.kozlowski
On 26-11-23 16:17:17, Faisal Hassan wrote:
> Runtime suspend always arms the wakeup interrupts in host mode, even if
> the device is not wakeup capable. If the controller is still runtime
> suspended when system suspend runs without wakeup enabled, the
> interrupts stay armed as wakeup sources, so they can still wake the
> system. System resume does not disarm them either, as it only does so
> when wakeup is enabled, so they remain armed after resume and the next
> runtime suspend arms them a second time.
>
> Disarm them in system suspend when the controller is already runtime
> suspended and wakeup is not enabled, so the state matches what a system
> suspend without a preceding runtime suspend would have left.
>
> Signed-off-by: Faisal Hassan <faisal.hassan@oss.qualcomm.com>
Reviewed-by: Peter Chen <peter.chen@oss.qualcomm.com>
Peter
> ---
> drivers/usb/dwc3/dwc3-qcom.c | 10 +++++++++-
> 1 file changed, 9 insertions(+), 1 deletion(-)
>
> diff --git a/drivers/usb/dwc3/dwc3-qcom.c b/drivers/usb/dwc3/dwc3-qcom.c
> index 7a7225b900b3..18db19cf2065 100644
> --- a/drivers/usb/dwc3/dwc3-qcom.c
> +++ b/drivers/usb/dwc3/dwc3-qcom.c
> @@ -350,8 +350,16 @@ static int dwc3_qcom_suspend(struct dwc3_qcom *qcom, pm_message_t msg)
> u32 val;
> int i, ret;
>
> - if (qcom->is_suspended)
> + if (qcom->is_suspended) {
> + /*
> + * Runtime suspend arms the wakeup interrupts in host mode
> + * regardless of the device wakeup setting. If system suspend
> + * runs without wakeup, disarm them here, as resume will not.
> + */
> + if (dwc3_qcom_is_host(qcom) && !wakeup)
> + dwc3_qcom_disable_interrupts(qcom);
> return 0;
> + }
>
> for (i = 0; i < qcom->num_ports; i++) {
> val = readl(qcom->qscratch_base + pwr_evnt_irq_stat_reg[i]);
> --
> 2.34.1
>
--
Thanks,
Peter Chen
^ permalink raw reply [flat|nested] 23+ messages in thread
* [PATCH v5 03/11] usb: dwc3: qcom: Keep wakeup IRQ enable/disable balanced on failed resume
2026-11-23 10:47 [PATCH v5 00/11] usb: dwc3: qcom: Add firmware-managed resource support for SA8255P Faisal Hassan
2026-11-23 10:47 ` [PATCH v5 01/11] usb: dwc3: qcom: Distinguish PM and runtime suspend/resume paths Faisal Hassan
2026-11-23 10:47 ` [PATCH v5 02/11] usb: dwc3: qcom: Disarm wakeup IRQs on system suspend without wakeup Faisal Hassan
@ 2026-11-23 10:47 ` Faisal Hassan
2026-11-26 8:37 ` Peter Chen
2026-11-26 17:31 ` Krishna Kurapati
2026-11-23 10:47 ` [PATCH v5 04/11] dt-bindings: usb: Add qcom,sa8255p-dwc3 for firmware-managed resources Faisal Hassan
` (7 subsequent siblings)
10 siblings, 2 replies; 23+ messages in thread
From: Faisal Hassan @ 2026-11-23 10:47 UTC (permalink / raw)
To: Thinh.Nguyen, gregkh
Cc: linux-usb, linux-arm-msm, linux-kernel, devicetree,
krishna.kurapati, peter.chen, krzysztof.kozlowski, Faisal Hassan
dwc3_qcom_resume() disables the wakeup interrupts before enabling the
clocks. If clk_bulk_prepare_enable() fails, it returns with them
disabled. The next suspend returns early on is_suspended without
re-enabling them, and the next resume disables them again, so every
failed resume leaves the disable depth one level deeper and host-mode
wakeup is lost for good.
Re-enabling them on the error path is not safe either: the
level-triggered ss_phy interrupt can stay asserted, and the handler
can't make progress while the controller is not resumed, so it would
fire continuously.
Track whether the wakeup interrupts are armed and make enabling and
disabling them idempotent. A failed resume now leaves them disarmed and
balanced, and the next suspend arms them again.
Signed-off-by: Faisal Hassan <faisal.hassan@oss.qualcomm.com>
---
drivers/usb/dwc3/dwc3-qcom.c | 16 ++++++++++++++++
1 file changed, 16 insertions(+)
diff --git a/drivers/usb/dwc3/dwc3-qcom.c b/drivers/usb/dwc3/dwc3-qcom.c
index 18db19cf2065..e7fadad9a4e1 100644
--- a/drivers/usb/dwc3/dwc3-qcom.c
+++ b/drivers/usb/dwc3/dwc3-qcom.c
@@ -81,6 +81,7 @@ struct dwc3_qcom {
enum usb_dr_mode mode;
bool is_suspended;
bool pm_suspended;
+ bool wakeup_irqs_armed;
struct icc_path *icc_path_ddr;
struct icc_path *icc_path_apps;
@@ -323,16 +324,26 @@ static void dwc3_qcom_disable_interrupts(struct dwc3_qcom *qcom)
{
int i;
+ if (!qcom->wakeup_irqs_armed)
+ return;
+
for (i = 0; i < qcom->num_ports; i++)
dwc3_qcom_disable_port_interrupts(&qcom->ports[i]);
+
+ qcom->wakeup_irqs_armed = false;
}
static void dwc3_qcom_enable_interrupts(struct dwc3_qcom *qcom)
{
int i;
+ if (qcom->wakeup_irqs_armed)
+ return;
+
for (i = 0; i < qcom->num_ports; i++)
dwc3_qcom_enable_port_interrupts(&qcom->ports[i]);
+
+ qcom->wakeup_irqs_armed = true;
}
/*
@@ -396,6 +407,11 @@ static int dwc3_qcom_resume(struct dwc3_qcom *qcom, pm_message_t msg)
if (!qcom->is_suspended)
return 0;
+ /*
+ * If a later step fails, the wakeup interrupts stay disarmed, as a
+ * level-triggered wakeup line could otherwise keep firing while the
+ * controller can't be resumed.
+ */
if (dwc3_qcom_is_host(qcom) && wakeup)
dwc3_qcom_disable_interrupts(qcom);
--
2.34.1
^ permalink raw reply [flat|nested] 23+ messages in thread* Re: [PATCH v5 03/11] usb: dwc3: qcom: Keep wakeup IRQ enable/disable balanced on failed resume
2026-11-23 10:47 ` [PATCH v5 03/11] usb: dwc3: qcom: Keep wakeup IRQ enable/disable balanced on failed resume Faisal Hassan
@ 2026-11-26 8:37 ` Peter Chen
2026-11-26 17:31 ` Krishna Kurapati
1 sibling, 0 replies; 23+ messages in thread
From: Peter Chen @ 2026-11-26 8:37 UTC (permalink / raw)
To: Faisal Hassan
Cc: Thinh.Nguyen, gregkh, linux-usb, linux-arm-msm, linux-kernel,
devicetree, krishna.kurapati, krzysztof.kozlowski
On 26-11-23 16:17:18, Faisal Hassan wrote:
> dwc3_qcom_resume() disables the wakeup interrupts before enabling the
> clocks. If clk_bulk_prepare_enable() fails, it returns with them
> disabled. The next suspend returns early
Have you run out this sequence at hardware? I find the dwc3 core suspend
(dwc3_pm_suspend) has not guarded for is_suspended, it should run into
some problems, eg visiting register with clocks off, etc. It is predate
issue, not related to your patch.
> on is_suspended without
> re-enabling them, and the next resume disables them again, so every
> failed resume leaves the disable depth one level deeper and host-mode
> wakeup is lost for good.
>
> Re-enabling them on the error path is not safe either: the
> level-triggered ss_phy interrupt can stay asserted, and the handler
> can't make progress while the controller is not resumed, so it would
> fire continuously.
>
> Track whether the wakeup interrupts are armed and make enabling and
> disabling them idempotent. A failed resume now leaves them disarmed and
> balanced, and the next suspend arms them again.
>
> Signed-off-by: Faisal Hassan <faisal.hassan@oss.qualcomm.com>
Reviewed-by: Peter Chen <peter.chen@oss.qualcomm.com>
Peter
> ---
> drivers/usb/dwc3/dwc3-qcom.c | 16 ++++++++++++++++
> 1 file changed, 16 insertions(+)
>
> diff --git a/drivers/usb/dwc3/dwc3-qcom.c b/drivers/usb/dwc3/dwc3-qcom.c
> index 18db19cf2065..e7fadad9a4e1 100644
> --- a/drivers/usb/dwc3/dwc3-qcom.c
> +++ b/drivers/usb/dwc3/dwc3-qcom.c
> @@ -81,6 +81,7 @@ struct dwc3_qcom {
> enum usb_dr_mode mode;
> bool is_suspended;
> bool pm_suspended;
> + bool wakeup_irqs_armed;
> struct icc_path *icc_path_ddr;
> struct icc_path *icc_path_apps;
>
> @@ -323,16 +324,26 @@ static void dwc3_qcom_disable_interrupts(struct dwc3_qcom *qcom)
> {
> int i;
>
> + if (!qcom->wakeup_irqs_armed)
> + return;
> +
> for (i = 0; i < qcom->num_ports; i++)
> dwc3_qcom_disable_port_interrupts(&qcom->ports[i]);
> +
> + qcom->wakeup_irqs_armed = false;
> }
>
> static void dwc3_qcom_enable_interrupts(struct dwc3_qcom *qcom)
> {
> int i;
>
> + if (qcom->wakeup_irqs_armed)
> + return;
> +
> for (i = 0; i < qcom->num_ports; i++)
> dwc3_qcom_enable_port_interrupts(&qcom->ports[i]);
> +
> + qcom->wakeup_irqs_armed = true;
> }
>
> /*
> @@ -396,6 +407,11 @@ static int dwc3_qcom_resume(struct dwc3_qcom *qcom, pm_message_t msg)
> if (!qcom->is_suspended)
> return 0;
>
> + /*
> + * If a later step fails, the wakeup interrupts stay disarmed, as a
> + * level-triggered wakeup line could otherwise keep firing while the
> + * controller can't be resumed.
> + */
> if (dwc3_qcom_is_host(qcom) && wakeup)
> dwc3_qcom_disable_interrupts(qcom);
>
> --
> 2.34.1
>
--
Thanks,
Peter Chen
^ permalink raw reply [flat|nested] 23+ messages in thread* Re: [PATCH v5 03/11] usb: dwc3: qcom: Keep wakeup IRQ enable/disable balanced on failed resume
2026-11-23 10:47 ` [PATCH v5 03/11] usb: dwc3: qcom: Keep wakeup IRQ enable/disable balanced on failed resume Faisal Hassan
2026-11-26 8:37 ` Peter Chen
@ 2026-11-26 17:31 ` Krishna Kurapati
1 sibling, 0 replies; 23+ messages in thread
From: Krishna Kurapati @ 2026-11-26 17:31 UTC (permalink / raw)
To: Faisal Hassan, Thinh.Nguyen, gregkh
Cc: linux-usb, linux-arm-msm, linux-kernel, devicetree, peter.chen,
krzysztof.kozlowski
On 11/23/2026 4:17 PM, Faisal Hassan wrote:
> dwc3_qcom_resume() disables the wakeup interrupts before enabling the
> clocks. If clk_bulk_prepare_enable() fails, it returns with them
> disabled. The next suspend returns early on is_suspended without
> re-enabling them, and the next resume disables them again, so every
> failed resume leaves the disable depth one level deeper and host-mode
> wakeup is lost for good.
>
> Re-enabling them on the error path is not safe either: the
> level-triggered ss_phy interrupt can stay asserted, and the handler
> can't make progress while the controller is not resumed, so it would
> fire continuously.
>
> Track whether the wakeup interrupts are armed and make enabling and
> disabling them idempotent. A failed resume now leaves them disarmed and
> balanced, and the next suspend arms them again.
>
> Signed-off-by: Faisal Hassan <faisal.hassan@oss.qualcomm.com>
Reviewed-by: Krishna Kurapati <krishna.kurapati@oss.qualcomm.com>
Regards,
Krishna,
> ---
> drivers/usb/dwc3/dwc3-qcom.c | 16 ++++++++++++++++
> 1 file changed, 16 insertions(+)
>
> diff --git a/drivers/usb/dwc3/dwc3-qcom.c b/drivers/usb/dwc3/dwc3-qcom.c
> index 18db19cf2065..e7fadad9a4e1 100644
> --- a/drivers/usb/dwc3/dwc3-qcom.c
> +++ b/drivers/usb/dwc3/dwc3-qcom.c
> @@ -81,6 +81,7 @@ struct dwc3_qcom {
> enum usb_dr_mode mode;
> bool is_suspended;
> bool pm_suspended;
> + bool wakeup_irqs_armed;
> struct icc_path *icc_path_ddr;
> struct icc_path *icc_path_apps;
>
> @@ -323,16 +324,26 @@ static void dwc3_qcom_disable_interrupts(struct dwc3_qcom *qcom)
> {
> int i;
>
> + if (!qcom->wakeup_irqs_armed)
> + return;
> +
> for (i = 0; i < qcom->num_ports; i++)
> dwc3_qcom_disable_port_interrupts(&qcom->ports[i]);
> +
> + qcom->wakeup_irqs_armed = false;
> }
>
> static void dwc3_qcom_enable_interrupts(struct dwc3_qcom *qcom)
> {
> int i;
>
> + if (qcom->wakeup_irqs_armed)
> + return;
> +
> for (i = 0; i < qcom->num_ports; i++)
> dwc3_qcom_enable_port_interrupts(&qcom->ports[i]);
> +
> + qcom->wakeup_irqs_armed = true;
> }
>
> /*
> @@ -396,6 +407,11 @@ static int dwc3_qcom_resume(struct dwc3_qcom *qcom, pm_message_t msg)
> if (!qcom->is_suspended)
> return 0;
>
> + /*
> + * If a later step fails, the wakeup interrupts stay disarmed, as a
> + * level-triggered wakeup line could otherwise keep firing while the
> + * controller can't be resumed.
> + */
> if (dwc3_qcom_is_host(qcom) && wakeup)
> dwc3_qcom_disable_interrupts(qcom);
>
^ permalink raw reply [flat|nested] 23+ messages in thread
* [PATCH v5 04/11] dt-bindings: usb: Add qcom,sa8255p-dwc3 for firmware-managed resources
2026-11-23 10:47 [PATCH v5 00/11] usb: dwc3: qcom: Add firmware-managed resource support for SA8255P Faisal Hassan
` (2 preceding siblings ...)
2026-11-23 10:47 ` [PATCH v5 03/11] usb: dwc3: qcom: Keep wakeup IRQ enable/disable balanced on failed resume Faisal Hassan
@ 2026-11-23 10:47 ` Faisal Hassan
2026-11-23 10:47 ` [PATCH v5 05/11] usb: host: xhci-plat: Support XHCI_RESET_ON_RESUME via device property Faisal Hassan
` (6 subsequent siblings)
10 siblings, 0 replies; 23+ messages in thread
From: Faisal Hassan @ 2026-11-23 10:47 UTC (permalink / raw)
To: Thinh.Nguyen, gregkh, Rob Herring, Krzysztof Kozlowski,
Conor Dooley, Wesley Cheng, Faisal Hassan
Cc: linux-usb, linux-arm-msm, linux-kernel, devicetree,
krishna.kurapati, peter.chen, krzysztof.kozlowski, Sriram Dash
On Qualcomm automotive SoC sa8255p, platform resources like clocks,
interconnects, resets, regulators and GDSC are abstracted and managed
collectively by firmware.
Add a new binding file for firmware-managed USB controllers where
access to these resources is exposed as two power domains:
- Power domain: Controls power supply (GDSC) to the USB controller
- Bus domain: Controls clocks and interconnects for data transfer
The binding makes power-domains and power-domain-names properties mandatory
for firmware-managed platforms. Clocks and interconnects are managed by
firmware through these power domains and are therefore not described.
Co-developed-by: Sriram Dash <sriram.dash@oss.qualcomm.com>
Signed-off-by: Sriram Dash <sriram.dash@oss.qualcomm.com>
Signed-off-by: Faisal Hassan <faisal.hassan@oss.qualcomm.com>
Reviewed-by: Krzysztof Kozlowski <krzysztof.kozlowski@oss.qualcomm.com>
---
.../bindings/usb/qcom,sa8255p-dwc3.yaml | 114 ++++++++++++++++++
1 file changed, 114 insertions(+)
create mode 100644 Documentation/devicetree/bindings/usb/qcom,sa8255p-dwc3.yaml
diff --git a/Documentation/devicetree/bindings/usb/qcom,sa8255p-dwc3.yaml b/Documentation/devicetree/bindings/usb/qcom,sa8255p-dwc3.yaml
new file mode 100644
index 000000000000..50361fe97c7a
--- /dev/null
+++ b/Documentation/devicetree/bindings/usb/qcom,sa8255p-dwc3.yaml
@@ -0,0 +1,114 @@
+# SPDX-License-Identifier: (GPL-2.0 OR BSD-2-Clause)
+%YAML 1.2
+---
+$id: http://devicetree.org/schemas/usb/qcom,sa8255p-dwc3.yaml#
+$schema: http://devicetree.org/meta-schemas/core.yaml#
+
+title: Qualcomm SA8255P USB3 Controller with Firmware-Managed Resources
+
+maintainers:
+ - Wesley Cheng <wesley.cheng@oss.qualcomm.com>
+ - Faisal Hassan <faisal.hassan@oss.qualcomm.com>
+
+description:
+ USB controller on Qualcomm SA8255P automotive SoC where platform resources
+ such as clocks, interconnects, resets, regulators and the GDSC are
+ abstracted and managed collectively by firmware through SCMI (System
+ Control and Management Interface).
+
+ Access to these firmware-managed resources is exposed as two power
+ domains, one gating the power supply (GDSC) to the controller, and one
+ gating the clocks and interconnects used for data transfer.
+ Both are SCMI power domains that are only switched on and off, and
+ neither carries performance levels.
+
+properties:
+ compatible:
+ const: qcom,sa8255p-dwc3
+
+ reg:
+ maxItems: 1
+
+ interrupts:
+ maxItems: 6
+
+ interrupt-names:
+ items:
+ - const: dwc_usb3
+ - const: pwr_event
+ - const: hs_phy_irq
+ - const: dp_hs_phy_irq
+ - const: dm_hs_phy_irq
+ - const: ss_phy_irq
+
+ power-domains:
+ maxItems: 2
+
+ power-domain-names:
+ items:
+ - const: power
+ - const: bus
+
+ resets:
+ maxItems: 1
+
+ iommus:
+ maxItems: 1
+
+ phys:
+ maxItems: 2
+
+ phy-names:
+ items:
+ - const: usb2-phy
+ - const: usb3-phy
+
+ dma-coherent: true
+
+required:
+ - compatible
+ - reg
+ - interrupts
+ - interrupt-names
+ - power-domains
+ - power-domain-names
+ - resets
+ - phys
+ - phy-names
+
+allOf:
+ - $ref: snps,dwc3-common.yaml#
+
+unevaluatedProperties: false
+
+examples:
+ - |
+ #include <dt-bindings/interrupt-controller/arm-gic.h>
+ #include <dt-bindings/interrupt-controller/irq.h>
+
+ usb@a800000 {
+ compatible = "qcom,sa8255p-dwc3";
+ reg = <0x0a800000 0x10000>;
+
+ interrupts-extended = <&intc GIC_SPI 349 IRQ_TYPE_LEVEL_HIGH>,
+ <&intc GIC_SPI 352 IRQ_TYPE_LEVEL_HIGH>,
+ <&intc GIC_SPI 351 IRQ_TYPE_LEVEL_HIGH>,
+ <&pdc 8 IRQ_TYPE_EDGE_BOTH>,
+ <&pdc 7 IRQ_TYPE_EDGE_BOTH>,
+ <&pdc 13 IRQ_TYPE_LEVEL_HIGH>;
+ interrupt-names = "dwc_usb3",
+ "pwr_event",
+ "hs_phy_irq",
+ "dp_hs_phy_irq",
+ "dm_hs_phy_irq",
+ "ss_phy_irq";
+
+ power-domains = <&scmi_pd 1>, <&scmi_pd 2>;
+ power-domain-names = "power", "bus";
+ resets = <&scmi_rst 0>;
+
+ iommus = <&apps_smmu 0x0a0 0x0>;
+ phys = <&usb_1_hsphy>, <&usb_1_qmpphy>;
+ phy-names = "usb2-phy", "usb3-phy";
+ };
+...
--
2.34.1
^ permalink raw reply [flat|nested] 23+ messages in thread* [PATCH v5 05/11] usb: host: xhci-plat: Support XHCI_RESET_ON_RESUME via device property
2026-11-23 10:47 [PATCH v5 00/11] usb: dwc3: qcom: Add firmware-managed resource support for SA8255P Faisal Hassan
` (3 preceding siblings ...)
2026-11-23 10:47 ` [PATCH v5 04/11] dt-bindings: usb: Add qcom,sa8255p-dwc3 for firmware-managed resources Faisal Hassan
@ 2026-11-23 10:47 ` Faisal Hassan
2026-11-23 10:47 ` [PATCH v5 06/11] usb: dwc3: Support resetting the xHCI host on system resume Faisal Hassan
` (5 subsequent siblings)
10 siblings, 0 replies; 23+ messages in thread
From: Faisal Hassan @ 2026-11-23 10:47 UTC (permalink / raw)
To: Thinh.Nguyen, gregkh, Mathias Nyman
Cc: linux-usb, linux-arm-msm, linux-kernel, devicetree,
krishna.kurapati, peter.chen, krzysztof.kozlowski, Faisal Hassan,
Sriram Dash
When the USB controller loses power during PM suspend (as occurs
on targets like SA8255P that fully power off the controller),
it generates a Host Controller Error (HCE) on resume requiring
full reinitialization. This is handled by the XHCI_RESET_ON_RESUME
quirk (introduced upstream in 8b328f8002bc).
Read the "xhci-reset-on-resume-quirk" device property to set
XHCI_RESET_ON_RESUME. This allows parent drivers (e.g., dwc3)
to enable the quirk via software nodes.
Co-developed-by: Sriram Dash <sriram.dash@oss.qualcomm.com>
Signed-off-by: Sriram Dash <sriram.dash@oss.qualcomm.com>
Signed-off-by: Faisal Hassan <faisal.hassan@oss.qualcomm.com>
Reviewed-by: Peter Chen <peter.chen@oss.qualcomm.com>
---
drivers/usb/host/xhci-plat.c | 3 +++
1 file changed, 3 insertions(+)
diff --git a/drivers/usb/host/xhci-plat.c b/drivers/usb/host/xhci-plat.c
index 6fd595f81a30..0093ed24ac3f 100644
--- a/drivers/usb/host/xhci-plat.c
+++ b/drivers/usb/host/xhci-plat.c
@@ -277,6 +277,9 @@ int xhci_plat_probe(struct platform_device *pdev, struct device *sysdev, const s
if (device_property_read_bool(tmpdev, "xhci-skip-phy-init-quirk"))
xhci->quirks |= XHCI_SKIP_PHY_INIT;
+ if (device_property_read_bool(tmpdev, "xhci-reset-on-resume-quirk"))
+ xhci->quirks |= XHCI_RESET_ON_RESUME;
+
device_property_read_u32(tmpdev, "imod-interval-ns",
&xhci->imod_interval);
device_property_read_u16(tmpdev, "num-hc-interrupters",
--
2.34.1
^ permalink raw reply [flat|nested] 23+ messages in thread* [PATCH v5 06/11] usb: dwc3: Support resetting the xHCI host on system resume
2026-11-23 10:47 [PATCH v5 00/11] usb: dwc3: qcom: Add firmware-managed resource support for SA8255P Faisal Hassan
` (4 preceding siblings ...)
2026-11-23 10:47 ` [PATCH v5 05/11] usb: host: xhci-plat: Support XHCI_RESET_ON_RESUME via device property Faisal Hassan
@ 2026-11-23 10:47 ` Faisal Hassan
2026-11-23 10:47 ` [PATCH v5 07/11] usb: dwc3: qcom: Recover controller state after power loss in system suspend Faisal Hassan
` (4 subsequent siblings)
10 siblings, 0 replies; 23+ messages in thread
From: Faisal Hassan @ 2026-11-23 10:47 UTC (permalink / raw)
To: Thinh.Nguyen, gregkh
Cc: linux-usb, linux-arm-msm, linux-kernel, devicetree,
krishna.kurapati, peter.chen, krzysztof.kozlowski, Faisal Hassan,
Sriram Dash
Some platforms power the controller down during system suspend, which
leaves the xHCI host in a state that needs a full reset on resume.
xhci-plat can already be told to do that with the
"xhci-reset-on-resume-quirk" device property, which sets
XHCI_RESET_ON_RESUME.
Add an xhci_reset_on_resume field to struct dwc3_properties so that a
glue driver can request it, and pass it on to the xhci-plat device as
that property when the host is created.
Co-developed-by: Sriram Dash <sriram.dash@oss.qualcomm.com>
Signed-off-by: Sriram Dash <sriram.dash@oss.qualcomm.com>
Signed-off-by: Faisal Hassan <faisal.hassan@oss.qualcomm.com>
---
drivers/usb/dwc3/core.c | 3 +++
drivers/usb/dwc3/core.h | 3 +++
drivers/usb/dwc3/glue.h | 2 ++
drivers/usb/dwc3/host.c | 5 ++++-
4 files changed, 12 insertions(+), 1 deletion(-)
diff --git a/drivers/usb/dwc3/core.c b/drivers/usb/dwc3/core.c
index d9f4e4109abb..d782d5ef9c57 100644
--- a/drivers/usb/dwc3/core.c
+++ b/drivers/usb/dwc3/core.c
@@ -1697,6 +1697,9 @@ static void dwc3_get_software_properties(struct dwc3 *dwc,
if (properties->skip_phy_init)
dwc->skip_phy_init = true;
+ if (properties->xhci_reset_on_resume)
+ dwc->xhci_reset_on_resume = true;
+
dwc->gsbuscfg0_reqinfo = DWC3_GSBUSCFG0_REQINFO_UNSPECIFIED;
if (properties->gsbuscfg0_reqinfo !=
diff --git a/drivers/usb/dwc3/core.h b/drivers/usb/dwc3/core.h
index 1c8d441ea9f8..3cbe4eeb0a5a 100644
--- a/drivers/usb/dwc3/core.h
+++ b/drivers/usb/dwc3/core.h
@@ -1177,6 +1177,7 @@ struct dwc3_glue_ops {
* 3 - Reserved
* @dis_metastability_quirk: set to disable metastability quirk.
* @dis_split_quirk: set to disable split boundary.
+ * @xhci_reset_on_resume: set to reset the xHCI host controller on system resume.
* @enable_usb2_transceiver_delay: Set to insert a delay before the
* assertion of the TxValid signal during a HS Chirp.
* @sys_wakeup: set if the device may do system wakeup.
@@ -1433,6 +1434,8 @@ struct dwc3 {
unsigned dis_metastability_quirk:1;
unsigned dis_split_quirk:1;
+ unsigned xhci_reset_on_resume:1;
+
unsigned enable_usb2_transceiver_delay:1;
unsigned async_callbacks:1;
unsigned sys_wakeup:1;
diff --git a/drivers/usb/dwc3/glue.h b/drivers/usb/dwc3/glue.h
index 72c5593e657a..028a4f8a4fac 100644
--- a/drivers/usb/dwc3/glue.h
+++ b/drivers/usb/dwc3/glue.h
@@ -15,11 +15,13 @@
* @needs_full_reinit: indicate the controller may not remain power during system
* pm and need full initialization
* @skip_phy_init: skip xHCI PHY initialization on host init
+ * @xhci_reset_on_resume: reset the xHCI host controller on system resume
*/
struct dwc3_properties {
u32 gsbuscfg0_reqinfo;
unsigned needs_full_reinit:1;
unsigned skip_phy_init:1;
+ unsigned xhci_reset_on_resume:1;
};
#define DWC3_DEFAULT_PROPERTIES ((struct dwc3_properties){ \
diff --git a/drivers/usb/dwc3/host.c b/drivers/usb/dwc3/host.c
index 3fb8be8be590..a9c81def13c2 100644
--- a/drivers/usb/dwc3/host.c
+++ b/drivers/usb/dwc3/host.c
@@ -130,7 +130,7 @@ static int dwc3_host_get_irq(struct dwc3 *dwc)
int dwc3_host_init(struct dwc3 *dwc)
{
- struct property_entry props[7];
+ struct property_entry props[9];
struct platform_device *xhci;
int ret, irq;
int prop_idx = 0;
@@ -177,6 +177,9 @@ int dwc3_host_init(struct dwc3 *dwc)
if (dwc->skip_phy_init)
props[prop_idx++] = PROPERTY_ENTRY_BOOL("xhci-skip-phy-init-quirk");
+ if (dwc->xhci_reset_on_resume)
+ props[prop_idx++] = PROPERTY_ENTRY_BOOL("xhci-reset-on-resume-quirk");
+
/**
* WORKAROUND: dwc3 revisions <=3.00a have a limitation
* where Port Disable command doesn't work.
--
2.34.1
^ permalink raw reply [flat|nested] 23+ messages in thread* [PATCH v5 07/11] usb: dwc3: qcom: Recover controller state after power loss in system suspend
2026-11-23 10:47 [PATCH v5 00/11] usb: dwc3: qcom: Add firmware-managed resource support for SA8255P Faisal Hassan
` (5 preceding siblings ...)
2026-11-23 10:47 ` [PATCH v5 06/11] usb: dwc3: Support resetting the xHCI host on system resume Faisal Hassan
@ 2026-11-23 10:47 ` Faisal Hassan
2026-11-26 9:52 ` Peter Chen
2026-11-23 10:47 ` [PATCH v5 08/11] usb: dwc3: qcom: Restore VBUS override after system resume Faisal Hassan
` (3 subsequent siblings)
10 siblings, 1 reply; 23+ messages in thread
From: Faisal Hassan @ 2026-11-23 10:47 UTC (permalink / raw)
To: Thinh.Nguyen, gregkh, Philipp Zabel
Cc: linux-usb, linux-arm-msm, linux-kernel, devicetree,
krishna.kurapati, peter.chen, krzysztof.kozlowski, Faisal Hassan,
Sriram Dash
On SA8255P, automotive platform requirements call for powering down the
controller's GDSC and entering VDDmin on the APPS side during system
suspend. The controller therefore loses all of its state across system
suspend, regardless of whether wakeup is enabled. Runtime suspend does
not remove power.
Add a per-compatible flag, power_lost_in_suspend, and use it to recover:
- Assert and deassert the controller reset on system resume, so the
controller starts from a known state. Skip this on runtime resume
as the controller keeps its state there.
- Set needs_full_reinit, so dwc3 core reinitializes the controller on
resume, and xhci_reset_on_resume, so the xHCI host is reset as well.
- Return 0 from .prepare, so the PM core does not apply direct_complete
to a runtime-suspended device. The system resume callback must always
run to reset the controller.
This follows dwc3-imx, which also sets needs_full_reinit because the
controller loses power across system suspend.
Co-developed-by: Sriram Dash <sriram.dash@oss.qualcomm.com>
Signed-off-by: Sriram Dash <sriram.dash@oss.qualcomm.com>
Signed-off-by: Faisal Hassan <faisal.hassan@oss.qualcomm.com>
---
drivers/usb/dwc3/dwc3-qcom.c | 47 ++++++++++++++++++++++++++++++++++++
1 file changed, 47 insertions(+)
diff --git a/drivers/usb/dwc3/dwc3-qcom.c b/drivers/usb/dwc3/dwc3-qcom.c
index e7fadad9a4e1..8e8d7e59c6d5 100644
--- a/drivers/usb/dwc3/dwc3-qcom.c
+++ b/drivers/usb/dwc3/dwc3-qcom.c
@@ -68,6 +68,10 @@ struct dwc3_qcom_port {
enum usb_device_speed usb2_speed;
};
+struct dwc3_qcom_priv_data {
+ bool power_lost_in_suspend;
+};
+
struct dwc3_qcom {
struct device *dev;
void __iomem *qscratch_base;
@@ -86,6 +90,12 @@ struct dwc3_qcom {
struct icc_path *icc_path_apps;
enum usb_role current_role;
+
+ bool power_lost_in_suspend;
+};
+
+static const struct dwc3_qcom_priv_data sa8255p_dwc3_qcom_priv_data = {
+ .power_lost_in_suspend = true,
};
#define to_dwc3_qcom(d) container_of((d), struct dwc3_qcom, dwc)
@@ -407,6 +417,23 @@ static int dwc3_qcom_resume(struct dwc3_qcom *qcom, pm_message_t msg)
if (!qcom->is_suspended)
return 0;
+ if (qcom->power_lost_in_suspend && !PMSG_IS_AUTO(msg)) {
+ /* Runtime suspend keeps power, so there is no state to recover */
+ ret = reset_control_assert(qcom->resets);
+ if (ret) {
+ dev_err(qcom->dev, "failed to assert resets, err=%d\n", ret);
+ return ret;
+ }
+
+ usleep_range(10, 1000);
+
+ ret = reset_control_deassert(qcom->resets);
+ if (ret) {
+ dev_err(qcom->dev, "failed to deassert resets, err=%d\n", ret);
+ return ret;
+ }
+ }
+
/*
* If a later step fails, the wakeup interrupts stay disarmed, as a
* level-triggered wakeup line could otherwise keep firing while the
@@ -649,6 +676,7 @@ static int dwc3_qcom_probe(struct platform_device *pdev)
struct dwc3_qcom *qcom;
struct resource res;
struct resource *r;
+ const struct dwc3_qcom_priv_data *priv_data;
int ret;
bool ignore_pipe_clk;
bool wakeup_source;
@@ -659,6 +687,10 @@ static int dwc3_qcom_probe(struct platform_device *pdev)
qcom->dev = &pdev->dev;
+ priv_data = of_device_get_match_data(dev);
+ if (priv_data)
+ qcom->power_lost_in_suspend = priv_data->power_lost_in_suspend;
+
qcom->resets = devm_reset_control_array_get_optional_exclusive(dev);
if (IS_ERR(qcom->resets)) {
return dev_err_probe(&pdev->dev, PTR_ERR(qcom->resets),
@@ -741,6 +773,9 @@ static int dwc3_qcom_probe(struct platform_device *pdev)
probe_data.ignore_clocks_and_resets = true;
probe_data.properties = DWC3_DEFAULT_PROPERTIES;
probe_data.properties.skip_phy_init = true;
+ /* Controller loses power on system suspend, even with wakeup enabled */
+ probe_data.properties.needs_full_reinit = qcom->power_lost_in_suspend;
+ probe_data.properties.xhci_reset_on_resume = qcom->power_lost_in_suspend;
ret = dwc3_core_probe(&probe_data);
if (ret) {
ret = dev_err_probe(dev, ret, "failed to register DWC3 Core\n");
@@ -829,6 +864,14 @@ static void dwc3_qcom_complete(struct device *dev)
static int dwc3_qcom_prepare(struct device *dev)
{
struct dwc3 *dwc = dev_get_drvdata(dev);
+ struct dwc3_qcom *qcom = to_dwc3_qcom(dwc);
+
+ /*
+ * Resume must always run to reset the controller, so don't let the
+ * PM core skip it for a runtime-suspended device (direct_complete).
+ */
+ if (qcom->power_lost_in_suspend)
+ return 0;
return dwc3_pm_prepare(dwc);
}
@@ -873,6 +916,10 @@ static const struct dev_pm_ops dwc3_qcom_dev_pm_ops = {
};
static const struct of_device_id dwc3_qcom_of_match[] = {
+ {
+ .compatible = "qcom,sa8255p-dwc3",
+ .data = &sa8255p_dwc3_qcom_priv_data,
+ },
{ .compatible = "qcom,snps-dwc3" },
{ }
};
--
2.34.1
^ permalink raw reply [flat|nested] 23+ messages in thread* Re: [PATCH v5 07/11] usb: dwc3: qcom: Recover controller state after power loss in system suspend
2026-11-23 10:47 ` [PATCH v5 07/11] usb: dwc3: qcom: Recover controller state after power loss in system suspend Faisal Hassan
@ 2026-11-26 9:52 ` Peter Chen
0 siblings, 0 replies; 23+ messages in thread
From: Peter Chen @ 2026-11-26 9:52 UTC (permalink / raw)
To: Faisal Hassan
Cc: Thinh.Nguyen, gregkh, Philipp Zabel, linux-usb, linux-arm-msm,
linux-kernel, devicetree, krishna.kurapati, krzysztof.kozlowski,
Sriram Dash
On 26-11-23 16:17:22, Faisal Hassan wrote:
> On SA8255P, automotive platform requirements call for powering down the
> controller's GDSC and entering VDDmin on the APPS side during system
> suspend. The controller therefore loses all of its state across system
> suspend, regardless of whether wakeup is enabled. Runtime suspend does
> not remove power.
>
> Add a per-compatible flag, power_lost_in_suspend, and use it to recover:
>
> - Assert and deassert the controller reset on system resume, so the
> controller starts from a known state. Skip this on runtime resume
> as the controller keeps its state there.
> - Set needs_full_reinit, so dwc3 core reinitializes the controller on
> resume, and xhci_reset_on_resume, so the xHCI host is reset as well.
> - Return 0 from .prepare, so the PM core does not apply direct_complete
> to a runtime-suspended device. The system resume callback must always
> run to reset the controller.
>
> This follows dwc3-imx, which also sets needs_full_reinit because the
> controller loses power across system suspend.
>
> Co-developed-by: Sriram Dash <sriram.dash@oss.qualcomm.com>
> Signed-off-by: Sriram Dash <sriram.dash@oss.qualcomm.com>
> Signed-off-by: Faisal Hassan <faisal.hassan@oss.qualcomm.com>
> ---
> drivers/usb/dwc3/dwc3-qcom.c | 47 ++++++++++++++++++++++++++++++++++++
> 1 file changed, 47 insertions(+)
>
> diff --git a/drivers/usb/dwc3/dwc3-qcom.c b/drivers/usb/dwc3/dwc3-qcom.c
> index e7fadad9a4e1..8e8d7e59c6d5 100644
> --- a/drivers/usb/dwc3/dwc3-qcom.c
> +++ b/drivers/usb/dwc3/dwc3-qcom.c
> @@ -68,6 +68,10 @@ struct dwc3_qcom_port {
> enum usb_device_speed usb2_speed;
> };
>
> +struct dwc3_qcom_priv_data {
> + bool power_lost_in_suspend;
> +};
> +
> struct dwc3_qcom {
> struct device *dev;
> void __iomem *qscratch_base;
> @@ -86,6 +90,12 @@ struct dwc3_qcom {
> struct icc_path *icc_path_apps;
>
> enum usb_role current_role;
> +
> + bool power_lost_in_suspend;
> +};
> +
> +static const struct dwc3_qcom_priv_data sa8255p_dwc3_qcom_priv_data = {
> + .power_lost_in_suspend = true,
> };
>
> #define to_dwc3_qcom(d) container_of((d), struct dwc3_qcom, dwc)
> @@ -407,6 +417,23 @@ static int dwc3_qcom_resume(struct dwc3_qcom *qcom, pm_message_t msg)
> if (!qcom->is_suspended)
> return 0;
>
> + if (qcom->power_lost_in_suspend && !PMSG_IS_AUTO(msg)) {
> + /* Runtime suspend keeps power, so there is no state to recover */
> + ret = reset_control_assert(qcom->resets);
> + if (ret) {
> + dev_err(qcom->dev, "failed to assert resets, err=%d\n", ret);
> + return ret;
> + }
> +
> + usleep_range(10, 1000);
> +
> + ret = reset_control_deassert(qcom->resets);
> + if (ret) {
> + dev_err(qcom->dev, "failed to deassert resets, err=%d\n", ret);
> + return ret;
> + }
> + }
> +
> /*
> * If a later step fails, the wakeup interrupts stay disarmed, as a
> * level-triggered wakeup line could otherwise keep firing while the
> @@ -649,6 +676,7 @@ static int dwc3_qcom_probe(struct platform_device *pdev)
> struct dwc3_qcom *qcom;
> struct resource res;
> struct resource *r;
> + const struct dwc3_qcom_priv_data *priv_data;
> int ret;
> bool ignore_pipe_clk;
> bool wakeup_source;
> @@ -659,6 +687,10 @@ static int dwc3_qcom_probe(struct platform_device *pdev)
>
> qcom->dev = &pdev->dev;
>
> + priv_data = of_device_get_match_data(dev);
> + if (priv_data)
> + qcom->power_lost_in_suspend = priv_data->power_lost_in_suspend;
> +
> qcom->resets = devm_reset_control_array_get_optional_exclusive(dev);
> if (IS_ERR(qcom->resets)) {
> return dev_err_probe(&pdev->dev, PTR_ERR(qcom->resets),
> @@ -741,6 +773,9 @@ static int dwc3_qcom_probe(struct platform_device *pdev)
> probe_data.ignore_clocks_and_resets = true;
> probe_data.properties = DWC3_DEFAULT_PROPERTIES;
> probe_data.properties.skip_phy_init = true;
> + /* Controller loses power on system suspend, even with wakeup enabled */
> + probe_data.properties.needs_full_reinit = qcom->power_lost_in_suspend;
> + probe_data.properties.xhci_reset_on_resume = qcom->power_lost_in_suspend;
There is a xhci_power_lost flag support patch for dwc3 at [1], do we still need
"xhci_reset_on_resume" or could totally re-use it?
[1] https://lore.kernel.org/all/20261125181116.121-1-26rote@gmail.com/
Peter
> ret = dwc3_core_probe(&probe_data);
> if (ret) {
> ret = dev_err_probe(dev, ret, "failed to register DWC3 Core\n");
> @@ -829,6 +864,14 @@ static void dwc3_qcom_complete(struct device *dev)
> static int dwc3_qcom_prepare(struct device *dev)
> {
> struct dwc3 *dwc = dev_get_drvdata(dev);
> + struct dwc3_qcom *qcom = to_dwc3_qcom(dwc);
> +
> + /*
> + * Resume must always run to reset the controller, so don't let the
> + * PM core skip it for a runtime-suspended device (direct_complete).
> + */
> + if (qcom->power_lost_in_suspend)
> + return 0;
>
> return dwc3_pm_prepare(dwc);
> }
> @@ -873,6 +916,10 @@ static const struct dev_pm_ops dwc3_qcom_dev_pm_ops = {
> };
>
> static const struct of_device_id dwc3_qcom_of_match[] = {
> + {
> + .compatible = "qcom,sa8255p-dwc3",
> + .data = &sa8255p_dwc3_qcom_priv_data,
> + },
> { .compatible = "qcom,snps-dwc3" },
> { }
> };
> --
> 2.34.1
>
--
Thanks,
Peter Chen
^ permalink raw reply [flat|nested] 23+ messages in thread
* [PATCH v5 08/11] usb: dwc3: qcom: Restore VBUS override after system resume
2026-11-23 10:47 [PATCH v5 00/11] usb: dwc3: qcom: Add firmware-managed resource support for SA8255P Faisal Hassan
` (6 preceding siblings ...)
2026-11-23 10:47 ` [PATCH v5 07/11] usb: dwc3: qcom: Recover controller state after power loss in system suspend Faisal Hassan
@ 2026-11-23 10:47 ` Faisal Hassan
2026-11-26 9:54 ` Peter Chen
2026-11-26 17:32 ` Krishna Kurapati
2026-11-23 10:47 ` [PATCH v5 09/11] usb: dwc3: qcom: Assert controller reset on remove and probe failure Faisal Hassan
` (2 subsequent siblings)
10 siblings, 2 replies; 23+ messages in thread
From: Faisal Hassan @ 2026-11-23 10:47 UTC (permalink / raw)
To: Thinh.Nguyen, gregkh
Cc: linux-usb, linux-arm-msm, linux-kernel, devicetree,
krishna.kurapati, peter.chen, krzysztof.kozlowski, Faisal Hassan,
Sriram Dash
The controller reset on system resume returns the Qscratch registers to
their power-on defaults, which clears the VBUS valid override that was
set up for device mode. Without it the PHY does not see VBUS and the
gadget fails to enumerate after resume.
Re-enable the override after resume when the controller is not in host
mode.
Co-developed-by: Sriram Dash <sriram.dash@oss.qualcomm.com>
Signed-off-by: Sriram Dash <sriram.dash@oss.qualcomm.com>
Signed-off-by: Faisal Hassan <faisal.hassan@oss.qualcomm.com>
---
drivers/usb/dwc3/dwc3-qcom.c | 8 ++++++++
1 file changed, 8 insertions(+)
diff --git a/drivers/usb/dwc3/dwc3-qcom.c b/drivers/usb/dwc3/dwc3-qcom.c
index 8e8d7e59c6d5..50fca06c83d4 100644
--- a/drivers/usb/dwc3/dwc3-qcom.c
+++ b/drivers/usb/dwc3/dwc3-qcom.c
@@ -457,6 +457,14 @@ static int dwc3_qcom_resume(struct dwc3_qcom *qcom, pm_message_t msg)
PWR_EVNT_LPM_IN_L2_MASK | PWR_EVNT_LPM_OUT_L2_MASK);
}
+ /*
+ * The reset above returned Qscratch to its power-on defaults, so
+ * restore the VBUS valid override set up for device mode.
+ */
+ if (qcom->power_lost_in_suspend && !PMSG_IS_AUTO(msg) &&
+ !dwc3_qcom_is_host(qcom))
+ dwc3_qcom_vbus_override_enable(qcom, true);
+
qcom->is_suspended = false;
return 0;
--
2.34.1
^ permalink raw reply [flat|nested] 23+ messages in thread* Re: [PATCH v5 08/11] usb: dwc3: qcom: Restore VBUS override after system resume
2026-11-23 10:47 ` [PATCH v5 08/11] usb: dwc3: qcom: Restore VBUS override after system resume Faisal Hassan
@ 2026-11-26 9:54 ` Peter Chen
2026-11-26 17:32 ` Krishna Kurapati
1 sibling, 0 replies; 23+ messages in thread
From: Peter Chen @ 2026-11-26 9:54 UTC (permalink / raw)
To: Faisal Hassan
Cc: Thinh.Nguyen, gregkh, linux-usb, linux-arm-msm, linux-kernel,
devicetree, krishna.kurapati, krzysztof.kozlowski, Sriram Dash
On 26-11-23 16:17:23, Faisal Hassan wrote:
> The controller reset on system resume returns the Qscratch registers to
> their power-on defaults, which clears the VBUS valid override that was
> set up for device mode. Without it the PHY does not see VBUS and the
> gadget fails to enumerate after resume.
>
> Re-enable the override after resume when the controller is not in host
> mode.
>
> Co-developed-by: Sriram Dash <sriram.dash@oss.qualcomm.com>
> Signed-off-by: Sriram Dash <sriram.dash@oss.qualcomm.com>
> Signed-off-by: Faisal Hassan <faisal.hassan@oss.qualcomm.com>
> ---
> drivers/usb/dwc3/dwc3-qcom.c | 8 ++++++++
> 1 file changed, 8 insertions(+)
>
> diff --git a/drivers/usb/dwc3/dwc3-qcom.c b/drivers/usb/dwc3/dwc3-qcom.c
> index 8e8d7e59c6d5..50fca06c83d4 100644
> --- a/drivers/usb/dwc3/dwc3-qcom.c
> +++ b/drivers/usb/dwc3/dwc3-qcom.c
> @@ -457,6 +457,14 @@ static int dwc3_qcom_resume(struct dwc3_qcom *qcom, pm_message_t msg)
> PWR_EVNT_LPM_IN_L2_MASK | PWR_EVNT_LPM_OUT_L2_MASK);
> }
>
> + /*
> + * The reset above returned Qscratch to its power-on defaults, so
> + * restore the VBUS valid override set up for device mode.
> + */
> + if (qcom->power_lost_in_suspend && !PMSG_IS_AUTO(msg) &&
> + !dwc3_qcom_is_host(qcom))
> + dwc3_qcom_vbus_override_enable(qcom, true);
> +
> qcom->is_suspended = false;
>
Reviewed-by: Peter Chen <peter.chen@oss.qualcomm.com>
--
Thanks,
Peter Chen
^ permalink raw reply [flat|nested] 23+ messages in thread
* Re: [PATCH v5 08/11] usb: dwc3: qcom: Restore VBUS override after system resume
2026-11-23 10:47 ` [PATCH v5 08/11] usb: dwc3: qcom: Restore VBUS override after system resume Faisal Hassan
2026-11-26 9:54 ` Peter Chen
@ 2026-11-26 17:32 ` Krishna Kurapati
1 sibling, 0 replies; 23+ messages in thread
From: Krishna Kurapati @ 2026-11-26 17:32 UTC (permalink / raw)
To: Faisal Hassan, Thinh.Nguyen, gregkh
Cc: linux-usb, linux-arm-msm, linux-kernel, devicetree, peter.chen,
krzysztof.kozlowski, Sriram Dash
On 11/23/2026 4:17 PM, Faisal Hassan wrote:
> The controller reset on system resume returns the Qscratch registers to
> their power-on defaults, which clears the VBUS valid override that was
> set up for device mode. Without it the PHY does not see VBUS and the
> gadget fails to enumerate after resume.
>
> Re-enable the override after resume when the controller is not in host
> mode.
>
> Co-developed-by: Sriram Dash <sriram.dash@oss.qualcomm.com>
> Signed-off-by: Sriram Dash <sriram.dash@oss.qualcomm.com>
> Signed-off-by: Faisal Hassan <faisal.hassan@oss.qualcomm.com>
Reviewed-by: Krishna Kurapati <krishna.kurapati@oss.qualcomm.com>
Regards,
Krishna,
> ---
> drivers/usb/dwc3/dwc3-qcom.c | 8 ++++++++
> 1 file changed, 8 insertions(+)
>
> diff --git a/drivers/usb/dwc3/dwc3-qcom.c b/drivers/usb/dwc3/dwc3-qcom.c
> index 8e8d7e59c6d5..50fca06c83d4 100644
> --- a/drivers/usb/dwc3/dwc3-qcom.c
> +++ b/drivers/usb/dwc3/dwc3-qcom.c
> @@ -457,6 +457,14 @@ static int dwc3_qcom_resume(struct dwc3_qcom *qcom, pm_message_t msg)
> PWR_EVNT_LPM_IN_L2_MASK | PWR_EVNT_LPM_OUT_L2_MASK);
> }
>
> + /*
> + * The reset above returned Qscratch to its power-on defaults, so
> + * restore the VBUS valid override set up for device mode.
> + */
> + if (qcom->power_lost_in_suspend && !PMSG_IS_AUTO(msg) &&
> + !dwc3_qcom_is_host(qcom))
> + dwc3_qcom_vbus_override_enable(qcom, true);
> +
> qcom->is_suspended = false;
>
> return 0;
^ permalink raw reply [flat|nested] 23+ messages in thread
* [PATCH v5 09/11] usb: dwc3: qcom: Assert controller reset on remove and probe failure
2026-11-23 10:47 [PATCH v5 00/11] usb: dwc3: qcom: Add firmware-managed resource support for SA8255P Faisal Hassan
` (7 preceding siblings ...)
2026-11-23 10:47 ` [PATCH v5 08/11] usb: dwc3: qcom: Restore VBUS override after system resume Faisal Hassan
@ 2026-11-23 10:47 ` Faisal Hassan
2026-11-26 9:56 ` Peter Chen
2026-11-23 10:47 ` [PATCH v5 10/11] usb: dwc3: qcom: Support firmware-managed resource states for power management Faisal Hassan
2026-11-23 10:47 ` [PATCH v5 11/11] usb: dwc3: qcom: Enable VBUS override at probe for default peripheral role Faisal Hassan
10 siblings, 1 reply; 23+ messages in thread
From: Faisal Hassan @ 2026-11-23 10:47 UTC (permalink / raw)
To: Thinh.Nguyen, gregkh, Philipp Zabel
Cc: linux-usb, linux-arm-msm, linux-kernel, devicetree,
krishna.kurapati, peter.chen, krzysztof.kozlowski, Faisal Hassan,
Shazad Hussain, Sriram Dash
The controller is taken out of reset at probe, but nothing puts it back
into reset when the driver is removed or when probe fails after that
point. The controller is left running when its clocks are gated, and a
later bind starts from whatever state it was left in.
Assert the reset before disabling the clocks on remove and on the probe
error path, so the controller is held in reset while unused.
Co-developed-by: Shazad Hussain <shazad.hussain@oss.qualcomm.com>
Signed-off-by: Shazad Hussain <shazad.hussain@oss.qualcomm.com>
Co-developed-by: Sriram Dash <sriram.dash@oss.qualcomm.com>
Signed-off-by: Sriram Dash <sriram.dash@oss.qualcomm.com>
Signed-off-by: Faisal Hassan <faisal.hassan@oss.qualcomm.com>
---
drivers/usb/dwc3/dwc3-qcom.c | 2 ++
1 file changed, 2 insertions(+)
diff --git a/drivers/usb/dwc3/dwc3-qcom.c b/drivers/usb/dwc3/dwc3-qcom.c
index 50fca06c83d4..61a3e3c38f59 100644
--- a/drivers/usb/dwc3/dwc3-qcom.c
+++ b/drivers/usb/dwc3/dwc3-qcom.c
@@ -804,6 +804,7 @@ static int dwc3_qcom_probe(struct platform_device *pdev)
remove_core:
dwc3_core_remove(&qcom->dwc);
clk_disable:
+ reset_control_assert(qcom->resets);
clk_bulk_disable_unprepare(qcom->num_clocks, qcom->clks);
return ret;
@@ -818,6 +819,7 @@ static void dwc3_qcom_remove(struct platform_device *pdev)
return;
dwc3_core_remove(&qcom->dwc);
+ reset_control_assert(qcom->resets);
clk_bulk_disable_unprepare(qcom->num_clocks, qcom->clks);
dwc3_qcom_interconnect_exit(qcom);
--
2.34.1
^ permalink raw reply [flat|nested] 23+ messages in thread* Re: [PATCH v5 09/11] usb: dwc3: qcom: Assert controller reset on remove and probe failure
2026-11-23 10:47 ` [PATCH v5 09/11] usb: dwc3: qcom: Assert controller reset on remove and probe failure Faisal Hassan
@ 2026-11-26 9:56 ` Peter Chen
0 siblings, 0 replies; 23+ messages in thread
From: Peter Chen @ 2026-11-26 9:56 UTC (permalink / raw)
To: Faisal Hassan
Cc: Thinh.Nguyen, gregkh, Philipp Zabel, linux-usb, linux-arm-msm,
linux-kernel, devicetree, krishna.kurapati, krzysztof.kozlowski,
Shazad Hussain, Sriram Dash
On 26-11-23 16:17:24, Faisal Hassan wrote:
> The controller is taken out of reset at probe, but nothing puts it back
> into reset when the driver is removed or when probe fails after that
> point. The controller is left running when its clocks are gated, and a
> later bind starts from whatever state it was left in.
>
> Assert the reset before disabling the clocks on remove and on the probe
> error path, so the controller is held in reset while unused.
>
> Co-developed-by: Shazad Hussain <shazad.hussain@oss.qualcomm.com>
> Signed-off-by: Shazad Hussain <shazad.hussain@oss.qualcomm.com>
> Co-developed-by: Sriram Dash <sriram.dash@oss.qualcomm.com>
> Signed-off-by: Sriram Dash <sriram.dash@oss.qualcomm.com>
> Signed-off-by: Faisal Hassan <faisal.hassan@oss.qualcomm.com>
> ---
> drivers/usb/dwc3/dwc3-qcom.c | 2 ++
> 1 file changed, 2 insertions(+)
>
> diff --git a/drivers/usb/dwc3/dwc3-qcom.c b/drivers/usb/dwc3/dwc3-qcom.c
> index 50fca06c83d4..61a3e3c38f59 100644
> --- a/drivers/usb/dwc3/dwc3-qcom.c
> +++ b/drivers/usb/dwc3/dwc3-qcom.c
> @@ -804,6 +804,7 @@ static int dwc3_qcom_probe(struct platform_device *pdev)
> remove_core:
> dwc3_core_remove(&qcom->dwc);
> clk_disable:
> + reset_control_assert(qcom->resets);
> clk_bulk_disable_unprepare(qcom->num_clocks, qcom->clks);
>
> return ret;
> @@ -818,6 +819,7 @@ static void dwc3_qcom_remove(struct platform_device *pdev)
> return;
>
> dwc3_core_remove(&qcom->dwc);
> + reset_control_assert(qcom->resets);
> clk_bulk_disable_unprepare(qcom->num_clocks, qcom->clks);
> dwc3_qcom_interconnect_exit(qcom);
>
Reviewed-by: Peter Chen <peter.chen@oss.qualcomm.com>
--
Thanks,
Peter Chen
^ permalink raw reply [flat|nested] 23+ messages in thread
* [PATCH v5 10/11] usb: dwc3: qcom: Support firmware-managed resource states for power management
2026-11-23 10:47 [PATCH v5 00/11] usb: dwc3: qcom: Add firmware-managed resource support for SA8255P Faisal Hassan
` (8 preceding siblings ...)
2026-11-23 10:47 ` [PATCH v5 09/11] usb: dwc3: qcom: Assert controller reset on remove and probe failure Faisal Hassan
@ 2026-11-23 10:47 ` Faisal Hassan
2026-11-26 10:09 ` Peter Chen
2026-11-23 10:47 ` [PATCH v5 11/11] usb: dwc3: qcom: Enable VBUS override at probe for default peripheral role Faisal Hassan
10 siblings, 1 reply; 23+ messages in thread
From: Faisal Hassan @ 2026-11-23 10:47 UTC (permalink / raw)
To: Thinh.Nguyen, gregkh, Philipp Zabel
Cc: linux-usb, linux-arm-msm, linux-kernel, devicetree,
krishna.kurapati, peter.chen, krzysztof.kozlowski, Faisal Hassan,
Shazad Hussain, Sriram Dash
Add support for firmware-managed resource handling in the Qualcomm
DWC3 USB controller driver. On platforms such as SA8255P, controller
resources are abstracted and managed collectively by firmware, and are
exposed to Linux through SCMI-backed power domains.
On SA8255P, resources such as clocks, regulators, resets, TLMM and
interconnects are controlled by firmware. The driver communicates with
firmware through two power domains:
- "power": controls power supply (GDSC) to the USB controller
- "bus": controls clocks and interconnects used for data transfer.
Register accesses through the controller require the "power"
domain to be enabled.
The clock and interconnect handling in the suspend, resume, probe and
remove paths is moved behind dwc3_qcom_resources_enable() and
dwc3_qcom_resources_disable(). They enable or disable the clocks and
interconnect paths on existing platforms, and vote the two domains on
or off when the resources are firmware-managed. The interconnect paths
are not requested for firmware-managed platforms.
The domains are voted on and off directly through runtime PM, whose
usage counting keeps each domain enabled for as long as it is required;
the driver does not attempt to track or infer any aggregate device power
state, nor does it assume what state firmware or the bootloader left the
domains in before probe.
Runtime suspend/resume vote only the "bus" domain, since the "power"
domain must remain enabled for hardware accesses that can occur while
runtime suspended. System suspend/resume vote both domains.
If system suspend is entered while the device is already runtime
suspended, only the "power" vote is still held, so system suspend
drops just that one. System resume then votes both domains back on,
which keeps the votes balanced across the cycle.
The domains are attached with devm_pm_domain_attach_list() and
PD_FLAG_NO_DEV_LINK, because runtime suspend and system suspend require
different supplier states. Runtime suspend releases only the "bus"
domain while retaining the "power" domain, whereas system suspend
releases both domains. Ordinary device-links would couple both
suppliers to the same consumer runtime PM state and therefore cannot
express the required policy. The driver consequently manages the
runtime PM references for the attached domains explicitly.
pm_runtime_put_sync() drops the domain usage count even when it
returns an error, so failures to vote a domain off are only reported.
Failing suspend on them would leave the driver thinking the votes are
still held and unbalance the next resume/suspend pair.
Enable firmware-managed resource handling for the "qcom,sa8255p-dwc3"
compatible while maintaining backward compatibility with existing
platforms that use direct resource control.
The probe error path now disables the resources through the common
helper, which also disables the interconnect paths. Clear the path
handles when dwc3_qcom_interconnect_init() fails, so the unwind does not
touch handles that were already released or never obtained.
Co-developed-by: Shazad Hussain <shazad.hussain@oss.qualcomm.com>
Signed-off-by: Shazad Hussain <shazad.hussain@oss.qualcomm.com>
Co-developed-by: Sriram Dash <sriram.dash@oss.qualcomm.com>
Signed-off-by: Sriram Dash <sriram.dash@oss.qualcomm.com>
Signed-off-by: Faisal Hassan <faisal.hassan@oss.qualcomm.com>
---
drivers/usb/dwc3/dwc3-qcom.c | 244 +++++++++++++++++++++++++++++++----
1 file changed, 222 insertions(+), 22 deletions(-)
diff --git a/drivers/usb/dwc3/dwc3-qcom.c b/drivers/usb/dwc3/dwc3-qcom.c
index 61a3e3c38f59..559de5172e61 100644
--- a/drivers/usb/dwc3/dwc3-qcom.c
+++ b/drivers/usb/dwc3/dwc3-qcom.c
@@ -13,6 +13,7 @@
#include <linux/kernel.h>
#include <linux/interconnect.h>
#include <linux/platform_device.h>
+#include <linux/pm_domain.h>
#include <linux/phy/phy.h>
#include <linux/usb/of.h>
#include <linux/reset.h>
@@ -70,6 +71,7 @@ struct dwc3_qcom_port {
struct dwc3_qcom_priv_data {
bool power_lost_in_suspend;
+ bool fw_managed;
};
struct dwc3_qcom {
@@ -92,10 +94,26 @@ struct dwc3_qcom {
enum usb_role current_role;
bool power_lost_in_suspend;
+
+ bool fw_managed;
+ struct dev_pm_domain_list *pd_list;
+};
+
+/* Firmware-managed power domains, indexed in pd_list->pd_devs[] */
+enum dwc3_qcom_pd {
+ DWC3_QCOM_PD_POWER,
+ DWC3_QCOM_PD_BUS,
+ DWC3_QCOM_NUM_PD,
+};
+
+static const char * const dwc3_qcom_pd_names[] = {
+ [DWC3_QCOM_PD_POWER] = "power",
+ [DWC3_QCOM_PD_BUS] = "bus",
};
static const struct dwc3_qcom_priv_data sa8255p_dwc3_qcom_priv_data = {
.power_lost_in_suspend = true,
+ .fw_managed = true,
};
#define to_dwc3_qcom(d) container_of((d), struct dwc3_qcom, dwc)
@@ -169,6 +187,164 @@ static int dwc3_qcom_interconnect_disable(struct dwc3_qcom *qcom)
return ret;
}
+/*
+ * Firmware-managed resources
+ *
+ * Firmware owns the clocks, interconnects and GDSC and exposes them as two
+ * power domains:
+ * - DWC3_QCOM_PD_POWER ("power"): the GDSC supplying the controller
+ * - DWC3_QCOM_PD_BUS ("bus"): clocks and interconnects, which also need
+ * "power" to be on for register accesses to succeed
+ *
+ * The domains are voted directly from the PM callbacks. The driver does not
+ * mirror the aggregate state, as the real state lives in firmware.
+ */
+
+/**
+ * dwc3_qcom_domain_attach() - Attach power domains
+ * @qcom: Pointer to the dwc3_qcom structure
+ *
+ * Attaches power domains for firmware managed resource handling. The
+ * domains are detached automatically when the driver is unbound.
+ * Returns 0 on success, negative error code on failure.
+ */
+static int dwc3_qcom_domain_attach(struct dwc3_qcom *qcom)
+{
+ struct dev_pm_domain_attach_data pd_data = {
+ /* Runtime and system suspend need different supplier states */
+ .pd_flags = PD_FLAG_NO_DEV_LINK,
+ .pd_names = dwc3_qcom_pd_names,
+ .num_pd_names = DWC3_QCOM_NUM_PD,
+ };
+ struct device *dev = qcom->dev;
+ int ret;
+
+ ret = devm_pm_domain_attach_list(dev, &pd_data, &qcom->pd_list);
+ if (ret != pd_data.num_pd_names) {
+ dev_err(dev, "domain attach failed (%d)\n", ret);
+ return ret < 0 ? ret : -ENODEV;
+ }
+
+ return 0;
+}
+
+/**
+ * dwc3_qcom_power_domain_put() - Vote the power domain off
+ * @qcom: Pointer to the dwc3_qcom structure
+ *
+ * pm_runtime_put_sync() drops the usage count even on error, so only warn.
+ * Failing the caller would make it think the vote is still held and
+ * unbalance the next get/put pair.
+ */
+static void dwc3_qcom_power_domain_put(struct dwc3_qcom *qcom)
+{
+ int ret;
+
+ ret = pm_runtime_put_sync(qcom->pd_list->pd_devs[DWC3_QCOM_PD_POWER]);
+ if (ret < 0)
+ dev_warn(qcom->dev, "failed to disable power domain: %d\n", ret);
+}
+
+/**
+ * dwc3_qcom_domains_get() - Vote the firmware-managed domains on
+ * @qcom: Pointer to the dwc3_qcom structure
+ * @bus_only: If true, leave the power domain untouched and only vote bus
+ *
+ * Each call must be paired with dwc3_qcom_domains_put() using the same
+ * @bus_only. Runtime PM usage counting keeps a domain on for as long as it
+ * is needed, regardless of the state firmware left it in.
+ * Returns 0 on success, negative error code on failure.
+ */
+static int dwc3_qcom_domains_get(struct dwc3_qcom *qcom, bool bus_only)
+{
+ struct device *power_dev = qcom->pd_list->pd_devs[DWC3_QCOM_PD_POWER];
+ struct device *bus_dev = qcom->pd_list->pd_devs[DWC3_QCOM_PD_BUS];
+ int ret;
+
+ if (!bus_only) {
+ ret = pm_runtime_resume_and_get(power_dev);
+ if (ret) {
+ dev_err(qcom->dev, "failed to enable power domain: %d\n", ret);
+ return ret;
+ }
+ }
+
+ ret = pm_runtime_resume_and_get(bus_dev);
+ if (ret) {
+ dev_err(qcom->dev, "failed to enable bus domain: %d\n", ret);
+ if (!bus_only)
+ pm_runtime_put_sync(power_dev);
+ return ret;
+ }
+
+ return 0;
+}
+
+/**
+ * dwc3_qcom_domains_put() - Vote the firmware-managed domains off
+ * @qcom: Pointer to the dwc3_qcom structure
+ * @bus_only: If true, leave the power domain untouched and only vote bus
+ *
+ * Bus is released before power, as bus accesses need power to be on.
+ */
+static void dwc3_qcom_domains_put(struct dwc3_qcom *qcom, bool bus_only)
+{
+ int ret;
+
+ ret = pm_runtime_put_sync(qcom->pd_list->pd_devs[DWC3_QCOM_PD_BUS]);
+ if (ret < 0)
+ dev_warn(qcom->dev, "failed to disable bus domain: %d\n", ret);
+
+ if (!bus_only)
+ dwc3_qcom_power_domain_put(qcom);
+}
+
+/**
+ * dwc3_qcom_resources_enable() - Enable clocks and interconnect, or vote domains on
+ * @qcom: Pointer to the dwc3_qcom structure
+ * @bus_only: Firmware-managed only: leave the power domain untouched
+ *
+ * Returns 0 on success, negative error code on failure.
+ */
+static int dwc3_qcom_resources_enable(struct dwc3_qcom *qcom, bool bus_only)
+{
+ int ret;
+
+ if (qcom->fw_managed)
+ return dwc3_qcom_domains_get(qcom, bus_only);
+
+ ret = clk_bulk_prepare_enable(qcom->num_clocks, qcom->clks);
+ if (ret < 0)
+ return ret;
+
+ ret = dwc3_qcom_interconnect_enable(qcom);
+ if (ret)
+ dev_warn(qcom->dev, "failed to enable interconnect: %d\n", ret);
+
+ return 0;
+}
+
+/**
+ * dwc3_qcom_resources_disable() - Undo dwc3_qcom_resources_enable()
+ * @qcom: Pointer to the dwc3_qcom structure
+ * @bus_only: Firmware-managed only: leave the power domain untouched
+ */
+static void dwc3_qcom_resources_disable(struct dwc3_qcom *qcom, bool bus_only)
+{
+ int ret;
+
+ if (qcom->fw_managed) {
+ dwc3_qcom_domains_put(qcom, bus_only);
+ return;
+ }
+
+ clk_bulk_disable_unprepare(qcom->num_clocks, qcom->clks);
+
+ ret = dwc3_qcom_interconnect_disable(qcom);
+ if (ret)
+ dev_warn(qcom->dev, "failed to disable interconnect: %d\n", ret);
+}
+
/**
* dwc3_qcom_interconnect_init() - Get interconnect path handles
* and set bandwidth.
@@ -181,10 +357,16 @@ static int dwc3_qcom_interconnect_init(struct dwc3_qcom *qcom)
struct device *dev = qcom->dev;
int ret;
+ /* Interconnects are managed by firmware */
+ if (qcom->fw_managed)
+ return 0;
+
qcom->icc_path_ddr = of_icc_get(dev, "usb-ddr");
if (IS_ERR(qcom->icc_path_ddr)) {
- return dev_err_probe(dev, PTR_ERR(qcom->icc_path_ddr),
- "failed to get usb-ddr path\n");
+ ret = dev_err_probe(dev, PTR_ERR(qcom->icc_path_ddr),
+ "failed to get usb-ddr path\n");
+ qcom->icc_path_ddr = NULL;
+ return ret;
}
qcom->icc_path_apps = of_icc_get(dev, "apps-usb");
@@ -219,6 +401,9 @@ static int dwc3_qcom_interconnect_init(struct dwc3_qcom *qcom)
icc_put(qcom->icc_path_apps);
put_path_ddr:
icc_put(qcom->icc_path_ddr);
+ /* Leave no stale handles for the error unwind to disable */
+ qcom->icc_path_ddr = NULL;
+ qcom->icc_path_apps = NULL;
return ret;
}
@@ -369,7 +554,7 @@ static int dwc3_qcom_suspend(struct dwc3_qcom *qcom, pm_message_t msg)
{
bool wakeup = dwc3_qcom_wakeup_enabled(qcom, msg);
u32 val;
- int i, ret;
+ int i;
if (qcom->is_suspended) {
/*
@@ -379,6 +564,15 @@ static int dwc3_qcom_suspend(struct dwc3_qcom *qcom, pm_message_t msg)
*/
if (dwc3_qcom_is_host(qcom) && !wakeup)
dwc3_qcom_disable_interrupts(qcom);
+
+ /*
+ * Runtime suspend dropped only the bus domain. System suspend
+ * must drop the power domain too, so that system resume, which
+ * votes both domains back on, stays balanced.
+ */
+ if (qcom->fw_managed && !PMSG_IS_AUTO(msg))
+ dwc3_qcom_power_domain_put(qcom);
+
return 0;
}
@@ -387,11 +581,9 @@ static int dwc3_qcom_suspend(struct dwc3_qcom *qcom, pm_message_t msg)
if (!(val & PWR_EVNT_LPM_IN_L2_MASK))
dev_err(qcom->dev, "port-%d HS-PHY not in L2\n", i + 1);
}
- clk_bulk_disable_unprepare(qcom->num_clocks, qcom->clks);
- ret = dwc3_qcom_interconnect_disable(qcom);
- if (ret)
- dev_warn(qcom->dev, "failed to disable interconnect: %d\n", ret);
+ /* Runtime suspend keeps power voted on; system suspend drops both. */
+ dwc3_qcom_resources_disable(qcom, PMSG_IS_AUTO(msg));
/*
* The role is stable during suspend as role switching is done from a
@@ -442,13 +634,10 @@ static int dwc3_qcom_resume(struct dwc3_qcom *qcom, pm_message_t msg)
if (dwc3_qcom_is_host(qcom) && wakeup)
dwc3_qcom_disable_interrupts(qcom);
- ret = clk_bulk_prepare_enable(qcom->num_clocks, qcom->clks);
- if (ret < 0)
- return ret;
-
- ret = dwc3_qcom_interconnect_enable(qcom);
+ /* Runtime resume re-votes bus only; system resume votes both. */
+ ret = dwc3_qcom_resources_enable(qcom, PMSG_IS_AUTO(msg));
if (ret)
- dev_warn(qcom->dev, "failed to enable interconnect: %d\n", ret);
+ return ret;
/* Clear existing events from PHY related to L2 in/out */
for (i = 0; i < qcom->num_ports; i++) {
@@ -696,8 +885,10 @@ static int dwc3_qcom_probe(struct platform_device *pdev)
qcom->dev = &pdev->dev;
priv_data = of_device_get_match_data(dev);
- if (priv_data)
+ if (priv_data) {
qcom->power_lost_in_suspend = priv_data->power_lost_in_suspend;
+ qcom->fw_managed = priv_data->fw_managed;
+ }
qcom->resets = devm_reset_control_array_get_optional_exclusive(dev);
if (IS_ERR(qcom->resets)) {
@@ -705,10 +896,16 @@ static int dwc3_qcom_probe(struct platform_device *pdev)
"failed to get resets\n");
}
- ret = devm_clk_bulk_get_all(&pdev->dev, &qcom->clks);
- if (ret < 0)
- return dev_err_probe(dev, ret, "failed to get clocks\n");
- qcom->num_clocks = ret;
+ if (!qcom->fw_managed) {
+ ret = devm_clk_bulk_get_all(&pdev->dev, &qcom->clks);
+ if (ret < 0)
+ return dev_err_probe(dev, ret, "failed to get clocks\n");
+ qcom->num_clocks = ret;
+ } else {
+ ret = dwc3_qcom_domain_attach(qcom);
+ if (ret)
+ return ret;
+ }
ret = reset_control_assert(qcom->resets);
if (ret) {
@@ -724,9 +921,12 @@ static int dwc3_qcom_probe(struct platform_device *pdev)
return ret;
}
- ret = clk_bulk_prepare_enable(qcom->num_clocks, qcom->clks);
- if (ret < 0)
+ /* Takes the votes whatever state firmware or the bootloader left */
+ ret = dwc3_qcom_resources_enable(qcom, false);
+ if (ret) {
+ reset_control_assert(qcom->resets);
return ret;
+ }
r = platform_get_resource(pdev, IORESOURCE_MEM, 0);
if (!r) {
@@ -805,7 +1005,7 @@ static int dwc3_qcom_probe(struct platform_device *pdev)
dwc3_core_remove(&qcom->dwc);
clk_disable:
reset_control_assert(qcom->resets);
- clk_bulk_disable_unprepare(qcom->num_clocks, qcom->clks);
+ dwc3_qcom_resources_disable(qcom, false);
return ret;
}
@@ -820,7 +1020,7 @@ static void dwc3_qcom_remove(struct platform_device *pdev)
dwc3_core_remove(&qcom->dwc);
reset_control_assert(qcom->resets);
- clk_bulk_disable_unprepare(qcom->num_clocks, qcom->clks);
+ dwc3_qcom_resources_disable(qcom, false);
dwc3_qcom_interconnect_exit(qcom);
pm_runtime_put_noidle(qcom->dev);
--
2.34.1
^ permalink raw reply [flat|nested] 23+ messages in thread* Re: [PATCH v5 10/11] usb: dwc3: qcom: Support firmware-managed resource states for power management
2026-11-23 10:47 ` [PATCH v5 10/11] usb: dwc3: qcom: Support firmware-managed resource states for power management Faisal Hassan
@ 2026-11-26 10:09 ` Peter Chen
0 siblings, 0 replies; 23+ messages in thread
From: Peter Chen @ 2026-11-26 10:09 UTC (permalink / raw)
To: Faisal Hassan
Cc: Thinh.Nguyen, gregkh, Philipp Zabel, linux-usb, linux-arm-msm,
linux-kernel, devicetree, krishna.kurapati, krzysztof.kozlowski,
Shazad Hussain, Sriram Dash
On 26-11-23 16:17:25, Faisal Hassan wrote:
> Add support for firmware-managed resource handling in the Qualcomm
> DWC3 USB controller driver. On platforms such as SA8255P, controller
> resources are abstracted and managed collectively by firmware, and are
> exposed to Linux through SCMI-backed power domains.
>
> On SA8255P, resources such as clocks, regulators, resets, TLMM and
> interconnects are controlled by firmware. The driver communicates with
> firmware through two power domains:
>
> - "power": controls power supply (GDSC) to the USB controller
> - "bus": controls clocks and interconnects used for data transfer.
> Register accesses through the controller require the "power"
> domain to be enabled.
>
> The clock and interconnect handling in the suspend, resume, probe and
> remove paths is moved behind dwc3_qcom_resources_enable() and
> dwc3_qcom_resources_disable(). They enable or disable the clocks and
> interconnect paths on existing platforms, and vote the two domains on
> or off when the resources are firmware-managed. The interconnect paths
> are not requested for firmware-managed platforms.
>
> The domains are voted on and off directly through runtime PM, whose
> usage counting keeps each domain enabled for as long as it is required;
> the driver does not attempt to track or infer any aggregate device power
> state, nor does it assume what state firmware or the bootloader left the
> domains in before probe.
>
> Runtime suspend/resume vote only the "bus" domain, since the "power"
> domain must remain enabled for hardware accesses that can occur while
> runtime suspended. System suspend/resume vote both domains.
>
> If system suspend is entered while the device is already runtime
> suspended, only the "power" vote is still held, so system suspend
> drops just that one. System resume then votes both domains back on,
> which keeps the votes balanced across the cycle.
>
> The domains are attached with devm_pm_domain_attach_list() and
> PD_FLAG_NO_DEV_LINK, because runtime suspend and system suspend require
> different supplier states. Runtime suspend releases only the "bus"
> domain while retaining the "power" domain, whereas system suspend
> releases both domains. Ordinary device-links would couple both
> suppliers to the same consumer runtime PM state and therefore cannot
> express the required policy. The driver consequently manages the
> runtime PM references for the attached domains explicitly.
>
> pm_runtime_put_sync() drops the domain usage count even when it
> returns an error, so failures to vote a domain off are only reported.
> Failing suspend on them would leave the driver thinking the votes are
> still held and unbalance the next resume/suspend pair.
>
> Enable firmware-managed resource handling for the "qcom,sa8255p-dwc3"
> compatible while maintaining backward compatibility with existing
> platforms that use direct resource control.
>
> The probe error path now disables the resources through the common
> helper, which also disables the interconnect paths. Clear the path
> handles when dwc3_qcom_interconnect_init() fails, so the unwind does not
> touch handles that were already released or never obtained.
>
> Co-developed-by: Shazad Hussain <shazad.hussain@oss.qualcomm.com>
> Signed-off-by: Shazad Hussain <shazad.hussain@oss.qualcomm.com>
> Co-developed-by: Sriram Dash <sriram.dash@oss.qualcomm.com>
> Signed-off-by: Sriram Dash <sriram.dash@oss.qualcomm.com>
> Signed-off-by: Faisal Hassan <faisal.hassan@oss.qualcomm.com>
Reviewed-by: Peter Chen <peter.chen@oss.qualcomm.com>
Peter
> ---
> drivers/usb/dwc3/dwc3-qcom.c | 244 +++++++++++++++++++++++++++++++----
> 1 file changed, 222 insertions(+), 22 deletions(-)
>
> diff --git a/drivers/usb/dwc3/dwc3-qcom.c b/drivers/usb/dwc3/dwc3-qcom.c
> index 61a3e3c38f59..559de5172e61 100644
> --- a/drivers/usb/dwc3/dwc3-qcom.c
> +++ b/drivers/usb/dwc3/dwc3-qcom.c
> @@ -13,6 +13,7 @@
> #include <linux/kernel.h>
> #include <linux/interconnect.h>
> #include <linux/platform_device.h>
> +#include <linux/pm_domain.h>
> #include <linux/phy/phy.h>
> #include <linux/usb/of.h>
> #include <linux/reset.h>
> @@ -70,6 +71,7 @@ struct dwc3_qcom_port {
>
> struct dwc3_qcom_priv_data {
> bool power_lost_in_suspend;
> + bool fw_managed;
> };
>
> struct dwc3_qcom {
> @@ -92,10 +94,26 @@ struct dwc3_qcom {
> enum usb_role current_role;
>
> bool power_lost_in_suspend;
> +
> + bool fw_managed;
> + struct dev_pm_domain_list *pd_list;
> +};
> +
> +/* Firmware-managed power domains, indexed in pd_list->pd_devs[] */
> +enum dwc3_qcom_pd {
> + DWC3_QCOM_PD_POWER,
> + DWC3_QCOM_PD_BUS,
> + DWC3_QCOM_NUM_PD,
> +};
> +
> +static const char * const dwc3_qcom_pd_names[] = {
> + [DWC3_QCOM_PD_POWER] = "power",
> + [DWC3_QCOM_PD_BUS] = "bus",
> };
>
> static const struct dwc3_qcom_priv_data sa8255p_dwc3_qcom_priv_data = {
> .power_lost_in_suspend = true,
> + .fw_managed = true,
> };
>
> #define to_dwc3_qcom(d) container_of((d), struct dwc3_qcom, dwc)
> @@ -169,6 +187,164 @@ static int dwc3_qcom_interconnect_disable(struct dwc3_qcom *qcom)
> return ret;
> }
>
> +/*
> + * Firmware-managed resources
> + *
> + * Firmware owns the clocks, interconnects and GDSC and exposes them as two
> + * power domains:
> + * - DWC3_QCOM_PD_POWER ("power"): the GDSC supplying the controller
> + * - DWC3_QCOM_PD_BUS ("bus"): clocks and interconnects, which also need
> + * "power" to be on for register accesses to succeed
> + *
> + * The domains are voted directly from the PM callbacks. The driver does not
> + * mirror the aggregate state, as the real state lives in firmware.
> + */
> +
> +/**
> + * dwc3_qcom_domain_attach() - Attach power domains
> + * @qcom: Pointer to the dwc3_qcom structure
> + *
> + * Attaches power domains for firmware managed resource handling. The
> + * domains are detached automatically when the driver is unbound.
> + * Returns 0 on success, negative error code on failure.
> + */
> +static int dwc3_qcom_domain_attach(struct dwc3_qcom *qcom)
> +{
> + struct dev_pm_domain_attach_data pd_data = {
> + /* Runtime and system suspend need different supplier states */
> + .pd_flags = PD_FLAG_NO_DEV_LINK,
> + .pd_names = dwc3_qcom_pd_names,
> + .num_pd_names = DWC3_QCOM_NUM_PD,
> + };
> + struct device *dev = qcom->dev;
> + int ret;
> +
> + ret = devm_pm_domain_attach_list(dev, &pd_data, &qcom->pd_list);
> + if (ret != pd_data.num_pd_names) {
> + dev_err(dev, "domain attach failed (%d)\n", ret);
> + return ret < 0 ? ret : -ENODEV;
> + }
> +
> + return 0;
> +}
> +
> +/**
> + * dwc3_qcom_power_domain_put() - Vote the power domain off
> + * @qcom: Pointer to the dwc3_qcom structure
> + *
> + * pm_runtime_put_sync() drops the usage count even on error, so only warn.
> + * Failing the caller would make it think the vote is still held and
> + * unbalance the next get/put pair.
> + */
> +static void dwc3_qcom_power_domain_put(struct dwc3_qcom *qcom)
> +{
> + int ret;
> +
> + ret = pm_runtime_put_sync(qcom->pd_list->pd_devs[DWC3_QCOM_PD_POWER]);
> + if (ret < 0)
> + dev_warn(qcom->dev, "failed to disable power domain: %d\n", ret);
> +}
> +
> +/**
> + * dwc3_qcom_domains_get() - Vote the firmware-managed domains on
> + * @qcom: Pointer to the dwc3_qcom structure
> + * @bus_only: If true, leave the power domain untouched and only vote bus
> + *
> + * Each call must be paired with dwc3_qcom_domains_put() using the same
> + * @bus_only. Runtime PM usage counting keeps a domain on for as long as it
> + * is needed, regardless of the state firmware left it in.
> + * Returns 0 on success, negative error code on failure.
> + */
> +static int dwc3_qcom_domains_get(struct dwc3_qcom *qcom, bool bus_only)
> +{
> + struct device *power_dev = qcom->pd_list->pd_devs[DWC3_QCOM_PD_POWER];
> + struct device *bus_dev = qcom->pd_list->pd_devs[DWC3_QCOM_PD_BUS];
> + int ret;
> +
> + if (!bus_only) {
> + ret = pm_runtime_resume_and_get(power_dev);
> + if (ret) {
> + dev_err(qcom->dev, "failed to enable power domain: %d\n", ret);
> + return ret;
> + }
> + }
> +
> + ret = pm_runtime_resume_and_get(bus_dev);
> + if (ret) {
> + dev_err(qcom->dev, "failed to enable bus domain: %d\n", ret);
> + if (!bus_only)
> + pm_runtime_put_sync(power_dev);
> + return ret;
> + }
> +
> + return 0;
> +}
> +
> +/**
> + * dwc3_qcom_domains_put() - Vote the firmware-managed domains off
> + * @qcom: Pointer to the dwc3_qcom structure
> + * @bus_only: If true, leave the power domain untouched and only vote bus
> + *
> + * Bus is released before power, as bus accesses need power to be on.
> + */
> +static void dwc3_qcom_domains_put(struct dwc3_qcom *qcom, bool bus_only)
> +{
> + int ret;
> +
> + ret = pm_runtime_put_sync(qcom->pd_list->pd_devs[DWC3_QCOM_PD_BUS]);
> + if (ret < 0)
> + dev_warn(qcom->dev, "failed to disable bus domain: %d\n", ret);
> +
> + if (!bus_only)
> + dwc3_qcom_power_domain_put(qcom);
> +}
> +
> +/**
> + * dwc3_qcom_resources_enable() - Enable clocks and interconnect, or vote domains on
> + * @qcom: Pointer to the dwc3_qcom structure
> + * @bus_only: Firmware-managed only: leave the power domain untouched
> + *
> + * Returns 0 on success, negative error code on failure.
> + */
> +static int dwc3_qcom_resources_enable(struct dwc3_qcom *qcom, bool bus_only)
> +{
> + int ret;
> +
> + if (qcom->fw_managed)
> + return dwc3_qcom_domains_get(qcom, bus_only);
> +
> + ret = clk_bulk_prepare_enable(qcom->num_clocks, qcom->clks);
> + if (ret < 0)
> + return ret;
> +
> + ret = dwc3_qcom_interconnect_enable(qcom);
> + if (ret)
> + dev_warn(qcom->dev, "failed to enable interconnect: %d\n", ret);
> +
> + return 0;
> +}
> +
> +/**
> + * dwc3_qcom_resources_disable() - Undo dwc3_qcom_resources_enable()
> + * @qcom: Pointer to the dwc3_qcom structure
> + * @bus_only: Firmware-managed only: leave the power domain untouched
> + */
> +static void dwc3_qcom_resources_disable(struct dwc3_qcom *qcom, bool bus_only)
> +{
> + int ret;
> +
> + if (qcom->fw_managed) {
> + dwc3_qcom_domains_put(qcom, bus_only);
> + return;
> + }
> +
> + clk_bulk_disable_unprepare(qcom->num_clocks, qcom->clks);
> +
> + ret = dwc3_qcom_interconnect_disable(qcom);
> + if (ret)
> + dev_warn(qcom->dev, "failed to disable interconnect: %d\n", ret);
> +}
> +
> /**
> * dwc3_qcom_interconnect_init() - Get interconnect path handles
> * and set bandwidth.
> @@ -181,10 +357,16 @@ static int dwc3_qcom_interconnect_init(struct dwc3_qcom *qcom)
> struct device *dev = qcom->dev;
> int ret;
>
> + /* Interconnects are managed by firmware */
> + if (qcom->fw_managed)
> + return 0;
> +
> qcom->icc_path_ddr = of_icc_get(dev, "usb-ddr");
> if (IS_ERR(qcom->icc_path_ddr)) {
> - return dev_err_probe(dev, PTR_ERR(qcom->icc_path_ddr),
> - "failed to get usb-ddr path\n");
> + ret = dev_err_probe(dev, PTR_ERR(qcom->icc_path_ddr),
> + "failed to get usb-ddr path\n");
> + qcom->icc_path_ddr = NULL;
> + return ret;
> }
>
> qcom->icc_path_apps = of_icc_get(dev, "apps-usb");
> @@ -219,6 +401,9 @@ static int dwc3_qcom_interconnect_init(struct dwc3_qcom *qcom)
> icc_put(qcom->icc_path_apps);
> put_path_ddr:
> icc_put(qcom->icc_path_ddr);
> + /* Leave no stale handles for the error unwind to disable */
> + qcom->icc_path_ddr = NULL;
> + qcom->icc_path_apps = NULL;
> return ret;
> }
>
> @@ -369,7 +554,7 @@ static int dwc3_qcom_suspend(struct dwc3_qcom *qcom, pm_message_t msg)
> {
> bool wakeup = dwc3_qcom_wakeup_enabled(qcom, msg);
> u32 val;
> - int i, ret;
> + int i;
>
> if (qcom->is_suspended) {
> /*
> @@ -379,6 +564,15 @@ static int dwc3_qcom_suspend(struct dwc3_qcom *qcom, pm_message_t msg)
> */
> if (dwc3_qcom_is_host(qcom) && !wakeup)
> dwc3_qcom_disable_interrupts(qcom);
> +
> + /*
> + * Runtime suspend dropped only the bus domain. System suspend
> + * must drop the power domain too, so that system resume, which
> + * votes both domains back on, stays balanced.
> + */
> + if (qcom->fw_managed && !PMSG_IS_AUTO(msg))
> + dwc3_qcom_power_domain_put(qcom);
> +
> return 0;
> }
>
> @@ -387,11 +581,9 @@ static int dwc3_qcom_suspend(struct dwc3_qcom *qcom, pm_message_t msg)
> if (!(val & PWR_EVNT_LPM_IN_L2_MASK))
> dev_err(qcom->dev, "port-%d HS-PHY not in L2\n", i + 1);
> }
> - clk_bulk_disable_unprepare(qcom->num_clocks, qcom->clks);
>
> - ret = dwc3_qcom_interconnect_disable(qcom);
> - if (ret)
> - dev_warn(qcom->dev, "failed to disable interconnect: %d\n", ret);
> + /* Runtime suspend keeps power voted on; system suspend drops both. */
> + dwc3_qcom_resources_disable(qcom, PMSG_IS_AUTO(msg));
>
> /*
> * The role is stable during suspend as role switching is done from a
> @@ -442,13 +634,10 @@ static int dwc3_qcom_resume(struct dwc3_qcom *qcom, pm_message_t msg)
> if (dwc3_qcom_is_host(qcom) && wakeup)
> dwc3_qcom_disable_interrupts(qcom);
>
> - ret = clk_bulk_prepare_enable(qcom->num_clocks, qcom->clks);
> - if (ret < 0)
> - return ret;
> -
> - ret = dwc3_qcom_interconnect_enable(qcom);
> + /* Runtime resume re-votes bus only; system resume votes both. */
> + ret = dwc3_qcom_resources_enable(qcom, PMSG_IS_AUTO(msg));
> if (ret)
> - dev_warn(qcom->dev, "failed to enable interconnect: %d\n", ret);
> + return ret;
>
> /* Clear existing events from PHY related to L2 in/out */
> for (i = 0; i < qcom->num_ports; i++) {
> @@ -696,8 +885,10 @@ static int dwc3_qcom_probe(struct platform_device *pdev)
> qcom->dev = &pdev->dev;
>
> priv_data = of_device_get_match_data(dev);
> - if (priv_data)
> + if (priv_data) {
> qcom->power_lost_in_suspend = priv_data->power_lost_in_suspend;
> + qcom->fw_managed = priv_data->fw_managed;
> + }
>
> qcom->resets = devm_reset_control_array_get_optional_exclusive(dev);
> if (IS_ERR(qcom->resets)) {
> @@ -705,10 +896,16 @@ static int dwc3_qcom_probe(struct platform_device *pdev)
> "failed to get resets\n");
> }
>
> - ret = devm_clk_bulk_get_all(&pdev->dev, &qcom->clks);
> - if (ret < 0)
> - return dev_err_probe(dev, ret, "failed to get clocks\n");
> - qcom->num_clocks = ret;
> + if (!qcom->fw_managed) {
> + ret = devm_clk_bulk_get_all(&pdev->dev, &qcom->clks);
> + if (ret < 0)
> + return dev_err_probe(dev, ret, "failed to get clocks\n");
> + qcom->num_clocks = ret;
> + } else {
> + ret = dwc3_qcom_domain_attach(qcom);
> + if (ret)
> + return ret;
> + }
>
> ret = reset_control_assert(qcom->resets);
> if (ret) {
> @@ -724,9 +921,12 @@ static int dwc3_qcom_probe(struct platform_device *pdev)
> return ret;
> }
>
> - ret = clk_bulk_prepare_enable(qcom->num_clocks, qcom->clks);
> - if (ret < 0)
> + /* Takes the votes whatever state firmware or the bootloader left */
> + ret = dwc3_qcom_resources_enable(qcom, false);
> + if (ret) {
> + reset_control_assert(qcom->resets);
> return ret;
> + }
>
> r = platform_get_resource(pdev, IORESOURCE_MEM, 0);
> if (!r) {
> @@ -805,7 +1005,7 @@ static int dwc3_qcom_probe(struct platform_device *pdev)
> dwc3_core_remove(&qcom->dwc);
> clk_disable:
> reset_control_assert(qcom->resets);
> - clk_bulk_disable_unprepare(qcom->num_clocks, qcom->clks);
> + dwc3_qcom_resources_disable(qcom, false);
>
> return ret;
> }
> @@ -820,7 +1020,7 @@ static void dwc3_qcom_remove(struct platform_device *pdev)
>
> dwc3_core_remove(&qcom->dwc);
> reset_control_assert(qcom->resets);
> - clk_bulk_disable_unprepare(qcom->num_clocks, qcom->clks);
> + dwc3_qcom_resources_disable(qcom, false);
> dwc3_qcom_interconnect_exit(qcom);
>
> pm_runtime_put_noidle(qcom->dev);
> --
> 2.34.1
>
--
Thanks,
Peter Chen
^ permalink raw reply [flat|nested] 23+ messages in thread
* [PATCH v5 11/11] usb: dwc3: qcom: Enable VBUS override at probe for default peripheral role
2026-11-23 10:47 [PATCH v5 00/11] usb: dwc3: qcom: Add firmware-managed resource support for SA8255P Faisal Hassan
` (9 preceding siblings ...)
2026-11-23 10:47 ` [PATCH v5 10/11] usb: dwc3: qcom: Support firmware-managed resource states for power management Faisal Hassan
@ 2026-11-23 10:47 ` Faisal Hassan
2026-11-26 10:12 ` Peter Chen
2026-11-26 17:34 ` Krishna Kurapati
10 siblings, 2 replies; 23+ messages in thread
From: Faisal Hassan @ 2026-11-23 10:47 UTC (permalink / raw)
To: Thinh.Nguyen, gregkh
Cc: linux-usb, linux-arm-msm, linux-kernel, devicetree,
krishna.kurapati, peter.chen, krzysztof.kozlowski, Faisal Hassan
When the controller is in OTG mode with usb-role-switch and
role-switch-default-mode set to peripheral, the role notifier never sees
a transition at probe, so the QSCRATCH VBUS override is not programmed
and the device never gets a session-valid indication.
Enable the VBUS override once at probe, after the initial role has been
determined, whenever that role is USB_ROLE_DEVICE. This also covers the
dr_mode = "peripheral" case, which previously programmed the override on
its own.
Validated on SA8255P with an HS host attached: 20 unbind/bind and 20
suspend/resume iterations completed with no failures.
Signed-off-by: Faisal Hassan <faisal.hassan@oss.qualcomm.com>
---
drivers/usb/dwc3/dwc3-qcom.c | 5 ++++-
1 file changed, 4 insertions(+), 1 deletion(-)
diff --git a/drivers/usb/dwc3/dwc3-qcom.c b/drivers/usb/dwc3/dwc3-qcom.c
index 559de5172e61..22b6c7ca0297 100644
--- a/drivers/usb/dwc3/dwc3-qcom.c
+++ b/drivers/usb/dwc3/dwc3-qcom.c
@@ -964,7 +964,6 @@ static int dwc3_qcom_probe(struct platform_device *pdev)
qcom->current_role = USB_ROLE_HOST;
} else if (qcom->mode == USB_DR_MODE_PERIPHERAL) {
qcom->current_role = USB_ROLE_DEVICE;
- dwc3_qcom_vbus_override_enable(qcom, true);
} else {
if ((device_property_read_bool(dev, "usb-role-switch")) &&
(usb_get_role_switch_default_mode(dev) == USB_DR_MODE_HOST))
@@ -973,6 +972,10 @@ static int dwc3_qcom_probe(struct platform_device *pdev)
qcom->current_role = USB_ROLE_DEVICE;
}
+ /* Force the VBUS valid indication to the PHYs in device mode */
+ if (qcom->current_role == USB_ROLE_DEVICE)
+ dwc3_qcom_vbus_override_enable(qcom, true);
+
qcom->dwc.glue_ops = &dwc3_qcom_glue_ops;
qcom->dwc.dev = dev;
--
2.34.1
^ permalink raw reply [flat|nested] 23+ messages in thread* Re: [PATCH v5 11/11] usb: dwc3: qcom: Enable VBUS override at probe for default peripheral role
2026-11-23 10:47 ` [PATCH v5 11/11] usb: dwc3: qcom: Enable VBUS override at probe for default peripheral role Faisal Hassan
@ 2026-11-26 10:12 ` Peter Chen
2026-11-26 17:34 ` Krishna Kurapati
1 sibling, 0 replies; 23+ messages in thread
From: Peter Chen @ 2026-11-26 10:12 UTC (permalink / raw)
To: Faisal Hassan
Cc: Thinh.Nguyen, gregkh, linux-usb, linux-arm-msm, linux-kernel,
devicetree, krishna.kurapati, krzysztof.kozlowski
On 26-11-23 16:17:26, Faisal Hassan wrote:
> When the controller is in OTG mode with usb-role-switch and
> role-switch-default-mode set to peripheral, the role notifier never sees
> a transition at probe, so the QSCRATCH VBUS override is not programmed
> and the device never gets a session-valid indication.
>
> Enable the VBUS override once at probe, after the initial role has been
> determined, whenever that role is USB_ROLE_DEVICE. This also covers the
> dr_mode = "peripheral" case, which previously programmed the override on
> its own.
>
> Validated on SA8255P with an HS host attached: 20 unbind/bind and 20
> suspend/resume iterations completed with no failures.
>
> Signed-off-by: Faisal Hassan <faisal.hassan@oss.qualcomm.com>
Reviewed-by: Peter Chen <peter.chen@oss.qualcomm.com>
Peter
> ---
> drivers/usb/dwc3/dwc3-qcom.c | 5 ++++-
> 1 file changed, 4 insertions(+), 1 deletion(-)
>
> diff --git a/drivers/usb/dwc3/dwc3-qcom.c b/drivers/usb/dwc3/dwc3-qcom.c
> index 559de5172e61..22b6c7ca0297 100644
> --- a/drivers/usb/dwc3/dwc3-qcom.c
> +++ b/drivers/usb/dwc3/dwc3-qcom.c
> @@ -964,7 +964,6 @@ static int dwc3_qcom_probe(struct platform_device *pdev)
> qcom->current_role = USB_ROLE_HOST;
> } else if (qcom->mode == USB_DR_MODE_PERIPHERAL) {
> qcom->current_role = USB_ROLE_DEVICE;
> - dwc3_qcom_vbus_override_enable(qcom, true);
> } else {
> if ((device_property_read_bool(dev, "usb-role-switch")) &&
> (usb_get_role_switch_default_mode(dev) == USB_DR_MODE_HOST))
> @@ -973,6 +972,10 @@ static int dwc3_qcom_probe(struct platform_device *pdev)
> qcom->current_role = USB_ROLE_DEVICE;
> }
>
> + /* Force the VBUS valid indication to the PHYs in device mode */
> + if (qcom->current_role == USB_ROLE_DEVICE)
> + dwc3_qcom_vbus_override_enable(qcom, true);
> +
> qcom->dwc.glue_ops = &dwc3_qcom_glue_ops;
>
> qcom->dwc.dev = dev;
> --
> 2.34.1
>
--
Thanks,
Peter Chen
^ permalink raw reply [flat|nested] 23+ messages in thread* Re: [PATCH v5 11/11] usb: dwc3: qcom: Enable VBUS override at probe for default peripheral role
2026-11-23 10:47 ` [PATCH v5 11/11] usb: dwc3: qcom: Enable VBUS override at probe for default peripheral role Faisal Hassan
2026-11-26 10:12 ` Peter Chen
@ 2026-11-26 17:34 ` Krishna Kurapati
1 sibling, 0 replies; 23+ messages in thread
From: Krishna Kurapati @ 2026-11-26 17:34 UTC (permalink / raw)
To: Faisal Hassan, Thinh.Nguyen, gregkh
Cc: linux-usb, linux-arm-msm, linux-kernel, devicetree, peter.chen,
krzysztof.kozlowski
On 11/23/2026 4:17 PM, Faisal Hassan wrote:
> When the controller is in OTG mode with usb-role-switch and
> role-switch-default-mode set to peripheral, the role notifier never sees
> a transition at probe, so the QSCRATCH VBUS override is not programmed
> and the device never gets a session-valid indication.
>
> Enable the VBUS override once at probe, after the initial role has been
> determined, whenever that role is USB_ROLE_DEVICE. This also covers the
> dr_mode = "peripheral" case, which previously programmed the override on
> its own.
>
> Validated on SA8255P with an HS host attached: 20 unbind/bind and 20
> suspend/resume iterations completed with no failures.
>
> Signed-off-by: Faisal Hassan <faisal.hassan@oss.qualcomm.com>
Reviewed-by: Krishna Kurapati <krishna.kurapati@oss.qualcomm.com>
Regards,
Krishna,
> ---
> drivers/usb/dwc3/dwc3-qcom.c | 5 ++++-
> 1 file changed, 4 insertions(+), 1 deletion(-)
>
> diff --git a/drivers/usb/dwc3/dwc3-qcom.c b/drivers/usb/dwc3/dwc3-qcom.c
> index 559de5172e61..22b6c7ca0297 100644
> --- a/drivers/usb/dwc3/dwc3-qcom.c
> +++ b/drivers/usb/dwc3/dwc3-qcom.c
> @@ -964,7 +964,6 @@ static int dwc3_qcom_probe(struct platform_device *pdev)
> qcom->current_role = USB_ROLE_HOST;
> } else if (qcom->mode == USB_DR_MODE_PERIPHERAL) {
> qcom->current_role = USB_ROLE_DEVICE;
> - dwc3_qcom_vbus_override_enable(qcom, true);
> } else {
> if ((device_property_read_bool(dev, "usb-role-switch")) &&
> (usb_get_role_switch_default_mode(dev) == USB_DR_MODE_HOST))
> @@ -973,6 +972,10 @@ static int dwc3_qcom_probe(struct platform_device *pdev)
> qcom->current_role = USB_ROLE_DEVICE;
> }
>
> + /* Force the VBUS valid indication to the PHYs in device mode */
> + if (qcom->current_role == USB_ROLE_DEVICE)
> + dwc3_qcom_vbus_override_enable(qcom, true);
> +
> qcom->dwc.glue_ops = &dwc3_qcom_glue_ops;
>
> qcom->dwc.dev = dev;
^ permalink raw reply [flat|nested] 23+ messages in thread