From: Emanuele Ghidoli <ghidoliemanuele@gmail.com>
To: Francesco Dolcini <francesco@dolcini.it>,
Sebastian Reichel <sre@kernel.org>, Rob Herring <robh@kernel.org>,
Krzysztof Kozlowski <krzk+dt@kernel.org>,
Conor Dooley <conor+dt@kernel.org>
Cc: Emanuele Ghidoli <emanuele.ghidoli@toradex.com>,
linux-pm@vger.kernel.org, devicetree@vger.kernel.org,
linux-kernel@vger.kernel.org, stable@vger.kernel.org
Subject: [PATCH v1] power: reset: tdx-ec-poweroff: fix restart
Date: Fri, 30 Jan 2026 08:11:35 +0100 [thread overview]
Message-ID: <20260130071208.1184239-1-ghidoliemanuele@gmail.com> (raw)
From: Emanuele Ghidoli <emanuele.ghidoli@toradex.com>
During testing, restart occasionally failed on Toradex modules.
The issue was traced to an interaction between the EC-based reset/poweroff
handler and the PSCI restart handler. While the embedded controller is
resetting or powering off the module, the PSCI code may still be invoked,
triggering an I2C transaction to the PMIC. This can leave the PMIC I2C
in a frozen state.
Add a delay after issuing the EC reset or power-off command to give the
controller time to complete the operation and avoid falling back to another
restart/poweroff provider.
Also print an error message if sending the command to the embedded controller
fails.
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 | 19 +++++++++++++++++++
1 file changed, 19 insertions(+)
diff --git a/drivers/power/reset/tdx-ec-poweroff.c b/drivers/power/reset/tdx-ec-poweroff.c
index 3302a127fce5..8040aa03d74d 100644
--- a/drivers/power/reset/tdx-ec-poweroff.c
+++ b/drivers/power/reset/tdx-ec-poweroff.c
@@ -8,7 +8,10 @@
*/
#include <linux/array_size.h>
+#include <linux/bug.h>
+#include <linux/delay.h>
#include <linux/device.h>
+#include <linux/dev_printk.h>
#include <linux/err.h>
#include <linux/i2c.h>
#include <linux/mod_devicetable.h>
@@ -31,6 +34,8 @@
#define EC_REG_MAX 0xD0
+#define EC_CMD_TIMEOUT_MS 1000
+
static const struct regmap_range volatile_ranges[] = {
regmap_reg_range(EC_CMD_REG, EC_CMD_REG),
};
@@ -75,6 +80,13 @@ static int tdx_ec_power_off(struct sys_off_data *data)
err = tdx_ec_cmd(regmap, EC_CMD_POWEROFF);
+ 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;
}
@@ -85,6 +97,13 @@ static int tdx_ec_restart(struct sys_off_data *data)
err = tdx_ec_cmd(regmap, EC_CMD_RESET);
+ 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;
}
--
2.43.0
next reply other threads:[~2026-01-30 7:13 UTC|newest]
Thread overview: 3+ messages / expand[flat|nested] mbox.gz Atom feed top
2026-01-30 7:11 Emanuele Ghidoli [this message]
2026-01-30 8:09 ` [PATCH v1] power: reset: tdx-ec-poweroff: fix restart Francesco Dolcini
2026-01-30 22:24 ` Sebastian Reichel
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=20260130071208.1184239-1-ghidoliemanuele@gmail.com \
--to=ghidoliemanuele@gmail.com \
--cc=conor+dt@kernel.org \
--cc=devicetree@vger.kernel.org \
--cc=emanuele.ghidoli@toradex.com \
--cc=francesco@dolcini.it \
--cc=krzk+dt@kernel.org \
--cc=linux-kernel@vger.kernel.org \
--cc=linux-pm@vger.kernel.org \
--cc=robh@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