* [PATCH 1/3] phy: qcom-qmp-usb-ss: add shared SS-link-state submode contract
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 ` 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
` (2 subsequent siblings)
3 siblings, 0 replies; 5+ messages in thread
From: Tapas Rana @ 2026-11-06 8:27 UTC (permalink / raw)
To: Vinod Koul, Thinh Nguyen, Greg Kroah-Hartman
Cc: Neil Armstrong, Manivannan Sadhasivam, Dmitry Baryshkov,
Abel Vesa, Konrad Dybcio, Wesley Cheng, Esteban Urrutia,
Loic Poulain, Krishna Kurapati, Ronak Raheja, Faisal Hassan,
Krishna Chaitanya Chundru, prashanth.k, linux-arm-msm, linux-phy,
linux-usb, linux-kernel, Tapas Rana
dwc3 core only calls phy_set_mode()/phy_set_mode_ext() with the base
PHY_MODE_USB_HOST or PHY_MODE_USB_DEVICE. It never passes the
PHY_MODE_USB_{HOST,DEVICE}_SS/HS/FS/LS submode values to any PHY
driver. However, QMP PHY drivers need to know whether a SuperSpeed
link is present to select the correct autonomous-mode wake interrupt
mask, and phy_mode alone cannot carry that.
Add enum qcom_usb_ss_state (UNKNOWN/PRESENT/ABSENT) and carry it
through the existing submode argument of phy_set_mode_ext(), instead
of extending enum phy_mode further. UNKNOWN is the default so callers
that do not yet pass a real value keep current behavior.
Signed-off-by: Tapas Rana <tapas.rana@oss.qualcomm.com>
---
include/linux/phy/phy-qcom-qmp-usb-ss.h | 17 +++++++++++++++++
1 file changed, 17 insertions(+)
create mode 100644 include/linux/phy/phy-qcom-qmp-usb-ss.h
diff --git a/include/linux/phy/phy-qcom-qmp-usb-ss.h b/include/linux/phy/phy-qcom-qmp-usb-ss.h
new file mode 100644
index 000000000000..4da4d71e977d
--- /dev/null
+++ b/include/linux/phy/phy-qcom-qmp-usb-ss.h
@@ -0,0 +1,17 @@
+/* SPDX-License-Identifier: GPL-2.0 */
+/*
+ * Shared submode contract between dwc3-qcom glue and the Qualcomm QMP
+ * USB3/combo PHY driver for communicating live SuperSpeed link presence
+ * at suspend-entry, via phy_set_mode_ext()'s submode argument.
+ */
+
+#ifndef _PHY_QCOM_QMP_USB_SS_H_
+#define _PHY_QCOM_QMP_USB_SS_H_
+
+enum qcom_usb_ss_state {
+ QCOM_USB_SS_UNKNOWN = 0,
+ QCOM_USB_SS_PRESENT,
+ QCOM_USB_SS_ABSENT,
+};
+
+#endif /* _PHY_QCOM_QMP_USB_SS_H_ */
--
2.43.0
^ permalink raw reply [flat|nested] 5+ messages in thread* [PATCH 2/3] phy: qcom: qmp-combo: Select LFPS detect only when SS link is confirmed present
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 ` Tapas Rana
2026-11-06 8:27 ` [PATCH 3/3] usb: dwc3: qcom: pass live SS-link state into PHY at suspend entry Tapas Rana
2026-11-06 15:06 ` [PATCH 0/3] phy: qcom: carry live SS-link state without growing enum phy_mode Konrad Dybcio
3 siblings, 0 replies; 5+ messages in thread
From: Tapas Rana @ 2026-11-06 8:27 UTC (permalink / raw)
To: Vinod Koul, Thinh Nguyen, Greg Kroah-Hartman
Cc: Neil Armstrong, Manivannan Sadhasivam, Dmitry Baryshkov,
Abel Vesa, Konrad Dybcio, Wesley Cheng, Esteban Urrutia,
Loic Poulain, Krishna Kurapati, Ronak Raheja, Faisal Hassan,
Krishna Chaitanya Chundru, prashanth.k, linux-arm-msm, linux-phy,
linux-usb, linux-kernel, Tapas Rana
qmp_combo_enable_autonomous_mode() selects the autonomous-mode wake
interrupt mask by comparing qmp->phy_mode against
PHY_MODE_USB_HOST_SS/PHY_MODE_USB_DEVICE_SS. However, this driver's
set_mode() only ever stores PHY_MODE_USB_HOST or PHY_MODE_USB_DEVICE,
since dwc3 core and dwc3-qcom never pass the _SS variants. As a
result, the comparison is always false and the PHY always falls back
to the ARCVR_DTCT_EN | ARCVR_DTCT_EVENT_SEL mask instead of also
enabling ALFPS_DTCT_EN, regardless of whether a SuperSpeed device is
attached.
Store the qcom_usb_ss_state submode (added in the previous patch)
alongside phy_mode in qmp_combo_usb_set_mode(), and switch
qmp_combo_enable_autonomous_mode() on it instead of on phy_mode, so
LFPS detection is selected only when a SuperSpeed link is confirmed
present.
Signed-off-by: Tapas Rana <tapas.rana@oss.qualcomm.com>
---
drivers/phy/qualcomm/phy-qcom-qmp-combo.c | 27 ++++++++++++++++++++---
1 file changed, 24 insertions(+), 3 deletions(-)
diff --git a/drivers/phy/qualcomm/phy-qcom-qmp-combo.c b/drivers/phy/qualcomm/phy-qcom-qmp-combo.c
index aa9dc9716574..813a0955c591 100644
--- a/drivers/phy/qualcomm/phy-qcom-qmp-combo.c
+++ b/drivers/phy/qualcomm/phy-qcom-qmp-combo.c
@@ -27,6 +27,7 @@
#include <drm/bridge/aux-bridge.h>
#include <dt-bindings/phy/phy-qcom-qmp.h>
+#include <linux/phy/phy-qcom-qmp-usb-ss.h>
#include "phy-qcom-qmp-common.h"
@@ -2630,6 +2631,7 @@ struct qmp_combo {
struct phy *usb_phy;
enum phy_mode phy_mode;
+ enum qcom_usb_ss_state ss_state;
unsigned int usb_init_count;
struct phy *dp_phy;
@@ -4518,6 +4520,16 @@ static int qmp_combo_usb_set_mode(struct phy *phy, enum phy_mode mode, int submo
qmp->phy_mode = mode;
+ switch (submode) {
+ case QCOM_USB_SS_PRESENT:
+ case QCOM_USB_SS_ABSENT:
+ qmp->ss_state = submode;
+ break;
+ default:
+ qmp->ss_state = QCOM_USB_SS_UNKNOWN;
+ break;
+ }
+
return 0;
}
@@ -4672,11 +4684,20 @@ static void qmp_combo_enable_autonomous_mode(struct qmp_combo *qmp)
void __iomem *pcs_aon = qmp->pcs_aon;
u32 intr_mask;
- if (qmp->phy_mode == PHY_MODE_USB_HOST_SS ||
- qmp->phy_mode == PHY_MODE_USB_DEVICE_SS)
+ /*
+ * Use LFPS detection only when a SuperSpeed device is known to be
+ * present. For absent or unknown state, use receiver detection.
+ */
+ switch (qmp->ss_state) {
+ case QCOM_USB_SS_PRESENT:
intr_mask = ARCVR_DTCT_EN | ALFPS_DTCT_EN;
- else
+ break;
+ case QCOM_USB_SS_ABSENT:
+ case QCOM_USB_SS_UNKNOWN:
+ default:
intr_mask = ARCVR_DTCT_EN | ARCVR_DTCT_EVENT_SEL;
+ break;
+ }
/* Clear any pending interrupts status */
qphy_setbits(pcs_usb, cfg->regs[QPHY_PCS_LFPS_RXTERM_IRQ_CLEAR], IRQ_CLEAR);
--
2.43.0
^ permalink raw reply [flat|nested] 5+ messages in thread* [PATCH 3/3] usb: dwc3: qcom: pass live SS-link state into PHY at suspend entry
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
2026-11-06 15:06 ` [PATCH 0/3] phy: qcom: carry live SS-link state without growing enum phy_mode Konrad Dybcio
3 siblings, 0 replies; 5+ messages in thread
From: Tapas Rana @ 2026-11-06 8:27 UTC (permalink / raw)
To: Vinod Koul, Thinh Nguyen, Greg Kroah-Hartman
Cc: Neil Armstrong, Manivannan Sadhasivam, Dmitry Baryshkov,
Abel Vesa, Konrad Dybcio, Wesley Cheng, Esteban Urrutia,
Loic Poulain, Krishna Kurapati, Ronak Raheja, Faisal Hassan,
Krishna Chaitanya Chundru, prashanth.k, linux-arm-msm, linux-phy,
linux-usb, linux-kernel, Tapas Rana
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
^ permalink raw reply [flat|nested] 5+ messages in thread* Re: [PATCH 0/3] phy: qcom: carry live SS-link state without growing enum phy_mode
2026-11-06 8:27 [PATCH 0/3] phy: qcom: carry live SS-link state without growing enum phy_mode Tapas Rana
` (2 preceding siblings ...)
2026-11-06 8:27 ` [PATCH 3/3] usb: dwc3: qcom: pass live SS-link state into PHY at suspend entry Tapas Rana
@ 2026-11-06 15:06 ` Konrad Dybcio
3 siblings, 0 replies; 5+ messages in thread
From: Konrad Dybcio @ 2026-11-06 15:06 UTC (permalink / raw)
To: Tapas Rana, Vinod Koul, Thinh Nguyen, Greg Kroah-Hartman
Cc: Neil Armstrong, Manivannan Sadhasivam, Dmitry Baryshkov,
Abel Vesa, Wesley Cheng, Esteban Urrutia, Loic Poulain,
Krishna Kurapati, Ronak Raheja, Faisal Hassan,
Krishna Chaitanya Chundru, prashanth.k, linux-arm-msm, linux-phy,
linux-usb, linux-kernel
On 11/6/26 9:27 AM, Tapas Rana wrote:
> QMP PHY drivers always enable receiver detection (ARCVR_DTCT_EN) in
> autonomous mode, and additionally enable LFPS detection (ALFPS_DTCT_EN)
> when a SuperSpeed link is present; otherwise they fall back to
> receiver-detect event selection (ARCVR_DTCT_EVENT_SEL). This choice is
> made by comparing phy_mode against
> PHY_MODE_USB_HOST_SS/PHY_MODE_USB_DEVICE_SS. However, dwc3 core only
> calls phy_set_mode()/phy_set_mode_ext() with the base
> PHY_MODE_USB_HOST or PHY_MODE_USB_DEVICE, never the _SS/_HS/_FS/_LS
> submodes.
Without much more insight, this sounds like the place to fix it then
Konrad
^ permalink raw reply [flat|nested] 5+ messages in thread