power: reset: tdx-ec-poweroff: fix restart
Subsystems (4)
Emanuele Ghidoli
maintainerPATCH 1/1 power: reset: tdx-ec-poweroff: fix restart
From: Emanuele Ghidoli <[email protected]>
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.
--- drivers/power/reset/tdx-ec-poweroff.c | 19 +++++++++++++++++++ 1 file changed, 19 insertions(+)
drivers/power/reset/tdx-ec-poweroff.c +19 -0
@@ -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 ; }
Signature · 1 line
2.43.0
Quoted 14 lines · Emanuele Ghidoli
From: Emanuele Ghidoli <[email protected]>
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.
Quoted 6 lines
Also print an error message if sending the command to the embedded controller fails.
Fixes 18672fe12367 ("power: reset: add Toradex Embedded Controller")Signed-off-by Emanuele Ghidoli <[email protected]>
Sebastian Reichel
AppliedQuoted 9 lines · Emanuele Ghidoli
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.
[...]
Applied, thanks!
[1/1] power: reset: tdx-ec-poweroff: fix restart
commit: 562357a6310f79e45844c3e980d410a1e8e02ce6
Best regards,
Signature · 1 line
Sebastian Reichel <[email protected]>