linux-watchdog.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
From: Guenter Roeck <linux@roeck-us.net>
To: Ulrich Hecht <uli+renesas@fpond.eu>, linux-renesas-soc@vger.kernel.org
Cc: wsa@the-dreams.de, geert@linux-m68k.org,
	linux-i2c@vger.kernel.org, linux-watchdog@vger.kernel.org
Subject: Re: [PATCH] watchdog: da9063: wake up parent ahead of reboot
Date: Tue, 1 Sep 2020 09:48:15 -0700	[thread overview]
Message-ID: <a89b6ee3-4b69-422c-4a48-d105ff8807ed@roeck-us.net> (raw)
In-Reply-To: <20200901161756.28100-1-uli+renesas@fpond.eu>

On 9/1/20 9:17 AM, Ulrich Hecht wrote:
> This patch ensures our parent is awake before a reboot takes place. This
> prevents situations in which the I2C host has been suspended and cannot
> be safely woken up anymore when it needs to talk to us.
> 

Why not call pm_runtime_get_sync() in da9063_wdt_restart() ? What
guarantees that the local notifier is called before the watchdog core's
restart notifier ? And what is the point of using the watchdog core's
reboot handler if it is bypassed anyway ?

Also, why is it not necessary to call pm functions when the watchdog is
started, when it is stopped, and during suspend/resume ?

Thanks,
Guenter

> Signed-off-by: Ulrich Hecht <uli+renesas@fpond.eu>
> ---
> 
> Hi!
> 
> This is supposed to resolve the issue that came up in the review of
> "[PATCH v2] i2c: sh_mobile: implement atomic transfers" that the parent
> controller may be suspended when the restart method is called. See
> https://www.spinics.net/lists/linux-i2c/msg46367.html for details.
> 
> CU
> Uli
> 
> 
>  drivers/watchdog/da9063_wdt.c   | 21 +++++++++++++++++++++
>  include/linux/mfd/da9063/core.h |  2 ++
>  2 files changed, 23 insertions(+)
> 
> diff --git a/drivers/watchdog/da9063_wdt.c b/drivers/watchdog/da9063_wdt.c
> index 423584252606..89718733491e 100644
> --- a/drivers/watchdog/da9063_wdt.c
> +++ b/drivers/watchdog/da9063_wdt.c
> @@ -18,6 +18,8 @@
>  #include <linux/mfd/da9063/registers.h>
>  #include <linux/mfd/da9063/core.h>
>  #include <linux/regmap.h>
> +#include <linux/pm_runtime.h>
> +#include <linux/reboot.h>
>  
>  /*
>   * Watchdog selector to timeout in seconds.
> @@ -158,6 +160,21 @@ static int da9063_wdt_set_timeout(struct watchdog_device *wdd,
>  	return ret;
>  }
>  
> +static int da9063_reboot_notifier(struct notifier_block *nb,
> +				  unsigned long code, void *unused)
> +{
> +	struct da9063 *da9063 = container_of(nb, struct da9063, reboot_nb);
> +
> +	/*
> +	 * Make sure parent device is running. This cannot be done in the
> +	 * restart handler because it is no longer safe to do runtime PM
> +	 * there.
> +	 */
> +	pm_runtime_get_sync(da9063->dev->parent);
> +
> +	return NOTIFY_DONE;
> +}
> +
>  static int da9063_wdt_restart(struct watchdog_device *wdd, unsigned long action,
>  			      void *data)
>  {
> @@ -233,6 +250,10 @@ static int da9063_wdt_probe(struct platform_device *pdev)
>  		set_bit(WDOG_HW_RUNNING, &wdd->status);
>  	}
>  
> +	/* Get early notification of reboot so we can wake up the parent. */
> +	da9063->reboot_nb.notifier_call = da9063_reboot_notifier;
> +	devm_register_reboot_notifier(dev, &da9063->reboot_nb);
> +
>  	return devm_watchdog_register_device(dev, wdd);
>  }
>  
> diff --git a/include/linux/mfd/da9063/core.h b/include/linux/mfd/da9063/core.h
> index fa7a43f02f27..9a3283d488b7 100644
> --- a/include/linux/mfd/da9063/core.h
> +++ b/include/linux/mfd/da9063/core.h
> @@ -85,6 +85,8 @@ struct da9063 {
>  	int		chip_irq;
>  	unsigned int	irq_base;
>  	struct regmap_irq_chip_data *regmap_irq;
> +
> +	struct notifier_block reboot_nb;
>  };
>  
>  int da9063_device_init(struct da9063 *da9063, unsigned int irq);
> 


  reply	other threads:[~2020-09-01 16:48 UTC|newest]

Thread overview: 3+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2020-09-01 16:17 [PATCH] watchdog: da9063: wake up parent ahead of reboot Ulrich Hecht
2020-09-01 16:48 ` Guenter Roeck [this message]
2020-09-07 21:19   ` Ulrich Hecht

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=a89b6ee3-4b69-422c-4a48-d105ff8807ed@roeck-us.net \
    --to=linux@roeck-us.net \
    --cc=geert@linux-m68k.org \
    --cc=linux-i2c@vger.kernel.org \
    --cc=linux-renesas-soc@vger.kernel.org \
    --cc=linux-watchdog@vger.kernel.org \
    --cc=uli+renesas@fpond.eu \
    --cc=wsa@the-dreams.de \
    /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;
as well as URLs for NNTP newsgroup(s).