From: Marco Felsch <m.felsch@pengutronix.de>
To: Guenter Roeck <linux@roeck-us.net>
Cc: wim@linux-watchdog.org, support.opensource@diasemi.com,
kernel@pengutronix.de, linux-watchdog@vger.kernel.org
Subject: Re: [PATCH v8 3/4] watchdog: da9063: Fix timeout handling during probe
Date: Sat, 26 May 2018 19:39:34 +0200 [thread overview]
Message-ID: <20180526173934.GA12799@pengutronix.de> (raw)
In-Reply-To: <20180525224230.GA4632@roeck-us.net>
On 18-05-25 15:42, Guenter Roeck wrote:
> On Fri, May 25, 2018 at 11:41:57PM +0200, Marco Felsch wrote:
> > Dear Guenter,
> >
> > On 18-05-25 06:46, Guenter Roeck wrote:
> > > On 05/25/2018 06:09 AM, Marco Felsch wrote:
> > > > On 18-05-25 01:50, Guenter Roeck wrote:
> > > > > On 05/24/2018 11:44 PM, Marco Felsch wrote:
> > > > > > On 18-05-24 11:07, Guenter Roeck wrote:
> > > > > > > On Thu, May 24, 2018 at 01:51:00PM +0200, Marco Felsch wrote:
> > > > > > > > The watchdog can be enabled in previous steps (e.g. the bootloader). Check
> > > > > > > > if the watchdog is already running, retrieve the set timeout value and
> > > > > > > > set it again to set the new timeout reference mark.
> > > > > > > >
> > > > > > > > Fixes: 5e9c16e37608 ("watchdog: Add DA9063 PMIC watchdog driver.")
> > > > > > > > Signed-off-by: Marco Felsch <m.felsch@pengutronix.de>
> > > > > > > > ---
> > > > > > > > drivers/watchdog/da9063_wdt.c | 19 +++++++++++++++++++
> > > > > > > > 1 file changed, 19 insertions(+)
> > > > > > > >
> > > > > > > > diff --git a/drivers/watchdog/da9063_wdt.c b/drivers/watchdog/da9063_wdt.c
> > > > > > > > index 6b0092b7d5a6..c5bd5ffe8ded 100644
> > > > > > > > --- a/drivers/watchdog/da9063_wdt.c
> > > > > > > > +++ b/drivers/watchdog/da9063_wdt.c
> > > > > > > > @@ -45,6 +45,18 @@ static unsigned int da9063_wdt_timeout_to_sel(unsigned int secs)
> > > > > > > > return DA9063_TWDSCALE_MAX;
> > > > > > > > }
> > > > > > > > +/*
> > > > > > > > + * Return 0 if watchdog is disabled, else non zero.
> > > > > > > > + */
> > > > > > > > +static unsigned int da9063_wdt_is_running(struct da9063 *da9063)
> > > > > > > > +{
> > > > > > > > + unsigned int val;
> > > > > > > > +
> > > > > > > > + regmap_read(da9063->regmap, DA9063_REG_CONTROL_D, &val);
> > > > > > > > +
> > > > > > > > + return val & DA9063_TWDSCALE_MASK;
> > > > > > > > +}
> > > > > > > > +
> > > > > > > > static int da9063_wdt_disable_timer(struct da9063 *da9063)
> > > > > > > > {
> > > > > > > > return regmap_update_bits(da9063->regmap, DA9063_REG_CONTROL_D,
> > > > > > > > @@ -180,6 +192,7 @@ static int da9063_wdt_probe(struct platform_device *pdev)
> > > > > > > > {
> > > > > > > > struct da9063 *da9063;
> > > > > > > > struct watchdog_device *wdd;
> > > > > > > > + unsigned int cur_timeout;
> > > > > > > > if (!pdev->dev.parent)
> > > > > > > > return -EINVAL;
> > > > > > > > @@ -206,6 +219,12 @@ static int da9063_wdt_probe(struct platform_device *pdev)
> > > > > > > > watchdog_set_drvdata(wdd, da9063);
> > > > > > > > + cur_timeout = da9063_wdt_is_running(da9063);
> > > > > > > > + if (cur_timeout) {
> > > > > > > > + set_bit(WDOG_HW_RUNNING, &wdd->status);
> > > > > > > > + _da9063_wdt_set_timeout(da9063, cur_timeout);
> > > > > > >
> > > > > > > Sorry, I should have been more specific. That doesn't make sense as written
> > > > > > > since it just sets the same timeout as before. You would have to replace
> > > > > > > the second argument with the desired timeout in seconds, and call
> > > > > > > da9063_wdt_timeout_to_sel() in _da9063_wdt_set_timeout(). That would
> > > > > > > actually make sense since all callers of _da9063_wdt_set_timeout()
> > > > > > > do that anyway before the call.
> > > > > >
> > > > > > That's the reason why I used da9063_wdt_set_timeout() in v6 because in
> > > > > > v6 da9063_wdt_is_running() has returned the mapped timeout in seconds.
> > > > > >
> > > > > > However, I'm with you to move da9063_wdt_timeout_to_sel() to
> > > > > > _da9063_wdt_set_timeout(). Should that happen in a seperate patch?
> > > > > >
> > > > > Yes, that would be better.
> > > >
> > > > We can't move it to the _da9063_wdt_set_timeout() because the
> > > > da9063_wdt_set_timeout() uses the mapped timeouts later:
> > > >
> > > > static int da9063_wdt_set_timeout(struct watchdog_device *wdd,
> > > > unsigned int timeout)
> > > > {
> > > > [ ... ]
> > > > else
> > > > wdd->timeout = wdt_timeout[selector];
> > > >
> > > > return ret;
> > > >
> > > > }
> > > >
> > > ...
> > > if (ret)
> > > return ret;
> > >
> > > wdd->timeout = wdt_timeout[da9063_wdt_timeout_to_sel(timeout)];
> > > return 0;
> > >
> > > Guenter
> >
> > Sorry, I tought da9063_wdt_timeout_to_sel() should get called only within
> > _da9063_wdt_set_timeout().
> >
> Well, you _could_ have _da9063_wdt_set_timeout() return either a negative
> error code or the actually selected timeout. Just an idea.
Yes, I've tought about this approach too. Anyway, is it okay to split
the series into a "fixes" series and a "improvment" series? I think we
losing sight of the initial problem "Change the timeout value more than
once." A next improvment could be to squash the da9062/1 and da9063 into
one if this is possible.
Marco
next prev parent reply other threads:[~2018-05-26 17:39 UTC|newest]
Thread overview: 15+ messages / expand[flat|nested] mbox.gz Atom feed top
2018-05-24 11:50 [PATCH v8 0/4] watchdog: da9063: Fix timeout handling Marco Felsch
2018-05-24 11:50 ` [PATCH v8 1/4] watchdog: da9063: Fix setting/changing timeout Marco Felsch
2018-05-24 11:50 ` [PATCH v8 2/4] watchdog: da9063: Fix updating timeout value Marco Felsch
2018-05-24 11:51 ` [PATCH v8 3/4] watchdog: da9063: Fix timeout handling during probe Marco Felsch
2018-05-24 18:07 ` Guenter Roeck
2018-05-25 6:44 ` Marco Felsch
2018-05-25 8:50 ` Guenter Roeck
2018-05-25 13:09 ` Marco Felsch
2018-05-25 13:46 ` Guenter Roeck
2018-05-25 21:41 ` Marco Felsch
2018-05-25 22:42 ` Guenter Roeck
2018-05-26 17:39 ` Marco Felsch [this message]
2018-05-26 23:11 ` Guenter Roeck
2018-06-01 14:12 ` Steve Twiss
2018-05-24 11:51 ` [PATCH v8 4/4] watchdog: da9063: rename helper function to avoid misunderstandings Marco Felsch
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=20180526173934.GA12799@pengutronix.de \
--to=m.felsch@pengutronix.de \
--cc=kernel@pengutronix.de \
--cc=linux-watchdog@vger.kernel.org \
--cc=linux@roeck-us.net \
--cc=support.opensource@diasemi.com \
--cc=wim@linux-watchdog.org \
/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 a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox