* [PATCH] watchdog: cadence_wdt: Fix the suspend resume
@ 2016-08-16 10:17 Shubhrajyoti Datta
2016-08-16 16:34 ` Guenter Roeck
0 siblings, 1 reply; 3+ messages in thread
From: Shubhrajyoti Datta @ 2016-08-16 10:17 UTC (permalink / raw)
To: linux-watchdog; +Cc: linux, shubhrajyoti.datta, Shubhrajyoti Datta
Currently even if no users are there the suspend tries to
stop the watchdog and resume starts the watchdog.
So after resume the watchdog starts and resets the board.
Fix the same by adding a check for users.
Signed-off-by: Shubhrajyoti Datta <shubhrajyoti.datta@xilinx.com>
---
drivers/watchdog/cadence_wdt.c | 22 +++++++++++++++-------
1 file changed, 15 insertions(+), 7 deletions(-)
diff --git a/drivers/watchdog/cadence_wdt.c b/drivers/watchdog/cadence_wdt.c
index 4dda902..b58343c 100644
--- a/drivers/watchdog/cadence_wdt.c
+++ b/drivers/watchdog/cadence_wdt.c
@@ -77,6 +77,7 @@ MODULE_PARM_DESC(nowayout,
struct cdns_wdt {
void __iomem *regs;
bool rst;
+ bool cdns_wdt_users;
struct clk *clk;
u32 prescaler;
u32 ctrl_clksel;
@@ -129,6 +130,7 @@ static int cdns_wdt_stop(struct watchdog_device *wdd)
struct cdns_wdt *wdt = watchdog_get_drvdata(wdd);
spin_lock(&wdt->io_lock);
+ wdt->cdns_wdt_users = false;
cdns_wdt_writereg(wdt, CDNS_WDT_ZMR_OFFSET,
CDNS_WDT_ZMR_ZKEY_VAL & (~CDNS_WDT_ZMR_WDEN_MASK));
spin_unlock(&wdt->io_lock);
@@ -182,6 +184,7 @@ static int cdns_wdt_start(struct watchdog_device *wdd)
unsigned short count;
unsigned long clock_f = clk_get_rate(wdt->clk);
+ wdt->cdns_wdt_users = true;
/*
* Counter value divisor to obtain the value of
* counter reset to be written to control register.
@@ -298,6 +301,7 @@ static int cdns_wdt_probe(struct platform_device *pdev)
if (!wdt)
return -ENOMEM;
+ wdt->cdns_wdt_users = false;
cdns_wdt_device = &wdt->cdns_wdt_device;
cdns_wdt_device->info = &cdns_wdt_info;
cdns_wdt_device->ops = &cdns_wdt_ops;
@@ -424,8 +428,10 @@ static int __maybe_unused cdns_wdt_suspend(struct device *dev)
struct platform_device *pdev = to_platform_device(dev);
struct cdns_wdt *wdt = platform_get_drvdata(pdev);
- cdns_wdt_stop(&wdt->cdns_wdt_device);
- clk_disable_unprepare(wdt->clk);
+ if (wdt->cdns_wdt_users) {
+ cdns_wdt_stop(&wdt->cdns_wdt_device);
+ clk_disable_unprepare(wdt->clk);
+ }
return 0;
}
@@ -442,12 +448,14 @@ static int __maybe_unused cdns_wdt_resume(struct device *dev)
struct platform_device *pdev = to_platform_device(dev);
struct cdns_wdt *wdt = platform_get_drvdata(pdev);
- ret = clk_prepare_enable(wdt->clk);
- if (ret) {
- dev_err(dev, "unable to enable clock\n");
- return ret;
+ if (wdt->cdns_wdt_users) {
+ ret = clk_prepare_enable(wdt->clk);
+ if (ret) {
+ dev_err(dev, "unable to enable clock\n");
+ return ret;
+ }
+ cdns_wdt_start(&wdt->cdns_wdt_device);
}
- cdns_wdt_start(&wdt->cdns_wdt_device);
return 0;
}
--
2.1.1
^ permalink raw reply related [flat|nested] 3+ messages in thread
* Re: [PATCH] watchdog: cadence_wdt: Fix the suspend resume
2016-08-16 10:17 [PATCH] watchdog: cadence_wdt: Fix the suspend resume Shubhrajyoti Datta
@ 2016-08-16 16:34 ` Guenter Roeck
2016-08-17 6:12 ` Shubhrajyoti Datta
0 siblings, 1 reply; 3+ messages in thread
From: Guenter Roeck @ 2016-08-16 16:34 UTC (permalink / raw)
To: Shubhrajyoti Datta; +Cc: linux-watchdog, shubhrajyoti.datta
On Tue, Aug 16, 2016 at 03:47:32PM +0530, Shubhrajyoti Datta wrote:
> Currently even if no users are there the suspend tries to
> stop the watchdog and resume starts the watchdog.
>
> So after resume the watchdog starts and resets the board.
> Fix the same by adding a check for users.
>
> Signed-off-by: Shubhrajyoti Datta <shubhrajyoti.datta@xilinx.com>
> ---
> drivers/watchdog/cadence_wdt.c | 22 +++++++++++++++-------
> 1 file changed, 15 insertions(+), 7 deletions(-)
>
> diff --git a/drivers/watchdog/cadence_wdt.c b/drivers/watchdog/cadence_wdt.c
> index 4dda902..b58343c 100644
> --- a/drivers/watchdog/cadence_wdt.c
> +++ b/drivers/watchdog/cadence_wdt.c
> @@ -77,6 +77,7 @@ MODULE_PARM_DESC(nowayout,
> struct cdns_wdt {
> void __iomem *regs;
> bool rst;
> + bool cdns_wdt_users;
> struct clk *clk;
> u32 prescaler;
> u32 ctrl_clksel;
> @@ -129,6 +130,7 @@ static int cdns_wdt_stop(struct watchdog_device *wdd)
> struct cdns_wdt *wdt = watchdog_get_drvdata(wdd);
>
> spin_lock(&wdt->io_lock);
> + wdt->cdns_wdt_users = false;
Why not use watchdog_active() ?
Guenter
> cdns_wdt_writereg(wdt, CDNS_WDT_ZMR_OFFSET,
> CDNS_WDT_ZMR_ZKEY_VAL & (~CDNS_WDT_ZMR_WDEN_MASK));
> spin_unlock(&wdt->io_lock);
> @@ -182,6 +184,7 @@ static int cdns_wdt_start(struct watchdog_device *wdd)
> unsigned short count;
> unsigned long clock_f = clk_get_rate(wdt->clk);
>
> + wdt->cdns_wdt_users = true;
> /*
> * Counter value divisor to obtain the value of
> * counter reset to be written to control register.
> @@ -298,6 +301,7 @@ static int cdns_wdt_probe(struct platform_device *pdev)
> if (!wdt)
> return -ENOMEM;
>
> + wdt->cdns_wdt_users = false;
> cdns_wdt_device = &wdt->cdns_wdt_device;
> cdns_wdt_device->info = &cdns_wdt_info;
> cdns_wdt_device->ops = &cdns_wdt_ops;
> @@ -424,8 +428,10 @@ static int __maybe_unused cdns_wdt_suspend(struct device *dev)
> struct platform_device *pdev = to_platform_device(dev);
> struct cdns_wdt *wdt = platform_get_drvdata(pdev);
>
> - cdns_wdt_stop(&wdt->cdns_wdt_device);
> - clk_disable_unprepare(wdt->clk);
> + if (wdt->cdns_wdt_users) {
> + cdns_wdt_stop(&wdt->cdns_wdt_device);
> + clk_disable_unprepare(wdt->clk);
> + }
>
> return 0;
> }
> @@ -442,12 +448,14 @@ static int __maybe_unused cdns_wdt_resume(struct device *dev)
> struct platform_device *pdev = to_platform_device(dev);
> struct cdns_wdt *wdt = platform_get_drvdata(pdev);
>
> - ret = clk_prepare_enable(wdt->clk);
> - if (ret) {
> - dev_err(dev, "unable to enable clock\n");
> - return ret;
> + if (wdt->cdns_wdt_users) {
> + ret = clk_prepare_enable(wdt->clk);
> + if (ret) {
> + dev_err(dev, "unable to enable clock\n");
> + return ret;
> + }
> + cdns_wdt_start(&wdt->cdns_wdt_device);
> }
> - cdns_wdt_start(&wdt->cdns_wdt_device);
>
> return 0;
> }
> --
> 2.1.1
>
> --
> To unsubscribe from this list: send the line "unsubscribe linux-watchdog" in
> the body of a message to majordomo@vger.kernel.org
> More majordomo info at http://vger.kernel.org/majordomo-info.html
^ permalink raw reply [flat|nested] 3+ messages in thread
* Re: [PATCH] watchdog: cadence_wdt: Fix the suspend resume
2016-08-16 16:34 ` Guenter Roeck
@ 2016-08-17 6:12 ` Shubhrajyoti Datta
0 siblings, 0 replies; 3+ messages in thread
From: Shubhrajyoti Datta @ 2016-08-17 6:12 UTC (permalink / raw)
To: Guenter Roeck; +Cc: Shubhrajyoti Datta, linux-watchdog
On Tue, Aug 16, 2016 at 10:04 PM, Guenter Roeck <linux@roeck-us.net> wrote:
> On Tue, Aug 16, 2016 at 03:47:32PM +0530, Shubhrajyoti Datta wrote:
>> Currently even if no users are there the suspend tries to
>> stop the watchdog and resume starts the watchdog.
>>
>> So after resume the watchdog starts and resets the board.
>> Fix the same by adding a check for users.
>>
>> Signed-off-by: Shubhrajyoti Datta <shubhrajyoti.datta@xilinx.com>
>> ---
>> drivers/watchdog/cadence_wdt.c | 22 +++++++++++++++-------
>> 1 file changed, 15 insertions(+), 7 deletions(-)
>>
>> diff --git a/drivers/watchdog/cadence_wdt.c b/drivers/watchdog/cadence_wdt.c
>> index 4dda902..b58343c 100644
>> --- a/drivers/watchdog/cadence_wdt.c
>> +++ b/drivers/watchdog/cadence_wdt.c
>> @@ -77,6 +77,7 @@ MODULE_PARM_DESC(nowayout,
>> struct cdns_wdt {
>> void __iomem *regs;
>> bool rst;
>> + bool cdns_wdt_users;
>> struct clk *clk;
>> u32 prescaler;
>> u32 ctrl_clksel;
>> @@ -129,6 +130,7 @@ static int cdns_wdt_stop(struct watchdog_device *wdd)
>> struct cdns_wdt *wdt = watchdog_get_drvdata(wdd);
>>
>> spin_lock(&wdt->io_lock);
>> + wdt->cdns_wdt_users = false;
>
> Why not use watchdog_active() ?
will fix in next version
>
> Guenter
>
^ permalink raw reply [flat|nested] 3+ messages in thread
end of thread, other threads:[~2016-08-17 6:12 UTC | newest]
Thread overview: 3+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2016-08-16 10:17 [PATCH] watchdog: cadence_wdt: Fix the suspend resume Shubhrajyoti Datta
2016-08-16 16:34 ` Guenter Roeck
2016-08-17 6:12 ` Shubhrajyoti Datta
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).