All of lore.kernel.org
 help / color / mirror / Atom feed
From: Joel Stanley <joel@jms.id.au>
To: Andrew Jeffery <andrew@aj.id.au>
Cc: linux-watchdog@vger.kernel.org, Wim Van Sebroeck <wim@iguana.be>,
	Guenter Roeck <linux@roeck-us.net>,
	Linux Kernel Mailing List <linux-kernel@vger.kernel.org>,
	OpenBMC Maillist <openbmc@lists.ozlabs.org>,
	linux-aspeed@lists.ozlabs.org,
	Ryan Chen <ryan_chen@aspeedtech.com>
Subject: Re: [PATCH 1/4] watchdog: aspeed: Retain watchdog enabled state
Date: Wed, 20 Sep 2017 11:17:09 +0930	[thread overview]
Message-ID: <CACPK8XezE6ZSfSQ7Aq7g85imqXLuahWGu_SQzG=+LAq0UxSdyA@mail.gmail.com> (raw)
In-Reply-To: <20170918054905.16470-2-andrew@aj.id.au>

On Mon, Sep 18, 2017 at 3:19 PM, Andrew Jeffery <andrew@aj.id.au> wrote:
> An unintended post-condition of probe() is that the watchdog is
> disabled. Rework probe() such that we retain the value of the "enabled"
> bit from the control register, and take the appropriate actions with
> respect to the watchdog core if so. Otherwise, just configure the
> watchdog as directed.
>

This should have a fixes line. The code as it stands in 4.14-rc1
unconditionally disables the watchdog at boot :(

> Signed-off-by: Andrew Jeffery <andrew@aj.id.au>
> ---
>  drivers/watchdog/aspeed_wdt.c | 9 +++++----
>  1 file changed, 5 insertions(+), 4 deletions(-)
>
> diff --git a/drivers/watchdog/aspeed_wdt.c b/drivers/watchdog/aspeed_wdt.c
> index 79cc766cd30f..99bc6fbd8852 100644
> --- a/drivers/watchdog/aspeed_wdt.c
> +++ b/drivers/watchdog/aspeed_wdt.c
> @@ -221,7 +221,8 @@ static int aspeed_wdt_probe(struct platform_device *pdev)
>                 return -EINVAL;
>         config = ofdid->data;
>
> -       wdt->ctrl = WDT_CTRL_1MHZ_CLK;
> +       wdt->ctrl |= readl(wdt->base + WDT_CTRL) & WDT_CTRL_ENABLE;

If we go back to before b7f0b8ad25f3 ("drivers/watchdog: ASPEED
reference dev tree properties for config"), the driver set up the
cached ctrl value and then tested the hardware state to decide if we
should have the watchdog enabled.

Looking at the driver now there's little reason to keep the cached
ctrl value. I'd suggest reworking the driver to not have it so we can
avoid bugs like the ones that b7f0b8ad25f3 introduced.

Cheers,

Joel

> +       wdt->ctrl |= WDT_CTRL_1MHZ_CLK;
>
>         /*
>          * Control reset on a per-device basis to ensure the
> @@ -243,11 +244,11 @@ static int aspeed_wdt_probe(struct platform_device *pdev)
>         if (of_property_read_bool(np, "aspeed,external-signal"))
>                 wdt->ctrl |= WDT_CTRL_WDT_EXT;
>
> -       writel(wdt->ctrl, wdt->base + WDT_CTRL);
> -
> -       if (readl(wdt->base + WDT_CTRL) & WDT_CTRL_ENABLE)  {
> +       if (wdt->ctrl & WDT_CTRL_ENABLE) {
>                 aspeed_wdt_start(&wdt->wdd);
>                 set_bit(WDOG_HW_RUNNING, &wdt->wdd.status);
> +       } else {
> +               writel(wdt->ctrl, wdt->base + WDT_CTRL);
>         }
>
>         if (of_device_is_compatible(np, "aspeed,ast2500-wdt")) {
> --
> 2.11.0
>

  parent reply	other threads:[~2017-09-20  1:47 UTC|newest]

Thread overview: 19+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2017-09-18  5:49 [PATCH 0/4] watchdog: aspeed: Retain enabled state and move to Andrew Jeffery
2017-09-18  5:49 ` [PATCH 1/4] watchdog: aspeed: Retain watchdog enabled state Andrew Jeffery
2017-09-18 13:25   ` Guenter Roeck
2017-09-19  2:30     ` Andrew Jeffery
2017-09-19  2:30       ` Andrew Jeffery
2017-09-20  1:47   ` Joel Stanley [this message]
2017-09-20  1:47     ` Joel Stanley
2017-09-20  2:32     ` Andrew Jeffery
2017-09-20  2:32       ` Andrew Jeffery
2017-09-18  5:49 ` [PATCH 2/4] watchdog: aspeed: Fix 'Apseed' typo in Kconfig Andrew Jeffery
2017-09-18 14:45   ` Guenter Roeck
2017-09-18  5:49 ` [PATCH 3/4] watchdog: aspeed: Remove specific reference to AST2400 " Andrew Jeffery
2017-09-18 14:45   ` Guenter Roeck
2017-09-18  5:49 ` [PATCH 4/4] watchdog: aspeed: Move init to arch_initcall Andrew Jeffery
2017-09-18 13:32   ` Guenter Roeck
2017-09-19  2:28     ` Andrew Jeffery
2017-09-19  2:28       ` Andrew Jeffery
2017-09-18  5:53 ` [PATCH 0/4] watchdog: aspeed: Retain enabled state and move to Andrew Jeffery
2017-09-18  5:53   ` Andrew Jeffery

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='CACPK8XezE6ZSfSQ7Aq7g85imqXLuahWGu_SQzG=+LAq0UxSdyA@mail.gmail.com' \
    --to=joel@jms.id.au \
    --cc=andrew@aj.id.au \
    --cc=linux-aspeed@lists.ozlabs.org \
    --cc=linux-kernel@vger.kernel.org \
    --cc=linux-watchdog@vger.kernel.org \
    --cc=linux@roeck-us.net \
    --cc=openbmc@lists.ozlabs.org \
    --cc=ryan_chen@aspeedtech.com \
    --cc=wim@iguana.be \
    /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.