Re: [PATCH RFC 5/6] watchdog: qcom-wdt: add support to read the restart reason from IMEM

From: Kathiravan Thirumoorthy
Date: Fri Apr 11 2025 - 01:34:50 EST



On 4/9/2025 12:33 PM, Krzysztof Kozlowski wrote:
+static int qcom_wdt_get_restart_reason(struct qcom_wdt *wdt)
+{
+ struct device_node *np;
+ struct resource imem;
+ void __iomem *base;
+ int ret;
+
+ np = of_find_compatible_node(NULL, NULL, "qcom,restart-reason-info");
+ if (!np)
That's not how you express dependencies between devices.


As I mentioned in the bindings patch, I leveraged this from the qcom_pil_info.c[1]. I shall use the syscon_regmap_lookup_by_compatible() function.



+ return -ENOENT;
+
+ ret = of_address_to_resource(np, 0, &imem);
+ of_node_put(np);
+ if (ret < 0) {
+ dev_err(wdt->wdd.parent, "can't translate OF node address\n");
+ return ret;
+ }
+
+ base = ioremap(imem.start, resource_size(&imem));
+ if (!base) {
+ dev_err(wdt->wdd.parent, "failed to map restart reason info region\n");
+ return -ENOMEM;
+ }
+
+ memcpy_fromio(&ret, base, sizeof(ret));
+ iounmap(base);
All this is wrong usage of syscon API, missing devlinks, messing up with
other device's address space.

I shall use regmap_read() instead of memcpy_fromio().