From: sashiko-bot@kernel.org
Cc: imx@lists.linux.dev, Frank.Li@kernel.org
Subject: Re: [PATCH] i2c: imx-lpi2c: mark I2C adapter when hardware is powered down
Date: Tue, 19 May 2026 11:15:16 +0000 [thread overview]
Message-ID: <20260519111517.36699C2BCB3@smtp.kernel.org> (raw)
In-Reply-To: <20260519104106.2794103-1-carlos.song@oss.nxp.com>
Thank you for your contribution! Sashiko AI review found 1 potential issue(s) to consider:
- [High] Incorrect ordering of adapter suspension and hardware power-down creates a race condition leading to deadlocks and kernel panics.
--
commit 4f51dfc32f43d5578829b4cc2fac1f8c956c3ca8
Author: Carlos Song <carlos.song@nxp.com>
Subject: i2c: imx-lpi2c: mark I2C adapter when hardware is powered down
This commit updates the suspend and resume routines to mark the I2C
adapter as suspended or resumed. This is intended to block transfers
while the hardware is powered down and prevent hangs.
> diff --git a/drivers/i2c/busses/i2c-imx-lpi2c.c b/drivers/i2c/busses/i2c-imx-lpi2c.c
> index a01c236964819..bf8c1ce1c7ff0 100644
> --- a/drivers/i2c/busses/i2c-imx-lpi2c.c
> +++ b/drivers/i2c/busses/i2c-imx-lpi2c.c
> @@ -1635,7 +1635,16 @@ 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;
> +
> + ret = pm_runtime_force_suspend(dev);
> + if (ret)
> + return ret;
> +
> + i2c_mark_adapter_suspended(&lpi2c_imx->adapter);
Could this ordering cause a deadlock and external abort if an I2C transfer
is currently active during suspend?
When pm_runtime_force_suspend is called, it disables the controller clocks.
If a transfer is ongoing, the hardware will stop responding and the
transfer will hang waiting for a completion timeout.
Then, i2c_mark_adapter_suspended attempts to acquire the root adapter lock,
which is still held by the hanging transfer, causing the suspend path to
block.
When the hung transfer eventually times out, its error handling path will
try to reset or abort the transfer by writing to the hardware registers.
Since the clocks were already disabled by pm_runtime_force_suspend,
wouldn't accessing these registers trigger a synchronous external abort
and panic the kernel?
Should i2c_mark_adapter_suspended be called before pm_runtime_force_suspend
so it can safely acquire the bus lock, wait for active transfers to finish,
and reject new transfers before the hardware is powered down?
[ ... ]
--
Sashiko AI review · https://sashiko.dev/#/patchset/20260519104106.2794103-1-carlos.song@oss.nxp.com?part=1
prev parent reply other threads:[~2026-05-19 11:15 UTC|newest]
Thread overview: 2+ messages / expand[flat|nested] mbox.gz Atom feed top
2026-05-19 10:41 [PATCH] i2c: imx-lpi2c: mark I2C adapter when hardware is powered down Carlos Song (OSS)
2026-05-19 11:15 ` sashiko-bot [this message]
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=20260519111517.36699C2BCB3@smtp.kernel.org \
--to=sashiko-bot@kernel.org \
--cc=Frank.Li@kernel.org \
--cc=imx@lists.linux.dev \
--cc=sashiko-reviews@lists.linux.dev \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.