2019-09-29 10:58:19

by Xingyu Chen

[permalink] [raw]
Subject: [PATCH] watchdog: meson: Fix the wrong value of left time

The left time value is wrong when we get it by sysfs. The left time value
should be equal to preset timeout value minus elapsed time value. According
to the Meson-GXB/GXL datasheets which can be found at [0], the timeout value
is saved to BIT[0-15] of the WATCHDOG_TCNT, and elapsed time value is saved
to BIT[16-31] of the WATCHDOG_TCNT.

[0]: http://linux-meson.com

Fixes: 683fa50f0e18 ("watchdog: Add Meson GXBB Watchdog Driver")
Signed-off-by: Xingyu Chen <[email protected]>
---
drivers/watchdog/meson_gxbb_wdt.c | 4 ++--
1 file changed, 2 insertions(+), 2 deletions(-)

diff --git a/drivers/watchdog/meson_gxbb_wdt.c b/drivers/watchdog/meson_gxbb_wdt.c
index d17c1a6..5a9ca10 100644
--- a/drivers/watchdog/meson_gxbb_wdt.c
+++ b/drivers/watchdog/meson_gxbb_wdt.c
@@ -89,8 +89,8 @@ static unsigned int meson_gxbb_wdt_get_timeleft(struct watchdog_device *wdt_dev)

reg = readl(data->reg_base + GXBB_WDT_TCNT_REG);

- return ((reg >> GXBB_WDT_TCNT_CNT_SHIFT) -
- (reg & GXBB_WDT_TCNT_SETUP_MASK)) / 1000;
+ return ((reg & GXBB_WDT_TCNT_SETUP_MASK) -
+ (reg >> GXBB_WDT_TCNT_CNT_SHIFT)) / 1000;
}

static const struct watchdog_ops meson_gxbb_wdt_ops = {
--
2.7.4


2019-09-30 08:19:21

by Neil Armstrong

[permalink] [raw]
Subject: Re: [PATCH] watchdog: meson: Fix the wrong value of left time

On 29/09/2019 12:53, Xingyu Chen wrote:
> The left time value is wrong when we get it by sysfs. The left time value
> should be equal to preset timeout value minus elapsed time value. According
> to the Meson-GXB/GXL datasheets which can be found at [0], the timeout value
> is saved to BIT[0-15] of the WATCHDOG_TCNT, and elapsed time value is saved
> to BIT[16-31] of the WATCHDOG_TCNT.
>
> [0]: http://linux-meson.com
>
> Fixes: 683fa50f0e18 ("watchdog: Add Meson GXBB Watchdog Driver")
> Signed-off-by: Xingyu Chen <[email protected]>
> ---
> drivers/watchdog/meson_gxbb_wdt.c | 4 ++--
> 1 file changed, 2 insertions(+), 2 deletions(-)
>
> diff --git a/drivers/watchdog/meson_gxbb_wdt.c b/drivers/watchdog/meson_gxbb_wdt.c
> index d17c1a6..5a9ca10 100644
> --- a/drivers/watchdog/meson_gxbb_wdt.c
> +++ b/drivers/watchdog/meson_gxbb_wdt.c
> @@ -89,8 +89,8 @@ static unsigned int meson_gxbb_wdt_get_timeleft(struct watchdog_device *wdt_dev)
>
> reg = readl(data->reg_base + GXBB_WDT_TCNT_REG);
>
> - return ((reg >> GXBB_WDT_TCNT_CNT_SHIFT) -
> - (reg & GXBB_WDT_TCNT_SETUP_MASK)) / 1000;
> + return ((reg & GXBB_WDT_TCNT_SETUP_MASK) -
> + (reg >> GXBB_WDT_TCNT_CNT_SHIFT)) / 1000;
> }
>
> static const struct watchdog_ops meson_gxbb_wdt_ops = {
>

Acked-by: Neil Armstrong <[email protected]>

2019-09-30 13:14:17

by Guenter Roeck

[permalink] [raw]
Subject: Re: [PATCH] watchdog: meson: Fix the wrong value of left time

On 9/29/19 3:53 AM, Xingyu Chen wrote:
> The left time value is wrong when we get it by sysfs. The left time value
> should be equal to preset timeout value minus elapsed time value. According
> to the Meson-GXB/GXL datasheets which can be found at [0], the timeout value
> is saved to BIT[0-15] of the WATCHDOG_TCNT, and elapsed time value is saved
> to BIT[16-31] of the WATCHDOG_TCNT.
>
> [0]: http://linux-meson.com
>
> Fixes: 683fa50f0e18 ("watchdog: Add Meson GXBB Watchdog Driver")
> Signed-off-by: Xingyu Chen <[email protected]>

Reviewed-by: Guenter Roeck <[email protected]>

> ---
> drivers/watchdog/meson_gxbb_wdt.c | 4 ++--
> 1 file changed, 2 insertions(+), 2 deletions(-)
>
> diff --git a/drivers/watchdog/meson_gxbb_wdt.c b/drivers/watchdog/meson_gxbb_wdt.c
> index d17c1a6..5a9ca10 100644
> --- a/drivers/watchdog/meson_gxbb_wdt.c
> +++ b/drivers/watchdog/meson_gxbb_wdt.c
> @@ -89,8 +89,8 @@ static unsigned int meson_gxbb_wdt_get_timeleft(struct watchdog_device *wdt_dev)
>
> reg = readl(data->reg_base + GXBB_WDT_TCNT_REG);
>
> - return ((reg >> GXBB_WDT_TCNT_CNT_SHIFT) -
> - (reg & GXBB_WDT_TCNT_SETUP_MASK)) / 1000;
> + return ((reg & GXBB_WDT_TCNT_SETUP_MASK) -
> + (reg >> GXBB_WDT_TCNT_CNT_SHIFT)) / 1000;
> }
>
> static const struct watchdog_ops meson_gxbb_wdt_ops = {
>

2019-10-03 18:20:49

by Kevin Hilman

[permalink] [raw]
Subject: Re: [PATCH] watchdog: meson: Fix the wrong value of left time

Xingyu Chen <[email protected]> writes:

> The left time value is wrong when we get it by sysfs. The left time value
> should be equal to preset timeout value minus elapsed time value. According
> to the Meson-GXB/GXL datasheets which can be found at [0], the timeout value
> is saved to BIT[0-15] of the WATCHDOG_TCNT, and elapsed time value is saved
> to BIT[16-31] of the WATCHDOG_TCNT.
>
> [0]: http://linux-meson.com
>
> Fixes: 683fa50f0e18 ("watchdog: Add Meson GXBB Watchdog Driver")
> Signed-off-by: Xingyu Chen <[email protected]>

Reviewed-by: Kevin Hilman <[email protected]>