From: Sasha Levin <sashal@kernel.org>
To: stable@vger.kernel.org
Cc: "Hans de Goede" <hdegoede@redhat.com>,
"Pali Rohár" <pali@kernel.org>,
"Andi Shyti" <andi.shyti@kernel.org>,
"Wolfram Sang" <wsa+renesas@sang-engineering.com>,
"Sasha Levin" <sashal@kernel.org>
Subject: [PATCH 5.15.y 1/5] i2c: core: Setup i2c_adapter runtime-pm before calling device_add()
Date: Tue, 21 Jul 2026 20:50:42 -0400 [thread overview]
Message-ID: <20260722005046.603973-1-sashal@kernel.org> (raw)
In-Reply-To: <2026071656-dullness-penalize-0e99@gregkh>
From: Hans de Goede <hdegoede@redhat.com>
[ Upstream commit 60f68597024d5af727c8a5f5f3b11f246265192b ]
Platform glue code, which is not build into the kernel and thus cannot
use i2c_register_board_info() may want to use bus_register_notifier()
to listen for i2c-adapters to show up on which the platform code needs
to manually instantiate platform specific i2c_clients.
This results in calling i2c_new_client_device() from the bus notifier
which happens near the device_add() call.
If the i2c-core has not yet setup runtime-pm (specifically the
no-callbacks and ignore-children flags) for the device embedded
inside struct i2c_adapter and the driver for the i2c_client
calls pm_runtime_set_active() this will trigger the following
error inside __pm_runtime_set_status():
"runtime PM trying to activate child device %s but parent (%s) is not active\n"
and the i2c_client's runtime-status will not be updated.
Split the device_register() call for the adapter into device_initialize()
and device_add() and move the pm-runtime init calls inbetween these 2 calls
so that the runtime-status can be correctly set when a driver binds from
the bus-notifier.
Note the moved pm-runtime init calls just override the initial value of
some flags in struct device set by device_initialize() and calling these
before device_add() is safe.
Reviewed-by: Pali Rohár <pali@kernel.org>
Reviewed-by: Andi Shyti <andi.shyti@kernel.org>
Signed-off-by: Hans de Goede <hdegoede@redhat.com>
Acked-by: Wolfram Sang <wsa+renesas@sang-engineering.com>
Signed-off-by: Andi Shyti <andi.shyti@kernel.org>
Stable-dep-of: 158efa411c57 ("i2c: core: fix adapter probe deferral loop")
Signed-off-by: Sasha Levin <sashal@kernel.org>
---
drivers/i2c/i2c-core-base.c | 16 +++++++++++-----
1 file changed, 11 insertions(+), 5 deletions(-)
diff --git a/drivers/i2c/i2c-core-base.c b/drivers/i2c/i2c-core-base.c
index 265b7f7f38c6eb..1df75dcea8b97f 100644
--- a/drivers/i2c/i2c-core-base.c
+++ b/drivers/i2c/i2c-core-base.c
@@ -1551,7 +1551,17 @@ static int i2c_register_adapter(struct i2c_adapter *adap)
dev_set_name(&adap->dev, "i2c-%d", adap->nr);
adap->dev.bus = &i2c_bus_type;
adap->dev.type = &i2c_adapter_type;
- res = device_register(&adap->dev);
+ device_initialize(&adap->dev);
+
+ /*
+ * This adapter can be used as a parent immediately after device_add(),
+ * setup runtime-pm (especially ignore-children) before hand.
+ */
+ pm_runtime_no_callbacks(&adap->dev);
+ pm_suspend_ignore_children(&adap->dev, true);
+ pm_runtime_enable(&adap->dev);
+
+ res = device_add(&adap->dev);
if (res) {
pr_err("adapter '%s': can't register device (%d)\n", adap->name, res);
goto out_list;
@@ -1563,10 +1573,6 @@ static int i2c_register_adapter(struct i2c_adapter *adap)
if (res)
goto out_reg;
- pm_runtime_no_callbacks(&adap->dev);
- pm_suspend_ignore_children(&adap->dev, true);
- pm_runtime_enable(&adap->dev);
-
res = i2c_init_recovery(adap);
if (res == -EPROBE_DEFER)
goto out_reg;
--
2.53.0
next prev parent reply other threads:[~2026-07-22 0:50 UTC|newest]
Thread overview: 6+ messages / expand[flat|nested] mbox.gz Atom feed top
2026-07-16 12:40 FAILED: patch "[PATCH] i2c: core: fix adapter probe deferral loop" failed to apply to 5.15-stable tree gregkh
2026-07-22 0:50 ` Sasha Levin [this message]
2026-07-22 0:50 ` [PATCH 5.15.y 2/5] i2c: core: fix reference leak in i2c_register_adapter() Sasha Levin
2026-07-22 0:50 ` [PATCH 5.15.y 3/5] i2c: core: fix irq domain leak on adapter registration failure Sasha Levin
2026-07-22 0:50 ` [PATCH 5.15.y 4/5] i2c: core: fix NULL-deref " Sasha Levin
2026-07-22 0:50 ` [PATCH 5.15.y 5/5] i2c: core: fix adapter probe deferral loop Sasha Levin
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=20260722005046.603973-1-sashal@kernel.org \
--to=sashal@kernel.org \
--cc=andi.shyti@kernel.org \
--cc=hdegoede@redhat.com \
--cc=pali@kernel.org \
--cc=stable@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 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.