Skip to contentSkip to conversation

clk: imx: scu: Fix pm_runtime_get_sync() error checking

PATCH In review Miaoqian Lin 3 participants 8 messages Apr 12, 2022 – Apr 23, 2022

Subsystems (3)
lore
Share & tools
lore
#0 lore raw

PATCH 1/1 clk: imx: scu: Fix pm_runtime_get_sync() error checking

If the device is already in a runtime PM enabled state pm_runtime_get_sync() will return 1, so a test for negative value should be used to check for errors.

Fixes 78edeb080330 ("clk: imx: scu: add runtime pm support")
---
 drivers/clk/imx/clk-scu.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)
drivers/clk/imx/clk-scu.c +1 -1
index 083da31dc3ea..18c6190eeffd 100644
@@ -529,7 +529,7 @@ static int imx_clk_scu_probe(struct platform_device *pdev)
 		pm_runtime_enable(dev);
 
 		ret = pm_runtime_get_sync(dev);
-		if (ret) {
+		if (ret < 0) {
 			pm_genpd_remove_device(dev);
 			pm_runtime_disable(dev);
 			return ret;
Signature · 7 lines
2.17.1


_______________________________________________
linux-arm-kernel mailing list
[email protected]
http://lists.infradead.org/mailman/listinfo/linux-arm-kernel
Reviewed-by on v1 1/1
#1 lore raw
Quoted 6 lines · Miaoqian Lin

If the device is already in a runtime PM enabled state pm_runtime_get_sync() will return 1, so a test for negative value should be used to check for errors.

Fixes 78edeb080330 ("clk: imx: scu: add runtime pm support")
Quoted 20 lines
---
 drivers/clk/imx/clk-scu.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)
drivers/clk/imx/clk-scu.c +1 -2
index 083da31dc3ea..18c6190eeffd 100644
@@ -529,7 +529,7 @@ static int imx_clk_scu_probe(struct platform_device *pdev)
 		pm_runtime_enable(dev);
 
 		ret = pm_runtime_get_sync(dev);
-		if (ret) {
+		if (ret < 0) {
 			pm_genpd_remove_device(dev);
 			pm_runtime_disable(dev);
 			return ret;
--

2.17.1

maintainer
#2 lore raw
In reply to Miaoqian Lin

Quoting Miaoqian Lin (2022-04-11 23:57:18)

Quoted 3 lines

If the device is already in a runtime PM enabled state pm_runtime_get_sync() will return 1, so a test for negative value should be used to check for errors.

Maybe it should use pm_runtime_resume_and_get() instead?

Quoted 23 lines
Fixes 78edeb080330 ("clk: imx: scu: add runtime pm support")
---
 drivers/clk/imx/clk-scu.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)
drivers/clk/imx/clk-scu.c +1 -1
index 083da31dc3ea..18c6190eeffd 100644
@@ -529,7 +529,7 @@ static int imx_clk_scu_probe(struct platform_device *pdev)
                pm_runtime_enable(dev);
 
                ret = pm_runtime_get_sync(dev);
-               if (ret) {
+               if (ret < 0) {
                        pm_genpd_remove_device(dev);
                        pm_runtime_disable(dev);
                        return ret;
Signature · 1 line
2.17.1
#3 lore raw
Quoted 5 lines · Stephen Boyd

Quoting Miaoqian Lin (2022-04-11 23:57:18)

Quoted 3 lines

If the device is already in a runtime PM enabled state pm_runtime_get_sync() will return 1, so a test for negative value should be used to check for errors.

Maybe it should use pm_runtime_resume_and_get() instead?

Fair enough,I will send patch v2.

Quoted 22 lines
Quoted 22 lines
Fixes 78edeb080330 ("clk: imx: scu: add runtime pm support")
---
 drivers/clk/imx/clk-scu.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)
drivers/clk/imx/clk-scu.c +1 -1
index 083da31dc3ea..18c6190eeffd 100644
@@ -529,7 +529,7 @@ static int imx_clk_scu_probe(struct platform_device *pdev)
                pm_runtime_enable(dev);
 
                ret = pm_runtime_get_sync(dev);
-               if (ret) {
+               if (ret < 0) {
                        pm_genpd_remove_device(dev);
                        pm_runtime_disable(dev);
                        return ret;
Signature · 1 line
2.17.1
#4 lore raw

PATCH v2 1/1 clk: imx: scu: Use pm_runtime_resume_and_get to fix pm_runtime_get_sync() usage

In reply to Stephen Boyd

If the device is already in a runtime PM enabled state pm_runtime_get_sync() will return 1.

Also, we need to call pm_runtime_put_noidle() when pm_runtime_get_sync() fails, so use pm_runtime_resume_and_get() instead. this function will handle this.

Fixes 78edeb080330 ("clk: imx: scu: add runtime pm support")
---
 drivers/clk/imx/clk-scu.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)
drivers/clk/imx/clk-scu.c +1 -1
index 083da31dc3ea..2044e62980e3 100644
@@ -528,7 +528,7 @@ static int imx_clk_scu_probe(struct platform_device *pdev)
 		pm_runtime_use_autosuspend(&pdev->dev);
 		pm_runtime_enable(dev);
 
-		ret = pm_runtime_get_sync(dev);
+		ret = pm_runtime_resume_and_get(dev);
 		if (ret) {
 			pm_genpd_remove_device(dev);
 			pm_runtime_disable(dev);
Signature · 1 line
2.17.1
maintainer
#5 lore raw

Re: [PATCH v2] clk: imx: scu: Use pm_runtime_resume_and_get to fix pm_runtime_get_sync() usage

Quoting Miaoqian Lin (2022-04-21 18:33:16)

Quoted 10 lines

If the device is already in a runtime PM enabled state pm_runtime_get_sync() will return 1.

Also, we need to call pm_runtime_put_noidle() when pm_runtime_get_sync() fails, so use pm_runtime_resume_and_get() instead. this function will handle this.

Fixes 78edeb080330 ("clk: imx: scu: add runtime pm support")

---

Please don't send patches as replies to previous versions of the patch.

Quoted 19 lines
 drivers/clk/imx/clk-scu.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)
drivers/clk/imx/clk-scu.c +1 -1
index 083da31dc3ea..2044e62980e3 100644
@@ -528,7 +528,7 @@ static int imx_clk_scu_probe(struct platform_device *pdev)
                pm_runtime_use_autosuspend(&pdev->dev);
                pm_runtime_enable(dev);
 
-               ret = pm_runtime_get_sync(dev);
+               ret = pm_runtime_resume_and_get(dev);
                if (ret) {
                        pm_genpd_remove_device(dev);
                        pm_runtime_disable(dev);
Signature · 1 line
2.17.1
#6 lore raw

Re: [PATCH v2] clk: imx: scu: Use pm_runtime_resume_and_get to fix pm_runtime_get_sync() usage

Quoted 4 lines · Stephen Boyd

Quoting Miaoqian Lin (2022-04-21 18:33:16)

Quoted 3 lines

If the device is already in a runtime PM enabled state pm_runtime_get_sync() will return 1.

Quoted 8 lines
Quoted 7 lines

Also, we need to call pm_runtime_put_noidle() when pm_runtime_get_sync() fails, so use pm_runtime_resume_and_get() instead. this function will handle this.

Fixes 78edeb080330 ("clk: imx: scu: add runtime pm support")

---

Please don't send patches as replies to previous versions of the patch.

Sorry, I thought I should keep them in one thread, to provide the context

for other people to follow up. Am I suppose to resend it?

Quoted 19 lines
Quoted 19 lines
 drivers/clk/imx/clk-scu.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)
drivers/clk/imx/clk-scu.c +1 -1
index 083da31dc3ea..2044e62980e3 100644
@@ -528,7 +528,7 @@ static int imx_clk_scu_probe(struct platform_device *pdev)
                pm_runtime_use_autosuspend(&pdev->dev);
                pm_runtime_enable(dev);
 
-               ret = pm_runtime_get_sync(dev);
+               ret = pm_runtime_resume_and_get(dev);
                if (ret) {
                        pm_genpd_remove_device(dev);
                        pm_runtime_disable(dev);
Signature · 1 line
2.17.1
maintainer
#7 lore raw

Re: [PATCH v2] clk: imx: scu: Use pm_runtime_resume_and_get to fix pm_runtime_get_sync() usage

Quoting Miaoqian Lin (2022-04-21 18:59:54)

Quoted 10 lines · Stephen Boyd
Quoted 8 lines

Quoting Miaoqian Lin (2022-04-21 18:33:16)

Quoted 7 lines

If the device is already in a runtime PM enabled state pm_runtime_get_sync() will return 1.

Also, we need to call pm_runtime_put_noidle() when pm_runtime_get_sync() fails, so use pm_runtime_resume_and_get() instead. this function will handle this.

Quoted 6 lines
Quoted 4 lines
Quoted 3 lines
Fixes 78edeb080330 ("clk: imx: scu: add runtime pm support")

---

Please don't send patches as replies to previous versions of the patch.

Sorry, I thought I should keep them in one thread, to provide the context

Please link back to previous revisions with lore.

https://lore.kernel.org/r/<message-id-of-rev1>

and then add a change log below the triple dash referencing that lore link and anything that has changed since that revision.

Quoted 2 lines

for other people to follow up. Am I suppose to resend it?

Yes. Might as well practice making a changelog at the same time.