All of lore.kernel.org
 help / color / mirror / Atom feed
From: Alexandre Belloni <alexandre.belloni@free-electrons.com>
To: Guenter Roeck <linux@roeck-us.net>
Cc: "winton.liu" <18502523564@163.com>,
	a.zummo@towertech.it, linux-rtc@vger.kernel.org,
	linux-kernel@vger.kernel.org, linux-watchdog@vger.kernel.org
Subject: Re: [PATCH] rtc: ds1374: wdt:support suspend/resume for watchdog
Date: Tue, 10 Oct 2017 15:51:34 +0200	[thread overview]
Message-ID: <20171010135134.2zepquujhfwbhxoq@piout.net> (raw)
In-Reply-To: <8b80788f-5906-38a5-4b40-0a78f0ab55d9@roeck-us.net>

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

  reply	other threads:[~2017-10-10 13:51 UTC|newest]

Thread overview: 12+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
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 [this message]
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

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20171010135134.2zepquujhfwbhxoq@piout.net \
    --to=alexandre.belloni@free-electrons.com \
    --cc=18502523564@163.com \
    --cc=a.zummo@towertech.it \
    --cc=linux-kernel@vger.kernel.org \
    --cc=linux-rtc@vger.kernel.org \
    --cc=linux-watchdog@vger.kernel.org \
    --cc=linux@roeck-us.net \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
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.