From: Peter Chen <peter.chen@oss.qualcomm.com>
To: Faisal Hassan <faisal.hassan@oss.qualcomm.com>
Cc: Thinh.Nguyen@synopsys.com, gregkh@linuxfoundation.org,
Philipp Zabel <p.zabel@pengutronix.de>,
linux-usb@vger.kernel.org, linux-arm-msm@vger.kernel.org,
linux-kernel@vger.kernel.org, devicetree@vger.kernel.org,
krishna.kurapati@oss.qualcomm.com,
krzysztof.kozlowski@oss.qualcomm.com,
Sriram Dash <sriram.dash@oss.qualcomm.com>
Subject: Re: [PATCH v5 07/11] usb: dwc3: qcom: Recover controller state after power loss in system suspend
Date: Thu, 26 Nov 2026 01:52:59 -0800 [thread overview]
Message-ID: <awgBe34JQQ-Z35kz@hu-petche-lv.qualcomm.com> (raw)
In-Reply-To: <20261123104727.1539149-8-faisal.hassan@oss.qualcomm.com>
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
next prev parent reply other threads:[~2026-11-26 9:53 UTC|newest]
Thread overview: 23+ messages / expand[flat|nested] mbox.gz Atom feed top
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-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
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
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
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 ` [PATCH v5 06/11] usb: dwc3: Support resetting the xHCI host on system resume 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
2026-11-26 9:52 ` Peter Chen [this message]
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
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
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
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
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=awgBe34JQQ-Z35kz@hu-petche-lv.qualcomm.com \
--to=peter.chen@oss.qualcomm.com \
--cc=Thinh.Nguyen@synopsys.com \
--cc=devicetree@vger.kernel.org \
--cc=faisal.hassan@oss.qualcomm.com \
--cc=gregkh@linuxfoundation.org \
--cc=krishna.kurapati@oss.qualcomm.com \
--cc=krzysztof.kozlowski@oss.qualcomm.com \
--cc=linux-arm-msm@vger.kernel.org \
--cc=linux-kernel@vger.kernel.org \
--cc=linux-usb@vger.kernel.org \
--cc=p.zabel@pengutronix.de \
--cc=sriram.dash@oss.qualcomm.com \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox
all inboxes | Powered by JetHome®