* [PATCH v3] i2c: imx-lpi2c: change to PIO mode in system-wide suspend/resume progress
@ 2025-11-21 3:00 Carlos Song
2025-11-21 3:20 ` Frank Li
2026-01-14 11:59 ` Wolfram Sang
0 siblings, 2 replies; 3+ messages in thread
From: Carlos Song @ 2025-11-21 3:00 UTC (permalink / raw)
To: frank.li, aisheng.dong, andi.shyti, shawnguo, s.hauer, kernel,
carlos.song
Cc: linux-i2c, imx, linux-arm-kernel, linux-kernel
EDMA resumes early and suspends late in the system power transition
sequence, while LPI2C enters the NOIRQ stage for both suspend and resume.
This means LPI2C resources become available before EDMA is fully resumed.
Once IRQs are enabled, a slave device may immediately trigger an LPI2C
transfer. If the transfer length meets DMA requirements, the driver will
attempt to use EDMA even though EDMA may still be unavailable.
This timing gap can lead to transfer failures. To prevent this, force
LPI2C to use PIO mode during system-wide suspend and resume transitions.
This reduces dependency on EDMA and avoids using an unready DMA resource.
Fixes: a09c8b3f9047 ("i2c: imx-lpi2c: add eDMA mode support for LPI2C")
Signed-off-by: Carlos Song <carlos.song@nxp.com>
---
Changes since v2:
* Updated commit message as per discussion with Frank and improve the
commit log by AI
Changes since v1:
* Updated commit message as per discussion with Frank.
---
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..d882126c1778 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;
+ /*
+ * A system-wide suspend or resume transition is in progress. LPI2C should use PIO to
+ * transfer data to avoid issue caused by no 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
^ permalink raw reply related [flat|nested] 3+ messages in thread* Re: [PATCH v3] i2c: imx-lpi2c: change to PIO mode in system-wide suspend/resume progress
2025-11-21 3:00 [PATCH v3] i2c: imx-lpi2c: change to PIO mode in system-wide suspend/resume progress Carlos Song
@ 2025-11-21 3:20 ` Frank Li
2026-01-14 11:59 ` Wolfram Sang
1 sibling, 0 replies; 3+ messages in thread
From: Frank Li @ 2025-11-21 3:20 UTC (permalink / raw)
To: Carlos Song
Cc: aisheng.dong, andi.shyti, shawnguo, s.hauer, kernel, linux-i2c,
imx, linux-arm-kernel, linux-kernel
On Fri, Nov 21, 2025 at 11:00:30AM +0800, Carlos Song wrote:
> EDMA resumes early and suspends late in the system power transition
> sequence, while LPI2C enters the NOIRQ stage for both suspend and resume.
> This means LPI2C resources become available before EDMA is fully resumed.
> Once IRQs are enabled, a slave device may immediately trigger an LPI2C
> transfer. If the transfer length meets DMA requirements, the driver will
> attempt to use EDMA even though EDMA may still be unavailable.
>
> This timing gap can lead to transfer failures. To prevent this, force
> LPI2C to use PIO mode during system-wide suspend and resume transitions.
> This reduces dependency on EDMA and avoids using an unready DMA resource.
>
> Fixes: a09c8b3f9047 ("i2c: imx-lpi2c: add eDMA mode support for LPI2C")
> Signed-off-by: Carlos Song <carlos.song@nxp.com>
>
> ---
Reviewed-by: Frank Li <Frank.Li@nxp.com>
> Changes since v2:
> * Updated commit message as per discussion with Frank and improve the
> commit log by AI
> Changes since v1:
> * Updated commit message as per discussion with Frank.
> ---
> 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..d882126c1778 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;
>
> + /*
> + * A system-wide suspend or resume transition is in progress. LPI2C should use PIO to
> + * transfer data to avoid issue caused by no 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
>
^ permalink raw reply [flat|nested] 3+ messages in thread* Re: [PATCH v3] i2c: imx-lpi2c: change to PIO mode in system-wide suspend/resume progress
2025-11-21 3:00 [PATCH v3] i2c: imx-lpi2c: change to PIO mode in system-wide suspend/resume progress Carlos Song
2025-11-21 3:20 ` Frank Li
@ 2026-01-14 11:59 ` Wolfram Sang
1 sibling, 0 replies; 3+ messages in thread
From: Wolfram Sang @ 2026-01-14 11:59 UTC (permalink / raw)
To: Carlos Song
Cc: frank.li, aisheng.dong, andi.shyti, shawnguo, s.hauer, kernel,
linux-i2c, imx, linux-arm-kernel, linux-kernel
On Fri, Nov 21, 2025 at 11:00:30AM +0800, Carlos Song wrote:
> EDMA resumes early and suspends late in the system power transition
> sequence, while LPI2C enters the NOIRQ stage for both suspend and resume.
> This means LPI2C resources become available before EDMA is fully resumed.
> Once IRQs are enabled, a slave device may immediately trigger an LPI2C
> transfer. If the transfer length meets DMA requirements, the driver will
> attempt to use EDMA even though EDMA may still be unavailable.
>
> This timing gap can lead to transfer failures. To prevent this, force
> LPI2C to use PIO mode during system-wide suspend and resume transitions.
> This reduces dependency on EDMA and avoids using an unready DMA resource.
>
> Fixes: a09c8b3f9047 ("i2c: imx-lpi2c: add eDMA mode support for LPI2C")
> Signed-off-by: Carlos Song <carlos.song@nxp.com>
> Reviewed-by: Frank Li <Frank.Li@nxp.com>
Applied to for-current, thanks!
^ permalink raw reply [flat|nested] 3+ messages in thread
end of thread, other threads:[~2026-01-14 11:59 UTC | newest]
Thread overview: 3+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2025-11-21 3:00 [PATCH v3] i2c: imx-lpi2c: change to PIO mode in system-wide suspend/resume progress Carlos Song
2025-11-21 3:20 ` Frank Li
2026-01-14 11:59 ` Wolfram Sang
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox