Skip to contentSkip to conversation

watchdog: starfive: Fix the probe return error if PM and early_enable are both disabled

PATCH Superseded Xingyu Wu 2 participants 5 messages Apr 25, 2023 – Apr 26, 2023

Subsystems (2)

v1 of 2 Superseded Latest is v2 →

lore
Share & tools
lore

Xingyu Wu

author maintainer
#0 lore raw

PATCH 1/1 watchdog: starfive: Fix the probe return error if PM and early_enable are both disabled

When the starfive watchdog driver uses 'pm_runtime_put_sync()' as probe return value at last and 'early_enable' is disabled, it could return the error '-ENOSYS' if the CONFIG_PM is disabled, but the driver should works normally.

Add a check to make sure the PM is enabled and then use 'pm_runtime_put_sync()' as return value when 'early_enable' is disabled.

Fixes db728ea9c7be ("drivers: watchdog: Add StarFive Watchdog driver")

---

Hi, Guenter and Wim,

This patch fixes the issue of StarFive watchdog driver and rebases on the master branch of linux-next.

Thanks.

---
 drivers/watchdog/starfive-wdt.c | 3 ++-
 1 file changed, 2 insertions(+), 1 deletion(-)
drivers/watchdog/starfive-wdt.c +2 -1
index 1995cceca51e..51e487e09960 100644
@@ -492,7 +492,8 @@ static int starfive_wdt_probe(struct platform_device *pdev)
 		goto err_exit;
 
 	if (!early_enable)
-		return pm_runtime_put_sync(&pdev->dev);
+		if (pm_runtime_enabled(&pdev->dev))
+			return pm_runtime_put_sync(&pdev->dev);
 
 	return 0;
 
Signature · 1 line
2.25.1
maintainer
#1 lore raw
Quoted 28 lines · Xingyu Wu

When the starfive watchdog driver uses 'pm_runtime_put_sync()' as probe return value at last and 'early_enable' is disabled, it could return the error '-ENOSYS' if the CONFIG_PM is disabled, but the driver should works normally.

Add a check to make sure the PM is enabled and then use 'pm_runtime_put_sync()' as return value when 'early_enable' is disabled.

Fixes db728ea9c7be ("drivers: watchdog: Add StarFive Watchdog driver")

---

Hi, Guenter and Wim,

This patch fixes the issue of StarFive watchdog driver and rebases on the master branch of linux-next.

Thanks.

---
  drivers/watchdog/starfive-wdt.c | 3 ++-
  1 file changed, 2 insertions(+), 1 deletion(-)
drivers/watchdog/starfive-wdt.c +0 -0
index 1995cceca51e..51e487e09960 100644

drivers/watchdog/starfive-wdt.c static int starfive_wdt_probe(struct platform_device *pdev) · line 497

Quoted 7 lines
drivers/watchdog/starfive-wdt.c +2 -1
@@ -492,7 +492,8 @@ static int starfive_wdt_probe(struct platform_device *pdev)
  		goto err_exit;
 
  	if (!early_enable)
-		return pm_runtime_put_sync(&pdev->dev);
+		if (pm_runtime_enabled(&pdev->dev))
+			return pm_runtime_put_sync(&pdev->dev);
 

Why not just

	if (!early_enable)
		pm_runtime_put_sync(&pdev->dev)

like almost every other caller of pm_runtime_put_sync() ?

Guenter

author maintainer
#2 lore raw
Quoted 37 lines · Guenter Roeck
Quoted 32 lines · Xingyu Wu

When the starfive watchdog driver uses 'pm_runtime_put_sync()' as probe return value at last and 'early_enable' is disabled, it could return the error '-ENOSYS' if the CONFIG_PM is disabled, but the driver should works normally.

Add a check to make sure the PM is enabled and then use 'pm_runtime_put_sync()' as return value when 'early_enable' is disabled.

Fixes db728ea9c7be ("drivers: watchdog: Add StarFive Watchdog driver")

---

Hi, Guenter and Wim,

This patch fixes the issue of StarFive watchdog driver and rebases on the master branch of linux-next.

Thanks.
  ---
  drivers/watchdog/starfive-wdt.c | 3 ++-

  1 file changed, 2 insertions(+), 1 deletion(-)
drivers/watchdog/starfive-wdt.c +2 -1
index 1995cceca51e..51e487e09960 100644
@@ -492,7 +492,8 @@ static int starfive_wdt_probe(struct platform_device *pdev)
           goto err_exit;
         if (!early_enable)
-        return pm_runtime_put_sync(&pdev->dev);
+        if (pm_runtime_enabled(&pdev->dev))
+            return pm_runtime_put_sync(&pdev->dev);
Quoted 1 line

Why not just

Quoted 5 lines

    if (!early_enable)
        pm_runtime_put_sync(&pdev->dev)

like almost every other caller of pm_runtime_put_sync() ?

The function of pm_runtime_put_sync() is that:

static inline int pm_runtime_put_sync(struct device *dev)

{
	return __pm_runtime_idle(dev, RPM_GET_PUT);
}

and when do not enable CONFIG_PM, the __pm_runtime_idle() is that:

static inline int __pm_runtime_idle(struct device *dev, int rpmflags)

{
	return -ENOSYS;
}

If I do not open PM, it will return error saying probe failed but it works fine without PM. I had tested that and probe really was failed. So I should add this check before using pm_runtime_put_sync().

Best regards,
Xingyu Wu

maintainer
#3 lore raw
Quoted 53 lines · Xingyu Wu
Quoted 37 lines · Guenter Roeck
Quoted 27 lines · Xingyu Wu

When the starfive watchdog driver uses 'pm_runtime_put_sync()' as probe return value at last and 'early_enable' is disabled, it could return the error '-ENOSYS' if the CONFIG_PM is disabled, but the driver should works normally.

Add a check to make sure the PM is enabled and then use 'pm_runtime_put_sync()' as return value when 'early_enable' is disabled.

Fixes db728ea9c7be ("drivers: watchdog: Add StarFive Watchdog driver")

---

Hi, Guenter and Wim,

This patch fixes the issue of StarFive watchdog driver and rebases on the master branch of linux-next.

Thanks.
  ---

   drivers/watchdog/starfive-wdt.c | 3 ++-
   1 file changed, 2 insertions(+), 1 deletion(-)
drivers/watchdog/starfive-wdt.c +0 -0
index 1995cceca51e..51e487e09960 100644

drivers/watchdog/starfive-wdt.c static int starfive_wdt_probe(struct platform_device *pdev) · line 496

Quoted 6 lines
drivers/watchdog/starfive-wdt.c +2 -1
@@ -492,7 +492,8 @@ static int starfive_wdt_probe(struct platform_device *pdev)
           goto err_exit;
         if (!early_enable)
-        return pm_runtime_put_sync(&pdev->dev);
+        if (pm_runtime_enabled(&pdev->dev))
+            return pm_runtime_put_sync(&pdev->dev);
 

Why not just

Quoted 5 lines

    if (!early_enable)
        pm_runtime_put_sync(&pdev->dev)

like almost every other caller of pm_runtime_put_sync() ?

The function of pm_runtime_put_sync() is that:

static inline int pm_runtime_put_sync(struct device *dev)

{
	return __pm_runtime_idle(dev, RPM_GET_PUT);
}

and when do not enable CONFIG_PM, the __pm_runtime_idle() is that:

Quoted 9 lines

static inline int __pm_runtime_idle(struct device *dev, int rpmflags)

{
	return -ENOSYS;
}

If I do not open PM, it will return error saying probe failed but it works fine without PM. I had tested that and probe really was failed. So I should add this check before using pm_runtime_put_sync().

You did not answer my question.

Guenter

author maintainer
#4 lore raw
Quoted 59 lines · Guenter Roeck
Quoted 58 lines · Xingyu Wu
Quoted 37 lines · Guenter Roeck
Quoted 32 lines · Xingyu Wu

When the starfive watchdog driver uses 'pm_runtime_put_sync()' as probe return value at last and 'early_enable' is disabled, it could return the error '-ENOSYS' if the CONFIG_PM is disabled, but the driver should works normally.

Add a check to make sure the PM is enabled and then use 'pm_runtime_put_sync()' as return value when 'early_enable' is disabled.

Fixes db728ea9c7be ("drivers: watchdog: Add StarFive Watchdog driver")

---

Hi, Guenter and Wim,

This patch fixes the issue of StarFive watchdog driver and rebases on the master branch of linux-next.

Thanks.
   ---
   drivers/watchdog/starfive-wdt.c | 3 ++-

   1 file changed, 2 insertions(+), 1 deletion(-)
drivers/watchdog/starfive-wdt.c +2 -1
index 1995cceca51e..51e487e09960 100644
@@ -492,7 +492,8 @@ static int starfive_wdt_probe(struct platform_device *pdev)
            goto err_exit;
          if (!early_enable)
-        return pm_runtime_put_sync(&pdev->dev);
+        if (pm_runtime_enabled(&pdev->dev))
+            return pm_runtime_put_sync(&pdev->dev);
Quoted 1 line

Why not just

Quoted 5 lines

     if (!early_enable)
         pm_runtime_put_sync(&pdev->dev)

like almost every other caller of pm_runtime_put_sync() ?

The function of pm_runtime_put_sync() is that:

static inline int pm_runtime_put_sync(struct device *dev) {
    return __pm_runtime_idle(dev, RPM_GET_PUT); }

and when do not enable CONFIG_PM, the __pm_runtime_idle() is that:

static inline int __pm_runtime_idle(struct device *dev, int rpmflags) {
    return -ENOSYS;
}

Quoted 7 lines
Quoted 4 lines

If I do not open PM, it will return error saying probe failed but it works fine without PM. I had tested that and probe really was failed. So I should add this check before using pm_runtime_put_sync().

You did not answer my question.

Oh sorry, I did not notice that you dropped the 'return'. It looks simpler.

Best regards,
Xingyu Wu