Skip to contentSkip to conversation

Add support to read the watchdog bootstatus from IMEM

PATCH Superseded Kathiravan Thirumoorthy 2 participants 8 messages May 13 – Jun 30

Subsystems (3)

v10 of 11 Superseded Latest is v11 →

lore
Share & tools
lore
#0 lore raw

v10 cover Add support to read the watchdog bootstatus from IMEM

In Qualcomm IPQ SoCs, if the system is rebooted due to the watchdog timeout, there is no way to identify it. Current approach of checking the EXPIRED_STATUS in WDT_STS is not working.

To achieve this, if the system is rebooted due to watchdog timeout, the information is captured in the IMEM by the bootloader (along with other reason codes as well).

This series attempts to address this by adding the support to read the IMEM and populate the information via bootstatus sysfs file.

With the CONFIG_WATCHDOG_SYSFS enabled, user can extract the information as below:

cat /sys/devices/platform/soc@0/f410000.watchdog/watchdog/watchdog0/bootstatus 32

Upto V9, this series has changes targeted for both qcom and watchdog tree. So V10 was sent with only watchdog changes and it is picked into watchdog tree[1]. For the remaining DTS patches, sending it as V10 again which needs to be picked via qcom tree.

Since the watchdog changes are not yet reflected in linux-next yet, upon merging this before the linux-next gets refreshed, below DT binding warning will be seen

arch/arm64/boot/dts/qcom/ipq5424-rdp466.dtb: watchdog@f410000:
Unevaluated properties are not allowed ('sram' was unexpected)
from schema $id:
http://devicetree.org/schemas/watchdog/qcom-wdt.yaml#

[1]
https://git.kernel.org/pub/scm/linux/kernel/git/groeck/linux-staging.git/log/?h=watchdog-next

---
Changes in v10:
- Dropped the watchdog patches which are applied to watchdog's tree
- Link to v9: https://lore.kernel.org/all/[email protected]

Changes in v9:
- Picked up the R-b tag for 1/5
- In 4/5, if fetching the boot status failed, just log the error instead
of exiting the probe
- Link to v8: https://lore.kernel.org/r/[email protected]

Changes in v8:
- Collected the tags
- Updated the commit msg with reasoning in 1/5
- Updated the comment in 4/5
- Link to v7: https://lore.kernel.org/r/[email protected]

Changes in v7:
- Collected the tags
- Added the reference link in 1/5
- Added the flag 'no-memory-wc' in 2/5
- Link to v6: https://lore.kernel.org/r/[email protected]

Changes in v6:
- Moved the IMEM compatible from qcom,imem to sram binding
- Updated the 'sram' property in watchdog binding to point to SRAM region and update the watchdog driver accordingly
- Dropped the Konrad's R-b tag in 2/5

Changes in v5:
- Rename property 'qcom,imem' to 'sram'
- Use dev_err_probe instead of dev_err
- Link to v4:
https://lore.kernel.org/linux-arm-msm/[email protected]/

Changes in v4:
- Kept only the WDIOF_CARDRESET and dropped other codes (Guenter)
- Renamed qcom_wdt_get_restart_reason() to qcom_wdt_get_bootstatus()
- Dropped the device data and describe the required information in the DT (Konrad)
- Link to v3:
https://lore.kernel.org/linux-arm-msm/[email protected]/

Changes in v3:
- Picked up the relevant tags
- Dropped the fallback compatible handling
- Split the driver changes into 2. Introduce the device data in one and extend the same in another for the use case
- Link to v2:
https://lore.kernel.org/linux-arm-msm/[email protected]/

Changes in v2:
- Dropped the RFC tag
- Reworked the driver changes to use the syscon API
- Link to v1:
https://lore.kernel.org/linux-arm-msm/[email protected]/

---
Kathiravan Thirumoorthy (3):
dt-bindings: sram: describe the IPQ5424 IMEM as mmio-sram
arm64: dts: qcom: ipq5424: Add the IMEM node
arm64: dts: qcom: ipq5424: add support to get watchdog bootstatus from IMEM

 Documentation/devicetree/bindings/sram/qcom,imem.yaml |  1 -
 Documentation/devicetree/bindings/sram/sram.yaml      |  1 +
 arch/arm64/boot/dts/qcom/ipq5424.dtsi                 | 16 ++++++++++++++++
 3 files changed, 17 insertions(+), 1 deletion(-)

---
base-commit: e98d21c170b01ddef366f023bbfcf6b31509fa83
change-id: 20250610-wdt_reset_reason-7a5afe702075

Best regards,

Signature · 1 line
Kathiravan Thirumoorthy <[email protected]>
#1 lore raw

PATCH v10 1/3 dt-bindings: sram: describe the IPQ5424 IMEM as mmio-sram

IMEM shouldn’t be treated as a syscon or simple-mfd because it’s really just on‑chip SRAM, not a block of control registers or a device with multiple hardware functions.

Describing it as generic mmio‑sram keeps the model simple and closer to what the hardware actually is.

---
 Documentation/devicetree/bindings/sram/qcom,imem.yaml | 1 -
 Documentation/devicetree/bindings/sram/sram.yaml      | 1 +
 2 files changed, 1 insertion(+), 1 deletion(-)
Documentation/devicetree/bindings/sram/qcom,imem.yaml +0 -1
index c63026904061..576e627fbc11 100644
@@ -18,7 +18,6 @@ properties:
     items:
       - enum:
           - qcom,apq8064-imem
-          - qcom,ipq5424-imem
           - qcom,msm8226-imem
           - qcom,msm8974-imem
           - qcom,msm8976-imem
Documentation/devicetree/bindings/sram/sram.yaml +1 -0
index eb695698a03e..2f594f60e1e6 100644
@@ -36,6 +36,7 @@ properties:
         - nvidia,tegra234-sysram
         - qcom,eliza-imem
         - qcom,hawi-imem
+        - qcom,ipq5424-imem
         - qcom,kaanapali-imem
         - qcom,milos-imem
         - qcom,rpm-msg-ram
Signature · 1 line
2.34.1
#2 lore raw

PATCH v10 2/3 arm64: dts: qcom: ipq5424: Add the IMEM node

In reply to Kathiravan Thirumoorthy

Add the IMEM node to the device tree to extract debugging information like system restart reason, which is populated via IMEM. Define the IMEM region to enable this functionality.

As described, overall IMEM region is 112KB but only initial 4KB is accessible by all masters in the SoC.

---
 arch/arm64/boot/dts/qcom/ipq5424.dtsi | 11 +++++++++++
 1 file changed, 11 insertions(+)
arch/arm64/boot/dts/qcom/ipq5424.dtsi +11 -0
index 876bf6a8b8ff..9b8410e32629 100644
@@ -730,6 +730,17 @@ ssphy_0: phy@7d000 {
 			status = "disabled";
 		};
 
+		sram@8600000 {
+			compatible = "qcom,ipq5424-imem", "mmio-sram";
+			reg = <0 0x08600000 0 0x1c000>;
+			ranges = <0 0 0x08600000 0x1c000>;
+
+			no-memory-wc;
+
+			#address-cells = <1>;
+			#size-cells = <1>;
+		};
+
 		usb3: usb3@8af8800 {
 			compatible = "qcom,ipq5424-dwc3", "qcom,dwc3";
 			reg = <0 0x08af8800 0 0x400>;
Signature · 1 line
2.34.1
#3 lore raw

Re: [PATCH v10 2/3] arm64: dts: qcom: ipq5424: Add the IMEM node

Thank you for your contribution! Sashiko AI review found 1 potential issue(s) to consider: - [High] The device tree node maps the full 112KB IMEM region, exposing inaccessible memory to the generic…

Thank you for your contribution! Sashiko AI review found 1 potential issue(s) to consider:
- [High] The device tree node maps the full 112KB IMEM region, exposing inaccessible memory to the generic SRAM allocator. --

commit d275aea75b5a17a008a9020c79777d0cc37ddedc
Author: Kathiravan Thirumoorthy <[email protected]>

arm64: dts: qcom: ipq5424: Add the IMEM node

This commit adds the IMEM node to the device tree for the IPQ5424 SoC to extract debugging information. It defines the IMEM region as 112KB, noting that only the first 4KB is accessible by all masters.

Quoted 3 lines
arch/arm64/boot/dts/qcom/ipq5424.dtsi +0 -0

[ ... ]

arch/arm64/boot/dts/qcom/ipq5424.dtsi ssphy_0: phy@7d000 { · line 736

Quoted 4 lines
arch/arm64/boot/dts/qcom/ipq5424.dtsi +4 -0
+		sram@8600000 {
+			compatible = "qcom,ipq5424-imem", "mmio-sram";
+			reg = <0 0x08600000 0 0x1c000>;
+			ranges = <0 0 0x08600000 0x1c000>;

Could mapping the full 112KB region cause XPU violations?

The commit message notes that only the initial 4KB is accessible by all masters in the SoC. Since this node uses the mmio-sram compatible, the generic SRAM driver will map the entire 0x1c000 region and add the unreserved portion to a gen_pool for dynamic allocation.

If a driver requests memory from this pool, could it receive an address within the restricted region and trigger an SError upon access?

Additionally, is there a risk of speculative execution or memory debugging tools accessing the restricted region and causing a kernel panic?

Should the reg and ranges sizes be limited strictly to the safely accessible 4KB (0x1000) region?

Quoted 6 lines
arch/arm64/boot/dts/qcom/ipq5424.dtsi +6 -0
+
+			no-memory-wc;
+
+			#address-cells = <1>;
+			#size-cells = <1>;
+		};
Signature · 1 line
Sashiko AI review · https://sashiko.dev/#/patchset/[email protected]?part=2
#4 lore raw

PATCH v10 3/3 arm64: dts: qcom: ipq5424: add support to get watchdog bootstatus from IMEM

In reply to Kathiravan Thirumoorthy

Add the "sram" property to the watchdog device node to enable retrieval of the system restart reason from IMEM, populated by XBL. Parse this information in the watchdog driver and update the bootstatus sysFS if the restart was triggered by a watchdog timeout.

---
 arch/arm64/boot/dts/qcom/ipq5424.dtsi | 5 +++++
 1 file changed, 5 insertions(+)
arch/arm64/boot/dts/qcom/ipq5424.dtsi +5 -0
index 9b8410e32629..33ff00990513 100644
@@ -624,6 +624,7 @@ watchdog@f410000 {
 			reg = <0 0x0f410000 0 0x1000>;
 			interrupts = <GIC_SPI 0 IRQ_TYPE_EDGE_RISING>;
 			clocks = <&sleep_clk>;
+			sram = <&restart_reason>;
 		};
 
 		qusb_phy_1: phy@71000 {
@@ -739,6 +740,10 @@ sram@8600000 {
 
 			#address-cells = <1>;
 			#size-cells = <1>;
+
+			restart_reason: restartreason-sram@7b0 {
+				reg = <0x7b0 0x4>;
+			};
 		};
 
 		usb3: usb3@8af8800 {
Signature · 1 line
2.34.1
#5 lore raw

Re: [PATCH v10 3/3] arm64: dts: qcom: ipq5424: add support to get watchdog bootstatus from IMEM

Thank you for your contribution! Sashiko AI review found 2 potential issue(s) to consider: - [Medium] Device Tree binding schema violation for the watchdog node. - [Medium] Missing watchdog driver…

Thank you for your contribution! Sashiko AI review found 2 potential issue(s) to consider:
- [Medium] Device Tree binding schema violation for the watchdog node.
- [Medium] Missing watchdog driver implementation and commit message mismatch. --

commit 552b829d163556b75c4f936455d4ccee76a98307
Author: Kathiravan Thirumoorthy <[email protected]>

arm64: dts: qcom: ipq5424: add support to get watchdog bootstatus from IMEM

This commit adds an "sram" property to the watchdog node in the IPQ5424 device tree and defines a new restart_reason node. The commit message states this allows the watchdog driver to retrieve the system restart reason from IMEM.

Quoted 2 lines

Parse this information in the watchdog driver and update the bootstatus sysFS if the restart was triggered by a watchdog timeout.

The commit message mentions parsing this information in the watchdog driver, but the patch only contains device tree changes. Should this commit also include the modifications to the watchdog driver code, or are those changes being introduced in a separate patch?

arch/arm64/boot/dts/qcom/ipq5424.dtsi watchdog@f410000 { · line 628

Quoted 10 lines
arch/arm64/boot/dts/qcom/ipq5424.dtsi +1 -0
index 9b8410e326290..33ff00990513c 100644
@@ -624,6 +624,7 @@ watchdog@f410000 {
 			reg = <0 0x0f410000 0 0x1000>;
 			interrupts = <GIC_SPI 0 IRQ_TYPE_EDGE_RISING>;
 			clocks = <&sleep_clk>;
+			sram = <&restart_reason>;
 		};

Will this new property cause device tree validation (make dtbs_check) to fail?

It looks like the "sram" property might not be documented in the corresponding device tree binding schema (qcom-wdt.yaml) yet. If the schema enforces unevaluatedProperties as false, introducing an undocumented property could trigger a validation error.

[ ... ]

Signature · 1 line
Sashiko AI review · https://sashiko.dev/#/patchset/[email protected]?part=3
#6 lore raw
In reply to Kathiravan Thirumoorthy
Quoted 32 lines · Kathiravan Thirumoorthy

In Qualcomm IPQ SoCs, if the system is rebooted due to the watchdog timeout, there is no way to identify it. Current approach of checking the EXPIRED_STATUS in WDT_STS is not working.

To achieve this, if the system is rebooted due to watchdog timeout, the information is captured in the IMEM by the bootloader (along with other reason codes as well).

This series attempts to address this by adding the support to read the IMEM and populate the information via bootstatus sysfs file.

With the CONFIG_WATCHDOG_SYSFS enabled, user can extract the information as below:

cat /sys/devices/platform/soc@0/f410000.watchdog/watchdog/watchdog0/bootstatus 32

Upto V9, this series has changes targeted for both qcom and watchdog tree. So V10 was sent with only watchdog changes and it is picked into watchdog tree[1]. For the remaining DTS patches, sending it as V10 again which needs to be picked via qcom tree.

Since the watchdog changes are not yet reflected in linux-next yet, upon merging this before the linux-next gets refreshed, below DT binding warning will be seen

arch/arm64/boot/dts/qcom/ipq5424-rdp466.dtb: watchdog@f410000:
Unevaluated properties are not allowed ('sram' was unexpected)
from schema $id:
http://devicetree.org/schemas/watchdog/qcom-wdt.yaml#

Quoted 4 lines

[1]
https://git.kernel.org/pub/scm/linux/kernel/git/groeck/linux-staging.git/log/?h=watchdog-next

Bjorn, Gentle ping... Can this be picked up for v7.2?

#7 lore raw
Quoted 35 lines · Kathiravan Thirumoorthy
Quoted 33 lines · Kathiravan Thirumoorthy

In Qualcomm IPQ SoCs, if the system is rebooted due to the watchdog timeout, there is no way to identify it. Current approach of checking the EXPIRED_STATUS in WDT_STS is not working.

To achieve this, if the system is rebooted due to watchdog timeout, the information is captured in the IMEM by the bootloader (along with other reason codes as well).

This series attempts to address this by adding the support to read the IMEM and populate the information via bootstatus sysfs file.

With the CONFIG_WATCHDOG_SYSFS enabled, user can extract the information as below:

cat /sys/devices/platform/soc@0/f410000.watchdog/watchdog/watchdog0/bootstatus

32

Upto V9, this series has changes targeted for both qcom and watchdog tree. So V10 was sent with only watchdog changes and it is picked into watchdog tree[1]. For the remaining DTS patches, sending it as V10 again which needs to be picked via qcom tree.

Since the watchdog changes are not yet reflected in linux-next yet, upon merging this before the linux-next gets refreshed, below DT binding warning will be seen

arch/arm64/boot/dts/qcom/ipq5424-rdp466.dtb: watchdog@f410000:
Unevaluated properties are not allowed ('sram' was unexpected) from schema $id:
http://devicetree.org/schemas/watchdog/qcom-wdt.yaml#

Quoted 8 lines
Quoted 5 lines

[1]
https://git.kernel.org/pub/scm/linux/kernel/git/groeck/linux-staging.git/log/?h=watchdog-next

Bjorn, Gentle ping... Can this be picked up for v7.2?

Bjorn, Gentle ping... (This series cleanly applies on the tag next-20260629.)