Re: [PATCH v3 4/4] watchdog: qcom: add support to read the restart reason from IMEM

From: Kathiravan Thirumoorthy
Date: Fri May 16 2025 - 08:52:51 EST



On 5/16/2025 4:48 PM, Konrad Dybcio wrote:
On 5/14/25 3:15 PM, Kathiravan Thirumoorthy wrote:
On 5/6/2025 4:31 PM, Kathiravan Thirumoorthy wrote:
On 5/3/2025 3:53 AM, Konrad Dybcio wrote:
On 5/2/25 6:28 PM, Kathiravan Thirumoorthy wrote:
On 5/2/2025 7:33 PM, Konrad Dybcio wrote:
+static int qcom_wdt_get_restart_reason(struct qcom_wdt *wdt,
+                    const struct qcom_wdt_match_data *data)
+{
+    struct regmap *imem;
+    unsigned int val;
+    int ret;
+
+    imem = syscon_regmap_lookup_by_compatible(data->imem_compatible);
Try syscon_regmap_lookup_by_phandle_args() and pass a phandle, see e.g.
drivers/phy/qualcomm/phy-qcom-qmp-pcie.c & phy@1bfc000 in x1e80100.dtsi

That way all platform specifics will live in the DT, requiring no
hardcode-y driver changes on similar platforms
Thanks. I thought about this API but it didn't strike that I can use the args to fetch and match the value.

I need a suggestion here. There is a plan to extend this feature to other IPQ targets and also support WDIOF_POWERUNDER and WDIOF_OVERHEAT cause as well. For IPQ5424, all 3 cause will support and for other IPQ platforms, we are exploring how to integrate WDIOF_OVERHEAT. In any case, can I define the DT entry like below

         imem,phandle = <&imem 0x7b0 <Non secure WDT value> <Power Under value> <Overheat value>>;

and store these in values args[1], args[2] and args[3] respectively and use it for manipulation? If any of the platform doesn't support all 3, I can update the bindings and define the number of args as required.
Let's call the property qcom,restart-reason and only pass the register value

Because we may have any number of crazy combinations of various restart
reasons, we can go two paths:

1. promise really really really hard we won't be too crazy with the number
    of possible values and put them in the driver
2. go all out on DT properties (such as `bootstatus-overheat`,
`bootstatus-fanfault` etc.

Thanks Konrad for the suggestions and the offline discussions.

@Guenter, I need a suggestion here. Currently as part of this series, we are planning to expose WDIOF_CARDRESET, WDIOF_POWERUNDER, WDIOF_OVERHEAT reasons.

Once this is done, we do have the custom reason codes like Kernel Panic, Secure Watchdog Bite, Bus error timeout, Bus error access and few many. Is it okay to expose these values also via the bootstatus sysFS by extending the current list of reasons? Since these are outside the scope of watchdog, need your thoughts on this.

Konrad / Guenter,

We had a further discussion on this internally. Outcome is, it wouldn't be ideal to hook the custom restart reason codes in watchdog framework, since there is no involvement of watchdog in such cases. Also I don't find any references to hook the custom values in watchdog's bootstatus.

If this is fine, I'm planning to resend the series to handle only the non secure watchdog timeout case. In that case, as suggested by Konrad, everything will be handled in DT like below to avoid the device data.

imem,phandle = <&phandle <imem_offset> <value>>;
the part before the comma is a vendor prefix, so that must be qcom,xyz


Sure, will name it as qcom,imem-phandle. Hope this name is fine.



what are your plans for the other reboot reasons? are we scrapping them?


No, we are not scrapping it. We are exploring further on where to put this. May be we can put those logic in some simple driver named as ipq-restart-reason.c under drivers/soc/qcom/?



Konrad