Message ID | 20220629084816.125515-4-stephan.gerhold@kernkonzept.com (mailing list archive) |
---|---|
State | Not Applicable |
Headers | show |
Series | watchdog: pm8916_wdt: Some minor improvements | expand |
On 6/29/22 01:48, Stephan Gerhold wrote: > The bootloader might already enable the watchdog to catch hangs > during the boot process. In that case the kernel needs to ping > the watchdog temporarily until userspace is fully started. > > Add a check for this in the probe() function and set the WDOG_HW_RUNNING > flag to make the watchdog core handle this automatically. > > Signed-off-by: Stephan Gerhold <stephan.gerhold@kernkonzept.com> Reviewed-by: Guenter Roeck <linux@roeck-us.net> > --- > Changes in v2: Improve error handling (suggested by Guenter) > --- > drivers/watchdog/pm8916_wdt.c | 10 ++++++++++ > 1 file changed, 10 insertions(+) > > diff --git a/drivers/watchdog/pm8916_wdt.c b/drivers/watchdog/pm8916_wdt.c > index 49f1a5204526..f4bfbffaf49c 100644 > --- a/drivers/watchdog/pm8916_wdt.c > +++ b/drivers/watchdog/pm8916_wdt.c > @@ -142,6 +142,7 @@ static int pm8916_wdt_probe(struct platform_device *pdev) > struct device *dev = &pdev->dev; > struct pm8916_wdt *wdt; > struct device *parent; > + unsigned int val; > int err, irq; > u8 poff[2]; > > @@ -199,6 +200,15 @@ static int pm8916_wdt_probe(struct platform_device *pdev) > if (poff[1] & PON_POFF_REASON2_OTST3) > wdt->wdev.bootstatus |= WDIOF_OVERHEAT; > > + err = regmap_read(wdt->regmap, wdt->baseaddr + PON_PMIC_WD_RESET_S2_CTL2, > + &val); > + if (err) { > + dev_err(dev, "failed to check if watchdog is active: %d\n", err); > + return err; > + } > + if (val & S2_RESET_EN_BIT) > + set_bit(WDOG_HW_RUNNING, &wdt->wdev.status); > + > /* Configure watchdog to hard-reset mode */ > err = regmap_write(wdt->regmap, > wdt->baseaddr + PON_PMIC_WD_RESET_S2_CTL,
On Wed, 29 Jun 2022 at 10:48, Stephan Gerhold <stephan.gerhold@kernkonzept.com> wrote: > > The bootloader might already enable the watchdog to catch hangs > during the boot process. In that case the kernel needs to ping > the watchdog temporarily until userspace is fully started. > > Add a check for this in the probe() function and set the WDOG_HW_RUNNING > flag to make the watchdog core handle this automatically. > > Signed-off-by: Stephan Gerhold <stephan.gerhold@kernkonzept.com> Reviewed-by: Loic Poulain <loic.poulain@linaro.org> > --- > Changes in v2: Improve error handling (suggested by Guenter) > --- > drivers/watchdog/pm8916_wdt.c | 10 ++++++++++ > 1 file changed, 10 insertions(+) > > diff --git a/drivers/watchdog/pm8916_wdt.c b/drivers/watchdog/pm8916_wdt.c > index 49f1a5204526..f4bfbffaf49c 100644 > --- a/drivers/watchdog/pm8916_wdt.c > +++ b/drivers/watchdog/pm8916_wdt.c > @@ -142,6 +142,7 @@ static int pm8916_wdt_probe(struct platform_device *pdev) > struct device *dev = &pdev->dev; > struct pm8916_wdt *wdt; > struct device *parent; > + unsigned int val; > int err, irq; > u8 poff[2]; > > @@ -199,6 +200,15 @@ static int pm8916_wdt_probe(struct platform_device *pdev) > if (poff[1] & PON_POFF_REASON2_OTST3) > wdt->wdev.bootstatus |= WDIOF_OVERHEAT; > > + err = regmap_read(wdt->regmap, wdt->baseaddr + PON_PMIC_WD_RESET_S2_CTL2, > + &val); > + if (err) { > + dev_err(dev, "failed to check if watchdog is active: %d\n", err); > + return err; > + } > + if (val & S2_RESET_EN_BIT) > + set_bit(WDOG_HW_RUNNING, &wdt->wdev.status); > + > /* Configure watchdog to hard-reset mode */ > err = regmap_write(wdt->regmap, > wdt->baseaddr + PON_PMIC_WD_RESET_S2_CTL, > -- > 2.30.2 >
diff --git a/drivers/watchdog/pm8916_wdt.c b/drivers/watchdog/pm8916_wdt.c index 49f1a5204526..f4bfbffaf49c 100644 --- a/drivers/watchdog/pm8916_wdt.c +++ b/drivers/watchdog/pm8916_wdt.c @@ -142,6 +142,7 @@ static int pm8916_wdt_probe(struct platform_device *pdev) struct device *dev = &pdev->dev; struct pm8916_wdt *wdt; struct device *parent; + unsigned int val; int err, irq; u8 poff[2]; @@ -199,6 +200,15 @@ static int pm8916_wdt_probe(struct platform_device *pdev) if (poff[1] & PON_POFF_REASON2_OTST3) wdt->wdev.bootstatus |= WDIOF_OVERHEAT; + err = regmap_read(wdt->regmap, wdt->baseaddr + PON_PMIC_WD_RESET_S2_CTL2, + &val); + if (err) { + dev_err(dev, "failed to check if watchdog is active: %d\n", err); + return err; + } + if (val & S2_RESET_EN_BIT) + set_bit(WDOG_HW_RUNNING, &wdt->wdev.status); + /* Configure watchdog to hard-reset mode */ err = regmap_write(wdt->regmap, wdt->baseaddr + PON_PMIC_WD_RESET_S2_CTL,
The bootloader might already enable the watchdog to catch hangs during the boot process. In that case the kernel needs to ping the watchdog temporarily until userspace is fully started. Add a check for this in the probe() function and set the WDOG_HW_RUNNING flag to make the watchdog core handle this automatically. Signed-off-by: Stephan Gerhold <stephan.gerhold@kernkonzept.com> --- Changes in v2: Improve error handling (suggested by Guenter) --- drivers/watchdog/pm8916_wdt.c | 10 ++++++++++ 1 file changed, 10 insertions(+)