Skip to contentSkip to conversation

Intel Keem Bay WDT bug fixes

PATCH Superseded [email protected] 2 participants 22 messages May 12, 2021 – May 13, 2021 Watchdog device drivers

v1 of 2 Superseded Latest is v2 →

lore
Share & tools
lore
#0 lore raw

cover Intel Keem Bay WDT bug fixes

From: Shruthi Sanil <[email protected]>

The series of patches include the below bug fixes
in the Intel Keem Bay watchdog timer driver:

Patch 1/10:
- Update WDT pre-timeout during the initialization
The pretimeout register has a default reset value. Hence when a smaller WDT timeout is set which would be lesser than the default pretimeout, the system behaves abnormally, starts triggering the pretimeout interrupt even when the WDT is not enabled, most of the times leading to system crash. Hence an update in the pre-timeout is also required for the default timeout that is being configured.

Patch 2/10:
- Upadate WDT pretimeout for every update in timeout The pre-timeout value to be programmed to the register has to be calculated and updated for every change in the timeout value. Else the threshold time wouldn't be calculated to its corresponding timeout.

Patch 3/10:
- Update pretimeout to 0 in the TH ISR
The pretimeout has to be updated to 0 during the ISR of the ThresHold interrupt. Else the TH interrupt would be triggerred for every tick until the timeout.

Patch 4/10:
- Clear either the TO or TH interrupt bit
During the interrupt service routine of the TimeOut interrupt and the ThresHold interrupt, the respective interrupt clear bit have to be cleared and not both.

Patch 5/10:
- Remove timeout update in the WDT start function
Removed set timeout from the start WDT function. There is a function defined to set the timeout. Hence no need to set the timeout again in start function as the timeout would have been already updated before calling the start/enable.

Patch 6/10:
- Removed timeout update in the TO ISR
In the TO ISR removed updating the Timeout value because its not serving any purpose as the timer would have already expired and the system would be rebooting.

Patch 7/10:
- Update the check in keembay_wdt_resume()
Corrected the typo in the function keembay_wdt_resume, we need to enable the WDT if it is disabled/not active.

Patch 8/10:
- MACRO for WDT enable and disable values
Introduced MACRO's for WDT enable and disable values for better readability

Patch 9/10:
- WDT SMC handler MACRO name update
Updated the WDT SMC handler MACRO name to make it clear that its a ARM SMC handler that helps in clearing the WDT interrupt bit.

Patch 10/10:
- Typo corrections and other blank operations Corrected typos, aligned the tabs and added new lines wherever required for better readability

Shruthi Sanil (10):
watchdog: keembay: Update WDT pre-timeout during the initialization
watchdog: keembay: Upadate WDT pretimeout for every update in timeout
watchdog: keembay: Update pretimeout to zero in the TH ISR
watchdog: keembay: Clear either the TO or TH interrupt bit
watchdog: keembay: Remove timeout update in the WDT start function
watchdog: keembay: Removed timeout update in the TO ISR
watchdog: keembay: Update the check in keembay_wdt_resume()
watchdog: keembay: MACRO for WDT enable and disable values
watchdog: keembay: WDT SMC handler MACRO name update
watchdog: keembay: Typo corrections and other blank operations

 drivers/watchdog/keembay_wdt.c | 36 ++++++++++++++++++++++------------
 1 file changed, 23 insertions(+), 13 deletions(-)

base-commit: 88b06399c9c766c283e070b022b5ceafa4f63f19

Signature · 1 line
2.17.1
#1 lore raw

PATCH 1/10 watchdog: keembay: Update WDT pre-timeout during the initialization

From: Shruthi Sanil <[email protected]>

The pretimeout register has a default reset value. Hence when a smaller WDT timeout is set which would be lesser than the default pretimeout, the system behaves abnormally, starts triggering the pretimeout interrupt even when the WDT is not enabled, most of the times leading to system crash. Hence an update in the pre-timeout is also required for the default timeout that is being configured.

Fixes fa0f8d51e90d ("watchdog: Add watchdog driver for Intel Keembay Soc")
---
 drivers/watchdog/keembay_wdt.c | 3 +++
 1 file changed, 3 insertions(+)
drivers/watchdog/keembay_wdt.c +3 -0
index 547d3fea33ff..f2f5c9fae29c 100644
@@ -29,6 +29,7 @@
 #define WDT_LOAD_MAX		U32_MAX
 #define WDT_LOAD_MIN		1
 #define WDT_TIMEOUT		5
+#define WDT_PRETIMEOUT		4
 
 static unsigned int timeout = WDT_TIMEOUT;
 module_param(timeout, int, 0);
@@ -224,11 +225,13 @@ static int keembay_wdt_probe(struct platform_device *pdev)
 	wdt->wdd.min_timeout	= WDT_LOAD_MIN;
 	wdt->wdd.max_timeout	= WDT_LOAD_MAX / wdt->rate;
 	wdt->wdd.timeout	= WDT_TIMEOUT;
+	wdt->wdd.pretimeout	= WDT_PRETIMEOUT;
 
 	watchdog_set_drvdata(&wdt->wdd, wdt);
 	watchdog_set_nowayout(&wdt->wdd, nowayout);
 	watchdog_init_timeout(&wdt->wdd, timeout, dev);
 	keembay_wdt_set_timeout(&wdt->wdd, wdt->wdd.timeout);
+	keembay_wdt_set_pretimeout(&wdt->wdd, wdt->wdd.pretimeout);
 
 	ret = devm_watchdog_register_device(dev, &wdt->wdd);
 	if (ret)
Signature · 1 line
2.17.1
maintainer Reviewed-by on v1 1/10
#2 lore raw

Re: [PATCH 01/10] watchdog: keembay: Update WDT pre-timeout during the initialization

Quoted 10 lines · On Wed, May 12, 2021 at 02:17:15PM +0530, [email protected] wrote:

From: Shruthi Sanil <[email protected]>

The pretimeout register has a default reset value. Hence when a smaller WDT timeout is set which would be lesser than the default pretimeout, the system behaves abnormally, starts triggering the pretimeout interrupt even when the WDT is not enabled, most of the times leading to system crash. Hence an update in the pre-timeout is also required for the default timeout that is being configured.

Quoted 4 lines
Fixes fa0f8d51e90d ("watchdog: Add watchdog driver for Intel Keembay Soc")
Quoted 33 lines
---
 drivers/watchdog/keembay_wdt.c | 3 +++
 1 file changed, 3 insertions(+)
drivers/watchdog/keembay_wdt.c +3 -0
index 547d3fea33ff..f2f5c9fae29c 100644
@@ -29,6 +29,7 @@
 #define WDT_LOAD_MAX		U32_MAX
 #define WDT_LOAD_MIN		1
 #define WDT_TIMEOUT		5
+#define WDT_PRETIMEOUT		4
 
 static unsigned int timeout = WDT_TIMEOUT;
 module_param(timeout, int, 0);
@@ -224,11 +225,13 @@ static int keembay_wdt_probe(struct platform_device *pdev)
 	wdt->wdd.min_timeout	= WDT_LOAD_MIN;
 	wdt->wdd.max_timeout	= WDT_LOAD_MAX / wdt->rate;
 	wdt->wdd.timeout	= WDT_TIMEOUT;
+	wdt->wdd.pretimeout	= WDT_PRETIMEOUT;
 
 	watchdog_set_drvdata(&wdt->wdd, wdt);
 	watchdog_set_nowayout(&wdt->wdd, nowayout);
 	watchdog_init_timeout(&wdt->wdd, timeout, dev);
 	keembay_wdt_set_timeout(&wdt->wdd, wdt->wdd.timeout);
+	keembay_wdt_set_pretimeout(&wdt->wdd, wdt->wdd.pretimeout);
 
 	ret = devm_watchdog_register_device(dev, &wdt->wdd);
 	if (ret)
Signature · 1 line
2.17.1
#3 lore raw

PATCH 2/10 watchdog: keembay: Upadate WDT pretimeout for every update in timeout

In reply to [email protected]

From: Shruthi Sanil <[email protected]>

The pre-timeout value to be programmed to the register has to be calculated and updated for every change in the timeout value. Else the threshold time wouldn't be calculated to its corresponding timeout.

Fixes fa0f8d51e90d ("watchdog: Add watchdog driver for Intel Keembay Soc")
---
 drivers/watchdog/keembay_wdt.c | 1 +
 1 file changed, 1 insertion(+)
drivers/watchdog/keembay_wdt.c +1 -0
index f2f5c9fae29c..b2afeb4a60e3 100644
@@ -109,6 +109,7 @@ static int keembay_wdt_set_timeout(struct watchdog_device *wdog, u32 t)
 {
 	wdog->timeout = t;
 	keembay_wdt_set_timeout_reg(wdog);
+	keembay_wdt_set_pretimeout_reg(wdog);
 
 	return 0;
 }
Signature · 1 line
2.17.1
maintainer Reviewed-by on v1 2/10
#4 lore raw

Re: [PATCH 02/10] watchdog: keembay: Upadate WDT pretimeout for every update in timeout

Quoted 11 lines · On Wed, May 12, 2021 at 02:17:16PM +0530, [email protected] wrote:

From: Shruthi Sanil <[email protected]>

The pre-timeout value to be programmed to the register has to be calculated and updated for every change in the timeout value. Else the threshold time wouldn't be calculated to its corresponding timeout.

Fixes fa0f8d51e90d ("watchdog: Add watchdog driver for Intel Keembay Soc")
Quoted 19 lines
---
 drivers/watchdog/keembay_wdt.c | 1 +
 1 file changed, 1 insertion(+)
drivers/watchdog/keembay_wdt.c +1 -0
index f2f5c9fae29c..b2afeb4a60e3 100644
@@ -109,6 +109,7 @@ static int keembay_wdt_set_timeout(struct watchdog_device *wdog, u32 t)
 {
 	wdog->timeout = t;
 	keembay_wdt_set_timeout_reg(wdog);
+	keembay_wdt_set_pretimeout_reg(wdog);
 
 	return 0;
 }
Signature · 1 line
2.17.1
#5 lore raw

PATCH 3/10 watchdog: keembay: Update pretimeout to zero in the TH ISR

In reply to [email protected]

From: Shruthi Sanil <[email protected]>

The pretimeout has to be updated to zero during the ISR of the ThresHold interrupt. Else the TH interrupt would be triggerred for every tick until the timeout.

Fixes fa0f8d51e90d ("watchdog: Add watchdog driver for Intel Keembay Soc")
---
 drivers/watchdog/keembay_wdt.c | 2 ++
 1 file changed, 2 insertions(+)
drivers/watchdog/keembay_wdt.c +2 -0
index b2afeb4a60e3..6053416b8d3d 100644
@@ -154,6 +154,8 @@ static irqreturn_t keembay_wdt_th_isr(int irq, void *dev_id)
 	struct keembay_wdt *wdt = dev_id;
 	struct arm_smccc_res res;
 
+	keembay_wdt_set_pretimeout(&wdt->wdd, 0x0);
+
 	arm_smccc_smc(WDT_ISR_CLEAR, WDT_ISR_MASK, 0, 0, 0, 0, 0, 0, &res);
 	dev_crit(wdt->wdd.parent, "Intel Keem Bay non-sec wdt pre-timeout.\n");
 	watchdog_notify_pretimeout(&wdt->wdd);
Signature · 1 line
2.17.1
maintainer Reviewed-by on v1 3/10
#6 lore raw

Re: [PATCH 03/10] watchdog: keembay: Update pretimeout to zero in the TH ISR

Quoted 10 lines · On Wed, May 12, 2021 at 02:17:17PM +0530, [email protected] wrote:

From: Shruthi Sanil <[email protected]>

The pretimeout has to be updated to zero during the ISR of the ThresHold interrupt. Else the TH interrupt would be triggerred for every tick until the timeout.

Fixes fa0f8d51e90d ("watchdog: Add watchdog driver for Intel Keembay Soc")
Quoted 20 lines
---
 drivers/watchdog/keembay_wdt.c | 2 ++
 1 file changed, 2 insertions(+)
drivers/watchdog/keembay_wdt.c +2 -0
index b2afeb4a60e3..6053416b8d3d 100644
@@ -154,6 +154,8 @@ static irqreturn_t keembay_wdt_th_isr(int irq, void *dev_id)
 	struct keembay_wdt *wdt = dev_id;
 	struct arm_smccc_res res;
 
+	keembay_wdt_set_pretimeout(&wdt->wdd, 0x0);
+
 	arm_smccc_smc(WDT_ISR_CLEAR, WDT_ISR_MASK, 0, 0, 0, 0, 0, 0, &res);
 	dev_crit(wdt->wdd.parent, "Intel Keem Bay non-sec wdt pre-timeout.\n");
 	watchdog_notify_pretimeout(&wdt->wdd);
Signature · 1 line
2.17.1
#7 lore raw

PATCH 4/10 watchdog: keembay: Clear either the TO or TH interrupt bit

In reply to [email protected]

From: Shruthi Sanil <[email protected]>

During the interrupt service routine of the TimeOut interrupt and the ThresHold interrupt, the respective interrupt clear bit have to be cleared and not both.

Fixes fa0f8d51e90d ("watchdog: Add watchdog driver for Intel Keembay Soc")
---
 drivers/watchdog/keembay_wdt.c | 7 ++++---
 1 file changed, 4 insertions(+), 3 deletions(-)
drivers/watchdog/keembay_wdt.c +4 -3
index 6053416b8d3d..f2a16c9933c3 100644
@@ -23,7 +23,8 @@
 #define TIM_WDOG_EN		0x8
 #define TIM_SAFE		0xc
 
-#define WDT_ISR_MASK		GENMASK(9, 8)
+#define WDT_TH_INT_MASK		BIT(8)
+#define WDT_TO_INT_MASK		BIT(9)
 #define WDT_ISR_CLEAR		0x8200ff18
 #define WDT_UNLOCK		0xf1d0dead
 #define WDT_LOAD_MAX		U32_MAX
@@ -142,7 +143,7 @@ static irqreturn_t keembay_wdt_to_isr(int irq, void *dev_id)
 	struct arm_smccc_res res;
 
 	keembay_wdt_writel(wdt, TIM_WATCHDOG, 1);
-	arm_smccc_smc(WDT_ISR_CLEAR, WDT_ISR_MASK, 0, 0, 0, 0, 0, 0, &res);
+	arm_smccc_smc(WDT_ISR_CLEAR, WDT_TO_INT_MASK, 0, 0, 0, 0, 0, 0, &res);
 	dev_crit(wdt->wdd.parent, "Intel Keem Bay non-sec wdt timeout.\n");
 	emergency_restart();
 
@@ -156,7 +157,7 @@ static irqreturn_t keembay_wdt_th_isr(int irq, void *dev_id)
 
 	keembay_wdt_set_pretimeout(&wdt->wdd, 0x0);
 
-	arm_smccc_smc(WDT_ISR_CLEAR, WDT_ISR_MASK, 0, 0, 0, 0, 0, 0, &res);
+	arm_smccc_smc(WDT_ISR_CLEAR, WDT_TH_INT_MASK, 0, 0, 0, 0, 0, 0, &res);
 	dev_crit(wdt->wdd.parent, "Intel Keem Bay non-sec wdt pre-timeout.\n");
 	watchdog_notify_pretimeout(&wdt->wdd);
 
Signature · 1 line
2.17.1
maintainer Reviewed-by on v1 4/10
#8 lore raw

Re: [PATCH 04/10] watchdog: keembay: Clear either the TO or TH interrupt bit

Quoted 10 lines · On Wed, May 12, 2021 at 02:17:18PM +0530, [email protected] wrote:

From: Shruthi Sanil <[email protected]>

During the interrupt service routine of the TimeOut interrupt and the ThresHold interrupt, the respective interrupt clear bit have to be cleared and not both.

Fixes fa0f8d51e90d ("watchdog: Add watchdog driver for Intel Keembay Soc")
Quoted 39 lines
---
 drivers/watchdog/keembay_wdt.c | 7 ++++---
 1 file changed, 4 insertions(+), 3 deletions(-)
drivers/watchdog/keembay_wdt.c +4 -3
index 6053416b8d3d..f2a16c9933c3 100644
@@ -23,7 +23,8 @@
 #define TIM_WDOG_EN		0x8
 #define TIM_SAFE		0xc
 
-#define WDT_ISR_MASK		GENMASK(9, 8)
+#define WDT_TH_INT_MASK		BIT(8)
+#define WDT_TO_INT_MASK		BIT(9)
 #define WDT_ISR_CLEAR		0x8200ff18
 #define WDT_UNLOCK		0xf1d0dead
 #define WDT_LOAD_MAX		U32_MAX
@@ -142,7 +143,7 @@ static irqreturn_t keembay_wdt_to_isr(int irq, void *dev_id)
 	struct arm_smccc_res res;
 
 	keembay_wdt_writel(wdt, TIM_WATCHDOG, 1);
-	arm_smccc_smc(WDT_ISR_CLEAR, WDT_ISR_MASK, 0, 0, 0, 0, 0, 0, &res);
+	arm_smccc_smc(WDT_ISR_CLEAR, WDT_TO_INT_MASK, 0, 0, 0, 0, 0, 0, &res);
 	dev_crit(wdt->wdd.parent, "Intel Keem Bay non-sec wdt timeout.\n");
 	emergency_restart();
 
@@ -156,7 +157,7 @@ static irqreturn_t keembay_wdt_th_isr(int irq, void *dev_id)
 
 	keembay_wdt_set_pretimeout(&wdt->wdd, 0x0);
 
-	arm_smccc_smc(WDT_ISR_CLEAR, WDT_ISR_MASK, 0, 0, 0, 0, 0, 0, &res);
+	arm_smccc_smc(WDT_ISR_CLEAR, WDT_TH_INT_MASK, 0, 0, 0, 0, 0, 0, &res);
 	dev_crit(wdt->wdd.parent, "Intel Keem Bay non-sec wdt pre-timeout.\n");
 	watchdog_notify_pretimeout(&wdt->wdd);
 
Signature · 1 line
2.17.1
#9 lore raw

PATCH 5/10 watchdog: keembay: Remove timeout update in the WDT start function

In reply to [email protected]

From: Shruthi Sanil <[email protected]>

Removed set timeout from the start WDT function. There is a function defined to set the timeout. Hence no need to set the timeout again in start function as the timeout would have been already updated before calling the start/enable.

Fixes fa0f8d51e90d ("watchdog: Add watchdog driver for Intel Keembay Soc")
---
 drivers/watchdog/keembay_wdt.c | 1 -
 1 file changed, 1 deletion(-)
drivers/watchdog/keembay_wdt.c +0 -1
index f2a16c9933c3..039753b9932b 100644
@@ -84,7 +84,6 @@ static int keembay_wdt_start(struct watchdog_device *wdog)
 {
 	struct keembay_wdt *wdt = watchdog_get_drvdata(wdog);
 
-	keembay_wdt_set_timeout_reg(wdog);
 	keembay_wdt_writel(wdt, TIM_WDOG_EN, 1);
 
 	return 0;
Signature · 1 line
2.17.1
maintainer Reviewed-by on v1 5/10
#10 lore raw

Re: [PATCH 05/10] watchdog: keembay: Remove timeout update in the WDT start function

Quoted 11 lines · On Wed, May 12, 2021 at 02:17:19PM +0530, [email protected] wrote:

From: Shruthi Sanil <[email protected]>

Removed set timeout from the start WDT function. There is a function defined to set the timeout. Hence no need to set the timeout again in start function as the timeout would have been already updated before calling the start/enable.

Fixes fa0f8d51e90d ("watchdog: Add watchdog driver for Intel Keembay Soc")
Quoted 19 lines
---
 drivers/watchdog/keembay_wdt.c | 1 -
 1 file changed, 1 deletion(-)
drivers/watchdog/keembay_wdt.c +0 -1
index f2a16c9933c3..039753b9932b 100644
@@ -84,7 +84,6 @@ static int keembay_wdt_start(struct watchdog_device *wdog)
 {
 	struct keembay_wdt *wdt = watchdog_get_drvdata(wdog);
 
-	keembay_wdt_set_timeout_reg(wdog);
 	keembay_wdt_writel(wdt, TIM_WDOG_EN, 1);
 
 	return 0;
Signature · 1 line
2.17.1
#11 lore raw

PATCH 6/10 watchdog: keembay: Removed timeout update in the TO ISR

In reply to [email protected]

From: Shruthi Sanil <[email protected]>

In the TO ISR removed updating the Timeout value because its not serving any purpose as the timer would have already expired and the system would be rebooting.

Fixes fa0f8d51e90d ("watchdog: Add watchdog driver for Intel Keembay Soc")
---
 drivers/watchdog/keembay_wdt.c | 1 -
 1 file changed, 1 deletion(-)
drivers/watchdog/keembay_wdt.c +0 -1
index 039753b9932b..dd192b8dff55 100644
@@ -141,7 +141,6 @@ static irqreturn_t keembay_wdt_to_isr(int irq, void *dev_id)
 	struct keembay_wdt *wdt = dev_id;
 	struct arm_smccc_res res;
 
-	keembay_wdt_writel(wdt, TIM_WATCHDOG, 1);
 	arm_smccc_smc(WDT_ISR_CLEAR, WDT_TO_INT_MASK, 0, 0, 0, 0, 0, 0, &res);
 	dev_crit(wdt->wdd.parent, "Intel Keem Bay non-sec wdt timeout.\n");
 	emergency_restart();
Signature · 1 line
2.17.1
maintainer Reviewed-by on v1 6/10
#12 lore raw

Re: [PATCH 06/10] watchdog: keembay: Removed timeout update in the TO ISR

Quoted 10 lines · On Wed, May 12, 2021 at 02:17:20PM +0530, [email protected] wrote:

From: Shruthi Sanil <[email protected]>

In the TO ISR removed updating the Timeout value because its not serving any purpose as the timer would have already expired and the system would be rebooting.

Fixes fa0f8d51e90d ("watchdog: Add watchdog driver for Intel Keembay Soc")
Quoted 19 lines
---
 drivers/watchdog/keembay_wdt.c | 1 -
 1 file changed, 1 deletion(-)
drivers/watchdog/keembay_wdt.c +0 -1
index 039753b9932b..dd192b8dff55 100644
@@ -141,7 +141,6 @@ static irqreturn_t keembay_wdt_to_isr(int irq, void *dev_id)
 	struct keembay_wdt *wdt = dev_id;
 	struct arm_smccc_res res;
 
-	keembay_wdt_writel(wdt, TIM_WATCHDOG, 1);
 	arm_smccc_smc(WDT_ISR_CLEAR, WDT_TO_INT_MASK, 0, 0, 0, 0, 0, 0, &res);
 	dev_crit(wdt->wdd.parent, "Intel Keem Bay non-sec wdt timeout.\n");
 	emergency_restart();
Signature · 1 line
2.17.1
#13 lore raw

PATCH 7/10 watchdog: keembay: Update the check in keembay_wdt_resume()

In reply to [email protected]

From: Shruthi Sanil <[email protected]>

Corrected the typo in the function keembay_wdt_resume, we need to enable the WDT if it is disabled/not active.

Fixes fa0f8d51e90d ("watchdog: Add watchdog driver for Intel Keembay Soc")
---
 drivers/watchdog/keembay_wdt.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)
drivers/watchdog/keembay_wdt.c +1 -1
index dd192b8dff55..10896415f8c7 100644
@@ -260,7 +260,7 @@ static int __maybe_unused keembay_wdt_resume(struct device *dev)
 {
 	struct keembay_wdt *wdt = dev_get_drvdata(dev);
 
-	if (watchdog_active(&wdt->wdd))
+	if (!watchdog_active(&wdt->wdd))
 		return keembay_wdt_start(&wdt->wdd);
 
 	return 0;
Signature · 1 line
2.17.1
maintainer
#14 lore raw

Re: [PATCH 07/10] watchdog: keembay: Update the check in keembay_wdt_resume()

Quoted 18 lines · On Wed, May 12, 2021 at 02:17:21PM +0530, [email protected] wrote:

From: Shruthi Sanil <[email protected]>

Corrected the typo in the function keembay_wdt_resume, we need to enable the WDT if it is disabled/not active.

Fixes fa0f8d51e90d ("watchdog: Add watchdog driver for Intel Keembay Soc")
---
 drivers/watchdog/keembay_wdt.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)
drivers/watchdog/keembay_wdt.c +0 -0
index dd192b8dff55..10896415f8c7 100644

drivers/watchdog/keembay_wdt.c static int __maybe_unused keembay_wdt_resume(struct device *dev) · line 263

Quoted 5 lines
drivers/watchdog/keembay_wdt.c +1 -1
@@ -260,7 +260,7 @@ static int __maybe_unused keembay_wdt_resume(struct device *dev)
 {
 	struct keembay_wdt *wdt = dev_get_drvdata(dev);
 
-	if (watchdog_active(&wdt->wdd))
+	if (!watchdog_active(&wdt->wdd))

Have you tested this ? "watchdog_active" refers to the watchdog core state. Your code now keeps the watchdog stopped after resume if it was running before, and starts it if it wasn't. Please run through a suspend/resume cycle with watchdog disabled and see what happens.

Guenter

Quoted 6 lines
drivers/watchdog/keembay_wdt.c +0 -0
 		return keembay_wdt_start(&wdt->wdd);
 
 	return 0;
Signature · 1 line
2.17.1
#15 lore raw

RE: [PATCH 07/10] watchdog: keembay: Update the check in keembay_wdt_resume()

Quoted 45 lines

-----Original Message-----
From: Guenter Roeck <[email protected]> On Behalf Of Guenter Roeck
Sent: Wednesday, May 12, 2021 7:32 PM
To: Sanil, Shruthi <[email protected]>
Cc: [email protected]; [email protected]; linux- [email protected]; [email protected]; [email protected]; [email protected]; Thokala, Srikanth <[email protected]>; Raja Subramanian, Lakshmi Bai <[email protected]>; Sangannavar, Mallikarjunappa <[email protected]>
Subject: Re: [PATCH 07/10] watchdog: keembay: Update the check in keembay_wdt_resume()

Quoted 20 lines · On Wed, May 12, 2021 at 02:17:21PM +0530, [email protected] wrote:

From: Shruthi Sanil <[email protected]>

Corrected the typo in the function keembay_wdt_resume, we need to enable the WDT if it is disabled/not active.

Fixes fa0f8d51e90d ("watchdog: Add watchdog driver for Intel Keembay

Soc")

---
 drivers/watchdog/keembay_wdt.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)
(quoted diff) +0 -0

b/drivers/watchdog/keembay_wdt.c index dd192b8dff55..10896415f8c7 100644

drivers/watchdog/keembay_wdt.c static int __maybe_unused · line 263

Quoted 5 lines
drivers/watchdog/keembay_wdt.c +1 -1
@@ -260,7 +260,7 @@ static int __maybe_unused
 keembay_wdt_resume(struct device *dev)  {
 	struct keembay_wdt *wdt = dev_get_drvdata(dev);
 
-	if (watchdog_active(&wdt->wdd))
+	if (!watchdog_active(&wdt->wdd))

Have you tested this ? "watchdog_active" refers to the watchdog core state. Your code now keeps the watchdog stopped after resume if it was running before, and starts it if it wasn't. Please run through a suspend/resume cycle with watchdog disabled and see what happens.

Quoted 1 line

Guenter

I had understood it wrongly. I was assuming that watchdog_active refers to the actual state of the HW. Hence I made that change. But since watchdog_active refers to the state of the core, the change that I have done is incorrect. Hence I'll drop this patch.

Thanks
Shruthi

Quoted 7 lines
Quoted 7 lines
drivers/watchdog/keembay_wdt.c +0 -1
 		return keembay_wdt_start(&wdt->wdd);
 
 	return 0;
--

2.17.1

#16 lore raw

PATCH 8/10 watchdog: keembay: MACRO for WDT enable and disable values

In reply to [email protected]

From: Shruthi Sanil <[email protected]>

Introduced MACRO's for WDT enable and disable values for better readability

---
 drivers/watchdog/keembay_wdt.c | 6 ++++--
 1 file changed, 4 insertions(+), 2 deletions(-)
drivers/watchdog/keembay_wdt.c +4 -2
index 10896415f8c7..63a7c5d719a3 100644
@@ -27,6 +27,8 @@
 #define WDT_TO_INT_MASK		BIT(9)
 #define WDT_ISR_CLEAR		0x8200ff18
 #define WDT_UNLOCK		0xf1d0dead
+#define WDT_DISABLE		0x0
+#define WDT_ENABLE		0x1
 #define WDT_LOAD_MAX		U32_MAX
 #define WDT_LOAD_MIN		1
 #define WDT_TIMEOUT		5
@@ -84,7 +86,7 @@ static int keembay_wdt_start(struct watchdog_device *wdog)
 {
 	struct keembay_wdt *wdt = watchdog_get_drvdata(wdog);
 
-	keembay_wdt_writel(wdt, TIM_WDOG_EN, 1);
+	keembay_wdt_writel(wdt, TIM_WDOG_EN, WDT_ENABLE);
 
 	return 0;
 }
@@ -93,7 +95,7 @@ static int keembay_wdt_stop(struct watchdog_device *wdog)
 {
 	struct keembay_wdt *wdt = watchdog_get_drvdata(wdog);
 
-	keembay_wdt_writel(wdt, TIM_WDOG_EN, 0);
+	keembay_wdt_writel(wdt, TIM_WDOG_EN, WDT_DISABLE);
 
 	return 0;
 }
Signature · 1 line
2.17.1
maintainer Reviewed-by on v1 8/10
#17 lore raw

Re: [PATCH 08/10] watchdog: keembay: MACRO for WDT enable and disable values

Quoted 7 lines · On Wed, May 12, 2021 at 02:17:22PM +0530, [email protected] wrote:

From: Shruthi Sanil <[email protected]>

Introduced MACRO's for WDT enable and disable values for better readability

Quoted 38 lines
---
 drivers/watchdog/keembay_wdt.c | 6 ++++--
 1 file changed, 4 insertions(+), 2 deletions(-)
drivers/watchdog/keembay_wdt.c +4 -2
index 10896415f8c7..63a7c5d719a3 100644
@@ -27,6 +27,8 @@
 #define WDT_TO_INT_MASK		BIT(9)
 #define WDT_ISR_CLEAR		0x8200ff18
 #define WDT_UNLOCK		0xf1d0dead
+#define WDT_DISABLE		0x0
+#define WDT_ENABLE		0x1
 #define WDT_LOAD_MAX		U32_MAX
 #define WDT_LOAD_MIN		1
 #define WDT_TIMEOUT		5
@@ -84,7 +86,7 @@ static int keembay_wdt_start(struct watchdog_device *wdog)
 {
 	struct keembay_wdt *wdt = watchdog_get_drvdata(wdog);
 
-	keembay_wdt_writel(wdt, TIM_WDOG_EN, 1);
+	keembay_wdt_writel(wdt, TIM_WDOG_EN, WDT_ENABLE);
 
 	return 0;
 }
@@ -93,7 +95,7 @@ static int keembay_wdt_stop(struct watchdog_device *wdog)
 {
 	struct keembay_wdt *wdt = watchdog_get_drvdata(wdog);
 
-	keembay_wdt_writel(wdt, TIM_WDOG_EN, 0);
+	keembay_wdt_writel(wdt, TIM_WDOG_EN, WDT_DISABLE);
 
 	return 0;
 }
Signature · 1 line
2.17.1
#18 lore raw

PATCH 9/10 watchdog: keembay: WDT SMC handler MACRO name update

In reply to [email protected]

From: Shruthi Sanil <[email protected]>

Updated the WDT SMC handler MACRO name to make it clear that its a ARM SMC handler that helps in clearing the WDT interrupt bit.

---
 drivers/watchdog/keembay_wdt.c | 6 +++---
 1 file changed, 3 insertions(+), 3 deletions(-)
drivers/watchdog/keembay_wdt.c +3 -3
index 63a7c5d719a3..0a8cf5b35699 100644
@@ -25,7 +25,7 @@
 
 #define WDT_TH_INT_MASK		BIT(8)
 #define WDT_TO_INT_MASK		BIT(9)
-#define WDT_ISR_CLEAR		0x8200ff18
+#define WDT_INT_CLEAR_SMC	0x8200ff18
 #define WDT_UNLOCK		0xf1d0dead
 #define WDT_DISABLE		0x0
 #define WDT_ENABLE		0x1
@@ -143,7 +143,7 @@ static irqreturn_t keembay_wdt_to_isr(int irq, void *dev_id)
 	struct keembay_wdt *wdt = dev_id;
 	struct arm_smccc_res res;
 
-	arm_smccc_smc(WDT_ISR_CLEAR, WDT_TO_INT_MASK, 0, 0, 0, 0, 0, 0, &res);
+	arm_smccc_smc(WDT_INT_CLEAR_SMC, WDT_TO_INT_MASK, 0, 0, 0, 0, 0, 0, &res);
 	dev_crit(wdt->wdd.parent, "Intel Keem Bay non-sec wdt timeout.\n");
 	emergency_restart();
 
@@ -157,7 +157,7 @@ static irqreturn_t keembay_wdt_th_isr(int irq, void *dev_id)
 
 	keembay_wdt_set_pretimeout(&wdt->wdd, 0x0);
 
-	arm_smccc_smc(WDT_ISR_CLEAR, WDT_TH_INT_MASK, 0, 0, 0, 0, 0, 0, &res);
+	arm_smccc_smc(WDT_INT_CLEAR_SMC, WDT_TH_INT_MASK, 0, 0, 0, 0, 0, 0, &res);
 	dev_crit(wdt->wdd.parent, "Intel Keem Bay non-sec wdt pre-timeout.\n");
 	watchdog_notify_pretimeout(&wdt->wdd);
 
Signature · 1 line
2.17.1
maintainer Reviewed-by on v1 9/10
#19 lore raw

Re: [PATCH 09/10] watchdog: keembay: WDT SMC handler MACRO name update

Quoted 7 lines · On Wed, May 12, 2021 at 02:17:23PM +0530, [email protected] wrote:

From: Shruthi Sanil <[email protected]>

Updated the WDT SMC handler MACRO name to make it clear that its a ARM SMC handler that helps in clearing the WDT interrupt bit.

Quoted 38 lines
---
 drivers/watchdog/keembay_wdt.c | 6 +++---
 1 file changed, 3 insertions(+), 3 deletions(-)
drivers/watchdog/keembay_wdt.c +3 -3
index 63a7c5d719a3..0a8cf5b35699 100644
@@ -25,7 +25,7 @@
 
 #define WDT_TH_INT_MASK		BIT(8)
 #define WDT_TO_INT_MASK		BIT(9)
-#define WDT_ISR_CLEAR		0x8200ff18
+#define WDT_INT_CLEAR_SMC	0x8200ff18
 #define WDT_UNLOCK		0xf1d0dead
 #define WDT_DISABLE		0x0
 #define WDT_ENABLE		0x1
@@ -143,7 +143,7 @@ static irqreturn_t keembay_wdt_to_isr(int irq, void *dev_id)
 	struct keembay_wdt *wdt = dev_id;
 	struct arm_smccc_res res;
 
-	arm_smccc_smc(WDT_ISR_CLEAR, WDT_TO_INT_MASK, 0, 0, 0, 0, 0, 0, &res);
+	arm_smccc_smc(WDT_INT_CLEAR_SMC, WDT_TO_INT_MASK, 0, 0, 0, 0, 0, 0, &res);
 	dev_crit(wdt->wdd.parent, "Intel Keem Bay non-sec wdt timeout.\n");
 	emergency_restart();
 
@@ -157,7 +157,7 @@ static irqreturn_t keembay_wdt_th_isr(int irq, void *dev_id)
 
 	keembay_wdt_set_pretimeout(&wdt->wdd, 0x0);
 
-	arm_smccc_smc(WDT_ISR_CLEAR, WDT_TH_INT_MASK, 0, 0, 0, 0, 0, 0, &res);
+	arm_smccc_smc(WDT_INT_CLEAR_SMC, WDT_TH_INT_MASK, 0, 0, 0, 0, 0, 0, &res);
 	dev_crit(wdt->wdd.parent, "Intel Keem Bay non-sec wdt pre-timeout.\n");
 	watchdog_notify_pretimeout(&wdt->wdd);
 
Signature · 1 line
2.17.1
#20 lore raw

PATCH 10/10 watchdog: keembay: Typo corrections and other blank operations

In reply to [email protected]

From: Shruthi Sanil <[email protected]>

Corrected typos, aligned the tabs and added new lines wherever required for better readability

---
 drivers/watchdog/keembay_wdt.c | 11 +++++++----
 1 file changed, 7 insertions(+), 4 deletions(-)
drivers/watchdog/keembay_wdt.c +7 -4
index 0a8cf5b35699..6a2699021263 100644
@@ -26,11 +26,14 @@
 #define WDT_TH_INT_MASK		BIT(8)
 #define WDT_TO_INT_MASK		BIT(9)
 #define WDT_INT_CLEAR_SMC	0x8200ff18
+
 #define WDT_UNLOCK		0xf1d0dead
 #define WDT_DISABLE		0x0
 #define WDT_ENABLE		0x1
+
 #define WDT_LOAD_MAX		U32_MAX
 #define WDT_LOAD_MIN		1
+
 #define WDT_TIMEOUT		5
 #define WDT_PRETIMEOUT		4
 
@@ -144,7 +147,7 @@ static irqreturn_t keembay_wdt_to_isr(int irq, void *dev_id)
 	struct arm_smccc_res res;
 
 	arm_smccc_smc(WDT_INT_CLEAR_SMC, WDT_TO_INT_MASK, 0, 0, 0, 0, 0, 0, &res);
-	dev_crit(wdt->wdd.parent, "Intel Keem Bay non-sec wdt timeout.\n");
+	dev_crit(wdt->wdd.parent, "Intel Keem Bay non-secure wdt timeout.\n");
 	emergency_restart();
 
 	return IRQ_HANDLED;
@@ -158,7 +161,7 @@ static irqreturn_t keembay_wdt_th_isr(int irq, void *dev_id)
 	keembay_wdt_set_pretimeout(&wdt->wdd, 0x0);
 
 	arm_smccc_smc(WDT_INT_CLEAR_SMC, WDT_TH_INT_MASK, 0, 0, 0, 0, 0, 0, &res);
-	dev_crit(wdt->wdd.parent, "Intel Keem Bay non-sec wdt pre-timeout.\n");
+	dev_crit(wdt->wdd.parent, "Intel Keem Bay non-secure wdt pre-timeout.\n");
 	watchdog_notify_pretimeout(&wdt->wdd);
 
 	return IRQ_HANDLED;
@@ -278,8 +281,8 @@ static const struct of_device_id keembay_wdt_match[] = {
 MODULE_DEVICE_TABLE(of, keembay_wdt_match);
 
 static struct platform_driver keembay_wdt_driver = {
-	.probe		= keembay_wdt_probe,
-	.driver		= {
+	.probe	= keembay_wdt_probe,
+	.driver	= {
 		.name		= "keembay_wdt",
 		.of_match_table	= keembay_wdt_match,
 		.pm		= &keembay_wdt_pm_ops,
Signature · 1 line
2.17.1
maintainer Reviewed-by on v1 10/10
#21 lore raw

Re: [PATCH 10/10] watchdog: keembay: Typo corrections and other blank operations

Quoted 8 lines · On Wed, May 12, 2021 at 02:17:24PM +0530, [email protected] wrote:

From: Shruthi Sanil <[email protected]>

Corrected typos, aligned the tabs and added new lines wherever required for better readability

Quoted 55 lines
---
 drivers/watchdog/keembay_wdt.c | 11 +++++++----
 1 file changed, 7 insertions(+), 4 deletions(-)
drivers/watchdog/keembay_wdt.c +7 -4
index 0a8cf5b35699..6a2699021263 100644
@@ -26,11 +26,14 @@
 #define WDT_TH_INT_MASK		BIT(8)
 #define WDT_TO_INT_MASK		BIT(9)
 #define WDT_INT_CLEAR_SMC	0x8200ff18
+
 #define WDT_UNLOCK		0xf1d0dead
 #define WDT_DISABLE		0x0
 #define WDT_ENABLE		0x1
+
 #define WDT_LOAD_MAX		U32_MAX
 #define WDT_LOAD_MIN		1
+
 #define WDT_TIMEOUT		5
 #define WDT_PRETIMEOUT		4
 
@@ -144,7 +147,7 @@ static irqreturn_t keembay_wdt_to_isr(int irq, void *dev_id)
 	struct arm_smccc_res res;
 
 	arm_smccc_smc(WDT_INT_CLEAR_SMC, WDT_TO_INT_MASK, 0, 0, 0, 0, 0, 0, &res);
-	dev_crit(wdt->wdd.parent, "Intel Keem Bay non-sec wdt timeout.\n");
+	dev_crit(wdt->wdd.parent, "Intel Keem Bay non-secure wdt timeout.\n");
 	emergency_restart();
 
 	return IRQ_HANDLED;
@@ -158,7 +161,7 @@ static irqreturn_t keembay_wdt_th_isr(int irq, void *dev_id)
 	keembay_wdt_set_pretimeout(&wdt->wdd, 0x0);
 
 	arm_smccc_smc(WDT_INT_CLEAR_SMC, WDT_TH_INT_MASK, 0, 0, 0, 0, 0, 0, &res);
-	dev_crit(wdt->wdd.parent, "Intel Keem Bay non-sec wdt pre-timeout.\n");
+	dev_crit(wdt->wdd.parent, "Intel Keem Bay non-secure wdt pre-timeout.\n");
 	watchdog_notify_pretimeout(&wdt->wdd);
 
 	return IRQ_HANDLED;
@@ -278,8 +281,8 @@ static const struct of_device_id keembay_wdt_match[] = {
 MODULE_DEVICE_TABLE(of, keembay_wdt_match);
 
 static struct platform_driver keembay_wdt_driver = {
-	.probe		= keembay_wdt_probe,
-	.driver		= {
+	.probe	= keembay_wdt_probe,
+	.driver	= {
 		.name		= "keembay_wdt",
 		.of_match_table	= keembay_wdt_match,
 		.pm		= &keembay_wdt_pm_ops,
Signature · 1 line
2.17.1