Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]
Groups > linux.kernel > #1582892 > unrolled thread
| Started by | Alexandre Belloni <alexandre.belloni@free-electrons.com> |
|---|---|
| First post | 2017-02-16 20:40 +0100 |
| Last post | 2017-02-20 05:50 +0100 |
| Articles | 6 — 2 participants |
Back to article view | Back to linux.kernel
This discussion starts older than the indexed window; earlier articles aren't shown. The article labeled Started by
below is the oldest one visible, not the original post.
[PATCH v2 2/3] watchdog: sama5d4: Fix setting timeout when watchdog is disabled Alexandre Belloni <alexandre.belloni@free-electrons.com> - 2017-02-16 20:40 +0100
Re: [PATCH v2 2/3] watchdog: sama5d4: Fix setting timeout when watchdog is disabled Guenter Roeck <linux@roeck-us.net> - 2017-02-17 15:50 +0100
Re: [PATCH v2 2/3] watchdog: sama5d4: Fix setting timeout when watchdog is disabled Alexandre Belloni <alexandre.belloni@free-electrons.com> - 2017-02-17 16:20 +0100
Re: [PATCH v2 2/3] watchdog: sama5d4: Fix setting timeout when watchdog is disabled Guenter Roeck <linux@roeck-us.net> - 2017-02-19 18:40 +0100
Re: [PATCH v2 2/3] watchdog: sama5d4: Fix setting timeout when watchdog is disabled Alexandre Belloni <alexandre.belloni@free-electrons.com> - 2017-02-20 01:00 +0100
Re: [PATCH v2 2/3] watchdog: sama5d4: Fix setting timeout when watchdog is disabled Guenter Roeck <linux@roeck-us.net> - 2017-02-20 05:50 +0100
| From | Alexandre Belloni <alexandre.belloni@free-electrons.com> |
|---|---|
| Date | 2017-02-16 20:40 +0100 |
| Subject | [PATCH v2 2/3] watchdog: sama5d4: Fix setting timeout when watchdog is disabled |
| Message-ID | <tbA4h-2sg-7@gated-at.bofh.it> |
The datasheet states: "When setting the WDDIS bit, and while it is set, the fields WDV and WDD must not be modified." Ensure WDDIS is not set when changing the timeout and set it afterwards if the watchdog was disabled. Signed-off-by: Alexandre Belloni <alexandre.belloni@free-electrons.com> --- Changes in v2: - new patch drivers/watchdog/sama5d4_wdt.c | 9 ++++++++- 1 file changed, 8 insertions(+), 1 deletion(-) diff --git a/drivers/watchdog/sama5d4_wdt.c b/drivers/watchdog/sama5d4_wdt.c index 2c6f5a70ae67..2a60251806d2 100644 --- a/drivers/watchdog/sama5d4_wdt.c +++ b/drivers/watchdog/sama5d4_wdt.c @@ -90,11 +90,18 @@ static int sama5d4_wdt_set_timeout(struct watchdog_device *wdd, u32 reg; reg = wdt_read(wdt, AT91_WDT_MR); + + if (reg & AT91_WDT_WDDIS) + wdt_write(wdt, AT91_WDT_MR, reg & ~AT91_WDT_WDDIS); + reg &= ~AT91_WDT_WDV; reg &= ~AT91_WDT_WDD; reg |= AT91_WDT_SET_WDV(value); reg |= AT91_WDT_SET_WDD(value); - wdt_write(wdt, AT91_WDT_MR, reg); + wdt_write(wdt, AT91_WDT_MR, reg & ~AT91_WDT_WDDIS); + + if (reg & AT91_WDT_WDDIS) + wdt_write(wdt, AT91_WDT_MR, reg); wdd->timeout = timeout; -- 2.11.0
[toc] | [next] | [standalone]
| From | Guenter Roeck <linux@roeck-us.net> |
|---|---|
| Date | 2017-02-17 15:50 +0100 |
| Subject | Re: [PATCH v2 2/3] watchdog: sama5d4: Fix setting timeout when watchdog is disabled |
| Message-ID | <tbS1c-5xl-45@gated-at.bofh.it> |
| In reply to | #1582892 |
On 02/16/2017 11:30 AM, Alexandre Belloni wrote: > The datasheet states: "When setting the WDDIS bit, and while it is set, the > fields WDV and WDD must not be modified." > > Ensure WDDIS is not set when changing the timeout and set it afterwards if > the watchdog was disabled. > > Signed-off-by: Alexandre Belloni <alexandre.belloni@free-electrons.com> > --- > Changes in v2: > - new patch > drivers/watchdog/sama5d4_wdt.c | 9 ++++++++- > 1 file changed, 8 insertions(+), 1 deletion(-) > > diff --git a/drivers/watchdog/sama5d4_wdt.c b/drivers/watchdog/sama5d4_wdt.c > index 2c6f5a70ae67..2a60251806d2 100644 > --- a/drivers/watchdog/sama5d4_wdt.c > +++ b/drivers/watchdog/sama5d4_wdt.c > @@ -90,11 +90,18 @@ static int sama5d4_wdt_set_timeout(struct watchdog_device *wdd, > u32 reg; > > reg = wdt_read(wdt, AT91_WDT_MR); > + > + if (reg & AT91_WDT_WDDIS) > + wdt_write(wdt, AT91_WDT_MR, reg & ~AT91_WDT_WDDIS); > + > reg &= ~AT91_WDT_WDV; > reg &= ~AT91_WDT_WDD; > reg |= AT91_WDT_SET_WDV(value); > reg |= AT91_WDT_SET_WDD(value); > - wdt_write(wdt, AT91_WDT_MR, reg); > + wdt_write(wdt, AT91_WDT_MR, reg & ~AT91_WDT_WDDIS); > + > + if (reg & AT91_WDT_WDDIS) > + wdt_write(wdt, AT91_WDT_MR, reg); > That means if the watchdog is running, the timeout would not be updated. It should be updated no matter if it is running or not. Guenter > wdd->timeout = timeout; > >
[toc] | [prev] | [next] | [standalone]
| From | Alexandre Belloni <alexandre.belloni@free-electrons.com> |
|---|---|
| Date | 2017-02-17 16:20 +0100 |
| Subject | Re: [PATCH v2 2/3] watchdog: sama5d4: Fix setting timeout when watchdog is disabled |
| Message-ID | <tbSue-5X8-15@gated-at.bofh.it> |
| In reply to | #1583498 |
On 17/02/2017 at 06:40:33 -0800, Guenter Roeck wrote: > On 02/16/2017 11:30 AM, Alexandre Belloni wrote: > > The datasheet states: "When setting the WDDIS bit, and while it is set, the > > fields WDV and WDD must not be modified." > > > > Ensure WDDIS is not set when changing the timeout and set it afterwards if > > the watchdog was disabled. > > > > Signed-off-by: Alexandre Belloni <alexandre.belloni@free-electrons.com> > > --- > > Changes in v2: > > - new patch > > drivers/watchdog/sama5d4_wdt.c | 9 ++++++++- > > 1 file changed, 8 insertions(+), 1 deletion(-) > > > > diff --git a/drivers/watchdog/sama5d4_wdt.c b/drivers/watchdog/sama5d4_wdt.c > > index 2c6f5a70ae67..2a60251806d2 100644 > > --- a/drivers/watchdog/sama5d4_wdt.c > > +++ b/drivers/watchdog/sama5d4_wdt.c > > @@ -90,11 +90,18 @@ static int sama5d4_wdt_set_timeout(struct watchdog_device *wdd, > > u32 reg; > > > > reg = wdt_read(wdt, AT91_WDT_MR); > > + > > + if (reg & AT91_WDT_WDDIS) > > + wdt_write(wdt, AT91_WDT_MR, reg & ~AT91_WDT_WDDIS); > > + > > reg &= ~AT91_WDT_WDV; > > reg &= ~AT91_WDT_WDD; > > reg |= AT91_WDT_SET_WDV(value); > > reg |= AT91_WDT_SET_WDD(value); > > - wdt_write(wdt, AT91_WDT_MR, reg); > > + wdt_write(wdt, AT91_WDT_MR, reg & ~AT91_WDT_WDDIS); > > + > > + if (reg & AT91_WDT_WDDIS) > > + wdt_write(wdt, AT91_WDT_MR, reg); > > > That means if the watchdog is running, the timeout would not be updated. > It should be updated no matter if it is running or not. > No, it is enabling the watchdog, then changing WDV and WDD and finally disabling the watchdog if necessary. So, WDV and WDD are always changed. -- Alexandre Belloni, Free Electrons Embedded Linux and Kernel engineering http://free-electrons.com
[toc] | [prev] | [next] | [standalone]
| From | Guenter Roeck <linux@roeck-us.net> |
|---|---|
| Date | 2017-02-19 18:40 +0100 |
| Subject | Re: [PATCH v2 2/3] watchdog: sama5d4: Fix setting timeout when watchdog is disabled |
| Message-ID | <tcDCO-1MT-25@gated-at.bofh.it> |
| In reply to | #1583520 |
On 02/17/2017 07:16 AM, Alexandre Belloni wrote: > On 17/02/2017 at 06:40:33 -0800, Guenter Roeck wrote: >> On 02/16/2017 11:30 AM, Alexandre Belloni wrote: >>> The datasheet states: "When setting the WDDIS bit, and while it is set, the >>> fields WDV and WDD must not be modified." >>> >>> Ensure WDDIS is not set when changing the timeout and set it afterwards if >>> the watchdog was disabled. >>> >>> Signed-off-by: Alexandre Belloni <alexandre.belloni@free-electrons.com> >>> --- >>> Changes in v2: >>> - new patch >>> drivers/watchdog/sama5d4_wdt.c | 9 ++++++++- >>> 1 file changed, 8 insertions(+), 1 deletion(-) >>> >>> diff --git a/drivers/watchdog/sama5d4_wdt.c b/drivers/watchdog/sama5d4_wdt.c >>> index 2c6f5a70ae67..2a60251806d2 100644 >>> --- a/drivers/watchdog/sama5d4_wdt.c >>> +++ b/drivers/watchdog/sama5d4_wdt.c >>> @@ -90,11 +90,18 @@ static int sama5d4_wdt_set_timeout(struct watchdog_device *wdd, >>> u32 reg; >>> >>> reg = wdt_read(wdt, AT91_WDT_MR); >>> + >>> + if (reg & AT91_WDT_WDDIS) >>> + wdt_write(wdt, AT91_WDT_MR, reg & ~AT91_WDT_WDDIS); >>> + >>> reg &= ~AT91_WDT_WDV; >>> reg &= ~AT91_WDT_WDD; >>> reg |= AT91_WDT_SET_WDV(value); >>> reg |= AT91_WDT_SET_WDD(value); >>> - wdt_write(wdt, AT91_WDT_MR, reg); >>> + wdt_write(wdt, AT91_WDT_MR, reg & ~AT91_WDT_WDDIS); >>> + >>> + if (reg & AT91_WDT_WDDIS) >>> + wdt_write(wdt, AT91_WDT_MR, reg); >>> >> That means if the watchdog is running, the timeout would not be updated. >> It should be updated no matter if it is running or not. >> > > No, it is enabling the watchdog, then changing WDV and WDD and finally > disabling the watchdog if necessary. So, WDV and WDD are always changed. > You are correct. Sorry for the noise. Seems odd that the watchdog must be _running_ to change the timeout. Usually, if there is a restriction, it is the opposite. I hope this doesn't cause race conditions, where the watchdog fires immediately after being enabled due to a low timeout. Guenter
[toc] | [prev] | [next] | [standalone]
| From | Alexandre Belloni <alexandre.belloni@free-electrons.com> |
|---|---|
| Date | 2017-02-20 01:00 +0100 |
| Subject | Re: [PATCH v2 2/3] watchdog: sama5d4: Fix setting timeout when watchdog is disabled |
| Message-ID | <tcJyx-5on-5@gated-at.bofh.it> |
| In reply to | #1584206 |
On 19/02/2017 at 08:57:35 -0800, Guenter Roeck wrote: > > > That means if the watchdog is running, the timeout would not be updated. > > > It should be updated no matter if it is running or not. > > > > > > > No, it is enabling the watchdog, then changing WDV and WDD and finally > > disabling the watchdog if necessary. So, WDV and WDD are always changed. > > > You are correct. Sorry for the noise. > > Seems odd that the watchdog must be _running_ to change the timeout. > Usually, if there is a restriction, it is the opposite. I hope this > doesn't cause race conditions, where the watchdog fires immediately > after being enabled due to a low timeout. > While it is difficult to reproduce, I can confirm it races and sometimes reset the SoC without any good reason. It doesn't matter whether it is disabled or not I've raised the issue at Atmel last Thursday so I don't have any answer yet. -- Alexandre Belloni, Free Electrons Embedded Linux and Kernel engineering http://free-electrons.com
[toc] | [prev] | [next] | [standalone]
| From | Guenter Roeck <linux@roeck-us.net> |
|---|---|
| Date | 2017-02-20 05:50 +0100 |
| Subject | Re: [PATCH v2 2/3] watchdog: sama5d4: Fix setting timeout when watchdog is disabled |
| Message-ID | <tcO5b-8mA-1@gated-at.bofh.it> |
| In reply to | #1584292 |
On 02/19/2017 03:52 PM, Alexandre Belloni wrote: > On 19/02/2017 at 08:57:35 -0800, Guenter Roeck wrote: >>>> That means if the watchdog is running, the timeout would not be updated. >>>> It should be updated no matter if it is running or not. >>>> >>> >>> No, it is enabling the watchdog, then changing WDV and WDD and finally >>> disabling the watchdog if necessary. So, WDV and WDD are always changed. >>> >> You are correct. Sorry for the noise. >> >> Seems odd that the watchdog must be _running_ to change the timeout. >> Usually, if there is a restriction, it is the opposite. I hope this >> doesn't cause race conditions, where the watchdog fires immediately >> after being enabled due to a low timeout. >> > > While it is difficult to reproduce, I can confirm it races and sometimes > reset the SoC without any good reason. It doesn't matter whether it is > disabled or not > Outch :-(. > I've raised the issue at Atmel last Thursday so I don't have any answer > yet. > Please keep us in the loop. Thanks, Guenter
[toc] | [prev] | [standalone]
Back to top | Article view | linux.kernel
csiph-web