[PATCH 3/3] usb: dwc3: qcom: pass live SS-link state into PHY at suspend entry
From: Tapas Rana
Date: Fri Nov 06 2026 - 03:35:18 EST
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@xxxxxxxxxxxxxxxx>
---
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