All of lore.kernel.org
 help / color / mirror / Atom feed
* [PATCH] rtc: ds1374: wdt:support suspend/resume for watchdog
@ 2017-10-10 13:12 winton.liu
  2017-10-10 13:41 ` Guenter Roeck
  0 siblings, 1 reply; 12+ messages in thread
From: winton.liu @ 2017-10-10 13:12 UTC (permalink / raw)
  To: a.zummo, alexandre.belloni, linux
  Cc: linux-rtc, linux-kernel, linux-watchdog, winton.liu

When enable CONFIG_RTC_DRV_DS1374_WDT use as watchdog,
in suspend mode, watchdog is still working but no daemon
patting the watchdog. The system will reboot if timeout.

Add support suspend/resume for watchdog.
suspend: disable the watchdog
resume: disable existing watchdog, reload watchdog timer, enable watchdog

Signed-off-by: winton.liu <18502523564@163.com>
---
 drivers/rtc/rtc-ds1374.c | 31 +++++++++++++++++++++++++++++++
 1 file changed, 31 insertions(+)

diff --git a/drivers/rtc/rtc-ds1374.c b/drivers/rtc/rtc-ds1374.c
index 38a2e9e..642e31d 100644
--- a/drivers/rtc/rtc-ds1374.c
+++ b/drivers/rtc/rtc-ds1374.c
@@ -437,6 +437,29 @@ static void ds1374_wdt_ping(void)
 		pr_info("WD TICK FAIL!!!!!!!!!! %i\n", ret);
 }
 
+static void ds1374_wdt_resume(void)
+{
+	int ret = -ENOIOCTLCMD;
+	int cr;
+
+	cr = i2c_smbus_read_byte_data(save_client, DS1374_REG_CR);
+
+	/* Disable any existing watchdog/alarm before setting the new one */
+	cr &= ~DS1374_REG_CR_WACE;
+
+	i2c_smbus_write_byte_data(save_client, DS1374_REG_CR, cr);
+
+	/* Reload watchdog timer */
+	ds1374_wdt_ping();
+
+	/* Enable watchdog timer */
+	cr |= DS1374_REG_CR_WACE | DS1374_REG_CR_WDALM;
+	cr &= ~DS1374_REG_CR_AIE;
+
+	ret = i2c_smbus_write_byte_data(save_client, DS1374_REG_CR, cr);
+
+}
+
 static void ds1374_wdt_disable(void)
 {
 	int ret = -ENOIOCTLCMD;
@@ -690,6 +713,10 @@ static int ds1374_suspend(struct device *dev)
 {
 	struct i2c_client *client = to_i2c_client(dev);
 
+#ifdef CONFIG_RTC_DRV_DS1374_WDT
+	ds1374_wdt_disable();
+#endif
+
 	if (client->irq > 0 && device_may_wakeup(&client->dev))
 		enable_irq_wake(client->irq);
 	return 0;
@@ -699,6 +726,10 @@ static int ds1374_resume(struct device *dev)
 {
 	struct i2c_client *client = to_i2c_client(dev);
 
+#ifdef CONFIG_RTC_DRV_DS1374_WDT
+	ds1374_wdt_resume();
+#endif
+
 	if (client->irq > 0 && device_may_wakeup(&client->dev))
 		disable_irq_wake(client->irq);
 	return 0;
-- 
1.9.1

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

* Re: [PATCH] rtc: ds1374: wdt:support suspend/resume for watchdog
  2017-10-10 13:12 [PATCH] rtc: ds1374: wdt:support suspend/resume for watchdog winton.liu
@ 2017-10-10 13:41 ` Guenter Roeck
  2017-10-10 13:51   ` Alexandre Belloni
  0 siblings, 1 reply; 12+ messages in thread
From: Guenter Roeck @ 2017-10-10 13:41 UTC (permalink / raw)
  To: winton.liu, a.zummo, alexandre.belloni
  Cc: linux-rtc, linux-kernel, linux-watchdog

On 10/10/2017 06:12 AM, winton.liu wrote:
> When enable CONFIG_RTC_DRV_DS1374_WDT use as watchdog,
> in suspend mode, watchdog is still working but no daemon
> patting the watchdog. The system will reboot if timeout.
> 
> Add support suspend/resume for watchdog.
> suspend: disable the watchdog
> resume: disable existing watchdog, reload watchdog timer, enable watchdog
> 
> Signed-off-by: winton.liu <18502523564@163.com>
> ---
>   drivers/rtc/rtc-ds1374.c | 31 +++++++++++++++++++++++++++++++
>   1 file changed, 31 insertions(+)
> 
> diff --git a/drivers/rtc/rtc-ds1374.c b/drivers/rtc/rtc-ds1374.c
> index 38a2e9e..642e31d 100644
> --- a/drivers/rtc/rtc-ds1374.c
> +++ b/drivers/rtc/rtc-ds1374.c
> @@ -437,6 +437,29 @@ static void ds1374_wdt_ping(void)
>   		pr_info("WD TICK FAIL!!!!!!!!!! %i\n", ret);
>   }
>   
> +static void ds1374_wdt_resume(void)
> +{
> +	int ret = -ENOIOCTLCMD;

Useless initialization (yes, I can see that this is widely done in the driver,
but that doesn't make it better).

> +	int cr;
> +
> +	cr = i2c_smbus_read_byte_data(save_client, DS1374_REG_CR);
> +
> +	/* Disable any existing watchdog/alarm before setting the new one */
> +	cr &= ~DS1374_REG_CR_WACE;
> +
> +	i2c_smbus_write_byte_data(save_client, DS1374_REG_CR, cr);
> +
> +	/* Reload watchdog timer */
> +	ds1374_wdt_ping();
> +
> +	/* Enable watchdog timer */
> +	cr |= DS1374_REG_CR_WACE | DS1374_REG_CR_WDALM;
> +	cr &= ~DS1374_REG_CR_AIE;
> +
> +	ret = i2c_smbus_write_byte_data(save_client, DS1374_REG_CR, cr);
> +
Extra empty line. Also, returns void, so what is the point of assigning
the result to ret ?

> +}

Unless I am missing something, this unconditionally starts the watchdog
at resume time. So if it was not running before, it will be started anyway,
and the system will reboot since there will be no ping.

I assume it is guaranteed that the chip doesn't forget the previously
configured timeout on resume.

Overall the driver would really benefit from a conversion to the watchdog
subsystem.

> +
>   static void ds1374_wdt_disable(void)
>   {
>   	int ret = -ENOIOCTLCMD;
> @@ -690,6 +713,10 @@ static int ds1374_suspend(struct device *dev)
>   {
>   	struct i2c_client *client = to_i2c_client(dev);
>   
> +#ifdef CONFIG_RTC_DRV_DS1374_WDT
> +	ds1374_wdt_disable();
> +#endif
> +
>   	if (client->irq > 0 && device_may_wakeup(&client->dev))
>   		enable_irq_wake(client->irq);
>   	return 0;
> @@ -699,6 +726,10 @@ static int ds1374_resume(struct device *dev)
>   {
>   	struct i2c_client *client = to_i2c_client(dev);
>   
> +#ifdef CONFIG_RTC_DRV_DS1374_WDT
> +	ds1374_wdt_resume();
> +#endif
> +
>   	if (client->irq > 0 && device_may_wakeup(&client->dev))
>   		disable_irq_wake(client->irq);
>   	return 0;
> 

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

* Re: [PATCH] rtc: ds1374: wdt:support suspend/resume for watchdog
  2017-10-10 13:41 ` Guenter Roeck
@ 2017-10-10 13:51   ` Alexandre Belloni
  2017-10-10 15:05     ` Guenter Roeck
  0 siblings, 1 reply; 12+ messages in thread
From: Alexandre Belloni @ 2017-10-10 13:51 UTC (permalink / raw)
  To: Guenter Roeck
  Cc: winton.liu, a.zummo, linux-rtc, linux-kernel, linux-watchdog

On 10/10/2017 at 06:41:15 -0700, Guenter Roeck wrote:
> On 10/10/2017 06:12 AM, winton.liu wrote:
> > When enable CONFIG_RTC_DRV_DS1374_WDT use as watchdog,
> > in suspend mode, watchdog is still working but no daemon
> > patting the watchdog. The system will reboot if timeout.
> > 
> > Add support suspend/resume for watchdog.
> > suspend: disable the watchdog
> > resume: disable existing watchdog, reload watchdog timer, enable watchdog
> > 
> > Signed-off-by: winton.liu <18502523564@163.com>
> > ---
> >   drivers/rtc/rtc-ds1374.c | 31 +++++++++++++++++++++++++++++++
> >   1 file changed, 31 insertions(+)
> > 
> > diff --git a/drivers/rtc/rtc-ds1374.c b/drivers/rtc/rtc-ds1374.c
> > index 38a2e9e..642e31d 100644
> > --- a/drivers/rtc/rtc-ds1374.c
> > +++ b/drivers/rtc/rtc-ds1374.c
> > @@ -437,6 +437,29 @@ static void ds1374_wdt_ping(void)
> >   		pr_info("WD TICK FAIL!!!!!!!!!! %i\n", ret);
> >   }
> > +static void ds1374_wdt_resume(void)
> > +{
> > +	int ret = -ENOIOCTLCMD;
> 
> Useless initialization (yes, I can see that this is widely done in the driver,
> but that doesn't make it better).
> 
> > +	int cr;
> > +
> > +	cr = i2c_smbus_read_byte_data(save_client, DS1374_REG_CR);
> > +
> > +	/* Disable any existing watchdog/alarm before setting the new one */
> > +	cr &= ~DS1374_REG_CR_WACE;
> > +
> > +	i2c_smbus_write_byte_data(save_client, DS1374_REG_CR, cr);
> > +
> > +	/* Reload watchdog timer */
> > +	ds1374_wdt_ping();
> > +
> > +	/* Enable watchdog timer */
> > +	cr |= DS1374_REG_CR_WACE | DS1374_REG_CR_WDALM;
> > +	cr &= ~DS1374_REG_CR_AIE;
> > +
> > +	ret = i2c_smbus_write_byte_data(save_client, DS1374_REG_CR, cr);
> > +
> Extra empty line. Also, returns void, so what is the point of assigning
> the result to ret ?
> 
> > +}
> 
> Unless I am missing something, this unconditionally starts the watchdog
> at resume time. So if it was not running before, it will be started anyway,
> and the system will reboot since there will be no ping.
> 

Also, I'm still not convinced this is the right thing to do. I have seen
many systems were it was desirable to let the watchdog run while the
system is suspended. It ensures it will either wake up or reboot. If you
don't want that, why not disabling the watchdog from userspace before
going to suspend?

> I assume it is guaranteed that the chip doesn't forget the previously
> configured timeout on resume.
> 
> Overall the driver would really benefit from a conversion to the watchdog
> subsystem.
> 

That is the point of https://www.spinics.net/lists/linux-watchdog/msg12095.html

-- 
Alexandre Belloni, Free Electrons
Embedded Linux and Kernel engineering
http://free-electrons.com

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

* Re: [PATCH] rtc: ds1374: wdt:support suspend/resume for watchdog
  2017-10-10 13:51   ` Alexandre Belloni
@ 2017-10-10 15:05     ` Guenter Roeck
  2017-10-12 13:40         ` 刘稳
  0 siblings, 1 reply; 12+ messages in thread
From: Guenter Roeck @ 2017-10-10 15:05 UTC (permalink / raw)
  To: Alexandre Belloni
  Cc: winton.liu, a.zummo, linux-rtc, linux-kernel, linux-watchdog

On Tue, Oct 10, 2017 at 03:51:34PM +0200, Alexandre Belloni wrote:
> On 10/10/2017 at 06:41:15 -0700, Guenter Roeck wrote:
> > On 10/10/2017 06:12 AM, winton.liu wrote:
> > > When enable CONFIG_RTC_DRV_DS1374_WDT use as watchdog,
> > > in suspend mode, watchdog is still working but no daemon
> > > patting the watchdog. The system will reboot if timeout.
> > > 
> > > Add support suspend/resume for watchdog.
> > > suspend: disable the watchdog
> > > resume: disable existing watchdog, reload watchdog timer, enable watchdog
> > > 
> > > Signed-off-by: winton.liu <18502523564@163.com>
> > > ---
> > >   drivers/rtc/rtc-ds1374.c | 31 +++++++++++++++++++++++++++++++
> > >   1 file changed, 31 insertions(+)
> > > 
> > > diff --git a/drivers/rtc/rtc-ds1374.c b/drivers/rtc/rtc-ds1374.c
> > > index 38a2e9e..642e31d 100644
> > > --- a/drivers/rtc/rtc-ds1374.c
> > > +++ b/drivers/rtc/rtc-ds1374.c
> > > @@ -437,6 +437,29 @@ static void ds1374_wdt_ping(void)
> > >   		pr_info("WD TICK FAIL!!!!!!!!!! %i\n", ret);
> > >   }
> > > +static void ds1374_wdt_resume(void)
> > > +{
> > > +	int ret = -ENOIOCTLCMD;
> > 
> > Useless initialization (yes, I can see that this is widely done in the driver,
> > but that doesn't make it better).
> > 
> > > +	int cr;
> > > +
> > > +	cr = i2c_smbus_read_byte_data(save_client, DS1374_REG_CR);
> > > +
> > > +	/* Disable any existing watchdog/alarm before setting the new one */
> > > +	cr &= ~DS1374_REG_CR_WACE;
> > > +
> > > +	i2c_smbus_write_byte_data(save_client, DS1374_REG_CR, cr);
> > > +
> > > +	/* Reload watchdog timer */
> > > +	ds1374_wdt_ping();
> > > +
> > > +	/* Enable watchdog timer */
> > > +	cr |= DS1374_REG_CR_WACE | DS1374_REG_CR_WDALM;
> > > +	cr &= ~DS1374_REG_CR_AIE;
> > > +
> > > +	ret = i2c_smbus_write_byte_data(save_client, DS1374_REG_CR, cr);
> > > +
> > Extra empty line. Also, returns void, so what is the point of assigning
> > the result to ret ?
> > 
> > > +}
> > 
> > Unless I am missing something, this unconditionally starts the watchdog
> > at resume time. So if it was not running before, it will be started anyway,
> > and the system will reboot since there will be no ping.
> > 
> 
> Also, I'm still not convinced this is the right thing to do. I have seen
> many systems were it was desirable to let the watchdog run while the
> system is suspended. It ensures it will either wake up or reboot. If you
> don't want that, why not disabling the watchdog from userspace before
> going to suspend?
> 

Usually watchdog drivers supporting suspend/resume do handle it this way.
Maybe that depends on the HW. Expecting user space to do it makes it
even more racy than it already is, since there is no watchdog protection
after it has been disabled, so I am not sure if that is really better.
Does anyone happen to know if/how systemd and watchdogd are handling
this situation ?

> > I assume it is guaranteed that the chip doesn't forget the previously
> > configured timeout on resume.
> > 
> > Overall the driver would really benefit from a conversion to the watchdog
> > subsystem.
> > 
> 
> That is the point of https://www.spinics.net/lists/linux-watchdog/msg12095.html

Ah, yes, and I even provided feedback. Hope I didn't miss an updated
version of that patch. Either case, seems to me we should wait for that
patch to make it in before accepting any further changes to the driver.

Guenter

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

* Re:Re: [PATCH] rtc: ds1374: wdt:support suspend/resume for watchdog
  2017-10-10 15:05     ` Guenter Roeck
@ 2017-10-12 13:40         ` 刘稳
  0 siblings, 0 replies; 12+ messages in thread
From: 刘稳 @ 2017-10-12 13:40 UTC (permalink / raw)
  To: Guenter Roeck
  Cc: Alexandre Belloni, a.zummo, linux-rtc, linux-kernel, linux-watchdog











At 2017-10-10 23:05:14, "Guenter Roeck" <linux@roeck-us.net> wrote:
>On Tue, Oct 10, 2017 at 03:51:34PM +0200, Alexandre Belloni wrote:
>> On 10/10/2017 at 06:41:15 -0700, Guenter Roeck wrote:
>> > On 10/10/2017 06:12 AM, winton.liu wrote:
>> > > When enable CONFIG_RTC_DRV_DS1374_WDT use as watchdog,
>> > > in suspend mode, watchdog is still working but no daemon
>> > > patting the watchdog. The system will reboot if timeout.
>> > > 
>> > > Add support suspend/resume for watchdog.
>> > > suspend: disable the watchdog
>> > > resume: disable existing watchdog, reload watchdog timer, enable watchdog
>> > > 
>> > > Signed-off-by: winton.liu <18502523564@163.com>
>> > > ---
>> > >   drivers/rtc/rtc-ds1374.c | 31 +++++++++++++++++++++++++++++++
>> > >   1 file changed, 31 insertions(+)
>> > > 
>> > > diff --git a/drivers/rtc/rtc-ds1374.c b/drivers/rtc/rtc-ds1374.c
>> > > index 38a2e9e..642e31d 100644
>> > > --- a/drivers/rtc/rtc-ds1374.c
>> > > +++ b/drivers/rtc/rtc-ds1374.c
>> > > @@ -437,6 +437,29 @@ static void ds1374_wdt_ping(void)
>> > >   		pr_info("WD TICK FAIL!!!!!!!!!! %i\n", ret);
>> > >   }
>> > > +static void ds1374_wdt_resume(void)
>> > > +{
>> > > +	int ret = -ENOIOCTLCMD;
>> > 
>> > Useless initialization (yes, I can see that this is widely done in the driver,
>> > but that doesn't make it better).
>> > 
        Yes, I think this is useless. The original ds1374_wdt_disable has the same issue.
>> > > +	int cr;
>> > > +
>> > > +	cr = i2c_smbus_read_byte_data(save_client, DS1374_REG_CR);
>> > > +
>> > > +	/* Disable any existing watchdog/alarm before setting the new one */
>> > > +	cr &= ~DS1374_REG_CR_WACE;
>> > > +
>> > > +	i2c_smbus_write_byte_data(save_client, DS1374_REG_CR, cr);
>> > > +
>> > > +	/* Reload watchdog timer */
>> > > +	ds1374_wdt_ping();
>> > > +
>> > > +	/* Enable watchdog timer */
>> > > +	cr |= DS1374_REG_CR_WACE | DS1374_REG_CR_WDALM;
>> > > +	cr &= ~DS1374_REG_CR_AIE;
>> > > +
>> > > +	ret = i2c_smbus_write_byte_data(save_client, DS1374_REG_CR, cr);
>> > > +
>> > Extra empty line. Also, returns void, so what is the point of assigning
>> > the result to ret ?
>> > 
>> > > +}
>> > 
>> > Unless I am missing something, this unconditionally starts the watchdog
>> > at resume time. So if it was not running before, it will be started anyway,
>> > and the system will reboot since there will be no ping.
>> > 
    This driver starts watchdog by default. In probe watchdog starts: 
   #ifdef CONFIG_RTC_DRV_DS1374_WDT
    save_client = client;
    ret = misc_register(&ds1374_miscdev);
    if (ret)
        return ret;
    ret = register_reboot_notifier(&ds1374_wdt_notifier);
    if (ret) {
        misc_deregister(&ds1374_miscdev);
        return ret;
    }
    ds1374_wdt_settimeout(131072);   //Here starts watchdog
#endif
   And userspace watchdogd will ping.
>> 
>> Also, I'm still not convinced this is the right thing to do. I have seen
>> many systems were it was desirable to let the watchdog run while the
>> system is suspended. It ensures it will either wake up or reboot. If you
>> don't want that, why not disabling the watchdog from userspace before
>> going to suspend?
>> 
>
>Usually watchdog drivers supporting suspend/resume do handle it this way.
>Maybe that depends on the HW. Expecting user space to do it makes it
>even more racy than it already is, since there is no watchdog protection
>after it has been disabled, so I am not sure if that is really better.
>Does anyone happen to know if/how systemd and watchdogd are handling
>this situation ?
>
>> > I assume it is guaranteed that the chip doesn't forget the previously
>> > configured timeout on resume.
>> > 
>> > Overall the driver would really benefit from a conversion to the watchdog
>> > subsystem.
>> > 
>> 
>> That is the point of https://www.spinics.net/lists/linux-watchdog/msg12095.html
>
>Ah, yes, and I even provided feedback. Hope I didn't miss an updated
>version of that patch. Either case, seems to me we should wait for that
>patch to make it in before accepting any further changes to the driver.
>
   Is this multi function patch has any update ? If not, could my patch be acceptable before moving to watchdog subsystem.(I could update a new patch for your suggestion)?
   Because current kernel using ds1374 for watchdog. If the device need suspend, there will be a reboot issue.

>Guenter

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

* Re:Re: [PATCH] rtc: ds1374: wdt:support suspend/resume for watchdog
@ 2017-10-12 13:40         ` 刘稳
  0 siblings, 0 replies; 12+ messages in thread
From: 刘稳 @ 2017-10-12 13:40 UTC (permalink / raw)
  To: Guenter Roeck
  Cc: Alexandre Belloni, a.zummo, linux-rtc, linux-kernel, linux-watchdog

CgoKCgoKCgoKCkF0IDIwMTctMTAtMTAgMjM6MDU6MTQsICJHdWVudGVyIFJvZWNrIiA8bGludXhA
cm9lY2stdXMubmV0PiB3cm90ZToKPk9uIFR1ZSwgT2N0IDEwLCAyMDE3IGF0IDAzOjUxOjM0UE0g
KzAyMDAsIEFsZXhhbmRyZSBCZWxsb25pIHdyb3RlOgo+PiBPbiAxMC8xMC8yMDE3IGF0IDA2OjQx
OjE1IC0wNzAwLCBHdWVudGVyIFJvZWNrIHdyb3RlOgo+PiA+IE9uIDEwLzEwLzIwMTcgMDY6MTIg
QU0sIHdpbnRvbi5saXUgd3JvdGU6Cj4+ID4gPiBXaGVuIGVuYWJsZSBDT05GSUdfUlRDX0RSVl9E
UzEzNzRfV0RUIHVzZSBhcyB3YXRjaGRvZywKPj4gPiA+IGluIHN1c3BlbmQgbW9kZSwgd2F0Y2hk
b2cgaXMg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lIGN1cnJlbnQga2VybmVsIHVzaW5nIGRz
MTM3NCBmb3Igd2F0Y2hkb2cuIElmIHRoZSBkZXZpY2UgbmVlZCBzdXNwZW5kLCB0aGVyZSB3aWxs
IGJlIGEgcmVib290IGlzc3VlLgoKPkd1ZW50ZXIK

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

* Re: [PATCH] rtc: ds1374: wdt:support suspend/resume for watchdog
  2017-10-12 13:40         ` 刘稳
  (?)
@ 2017-10-12 14:12         ` Guenter Roeck
  -1 siblings, 0 replies; 12+ messages in thread
From: Guenter Roeck @ 2017-10-12 14:12 UTC (permalink / raw)
  To: 刘稳
  Cc: Alexandre Belloni, a.zummo, linux-rtc, linux-kernel, linux-watchdog

On 10/12/2017 06:40 AM, 刘稳 wrote:
> 
> 
> 
> 
> 
> 
> 
> 
> 
> 
> At 2017-10-10 23:05:14, "Guenter Roeck" <linux@roeck-us.net> wrote:
>> On Tue, Oct 10, 2017 at 03:51:34PM +0200, Alexandre Belloni wrote:
>>> On 10/10/2017 at 06:41:15 -0700, Guenter Roeck wrote:
>>>> On 10/10/2017 06:12 AM, winton.liu wrote:
>>>>> When enable CONFIG_RTC_DRV_DS1374_WDT use as watchdog,
>>>>> in suspend mode, watchdog is still working but no daemon
>>>>> patting the watchdog. The system will reboot if timeout.
>>>>>
>>>>> Add support suspend/resume for watchdog.
>>>>> suspend: disable the watchdog
>>>>> resume: disable existing watchdog, reload watchdog timer, enable watchdog
>>>>>
>>>>> Signed-off-by: winton.liu <18502523564@163.com>
>>>>> ---
>>>>>    drivers/rtc/rtc-ds1374.c | 31 +++++++++++++++++++++++++++++++
>>>>>    1 file changed, 31 insertions(+)
>>>>>
>>>>> diff --git a/drivers/rtc/rtc-ds1374.c b/drivers/rtc/rtc-ds1374.c
>>>>> index 38a2e9e..642e31d 100644
>>>>> --- a/drivers/rtc/rtc-ds1374.c
>>>>> +++ b/drivers/rtc/rtc-ds1374.c
>>>>> @@ -437,6 +437,29 @@ static void ds1374_wdt_ping(void)
>>>>>    		pr_info("WD TICK FAIL!!!!!!!!!! %i\n", ret);
>>>>>    }
>>>>> +static void ds1374_wdt_resume(void)
>>>>> +{
>>>>> +	int ret = -ENOIOCTLCMD;
>>>>
>>>> Useless initialization (yes, I can see that this is widely done in the driver,
>>>> but that doesn't make it better).
>>>>
>          Yes, I think this is useless. The original ds1374_wdt_disable has the same issue.

That doesn't make it better and is not an argument.

>>>>> +	int cr;
>>>>> +
>>>>> +	cr = i2c_smbus_read_byte_data(save_client, DS1374_REG_CR);
>>>>> +
>>>>> +	/* Disable any existing watchdog/alarm before setting the new one */
>>>>> +	cr &= ~DS1374_REG_CR_WACE;
>>>>> +
>>>>> +	i2c_smbus_write_byte_data(save_client, DS1374_REG_CR, cr);
>>>>> +
>>>>> +	/* Reload watchdog timer */
>>>>> +	ds1374_wdt_ping();
>>>>> +
>>>>> +	/* Enable watchdog timer */
>>>>> +	cr |= DS1374_REG_CR_WACE | DS1374_REG_CR_WDALM;
>>>>> +	cr &= ~DS1374_REG_CR_AIE;
>>>>> +
>>>>> +	ret = i2c_smbus_write_byte_data(save_client, DS1374_REG_CR, cr);
>>>>> +
>>>> Extra empty line. Also, returns void, so what is the point of assigning
>>>> the result to ret ?
>>>>
>>>>> +}
>>>>
>>>> Unless I am missing something, this unconditionally starts the watchdog
>>>> at resume time. So if it was not running before, it will be started anyway,
>>>> and the system will reboot since there will be no ping.
>>>>
>      This driver starts watchdog by default. In probe watchdog starts:
>     #ifdef CONFIG_RTC_DRV_DS1374_WDT
>      save_client = client;
>      ret = misc_register(&ds1374_miscdev);
>      if (ret)
>          return ret;
>      ret = register_reboot_notifier(&ds1374_wdt_notifier);
>      if (ret) {
>          misc_deregister(&ds1374_miscdev);
>          return ret;
>      }
>      ds1374_wdt_settimeout(131072);   //Here starts watchdog

Meaning the system will reboot unless the watchdog device is opened ?
Weird, and conceptually wrong.

What if the watchdog device is stopped explicitly by the watchdog demon ?

> #endif
>     And userspace watchdogd will ping.
>>>
>>> Also, I'm still not convinced this is the right thing to do. I have seen
>>> many systems were it was desirable to let the watchdog run while the
>>> system is suspended. It ensures it will either wake up or reboot. If you
>>> don't want that, why not disabling the watchdog from userspace before
>>> going to suspend?
>>>
>>
>> Usually watchdog drivers supporting suspend/resume do handle it this way.
>> Maybe that depends on the HW. Expecting user space to do it makes it
>> even more racy than it already is, since there is no watchdog protection
>> after it has been disabled, so I am not sure if that is really better.
>> Does anyone happen to know if/how systemd and watchdogd are handling
>> this situation ?
>>
>>>> I assume it is guaranteed that the chip doesn't forget the previously
>>>> configured timeout on resume.
>>>>
>>>> Overall the driver would really benefit from a conversion to the watchdog
>>>> subsystem.
>>>>
>>>
>>> That is the point of https://www.spinics.net/lists/linux-watchdog/msg12095.html
>>
>> Ah, yes, and I even provided feedback. Hope I didn't miss an updated
>> version of that patch. Either case, seems to me we should wait for that
>> patch to make it in before accepting any further changes to the driver.
>>
>     Is this multi function patch has any update ? If not, could my patch be acceptable before moving to watchdog subsystem.(I could update a new patch for your suggestion)?
>     Because current kernel using ds1374 for watchdog. If the device need suspend, there will be a reboot issue.
> 
Only if CONFIG_RTC_DRV_DS1374_WDT is enabled, and then it appears the driver
has other problems such as unconditionally enabling the watchdog.
Given that, I am not in favor of temporary changes.

Guenter

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

* Re: [PATCH] rtc: ds1374: wdt:support suspend/resume for watchdog
  2017-09-26 10:22     ` Alexandre Belloni
@ 2017-09-26 13:52       ` Guenter Roeck
  0 siblings, 0 replies; 12+ messages in thread
From: Guenter Roeck @ 2017-09-26 13:52 UTC (permalink / raw)
  To: Alexandre Belloni, 18502523564
  Cc: a.zummo, linux-rtc, linux-kernel, Wim Van Sebroeck, linux-watchdog

On 09/26/2017 03:22 AM, Alexandre Belloni wrote:
> (+Cc wdt maintainers)
> 
> On 26/09/2017 at 09:56:32 +0800, 18502523564 wrote:
>> Hi Alexandre,
>>
>> Thanks for your reply.
>> Do you think is this a issue when using as a watchdog in suspend?
>> I takes the drivers/watchdog/ subsystem for reference, some drivers in suspend
>> also call disable_watchdog.Or do you have any  better suggestion?
> 
> I guess this is a question for the watchdog subsystem maintainers.
> However, I think that everything can be handled properly from userspace
> as I know some atmel based devices have their watchdog enabled while
> the platform is suspended.
> 

Depends on the driver, really. There is one thing wrong below, though:
It appears that on resume, the watchdog is unconditionally enabled.

Guenter

>> Thank you.
>>
>>
>>
>>
>> ------------------ Original ------------------
>> From: Alexandre Belloni <alexandre.belloni@free-electrons.com>
>> Date: 周一,9月 25,2017 20:07
>> To: winton.liu <18502523564@163.com>
>> Cc: a.zummo <a.zummo@towertech.it>, linux-rtc <linux-rtc@vger.kernel.org>,
>> linux-kernel <linux-kernel@vger.kernel.org>
>> Subject: Re: [PATCH] rtc: ds1374: wdt:support suspend/resume for watchdog
>>
>>
>> Hi,
>>
>> On 25/09/2017 at 19:58:44 +0800, winton.liu wrote:
>>> When enable CONFIG_RTC_DRV_DS1374_WDT use as watchdog,
>>> in suspend mode, watchdog is still working but no daemon
>>> patting the watchdog. The system will reboot if timeout.
>>> So disable watchdog in suspend  and recover it in resume.
>>>
>>
>> That is definitively not what we want. Many people will want to still
>> have the watchdog running when the platform is suspended. Your options
>> are to either disable the watchdog before going to suspend or wake up
>> the platform just in time to ping the watchdog.
>>
>>> Signed-off-by: winton.liu <18502523564@163.com>
>>> ---
>>>   drivers/rtc/rtc-ds1374.c | 8 ++++++++
>>>   1 file changed, 8 insertions(+)
>>>
>>> diff --git a/drivers/rtc/rtc-ds1374.c b/drivers/rtc/rtc-ds1374.c
>>> index 38a2e9e..e990773 100644
>>> --- a/drivers/rtc/rtc-ds1374.c
>>> +++ b/drivers/rtc/rtc-ds1374.c
>>> @@ -690,6 +690,10 @@ static int ds1374_suspend(struct device *dev)
>>>   {
>>>        struct i2c_client *client = to_i2c_client(dev);
>>>
>>> +#ifdef CONFIG_RTC_DRV_DS1374_WDT
>>> +     ds1374_wdt_disable();
>>> +#endif
>>> +
>>>        if (client->irq > 0 && device_may_wakeup(&client->dev))
>>>                enable_irq_wake(client->irq);
>>>        return 0;
>>> @@ -699,6 +703,10 @@ static int ds1374_resume(struct device *dev)
>>>   {
>>>        struct i2c_client *client = to_i2c_client(dev);
>>>
>>> +#ifdef CONFIG_RTC_DRV_DS1374_WDT
>>> +     ds1374_wdt_settimeout(131072);
>>> +#endif
>>> +
>>>        if (client->irq > 0 && device_may_wakeup(&client->dev))
>>>                disable_irq_wake(client->irq);
>>>        return 0;
>>> --
>>> 1.9.1
>>>
>>>
>>
>> --
>> Alexandre Belloni, Free Electrons
>> Embedded Linux and Kernel engineering
>> http://free-electrons.com
>>
> 

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

* Re: [PATCH] rtc: ds1374: wdt:support suspend/resume for watchdog
  2017-09-26  1:56   ` 18502523564
@ 2017-09-26 10:22     ` Alexandre Belloni
  2017-09-26 13:52       ` Guenter Roeck
  0 siblings, 1 reply; 12+ messages in thread
From: Alexandre Belloni @ 2017-09-26 10:22 UTC (permalink / raw)
  To: 18502523564
  Cc: a.zummo, linux-rtc, linux-kernel, Wim Van Sebroeck,
	Guenter Roeck, linux-watchdog

(+Cc wdt maintainers)

On 26/09/2017 at 09:56:32 +0800, 18502523564 wrote:
> Hi Alexandre,
> 
> Thanks for your reply.
> Do you think is this a issue when using as a watchdog in suspend?
> I takes the drivers/watchdog/ subsystem for reference, some drivers in suspend
> also call disable_watchdog.Or do you have any  better suggestion?

I guess this is a question for the watchdog subsystem maintainers.
However, I think that everything can be handled properly from userspace
as I know some atmel based devices have their watchdog enabled while
the platform is suspended.

> Thank you.
> 
> 
> 
> 
> ------------------ Original ------------------
> From: Alexandre Belloni <alexandre.belloni@free-electrons.com>
> Date: 周一,9月 25,2017 20:07
> To: winton.liu <18502523564@163.com>
> Cc: a.zummo <a.zummo@towertech.it>, linux-rtc <linux-rtc@vger.kernel.org>,
> linux-kernel <linux-kernel@vger.kernel.org>
> Subject: Re: [PATCH] rtc: ds1374: wdt:support suspend/resume for watchdog
> 
> 
> Hi,
> 
> On 25/09/2017 at 19:58:44 +0800, winton.liu wrote:
> > When enable CONFIG_RTC_DRV_DS1374_WDT use as watchdog,
> > in suspend mode, watchdog is still working but no daemon
> > patting the watchdog. The system will reboot if timeout.
> > So disable watchdog in suspend  and recover it in resume.
> >
> 
> That is definitively not what we want. Many people will want to still
> have the watchdog running when the platform is suspended. Your options
> are to either disable the watchdog before going to suspend or wake up
> the platform just in time to ping the watchdog.
> 
> > Signed-off-by: winton.liu <18502523564@163.com>
> > ---
> >  drivers/rtc/rtc-ds1374.c | 8 ++++++++
> >  1 file changed, 8 insertions(+)
> >
> > diff --git a/drivers/rtc/rtc-ds1374.c b/drivers/rtc/rtc-ds1374.c
> > index 38a2e9e..e990773 100644
> > --- a/drivers/rtc/rtc-ds1374.c
> > +++ b/drivers/rtc/rtc-ds1374.c
> > @@ -690,6 +690,10 @@ static int ds1374_suspend(struct device *dev)
> >  {
> >       struct i2c_client *client = to_i2c_client(dev);
> >
> > +#ifdef CONFIG_RTC_DRV_DS1374_WDT
> > +     ds1374_wdt_disable();
> > +#endif
> > +
> >       if (client->irq > 0 && device_may_wakeup(&client->dev))
> >               enable_irq_wake(client->irq);
> >       return 0;
> > @@ -699,6 +703,10 @@ static int ds1374_resume(struct device *dev)
> >  {
> >       struct i2c_client *client = to_i2c_client(dev);
> >
> > +#ifdef CONFIG_RTC_DRV_DS1374_WDT
> > +     ds1374_wdt_settimeout(131072);
> > +#endif
> > +
> >       if (client->irq > 0 && device_may_wakeup(&client->dev))
> >               disable_irq_wake(client->irq);
> >       return 0;
> > --
> > 1.9.1
> >
> >
> 
> --
> Alexandre Belloni, Free Electrons
> Embedded Linux and Kernel engineering
> http://free-electrons.com
> 

-- 
Alexandre Belloni, Free Electrons
Embedded Linux and Kernel engineering
http://free-electrons.com

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

* Re: [PATCH] rtc: ds1374: wdt:support suspend/resume for watchdog
  2017-09-25 12:07 ` Alexandre Belloni
@ 2017-09-26  1:56   ` 18502523564
  2017-09-26 10:22     ` Alexandre Belloni
  0 siblings, 1 reply; 12+ messages in thread
From: 18502523564 @ 2017-09-26  1:56 UTC (permalink / raw)
  To: Alexandre Belloni ; +Cc: a.zummo, linux-rtc, linux-kernel

[-- Attachment #1: Type: text/html, Size: 4283 bytes --]

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

* Re: [PATCH] rtc: ds1374: wdt:support suspend/resume for watchdog
  2017-09-25 11:58 winton.liu
@ 2017-09-25 12:07 ` Alexandre Belloni
  2017-09-26  1:56   ` 18502523564
  0 siblings, 1 reply; 12+ messages in thread
From: Alexandre Belloni @ 2017-09-25 12:07 UTC (permalink / raw)
  To: winton.liu; +Cc: a.zummo, linux-rtc, linux-kernel

Hi,

On 25/09/2017 at 19:58:44 +0800, winton.liu wrote:
> When enable CONFIG_RTC_DRV_DS1374_WDT use as watchdog,
> in suspend mode, watchdog is still working but no daemon
> patting the watchdog. The system will reboot if timeout.
> So disable watchdog in suspend  and recover it in resume.
> 

That is definitively not what we want. Many people will want to still
have the watchdog running when the platform is suspended. Your options
are to either disable the watchdog before going to suspend or wake up
the platform just in time to ping the watchdog.

> Signed-off-by: winton.liu <18502523564@163.com>
> ---
>  drivers/rtc/rtc-ds1374.c | 8 ++++++++
>  1 file changed, 8 insertions(+)
> 
> diff --git a/drivers/rtc/rtc-ds1374.c b/drivers/rtc/rtc-ds1374.c
> index 38a2e9e..e990773 100644
> --- a/drivers/rtc/rtc-ds1374.c
> +++ b/drivers/rtc/rtc-ds1374.c
> @@ -690,6 +690,10 @@ static int ds1374_suspend(struct device *dev)
>  {
>  	struct i2c_client *client = to_i2c_client(dev);
>  
> +#ifdef CONFIG_RTC_DRV_DS1374_WDT
> +	ds1374_wdt_disable();
> +#endif
> +
>  	if (client->irq > 0 && device_may_wakeup(&client->dev))
>  		enable_irq_wake(client->irq);
>  	return 0;
> @@ -699,6 +703,10 @@ static int ds1374_resume(struct device *dev)
>  {
>  	struct i2c_client *client = to_i2c_client(dev);
>  
> +#ifdef CONFIG_RTC_DRV_DS1374_WDT
> +	ds1374_wdt_settimeout(131072);
> +#endif
> +
>  	if (client->irq > 0 && device_may_wakeup(&client->dev))
>  		disable_irq_wake(client->irq);
>  	return 0;
> -- 
> 1.9.1
> 
> 

-- 
Alexandre Belloni, Free Electrons
Embedded Linux and Kernel engineering
http://free-electrons.com

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

* [PATCH] rtc: ds1374: wdt:support suspend/resume for watchdog
@ 2017-09-25 11:58 winton.liu
  2017-09-25 12:07 ` Alexandre Belloni
  0 siblings, 1 reply; 12+ messages in thread
From: winton.liu @ 2017-09-25 11:58 UTC (permalink / raw)
  To: a.zummo, alexandre.belloni, linux-rtc, linux-kernel; +Cc: winton.liu

When enable CONFIG_RTC_DRV_DS1374_WDT use as watchdog,
in suspend mode, watchdog is still working but no daemon
patting the watchdog. The system will reboot if timeout.
So disable watchdog in suspend  and recover it in resume.

Signed-off-by: winton.liu <18502523564@163.com>
---
 drivers/rtc/rtc-ds1374.c | 8 ++++++++
 1 file changed, 8 insertions(+)

diff --git a/drivers/rtc/rtc-ds1374.c b/drivers/rtc/rtc-ds1374.c
index 38a2e9e..e990773 100644
--- a/drivers/rtc/rtc-ds1374.c
+++ b/drivers/rtc/rtc-ds1374.c
@@ -690,6 +690,10 @@ static int ds1374_suspend(struct device *dev)
 {
 	struct i2c_client *client = to_i2c_client(dev);
 
+#ifdef CONFIG_RTC_DRV_DS1374_WDT
+	ds1374_wdt_disable();
+#endif
+
 	if (client->irq > 0 && device_may_wakeup(&client->dev))
 		enable_irq_wake(client->irq);
 	return 0;
@@ -699,6 +703,10 @@ static int ds1374_resume(struct device *dev)
 {
 	struct i2c_client *client = to_i2c_client(dev);
 
+#ifdef CONFIG_RTC_DRV_DS1374_WDT
+	ds1374_wdt_settimeout(131072);
+#endif
+
 	if (client->irq > 0 && device_may_wakeup(&client->dev))
 		disable_irq_wake(client->irq);
 	return 0;
-- 
1.9.1

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

end of thread, other threads:[~2017-10-12 14:12 UTC | newest]

Thread overview: 12+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2017-10-10 13:12 [PATCH] rtc: ds1374: wdt:support suspend/resume for watchdog winton.liu
2017-10-10 13:41 ` Guenter Roeck
2017-10-10 13:51   ` Alexandre Belloni
2017-10-10 15:05     ` Guenter Roeck
2017-10-12 13:40       ` 刘稳
2017-10-12 13:40         ` 刘稳
2017-10-12 14:12         ` Guenter Roeck
  -- strict thread matches above, loose matches on Subject: below --
2017-09-25 11:58 winton.liu
2017-09-25 12:07 ` Alexandre Belloni
2017-09-26  1:56   ` 18502523564
2017-09-26 10:22     ` Alexandre Belloni
2017-09-26 13:52       ` Guenter Roeck

This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.