From: Andrew Jeffery <andrew@codeconstruct.com.au>
To: Chin-Ting Kuo <chin-ting_kuo@aspeedtech.com>,
patrick@stwcx.xyz, linux@roeck-us.net, wim@linux-watchdog.org,
joel@jms.id.au, linux-watchdog@vger.kernel.org,
linux-arm-kernel@lists.infradead.org,
linux-aspeed@lists.ozlabs.org, linux-kernel@vger.kernel.org
Cc: Peter.Yin@quantatw.com, Patrick_NC_Lin@wiwynn.com,
BMC-SW@aspeedtech.com, chnguyen@amperecomputing.com,
aaron_lee@aspeedtech.com
Subject: Re: [PATCH v6 1/1] watchdog: aspeed: Update bootstatus handling
Date: Mon, 13 Jan 2025 13:58:35 +1030 [thread overview]
Message-ID: <b4fa429c6c7df899281d36f295b4431c90fe443c.camel@codeconstruct.com.au> (raw)
In-Reply-To: <20250112081204.263216-2-chin-ting_kuo@aspeedtech.com>
On Sun, 2025-01-12 at 16:12 +0800, Chin-Ting Kuo wrote:
> The boot status in the watchdog device struct is updated during
> controller probe stage. Application layer can get the boot status
> through the command, cat /sys/class/watchdog/watchdogX/bootstatus.
> The bootstatus can be,
> WDIOF_CARDRESET => the system is reset by WDT SoC reset.
> Others => other reset events, e.g., power on reset.
>
> On ASPEED platform, the boot status is recorded in the SCU registers.
> - AST2400: Only a bit represents for any WDT reset.
> - AST2500/AST2600: The reset triggered by different WDT controllers
> can be distinguished by different SCU bits.
>
> Besides, on AST2400 and AST2500, since alternating boot event is
> triggered by WDT SoC reset, it is classified as WDIOF_CARDRESET.
>
> Signed-off-by: Chin-Ting Kuo <chin-ting_kuo@aspeedtech.com>
> ---
> drivers/watchdog/aspeed_wdt.c | 81
> ++++++++++++++++++++++++++++++++++-
> 1 file changed, 79 insertions(+), 2 deletions(-)
>
> diff --git a/drivers/watchdog/aspeed_wdt.c
> b/drivers/watchdog/aspeed_wdt.c
> index b4773a6aaf8c..369635b38ca0 100644
> --- a/drivers/watchdog/aspeed_wdt.c
> +++ b/drivers/watchdog/aspeed_wdt.c
> @@ -11,21 +11,30 @@
> #include <linux/io.h>
> #include <linux/kernel.h>
> #include <linux/kstrtox.h>
> +#include <linux/mfd/syscon.h>
> #include <linux/module.h>
> #include <linux/of.h>
> #include <linux/of_irq.h>
> #include <linux/platform_device.h>
> +#include <linux/regmap.h>
> #include <linux/watchdog.h>
>
> static bool nowayout = WATCHDOG_NOWAYOUT;
> module_param(nowayout, bool, 0);
> MODULE_PARM_DESC(nowayout, "Watchdog cannot be stopped once started
> (default="
> __MODULE_STRING(WATCHDOG_NOWAYOUT)
> ")");
> +struct aspeed_wdt_scu {
> + const char *compatible;
> + u32 reset_status_reg;
> + u32 wdt_reset_mask;
> + u32 wdt_reset_mask_shift;
> +};
>
> struct aspeed_wdt_config {
> u32 ext_pulse_width_mask;
> u32 irq_shift;
> u32 irq_mask;
> + struct aspeed_wdt_scu scu;
> };
>
> struct aspeed_wdt {
> @@ -39,18 +48,36 @@ static const struct aspeed_wdt_config
> ast2400_config = {
> .ext_pulse_width_mask = 0xff,
> .irq_shift = 0,
> .irq_mask = 0,
> + .scu = {
> + .compatible = "aspeed,ast2400-scu",
> + .reset_status_reg = 0x3c,
> + .wdt_reset_mask = 0x1,
> + .wdt_reset_mask_shift = 1,
> + },
> };
>
> static const struct aspeed_wdt_config ast2500_config = {
> .ext_pulse_width_mask = 0xfffff,
> .irq_shift = 12,
> .irq_mask = GENMASK(31, 12),
> + .scu = {
> + .compatible = "aspeed,ast2500-scu",
> + .reset_status_reg = 0x3c,
> + .wdt_reset_mask = 0x1,
> + .wdt_reset_mask_shift = 2,
> + },
> };
>
> static const struct aspeed_wdt_config ast2600_config = {
> .ext_pulse_width_mask = 0xfffff,
> .irq_shift = 0,
> .irq_mask = GENMASK(31, 10),
> + .scu = {
> + .compatible = "aspeed,ast2600-scu",
> + .reset_status_reg = 0x74,
> + .wdt_reset_mask = 0xf,
> + .wdt_reset_mask_shift = 16,
> + },
> };
>
> static const struct of_device_id aspeed_wdt_of_table[] = {
> @@ -213,6 +240,56 @@ static int aspeed_wdt_restart(struct
> watchdog_device *wdd,
> return 0;
> }
>
> +static void aspeed_wdt_update_bootstatus(struct platform_device
> *pdev,
> + struct aspeed_wdt *wdt)
> +{
> + const struct resource *res;
> + struct aspeed_wdt_scu scu = wdt->cfg->scu;
> + struct regmap *scu_base;
> + u32 reset_mask_width;
> + u32 reset_mask_shift;
> + u32 idx = 0;
> + u32 status;
> + int ret;
> +
> + if (!of_device_is_compatible(pdev->dev.of_node,
> "aspeed,ast2400-wdt")) {
> + res = platform_get_resource(pdev, IORESOURCE_MEM, 0);
> + idx = ((intptr_t)wdt->base & 0x00000fff) /
> resource_size(res);
> + }
> +
> + scu_base =
> syscon_regmap_lookup_by_compatible(scu.compatible);
> + if (IS_ERR(scu_base)) {
> + wdt->wdd.bootstatus = WDIOS_UNKNOWN;
> + return;
> + }
> +
> + ret = regmap_read(scu_base, scu.reset_status_reg, &status);
> + if (ret) {
> + wdt->wdd.bootstatus = WDIOS_UNKNOWN;
> + return;
> + }
> +
> + reset_mask_width = hweight32(scu.wdt_reset_mask);
> + reset_mask_shift = scu.wdt_reset_mask_shift +
> + reset_mask_width * idx;
> +
> + if (status & (scu.wdt_reset_mask << reset_mask_shift))
> + wdt->wdd.bootstatus = WDIOF_CARDRESET;
How precise is the wording in your commit message? The AST2600, for
instance, has 4 reset types:
1. "SoC"
2. "Full"
3. "ARM"
4. "Software"
In the commit message, you said:
> WDIOF_CARDRESET => the system is reset by WDT SoC reset.
However the logic here (with the way you've initialised the config
struct for the AST2600) will signal WDIOF_CARDRESET even if what
occurred was e.g. a (graceful?) software reset.
The only thing WDIOF_CARDRESET differentiates is a power-on reset from
any other kind of watchdog-driven reset.
Is that what's intended? I'm just wary of confusion for what appears to
be a generic use of "SoC" in the commit message vs the specific "SoC"
mode of the watchdog controller (should some documentation be
written/updated?)
Andrew
next prev parent reply other threads:[~2025-01-13 3:30 UTC|newest]
Thread overview: 6+ messages / expand[flat|nested] mbox.gz Atom feed top
2025-01-12 8:12 [PATCH v6 0/1] Update ASPEED WDT bootstatus Chin-Ting Kuo
2025-01-12 8:12 ` [PATCH v6 1/1] watchdog: aspeed: Update bootstatus handling Chin-Ting Kuo
2025-01-12 15:20 ` Guenter Roeck
2025-01-13 3:28 ` Andrew Jeffery [this message]
2025-01-13 3:41 ` Chin-Ting Kuo
2025-01-13 3:59 ` Andrew Jeffery
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=b4fa429c6c7df899281d36f295b4431c90fe443c.camel@codeconstruct.com.au \
--to=andrew@codeconstruct.com.au \
--cc=BMC-SW@aspeedtech.com \
--cc=Patrick_NC_Lin@wiwynn.com \
--cc=Peter.Yin@quantatw.com \
--cc=aaron_lee@aspeedtech.com \
--cc=chin-ting_kuo@aspeedtech.com \
--cc=chnguyen@amperecomputing.com \
--cc=joel@jms.id.au \
--cc=linux-arm-kernel@lists.infradead.org \
--cc=linux-aspeed@lists.ozlabs.org \
--cc=linux-kernel@vger.kernel.org \
--cc=linux-watchdog@vger.kernel.org \
--cc=linux@roeck-us.net \
--cc=patrick@stwcx.xyz \
--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