Linux-Watchdog Archive on lore.kernel.org
 help / color / Atom feed
* [PATCH] watchdog: meson: Fix the wrong value of left time
@ 2019-09-29 10:53 Xingyu Chen
  2019-09-30  8:16 ` Neil Armstrong
                   ` (2 more replies)
  0 siblings, 3 replies; 4+ messages in thread
From: Xingyu Chen @ 2019-09-29 10:53 UTC (permalink / raw)
  To: Wim Van Sebroeck, Guenter Roeck, Kevin Hilman, Neil Armstrong
  Cc: Xingyu Chen, Jerome Brunet, Qianggui Song, Jianxin Pan,
	linux-watchdog, linux-amlogic, linux-arm-kernel, linux-kernel

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 <xingyu.chen@amlogic.com>
---
 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


^ permalink raw reply	[flat|nested] 4+ messages in thread

* Re: [PATCH] watchdog: meson: Fix the wrong value of left time
  2019-09-29 10:53 [PATCH] watchdog: meson: Fix the wrong value of left time Xingyu Chen
@ 2019-09-30  8:16 ` Neil Armstrong
  2019-09-30 13:12 ` Guenter Roeck
  2019-10-03 17:35 ` Kevin Hilman
  2 siblings, 0 replies; 4+ messages in thread
From: Neil Armstrong @ 2019-09-30  8:16 UTC (permalink / raw)
  To: Xingyu Chen, Wim Van Sebroeck, Guenter Roeck, Kevin Hilman
  Cc: Jerome Brunet, Qianggui Song, Jianxin Pan, linux-watchdog,
	linux-amlogic, linux-arm-kernel, linux-kernel

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 <xingyu.chen@amlogic.com>
> ---
>  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 <narmstrong@baylibre.com>

^ permalink raw reply	[flat|nested] 4+ messages in thread

* Re: [PATCH] watchdog: meson: Fix the wrong value of left time
  2019-09-29 10:53 [PATCH] watchdog: meson: Fix the wrong value of left time Xingyu Chen
  2019-09-30  8:16 ` Neil Armstrong
@ 2019-09-30 13:12 ` Guenter Roeck
  2019-10-03 17:35 ` Kevin Hilman
  2 siblings, 0 replies; 4+ messages in thread
From: Guenter Roeck @ 2019-09-30 13:12 UTC (permalink / raw)
  To: Xingyu Chen, Wim Van Sebroeck, Kevin Hilman, Neil Armstrong
  Cc: Jerome Brunet, Qianggui Song, Jianxin Pan, linux-watchdog,
	linux-amlogic, linux-arm-kernel, linux-kernel

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 <xingyu.chen@amlogic.com>

Reviewed-by: Guenter Roeck <linux@roeck-us.net>

> ---
>   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 = {
> 


^ permalink raw reply	[flat|nested] 4+ messages in thread

* Re: [PATCH] watchdog: meson: Fix the wrong value of left time
  2019-09-29 10:53 [PATCH] watchdog: meson: Fix the wrong value of left time Xingyu Chen
  2019-09-30  8:16 ` Neil Armstrong
  2019-09-30 13:12 ` Guenter Roeck
@ 2019-10-03 17:35 ` Kevin Hilman
  2 siblings, 0 replies; 4+ messages in thread
From: Kevin Hilman @ 2019-10-03 17:35 UTC (permalink / raw)
  To: Xingyu Chen, Wim Van Sebroeck, Guenter Roeck, Neil Armstrong
  Cc: Xingyu Chen, Jerome Brunet, Qianggui Song, Jianxin Pan,
	linux-watchdog, linux-amlogic, linux-arm-kernel, linux-kernel

Xingyu Chen <xingyu.chen@amlogic.com> 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 <xingyu.chen@amlogic.com>

Reviewed-by: Kevin Hilman <khilman@baylibre.com>

^ permalink raw reply	[flat|nested] 4+ messages in thread

end of thread, back to index

Thread overview: 4+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2019-09-29 10:53 [PATCH] watchdog: meson: Fix the wrong value of left time Xingyu Chen
2019-09-30  8:16 ` Neil Armstrong
2019-09-30 13:12 ` Guenter Roeck
2019-10-03 17:35 ` Kevin Hilman

Linux-Watchdog Archive on lore.kernel.org

Archives are clonable:
	git clone --mirror https://lore.kernel.org/linux-watchdog/0 linux-watchdog/git/0.git

	# If you have public-inbox 1.1+ installed, you may
	# initialize and index your mirror using the following commands:
	public-inbox-init -V2 linux-watchdog linux-watchdog/ https://lore.kernel.org/linux-watchdog \
		linux-watchdog@vger.kernel.org linux-watchdog@archiver.kernel.org
	public-inbox-index linux-watchdog

Example config snippet for mirrors

Newsgroup available over NNTP:
	nntp://nntp.lore.kernel.org/org.kernel.vger.linux-watchdog


AGPL code for this site: git clone https://public-inbox.org/ public-inbox