Skip to contentSkip to conversation

iommu/arm-smmu: Add clk_bulk_{prepare/unprepare} to system pm callbacks

PATCH Superseded Sai Prakash Ranjan 4 participants 8 messages Jul 27, 2021 – Aug 10, 2021

Subsystems (3)

v1 of 2 Superseded Latest is v2 →

lore
Share & tools
lore
#0 lore raw

PATCH 1/1 iommu/arm-smmu: Add clk_bulk_{prepare/unprepare} to system pm callbacks

Some clocks for SMMU can have parent as XO such as gpu_cc_hub_cx_int_clk of GPU SMMU in QTI SC7280 SoC and in order to enter deep sleep states in such cases, we would need to drop the XO clock vote in unprepare call and this unprepare callback for XO is in RPMh (Resource Power Manager-Hardened) clock driver which controls RPMh managed clock resources for new QTI SoCs and is a blocking call.

Given we cannot have a sleeping calls such as clk_bulk_prepare() and clk_bulk_unprepare() in arm-smmu runtime pm callbacks since the iommu operations like map and unmap can be in atomic context and are in fast path, add this prepare and unprepare call to drop the XO vote only for system pm callbacks since it is not a fast path and we expect the system to enter deep sleep states with system pm as opposed to runtime pm.

This is a similar sequence of clock requests (prepare,enable and disable,unprepare) in arm-smmu probe and remove.

---
 drivers/iommu/arm/arm-smmu/arm-smmu.c | 20 ++++++++++++++++++--
 1 file changed, 18 insertions(+), 2 deletions(-)
drivers/iommu/arm/arm-smmu/arm-smmu.c +18 -2
index d3c6f54110a5..9561ba4c5d39 100644
@@ -2277,6 +2277,13 @@ static int __maybe_unused arm_smmu_runtime_suspend(struct device *dev)
 
 static int __maybe_unused arm_smmu_pm_resume(struct device *dev)
 {
+	int ret;
+	struct arm_smmu_device *smmu = dev_get_drvdata(dev);
+
+	ret = clk_bulk_prepare(smmu->num_clks, smmu->clks);
+	if (ret)
+		return ret;
+
 	if (pm_runtime_suspended(dev))
 		return 0;
 
@@ -2285,10 +2292,19 @@ static int __maybe_unused arm_smmu_pm_resume(struct device *dev)
 
 static int __maybe_unused arm_smmu_pm_suspend(struct device *dev)
 {
+	int ret = 0;
+	struct arm_smmu_device *smmu = dev_get_drvdata(dev);
+
 	if (pm_runtime_suspended(dev))
-		return 0;
+		goto clk_unprepare;
 
-	return arm_smmu_runtime_suspend(dev);
+	ret = arm_smmu_runtime_suspend(dev);
+	if (ret)
+		return ret;
+
+clk_unprepare:
+	clk_bulk_unprepare(smmu->num_clks, smmu->clks);
+	return ret;
 }
 
 static const struct dev_pm_ops arm_smmu_pm_ops = {
Signature · 7 lines
QUALCOMM INDIA, on behalf of Qualcomm Innovation Center, Inc. is a member
of Code Aurora Forum, hosted by The Linux Foundation

_______________________________________________
iommu mailing list
[email protected]
https://lists.linuxfoundation.org/mailman/listinfo/iommu
reviewer
#1 lore raw
Quoted 14 lines · Sai Prakash Ranjan

Some clocks for SMMU can have parent as XO such as gpu_cc_hub_cx_int_clk of GPU SMMU in QTI SC7280 SoC and in order to enter deep sleep states in such cases, we would need to drop the XO clock vote in unprepare call and this unprepare callback for XO is in RPMh (Resource Power Manager-Hardened) clock driver which controls RPMh managed clock resources for new QTI SoCs and is a blocking call.

Given we cannot have a sleeping calls such as clk_bulk_prepare() and clk_bulk_unprepare() in arm-smmu runtime pm callbacks since the iommu operations like map and unmap can be in atomic context and are in fast path, add this prepare and unprepare call to drop the XO vote only for system pm callbacks since it is not a fast path and we expect the system to enter deep sleep states with system pm as opposed to runtime pm.

Quoted 2 lines

This is a similar sequence of clock requests (prepare,enable and disable,unprepare) in arm-smmu probe and remove.

Nope. We call arm_smmu_rpm_get(), which may resume the device, from atomic contexts. clk_prepare() may sleep. This doesn't work.

Robin.

Quoted 48 lines
---
  drivers/iommu/arm/arm-smmu/arm-smmu.c | 20 ++++++++++++++++++--
  1 file changed, 18 insertions(+), 2 deletions(-)
drivers/iommu/arm/arm-smmu/arm-smmu.c +18 -2
index d3c6f54110a5..9561ba4c5d39 100644
@@ -2277,6 +2277,13 @@ static int __maybe_unused arm_smmu_runtime_suspend(struct device *dev)
 
  static int __maybe_unused arm_smmu_pm_resume(struct device *dev)
  {
+	int ret;
+	struct arm_smmu_device *smmu = dev_get_drvdata(dev);
+
+	ret = clk_bulk_prepare(smmu->num_clks, smmu->clks);
+	if (ret)
+		return ret;
+
  	if (pm_runtime_suspended(dev))
  		return 0;
 
@@ -2285,10 +2292,19 @@ static int __maybe_unused arm_smmu_pm_resume(struct device *dev)
 
  static int __maybe_unused arm_smmu_pm_suspend(struct device *dev)
  {
+	int ret = 0;
+	struct arm_smmu_device *smmu = dev_get_drvdata(dev);
+
  	if (pm_runtime_suspended(dev))
-		return 0;
+		goto clk_unprepare;
 
-	return arm_smmu_runtime_suspend(dev);
+	ret = arm_smmu_runtime_suspend(dev);
+	if (ret)
+		return ret;
+
+clk_unprepare:
+	clk_bulk_unprepare(smmu->num_clks, smmu->clks);
+	return ret;
  }
 
  static const struct dev_pm_ops arm_smmu_pm_ops = {
reviewer
#2 lore raw
Quoted 15 lines · Robin Murphy
Quoted 14 lines · Sai Prakash Ranjan

Some clocks for SMMU can have parent as XO such as gpu_cc_hub_cx_int_clk of GPU SMMU in QTI SC7280 SoC and in order to enter deep sleep states in such cases, we would need to drop the XO clock vote in unprepare call and this unprepare callback for XO is in RPMh (Resource Power Manager-Hardened) clock driver which controls RPMh managed clock resources for new QTI SoCs and is a blocking call.

Given we cannot have a sleeping calls such as clk_bulk_prepare() and clk_bulk_unprepare() in arm-smmu runtime pm callbacks since the iommu operations like map and unmap can be in atomic context and are in fast path, add this prepare and unprepare call to drop the XO vote only for system pm callbacks since it is not a fast path and we expect the system to enter deep sleep states with system pm as opposed to runtime pm.

Quoted 4 lines
Quoted 2 lines

This is a similar sequence of clock requests (prepare,enable and disable,unprepare) in arm-smmu probe and remove.

Nope. We call arm_smmu_rpm_get(), which may resume the device, from atomic contexts. clk_prepare() may sleep. This doesn't work.

Urgh, or maybe I skimmed the commit message too lightly *and* managed to totally misread the patch, sorry :(

I'll wake up some more and try again later...

Robin.

Quoted 49 lines
Quoted 35 lines

---
  drivers/iommu/arm/arm-smmu/arm-smmu.c | 20 ++++++++++++++++++--

  1 file changed, 18 insertions(+), 2 deletions(-)
drivers/iommu/arm/arm-smmu/arm-smmu.c +11 -2
index d3c6f54110a5..9561ba4c5d39 100644
@@ -2277,6 +2277,13 @@ static int __maybe_unused 
 arm_smmu_runtime_suspend(struct device *dev)
   static int __maybe_unused arm_smmu_pm_resume(struct device *dev)
   {
+    int ret;
+    struct arm_smmu_device *smmu = dev_get_drvdata(dev);
+
+    ret = clk_bulk_prepare(smmu->num_clks, smmu->clks);
+    if (ret)
+        return ret;
+
       if (pm_runtime_suspended(dev))
           return 0;
@@ -2285,10 +2292,19 @@ static int __maybe_unused 
 arm_smmu_pm_resume(struct device *dev)
   static int __maybe_unused arm_smmu_pm_suspend(struct device *dev)
   {
+    int ret = 0;
+    struct arm_smmu_device *smmu = dev_get_drvdata(dev);
+
       if (pm_runtime_suspended(dev))
-        return 0;
+        goto clk_unprepare;
-    return arm_smmu_runtime_suspend(dev);

drivers/iommu/arm/arm-smmu/arm-smmu.c static int __maybe_unused · line 2309

Quoted 10 lines
drivers/iommu/arm/arm-smmu/arm-smmu.c +7 -0
+    ret = arm_smmu_runtime_suspend(dev);
+    if (ret)
+        return ret;
+
+clk_unprepare:
+    clk_bulk_unprepare(smmu->num_clks, smmu->clks);
+    return ret;
   }
   static const struct dev_pm_ops arm_smmu_pm_ops = {
 

_______________________________________________
iommu mailing list
[email protected]
https://lists.linuxfoundation.org/mailman/listinfo/iommu

#3 lore raw

Hi Robin,

Quoted 19 lines · Robin Murphy
Quoted 18 lines · Robin Murphy
Quoted 16 lines · Sai Prakash Ranjan

Some clocks for SMMU can have parent as XO such as gpu_cc_hub_cx_int_clk of GPU SMMU in QTI SC7280 SoC and in order to enter deep sleep states in such cases, we would need to drop the XO clock vote in unprepare call and this unprepare callback for XO is in RPMh (Resource Power Manager-Hardened) clock driver which controls RPMh managed clock resources for new QTI SoCs and is a blocking call.

Given we cannot have a sleeping calls such as clk_bulk_prepare() and clk_bulk_unprepare() in arm-smmu runtime pm callbacks since the iommu operations like map and unmap can be in atomic context and are in fast path, add this prepare and unprepare call to drop the XO vote only for system pm callbacks since it is not a fast path and we expect the system to enter deep sleep states with system pm as opposed to runtime pm.

This is a similar sequence of clock requests (prepare,enable and disable,unprepare) in arm-smmu probe and remove.

Quoted 7 lines
Quoted 1 line

Nope. We call arm_smmu_rpm_get(), which may resume the device, from atomic contexts. clk_prepare() may sleep. This doesn't work.

Urgh, or maybe I skimmed the commit message too lightly *and* managed to totally misread the patch, sorry :(

I'll wake up some more and try again later...

No worries, we took our time looking through that many times before posting this :)

Thanks,
Sai

Signature · 6 lines
QUALCOMM INDIA, on behalf of Qualcomm Innovation Center, Inc. is a member
of Code Aurora Forum, hosted by The Linux Foundation
_______________________________________________
iommu mailing list
[email protected]
https://lists.linuxfoundation.org/mailman/listinfo/iommu
maintainer
#4 lore raw
In reply to Sai Prakash Ranjan
Quoted 17 lines · Sai Prakash Ranjan

Some clocks for SMMU can have parent as XO such as gpu_cc_hub_cx_int_clk of GPU SMMU in QTI SC7280 SoC and in order to enter deep sleep states in such cases, we would need to drop the XO clock vote in unprepare call and this unprepare callback for XO is in RPMh (Resource Power Manager-Hardened) clock driver which controls RPMh managed clock resources for new QTI SoCs and is a blocking call.

Given we cannot have a sleeping calls such as clk_bulk_prepare() and clk_bulk_unprepare() in arm-smmu runtime pm callbacks since the iommu operations like map and unmap can be in atomic context and are in fast path, add this prepare and unprepare call to drop the XO vote only for system pm callbacks since it is not a fast path and we expect the system to enter deep sleep states with system pm as opposed to runtime pm.

This is a similar sequence of clock requests (prepare,enable and disable,unprepare) in arm-smmu probe and remove.

Quoted 6 lines
---
 drivers/iommu/arm/arm-smmu/arm-smmu.c | 20 ++++++++++++++++++--
 1 file changed, 18 insertions(+), 2 deletions(-)

[+Rob]

How does this work with that funny GPU which writes to the SMMU registers directly? Does the SMMU need to remain independently clocked for that to work or is it all in the same clock domain?

Quoted 7 lines
drivers/iommu/arm/arm-smmu/arm-smmu.c +0 -0
index d3c6f54110a5..9561ba4c5d39 100644
@@ -2277,6 +2277,13 @@ static int __maybe_unused arm_smmu_runtime_suspend(struct device *dev)
 
 static int __maybe_unused arm_smmu_pm_resume(struct device *dev)

drivers/iommu/arm/arm-smmu/arm-smmu.c static int __maybe_unused arm_smmu_runtime_suspend(struct device *dev) · line 2288

Quoted 10 lines
drivers/iommu/arm/arm-smmu/arm-smmu.c +7 -0
 {
+	int ret;
+	struct arm_smmu_device *smmu = dev_get_drvdata(dev);
+
+	ret = clk_bulk_prepare(smmu->num_clks, smmu->clks);
+	if (ret)
+		return ret;
+
 	if (pm_runtime_suspended(dev))
 		return 0;

If we subsequently fail to enable the clks in arm_smmu_runtime_resume() should we unprepare them again?

Will

Quoted 26 lines
drivers/iommu/arm/arm-smmu/arm-smmu.c +11 -2
@@ -2285,10 +2292,19 @@ static int __maybe_unused arm_smmu_pm_resume(struct device *dev)
 
 static int __maybe_unused arm_smmu_pm_suspend(struct device *dev)
 {
+	int ret = 0;
+	struct arm_smmu_device *smmu = dev_get_drvdata(dev);
+
 	if (pm_runtime_suspended(dev))
-		return 0;
+		goto clk_unprepare;
 
-	return arm_smmu_runtime_suspend(dev);
+	ret = arm_smmu_runtime_suspend(dev);
+	if (ret)
+		return ret;
+
+clk_unprepare:
+	clk_bulk_unprepare(smmu->num_clks, smmu->clks);
+	return ret;
 }
 
 static const struct dev_pm_ops arm_smmu_pm_ops = {
Signature · 2 lines
QUALCOMM INDIA, on behalf of Qualcomm Innovation Center, Inc. is a member
of Code Aurora Forum, hosted by The Linux Foundation
#5 lore raw
Quoted 26 lines · Will Deacon
Quoted 17 lines · Sai Prakash Ranjan

Some clocks for SMMU can have parent as XO such as gpu_cc_hub_cx_int_clk of GPU SMMU in QTI SC7280 SoC and in order to enter deep sleep states in such cases, we would need to drop the XO clock vote in unprepare call and this unprepare callback for XO is in RPMh (Resource Power Manager-Hardened) clock driver which controls RPMh managed clock resources for new QTI SoCs and is a blocking call.

Given we cannot have a sleeping calls such as clk_bulk_prepare() and clk_bulk_unprepare() in arm-smmu runtime pm callbacks since the iommu operations like map and unmap can be in atomic context and are in fast path, add this prepare and unprepare call to drop the XO vote only for system pm callbacks since it is not a fast path and we expect the system to enter deep sleep states with system pm as opposed to runtime pm.

This is a similar sequence of clock requests (prepare,enable and disable,unprepare) in arm-smmu probe and remove.

Quoted 6 lines
---
 drivers/iommu/arm/arm-smmu/arm-smmu.c | 20 ++++++++++++++++++--
 1 file changed, 18 insertions(+), 2 deletions(-)
Quoted 5 lines

[+Rob]

How does this work with that funny GPU which writes to the SMMU registers directly? Does the SMMU need to remain independently clocked for that to work or is it all in the same clock domain?

AFAIU the device_link stuff should keep the SMMU clocked as long as the GPU is alive, so I think this should work out ok.. ie. the SMMU won't suspend while the GPU is not suspended.

BR,
-R

Quoted 44 lines
Quoted 7 lines
drivers/iommu/arm/arm-smmu/arm-smmu.c +0 -0
index d3c6f54110a5..9561ba4c5d39 100644
@@ -2277,6 +2277,13 @@ static int __maybe_unused arm_smmu_runtime_suspend(struct device *dev)
 
 static int __maybe_unused arm_smmu_pm_resume(struct device *dev)

drivers/iommu/arm/arm-smmu/arm-smmu.c static int __maybe_unused arm_smmu_runtime_suspend(struct device *dev) · line 2288

Quoted 10 lines
drivers/iommu/arm/arm-smmu/arm-smmu.c +7 -0
 {
+     int ret;
+     struct arm_smmu_device *smmu = dev_get_drvdata(dev);
+
+     ret = clk_bulk_prepare(smmu->num_clks, smmu->clks);
+     if (ret)
+             return ret;
+
      if (pm_runtime_suspended(dev))
              return 0;

If we subsequently fail to enable the clks in arm_smmu_runtime_resume() should we unprepare them again?

Will

Quoted 21 lines
drivers/iommu/arm/arm-smmu/arm-smmu.c +11 -2
@@ -2285,10 +2292,19 @@ static int __maybe_unused arm_smmu_pm_resume(struct device *dev)
 
 static int __maybe_unused arm_smmu_pm_suspend(struct device *dev)
 {
+     int ret = 0;
+     struct arm_smmu_device *smmu = dev_get_drvdata(dev);
+
      if (pm_runtime_suspended(dev))
-             return 0;
+             goto clk_unprepare;
 
-     return arm_smmu_runtime_suspend(dev);
+     ret = arm_smmu_runtime_suspend(dev);
+     if (ret)
+             return ret;
+
+clk_unprepare:
+     clk_bulk_unprepare(smmu->num_clks, smmu->clks);
+     return ret;
 }
 
Quoted 9 lines
Quoted 5 lines
drivers/iommu/arm/arm-smmu/arm-smmu.c +0 -1
 static const struct dev_pm_ops arm_smmu_pm_ops = {
--

QUALCOMM INDIA, on behalf of Qualcomm Innovation Center, Inc. is a member of Code Aurora Forum, hosted by The Linux Foundation

_______________________________________________
iommu mailing list
[email protected]
https://lists.linuxfoundation.org/mailman/listinfo/iommu

_______________________________________________
iommu mailing list
[email protected]
https://lists.linuxfoundation.org/mailman/listinfo/iommu

#6 lore raw
In reply to Will Deacon
Quoted 25 lines · Will Deacon
Quoted 17 lines · Sai Prakash Ranjan

Some clocks for SMMU can have parent as XO such as gpu_cc_hub_cx_int_clk of GPU SMMU in QTI SC7280 SoC and in order to enter deep sleep states in such cases, we would need to drop the XO clock vote in unprepare call and this unprepare callback for XO is in RPMh (Resource Power Manager-Hardened) clock driver which controls RPMh managed clock resources for new QTI SoCs and is a blocking call.

Given we cannot have a sleeping calls such as clk_bulk_prepare() and clk_bulk_unprepare() in arm-smmu runtime pm callbacks since the iommu operations like map and unmap can be in atomic context and are in fast path, add this prepare and unprepare call to drop the XO vote only for system pm callbacks since it is not a fast path and we expect the system to enter deep sleep states with system pm as opposed to runtime pm.

This is a similar sequence of clock requests (prepare,enable and disable,unprepare) in arm-smmu probe and remove.

Quoted 6 lines
---
 drivers/iommu/arm/arm-smmu/arm-smmu.c | 20 ++++++++++++++++++--
 1 file changed, 18 insertions(+), 2 deletions(-)
Quoted 6 lines

[+Rob]

How does this work with that funny GPU which writes to the SMMU registers directly? Does the SMMU need to remain independently clocked for that to work or is it all in the same clock domain?

As Rob mentioned, device link should take care of all the dependencies between SMMU and its consumers. But not sure how the question relates to this patch as this change is for system pm and not runtime pm, so it is exactly the sequence of SMMU probe/remove which if works currently for that GPU SMMU, then it should work just fine for system suspend and resume as well.

Quoted 7 lines
Quoted 7 lines
drivers/iommu/arm/arm-smmu/arm-smmu.c +0 -0
index d3c6f54110a5..9561ba4c5d39 100644
@@ -2277,6 +2277,13 @@ static int __maybe_unused 
 arm_smmu_runtime_suspend(struct device *dev)
 
Quoted 15 lines

drivers/iommu/arm/arm-smmu/arm-smmu.c static int __maybe_unused arm_smmu_runtime_suspend(struct device *dev) · line 2288

Quoted 11 lines
drivers/iommu/arm/arm-smmu/arm-smmu.c +7 -0
 static int __maybe_unused arm_smmu_pm_resume(struct device *dev)
 {
+	int ret;
+	struct arm_smmu_device *smmu = dev_get_drvdata(dev);
+
+	ret = clk_bulk_prepare(smmu->num_clks, smmu->clks);
+	if (ret)
+		return ret;
+
 	if (pm_runtime_suspended(dev))
 		return 0;

If we subsequently fail to enable the clks in arm_smmu_runtime_resume() should we unprepare them again?

If we are unable to turn on the clks then its fatal and we will not live for long.

Thanks,
Sai

Quoted 29 lines

Will

Quoted 27 lines
drivers/iommu/arm/arm-smmu/arm-smmu.c +11 -2
@@ -2285,10 +2292,19 @@ static int __maybe_unused 
 arm_smmu_pm_resume(struct device *dev)
 
 static int __maybe_unused arm_smmu_pm_suspend(struct device *dev)
 {
+	int ret = 0;
+	struct arm_smmu_device *smmu = dev_get_drvdata(dev);
+
 	if (pm_runtime_suspended(dev))
-		return 0;
+		goto clk_unprepare;
 
-	return arm_smmu_runtime_suspend(dev);
+	ret = arm_smmu_runtime_suspend(dev);
+	if (ret)
+		return ret;
+
+clk_unprepare:
+	clk_bulk_unprepare(smmu->num_clks, smmu->clks);
+	return ret;
 }
 

static const struct dev_pm_ops arm_smmu_pm_ops = {
--
QUALCOMM INDIA, on behalf of Qualcomm Innovation Center, Inc. is a member of Code Aurora Forum, hosted by The Linux Foundation

Signature · 6 lines
QUALCOMM INDIA, on behalf of Qualcomm Innovation Center, Inc. is a member
of Code Aurora Forum, hosted by The Linux Foundation
_______________________________________________
iommu mailing list
[email protected]
https://lists.linuxfoundation.org/mailman/listinfo/iommu
#7 lore raw
Quoted 64 lines · Sai Prakash Ranjan
Quoted 25 lines · Will Deacon
Quoted 17 lines · Sai Prakash Ranjan

Some clocks for SMMU can have parent as XO such as gpu_cc_hub_cx_int_clk of GPU SMMU in QTI SC7280 SoC and in order to enter deep sleep states in such cases, we would need to drop the XO clock vote in unprepare call and this unprepare callback for XO is in RPMh (Resource Power Manager-Hardened) clock driver which controls RPMh managed clock resources for new QTI SoCs and is a blocking call.

Given we cannot have a sleeping calls such as clk_bulk_prepare() and clk_bulk_unprepare() in arm-smmu runtime pm callbacks since the iommu operations like map and unmap can be in atomic context and are in fast path, add this prepare and unprepare call to drop the XO vote only for system pm callbacks since it is not a fast path and we expect the system to enter deep sleep states with system pm as opposed to runtime pm.

This is a similar sequence of clock requests (prepare,enable and disable,unprepare) in arm-smmu probe and remove.

Quoted 6 lines
---
 drivers/iommu/arm/arm-smmu/arm-smmu.c | 20 ++++++++++++++++++--
 1 file changed, 18 insertions(+), 2 deletions(-)
Quoted 6 lines

[+Rob]

How does this work with that funny GPU which writes to the SMMU registers directly? Does the SMMU need to remain independently clocked for that to work or is it all in the same clock domain?

As Rob mentioned, device link should take care of all the dependencies between SMMU and its consumers. But not sure how the question relates to this patch as this
change is for system pm and not runtime pm, so it is exactly the sequence of SMMU probe/remove which if works currently for that GPU SMMU, then it should work
just fine for system suspend and resume as well.

Quoted 7 lines
Quoted 7 lines
drivers/iommu/arm/arm-smmu/arm-smmu.c +0 -0
index d3c6f54110a5..9561ba4c5d39 100644
@@ -2277,6 +2277,13 @@ static int __maybe_unused 
 arm_smmu_runtime_suspend(struct device *dev)
 
Quoted 15 lines

drivers/iommu/arm/arm-smmu/arm-smmu.c static int __maybe_unused arm_smmu_runtime_suspend(struct device *dev) · line 2288

Quoted 11 lines
drivers/iommu/arm/arm-smmu/arm-smmu.c +7 -0
 static int __maybe_unused arm_smmu_pm_resume(struct device *dev)
 {
+	int ret;
+	struct arm_smmu_device *smmu = dev_get_drvdata(dev);
+
+	ret = clk_bulk_prepare(smmu->num_clks, smmu->clks);
+	if (ret)
+		return ret;
+
 	if (pm_runtime_suspended(dev))
 		return 0;

If we subsequently fail to enable the clks in arm_smmu_runtime_resume() should we unprepare them again?

Quoted 3 lines

If we are unable to turn on the clks then its fatal and we will not live for long.

Nonetheless, it won't hurt to unprepare if clk enable fails as that is the correct thing anyway, so I have added it and sent a v2.

Thanks,
Sai

Quoted 30 lines
Quoted 30 lines

Will

Quoted 27 lines
drivers/iommu/arm/arm-smmu/arm-smmu.c +11 -2
@@ -2285,10 +2292,19 @@ static int __maybe_unused 
 arm_smmu_pm_resume(struct device *dev)
 
 static int __maybe_unused arm_smmu_pm_suspend(struct device *dev)
 {
+	int ret = 0;
+	struct arm_smmu_device *smmu = dev_get_drvdata(dev);
+
 	if (pm_runtime_suspended(dev))
-		return 0;
+		goto clk_unprepare;
 
-	return arm_smmu_runtime_suspend(dev);
+	ret = arm_smmu_runtime_suspend(dev);
+	if (ret)
+		return ret;
+
+clk_unprepare:
+	clk_bulk_unprepare(smmu->num_clks, smmu->clks);
+	return ret;
 }
 

static const struct dev_pm_ops arm_smmu_pm_ops = {
--
QUALCOMM INDIA, on behalf of Qualcomm Innovation Center, Inc. is a member of Code Aurora Forum, hosted by The Linux Foundation

Signature · 2 lines
QUALCOMM INDIA, on behalf of Qualcomm Innovation Center, Inc. is a member
of Code Aurora Forum, hosted by The Linux Foundation