From: Tapas Rana <tapas.rana@oss.qualcomm.com>
To: Vinod Koul <vkoul@kernel.org>,
Thinh Nguyen <Thinh.Nguyen@synopsys.com>,
Greg Kroah-Hartman <gregkh@linuxfoundation.org>
Cc: Neil Armstrong <neil.armstrong@linaro.org>,
Manivannan Sadhasivam <mani@kernel.org>,
Dmitry Baryshkov <dmitry.baryshkov@oss.qualcomm.com>,
Abel Vesa <abelvesa@kernel.org>,
Konrad Dybcio <konrad.dybcio@oss.qualcomm.com>,
Wesley Cheng <wesley.cheng@oss.qualcomm.com>,
Esteban Urrutia <esteuwu@proton.me>,
Loic Poulain <loic.poulain@oss.qualcomm.com>,
Krishna Kurapati <krishna.kurapati@oss.qualcomm.com>,
Ronak Raheja <ronak.raheja@oss.qualcomm.com>,
Faisal Hassan <faisal.hassan@oss.qualcomm.com>,
Krishna Chaitanya Chundru <krishna.chundru@oss.qualcomm.com>,
prashanth.k@oss.qualcomm.com, linux-arm-msm@vger.kernel.org,
linux-phy@lists.infradead.org, linux-usb@vger.kernel.org,
linux-kernel@vger.kernel.org,
Tapas Rana <tapas.rana@oss.qualcomm.com>
Subject: [PATCH 3/3] usb: dwc3: qcom: pass live SS-link state into PHY at suspend entry
Date: Fri, 6 Nov 2026 13:57:16 +0530 [thread overview]
Message-ID: <20261106082716.128968-4-tapas.rana@oss.qualcomm.com> (raw)
In-Reply-To: <20261106082716.128968-1-tapas.rana@oss.qualcomm.com>
dwc3_qcom_suspend() puts each host port into autonomous/wake mode
without ever telling the PHY whether a SuperSpeed device is currently
attached. qmp_combo_enable_autonomous_mode(), made SS-aware in the
previous patch, therefore has no live signal to act on and always
sees QCOM_USB_SS_UNKNOWN, falling back to the legacy receiver-detect
mask regardless of actual link state.
Add dwc3_qcom_read_ss_state() to check each port's USB3 roothub for
an attached child device running at SuperSpeed or above, and pass the
result as the submode argument of phy_set_mode_ext() so the PHY can
select LFPS detection when appropriate.
Signed-off-by: Tapas Rana <tapas.rana@oss.qualcomm.com>
---
drivers/usb/dwc3/dwc3-qcom.c | 36 +++++++++++++++++++++++++++++++++++-
1 file changed, 35 insertions(+), 1 deletion(-)
diff --git a/drivers/usb/dwc3/dwc3-qcom.c b/drivers/usb/dwc3/dwc3-qcom.c
index ac68b4218b56..d4ba095e47eb 100644
--- a/drivers/usb/dwc3/dwc3-qcom.c
+++ b/drivers/usb/dwc3/dwc3-qcom.c
@@ -19,6 +19,7 @@
#include <linux/iopoll.h>
#include <linux/usb/hcd.h>
#include <linux/usb.h>
+#include <linux/phy/phy-qcom-qmp-usb-ss.h>
#include "core.h"
#include "glue.h"
@@ -66,6 +67,7 @@ struct dwc3_qcom_port {
int dm_hs_phy_irq;
int ss_phy_irq;
enum usb_device_speed usb2_speed;
+ enum qcom_usb_ss_state ss_state;
};
struct dwc3_qcom {
@@ -251,6 +253,34 @@ static enum usb_device_speed dwc3_qcom_read_usb2_speed(struct dwc3_qcom *qcom, i
return udev->speed;
}
+static enum qcom_usb_ss_state dwc3_qcom_read_ss_state(struct dwc3_qcom *qcom, int port_index)
+{
+ struct usb_device *udev;
+ struct usb_hcd __maybe_unused *hcd, *usb3_hcd;
+ struct dwc3 *dwc = &qcom->dwc;
+
+ /*
+ * FIXME: Fix this layering violation.
+ */
+ hcd = platform_get_drvdata(dwc->xhci);
+ if (!hcd)
+ return QCOM_USB_SS_ABSENT;
+
+#ifdef CONFIG_USB
+ usb3_hcd = hcd->shared_hcd ? hcd->shared_hcd : hcd;
+ if (!usb3_hcd->self.root_hub)
+ return QCOM_USB_SS_ABSENT;
+
+ udev = usb_hub_find_child(usb3_hcd->self.root_hub, port_index + 1);
+#else
+ udev = NULL;
+#endif
+ if (!udev)
+ return QCOM_USB_SS_ABSENT;
+
+ return udev->speed >= USB_SPEED_SUPER ? QCOM_USB_SS_PRESENT : QCOM_USB_SS_ABSENT;
+}
+
static void dwc3_qcom_enable_wakeup_irq(int irq, unsigned int polarity)
{
if (!irq)
@@ -359,8 +389,12 @@ static int dwc3_qcom_suspend(struct dwc3_qcom *qcom, bool wakeup)
* freezable workqueue.
*/
if (dwc3_qcom_is_host(qcom) && wakeup) {
- for (i = 0; i < qcom->num_ports; i++)
+ for (i = 0; i < qcom->num_ports; i++) {
qcom->ports[i].usb2_speed = dwc3_qcom_read_usb2_speed(qcom, i);
+ qcom->ports[i].ss_state = dwc3_qcom_read_ss_state(qcom, i);
+ phy_set_mode_ext(qcom->dwc.usb3_generic_phy[i], PHY_MODE_USB_HOST,
+ qcom->ports[i].ss_state);
+ }
dwc3_qcom_enable_interrupts(qcom);
}
--
2.43.0
next prev parent reply other threads:[~2026-11-06 8:27 UTC|newest]
Thread overview: 5+ messages / expand[flat|nested] mbox.gz Atom feed top
2026-11-06 8:27 [PATCH 0/3] phy: qcom: carry live SS-link state without growing enum phy_mode Tapas Rana
2026-11-06 8:27 ` [PATCH 1/3] phy: qcom-qmp-usb-ss: add shared SS-link-state submode contract Tapas Rana
2026-11-06 8:27 ` [PATCH 2/3] phy: qcom: qmp-combo: Select LFPS detect only when SS link is confirmed present Tapas Rana
2026-11-06 8:27 ` Tapas Rana [this message]
2026-11-06 15:06 ` [PATCH 0/3] phy: qcom: carry live SS-link state without growing enum phy_mode Konrad Dybcio
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=20261106082716.128968-4-tapas.rana@oss.qualcomm.com \
--to=tapas.rana@oss.qualcomm.com \
--cc=Thinh.Nguyen@synopsys.com \
--cc=abelvesa@kernel.org \
--cc=dmitry.baryshkov@oss.qualcomm.com \
--cc=esteuwu@proton.me \
--cc=faisal.hassan@oss.qualcomm.com \
--cc=gregkh@linuxfoundation.org \
--cc=konrad.dybcio@oss.qualcomm.com \
--cc=krishna.chundru@oss.qualcomm.com \
--cc=krishna.kurapati@oss.qualcomm.com \
--cc=linux-arm-msm@vger.kernel.org \
--cc=linux-kernel@vger.kernel.org \
--cc=linux-phy@lists.infradead.org \
--cc=linux-usb@vger.kernel.org \
--cc=loic.poulain@oss.qualcomm.com \
--cc=mani@kernel.org \
--cc=neil.armstrong@linaro.org \
--cc=prashanth.k@oss.qualcomm.com \
--cc=ronak.raheja@oss.qualcomm.com \
--cc=vkoul@kernel.org \
--cc=wesley.cheng@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®