[PATCH] i2c: imx-lpi2c: change to PIO mode in system-wide suspend/resume progress

Carlos Song posted 1 patch 1 week, 6 days ago
There is a newer version of this series
drivers/i2c/busses/i2c-imx-lpi2c.c | 7 +++++++
1 file changed, 7 insertions(+)
[PATCH] i2c: imx-lpi2c: change to PIO mode in system-wide suspend/resume progress
Posted by Carlos Song 1 week, 6 days ago
If a system-wide suspend or resume transition is in progress. LPI2C should
use PIO to transfer data not DMA to avoid issue caused by not ready DMA HW
resource.

Fixes: a09c8b3f9047 ("i2c: imx-lpi2c: add eDMA mode support for LPI2C")
Signed-off-by: Carlos Song <carlos.song@nxp.com>
---
 drivers/i2c/busses/i2c-imx-lpi2c.c | 7 +++++++
 1 file changed, 7 insertions(+)

diff --git a/drivers/i2c/busses/i2c-imx-lpi2c.c b/drivers/i2c/busses/i2c-imx-lpi2c.c
index 2a0962a0b441..5050e14a9919 100644
--- a/drivers/i2c/busses/i2c-imx-lpi2c.c
+++ b/drivers/i2c/busses/i2c-imx-lpi2c.c
@@ -592,6 +592,13 @@ static bool is_use_dma(struct lpi2c_imx_struct *lpi2c_imx, struct i2c_msg *msg)
 	if (!lpi2c_imx->can_use_dma)
 		return false;
 
+	/*
+	 * When system is in suspend process. LPI2C should use PIO to transfer data to
+	 * avoid issue caused by not ready DMA HW resource.
+	 */
+	if (pm_suspend_in_progress())
+		return false;
+
 	/*
 	 * When the length of data is less than I2C_DMA_THRESHOLD,
 	 * cpu mode is used directly to avoid low performance.
-- 
2.34.1
Re: [PATCH] i2c: imx-lpi2c: change to PIO mode in system-wide suspend/resume progress
Posted by Frank Li 1 week, 6 days ago
On Tue, Nov 18, 2025 at 03:18:37PM +0800, Carlos Song wrote:
> If a system-wide suspend or resume transition is in progress. LPI2C should
> use PIO to transfer data not DMA to avoid issue caused by not ready DMA HW
> resource.

Currently there is no device link between the DMA engine and its DMA
consumer, which allows the DMA engine to suspend before the consumer.

To avoid this, switch to PIO mode instead of DMA during suspend/resume so
the transfer does not rely on the DMA engine’s state.

Notes: I suppose DMA engine suspend before LPI2C. Do you meet this or
other reason cause DMA HW resource ready.

Not sure if below
https://lore.kernel.org/dmaengine/20250912-v6-16-topic-dma-devlink-v1-0-4debc2fbf901@pengutronix.de/
can fix your problem.

Anyway, I think it is fine to use PIO at suspend to reduce dependence. But
we need know why DMA HW is not ready.

Frank

>
> Fixes: a09c8b3f9047 ("i2c: imx-lpi2c: add eDMA mode support for LPI2C")
> Signed-off-by: Carlos Song <carlos.song@nxp.com>
> ---
>  drivers/i2c/busses/i2c-imx-lpi2c.c | 7 +++++++
>  1 file changed, 7 insertions(+)
>
> diff --git a/drivers/i2c/busses/i2c-imx-lpi2c.c b/drivers/i2c/busses/i2c-imx-lpi2c.c
> index 2a0962a0b441..5050e14a9919 100644
> --- a/drivers/i2c/busses/i2c-imx-lpi2c.c
> +++ b/drivers/i2c/busses/i2c-imx-lpi2c.c
> @@ -592,6 +592,13 @@ static bool is_use_dma(struct lpi2c_imx_struct *lpi2c_imx, struct i2c_msg *msg)
>  	if (!lpi2c_imx->can_use_dma)
>  		return false;
>
> +	/*
> +	 * When system is in suspend process. LPI2C should use PIO to transfer data to
> +	 * avoid issue caused by not ready DMA HW resource.
> +	 */
> +	if (pm_suspend_in_progress())
> +		return false;
> +
>  	/*
>  	 * When the length of data is less than I2C_DMA_THRESHOLD,
>  	 * cpu mode is used directly to avoid low performance.
> --
> 2.34.1
>