Re: [PACTH v2] i2c: imx-lpi2c: mark I2C adapter when hardware is powered down

From: Frank Li

Date: Thu Jun 04 2026 - 15:02:22 EST


On Wed, May 20, 2026 at 05:09:10PM +0800, Carlos Song (OSS) wrote:
> From: Carlos Song <carlos.song@xxxxxxx>
>
> Mark the I2C adapter as suspended during system suspend to block further
> transfers, and resume it on system resume. This prevents potential hangs
> when the hardware is powered down but clients still attempt I2C transfers.
>
> Fixes: 1ee867e465c1 ("i2c: imx-lpi2c: add target mode support")
> Cc: stable@xxxxxxxxxxxxxxx
> Signed-off-by: Carlos Song <carlos.song@xxxxxxx>
> ---

Reviewed-by: Frank Li <Frank.Li@xxxxxxx>

> Change for v2:
> - Call i2c_mark_adapter_suspended() before pm_runtime_force_suspend()
> to prevent potential deadlock if a transfer is active during suspend.
> - Roll back with i2c_mark_adapter_resumed() if pm_runtime_force_suspend()
> fails.
> ---
> drivers/i2c/busses/i2c-imx-lpi2c.c | 15 ++++++++++++++-
> 1 file changed, 14 insertions(+), 1 deletion(-)
>
> diff --git a/drivers/i2c/busses/i2c-imx-lpi2c.c b/drivers/i2c/busses/i2c-imx-lpi2c.c
> index a01c23696481..01ee38131ef2 100644
> --- a/drivers/i2c/busses/i2c-imx-lpi2c.c
> +++ b/drivers/i2c/busses/i2c-imx-lpi2c.c
> @@ -1635,7 +1635,18 @@ static int __maybe_unused lpi2c_runtime_resume(struct device *dev)
>
> static int __maybe_unused lpi2c_suspend_noirq(struct device *dev)
> {
> - return pm_runtime_force_suspend(dev);
> + struct lpi2c_imx_struct *lpi2c_imx = dev_get_drvdata(dev);
> + int ret;
> +
> + i2c_mark_adapter_suspended(&lpi2c_imx->adapter);
> +
> + ret = pm_runtime_force_suspend(dev);
> + if (ret) {
> + i2c_mark_adapter_resumed(&lpi2c_imx->adapter);
> + return ret;
> + }
> +
> + return 0;
> }
>
> static int __maybe_unused lpi2c_resume_noirq(struct device *dev)
> @@ -1655,6 +1666,8 @@ static int __maybe_unused lpi2c_resume_noirq(struct device *dev)
> if (lpi2c_imx->target)
> lpi2c_imx_target_init(lpi2c_imx);
>
> + i2c_mark_adapter_resumed(&lpi2c_imx->adapter);
> +
> return 0;
> }
>
> --
> 2.43.0
>