From: Guenter Roeck <linux@roeck-us.net>
To: Kathiravan Thirumoorthy
<kathiravan.thirumoorthy@oss.qualcomm.com>,
Rob Herring <robh@kernel.org>,
Krzysztof Kozlowski <krzk+dt@kernel.org>,
Conor Dooley <conor+dt@kernel.org>,
Bjorn Andersson <andersson@kernel.org>,
Konrad Dybcio <konradybcio@kernel.org>,
Wim Van Sebroeck <wim@linux-watchdog.org>
Cc: linux-arm-msm@vger.kernel.org, devicetree@vger.kernel.org,
linux-kernel@vger.kernel.org, linux-watchdog@vger.kernel.org
Subject: Re: [PATCH RFC 5/6] watchdog: qcom-wdt: add support to read the restart reason from IMEM
Date: Tue, 8 Apr 2025 05:33:12 -0700 [thread overview]
Message-ID: <e02e7431-2e30-4e65-b04b-15fbb0bcd8d0@roeck-us.net> (raw)
In-Reply-To: <20250408-wdt_reset_reason-v1-5-e6ec30c2c926@oss.qualcomm.com>
On 4/8/25 01:49, Kathiravan Thirumoorthy wrote:
> When the system boots up after a watchdog reset, the EXPIRED_STATUS bit
> in the WDT_STS register is cleared. To identify if the system was restarted
> due to WDT expiry, bootloaders update the information in the IMEM region.
> Update the driver to read the restart reason from IMEM and populate the
> bootstatus accordingly.
>
> For backward compatibility, keep the EXPIRED_STATUS bit check. Add a new
> function qcom_wdt_get_restart_reason() to read the restart reason from
> IMEM.
>
> Signed-off-by: Kathiravan Thirumoorthy <kathiravan.thirumoorthy@oss.qualcomm.com>
> ---
> drivers/watchdog/qcom-wdt.c | 40 +++++++++++++++++++++++++++++++++++++++-
> 1 file changed, 39 insertions(+), 1 deletion(-)
>
> diff --git a/drivers/watchdog/qcom-wdt.c b/drivers/watchdog/qcom-wdt.c
> index 006f9c61aa64fd2b4ee9db493aeb54c8fafac818..54d6eaa132ab9f63e1312a69ad51b7a14f78fe2d 100644
> --- a/drivers/watchdog/qcom-wdt.c
> +++ b/drivers/watchdog/qcom-wdt.c
> @@ -9,6 +9,7 @@
> #include <linux/kernel.h>
> #include <linux/module.h>
> #include <linux/of.h>
> +#include <linux/of_address.h>
> #include <linux/platform_device.h>
> #include <linux/watchdog.h>
>
> @@ -22,6 +23,8 @@ enum wdt_reg {
>
> #define QCOM_WDT_ENABLE BIT(0)
>
> +#define NON_SECURE_WDT_RESET 0x5
> +
> static const u32 reg_offset_data_apcs_tmr[] = {
> [WDT_RST] = 0x38,
> [WDT_EN] = 0x40,
> @@ -187,6 +190,39 @@ static const struct qcom_wdt_match_data match_data_kpss = {
> .max_tick_count = 0xFFFFFU,
> };
>
> +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)
> + 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);
> +
> + if (ret == NON_SECURE_WDT_RESET)
> + wdt->wdd.bootstatus = WDIOF_CARDRESET;
> +
> + return 0;
> +}
> +
> static int qcom_wdt_probe(struct platform_device *pdev)
> {
> struct device *dev = &pdev->dev;
> @@ -267,7 +303,9 @@ static int qcom_wdt_probe(struct platform_device *pdev)
> wdt->wdd.parent = dev;
> wdt->layout = data->offset;
>
> - if (readl(wdt_addr(wdt, WDT_STS)) & 1)
> + ret = qcom_wdt_get_restart_reason(wdt);
> + if (ret == -ENOENT &&
> + readl(wdt_addr(wdt, WDT_STS)) & 1)
> wdt->wdd.bootstatus = WDIOF_CARDRESET;
This ignores all other error returns from qcom_wdt_get_restart_reason(),
but in that function it generates several dev_err(). Either make those
messages less than an error, or treat them as error and drop out here.
Thanks,
Guenter
next prev parent reply other threads:[~2025-04-08 12:33 UTC|newest]
Thread overview: 22+ messages / expand[flat|nested] mbox.gz Atom feed top
2025-04-08 8:49 [PATCH RFC 0/6] Add support to read the restart reason from IMEM Kathiravan Thirumoorthy
2025-04-08 8:49 ` [PATCH RFC 1/6] dt-bindings: sram: qcom,imem: Document IPQ5424 compatible Kathiravan Thirumoorthy
2025-04-09 6:58 ` Krzysztof Kozlowski
2025-04-11 4:57 ` Kathiravan Thirumoorthy
2025-04-08 8:49 ` [PATCH RFC 2/6] arm64: dts: qcom: ipq5424: Add the IMEM node Kathiravan Thirumoorthy
2025-04-09 18:41 ` Konrad Dybcio
2025-04-11 5:01 ` Kathiravan Thirumoorthy
2025-04-11 9:03 ` Konrad Dybcio
2025-04-11 9:17 ` Kathiravan Thirumoorthy
2025-04-08 8:49 ` [PATCH RFC 3/6] dt-bindings: watchdog: Add Qualcomm restart reason binding Kathiravan Thirumoorthy
2025-04-08 11:41 ` Rob Herring (Arm)
2025-04-09 7:00 ` Krzysztof Kozlowski
2025-04-11 5:25 ` Kathiravan Thirumoorthy
2025-04-08 8:49 ` [PATCH RFC 4/6] dt-bindings: sram: qcom,imem: add the support for restart reason Kathiravan Thirumoorthy
2025-04-09 7:02 ` Krzysztof Kozlowski
2025-04-08 8:49 ` [PATCH RFC 5/6] watchdog: qcom-wdt: add support to read the restart reason from IMEM Kathiravan Thirumoorthy
2025-04-08 12:33 ` Guenter Roeck [this message]
2025-04-11 5:29 ` Kathiravan Thirumoorthy
2025-04-09 7:03 ` Krzysztof Kozlowski
2025-04-11 5:34 ` Kathiravan Thirumoorthy
2025-04-08 8:49 ` [PATCH RFC 6/6] arm64: dts: qcom: ipq5424: add node for the restart reason information Kathiravan Thirumoorthy
2025-04-09 18:49 ` [PATCH RFC 0/6] Add support to read the restart reason from IMEM Konrad Dybcio
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=e02e7431-2e30-4e65-b04b-15fbb0bcd8d0@roeck-us.net \
--to=linux@roeck-us.net \
--cc=andersson@kernel.org \
--cc=conor+dt@kernel.org \
--cc=devicetree@vger.kernel.org \
--cc=kathiravan.thirumoorthy@oss.qualcomm.com \
--cc=konradybcio@kernel.org \
--cc=krzk+dt@kernel.org \
--cc=linux-arm-msm@vger.kernel.org \
--cc=linux-kernel@vger.kernel.org \
--cc=linux-watchdog@vger.kernel.org \
--cc=robh@kernel.org \
--cc=wim@linux-watchdog.org \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox