lkml.org 
[lkml]   [2023]   [Feb]   [6]   [last100]   RSS Feed
Views: [wrap][no wrap]   [headers]  [forward] 
 
Messages in this thread
Patch in this message
/
From
Subject[PATCH 2/2] watchdog: sbsa_wdog: Make sure to program a larger timeout value
Date
There could be a corner case were-in the timeout value calculated will
become way to less than the calculated value since we are rounding down
the timeout value from 64-bit to 32-bit. To avoid hitting such cases,
make sure to program the timeout value to be UINT_MAX if the timeout
value is greater than UINT_MAX and the imeplementation is sbsa watchdog
revision 0.

Fixes: abd3ac7902fb ("watchdog: sbsa: Support architecture version 1")

Signed-off-by: George Cherian <george.cherian@marvell.com>
---
drivers/watchdog/sbsa_gwdt.c | 10 +++++++---
1 file changed, 7 insertions(+), 3 deletions(-)

diff --git a/drivers/watchdog/sbsa_gwdt.c b/drivers/watchdog/sbsa_gwdt.c
index aaa3f5631f29..028e450ed547 100644
--- a/drivers/watchdog/sbsa_gwdt.c
+++ b/drivers/watchdog/sbsa_gwdt.c
@@ -135,10 +135,14 @@ static u64 sbsa_gwdt_reg_read(struct sbsa_gwdt *gwdt)

static void sbsa_gwdt_reg_write(u64 val, struct sbsa_gwdt *gwdt)
{
- if (gwdt->version == 0)
- writel((u32)val, gwdt->control_base + SBSA_GWDT_WOR);
- else
+ if (gwdt->version == 0) {
+ if (val > UINT_MAX)
+ writel(UINT_MAX, gwdt->control_base + SBSA_GWDT_WOR);
+ else
+ writel((u32)val, gwdt->control_base + SBSA_GWDT_WOR);
+ } else {
lo_hi_writeq(val, gwdt->control_base + SBSA_GWDT_WOR);
+ }
}

/*
--
2.34.1
\
 
 \ /
  Last update: 2023-03-27 00:12    [W:0.553 / U:0.588 seconds]
©2003-2020 Jasper Spaans|hosted at Digital Ocean and TransIP|Read the blog|Advertise on this site