* [PATCH v6 1/3] dt-bindings: watchdog: ti,rti-wdt: Add support for WDIOF_CARDRESET
2023-07-18 2:10 [PATCH v6 0/3] Add support for WDIOF_CARDRESET on TI AM65x huaqian.li
@ 2023-07-18 2:10 ` huaqian.li
2023-07-19 7:46 ` Krzysztof Kozlowski
2023-07-19 13:39 ` Guenter Roeck
2023-07-18 2:10 ` [DONOTMERGE PATCH v6 2/3] arm64: dts: ti: Add reserved memory for watchdog huaqian.li
2023-07-18 2:10 ` [PATCH v6 3/3] watchdog:rit_wdt: Add support for WDIOF_CARDRESET huaqian.li
2 siblings, 2 replies; 7+ messages in thread
From: huaqian.li @ 2023-07-18 2:10 UTC (permalink / raw)
To: wim, linux, robh+dt, krzysztof.kozlowski+dt, conor+dt
Cc: huaqianlee, nm, vigneshr, kristo, linux-watchdog, devicetree,
linux-kernel, linux-arm-kernel, jan.kiszka, baocheng.su,
Li Hua Qian
From: Li Hua Qian <huaqian.li@siemens.com>
TI RTI (Real Time Interrupt) Watchdog doesn't support to record the
watchdog cause. Add a reserved memory to know the last reboot was caused
by the watchdog card. In the reserved memory, some specific info will be
saved to indicate whether the watchdog reset was triggered in last
boot.
Signed-off-by: Li Hua Qian <huaqian.li@siemens.com>
---
.../bindings/watchdog/ti,rti-wdt.yaml | 28 ++++++++++++++++++-
1 file changed, 27 insertions(+), 1 deletion(-)
diff --git a/Documentation/devicetree/bindings/watchdog/ti,rti-wdt.yaml b/Documentation/devicetree/bindings/watchdog/ti,rti-wdt.yaml
index fc553211e42d..9d847e4b7278 100644
--- a/Documentation/devicetree/bindings/watchdog/ti,rti-wdt.yaml
+++ b/Documentation/devicetree/bindings/watchdog/ti,rti-wdt.yaml
@@ -34,6 +34,20 @@ properties:
power-domains:
maxItems: 1
+ memory-region:
+ maxItems: 1
+ description:
+ Contains the watchdog reserved memory. It is optional.
+ In the reserved memory, the specified values, which are
+ PON_REASON_SOF_NUM(0xBBBBCCCC), PON_REASON_MAGIC_NUM(0xDDDDDDDD),
+ and PON_REASON_EOF_NUM(0xCCCCBBBB), are pre-stored at the first
+ 3 * 4 bytes to tell that last boot was caused by watchdog reset.
+ Once the PON reason is captured by driver(rti_wdt.c), the driver
+ is supposed to wipe the whole memory region. Surely, if this
+ property is set, at least 12 bytes reserved memory starting from
+ specific memory address(0xa220000) should be set. More please
+ refer to example.
+
required:
- compatible
- reg
@@ -47,7 +61,18 @@ examples:
/*
* RTI WDT in main domain on J721e SoC. Assigned clocks are used to
* select the source clock for the watchdog, forcing it to tick with
- * a 32kHz clock in this case.
+ * a 32kHz clock in this case. Add a reserved memory(optional) to keep
+ * the watchdog reset cause persistent, which was be written in 12 bytes
+ * starting from 0xa2200000 by RTI Watchdog Firmware, then make it
+ * possible to get watchdog reset cause in driver.
+ *
+ * Reserved memory should be defined as follows:
+ * reserved-memory {
+ * wdt_reset_memory_region: wdt-memory@a2200000 {
+ * reg = <0x00 0xa2200000 0x00 0x1000>;
+ * no-map;
+ * };
+ * }
*/
#include <dt-bindings/soc/ti,sci_pm_domain.h>
@@ -58,4 +83,5 @@ examples:
power-domains = <&k3_pds 252 TI_SCI_PD_EXCLUSIVE>;
assigned-clocks = <&k3_clks 252 1>;
assigned-clock-parents = <&k3_clks 252 5>;
+ memory-region = <&wdt_reset_memory_region>;
};
--
2.34.1
^ permalink raw reply related [flat|nested] 7+ messages in thread* Re: [PATCH v6 1/3] dt-bindings: watchdog: ti,rti-wdt: Add support for WDIOF_CARDRESET
2023-07-18 2:10 ` [PATCH v6 1/3] dt-bindings: watchdog: ti,rti-wdt: Add support for WDIOF_CARDRESET huaqian.li
@ 2023-07-19 7:46 ` Krzysztof Kozlowski
2023-07-19 13:39 ` Guenter Roeck
1 sibling, 0 replies; 7+ messages in thread
From: Krzysztof Kozlowski @ 2023-07-19 7:46 UTC (permalink / raw)
To: huaqian.li, wim, linux, robh+dt, krzysztof.kozlowski+dt, conor+dt
Cc: huaqianlee, nm, vigneshr, kristo, linux-watchdog, devicetree,
linux-kernel, linux-arm-kernel, jan.kiszka, baocheng.su
On 18/07/2023 04:10, huaqian.li@siemens.com wrote:
> From: Li Hua Qian <huaqian.li@siemens.com>
>
> TI RTI (Real Time Interrupt) Watchdog doesn't support to record the
> watchdog cause. Add a reserved memory to know the last reboot was caused
> by the watchdog card. In the reserved memory, some specific info will be
> saved to indicate whether the watchdog reset was triggered in last
> boot.
>
> Signed-off-by: Li Hua Qian <huaqian.li@siemens.com>
> ---
Reviewed-by: Krzysztof Kozlowski <krzysztof.kozlowski@linaro.org>
---
This is an automated instruction, just in case, because many review tags
are being ignored. If you do not know the process, here is a short
explanation:
Please add Acked-by/Reviewed-by/Tested-by tags you received, when
posting new versions, under or above your Signed-off-by tag. Tools like
b4 can help here. However, there's no need to repost patches *only* to
add the tags. The upstream maintainer will do that for acks received on
the version they apply.
https://elixir.bootlin.com/linux/v5.17/source/Documentation/process/submitting-patches.rst#L540
Best regards,
Krzysztof
^ permalink raw reply [flat|nested] 7+ messages in thread
* Re: [PATCH v6 1/3] dt-bindings: watchdog: ti,rti-wdt: Add support for WDIOF_CARDRESET
2023-07-18 2:10 ` [PATCH v6 1/3] dt-bindings: watchdog: ti,rti-wdt: Add support for WDIOF_CARDRESET huaqian.li
2023-07-19 7:46 ` Krzysztof Kozlowski
@ 2023-07-19 13:39 ` Guenter Roeck
1 sibling, 0 replies; 7+ messages in thread
From: Guenter Roeck @ 2023-07-19 13:39 UTC (permalink / raw)
To: huaqian.li, wim, robh+dt, krzysztof.kozlowski+dt, conor+dt
Cc: huaqianlee, nm, vigneshr, kristo, linux-watchdog, devicetree,
linux-kernel, linux-arm-kernel, jan.kiszka, baocheng.su
On 7/17/23 19:10, huaqian.li@siemens.com wrote:
> From: Li Hua Qian <huaqian.li@siemens.com>
>
> TI RTI (Real Time Interrupt) Watchdog doesn't support to record the
> watchdog cause. Add a reserved memory to know the last reboot was caused
> by the watchdog card. In the reserved memory, some specific info will be
> saved to indicate whether the watchdog reset was triggered in last
> boot.
>
> Signed-off-by: Li Hua Qian <huaqian.li@siemens.com>
Reviewed-by: Guenter Roeck <linux@roeck-us.net>
> ---
> .../bindings/watchdog/ti,rti-wdt.yaml | 28 ++++++++++++++++++-
> 1 file changed, 27 insertions(+), 1 deletion(-)
>
> diff --git a/Documentation/devicetree/bindings/watchdog/ti,rti-wdt.yaml b/Documentation/devicetree/bindings/watchdog/ti,rti-wdt.yaml
> index fc553211e42d..9d847e4b7278 100644
> --- a/Documentation/devicetree/bindings/watchdog/ti,rti-wdt.yaml
> +++ b/Documentation/devicetree/bindings/watchdog/ti,rti-wdt.yaml
> @@ -34,6 +34,20 @@ properties:
> power-domains:
> maxItems: 1
>
> + memory-region:
> + maxItems: 1
> + description:
> + Contains the watchdog reserved memory. It is optional.
> + In the reserved memory, the specified values, which are
> + PON_REASON_SOF_NUM(0xBBBBCCCC), PON_REASON_MAGIC_NUM(0xDDDDDDDD),
> + and PON_REASON_EOF_NUM(0xCCCCBBBB), are pre-stored at the first
> + 3 * 4 bytes to tell that last boot was caused by watchdog reset.
> + Once the PON reason is captured by driver(rti_wdt.c), the driver
> + is supposed to wipe the whole memory region. Surely, if this
> + property is set, at least 12 bytes reserved memory starting from
> + specific memory address(0xa220000) should be set. More please
> + refer to example.
> +
> required:
> - compatible
> - reg
> @@ -47,7 +61,18 @@ examples:
> /*
> * RTI WDT in main domain on J721e SoC. Assigned clocks are used to
> * select the source clock for the watchdog, forcing it to tick with
> - * a 32kHz clock in this case.
> + * a 32kHz clock in this case. Add a reserved memory(optional) to keep
> + * the watchdog reset cause persistent, which was be written in 12 bytes
> + * starting from 0xa2200000 by RTI Watchdog Firmware, then make it
> + * possible to get watchdog reset cause in driver.
> + *
> + * Reserved memory should be defined as follows:
> + * reserved-memory {
> + * wdt_reset_memory_region: wdt-memory@a2200000 {
> + * reg = <0x00 0xa2200000 0x00 0x1000>;
> + * no-map;
> + * };
> + * }
> */
> #include <dt-bindings/soc/ti,sci_pm_domain.h>
>
> @@ -58,4 +83,5 @@ examples:
> power-domains = <&k3_pds 252 TI_SCI_PD_EXCLUSIVE>;
> assigned-clocks = <&k3_clks 252 1>;
> assigned-clock-parents = <&k3_clks 252 5>;
> + memory-region = <&wdt_reset_memory_region>;
> };
^ permalink raw reply [flat|nested] 7+ messages in thread
* [DONOTMERGE PATCH v6 2/3] arm64: dts: ti: Add reserved memory for watchdog
2023-07-18 2:10 [PATCH v6 0/3] Add support for WDIOF_CARDRESET on TI AM65x huaqian.li
2023-07-18 2:10 ` [PATCH v6 1/3] dt-bindings: watchdog: ti,rti-wdt: Add support for WDIOF_CARDRESET huaqian.li
@ 2023-07-18 2:10 ` huaqian.li
2023-07-18 2:10 ` [PATCH v6 3/3] watchdog:rit_wdt: Add support for WDIOF_CARDRESET huaqian.li
2 siblings, 0 replies; 7+ messages in thread
From: huaqian.li @ 2023-07-18 2:10 UTC (permalink / raw)
To: wim, linux, robh+dt, krzysztof.kozlowski+dt, conor+dt
Cc: huaqianlee, nm, vigneshr, kristo, linux-watchdog, devicetree,
linux-kernel, linux-arm-kernel, jan.kiszka, baocheng.su,
Li Hua Qian
From: Li Hua Qian <huaqian.li@siemens.com>
This patch adds a reserved memory for the TI AM65X platform watchdog to
reserve the specific info, triggering the watchdog reset in last boot,
to know if the board reboot is due to a watchdog reset.
Signed-off-by: Li Hua Qian <huaqian.li@siemens.com>
---
arch/arm64/boot/dts/ti/k3-am65-iot2050-common.dtsi | 10 ++++++++++
1 file changed, 10 insertions(+)
diff --git a/arch/arm64/boot/dts/ti/k3-am65-iot2050-common.dtsi b/arch/arm64/boot/dts/ti/k3-am65-iot2050-common.dtsi
index e26bd988e522..4bb20d493651 100644
--- a/arch/arm64/boot/dts/ti/k3-am65-iot2050-common.dtsi
+++ b/arch/arm64/boot/dts/ti/k3-am65-iot2050-common.dtsi
@@ -63,6 +63,12 @@ rtos_ipc_memory_region: ipc-memories@a2000000 {
alignment = <0x1000>;
no-map;
};
+
+ /* To reserve the power-on(PON) reason for watchdog reset */
+ wdt_reset_memory_region: wdt-memory@a2200000 {
+ reg = <0x00 0xa2200000 0x00 0x1000>;
+ no-map;
+ };
};
leds {
@@ -718,3 +724,7 @@ &mcu_r5fss0_core1 {
<&mcu_r5fss0_core1_memory_region>;
mboxes = <&mailbox0_cluster1>, <&mbox_mcu_r5fss0_core1>;
};
+
+&mcu_rti1 {
+ memory-region = <&wdt_reset_memory_region>;
+};
--
2.34.1
^ permalink raw reply related [flat|nested] 7+ messages in thread* [PATCH v6 3/3] watchdog:rit_wdt: Add support for WDIOF_CARDRESET
2023-07-18 2:10 [PATCH v6 0/3] Add support for WDIOF_CARDRESET on TI AM65x huaqian.li
2023-07-18 2:10 ` [PATCH v6 1/3] dt-bindings: watchdog: ti,rti-wdt: Add support for WDIOF_CARDRESET huaqian.li
2023-07-18 2:10 ` [DONOTMERGE PATCH v6 2/3] arm64: dts: ti: Add reserved memory for watchdog huaqian.li
@ 2023-07-18 2:10 ` huaqian.li
2023-07-19 13:38 ` Guenter Roeck
2 siblings, 1 reply; 7+ messages in thread
From: huaqian.li @ 2023-07-18 2:10 UTC (permalink / raw)
To: wim, linux, robh+dt, krzysztof.kozlowski+dt, conor+dt
Cc: huaqianlee, nm, vigneshr, kristo, linux-watchdog, devicetree,
linux-kernel, linux-arm-kernel, jan.kiszka, baocheng.su,
Li Hua Qian
From: Li Hua Qian <huaqian.li@siemens.com>
This patch adds the WDIOF_CARDRESET support for the platform watchdog
whose hardware does not support this feature, to know if the board
reboot is due to a watchdog reset.
This is done via reserved memory(RAM), which indicates if specific
info saved, triggering the watchdog reset in last boot.
Signed-off-by: Li Hua Qian <huaqian.li@siemens.com>
---
drivers/watchdog/rti_wdt.c | 48 ++++++++++++++++++++++++++++++++++++++
1 file changed, 48 insertions(+)
diff --git a/drivers/watchdog/rti_wdt.c b/drivers/watchdog/rti_wdt.c
index ce8f18e93aa9..901109d979f0 100644
--- a/drivers/watchdog/rti_wdt.c
+++ b/drivers/watchdog/rti_wdt.c
@@ -14,6 +14,8 @@
#include <linux/mod_devicetable.h>
#include <linux/module.h>
#include <linux/moduleparam.h>
+#include <linux/of.h>
+#include <linux/of_address.h>
#include <linux/platform_device.h>
#include <linux/pm_runtime.h>
#include <linux/types.h>
@@ -52,6 +54,11 @@
#define DWDST BIT(1)
+#define PON_REASON_SOF_NUM 0xBBBBCCCC
+#define PON_REASON_MAGIC_NUM 0xDDDDDDDD
+#define PON_REASON_EOF_NUM 0xCCCCBBBB
+#define RESERVED_MEM_MIN_SIZE 12
+
static int heartbeat = DEFAULT_HEARTBEAT;
/*
@@ -198,6 +205,11 @@ static int rti_wdt_probe(struct platform_device *pdev)
struct rti_wdt_device *wdt;
struct clk *clk;
u32 last_ping = 0;
+ struct device_node *node;
+ u32 reserved_mem_size;
+ struct resource res;
+ u32 *vaddr;
+ u64 paddr;
wdt = devm_kzalloc(dev, sizeof(*wdt), GFP_KERNEL);
if (!wdt)
@@ -284,6 +296,42 @@ static int rti_wdt_probe(struct platform_device *pdev)
}
}
+ node = of_parse_phandle(pdev->dev.of_node, "memory-region", 0);
+ if (node) {
+ ret = of_address_to_resource(node, 0, &res);
+ if (ret) {
+ dev_err(dev, "No memory address assigned to the region.\n");
+ goto err_iomap;
+ }
+
+ /*
+ * If reserved memory is defined for watchdog reset cause.
+ * Readout the Power-on(PON) reason and pass to bootstatus.
+ */
+ paddr = res.start;
+ reserved_mem_size = resource_size(&res);
+ if (reserved_mem_size < RESERVED_MEM_MIN_SIZE) {
+ dev_err(dev, "The size of reserved memory is too small.\n");
+ ret = -EINVAL;
+ goto err_iomap;
+ }
+
+ vaddr = memremap(paddr, reserved_mem_size, MEMREMAP_WB);
+ if (vaddr == NULL) {
+ dev_err(dev, "Failed to map memory-region.\n");
+ ret = -ENOMEM;
+ goto err_iomap;
+ }
+
+ if (vaddr[0] == PON_REASON_SOF_NUM &&
+ vaddr[1] == PON_REASON_MAGIC_NUM &&
+ vaddr[2] == PON_REASON_EOF_NUM) {
+ wdd->bootstatus |= WDIOF_CARDRESET;
+ }
+ memset(vaddr, 0, reserved_mem_size);
+ memunmap(vaddr);
+ }
+
watchdog_init_timeout(wdd, heartbeat, dev);
ret = watchdog_register_device(wdd);
--
2.34.1
^ permalink raw reply related [flat|nested] 7+ messages in thread* Re: [PATCH v6 3/3] watchdog:rit_wdt: Add support for WDIOF_CARDRESET
2023-07-18 2:10 ` [PATCH v6 3/3] watchdog:rit_wdt: Add support for WDIOF_CARDRESET huaqian.li
@ 2023-07-19 13:38 ` Guenter Roeck
0 siblings, 0 replies; 7+ messages in thread
From: Guenter Roeck @ 2023-07-19 13:38 UTC (permalink / raw)
To: huaqian.li, wim, robh+dt, krzysztof.kozlowski+dt, conor+dt
Cc: huaqianlee, nm, vigneshr, kristo, linux-watchdog, devicetree,
linux-kernel, linux-arm-kernel, jan.kiszka, baocheng.su
On 7/17/23 19:10, huaqian.li@siemens.com wrote:
> From: Li Hua Qian <huaqian.li@siemens.com>
>
> This patch adds the WDIOF_CARDRESET support for the platform watchdog
> whose hardware does not support this feature, to know if the board
> reboot is due to a watchdog reset.
>
> This is done via reserved memory(RAM), which indicates if specific
> info saved, triggering the watchdog reset in last boot.
>
> Signed-off-by: Li Hua Qian <huaqian.li@siemens.com>
Reviewed-by: Guenter Roeck <linux@roeck-us.net>
> ---
> drivers/watchdog/rti_wdt.c | 48 ++++++++++++++++++++++++++++++++++++++
> 1 file changed, 48 insertions(+)
>
> diff --git a/drivers/watchdog/rti_wdt.c b/drivers/watchdog/rti_wdt.c
> index ce8f18e93aa9..901109d979f0 100644
> --- a/drivers/watchdog/rti_wdt.c
> +++ b/drivers/watchdog/rti_wdt.c
> @@ -14,6 +14,8 @@
> #include <linux/mod_devicetable.h>
> #include <linux/module.h>
> #include <linux/moduleparam.h>
> +#include <linux/of.h>
> +#include <linux/of_address.h>
> #include <linux/platform_device.h>
> #include <linux/pm_runtime.h>
> #include <linux/types.h>
> @@ -52,6 +54,11 @@
>
> #define DWDST BIT(1)
>
> +#define PON_REASON_SOF_NUM 0xBBBBCCCC
> +#define PON_REASON_MAGIC_NUM 0xDDDDDDDD
> +#define PON_REASON_EOF_NUM 0xCCCCBBBB
> +#define RESERVED_MEM_MIN_SIZE 12
> +
> static int heartbeat = DEFAULT_HEARTBEAT;
>
> /*
> @@ -198,6 +205,11 @@ static int rti_wdt_probe(struct platform_device *pdev)
> struct rti_wdt_device *wdt;
> struct clk *clk;
> u32 last_ping = 0;
> + struct device_node *node;
> + u32 reserved_mem_size;
> + struct resource res;
> + u32 *vaddr;
> + u64 paddr;
>
> wdt = devm_kzalloc(dev, sizeof(*wdt), GFP_KERNEL);
> if (!wdt)
> @@ -284,6 +296,42 @@ static int rti_wdt_probe(struct platform_device *pdev)
> }
> }
>
> + node = of_parse_phandle(pdev->dev.of_node, "memory-region", 0);
> + if (node) {
> + ret = of_address_to_resource(node, 0, &res);
> + if (ret) {
> + dev_err(dev, "No memory address assigned to the region.\n");
> + goto err_iomap;
> + }
> +
> + /*
> + * If reserved memory is defined for watchdog reset cause.
> + * Readout the Power-on(PON) reason and pass to bootstatus.
> + */
> + paddr = res.start;
> + reserved_mem_size = resource_size(&res);
> + if (reserved_mem_size < RESERVED_MEM_MIN_SIZE) {
> + dev_err(dev, "The size of reserved memory is too small.\n");
> + ret = -EINVAL;
> + goto err_iomap;
> + }
> +
> + vaddr = memremap(paddr, reserved_mem_size, MEMREMAP_WB);
> + if (vaddr == NULL) {
> + dev_err(dev, "Failed to map memory-region.\n");
> + ret = -ENOMEM;
> + goto err_iomap;
> + }
> +
> + if (vaddr[0] == PON_REASON_SOF_NUM &&
> + vaddr[1] == PON_REASON_MAGIC_NUM &&
> + vaddr[2] == PON_REASON_EOF_NUM) {
> + wdd->bootstatus |= WDIOF_CARDRESET;
> + }
> + memset(vaddr, 0, reserved_mem_size);
> + memunmap(vaddr);
> + }
> +
> watchdog_init_timeout(wdd, heartbeat, dev);
>
> ret = watchdog_register_device(wdd);
^ permalink raw reply [flat|nested] 7+ messages in thread