mirror of https://lore.kernel.org/lkml/
 help / color / mirror / Atom feed
From: Mateusz Nowicki <mateusz.nowicki@posteo.net>
To: Wim Van Sebroeck <wim@linux-watchdog.org>,
	Guenter Roeck <linux@roeck-us.net>,
	linux-watchdog@vger.kernel.org
Cc: Mateusz Nowicki <mateusz.nowicki@posteo.net>,
	Julius Werner <jwerner@chromium.org>,
	Evan Benn <evanbenn@chromium.org>, Rob Herring <robh@kernel.org>,
	Krzysztof Kozlowski <krzk+dt@kernel.org>,
	Conor Dooley <conor+dt@kernel.org>,
	Maxime Coquelin <mcoquelin.stm32@gmail.com>,
	Alexandre Torgue <alexandre.torgue@foss.st.com>,
	Antonio Borneo <antonio.borneo@foss.st.com>,
	Marek Vasut <marex@nabladev.com>,
	devicetree@vger.kernel.org,
	linux-stm32@st-md-mailman.stormreply.com,
	linux-arm-kernel@lists.infradead.org,
	linux-kernel@vger.kernel.org
Subject: [RFC PATCH 2/3] watchdog: arm_smc_wdt: try every id of arm,smc-id
Date: Wed, 04 Nov 2026 16:16:06 +0000	[thread overview]
Message-ID: <20261104161553.30115-3-mateusz.nowicki@posteo.net> (raw)
In-Reply-To: <20261104161553.30115-1-mateusz.nowicki@posteo.net>

The SMC function id of the watchdog service is not discoverable, and
firmware for the same SoC does not always use the same one: on the
STM32MP2 SoCs it is 0xbc000000 (the OP-TEE default for the platform) or
0xb200005a. With a single id in the SoC dtsi, every board whose firmware
uses the other id loses its watchdog.

Read arm,smc-id as a list and use the first id for which SMCWD_INIT
succeeds. Go to the next id on any error: OP-TEE answers an unknown
function id with 0xffffffff in a0, which smcwd_call() reports as -EIO,
not -ENODEV. A missing property still means 0x82003D06.

Signed-off-by: Mateusz Nowicki <mateusz.nowicki@posteo.net>
---
 drivers/watchdog/arm_smc_wdt.c | 18 ++++++++++++------
 1 file changed, 12 insertions(+), 6 deletions(-)

diff --git a/drivers/watchdog/arm_smc_wdt.c b/drivers/watchdog/arm_smc_wdt.c
index c73ed1dcdfcb..993c8f92c871 100644
--- a/drivers/watchdog/arm_smc_wdt.c
+++ b/drivers/watchdog/arm_smc_wdt.c
@@ -113,8 +113,9 @@ static const struct watchdog_ops smcwd_timeleft_ops = {
 
 static int smcwd_probe(struct platform_device *pdev)
 {
+	struct device_node *np = pdev->dev.of_node;
 	struct watchdog_device *wdd;
-	int err;
+	int err, i, n;
 	struct arm_smccc_res res;
 	u32 smc_func_id;
 
@@ -123,12 +124,17 @@ static int smcwd_probe(struct platform_device *pdev)
 		return -ENOMEM;
 	platform_set_drvdata(pdev, wdd);
 
-	if (of_property_read_u32(pdev->dev.of_node, "arm,smc-id",
-				 &smc_func_id))
-		smc_func_id = 0x82003D06;
-	watchdog_set_drvdata(wdd, (void *)(uintptr_t)smc_func_id);
+	/* The id is not discoverable: take the first one of the list the firmware accepts */
+	n = of_property_count_u32_elems(np, "arm,smc-id");
+	for (i = 0; i < max(n, 1); i++) {
+		if (of_property_read_u32_index(np, "arm,smc-id", i, &smc_func_id))
+			smc_func_id = 0x82003D06;
+		watchdog_set_drvdata(wdd, (void *)(uintptr_t)smc_func_id);
 
-	err = smcwd_call(wdd, SMCWD_INIT, 0, &res);
+		err = smcwd_call(wdd, SMCWD_INIT, 0, &res);
+		if (!err)
+			break;
+	}
 	if (err < 0)
 		return err;
 
-- 
2.56.0


  parent reply	other threads:[~2026-11-04 16:16 UTC|newest]

Thread overview: 11+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2026-11-04 16:16 [RFC PATCH 0/3] watchdog: arm_smc_wdt: allow a list of SMC function ids Mateusz Nowicki
2026-11-04 16:16 ` [RFC PATCH 1/3] dt-bindings: watchdog: arm-smc-wdt: allow a list of SMC ids Mateusz Nowicki
2026-11-04 16:47   ` Marek Vasut
2026-11-04 16:16 ` Mateusz Nowicki [this message]
2026-11-04 16:16 ` [RFC PATCH 3/3] arm64: dts: st: list both watchdog SMC ids on stm32mp23 and stm32mp25 Mateusz Nowicki
2026-11-04 16:39 ` [RFC PATCH 0/3] watchdog: arm_smc_wdt: allow a list of SMC function ids Guenter Roeck
2026-11-04 16:46   ` Marek Vasut
2026-11-04 18:10   ` mateusz.nowicki
2026-11-04 18:59     ` Guenter Roeck
2026-11-05  2:13 ` Julius Werner
2026-11-05 10:04   ` mateusz.nowicki

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=20261104161553.30115-3-mateusz.nowicki@posteo.net \
    --to=mateusz.nowicki@posteo.net \
    --cc=alexandre.torgue@foss.st.com \
    --cc=antonio.borneo@foss.st.com \
    --cc=conor+dt@kernel.org \
    --cc=devicetree@vger.kernel.org \
    --cc=evanbenn@chromium.org \
    --cc=jwerner@chromium.org \
    --cc=krzk+dt@kernel.org \
    --cc=linux-arm-kernel@lists.infradead.org \
    --cc=linux-kernel@vger.kernel.org \
    --cc=linux-stm32@st-md-mailman.stormreply.com \
    --cc=linux-watchdog@vger.kernel.org \
    --cc=linux@roeck-us.net \
    --cc=marex@nabladev.com \
    --cc=mcoquelin.stm32@gmail.com \
    --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

all inboxes | Powered by JetHome®