mirror of https://lore.kernel.org/lkml/
 help / color / mirror / Atom feed
* [PATCH v2 0/2] Add the PM suspend/resume callbacks for qmp phys
@ 2026-11-13 10:31 Prashanth K
  2026-11-13 10:31 ` [PATCH v2 1/2] phy: qcom: qmp-usb: Add PM suspend/resume callbacks Prashanth K
  2026-11-13 10:31 ` [PATCH v2 2/2] phy: qcom: qmp-combo: " Prashanth K
  0 siblings, 2 replies; 6+ messages in thread
From: Prashanth K @ 2026-11-13 10:31 UTC (permalink / raw)
  To: Vinod Koul, Kishon Vijay Abraham I
  Cc: Konrad Dybcio, linux-arm-msm, linux-phy, linux-kernel, Prashanth K

From: Prashanth K <prashk@qti.qualcomm.com>

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.

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 | 7 ++++++-
 drivers/phy/qualcomm/phy-qcom-qmp-usb.c   | 3 ++-
 2 files changed, 8 insertions(+), 2 deletions(-)

-- 
2.34.1


^ permalink raw reply	[flat|nested] 6+ messages in thread

* [PATCH v2 1/2] phy: qcom: qmp-usb: Add PM suspend/resume callbacks
  2026-11-13 10:31 [PATCH v2 0/2] Add the PM suspend/resume callbacks for qmp phys Prashanth K
@ 2026-11-13 10:31 ` Prashanth K
  2026-11-27 13:40   ` Manivannan Sadhasivam
  2026-11-13 10:31 ` [PATCH v2 2/2] phy: qcom: qmp-combo: " Prashanth K
  1 sibling, 1 reply; 6+ messages in thread
From: Prashanth K @ 2026-11-13 10:31 UTC (permalink / raw)
  To: Vinod Koul, Kishon Vijay Abraham I
  Cc: Konrad Dybcio, 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 | 3 ++-
 1 file changed, 2 insertions(+), 1 deletion(-)

diff --git a/drivers/phy/qualcomm/phy-qcom-qmp-usb.c b/drivers/phy/qualcomm/phy-qcom-qmp-usb.c
index 6a9faa0ce3bb..dc8be977e0a8 100644
--- a/drivers/phy/qualcomm/phy-qcom-qmp-usb.c
+++ b/drivers/phy/qualcomm/phy-qcom-qmp-usb.c
@@ -2129,6 +2129,7 @@ static int __maybe_unused qmp_usb_runtime_resume(struct device *dev)
 static const struct dev_pm_ops qmp_usb_pm_ops = {
 	SET_RUNTIME_PM_OPS(qmp_usb_runtime_suspend,
 			   qmp_usb_runtime_resume, NULL)
+	SET_SYSTEM_SLEEP_PM_OPS(pm_runtime_force_suspend, pm_runtime_force_resume)
 };
 
 static int qmp_usb_reset_init(struct qmp_usb *qmp,
@@ -2510,7 +2511,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	[flat|nested] 6+ messages in thread

* [PATCH v2 2/2] phy: qcom: qmp-combo: Add PM suspend/resume callbacks
  2026-11-13 10:31 [PATCH v2 0/2] Add the PM suspend/resume callbacks for qmp phys Prashanth K
  2026-11-13 10:31 ` [PATCH v2 1/2] phy: qcom: qmp-usb: Add PM suspend/resume callbacks Prashanth K
@ 2026-11-13 10:31 ` Prashanth K
  2026-11-27 13:41   ` Manivannan Sadhasivam
  1 sibling, 1 reply; 6+ messages in thread
From: Prashanth K @ 2026-11-13 10:31 UTC (permalink / raw)
  To: Vinod Koul, Kishon Vijay Abraham I
  Cc: Konrad Dybcio, 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 | 7 ++++++-
 1 file changed, 6 insertions(+), 1 deletion(-)

diff --git a/drivers/phy/qualcomm/phy-qcom-qmp-combo.c b/drivers/phy/qualcomm/phy-qcom-qmp-combo.c
index 187f0cd11f6c..65d280f45db1 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;
@@ -4761,6 +4765,7 @@ static int __maybe_unused qmp_combo_runtime_resume(struct device *dev)
 static const struct dev_pm_ops qmp_combo_pm_ops = {
 	SET_RUNTIME_PM_OPS(qmp_combo_runtime_suspend,
 			   qmp_combo_runtime_resume, NULL)
+	SET_SYSTEM_SLEEP_PM_OPS(pm_runtime_force_suspend, pm_runtime_force_resume)
 };
 
 static int qmp_combo_reset_init(struct qmp_combo *qmp)
@@ -5749,7 +5754,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	[flat|nested] 6+ messages in thread

* Re: [PATCH v2 1/2] phy: qcom: qmp-usb: Add PM suspend/resume callbacks
  2026-11-13 10:31 ` [PATCH v2 1/2] phy: qcom: qmp-usb: Add PM suspend/resume callbacks Prashanth K
@ 2026-11-27 13:40   ` Manivannan Sadhasivam
  0 siblings, 0 replies; 6+ messages in thread
From: Manivannan Sadhasivam @ 2026-11-27 13:40 UTC (permalink / raw)
  To: Prashanth K
  Cc: Vinod Koul, Kishon Vijay Abraham I, Konrad Dybcio, linux-arm-msm,
	linux-phy, linux-kernel

On 2026-11-13 16:01 +0530, Prashanth K wrote:
> 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 | 3 ++-
>  1 file changed, 2 insertions(+), 1 deletion(-)
> 
> diff --git a/drivers/phy/qualcomm/phy-qcom-qmp-usb.c b/drivers/phy/qualcomm/phy-qcom-qmp-usb.c
> index 6a9faa0ce3bb..dc8be977e0a8 100644
> --- a/drivers/phy/qualcomm/phy-qcom-qmp-usb.c
> +++ b/drivers/phy/qualcomm/phy-qcom-qmp-usb.c
> @@ -2129,6 +2129,7 @@ static int __maybe_unused qmp_usb_runtime_resume(struct device *dev)
>  static const struct dev_pm_ops qmp_usb_pm_ops = {
>  	SET_RUNTIME_PM_OPS(qmp_usb_runtime_suspend,
>  			   qmp_usb_runtime_resume, NULL)
> +	SET_SYSTEM_SLEEP_PM_OPS(pm_runtime_force_suspend, pm_runtime_force_resume)

This indicates that DEFINE_RUNTIME_DEV_PM_OPS() can be used instead.

- Mani



^ permalink raw reply	[flat|nested] 6+ messages in thread

* Re: [PATCH v2 2/2] phy: qcom: qmp-combo: Add PM suspend/resume callbacks
  2026-11-13 10:31 ` [PATCH v2 2/2] phy: qcom: qmp-combo: " Prashanth K
@ 2026-11-27 13:41   ` Manivannan Sadhasivam
  2026-11-30 11:00     ` Prashanth K
  0 siblings, 1 reply; 6+ messages in thread
From: Manivannan Sadhasivam @ 2026-11-27 13:41 UTC (permalink / raw)
  To: Prashanth K
  Cc: Vinod Koul, Kishon Vijay Abraham I, Konrad Dybcio, linux-arm-msm,
	linux-phy, linux-kernel

On 2026-11-13 16:01 +0530, Prashanth K wrote:
> 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.
> 

I don't see how this race can happen.

> Signed-off-by: Prashanth K <prashanth.k@oss.qualcomm.com>
> ---
>  drivers/phy/qualcomm/phy-qcom-qmp-combo.c | 7 ++++++-
>  1 file changed, 6 insertions(+), 1 deletion(-)
> 
> diff --git a/drivers/phy/qualcomm/phy-qcom-qmp-combo.c b/drivers/phy/qualcomm/phy-qcom-qmp-combo.c
> index 187f0cd11f6c..65d280f45db1 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;
> @@ -4761,6 +4765,7 @@ static int __maybe_unused qmp_combo_runtime_resume(struct device *dev)
>  static const struct dev_pm_ops qmp_combo_pm_ops = {
>  	SET_RUNTIME_PM_OPS(qmp_combo_runtime_suspend,
>  			   qmp_combo_runtime_resume, NULL)
> +	SET_SYSTEM_SLEEP_PM_OPS(pm_runtime_force_suspend, pm_runtime_force_resume)

Same comment as patch 1.

- Mani



^ permalink raw reply	[flat|nested] 6+ messages in thread

* Re: [PATCH v2 2/2] phy: qcom: qmp-combo: Add PM suspend/resume callbacks
  2026-11-27 13:41   ` Manivannan Sadhasivam
@ 2026-11-30 11:00     ` Prashanth K
  0 siblings, 0 replies; 6+ messages in thread
From: Prashanth K @ 2026-11-30 11:00 UTC (permalink / raw)
  To: Manivannan Sadhasivam
  Cc: Vinod Koul, Kishon Vijay Abraham I, Konrad Dybcio, linux-arm-msm,
	linux-phy, linux-kernel



On 11/27/2026 7:11 PM, Manivannan Sadhasivam wrote:
> On 2026-11-13 16:01 +0530, Prashanth K wrote:
>> 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.
>>
> 
> I don't see how this race can happen.

https://sashiko.dev/#/patchset/20261022104321.306679-1-prashanth.k@oss.qualcomm.com?part=1

This was suggested by sashiko, and later Konrad also suggested to throw
a mutex guard for safety. Its true that we havent seen any issues for
now, but it would be safter to have a mutex to avoid concurrency.

> 
>> Signed-off-by: Prashanth K <prashanth.k@oss.qualcomm.com>
>> ---
>>  drivers/phy/qualcomm/phy-qcom-qmp-combo.c | 7 ++++++-
>>  1 file changed, 6 insertions(+), 1 deletion(-)
>>
>> diff --git a/drivers/phy/qualcomm/phy-qcom-qmp-combo.c b/drivers/phy/qualcomm/phy-qcom-qmp-combo.c
>> index 187f0cd11f6c..65d280f45db1 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;
>> @@ -4761,6 +4765,7 @@ static int __maybe_unused qmp_combo_runtime_resume(struct device *dev)
>>  static const struct dev_pm_ops qmp_combo_pm_ops = {
>>  	SET_RUNTIME_PM_OPS(qmp_combo_runtime_suspend,
>>  			   qmp_combo_runtime_resume, NULL)
>> +	SET_SYSTEM_SLEEP_PM_OPS(pm_runtime_force_suspend, pm_runtime_force_resume)
> 
> Same comment as patch 1.
> 
> - Mani

Yea, that sounds better, will do that.

- Prashanth K


^ permalink raw reply	[flat|nested] 6+ messages in thread

end of thread, other threads:[~2026-11-30 11:01 UTC | newest]

Thread overview: 6+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2026-11-13 10:31 [PATCH v2 0/2] Add the PM suspend/resume callbacks for qmp phys Prashanth K
2026-11-13 10:31 ` [PATCH v2 1/2] phy: qcom: qmp-usb: Add PM suspend/resume callbacks Prashanth K
2026-11-27 13:40   ` Manivannan Sadhasivam
2026-11-13 10:31 ` [PATCH v2 2/2] phy: qcom: qmp-combo: " Prashanth K
2026-11-27 13:41   ` Manivannan Sadhasivam
2026-11-30 11:00     ` Prashanth K

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®