* [PATCH v3 0/2] Add the PM suspend/resume callbacks for qmp phys @ 2026-12-02 10:08 ` Prashanth K 0 siblings, 0 replies; 7+ messages in thread From: Prashanth K @ 2026-12-02 10:08 UTC (permalink / raw) To: Vinod Koul, Kishon Vijay Abraham I Cc: Konrad Dybcio, Manivannan Sadhasivam, linux-arm-msm, linux-phy, linux-kernel, Prashanth K Currently the phy clocks are left ON during system suspend, this leading to power leakages. Prevent this by disabling the phy clocks during PM suspend. Achieve this by reusing the RT suspend/resume callbacks for PM operations. Changes in v3: - Use DEFINE_RUNTIME_DEV_PM_OPS macro for the dev_pm_ops. - Line to v2: https://lore.kernel.org/all/20261113103111.156476-1-prashanth.k@oss.qualcomm.com/ Changes in v2: - Added pm_runtime_force_suspend for pm callbacks. - Added mutex to prevent race between typec/mux callbacks with suspend/resume. - Link to v1: https://lore.kernel.org/all/20261022104321.306679-1-prashanth.k@oss.qualcomm.com/ Prashanth K (2): phy: qcom: qmp-usb: Add PM suspend/resume callbacks phy: qcom: qmp-combo: Add PM suspend/resume callbacks drivers/phy/qualcomm/phy-qcom-qmp-combo.c | 13 ++++++++----- drivers/phy/qualcomm/phy-qcom-qmp-usb.c | 9 ++++----- 2 files changed, 12 insertions(+), 10 deletions(-) -- 2.34.1 ^ permalink raw reply [flat|nested] 7+ messages in thread
* [PATCH v3 0/2] Add the PM suspend/resume callbacks for qmp phys @ 2026-12-02 10:08 ` Prashanth K 0 siblings, 0 replies; 7+ messages in thread From: Prashanth K @ 2026-12-02 10:08 UTC (permalink / raw) To: Vinod Koul, Kishon Vijay Abraham I Cc: Konrad Dybcio, Manivannan Sadhasivam, linux-arm-msm, linux-phy, linux-kernel, Prashanth K Currently the phy clocks are left ON during system suspend, this leading to power leakages. Prevent this by disabling the phy clocks during PM suspend. Achieve this by reusing the RT suspend/resume callbacks for PM operations. Changes in v3: - Use DEFINE_RUNTIME_DEV_PM_OPS macro for the dev_pm_ops. - Line to v2: https://lore.kernel.org/all/20261113103111.156476-1-prashanth.k@oss.qualcomm.com/ Changes in v2: - Added pm_runtime_force_suspend for pm callbacks. - Added mutex to prevent race between typec/mux callbacks with suspend/resume. - Link to v1: https://lore.kernel.org/all/20261022104321.306679-1-prashanth.k@oss.qualcomm.com/ Prashanth K (2): phy: qcom: qmp-usb: Add PM suspend/resume callbacks phy: qcom: qmp-combo: Add PM suspend/resume callbacks drivers/phy/qualcomm/phy-qcom-qmp-combo.c | 13 ++++++++----- drivers/phy/qualcomm/phy-qcom-qmp-usb.c | 9 ++++----- 2 files changed, 12 insertions(+), 10 deletions(-) -- 2.34.1 -- linux-phy mailing list linux-phy@lists.infradead.org https://lists.infradead.org/mailman/listinfo/linux-phy ^ permalink raw reply [flat|nested] 7+ messages in thread
* [PATCH v3 1/2] phy: qcom: qmp-usb: Add PM suspend/resume callbacks 2026-12-02 10:08 ` Prashanth K @ 2026-12-02 10:08 ` Prashanth K -1 siblings, 0 replies; 7+ messages in thread From: Prashanth K @ 2026-12-02 10:08 UTC (permalink / raw) To: Vinod Koul, Kishon Vijay Abraham I Cc: Konrad Dybcio, Manivannan Sadhasivam, linux-arm-msm, linux-phy, linux-kernel, Prashanth K Currently when we perform system suspend, the phy clocks aren't turned off, this leads to power leakage. Prevent this by adding PM suspend/resume callbacks for the qmp-usb phy which toggles clocks on/off correspondingly. Signed-off-by: Prashanth K <prashanth.k@oss.qualcomm.com> --- drivers/phy/qualcomm/phy-qcom-qmp-usb.c | 9 ++++----- 1 file changed, 4 insertions(+), 5 deletions(-) diff --git a/drivers/phy/qualcomm/phy-qcom-qmp-usb.c b/drivers/phy/qualcomm/phy-qcom-qmp-usb.c index 6348bb68d822..9e056956100b 100644 --- a/drivers/phy/qualcomm/phy-qcom-qmp-usb.c +++ b/drivers/phy/qualcomm/phy-qcom-qmp-usb.c @@ -2126,10 +2126,9 @@ static int __maybe_unused qmp_usb_runtime_resume(struct device *dev) return 0; } -static const struct dev_pm_ops qmp_usb_pm_ops = { - SET_RUNTIME_PM_OPS(qmp_usb_runtime_suspend, - qmp_usb_runtime_resume, NULL) -}; +static DEFINE_RUNTIME_DEV_PM_OPS(qmp_usb_pm_ops, + qmp_usb_runtime_suspend, + qmp_usb_runtime_resume, NULL); static int qmp_usb_reset_init(struct qmp_usb *qmp, const char *const *reset_list, @@ -2509,7 +2508,7 @@ static struct platform_driver qmp_usb_driver = { .probe = qmp_usb_probe, .driver = { .name = "qcom-qmp-usb-phy", - .pm = &qmp_usb_pm_ops, + .pm = pm_ptr(&qmp_usb_pm_ops), .of_match_table = qmp_usb_of_match_table, }, }; -- 2.34.1 ^ permalink raw reply related [flat|nested] 7+ messages in thread
* [PATCH v3 1/2] phy: qcom: qmp-usb: Add PM suspend/resume callbacks @ 2026-12-02 10:08 ` Prashanth K 0 siblings, 0 replies; 7+ messages in thread From: Prashanth K @ 2026-12-02 10:08 UTC (permalink / raw) To: Vinod Koul, Kishon Vijay Abraham I Cc: Konrad Dybcio, Manivannan Sadhasivam, linux-arm-msm, linux-phy, linux-kernel, Prashanth K Currently when we perform system suspend, the phy clocks aren't turned off, this leads to power leakage. Prevent this by adding PM suspend/resume callbacks for the qmp-usb phy which toggles clocks on/off correspondingly. Signed-off-by: Prashanth K <prashanth.k@oss.qualcomm.com> --- drivers/phy/qualcomm/phy-qcom-qmp-usb.c | 9 ++++----- 1 file changed, 4 insertions(+), 5 deletions(-) diff --git a/drivers/phy/qualcomm/phy-qcom-qmp-usb.c b/drivers/phy/qualcomm/phy-qcom-qmp-usb.c index 6348bb68d822..9e056956100b 100644 --- a/drivers/phy/qualcomm/phy-qcom-qmp-usb.c +++ b/drivers/phy/qualcomm/phy-qcom-qmp-usb.c @@ -2126,10 +2126,9 @@ static int __maybe_unused qmp_usb_runtime_resume(struct device *dev) return 0; } -static const struct dev_pm_ops qmp_usb_pm_ops = { - SET_RUNTIME_PM_OPS(qmp_usb_runtime_suspend, - qmp_usb_runtime_resume, NULL) -}; +static DEFINE_RUNTIME_DEV_PM_OPS(qmp_usb_pm_ops, + qmp_usb_runtime_suspend, + qmp_usb_runtime_resume, NULL); static int qmp_usb_reset_init(struct qmp_usb *qmp, const char *const *reset_list, @@ -2509,7 +2508,7 @@ static struct platform_driver qmp_usb_driver = { .probe = qmp_usb_probe, .driver = { .name = "qcom-qmp-usb-phy", - .pm = &qmp_usb_pm_ops, + .pm = pm_ptr(&qmp_usb_pm_ops), .of_match_table = qmp_usb_of_match_table, }, }; -- 2.34.1 -- linux-phy mailing list linux-phy@lists.infradead.org https://lists.infradead.org/mailman/listinfo/linux-phy ^ permalink raw reply related [flat|nested] 7+ messages in thread
* [PATCH v3 2/2] phy: qcom: qmp-combo: Add PM suspend/resume callbacks 2026-12-02 10:08 ` Prashanth K @ 2026-12-02 10:08 ` Prashanth K -1 siblings, 0 replies; 7+ messages in thread From: Prashanth K @ 2026-12-02 10:08 UTC (permalink / raw) To: Vinod Koul, Kishon Vijay Abraham I Cc: Konrad Dybcio, Manivannan Sadhasivam, linux-arm-msm, linux-phy, linux-kernel, Prashanth K Currently when we perform system suspend, the phy clocks aren't turned off leading to power leakage. Prevent this by adding PM suspend/resume callbacks for the qmp-combo-phy which toggles clocks on/off correspondingly. While at it, add mutex guard in runtime_suspend/resume in order to prevent any race between RT operations and phy_init/exit(), as it can lead to unclocked register access crash, underflowing the clock enable counts. Signed-off-by: Prashanth K <prashanth.k@oss.qualcomm.com> --- drivers/phy/qualcomm/phy-qcom-qmp-combo.c | 13 ++++++++----- 1 file changed, 8 insertions(+), 5 deletions(-) diff --git a/drivers/phy/qualcomm/phy-qcom-qmp-combo.c b/drivers/phy/qualcomm/phy-qcom-qmp-combo.c index 61d8b7a5ce8f..8e5dfdd55c3c 100644 --- a/drivers/phy/qualcomm/phy-qcom-qmp-combo.c +++ b/drivers/phy/qualcomm/phy-qcom-qmp-combo.c @@ -4717,6 +4717,8 @@ static int __maybe_unused qmp_combo_runtime_suspend(struct device *dev) dev_vdbg(dev, "Suspending QMP phy, mode:%d\n", qmp->phy_mode); + guard(mutex)(&qmp->phy_mutex); + if (!qmp->init_count) { dev_vdbg(dev, "PHY not initialized, bailing out\n"); return 0; @@ -4737,6 +4739,8 @@ static int __maybe_unused qmp_combo_runtime_resume(struct device *dev) dev_vdbg(dev, "Resuming QMP phy, mode:%d\n", qmp->phy_mode); + guard(mutex)(&qmp->phy_mutex); + if (!qmp->init_count) { dev_vdbg(dev, "PHY not initialized, bailing out\n"); return 0; @@ -4758,10 +4762,9 @@ static int __maybe_unused qmp_combo_runtime_resume(struct device *dev) return 0; } -static const struct dev_pm_ops qmp_combo_pm_ops = { - SET_RUNTIME_PM_OPS(qmp_combo_runtime_suspend, - qmp_combo_runtime_resume, NULL) -}; +static DEFINE_RUNTIME_DEV_PM_OPS(qmp_combo_pm_ops, + qmp_combo_runtime_suspend, + qmp_combo_runtime_resume, NULL); static int qmp_combo_reset_init(struct qmp_combo *qmp) { @@ -5748,7 +5751,7 @@ static struct platform_driver qmp_combo_driver = { .probe = qmp_combo_probe, .driver = { .name = "qcom-qmp-combo-phy", - .pm = &qmp_combo_pm_ops, + .pm = pm_ptr(&qmp_combo_pm_ops), .of_match_table = qmp_combo_of_match_table, }, }; -- 2.34.1 ^ permalink raw reply related [flat|nested] 7+ messages in thread
* [PATCH v3 2/2] phy: qcom: qmp-combo: Add PM suspend/resume callbacks @ 2026-12-02 10:08 ` Prashanth K 0 siblings, 0 replies; 7+ messages in thread From: Prashanth K @ 2026-12-02 10:08 UTC (permalink / raw) To: Vinod Koul, Kishon Vijay Abraham I Cc: Konrad Dybcio, Manivannan Sadhasivam, linux-arm-msm, linux-phy, linux-kernel, Prashanth K Currently when we perform system suspend, the phy clocks aren't turned off leading to power leakage. Prevent this by adding PM suspend/resume callbacks for the qmp-combo-phy which toggles clocks on/off correspondingly. While at it, add mutex guard in runtime_suspend/resume in order to prevent any race between RT operations and phy_init/exit(), as it can lead to unclocked register access crash, underflowing the clock enable counts. Signed-off-by: Prashanth K <prashanth.k@oss.qualcomm.com> --- drivers/phy/qualcomm/phy-qcom-qmp-combo.c | 13 ++++++++----- 1 file changed, 8 insertions(+), 5 deletions(-) diff --git a/drivers/phy/qualcomm/phy-qcom-qmp-combo.c b/drivers/phy/qualcomm/phy-qcom-qmp-combo.c index 61d8b7a5ce8f..8e5dfdd55c3c 100644 --- a/drivers/phy/qualcomm/phy-qcom-qmp-combo.c +++ b/drivers/phy/qualcomm/phy-qcom-qmp-combo.c @@ -4717,6 +4717,8 @@ static int __maybe_unused qmp_combo_runtime_suspend(struct device *dev) dev_vdbg(dev, "Suspending QMP phy, mode:%d\n", qmp->phy_mode); + guard(mutex)(&qmp->phy_mutex); + if (!qmp->init_count) { dev_vdbg(dev, "PHY not initialized, bailing out\n"); return 0; @@ -4737,6 +4739,8 @@ static int __maybe_unused qmp_combo_runtime_resume(struct device *dev) dev_vdbg(dev, "Resuming QMP phy, mode:%d\n", qmp->phy_mode); + guard(mutex)(&qmp->phy_mutex); + if (!qmp->init_count) { dev_vdbg(dev, "PHY not initialized, bailing out\n"); return 0; @@ -4758,10 +4762,9 @@ static int __maybe_unused qmp_combo_runtime_resume(struct device *dev) return 0; } -static const struct dev_pm_ops qmp_combo_pm_ops = { - SET_RUNTIME_PM_OPS(qmp_combo_runtime_suspend, - qmp_combo_runtime_resume, NULL) -}; +static DEFINE_RUNTIME_DEV_PM_OPS(qmp_combo_pm_ops, + qmp_combo_runtime_suspend, + qmp_combo_runtime_resume, NULL); static int qmp_combo_reset_init(struct qmp_combo *qmp) { @@ -5748,7 +5751,7 @@ static struct platform_driver qmp_combo_driver = { .probe = qmp_combo_probe, .driver = { .name = "qcom-qmp-combo-phy", - .pm = &qmp_combo_pm_ops, + .pm = pm_ptr(&qmp_combo_pm_ops), .of_match_table = qmp_combo_of_match_table, }, }; -- 2.34.1 -- linux-phy mailing list linux-phy@lists.infradead.org https://lists.infradead.org/mailman/listinfo/linux-phy ^ permalink raw reply related [flat|nested] 7+ messages in thread
* Re: [PATCH v3 2/2] phy: qcom: qmp-combo: Add PM suspend/resume callbacks 2026-12-02 10:08 ` Prashanth K (?) @ 2026-12-02 10:34 ` sashiko-bot -1 siblings, 0 replies; 7+ messages in thread From: sashiko-bot @ 2026-12-02 10:34 UTC (permalink / raw) To: Prashanth K; +Cc: linux-phy, vkoul, neil.armstrong, olteanv Thank you for your contribution! Sashiko AI review found 1 potential issue to consider: - [High] phy: qcom: qmp-combo: unclocked access in Type-C callbacks while suspended -- commit e87be7553b09b437b8b2cf35ebd238ecfba5cca9 Author: Prashanth K <prashanth.k@oss.qualcomm.com> phy: qcom: qmp-combo: Add PM suspend/resume callbacks This commit converts qmp_combo_pm_ops to DEFINE_RUNTIME_DEV_PM_OPS() so that system suspend and resume toggle the PHY clocks, and adds qmp->phy_mutex guards to the runtime PM callbacks. > diff --git a/drivers/phy/qualcomm/phy-qcom-qmp-combo.c b/drivers/phy/qualcomm/phy-qcom-qmp-combo.c > index 3acf28c7d7b21..c5e71aa4e1929 100644 > --- a/drivers/phy/qualcomm/phy-qcom-qmp-combo.c > +++ b/drivers/phy/qualcomm/phy-qcom-qmp-combo.c > @@ -4726,6 +4726,8 @@ static int __maybe_unused qmp_combo_runtime_suspend(struct device *dev) > > dev_vdbg(dev, "Suspending QMP phy, mode:%d\n", qmp->phy_mode); > > + guard(mutex)(&qmp->phy_mutex); > + > if (!qmp->init_count) { > dev_vdbg(dev, "PHY not initialized, bailing out\n"); > return 0; > @@ -4746,6 +4748,8 @@ static int __maybe_unused qmp_combo_runtime_resume(struct device *dev) > > dev_vdbg(dev, "Resuming QMP phy, mode:%d\n", qmp->phy_mode); > > + guard(mutex)(&qmp->phy_mutex); > + > if (!qmp->init_count) { > dev_vdbg(dev, "PHY not initialized, bailing out\n"); > return 0; > @@ -4767,10 +4771,9 @@ static int __maybe_unused qmp_combo_runtime_resume(struct device *dev) > return 0; > } > > -static const struct dev_pm_ops qmp_combo_pm_ops = { > - SET_RUNTIME_PM_OPS(qmp_combo_runtime_suspend, > - qmp_combo_runtime_resume, NULL) > -}; > +static DEFINE_RUNTIME_DEV_PM_OPS(qmp_combo_pm_ops, > + qmp_combo_runtime_suspend, > + qmp_combo_runtime_resume, NULL); [Severity: High] Can qmp_combo_typec_switch_set() and qmp_combo_typec_mux_set() perform unclocked MMIO accesses and underflow the clock enable counts while the PHY is suspended? DEFINE_RUNTIME_DEV_PM_OPS() wires pm_runtime_force_suspend() and pm_runtime_force_resume() as the system sleep callbacks. When the PHY is initialized across system suspend (for example, dwc3 in host mode with wakeup enabled does not call phy_exit()), qmp_combo_runtime_suspend() disables qmp->pipe_clk and qmp->clks and releases qmp->phy_mutex while qmp->init_count remains non-zero. Type-C switch and mux consumers such as ucsi_glink have no PM callbacks or device links to qmp->dev and process connector notifications on non-freezable workqueues. If a Type-C event runs after qmp_combo_runtime_suspend() and before qmp_combo_runtime_resume(): drivers/phy/qualcomm/phy-qcom-qmp-combo.c:qmp_combo_typec_switch_set() { guard(mutex)(&qmp->phy_mutex); qmp->orientation = orientation; if (qmp->init_count) { if (qmp->usb_init_count || qmp->usb4_init_count) qmp_combo_usb_power_off(qmp->usb_phy); qmp_combo_com_exit(qmp, true); qmp_combo_com_init(qmp, true); ... } Both qmp_combo_typec_switch_set() and qmp_combo_typec_mux_set() only check qmp->init_count, so they access qmp->pcs and qmp->dp_dp_phy registers with the PHY clocks disabled (causing an immediate synchronous external abort on ARM64). qmp_combo_com_exit() and qmp_combo_com_init() also disable the already-disabled clocks and re-enable them before qmp_combo_runtime_resume() enables them a second time. -- Sashiko AI review · https://sashiko.dev/#/patchset/20261202100815.3144017-1-prashanth.k@oss.qualcomm.com?part=2 -- linux-phy mailing list linux-phy@lists.infradead.org https://lists.infradead.org/mailman/listinfo/linux-phy ^ permalink raw reply [flat|nested] 7+ messages in thread
end of thread, other threads:[~2026-12-02 11:14 UTC | newest] Thread overview: 7+ messages (download: mbox.gz follow: Atom feed -- links below jump to the message on this page -- 2026-12-02 10:08 [PATCH v3 0/2] Add the PM suspend/resume callbacks for qmp phys Prashanth K 2026-12-02 10:08 ` Prashanth K 2026-12-02 10:08 ` [PATCH v3 1/2] phy: qcom: qmp-usb: Add PM suspend/resume callbacks Prashanth K 2026-12-02 10:08 ` Prashanth K 2026-12-02 10:08 ` [PATCH v3 2/2] phy: qcom: qmp-combo: " Prashanth K 2026-12-02 10:08 ` Prashanth K 2026-12-02 10:34 ` sashiko-bot
This is an external index of several public inboxes, see mirroring instructions on how to clone and mirror all data and code used by this external index.