drivers/i2c/busses/i2c-amd-asf-plat.c | 4 ++-- drivers/i2c/busses/i2c-mv64xxx.c | 4 ++-- drivers/i2c/busses/i2c-piix4.c | 6 +++--- include/linux/i2c.h | 5 +++++ 4 files changed, 12 insertions(+), 7 deletions(-)
It's been another year of discussing the object life-time problems at
conferences. I2C is one of the offenders and its problems are more
complex than those of some other subsystems. It seems the revocable[1]
API may make its way into the kernel this year but even with it in
place, I2C won't be able to use it as there's currently nothing to
*revoke*. The struct device is embedded within the i2c_adapter struct
whose lifetime is tied to the provider device being bound to its driver.
Fixing this won't be fast and easy but nothing's going to happen if we
don't start chipping away at it. The ultimate goal in order to be able
to use an SRCU-based solution (revocable or otherwise) is to convert the
embedded struct device in struct i2c_adapter into an __rcu pointer that
can be *revoked*. To that end we need to hide all dereferences of
adap->dev in drivers.
Other series address more generic problems - like printk helpers and
parent/of_node setting - but there are still some more specific
use-cases of drivers dereferencing the internal struct device of
i2c_adapters. We need to hide the fact that the device is embedded in
i2c_adapter before we can move it out so provide a helper that provides
the address of struct device without showing how it's stored and use it
in some drivers.
Link: [1] https://lore.kernel.org/all/20251106152330.11733-1-tzungbi@kernel.org/
Signed-off-by: Bartosz Golaszewski <bartosz.golaszewski@oss.qualcomm.com>
---
Changes in v2:
- drop two patches that can be addressed in a different series
- rebase on top of v7.0-rc1
- collect tags
- Link to v1: https://lore.kernel.org/r/20251223-i2c-adapter-dev-wrapper-v1-0-bcf960a48fa9@oss.qualcomm.com
---
Bartosz Golaszewski (4):
i2c: provide i2c_adapter_dev()
i2c: piix4: use i2c_adapter_dev()
i2c: amd-asf-plat: use i2c_adapter_dev()
i2c: mv64xxx: use i2c_adapter_dev()
drivers/i2c/busses/i2c-amd-asf-plat.c | 4 ++--
drivers/i2c/busses/i2c-mv64xxx.c | 4 ++--
drivers/i2c/busses/i2c-piix4.c | 6 +++---
include/linux/i2c.h | 5 +++++
4 files changed, 12 insertions(+), 7 deletions(-)
---
base-commit: 6de23f81a5e08be8fbf5e8d7e9febc72a5b5f27f
change-id: 20251222-i2c-adapter-dev-wrapper-c882660190a2
Best regards,
--
Bartosz Golaszewski <bartosz.golaszewski@oss.qualcomm.com>
On Mon, Feb 23, 2026 at 10:02:48AM +0100, Bartosz Golaszewski wrote: > It's been another year of discussing the object life-time problems at > conferences. I2C is one of the offenders and its problems are more > complex than those of some other subsystems. It seems the revocable[1] > API may make its way into the kernel this year but even with it in > place, I2C won't be able to use it as there's currently nothing to > *revoke*. The struct device is embedded within the i2c_adapter struct > whose lifetime is tied to the provider device being bound to its driver. > > Fixing this won't be fast and easy but nothing's going to happen if we > don't start chipping away at it. The ultimate goal in order to be able > to use an SRCU-based solution (revocable or otherwise) is to convert the > embedded struct device in struct i2c_adapter into an __rcu pointer that > can be *revoked*. To that end we need to hide all dereferences of > adap->dev in drivers. > > Other series address more generic problems - like printk helpers and > parent/of_node setting - but there are still some more specific > use-cases of drivers dereferencing the internal struct device of > i2c_adapters. We need to hide the fact that the device is embedded in > i2c_adapter before we can move it out so provide a helper that provides > the address of struct device without showing how it's stored and use it > in some drivers. > > Link: [1] https://lore.kernel.org/all/20251106152330.11733-1-tzungbi@kernel.org/ > Signed-off-by: Bartosz Golaszewski <bartosz.golaszewski@oss.qualcomm.com> Also applied to for-current and squashed everything into one patch... > --- > Changes in v2: > - drop two patches that can be addressed in a different series > - rebase on top of v7.0-rc1 ... but why didn't you rebase on top of rc1 + plus your previous series? The merge conflict was easy to solve but kinda unnecessary in my book...?
On Mon, Feb 23, 2026 at 10:02:48AM +0100, Bartosz Golaszewski wrote: > It's been another year of discussing the object life-time problems at > conferences. I2C is one of the offenders and its problems are more > complex than those of some other subsystems. It seems the revocable[1] > API may make its way into the kernel this year but even with it in > place, I2C won't be able to use it as there's currently nothing to > *revoke*. The struct device is embedded within the i2c_adapter struct > whose lifetime is tied to the provider device being bound to its driver. > > Fixing this won't be fast and easy but nothing's going to happen if we > don't start chipping away at it. The ultimate goal in order to be able > to use an SRCU-based solution (revocable or otherwise) is to convert the > embedded struct device in struct i2c_adapter into an __rcu pointer that > can be *revoked*. To that end we need to hide all dereferences of > adap->dev in drivers. > > Other series address more generic problems - like printk helpers and > parent/of_node setting - but there are still some more specific > use-cases of drivers dereferencing the internal struct device of > i2c_adapters. We need to hide the fact that the device is embedded in > i2c_adapter before we can move it out so provide a helper that provides > the address of struct device without showing how it's stored and use it > in some drivers. LGTM, and I follow the evolution of these two series for a while, Reviewed-by: Andy Shevchenko <andriy.shevchenko@linux.intel.com> for this one. -- With Best Regards, Andy Shevchenko
© 2016 - 2026 Red Hat, Inc.