* [PATCH v2] i2c: imx-lpi2c: change to PIO mode in system-wide suspend/resume progress
@ 2025-11-20 10:30 Carlos Song
2025-11-20 13:55 ` Daniel Baluta
2025-11-20 15:39 ` Frank Li
0 siblings, 2 replies; 5+ messages in thread
From: Carlos Song @ 2025-11-20 10:30 UTC (permalink / raw)
To: aisheng.dong, andi.shyti, shawnguo, s.hauer, kernel, carlos.song,
frank.li
Cc: linux-i2c, imx, linux-arm-kernel, linux-kernel
EDMA resume is in early stage and suspend is in late stage, but LPI2C
resume and suspend are in NOIRQ stage. So LPI2C resource become ready
earlier than EDMA. When IRQ enabled, immediately slave will trigger LPI2C
to read data and the length meets the requirements for DMA usage, the DMA
will be needed at this time. Within a very small time window, EDMA is
still not resumed.
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..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] 5+ messages in thread* Re: [PATCH v2] i2c: imx-lpi2c: change to PIO mode in system-wide suspend/resume progress
2025-11-20 10:30 [PATCH v2] i2c: imx-lpi2c: change to PIO mode in system-wide suspend/resume progress Carlos Song
@ 2025-11-20 13:55 ` Daniel Baluta
2025-11-21 2:01 ` [EXT] " Carlos Song
2025-11-20 15:39 ` Frank Li
1 sibling, 1 reply; 5+ messages in thread
From: Daniel Baluta @ 2025-11-20 13:55 UTC (permalink / raw)
To: Carlos Song
Cc: aisheng.dong, andi.shyti, shawnguo, s.hauer, kernel, frank.li,
linux-i2c, imx, linux-arm-kernel, linux-kernel
On Thu, Nov 20, 2025 at 12:31 PM Carlos Song <carlos.song@nxp.com> wrote:
>
> EDMA resume is in early stage and suspend is in late stage, but LPI2C
> resume and suspend are in NOIRQ stage. So LPI2C resource become ready
> earlier than EDMA. When IRQ enabled, immediately slave will trigger LPI2C
> to read data and the length meets the requirements for DMA usage, the DMA
> will be needed at this time. Within a very small time window, EDMA is
> still not resumed.
>
> 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>
> ---
For future patches please add here a small description of what changed since v1:
e.g
Changes since v1:
* updated commit message as per discussion with Frank.
^ permalink raw reply [flat|nested] 5+ messages in thread* RE: [EXT] Re: [PATCH v2] i2c: imx-lpi2c: change to PIO mode in system-wide suspend/resume progress
2025-11-20 13:55 ` Daniel Baluta
@ 2025-11-21 2:01 ` Carlos Song
0 siblings, 0 replies; 5+ messages in thread
From: Carlos Song @ 2025-11-21 2:01 UTC (permalink / raw)
To: Daniel Baluta
Cc: Aisheng Dong, andi.shyti@kernel.org, shawnguo@kernel.org,
s.hauer@pengutronix.de, kernel@pengutronix.de, Frank Li,
linux-i2c@vger.kernel.org, imx@lists.linux.dev,
linux-arm-kernel@lists.infradead.org,
linux-kernel@vger.kernel.org
> -----Original Message-----
> From: Daniel Baluta <daniel.baluta@gmail.com>
> Sent: Thursday, November 20, 2025 9:56 PM
> To: Carlos Song <carlos.song@nxp.com>
> Cc: Aisheng Dong <aisheng.dong@nxp.com>; andi.shyti@kernel.org;
> shawnguo@kernel.org; s.hauer@pengutronix.de; kernel@pengutronix.de;
> Frank Li <frank.li@nxp.com>; linux-i2c@vger.kernel.org; imx@lists.linux.dev;
> linux-arm-kernel@lists.infradead.org; linux-kernel@vger.kernel.org
> Subject: [EXT] Re: [PATCH v2] i2c: imx-lpi2c: change to PIO mode in system-wide
> suspend/resume progress
>
> Caution: This is an external email. Please take care when clicking links or
> opening attachments. When in doubt, report the message using the 'Report this
> email' button
>
>
> On Thu, Nov 20, 2025 at 12:31 PM Carlos Song <carlos.song@nxp.com> wrote:
> >
> > EDMA resume is in early stage and suspend is in late stage, but LPI2C
> > resume and suspend are in NOIRQ stage. So LPI2C resource become ready
> > earlier than EDMA. When IRQ enabled, immediately slave will trigger
> > LPI2C to read data and the length meets the requirements for DMA
> > usage, the DMA will be needed at this time. Within a very small time
> > window, EDMA is still not resumed.
> >
> > 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>
> > ---
>
Thank you very much. I miss it. I will do this then.
> For future patches please add here a small description of what changed since v1:
> e.g
>
> Changes since v1:
> * updated commit message as per discussion with Frank.
^ permalink raw reply [flat|nested] 5+ messages in thread
* Re: [PATCH v2] i2c: imx-lpi2c: change to PIO mode in system-wide suspend/resume progress
2025-11-20 10:30 [PATCH v2] i2c: imx-lpi2c: change to PIO mode in system-wide suspend/resume progress Carlos Song
2025-11-20 13:55 ` Daniel Baluta
@ 2025-11-20 15:39 ` Frank Li
2025-11-21 2:02 ` Carlos Song
1 sibling, 1 reply; 5+ messages in thread
From: Frank Li @ 2025-11-20 15:39 UTC (permalink / raw)
To: Carlos Song
Cc: aisheng.dong, andi.shyti, shawnguo, s.hauer, kernel, linux-i2c,
imx, linux-arm-kernel, linux-kernel
On Thu, Nov 20, 2025 at 06:30:39PM +0800, Carlos Song wrote:
> EDMA resume is in early stage and suspend is in late stage, but LPI2C
> resume and suspend are in NOIRQ stage. So LPI2C resource become ready
> earlier than EDMA. When IRQ enabled, immediately slave will trigger LPI2C
> to read data and the length meets the requirements for DMA usage, the DMA
"the length meets the requirements for DMA usage" is condition to trigger
DMA, reader easily miss this and confuse.
> will be needed at this time. Within a very small time window, EDMA is
> still not resumed.
>
> 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.
You can use AI help rephrase.
EDMA resume happens in the early stage and suspend in the late stage, while
LPI2C resume and suspend run in the NOIRQ stage. This causes the LPI2C
resources to become available earlier than EDMA. When IRQs are enabled, a
slave device may immediately trigger LPI2C to read data. If the transfer
length meets the DMA requirements, the driver will attempt to use EDMA even
though EDMA may not yet be resumed.
Within this small timing window, EDMA is unavailable, leading to transfer
failures. Force PIO mode for LPI2C during system suspend and resume
transitions to reduce system dependency and avoid using an unready EDMA
resource.
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..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] 5+ messages in thread* RE: [PATCH v2] i2c: imx-lpi2c: change to PIO mode in system-wide suspend/resume progress
2025-11-20 15:39 ` Frank Li
@ 2025-11-21 2:02 ` Carlos Song
0 siblings, 0 replies; 5+ messages in thread
From: Carlos Song @ 2025-11-21 2:02 UTC (permalink / raw)
To: Frank Li
Cc: Aisheng Dong, andi.shyti@kernel.org, shawnguo@kernel.org,
s.hauer@pengutronix.de, kernel@pengutronix.de,
linux-i2c@vger.kernel.org, imx@lists.linux.dev,
linux-arm-kernel@lists.infradead.org,
linux-kernel@vger.kernel.org
> -----Original Message-----
> From: Frank Li <frank.li@nxp.com>
> Sent: Thursday, November 20, 2025 11:40 PM
> To: Carlos Song <carlos.song@nxp.com>
> Cc: Aisheng Dong <aisheng.dong@nxp.com>; andi.shyti@kernel.org;
> shawnguo@kernel.org; s.hauer@pengutronix.de; kernel@pengutronix.de;
> linux-i2c@vger.kernel.org; imx@lists.linux.dev;
> linux-arm-kernel@lists.infradead.org; linux-kernel@vger.kernel.org
> Subject: Re: [PATCH v2] i2c: imx-lpi2c: change to PIO mode in system-wide
> suspend/resume progress
>
> On Thu, Nov 20, 2025 at 06:30:39PM +0800, Carlos Song wrote:
> > EDMA resume is in early stage and suspend is in late stage, but LPI2C
> > resume and suspend are in NOIRQ stage. So LPI2C resource become ready
> > earlier than EDMA. When IRQ enabled, immediately slave will trigger
> > LPI2C to read data and the length meets the requirements for DMA
> > usage, the DMA
>
> "the length meets the requirements for DMA usage" is condition to trigger DMA,
> reader easily miss this and confuse.
>
> > will be needed at this time. Within a very small time window, EDMA is
> > still not resumed.
> >
> > 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.
>
> You can use AI help rephrase.
>
> EDMA resume happens in the early stage and suspend in the late stage, while
> LPI2C resume and suspend run in the NOIRQ stage. This causes the LPI2C
> resources to become available earlier than EDMA. When IRQs are enabled, a
> slave device may immediately trigger LPI2C to read data. If the transfer length
> meets the DMA requirements, the driver will attempt to use EDMA even though
> EDMA may not yet be resumed.
>
> Within this small timing window, EDMA is unavailable, leading to transfer
> failures. Force PIO mode for LPI2C during system suspend and resume
> transitions to reduce system dependency and avoid using an unready EDMA
> resource.
>
Thank you Frank, I will send V3 according to this.
> 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..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] 5+ messages in thread
end of thread, other threads:[~2025-11-21 2:02 UTC | newest]
Thread overview: 5+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2025-11-20 10:30 [PATCH v2] i2c: imx-lpi2c: change to PIO mode in system-wide suspend/resume progress Carlos Song
2025-11-20 13:55 ` Daniel Baluta
2025-11-21 2:01 ` [EXT] " Carlos Song
2025-11-20 15:39 ` Frank Li
2025-11-21 2:02 ` Carlos Song
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox