mirror of https://lore.kernel.org/lkml/
 help / color / mirror / Atom feed
From: Emanuele Ghidoli <ghidoliemanuele@gmail.com>
To: Emanuele Ghidoli <ghidoliemanuele@gmail.com>,
	Francesco Dolcini <francesco@dolcini.it>,
	Sebastian Reichel <sre@kernel.org>
Cc: Emanuele Ghidoli <emanuele.ghidoli@toradex.com>,
	linux-pm@vger.kernel.org, linux-kernel@vger.kernel.org,
	stable@vger.kernel.org
Subject: [PATCH] power: reset: tdx-ec-poweroff: fix return value on command failure
Date: Fri, 27 Nov 2026 15:52:12 +0100	[thread overview]
Message-ID: <20261127145216.2058830-1-ghidoliemanuele@gmail.com> (raw)

From: Emanuele Ghidoli <emanuele.ghidoli@toradex.com>

When the power-off or restart command cannot be sent to the embedded
controller, the handlers return NOTIFY_BAD. NOTIFY_BAD includes
NOTIFY_STOP_MASK, so the sys-off notifier chain stops and lower priority
handlers are never called. The system then halts instead of powering off
or restarting.

Fix this by returning NOTIFY_DONE in the error path too, so the next
handler can take over.

A failed write does not guarantee that the EC did not receive the
command. To avoid running the next handler while the EC may still be
acting on it, wait EC_CMD_TIMEOUT_MS unconditionally.

Fixes: 18672fe12367 ("power: reset: add Toradex Embedded Controller")
Cc: stable@vger.kernel.org
Signed-off-by: Emanuele Ghidoli <emanuele.ghidoli@toradex.com>
---
 drivers/power/reset/tdx-ec-poweroff.c | 22 ++++++++++------------
 1 file changed, 10 insertions(+), 12 deletions(-)

diff --git a/drivers/power/reset/tdx-ec-poweroff.c b/drivers/power/reset/tdx-ec-poweroff.c
index b4f1c87f5651..5d025a724392 100644
--- a/drivers/power/reset/tdx-ec-poweroff.c
+++ b/drivers/power/reset/tdx-ec-poweroff.c
@@ -79,14 +79,13 @@ static int tdx_ec_power_off(struct sys_off_data *data)
 
 	err = tdx_ec_cmd(regmap, EC_CMD_POWEROFF);
 
-	if (err) {
+	if (err)
 		dev_err(data->dev, "Failed to send power off command\n");
-	} else {
-		mdelay(EC_CMD_TIMEOUT_MS);
-		WARN_ONCE(1, "Unable to power off system\n");
-	}
 
-	return err ? NOTIFY_BAD : NOTIFY_DONE;
+	mdelay(EC_CMD_TIMEOUT_MS);
+	WARN_ONCE(!err, "Unable to power off system\n");
+
+	return NOTIFY_DONE;
 }
 
 static int tdx_ec_restart(struct sys_off_data *data)
@@ -96,14 +95,13 @@ static int tdx_ec_restart(struct sys_off_data *data)
 
 	err = tdx_ec_cmd(regmap, EC_CMD_RESET);
 
-	if (err) {
+	if (err)
 		dev_err(data->dev, "Failed to send restart command\n");
-	} else {
-		mdelay(EC_CMD_TIMEOUT_MS);
-		WARN_ONCE(1, "Unable to restart system\n");
-	}
 
-	return err ? NOTIFY_BAD : NOTIFY_DONE;
+	mdelay(EC_CMD_TIMEOUT_MS);
+	WARN_ONCE(!err, "Unable to restart system\n");
+
+	return NOTIFY_DONE;
 }
 
 static int tdx_ec_register_power_off_restart(struct device *dev, struct regmap *regmap)
-- 
2.53.0


                 reply	other threads:[~2026-11-27 14:52 UTC|newest]

Thread overview: [no followups] expand[flat|nested]  mbox.gz  Atom feed

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=20261127145216.2058830-1-ghidoliemanuele@gmail.com \
    --to=ghidoliemanuele@gmail.com \
    --cc=emanuele.ghidoli@toradex.com \
    --cc=francesco@dolcini.it \
    --cc=linux-kernel@vger.kernel.org \
    --cc=linux-pm@vger.kernel.org \
    --cc=sre@kernel.org \
    --cc=stable@vger.kernel.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®