Add reaction control in rti
Subsystems (2)
v3 cover Add reaction control in rti
This allows for reaction control in rti driver. Since AM62L SoC [0] does not have WWD reset output routed to a ESM module like all other K3 SoC's and has a reset signal routed to the reset HW block, add a new compatible for AM62L and configure reset reaction for AM62L SoC instead of NMI.
This patch has been tested on AM62L EVM [1].
Changes since v2:
- Pick Krzysztof's tag
- Take Andrew's sugestions from v2 for patch 2/2
-> switch to device_get_match_data
-> fix comment and assignment of reaction variable logic in rti_wdt_start
v2: https://lore.kernel.org/linux-devicetree/[email protected]/
v1-resend: https://lore.kernel.org/linux-devicetree/[email protected]/
v1: https://lore.kernel.org/linux-devicetree/[email protected]/
[0] https://www.ti.com/product/AM62L
[1] https://www.ti.com/tool/TMDS62LEVM
Judith Mendez (2):
dt-bindings: watchdog: ti,rti-wdt: Add ti,am62l-rti-wdt compatible
watchdog: rti_wdt: Add reaction control
.../bindings/watchdog/ti,rti-wdt.yaml | 1 + drivers/watchdog/rti_wdt.c | 32 ++++++++++++++++--- 2 files changed, 29 insertions(+), 4 deletions(-)
Signature · 1 line
2.49.0
PATCH v3 1/2 dt-bindings: watchdog: ti,rti-wdt: Add ti,am62l-rti-wdt compatible
Add a new compatible ti,am62l-rti-wdt for am62l SoC [0].
[0] https://www.ti.com/product/AM62L
--- Documentation/devicetree/bindings/watchdog/ti,rti-wdt.yaml | 1 + 1 file changed, 1 insertion(+)
Documentation/devicetree/bindings/watchdog/ti,rti-wdt.yaml +1 -0
@@ -23,6 +23,7 @@ allOf: properties: compatible: enum: + - ti,am62l-rti-wdt - ti,j7-rti-wdt reg:
Signature · 1 line
2.49.0
PATCH v3 2/2 watchdog: rti_wdt: Add reaction control
In reply to Judith MendezThis allows to configure reaction between NMI and reset for WWD.
On K3 SoC's other than AM62L SoC [0], watchdog reset output is routed to the ESM module which can subsequently route the signal to safety master or SoC reset. On AM62L, the watchdog reset output is routed to the SoC HW reset block. So, add a new compatible for AM62l to add SoC data and configure reaction to reset instead of NMI.
[0] https://www.ti.com/product/AM62L
--- drivers/watchdog/rti_wdt.c | 32 ++++++++++++++++++++++++++++---- 1 file changed, 28 insertions(+), 4 deletions(-)
drivers/watchdog/rti_wdt.c +28 -4
@@ -35,7 +35,8 @@#define RTIWWDRXCTRL 0xa4#define RTIWWDSIZECTRL 0xa8 -#define RTIWWDRX_NMI 0xa +#define RTIWWDRXN_RST 0x5 +#define RTIWWDRXN_NMI 0xa#define RTIWWDSIZE_50P 0x50#define RTIWWDSIZE_25P 0x500
@@ -63,22 +64,29 @@static int heartbeat; +struct rti_wdt_data { +bool reset; +}; +/* * struct to hold data for each WDT device * @base - base io address of WD device * @freq - source clock frequency of WDT * @wdd - hold watchdog device as is in WDT core +* @data - hold configuration data */ struct rti_wdt_device {void __iomem *base;unsigned long freq;struct watchdog_device wdd; +const struct rti_wdt_data *data; };static int rti_wdt_start (struct watchdog_device *wdd) {u32 timer_margin;struct rti_wdt_device *wdt =watchdog_get_drvdata (wdd); +u8 reaction;int ret; ret =pm_runtime_resume_and_get (wdd->parent);
@@ -101,8 +109,13 @@ static int rti_wdt_start(struct watchdog_device *wdd)*/ wdd->min_hw_heartbeat_ms =520 * wdd->timeout +MAX_HW_ERROR ; -/* Generate NMI when wdt expires */ -writel_relaxed (RTIWWDRX_NMI , wdt->base +RTIWWDRXCTRL ); +/* Reset device if wdt serviced outside of window or generate NMI if available */ +if (wdt->data->reset) + reaction =RTIWWDRXN_RST ; +else + reaction =RTIWWDRXN_NMI ; + +writel_relaxed (reaction, wdt->base +RTIWWDRXCTRL );/* Open window size 50%; this is the largest window size available */ writel_relaxed (RTIWWDSIZE_50P , wdt->base +RTIWWDSIZECTRL );
@@ -255,6 +268,8 @@ static int rti_wdt_probe(struct platform_device *pdev) wdd->timeout =DEFAULT_HEARTBEAT ; wdd->parent = dev; + wdt->data =device_get_match_data (dev); +watchdog_set_drvdata (wdd, wdt);watchdog_set_nowayout (wdd,1 );watchdog_set_restart_priority (wdd,128 );
@@ -369,8 +384,17 @@ static void rti_wdt_remove(struct platform_device *pdev)pm_runtime_disable (&pdev->dev); } +static struct rti_wdt_data j7_wdt = { + .reset = false, +}; + +static struct rti_wdt_data am62l_wdt = { + .reset = true, +}; +static const struct of_device_id rti_wdt_of_match[] = { - { .compatible ="ti,j7-rti-wdt" , }, + { .compatible ="ti,j7-rti-wdt" , .data = &j7_wdt }, + { .compatible ="ti,am62l-rti-wdt" , .data = &am62l_wdt }, {}, };MODULE_DEVICE_TABLE (of, rti_wdt_of_match);
Signature · 1 line
2.49.0
Guenter Roeck
maintainerRe: [PATCH v3 2/2] watchdog: rti_wdt: Add reaction control
Quoted 59 lines · Judith Mendez
This allows to configure reaction between NMI and reset for WWD.
On K3 SoC's other than AM62L SoC [0], watchdog reset output is routed to the ESM module which can subsequently route the signal to safety master or SoC reset. On AM62L, the watchdog reset output is routed to the SoC HW reset block. So, add a new compatible for AM62l to add SoC data and configure reaction to reset instead of NMI.
[0] https://www.ti.com/product/AM62L
Signed-off-by Judith Mendez <[email protected]>--- drivers/watchdog/rti_wdt.c | 32 ++++++++++++++++++++++++++++---- 1 file changed, 28 insertions(+), 4 deletions(-)drivers/watchdog/rti_wdt.c +9
-1@@ -35,7 +35,8 @@#define RTIWWDRXCTRL 0xa4#define RTIWWDSIZECTRL 0xa8 -#define RTIWWDRX_NMI 0xa +#define RTIWWDRXN_RST 0x5 +#define RTIWWDRXN_NMI 0xa#define RTIWWDSIZE_50P 0x50#define RTIWWDSIZE_25P 0x500@@ -63,22 +64,29 @@static int heartbeat; +struct rti_wdt_data { +bool reset; +}; +/* * struct to hold data for each WDT device * @base - base io address of WD device * @freq - source clock frequency of WDT * @wdd - hold watchdog device as is in WDT core +* @data - hold configuration data */ struct rti_wdt_device {void __iomem *base;unsigned long freq;struct watchdog_device wdd; +const struct rti_wdt_data *data; };static int rti_wdt_start (struct watchdog_device *wdd) {u32 timer_margin;struct rti_wdt_device *wdt =watchdog_get_drvdata (wdd); +u8 reaction;int ret; ret =pm_runtime_resume_and_get (wdd->parent);
drivers/watchdog/rti_wdt.c static int rti_wdt_start(struct watchdog_device *wdd) · line 112
Quoted 6 lines
drivers/watchdog/rti_wdt.c +1
-2@@ -101,8 +109,13 @@ static int rti_wdt_start(struct watchdog_device *wdd)*/ wdd->min_hw_heartbeat_ms =520 * wdd->timeout +MAX_HW_ERROR ; -/* Generate NMI when wdt expires */ -writel_relaxed (RTIWWDRX_NMI , wdt->base +RTIWWDRXCTRL ); +/* Reset device if wdt serviced outside of window or generate NMI if available */
Shouldn't that be "or generate NMI if _not_ available" ?
Guenter
Quoted 40 lines
drivers/watchdog/rti_wdt.c +18
-1+if (wdt->data->reset) + reaction =RTIWWDRXN_RST ; +else + reaction =RTIWWDRXN_NMI ; + +writel_relaxed (reaction, wdt->base +RTIWWDRXCTRL );/* Open window size 50%; this is the largest window size available */ writel_relaxed (RTIWWDSIZE_50P , wdt->base +RTIWWDSIZECTRL );@@ -255,6 +268,8 @@ static int rti_wdt_probe(struct platform_device *pdev) wdd->timeout =DEFAULT_HEARTBEAT ; wdd->parent = dev; + wdt->data =device_get_match_data (dev); +watchdog_set_drvdata (wdd, wdt);watchdog_set_nowayout (wdd,1 );watchdog_set_restart_priority (wdd,128 );@@ -369,8 +384,17 @@ static void rti_wdt_remove(struct platform_device *pdev)pm_runtime_disable (&pdev->dev); } +static struct rti_wdt_data j7_wdt = { + .reset = false, +}; + +static struct rti_wdt_data am62l_wdt = { + .reset = true, +}; +static const struct of_device_id rti_wdt_of_match[] = { - { .compatible ="ti,j7-rti-wdt" , }, + { .compatible ="ti,j7-rti-wdt" , .data = &j7_wdt }, + { .compatible ="ti,am62l-rti-wdt" , .data = &am62l_wdt }, {}, };MODULE_DEVICE_TABLE (of, rti_wdt_of_match);Signature · 1 line
2.49.0
Re: [PATCH v3 2/2] watchdog: rti_wdt: Add reaction control
Quoted 63 lines · Guenter Roeck
Quoted 62 lines · Judith Mendez
This allows to configure reaction between NMI and reset for WWD.
On K3 SoC's other than AM62L SoC [0], watchdog reset output is routed to the ESM module which can subsequently route the signal to safety master or SoC reset. On AM62L, the watchdog reset output is routed to the SoC HW reset block. So, add a new compatible for AM62l to add SoC data and configure reaction to reset instead of NMI.
[0] https://www.ti.com/product/AM62L
Signed-off-by Judith Mendez <[email protected]>--- drivers/watchdog/rti_wdt.c | 32 ++++++++++++++++++++++++++++---- 1 file changed, 28 insertions(+), 4 deletions(-)drivers/watchdog/rti_wdt.c +9
-1@@ -35,7 +35,8 @@#define RTIWWDRXCTRL 0xa4#define RTIWWDSIZECTRL 0xa8 -#define RTIWWDRX_NMI 0xa +#define RTIWWDRXN_RST 0x5 +#define RTIWWDRXN_NMI 0xa#define RTIWWDSIZE_50P 0x50#define RTIWWDSIZE_25P 0x500@@ -63,22 +64,29 @@static int heartbeat; +struct rti_wdt_data { +bool reset; +}; +/* * struct to hold data for each WDT device * @base - base io address of WD device * @freq - source clock frequency of WDT * @wdd - hold watchdog device as is in WDT core +* @data - hold configuration data */ struct rti_wdt_device {void __iomem *base;unsigned long freq;struct watchdog_device wdd; +const struct rti_wdt_data *data; };static int rti_wdt_start (struct watchdog_device *wdd) {u32 timer_margin;struct rti_wdt_device *wdt =watchdog_get_drvdata (wdd); +u8 reaction;int ret; ret =pm_runtime_resume_and_get (wdd->parent);@@ -101,8 +109,13 @@ static int rti_wdt_start(struct watchdog_device *wdd)*/ wdd->min_hw_heartbeat_ms =520 * wdd->timeout +MAX_HW_ERROR ;
Quoted 6 lines
drivers/watchdog/rti_wdt.c static int rti_wdt_start(struct watchdog_device *wdd) · line 112
Quoted 3 lines
drivers/watchdog/rti_wdt.c +1
-2-/* Generate NMI when wdt expires */ -writel_relaxed (RTIWWDRX_NMI , wdt->base +RTIWWDRXCTRL ); +/* Reset device if wdt serviced outside of window or generate NMI if available */ Shouldn't that be "or generate NMI if _not_ available" ?
For almost all the K3 devices, the WDT has two selectable outputs, one resets the device directly, the other is this "NMI" which is wired to an ESM module which can take other actions (but usually it just also resets the device). For AM62L that second NMI output is not wired (no ESM module), so our only choice is to set the WDT to direct reset mode.
The wording is a little strange, but the "or generate NMI if available" meaning if NMI is available, then do that. Reset being the fallback when _not_ available.
Maybe this would work better:
/* If WDT is serviced outside of window, generate NMI if available, or reset device */
Andrew
Quoted 42 lines
Guenter
Quoted 40 lines
drivers/watchdog/rti_wdt.c +18
-1+if (wdt->data->reset) + reaction =RTIWWDRXN_RST ; +else + reaction =RTIWWDRXN_NMI ; + +writel_relaxed (reaction, wdt->base +RTIWWDRXCTRL );/* Open window size 50%; this is the largest window size available */ writel_relaxed (RTIWWDSIZE_50P , wdt->base +RTIWWDSIZECTRL );@@ -255,6 +268,8 @@ static int rti_wdt_probe(struct platform_device *pdev) wdd->timeout =DEFAULT_HEARTBEAT ; wdd->parent = dev; + wdt->data =device_get_match_data (dev); +watchdog_set_drvdata (wdd, wdt);watchdog_set_nowayout (wdd,1 );watchdog_set_restart_priority (wdd,128 );@@ -369,8 +384,17 @@ static void rti_wdt_remove(struct platform_device *pdev)pm_runtime_disable (&pdev->dev); } +static struct rti_wdt_data j7_wdt = { + .reset = false, +}; + +static struct rti_wdt_data am62l_wdt = { + .reset = true, +}; +static const struct of_device_id rti_wdt_of_match[] = { - { .compatible ="ti,j7-rti-wdt" , }, + { .compatible ="ti,j7-rti-wdt" , .data = &j7_wdt }, + { .compatible ="ti,am62l-rti-wdt" , .data = &am62l_wdt }, {}, };MODULE_DEVICE_TABLE (of, rti_wdt_of_match);Signature · 1 line
2.49.0
Guenter Roeck
maintainerRe: [PATCH v3 2/2] watchdog: rti_wdt: Add reaction control
Quoted 70 lines · Andrew Davis
Quoted 53 lines · Guenter Roeck
Quoted 52 lines · Judith Mendez
This allows to configure reaction between NMI and reset for WWD.
On K3 SoC's other than AM62L SoC [0], watchdog reset output is routed to the ESM module which can subsequently route the signal to safety master or SoC reset. On AM62L, the watchdog reset output is routed to the SoC HW reset block. So, add a new compatible for AM62l to add SoC data and configure reaction to reset instead of NMI.
[0] https://www.ti.com/product/AM62L
Signed-off-by Judith Mendez <[email protected]>--- drivers/watchdog/rti_wdt.c | 32 ++++++++++++++++++++++++++++---- 1 file changed, 28 insertions(+), 4 deletions(-)drivers/watchdog/rti_wdt.c +9
-1@@ -35,7 +35,8 @@#define RTIWWDRXCTRL 0xa4#define RTIWWDSIZECTRL 0xa8 -#define RTIWWDRX_NMI 0xa +#define RTIWWDRXN_RST 0x5 +#define RTIWWDRXN_NMI 0xa#define RTIWWDSIZE_50P 0x50#define RTIWWDSIZE_25P 0x500@@ -63,22 +64,29 @@static int heartbeat; +struct rti_wdt_data { +bool reset; +}; +/* * struct to hold data for each WDT device * @base - base io address of WD device * @freq - source clock frequency of WDT * @wdd - hold watchdog device as is in WDT core +* @data - hold configuration data */ struct rti_wdt_device {void __iomem *base;unsigned long freq;struct watchdog_device wdd; +const struct rti_wdt_data *data; };static int rti_wdt_start (struct watchdog_device *wdd) {u32 timer_margin;struct rti_wdt_device *wdt =watchdog_get_drvdata (wdd); +u8 reaction;int ret; ret =pm_runtime_resume_and_get (wdd->parent);Quoted 9 lines
drivers/watchdog/rti_wdt.c static int rti_wdt_start(struct watchdog_device *wdd) · line 111
Quoted 6 lines
drivers/watchdog/rti_wdt.c +1
-2@@ -101,8 +109,13 @@ static int rti_wdt_start(struct watchdog_device *wdd)*/ wdd->min_hw_heartbeat_ms =520 * wdd->timeout +MAX_HW_ERROR ; -/* Generate NMI when wdt expires */ -writel_relaxed (RTIWWDRX_NMI , wdt->base +RTIWWDRXCTRL ); +/* Reset device if wdt serviced outside of window or generate NMI if available */ Shouldn't that be "or generate NMI if _not_ available" ?
For almost all the K3 devices, the WDT has two selectable outputs, one resets the device directly, the other is this "NMI" which is wired to an ESM module which can take other actions (but usually it just also resets the device). For AM62L that second NMI output is not wired (no ESM module), so our only choice is to set the WDT to direct reset mode.
Quoted 7 lines
The wording is a little strange, but the "or generate NMI if available" meaning if NMI is available, then do that. Reset being the fallback when _not_ available.
Maybe this would work better:
/* If WDT is serviced outside of window, generate NMI if available, or reset device */
The problem is that the code doesn't match the comment. The code checks the "reset" flag and requests a reset if available. If doesn't check an "nmi" flag.
If the preference is NMI, as your comment suggests, the flag should be named "nmi" and be set if NMI is available. That would align the code and the comment. Right now both code and comment are misleading, since the presence of a reset flag (and setting it to false) suggests that a direct reset is not available, and that reset is preferred if available. A reset is the normally expected behavior for a watchdog, so the fact that this is _not_ the case for this watchdog should be made more visible.
Guenter
Quoted 41 lines
Andrew
Quoted 39 lines
Guenter
Quoted 37 lines
drivers/watchdog/rti_wdt.c +18
-1+if (wdt->data->reset) + reaction =RTIWWDRXN_RST ; +else + reaction =RTIWWDRXN_NMI ; + +writel_relaxed (reaction, wdt->base +RTIWWDRXCTRL );/* Open window size 50%; this is the largest window size available */ writel_relaxed (RTIWWDSIZE_50P , wdt->base +RTIWWDSIZECTRL );@@ -255,6 +268,8 @@ static int rti_wdt_probe(struct platform_device *pdev) wdd->timeout =DEFAULT_HEARTBEAT ; wdd->parent = dev; + wdt->data =device_get_match_data (dev); +watchdog_set_drvdata (wdd, wdt);watchdog_set_nowayout (wdd,1 );watchdog_set_restart_priority (wdd,128 );@@ -369,8 +384,17 @@ static void rti_wdt_remove(struct platform_device *pdev)pm_runtime_disable (&pdev->dev); } +static struct rti_wdt_data j7_wdt = { + .reset = false, +}; + +static struct rti_wdt_data am62l_wdt = { + .reset = true, +}; +static const struct of_device_id rti_wdt_of_match[] = { - { .compatible ="ti,j7-rti-wdt" , }, + { .compatible ="ti,j7-rti-wdt" , .data = &j7_wdt }, + { .compatible ="ti,am62l-rti-wdt" , .data = &am62l_wdt }, {}, };MODULE_DEVICE_TABLE (of, rti_wdt_of_match);Signature · 1 line
2.49.0
Re: [PATCH v3 2/2] watchdog: rti_wdt: Add reaction control
Hi Guenter, Andrew,
Quoted 83 lines · Guenter Roeck
Quoted 70 lines · Andrew Davis
Quoted 53 lines · Guenter Roeck
Quoted 52 lines · Judith Mendez
This allows to configure reaction between NMI and reset for WWD.
On K3 SoC's other than AM62L SoC [0], watchdog reset output is routed to the ESM module which can subsequently route the signal to safety master or SoC reset. On AM62L, the watchdog reset output is routed to the SoC HW reset block. So, add a new compatible for AM62l to add SoC data and configure reaction to reset instead of NMI.
[0] https://www.ti.com/product/AM62L
Signed-off-by Judith Mendez <[email protected]>--- drivers/watchdog/rti_wdt.c | 32 ++++++++++++++++++++++++++++---- 1 file changed, 28 insertions(+), 4 deletions(-)drivers/watchdog/rti_wdt.c +9
-1@@ -35,7 +35,8 @@#define RTIWWDRXCTRL 0xa4#define RTIWWDSIZECTRL 0xa8 -#define RTIWWDRX_NMI 0xa +#define RTIWWDRXN_RST 0x5 +#define RTIWWDRXN_NMI 0xa#define RTIWWDSIZE_50P 0x50#define RTIWWDSIZE_25P 0x500@@ -63,22 +64,29 @@static int heartbeat; +struct rti_wdt_data { +bool reset; +}; +/* * struct to hold data for each WDT device * @base - base io address of WD device * @freq - source clock frequency of WDT * @wdd - hold watchdog device as is in WDT core +* @data - hold configuration data */ struct rti_wdt_device {void __iomem *base;unsigned long freq;struct watchdog_device wdd; +const struct rti_wdt_data *data; };static int rti_wdt_start (struct watchdog_device *wdd) {u32 timer_margin;struct rti_wdt_device *wdt =watchdog_get_drvdata (wdd); +u8 reaction;int ret; ret =pm_runtime_resume_and_get (wdd->parent);Quoted 9 lines
drivers/watchdog/rti_wdt.c static int rti_wdt_start(struct watchdog_device *wdd) · line 111
Quoted 6 lines
drivers/watchdog/rti_wdt.c +1
-2@@ -101,8 +109,13 @@ static int rti_wdt_start(struct watchdog_device *wdd)*/ wdd->min_hw_heartbeat_ms =520 * wdd->timeout +MAX_HW_ERROR ; -/* Generate NMI when wdt expires */ -writel_relaxed (RTIWWDRX_NMI , wdt->base +RTIWWDRXCTRL ); +/* Reset device if wdt serviced outside of window or generate NMI if available */ Shouldn't that be "or generate NMI if _not_ available" ?
For almost all the K3 devices, the WDT has two selectable outputs, one resets the device directly, the other is this "NMI" which is wired to an ESM module which can take other actions (but usually it just also resets the device). For AM62L that second NMI output is not wired (no ESM module), so our only choice is to set the WDT to direct reset mode.
Quoted 7 lines
The wording is a little strange, but the "or generate NMI if available" meaning if NMI is available, then do that. Reset being the fallback when _not_ available.
Maybe this would work better:
/* If WDT is serviced outside of window, generate NMI if available, or reset device */
The problem is that the code doesn't match the comment. The code checks the "reset" flag and requests a reset if available. If doesn't check an "nmi" flag.
Quoted 7 lines
If the preference is NMI, as your comment suggests, the flag should be named "nmi" and be set if NMI is available. That would align the code and the comment. Right now both code and comment are misleading, since the presence of a reset flag (and setting it to false) suggests that a direct reset is not available, and that reset is preferred if available. A reset is the normally expected behavior for a watchdog, so the fact that this is _not_ the case for this watchdog should be made more visible.
How about:
/* If WWDT serviced outside of window, generate NMI or reset the device if NMI not available */
if (wdt->data->reset)
reaction = RTIWWDRXN_RST; else reaction = RTIWWDRXN_NMI;
~ Judith
...
Re: [PATCH v3 2/2] watchdog: rti_wdt: Add reaction control
Hi all,
Quoted 100 lines · Judith Mendez
Hi Guenter, Andrew,
Quoted 85 lines · Guenter Roeck
Quoted 72 lines · Andrew Davis
Quoted 55 lines · Guenter Roeck
Quoted 54 lines · Judith Mendez
This allows to configure reaction between NMI and reset for WWD.
On K3 SoC's other than AM62L SoC [0], watchdog reset output is routed to the ESM module which can subsequently route the signal to safety master or SoC reset. On AM62L, the watchdog reset output is routed to the SoC HW reset block. So, add a new compatible for AM62l to add SoC data and configure reaction to reset instead of NMI.
[0] https://www.ti.com/product/AM62L
Signed-off-by Judith Mendez <[email protected]>---
drivers/watchdog/rti_wdt.c| 32 ++++++++++++++++++++++++++++----1 file changed, 28 insertions(+), 4 deletions(-)drivers/watchdog/rti_wdt.c +9
-1@@ -35,7 +35,8 @@ #define RTIWWDRXCTRL 0xa4 #define RTIWWDSIZECTRL 0xa8 -#define RTIWWDRX_NMI 0xa +#define RTIWWDRXN_RST 0x5 +#define RTIWWDRXN_NMI 0xa #define RTIWWDSIZE_50P 0x50 #define RTIWWDSIZE_25P 0x500@@ -63,22 +64,29 @@ static int heartbeat; +struct rti_wdt_data { + bool reset; +}; + /* * struct to hold data for each WDT device * @base - base io address of WD device * @freq - source clock frequency of WDT * @wdd - hold watchdog device as is in WDT core + * @data - hold configuration data */ struct rti_wdt_device { void __iomem *base; unsigned long freq; struct watchdog_device wdd; + const struct rti_wdt_data *data; }; static int rti_wdt_start(struct watchdog_device *wdd) { u32 timer_margin; struct rti_wdt_device *wdt = watchdog_get_drvdata(wdd); + u8 reaction; int ret; ret = pm_runtime_resume_and_get(wdd->parent);@@ -101,8 +109,13 @@ static int rti_wdt_start(struct watchdog_device *wdd)Quoted 9 lines
Quoted 6 lines
drivers/watchdog/rti_wdt.c +1
-2*/ wdd->min_hw_heartbeat_ms = 520 * wdd->timeout + MAX_HW_ERROR; - /* Generate NMI when wdt expires */ - writel_relaxed(RTIWWDRX_NMI, wdt->base + RTIWWDRXCTRL); + /* Reset device if wdt serviced outside of window or generateNMI if available */
Shouldn't that be "or generate NMI if _not_ available" ?
For almost all the K3 devices, the WDT has two selectable outputs, one resets the device directly, the other is this "NMI" which is wired to an ESM module which can take other actions (but usually it just also resets the device). For AM62L that second NMI output is not wired (no ESM module), so our only choice is to set the WDT to direct reset mode.
Quoted 7 lines
The wording is a little strange, but the "or generate NMI if available" meaning if NMI is available, then do that. Reset being the fallback when _not_ available.
Maybe this would work better:
/* If WDT is serviced outside of window, generate NMI if available, or reset device */
The problem is that the code doesn't match the comment. The code checks the "reset" flag and requests a reset if available. If doesn't check an "nmi" flag.
Quoted 7 lines
If the preference is NMI, as your comment suggests, the flag should be named "nmi" and be set if NMI is available. That would align the code and the comment. Right now both code and comment are misleading, since the presence of a reset flag (and setting it to false) suggests that a direct reset is not available, and that reset is preferred if available. A reset is the normally expected behavior for a watchdog, so the fact that this is _not_ the case for this watchdog should be made more visible.
How about:
Quoted 7 lines
/* If WWDT serviced outside of window, generate NMI or reset the device if NMI not available */
if (
wdt->data->reset)
reaction =RTIWWDRXN_RST;
else
reaction =RTIWWDRXN_NMI;
Since there is no response, I assume no one has an issue with the above comment, so will respin the series with that change.
~ Judith
Guenter Roeck
maintainerRe: [PATCH v3 2/2] watchdog: rti_wdt: Add reaction control
In reply to Judith MendezQuoted 98 lines · Judith Mendez
Hi Guenter, Andrew,
Quoted 83 lines · Guenter Roeck
Quoted 70 lines · Andrew Davis
Quoted 53 lines · Guenter Roeck
Quoted 52 lines · Judith Mendez
This allows to configure reaction between NMI and reset for WWD.
On K3 SoC's other than AM62L SoC [0], watchdog reset output is routed to the ESM module which can subsequently route the signal to safety master or SoC reset. On AM62L, the watchdog reset output is routed to the SoC HW reset block. So, add a new compatible for AM62l to add SoC data and configure reaction to reset instead of NMI.
[0] https://www.ti.com/product/AM62L
Signed-off-by Judith Mendez <[email protected]>---
drivers/watchdog/rti_wdt.c| 32 ++++++++++++++++++++++++++++----1 file changed, 28 insertions(+), 4 deletions(-)drivers/watchdog/rti_wdt.c +9
-1@@ -35,7 +35,8 @@ #define RTIWWDRXCTRL 0xa4 #define RTIWWDSIZECTRL 0xa8 -#define RTIWWDRX_NMI 0xa +#define RTIWWDRXN_RST 0x5 +#define RTIWWDRXN_NMI 0xa #define RTIWWDSIZE_50P 0x50 #define RTIWWDSIZE_25P 0x500@@ -63,22 +64,29 @@ static int heartbeat; +struct rti_wdt_data { + bool reset; +}; + /* * struct to hold data for each WDT device * @base - base io address of WD device * @freq - source clock frequency of WDT * @wdd - hold watchdog device as is in WDT core + * @data - hold configuration data */ struct rti_wdt_device { void __iomem *base; unsigned long freq; struct watchdog_device wdd; + const struct rti_wdt_data *data; }; static int rti_wdt_start(struct watchdog_device *wdd) { u32 timer_margin; struct rti_wdt_device *wdt = watchdog_get_drvdata(wdd); + u8 reaction; int ret; ret = pm_runtime_resume_and_get(wdd->parent);Quoted 9 lines
drivers/watchdog/rti_wdt.c static int rti_wdt_start(struct watchdog_device *wdd) · line 111
Quoted 6 lines
drivers/watchdog/rti_wdt.c +1
-2@@ -101,8 +109,13 @@ static int rti_wdt_start(struct watchdog_device *wdd)*/ wdd->min_hw_heartbeat_ms = 520 * wdd->timeout + MAX_HW_ERROR; - /* Generate NMI when wdt expires */ - writel_relaxed(RTIWWDRX_NMI, wdt->base + RTIWWDRXCTRL); + /* Reset device if wdt serviced outside of window or generate NMI if available */Shouldn't that be "or generate NMI if _not_ available" ?
For almost all the K3 devices, the WDT has two selectable outputs, one resets the device directly, the other is this "NMI" which is wired to an ESM module which can take other actions (but usually it just also resets the device). For AM62L that second NMI output is not wired (no ESM module), so our only choice is to set the WDT to direct reset mode.
Quoted 7 lines
The wording is a little strange, but the "or generate NMI if available" meaning if NMI is available, then do that. Reset being the fallback when _not_ available.
Maybe this would work better:
/* If WDT is serviced outside of window, generate NMI if available, or reset device */
The problem is that the code doesn't match the comment. The code checks the "reset" flag and requests a reset if available. If doesn't check an "nmi" flag.
Quoted 7 lines
If the preference is NMI, as your comment suggests, the flag should be named "nmi" and be set if NMI is available. That would align the code and the comment. Right now both code and comment are misleading, since the presence of a reset flag (and setting it to false) suggests that a direct reset is not available, and that reset is preferred if available. A reset is the normally expected behavior for a watchdog, so the fact that this is _not_ the case for this watchdog should be made more visible.
How about:
Quoted 8 lines
/* If WWDT serviced outside of window, generate NMI or reset the device if NMI not available */
if (
wdt->data->reset)
reaction =RTIWWDRXN_RST;
else
reaction =RTIWWDRXN_NMI;
As I have said before, the problem is the "reset" flag. Its name suggests that it means "reset is available". That is not what it actually means. It means "NMI is not available". So I suggested to rename it to "nmi" or maybe "no_nmi". Please educate me - why is that such a problem to name the flag to match its meaning ?
Guenter
Re: [PATCH v3 2/2] watchdog: rti_wdt: Add reaction control
Hi Guenter,
Quoted 110 lines · Guenter Roeck
Quoted 100 lines · Judith Mendez
Hi Guenter, Andrew,
Quoted 85 lines · Guenter Roeck
Quoted 72 lines · Andrew Davis
Quoted 55 lines · Guenter Roeck
Quoted 54 lines · Judith Mendez
This allows to configure reaction between NMI and reset for WWD.
On K3 SoC's other than AM62L SoC [0], watchdog reset output is routed to the ESM module which can subsequently route the signal to safety master or SoC reset. On AM62L, the watchdog reset output is routed to the SoC HW reset block. So, add a new compatible for AM62l to add SoC data and configure reaction to reset instead of NMI.
[0] https://www.ti.com/product/AM62L
Signed-off-by Judith Mendez <[email protected]>---
drivers/watchdog/rti_wdt.c| 32 ++++++++++++++++++++++++++++----1 file changed, 28 insertions(+), 4 deletions(-)drivers/watchdog/rti_wdt.c +9
-1@@ -35,7 +35,8 @@ #define RTIWWDRXCTRL 0xa4 #define RTIWWDSIZECTRL 0xa8 -#define RTIWWDRX_NMI 0xa +#define RTIWWDRXN_RST 0x5 +#define RTIWWDRXN_NMI 0xa #define RTIWWDSIZE_50P 0x50 #define RTIWWDSIZE_25P 0x500@@ -63,22 +64,29 @@ static int heartbeat; +struct rti_wdt_data { + bool reset; +}; + /* * struct to hold data for each WDT device * @base - base io address of WD device * @freq - source clock frequency of WDT * @wdd - hold watchdog device as is in WDT core + * @data - hold configuration data */ struct rti_wdt_device { void __iomem *base; unsigned long freq; struct watchdog_device wdd; + const struct rti_wdt_data *data; }; static int rti_wdt_start(struct watchdog_device *wdd) { u32 timer_margin; struct rti_wdt_device *wdt = watchdog_get_drvdata(wdd); + u8 reaction; int ret; ret = pm_runtime_resume_and_get(wdd->parent);@@ -101,8 +109,13 @@ static int rti_wdt_start(struct watchdog_device *wdd)Quoted 9 lines
Quoted 6 lines
drivers/watchdog/rti_wdt.c +1
-2*/ wdd->min_hw_heartbeat_ms = 520 * wdd->timeout + MAX_HW_ERROR; - /* Generate NMI when wdt expires */ - writel_relaxed(RTIWWDRX_NMI, wdt->base + RTIWWDRXCTRL); + /* Reset device if wdt serviced outside of window or generateNMI if available */
Shouldn't that be "or generate NMI if _not_ available" ?
For almost all the K3 devices, the WDT has two selectable outputs, one resets the device directly, the other is this "NMI" which is wired to an ESM module which can take other actions (but usually it just also resets the device). For AM62L that second NMI output is not wired (no ESM module), so our only choice is to set the WDT to direct reset mode.
Quoted 7 lines
The wording is a little strange, but the "or generate NMI if available" meaning if NMI is available, then do that. Reset being the fallback when _not_ available.
Maybe this would work better:
/* If WDT is serviced outside of window, generate NMI if available, or reset device */
The problem is that the code doesn't match the comment. The code checks the "reset" flag and requests a reset if available. If doesn't check an "nmi" flag.
Quoted 7 lines
If the preference is NMI, as your comment suggests, the flag should be named "nmi" and be set if NMI is available. That would align the code and the comment. Right now both code and comment are misleading, since the presence of a reset flag (and setting it to false) suggests that a direct reset is not available, and that reset is preferred if available. A reset is the normally expected behavior for a watchdog, so the fact that this is _not_ the case for this watchdog should be made more visible.
How about:
Quoted 8 lines
/* If WWDT serviced outside of window, generate NMI or reset the device if NMI not available */
if (
wdt->data->reset)
reaction =RTIWWDRXN_RST;
else
reaction =RTIWWDRXN_NMI;
Quoted 5 lines
As I have said before, the problem is the "reset" flag. Its name suggests that it means "reset is available". That is not what it actually means. It means "NMI is not available". So I suggested to rename it to "nmi" or maybe "
no_nmi". Please educate me - why is that such a problem to name the flag to match its meaning ?
wdt->data->reset makes more sense because it shows there is a physical line routed to the MAIN RESET HW LOGIC:
Quoted 4 lines
Quoted 4 lines
if (
wdt->data->reset)reaction = RTIWWDRXN_RST; else reaction = RTIWWDRXN_NMI;
If there is a direct reset line to MAIN RESET HW logic, then the reaction should be reset, if there is no reset line, then generate and NMI to ESM.
then the comment could be simplified to:
/* If WWDT serviced outside of window, generate reset or NMI to ESM */
to match the code better if you like.
~ Judith
Re: [PATCH v3 2/2] watchdog: rti_wdt: Add reaction control
Quoted 120 lines · Judith Mendez
Hi Guenter,
Quoted 108 lines · Guenter Roeck
Quoted 98 lines · Judith Mendez
Hi Guenter, Andrew,
Quoted 83 lines · Guenter Roeck
Quoted 70 lines · Andrew Davis
Quoted 53 lines · Guenter Roeck
Quoted 52 lines · Judith Mendez
This allows to configure reaction between NMI and reset for WWD.
On K3 SoC's other than AM62L SoC [0], watchdog reset output is routed to the ESM module which can subsequently route the signal to safety master or SoC reset. On AM62L, the watchdog reset output is routed to the SoC HW reset block. So, add a new compatible for AM62l to add SoC data and configure reaction to reset instead of NMI.
[0] https://www.ti.com/product/AM62L
Signed-off-by Judith Mendez <[email protected]>---
drivers/watchdog/rti_wdt.c| 32 ++++++++++++++++++++++++++++----1 file changed, 28 insertions(+), 4 deletions(-)drivers/watchdog/rti_wdt.c +9
-1@@ -35,7 +35,8 @@ #define RTIWWDRXCTRL 0xa4 #define RTIWWDSIZECTRL 0xa8 -#define RTIWWDRX_NMI 0xa +#define RTIWWDRXN_RST 0x5 +#define RTIWWDRXN_NMI 0xa #define RTIWWDSIZE_50P 0x50 #define RTIWWDSIZE_25P 0x500@@ -63,22 +64,29 @@ static int heartbeat; +struct rti_wdt_data { + bool reset; +}; + /* * struct to hold data for each WDT device * @base - base io address of WD device * @freq - source clock frequency of WDT * @wdd - hold watchdog device as is in WDT core + * @data - hold configuration data */ struct rti_wdt_device { void __iomem *base; unsigned long freq; struct watchdog_device wdd; + const struct rti_wdt_data *data; }; static int rti_wdt_start(struct watchdog_device *wdd) { u32 timer_margin; struct rti_wdt_device *wdt = watchdog_get_drvdata(wdd); + u8 reaction; int ret; ret = pm_runtime_resume_and_get(wdd->parent);Quoted 9 lines
drivers/watchdog/rti_wdt.c static int rti_wdt_start(struct watchdog_device *wdd) · line 111
Quoted 6 lines
drivers/watchdog/rti_wdt.c +1
-2@@ -101,8 +109,13 @@ static int rti_wdt_start(struct watchdog_device *wdd)*/ wdd->min_hw_heartbeat_ms = 520 * wdd->timeout + MAX_HW_ERROR; - /* Generate NMI when wdt expires */ - writel_relaxed(RTIWWDRX_NMI, wdt->base + RTIWWDRXCTRL); + /* Reset device if wdt serviced outside of window or generate NMI if available */Shouldn't that be "or generate NMI if _not_ available" ?
For almost all the K3 devices, the WDT has two selectable outputs, one resets the device directly, the other is this "NMI" which is wired to an ESM module which can take other actions (but usually it just also resets the device). For AM62L that second NMI output is not wired (no ESM module), so our only choice is to set the WDT to direct reset mode.
Quoted 7 lines
The wording is a little strange, but the "or generate NMI if available" meaning if NMI is available, then do that. Reset being the fallback when _not_ available.
Maybe this would work better:
/* If WDT is serviced outside of window, generate NMI if available, or reset device */
The problem is that the code doesn't match the comment. The code checks the "reset" flag and requests a reset if available. If doesn't check an "nmi" flag.
Quoted 7 lines
If the preference is NMI, as your comment suggests, the flag should be named "nmi" and be set if NMI is available. That would align the code and the comment. Right now both code and comment are misleading, since the presence of a reset flag (and setting it to false) suggests that a direct reset is not available, and that reset is preferred if available. A reset is the normally expected behavior for a watchdog, so the fact that this is _not_ the case for this watchdog should be made more visible.
How about:
Quoted 8 lines
/* If WWDT serviced outside of window, generate NMI or reset the device if NMI not available */
if (
wdt->data->reset)
reaction =RTIWWDRXN_RST;
else
reaction =RTIWWDRXN_NMI;Quoted 5 lines
As I have said before, the problem is the "reset" flag. Its name suggests that it means "reset is available". That is not what it actually means. It means "NMI is not available". So I suggested to rename it to "nmi" or maybe "
no_nmi". Please educate me - why is that such a problem to name the flag to match its meaning ?
wdt->data->resetmakes more sense because it shows there is a physical line routed to the MAIN RESET HW LOGIC:
Quoted 9 lines
Quoted 4 lines
Quoted 4 lines
if (
wdt->data->reset)
reaction =RTIWWDRXN_RST;
else
reaction =RTIWWDRXN_NMI;If there is a direct reset line to MAIN RESET HW logic, then the reaction should be reset, if there is no reset line, then generate and NMI to ESM.
There is a reset line on all K3 devices, if you did it this way then all devices would have wdt->data->reset set to true and you wouldn't need this logic at all. The thing that changes is if NMI/ESM is available or not, so as Guenter suggests the flag should be called "nmi" or similar and you switch on that.
Andrew
Quoted 10 lines
then the comment could be simplified to:
/* If WWDT serviced outside of window, generate reset or NMI to ESM */
to match the code better if you like.
~ Judith
Re: [PATCH v3 2/2] watchdog: rti_wdt: Add reaction control
Hi Andrew,
Quoted 133 lines · Andrew Davis
Quoted 122 lines · Judith Mendez
Hi Guenter,
Quoted 110 lines · Guenter Roeck
Quoted 100 lines · Judith Mendez
Hi Guenter, Andrew,
Quoted 85 lines · Guenter Roeck
Quoted 72 lines · Andrew Davis
Quoted 55 lines · Guenter Roeck
Quoted 54 lines · Judith Mendez
This allows to configure reaction between NMI and reset for WWD.
On K3 SoC's other than AM62L SoC [0], watchdog reset output is routed to the ESM module which can subsequently route the signal to safety master or SoC reset. On AM62L, the watchdog reset output is routed to the SoC HW reset block. So, add a new compatible for AM62l to add SoC data and configure reaction to reset instead of NMI.
[0] https://www.ti.com/product/AM62L
Signed-off-by Judith Mendez <[email protected]>---
drivers/watchdog/rti_wdt.c| 32 ++++++++++++++++++++++++++++----1 file changed, 28 insertions(+), 4 deletions(-)drivers/watchdog/rti_wdt.c +9
-1@@ -35,7 +35,8 @@ #define RTIWWDRXCTRL 0xa4 #define RTIWWDSIZECTRL 0xa8 -#define RTIWWDRX_NMI 0xa +#define RTIWWDRXN_RST 0x5 +#define RTIWWDRXN_NMI 0xa #define RTIWWDSIZE_50P 0x50 #define RTIWWDSIZE_25P 0x500@@ -63,22 +64,29 @@ static int heartbeat; +struct rti_wdt_data { + bool reset; +}; + /* * struct to hold data for each WDT device * @base - base io address of WD device * @freq - source clock frequency of WDT * @wdd - hold watchdog device as is in WDT core + * @data - hold configuration data */ struct rti_wdt_device { void __iomem *base; unsigned long freq; struct watchdog_device wdd; + const struct rti_wdt_data *data; }; static int rti_wdt_start(struct watchdog_device *wdd) { u32 timer_margin; struct rti_wdt_device *wdt = watchdog_get_drvdata(wdd); + u8 reaction; int ret; ret = pm_runtime_resume_and_get(wdd->parent);@@ -101,8 +109,13 @@ static int rti_wdt_start(struct watchdog_device *wdd)Quoted 9 lines
Quoted 6 lines
drivers/watchdog/rti_wdt.c +1
-2*/ wdd->min_hw_heartbeat_ms = 520 * wdd->timeout + MAX_HW_ERROR; - /* Generate NMI when wdt expires */ - writel_relaxed(RTIWWDRX_NMI, wdt->base + RTIWWDRXCTRL); + /* Reset device if wdt serviced outside of window orgenerate NMI if available */
Shouldn't that be "or generate NMI if _not_ available" ?
For almost all the K3 devices, the WDT has two selectable outputs, one resets the device directly, the other is this "NMI" which is wired to an ESM module which can take other actions (but usually it just also resets the device). For AM62L that second NMI output is not wired (no ESM module), so our only choice is to set the WDT to direct reset mode.
Quoted 7 lines
The wording is a little strange, but the "or generate NMI if available" meaning if NMI is available, then do that. Reset being the fallback when _not_ available.
Maybe this would work better:
/* If WDT is serviced outside of window, generate NMI if available, or reset device */
The problem is that the code doesn't match the comment. The code checks the "reset" flag and requests a reset if available. If doesn't check an "nmi" flag.
Quoted 7 lines
If the preference is NMI, as your comment suggests, the flag should be named "nmi" and be set if NMI is available. That would align the code and the comment. Right now both code and comment are misleading, since the presence of a reset flag (and setting it to false) suggests that a direct reset is not available, and that reset is preferred if available. A reset is the normally expected behavior for a watchdog, so the fact that this is _not_ the case for this watchdog should be made more visible.
How about:
Quoted 8 lines
/* If WWDT serviced outside of window, generate NMI or reset the device if NMI not available */
if (
wdt->data->reset)
reaction =RTIWWDRXN_RST;
else
reaction =RTIWWDRXN_NMI;Quoted 5 lines
As I have said before, the problem is the "reset" flag. Its name suggests that it means "reset is available". That is not what it actually means. It means "NMI is not available". So I suggested to rename it to "nmi" or maybe "
no_nmi". Please educate me - why is that such a problem to name the flag to match its meaning ?
wdt->data->resetmakes more sense because it shows there is a physical line routed to the MAIN RESET HW LOGIC:Quoted 9 lines
>> if (
wdt->data->reset)
>> reaction =RTIWWDRXN_RST;
>> else
>> reaction =RTIWWDRXN_NMI;If there is a direct reset line to MAIN RESET HW logic, then the reaction should be reset, if there is no reset line, then generate and NMI to ESM.
Quoted 5 lines
There is a reset line on all K3 devices, if you did it this way then all devices would have
wdt->data->resetset to true and you wouldn't need this logic at all. The thing that changes is if NMI/ESM is available or not, so as Guenter suggests the flag should be called "nmi" or similar and you switch on that.
Looking at the integration spec, I do not see a direct reset line for any device besides am62l, could you confirm that what I am reading is correct please?
~ Judith
Re: [PATCH v3 2/2] watchdog: rti_wdt: Add reaction control
Quoted 140 lines · Judith Mendez
Hi Andrew,
Quoted 131 lines · Andrew Davis
Quoted 120 lines · Judith Mendez
Hi Guenter,
Quoted 108 lines · Guenter Roeck
Quoted 98 lines · Judith Mendez
Hi Guenter, Andrew,
Quoted 83 lines · Guenter Roeck
Quoted 70 lines · Andrew Davis
Quoted 53 lines · Guenter Roeck
Quoted 52 lines · Judith Mendez
This allows to configure reaction between NMI and reset for WWD.
On K3 SoC's other than AM62L SoC [0], watchdog reset output is routed to the ESM module which can subsequently route the signal to safety master or SoC reset. On AM62L, the watchdog reset output is routed to the SoC HW reset block. So, add a new compatible for AM62l to add SoC data and configure reaction to reset instead of NMI.
[0] https://www.ti.com/product/AM62L
Signed-off-by Judith Mendez <[email protected]>---
drivers/watchdog/rti_wdt.c| 32 ++++++++++++++++++++++++++++----1 file changed, 28 insertions(+), 4 deletions(-)drivers/watchdog/rti_wdt.c +9
-1@@ -35,7 +35,8 @@ #define RTIWWDRXCTRL 0xa4 #define RTIWWDSIZECTRL 0xa8 -#define RTIWWDRX_NMI 0xa +#define RTIWWDRXN_RST 0x5 +#define RTIWWDRXN_NMI 0xa #define RTIWWDSIZE_50P 0x50 #define RTIWWDSIZE_25P 0x500@@ -63,22 +64,29 @@ static int heartbeat; +struct rti_wdt_data { + bool reset; +}; + /* * struct to hold data for each WDT device * @base - base io address of WD device * @freq - source clock frequency of WDT * @wdd - hold watchdog device as is in WDT core + * @data - hold configuration data */ struct rti_wdt_device { void __iomem *base; unsigned long freq; struct watchdog_device wdd; + const struct rti_wdt_data *data; }; static int rti_wdt_start(struct watchdog_device *wdd) { u32 timer_margin; struct rti_wdt_device *wdt = watchdog_get_drvdata(wdd); + u8 reaction; int ret; ret = pm_runtime_resume_and_get(wdd->parent);Quoted 9 lines
drivers/watchdog/rti_wdt.c static int rti_wdt_start(struct watchdog_device *wdd) · line 111
Quoted 6 lines
drivers/watchdog/rti_wdt.c +1
-2@@ -101,8 +109,13 @@ static int rti_wdt_start(struct watchdog_device *wdd)*/ wdd->min_hw_heartbeat_ms = 520 * wdd->timeout + MAX_HW_ERROR; - /* Generate NMI when wdt expires */ - writel_relaxed(RTIWWDRX_NMI, wdt->base + RTIWWDRXCTRL); + /* Reset device if wdt serviced outside of window or generate NMI if available */Shouldn't that be "or generate NMI if _not_ available" ?
For almost all the K3 devices, the WDT has two selectable outputs, one resets the device directly, the other is this "NMI" which is wired to an ESM module which can take other actions (but usually it just also resets the device). For AM62L that second NMI output is not wired (no ESM module), so our only choice is to set the WDT to direct reset mode.
Quoted 7 lines
The wording is a little strange, but the "or generate NMI if available" meaning if NMI is available, then do that. Reset being the fallback when _not_ available.
Maybe this would work better:
/* If WDT is serviced outside of window, generate NMI if available, or reset device */
The problem is that the code doesn't match the comment. The code checks the "reset" flag and requests a reset if available. If doesn't check an "nmi" flag.
Quoted 7 lines
If the preference is NMI, as your comment suggests, the flag should be named "nmi" and be set if NMI is available. That would align the code and the comment. Right now both code and comment are misleading, since the presence of a reset flag (and setting it to false) suggests that a direct reset is not available, and that reset is preferred if available. A reset is the normally expected behavior for a watchdog, so the fact that this is _not_ the case for this watchdog should be made more visible.
How about:
Quoted 8 lines
/* If WWDT serviced outside of window, generate NMI or reset the device if NMI not available */
if (
wdt->data->reset)
reaction =RTIWWDRXN_RST;
else
reaction =RTIWWDRXN_NMI;Quoted 5 lines
As I have said before, the problem is the "reset" flag. Its name suggests that it means "reset is available". That is not what it actually means. It means "NMI is not available". So I suggested to rename it to "nmi" or maybe "
no_nmi". Please educate me - why is that such a problem to name the flag to match its meaning ?
wdt->data->resetmakes more sense because it shows there is a physical line routed to the MAIN RESET HW LOGIC:Quoted 9 lines
>> if (
wdt->data->reset)
>> reaction =RTIWWDRXN_RST;
>> else
>> reaction =RTIWWDRXN_NMI;If there is a direct reset line to MAIN RESET HW logic, then the reaction should be reset, if there is no reset line, then generate and NMI to ESM.
Quoted 5 lines
There is a reset line on all K3 devices, if you did it this way then all devices would have
wdt->data->resetset to true and you wouldn't need this logic at all. The thing that changes is if NMI/ESM is available or not, so as Guenter suggests the flag should be called "nmi" or similar and you switch on that.
Quoted 4 lines
Looking at the integration spec, I do not see a direct reset line for any device besides am62l, could you confirm that what I am reading is correct please?
I'm not even finding the direct reset line for AM62L, some of these datasheets are lacking the reset routing.
Anyway, one thing I did notice in these datasheets is that the default value for the RTIWWDRXCTRL register is 0x5 (send reset). So even if these other devices do not wire the reset we are still changing the default by setting the register to 0xa (NMI), so the point would still stand. Setting the value to NMI is a change from the default and so should be codded that way: have a NMI flag, set to true for all devices that have it, leave false for AM62L.
Andrew
Re: [PATCH v3 2/2] watchdog: rti_wdt: Add reaction control
Hi all,
Quoted 144 lines · Andrew Davis
Quoted 143 lines · Judith Mendez
Hi Andrew,
Quoted 139 lines · Andrew Davis
Quoted 123 lines · Judith Mendez
Hi Guenter,
Quoted 111 lines · Guenter Roeck
Quoted 101 lines · Judith Mendez
Hi Guenter, Andrew,
Quoted 86 lines · Guenter Roeck
Quoted 73 lines · Andrew Davis
Quoted 56 lines · Guenter Roeck
Quoted 55 lines · Judith Mendez
This allows to configure reaction between NMI and reset for WWD.
On K3 SoC's other than AM62L SoC [0], watchdog reset output is routed to the ESM module which can subsequently route the signal to safety master or SoC reset. On AM62L, the watchdog reset output is routed to the SoC HW reset block. So, add a new compatible for AM62l to add SoC data and configure reaction to reset instead of NMI.
[0] https://www.ti.com/product/AM62L
Signed-off-by Judith Mendez <[email protected]>---
drivers/watchdog/rti_wdt.c| 32
++++++++++++++++++++++++++++----1 file changed, 28 insertions(+), 4 deletions(-)drivers/watchdog/rti_wdt.c +9
-1@@ -35,7 +35,8 @@ #define RTIWWDRXCTRL 0xa4 #define RTIWWDSIZECTRL 0xa8 -#define RTIWWDRX_NMI 0xa +#define RTIWWDRXN_RST 0x5 +#define RTIWWDRXN_NMI 0xa #define RTIWWDSIZE_50P 0x50 #define RTIWWDSIZE_25P 0x500@@ -63,22 +64,29 @@ static int heartbeat; +struct rti_wdt_data { + bool reset; +}; + /* * struct to hold data for each WDT device * @base - base io address of WD device * @freq - source clock frequency of WDT * @wdd - hold watchdog device as is in WDT core + * @data - hold configuration data */ struct rti_wdt_device { void __iomem *base; unsigned long freq; struct watchdog_device wdd; + const struct rti_wdt_data *data; }; static int rti_wdt_start(struct watchdog_device *wdd) { u32 timer_margin; struct rti_wdt_device *wdt = watchdog_get_drvdata(wdd); + u8 reaction; int ret; ret = pm_runtime_resume_and_get(wdd->parent);@@ -101,8 +109,13 @@ static int rti_wdt_start(struct watchdog_device *wdd)Quoted 9 lines
Quoted 6 lines
drivers/watchdog/rti_wdt.c +1
-2*/ wdd->min_hw_heartbeat_ms = 520 * wdd->timeout + MAX_HW_ERROR; - /* Generate NMI when wdt expires */ - writel_relaxed(RTIWWDRX_NMI, wdt->base + RTIWWDRXCTRL); + /* Reset device if wdt serviced outside of window orgenerate NMI if available */
Shouldn't that be "or generate NMI if _not_ available" ?
For almost all the K3 devices, the WDT has two selectable outputs, one resets the device directly, the other is this "NMI" which is wired to an ESM module which can take other actions (but usually it just also resets the device). For AM62L that second NMI output is not wired (no ESM module), so our only choice is to set the WDT to direct reset mode.
Quoted 7 lines
The wording is a little strange, but the "or generate NMI if available" meaning if NMI is available, then do that. Reset being the fallback when _not_ available.
Maybe this would work better:
/* If WDT is serviced outside of window, generate NMI if available, or reset device */
The problem is that the code doesn't match the comment. The code checks the "reset" flag and requests a reset if available. If doesn't check an "nmi" flag.
Quoted 7 lines
If the preference is NMI, as your comment suggests, the flag should be named "nmi" and be set if NMI is available. That would align the code and the comment. Right now both code and comment are misleading, since the presence of a reset flag (and setting it to false) suggests that a direct reset is not available, and that reset is preferred if available. A reset is the normally expected behavior for a watchdog, so the fact that this is _not_ the case for this watchdog should be made more visible.
How about:
Quoted 8 lines
/* If WWDT serviced outside of window, generate NMI or reset the device if NMI not available */
if (
wdt->data->reset)
reaction =RTIWWDRXN_RST;
else
reaction =RTIWWDRXN_NMI;Quoted 5 lines
As I have said before, the problem is the "reset" flag. Its name suggests that it means "reset is available". That is not what it actually means. It means "NMI is not available". So I suggested to rename it to "nmi" or maybe "
no_nmi". Please educate me - why is that such a problem to name the flag to match its meaning ?
wdt->data->resetmakes more sense because it shows there is a physical line routed to the MAIN RESET HW LOGIC:Quoted 9 lines
>> if (
wdt->data->reset)
>> reaction =RTIWWDRXN_RST;
>> else
>> reaction =RTIWWDRXN_NMI;If there is a direct reset line to MAIN RESET HW logic, then the reaction should be reset, if there is no reset line, then generate and NMI to ESM.
There is a reset line on all K3 devices, if you did it this way then all devices would have
wdt->data->resetset to true and you wouldn't need this logic at all. The thing that changes is if NMI/ESM is available or not, so as Guenter suggests the flag should be called "nmi" or similar and you switch on that.
Quoted 7 lines
Quoted 4 lines
Looking at the integration spec, I do not see a direct reset line for any device besides am62l, could you confirm that what I am reading is correct please?
I'm not even finding the direct reset line for AM62L, some of these datasheets are lacking the reset routing.
You can only find in integration spec, not any other spec or datasheet.
Quoted 8 lines
Anyway, one thing I did notice in these datasheets is that the default value for the RTIWWDRXCTRL register is
0x5(send reset). So even if these other devices do not wire the reset we are still changing the default by setting the register to0xa(NMI), so the point would still stand. Setting the value to NMI is a change from the default and so should be codded that way: have a NMI flag, set to true for all devices that have it, leave false for AM62L.
Fine, will fix with v4.
Thanks for reviewing (:
~ Judith