From: Dmitry Guzman <Dmitry.Guzman@mobileye.com>
To: Linus Walleij <linusw@kernel.org>,
Andi Shyti <andi.shyti@kernel.org>,
Wolfram Sang <wsa+renesas@sang-engineering.com>
Cc: linux-arm-kernel@lists.infradead.org, linux-i2c@vger.kernel.org,
linux-kernel@vger.kernel.org,
Dmitry Guzman <Dmitry.Guzman@mobileye.com>
Subject: [PATCH] i2c: nomadik: handle pm_runtime errors
Date: Tue, 10 Nov 2026 15:06:16 +0200 [thread overview]
Message-ID: <20261110-i2c-nomadik-handle-pm_errors-v1-1-ea1ac92af8f4@mobileye.com> (raw)
In nmk_i2c_xfer(), pm_runtime_get_sync() is called on start and then
the controller registers are accessed without checking the return value.
If pm_runtime_get_sync() fails, access to the register of the device that
was not correctly powered on may cause a bus fault or other unpredictable
system behavior.
Replace pm_runtime_get_sync() with pm_runtime_resume_and_get() that
always return 0 on success and automatically restores PM usage counter
on failure, and return immediately if it returns any error.
Signed-off-by: Dmitry Guzman <Dmitry.Guzman@mobileye.com>
---
This is fixed version of patch #6 in a set of fixes in i2c-nomadik
driver:
https://lore.kernel.org/linux-i2c/20261103-i2c-nomadik-fixes-v1-6-655c6af2cb70@mobileye.com/
Please replace that patch with this one.
Changes in this version of the patch:
- use pm_runtime_resume_and_get() instead of pm_runtime_get_sync() in
order to automatically restore the usage counter on failure and always
get 0 on success (pm_runtime_get_sync() may also return 1 if the device
is already active).
- use variable `status` instead of `i` for its return value.
---
drivers/i2c/busses/i2c-nomadik.c | 7 ++++---
1 file changed, 4 insertions(+), 3 deletions(-)
diff --git a/drivers/i2c/busses/i2c-nomadik.c b/drivers/i2c/busses/i2c-nomadik.c
index c3878670da9c..74ecf188c9eb 100644
--- a/drivers/i2c/busses/i2c-nomadik.c
+++ b/drivers/i2c/busses/i2c-nomadik.c
@@ -713,12 +713,13 @@ static int nmk_i2c_xfer_one(struct nmk_i2c_dev *priv, u16 flags)
static int nmk_i2c_xfer(struct i2c_adapter *i2c_adap,
struct i2c_msg msgs[], int num_msgs)
{
- int status = 0;
- int i;
+ int status, i;
struct nmk_i2c_dev *priv = i2c_get_adapdata(i2c_adap);
int j;
- pm_runtime_get_sync(&priv->adev->dev);
+ status = pm_runtime_resume_and_get(&priv->adev->dev);
+ if (status)
+ return status;
/* Attempt three times to send the message queue */
for (j = 0; j < 3; j++) {
---
base-commit: 6628e7d4c6b25c8d18f1345e3a20d21829aae7e4
change-id: 20261110-i2c-nomadik-handle-pm_errors-4925b54a5076
Best regards,
--
Dmitry Guzman <Dmitry.Guzman@mobileye.com>
next reply other threads:[~2026-11-10 13:07 UTC|newest]
Thread overview: 2+ messages / expand[flat|nested] mbox.gz Atom feed top
2026-11-10 13:06 Dmitry Guzman [this message]
2026-11-10 19:52 ` Wolfram Sang
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=20261110-i2c-nomadik-handle-pm_errors-v1-1-ea1ac92af8f4@mobileye.com \
--to=dmitry.guzman@mobileye.com \
--cc=andi.shyti@kernel.org \
--cc=linusw@kernel.org \
--cc=linux-arm-kernel@lists.infradead.org \
--cc=linux-i2c@vger.kernel.org \
--cc=linux-kernel@vger.kernel.org \
--cc=wsa+renesas@sang-engineering.com \
/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 a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox
all inboxes | Powered by JetHome®