Skip to content
/ linux Public

Commit 491f04b

Browse files
eghidoliSasha Levin
authored andcommitted
power: reset: tdx-ec-poweroff: fix restart
[ Upstream commit 562357a ] 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: 18672fe ("power: reset: add Toradex Embedded Controller") Cc: stable@vger.kernel.org Signed-off-by: Emanuele Ghidoli <emanuele.ghidoli@toradex.com> Reviewed-by: Francesco Dolcini <francesco.dolcini@toradex.com> Link: https://patch.msgid.link/20260130071208.1184239-1-ghidoliemanuele@gmail.com Signed-off-by: Sebastian Reichel <sebastian.reichel@collabora.com> Signed-off-by: Sasha Levin <sashal@kernel.org>
1 parent bc14926 commit 491f04b

File tree

1 file changed

+19
-0
lines changed

1 file changed

+19
-0
lines changed

drivers/power/reset/tdx-ec-poweroff.c

Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,10 @@
88
*/
99

1010
#include <linux/array_size.h>
11+
#include <linux/bug.h>
12+
#include <linux/delay.h>
1113
#include <linux/device.h>
14+
#include <linux/dev_printk.h>
1215
#include <linux/err.h>
1316
#include <linux/i2c.h>
1417
#include <linux/mod_devicetable.h>
@@ -31,6 +34,8 @@
3134

3235
#define EC_REG_MAX 0xD0
3336

37+
#define EC_CMD_TIMEOUT_MS 1000
38+
3439
static const struct regmap_range volatile_ranges[] = {
3540
regmap_reg_range(EC_CMD_REG, EC_CMD_REG),
3641
};
@@ -75,6 +80,13 @@ static int tdx_ec_power_off(struct sys_off_data *data)
7580

7681
err = tdx_ec_cmd(regmap, EC_CMD_POWEROFF);
7782

83+
if (err) {
84+
dev_err(data->dev, "Failed to send power off command\n");
85+
} else {
86+
mdelay(EC_CMD_TIMEOUT_MS);
87+
WARN_ONCE(1, "Unable to power off system\n");
88+
}
89+
7890
return err ? NOTIFY_BAD : NOTIFY_DONE;
7991
}
8092

@@ -85,6 +97,13 @@ static int tdx_ec_restart(struct sys_off_data *data)
8597

8698
err = tdx_ec_cmd(regmap, EC_CMD_RESET);
8799

100+
if (err) {
101+
dev_err(data->dev, "Failed to send restart command\n");
102+
} else {
103+
mdelay(EC_CMD_TIMEOUT_MS);
104+
WARN_ONCE(1, "Unable to restart system\n");
105+
}
106+
88107
return err ? NOTIFY_BAD : NOTIFY_DONE;
89108
}
90109

0 commit comments

Comments
 (0)