* Re: [PATCH v2 01/12] i2c: allow setting the parent device and OF node through the adapter struct [not found] <EDF3FB58-4747-442E-8463-6F1C6E568962@gmail.com> @ 2026-03-02 11:08 ` Bartosz Golaszewski 2026-03-02 15:59 ` Andreas Kemnade 2026-03-02 15:09 ` Andreas Kemnade 1 sibling, 1 reply; 9+ messages in thread From: Bartosz Golaszewski @ 2026-03-02 11:08 UTC (permalink / raw) To: Kalle Niemi Cc: Bartosz Golaszewski, Mukesh Kumar Savaliya, Viken Dadhaniya, Andi Shyti, Florian Fainelli, Ray Jui, Branden Scott, bcm-kernel-feedback-list, Vignesh R, Aaro Koskinen, Janusz Krzysztofik, Tony Lindgren, Andreas Kemnade, Kevin Hilman, Roger Quadros, Geert Uytterhoeven, Magnus Damm, Patrice Chotard, Shawn Guo, Sascha Hauer, Pengutronix Kernel Team, Fabio Estevam, Linus Walleij, Frank Li, linux-i2c, linux-kernel, linux-arm-msm, linux-omap, linux-renesas-soc, linux-arm-kernel, imx, linux-rpi-kernel, Matti Vaittinen, Bartosz Golaszewski, Wolfram Sang On Mon, 2 Mar 2026 11:38:27 +0100, Kalle Niemi <kaleposti@gmail.com> said: > On 3/2/26 10:55, Bartosz Golaszewski wrote: >> On Mon, Mar 2, 2026 at 8:47 AM Kalle Niemi <kaleposti@gmail.com> wrote: >>> On 2/23/26 11:05, Bartosz Golaszewski wrote: >>>> In order to stop i2c bus drivers from dereferencing the struct device >>>> embedded in struct i2c_adapter, let's allow configuring the parent >>>> device and OF-node of the adapter directly through dedicated fields. >>>> Signed-off-by: Bartosz Golaszewski <bartosz.golaszewski@oss.qualcomm.com> >>>> --- >>> Hello, >>> Automated driver test system bisected this commit to be the first bad >>> commit, linux-next next-20260227 was tested. Failed tests include driver >>> tests for ROHM PMIC and accelerometers, which are connected to >>> BeagleBone Black. >>> The failed driver tests all fail to first i2cget and the tests stop >>> there: "Could not open file '/dev/i2c-2' or 'dev/i2c/2': No such file or >>> directory". >> Wolfram: well, now it would actually be useful to know which commit >> exactly is the culprit so maybe splitting the changes is not a bad >> idea after all. >> Kalle: which i2c bus driver fails here? Any errors in kernel log? >> Bart > > Hello Bart, > > i2c-1 and i2c-2 are failing. I am not seeing any i2c errors in kernel log. I got two failures without the dmesg available (this is bugged test sequence, and not a kernel crash), but those got the same stdout message "Could not open file ...." as all others. > > -Kalle > I meant what driver are you using but I suppose it's i2c-omap. Can you try the following change and let me know if it fixes the issue? diff --git a/drivers/i2c/i2c-core-base.c b/drivers/i2c/i2c-core-base.c index dd8cec9b04c6..01656f82d2c6 100644 --- a/drivers/i2c/i2c-core-base.c +++ b/drivers/i2c/i2c-core-base.c @@ -1548,6 +1548,11 @@ static int i2c_register_adapter(struct i2c_adapter *adap) if (adap->timeout == 0) adap->timeout = HZ; + if (!adap->dev.parent) + adap->dev.parent = adap->parent; + if (!adap->dev.of_node) + adap->dev.of_node = adap->of_node; + /* register soft irqs for Host Notify */ res = i2c_setup_host_notify_irq_domain(adap); if (res) { @@ -1561,11 +1566,6 @@ static int i2c_register_adapter(struct i2c_adapter *adap) adap->dev.type = &i2c_adapter_type; device_initialize(&adap->dev); - if (!adap->dev.parent) - adap->dev.parent = adap->parent; - if (!adap->dev.of_node) - adap->dev.of_node = adap->of_node; - /* * This adapter can be used as a parent immediately after device_add(), * setup runtime-pm (especially ignore-children) before hand. Bart ^ permalink raw reply related [flat|nested] 9+ messages in thread
* Re: [PATCH v2 01/12] i2c: allow setting the parent device and OF node through the adapter struct 2026-03-02 11:08 ` [PATCH v2 01/12] i2c: allow setting the parent device and OF node through the adapter struct Bartosz Golaszewski @ 2026-03-02 15:59 ` Andreas Kemnade 2026-03-02 16:56 ` Andreas Kemnade 0 siblings, 1 reply; 9+ messages in thread From: Andreas Kemnade @ 2026-03-02 15:59 UTC (permalink / raw) To: Bartosz Golaszewski Cc: Kalle Niemi, Bartosz Golaszewski, Mukesh Kumar Savaliya, Viken Dadhaniya, Andi Shyti, Florian Fainelli, Ray Jui, Branden Scott, bcm-kernel-feedback-list, Vignesh R, Aaro Koskinen, Janusz Krzysztofik, Tony Lindgren, Kevin Hilman, Roger Quadros, Geert Uytterhoeven, Magnus Damm, Patrice Chotard, Shawn Guo, Sascha Hauer, Pengutronix Kernel Team, Fabio Estevam, Linus Walleij, Frank Li, linux-i2c, linux-kernel, linux-arm-msm, linux-omap, linux-renesas-soc, linux-arm-kernel, imx, linux-rpi-kernel, Matti Vaittinen, Wolfram Sang On Mon, 2 Mar 2026 03:08:24 -0800 Bartosz Golaszewski <brgl@kernel.org> wrote: > On Mon, 2 Mar 2026 11:38:27 +0100, Kalle Niemi <kaleposti@gmail.com> said: > > On 3/2/26 10:55, Bartosz Golaszewski wrote: > >> On Mon, Mar 2, 2026 at 8:47 AM Kalle Niemi <kaleposti@gmail.com> wrote: > >>> On 2/23/26 11:05, Bartosz Golaszewski wrote: > >>>> In order to stop i2c bus drivers from dereferencing the struct device > >>>> embedded in struct i2c_adapter, let's allow configuring the parent > >>>> device and OF-node of the adapter directly through dedicated fields. > >>>> Signed-off-by: Bartosz Golaszewski <bartosz.golaszewski@oss.qualcomm.com> > >>>> --- > >>> Hello, > >>> Automated driver test system bisected this commit to be the first bad > >>> commit, linux-next next-20260227 was tested. Failed tests include driver > >>> tests for ROHM PMIC and accelerometers, which are connected to > >>> BeagleBone Black. > >>> The failed driver tests all fail to first i2cget and the tests stop > >>> there: "Could not open file '/dev/i2c-2' or 'dev/i2c/2': No such file or > >>> directory". > >> Wolfram: well, now it would actually be useful to know which commit > >> exactly is the culprit so maybe splitting the changes is not a bad > >> idea after all. > >> Kalle: which i2c bus driver fails here? Any errors in kernel log? > >> Bart > > > > Hello Bart, > > > > i2c-1 and i2c-2 are failing. I am not seeing any i2c errors in kernel log. I got two failures without the dmesg available (this is bugged test sequence, and not a kernel crash), but those got the same stdout message "Could not open file ...." as all others. > > > > -Kalle > > > > I meant what driver are you using but I suppose it's i2c-omap. > > Can you try the following change and let me know if it fixes the issue? > > diff --git a/drivers/i2c/i2c-core-base.c b/drivers/i2c/i2c-core-base.c > index dd8cec9b04c6..01656f82d2c6 100644 > --- a/drivers/i2c/i2c-core-base.c > +++ b/drivers/i2c/i2c-core-base.c > @@ -1548,6 +1548,11 @@ static int i2c_register_adapter(struct i2c_adapter *adap) > if (adap->timeout == 0) > adap->timeout = HZ; > > + if (!adap->dev.parent) > + adap->dev.parent = adap->parent; > + if (!adap->dev.of_node) > + adap->dev.of_node = adap->of_node; > + > /* register soft irqs for Host Notify */ > res = i2c_setup_host_notify_irq_domain(adap); > if (res) { > @@ -1561,11 +1566,6 @@ static int i2c_register_adapter(struct i2c_adapter *adap) > adap->dev.type = &i2c_adapter_type; > device_initialize(&adap->dev); > > - if (!adap->dev.parent) > - adap->dev.parent = adap->parent; > - if (!adap->dev.of_node) > - adap->dev.of_node = adap->of_node; > - > /* > * This adapter can be used as a parent immediately after device_add(), > * setup runtime-pm (especially ignore-children) before hand. > No changes here. Devices probe, bus indexes are still shifted. If I take that into account, i2cget still works. But I think there is no defined order anyways. So if I would add e.g. usb device provoding i2c busses early than omap-i2c for some odd reason, things were messed anyways. On the other hand, just having numbers skipped seems to be odd. Regards, Andreas ^ permalink raw reply [flat|nested] 9+ messages in thread
* Re: [PATCH v2 01/12] i2c: allow setting the parent device and OF node through the adapter struct 2026-03-02 15:59 ` Andreas Kemnade @ 2026-03-02 16:56 ` Andreas Kemnade 0 siblings, 0 replies; 9+ messages in thread From: Andreas Kemnade @ 2026-03-02 16:56 UTC (permalink / raw) To: Bartosz Golaszewski Cc: Kalle Niemi, Bartosz Golaszewski, Mukesh Kumar Savaliya, Viken Dadhaniya, Andi Shyti, Florian Fainelli, Ray Jui, Branden Scott, bcm-kernel-feedback-list, Vignesh R, Aaro Koskinen, Janusz Krzysztofik, Tony Lindgren, Kevin Hilman, Roger Quadros, Geert Uytterhoeven, Magnus Damm, Patrice Chotard, Shawn Guo, Sascha Hauer, Pengutronix Kernel Team, Fabio Estevam, Linus Walleij, Frank Li, linux-i2c, linux-kernel, linux-arm-msm, linux-omap, linux-renesas-soc, linux-arm-kernel, imx, linux-rpi-kernel, Matti Vaittinen, Wolfram Sang On Mon, 2 Mar 2026 16:59:28 +0100 Andreas Kemnade <andreas@kemnade.info> wrote: > On Mon, 2 Mar 2026 03:08:24 -0800 > Bartosz Golaszewski <brgl@kernel.org> wrote: > > > On Mon, 2 Mar 2026 11:38:27 +0100, Kalle Niemi <kaleposti@gmail.com> said: > > > On 3/2/26 10:55, Bartosz Golaszewski wrote: > > >> On Mon, Mar 2, 2026 at 8:47 AM Kalle Niemi <kaleposti@gmail.com> wrote: > > >>> On 2/23/26 11:05, Bartosz Golaszewski wrote: > > >>>> In order to stop i2c bus drivers from dereferencing the struct device > > >>>> embedded in struct i2c_adapter, let's allow configuring the parent > > >>>> device and OF-node of the adapter directly through dedicated fields. > > >>>> Signed-off-by: Bartosz Golaszewski <bartosz.golaszewski@oss.qualcomm.com> > > >>>> --- > > >>> Hello, > > >>> Automated driver test system bisected this commit to be the first bad > > >>> commit, linux-next next-20260227 was tested. Failed tests include driver > > >>> tests for ROHM PMIC and accelerometers, which are connected to > > >>> BeagleBone Black. > > >>> The failed driver tests all fail to first i2cget and the tests stop > > >>> there: "Could not open file '/dev/i2c-2' or 'dev/i2c/2': No such file or > > >>> directory". > > >> Wolfram: well, now it would actually be useful to know which commit > > >> exactly is the culprit so maybe splitting the changes is not a bad > > >> idea after all. > > >> Kalle: which i2c bus driver fails here? Any errors in kernel log? > > >> Bart > > > > > > Hello Bart, > > > > > > i2c-1 and i2c-2 are failing. I am not seeing any i2c errors in kernel log. I got two failures without the dmesg available (this is bugged test sequence, and not a kernel crash), but those got the same stdout message "Could not open file ...." as all others. > > > > > > -Kalle > > > > > > > I meant what driver are you using but I suppose it's i2c-omap. > > > > Can you try the following change and let me know if it fixes the issue? > > > > diff --git a/drivers/i2c/i2c-core-base.c b/drivers/i2c/i2c-core-base.c > > index dd8cec9b04c6..01656f82d2c6 100644 > > --- a/drivers/i2c/i2c-core-base.c > > +++ b/drivers/i2c/i2c-core-base.c > > @@ -1548,6 +1548,11 @@ static int i2c_register_adapter(struct i2c_adapter *adap) > > if (adap->timeout == 0) > > adap->timeout = HZ; > > > > + if (!adap->dev.parent) > > + adap->dev.parent = adap->parent; > > + if (!adap->dev.of_node) > > + adap->dev.of_node = adap->of_node; > > + > > /* register soft irqs for Host Notify */ > > res = i2c_setup_host_notify_irq_domain(adap); > > if (res) { > > @@ -1561,11 +1566,6 @@ static int i2c_register_adapter(struct i2c_adapter *adap) > > adap->dev.type = &i2c_adapter_type; > > device_initialize(&adap->dev); > > > > - if (!adap->dev.parent) > > - adap->dev.parent = adap->parent; > > - if (!adap->dev.of_node) > > - adap->dev.of_node = adap->of_node; > > - > > /* > > * This adapter can be used as a parent immediately after device_add(), > > * setup runtime-pm (especially ignore-children) before hand. > > > No changes here. Devices probe, bus indexes are still shifted. > If I take that into account, i2cget still works. > > But I think there is no defined order anyways. So if > I would add e.g. usb device provoding i2c busses early than > omap-i2c for some odd reason, things were messed anyways. > > On the other hand, just having numbers skipped seems to be odd. > ok, looked around further, We have aliases, so numbers should be static i2c_add_adapter calls i2c_register_adapter() as the last thing, but needs to determine the number earlier. This seems to help: diff --git a/drivers/i2c/i2c-core-base.c b/drivers/i2c/i2c-core-base.c index dd8cec9b04c6..e22d784202b8 100644 --- a/drivers/i2c/i2c-core-base.c +++ b/drivers/i2c/i2c-core-base.c @@ -1657,10 +1657,9 @@ static int __i2c_add_numbered_adapter(struct i2c_adapter *adap) */ int i2c_add_adapter(struct i2c_adapter *adapter) { - struct device *dev = &adapter->dev; int id; - id = of_alias_get_id(dev->of_node, "i2c"); + id = of_alias_get_id(adapter->of_node, "i2c"); if (id >= 0) { adapter->nr = id; return __i2c_add_numbered_adapter(adapter); > Regards, > Andreas > > ^ permalink raw reply related [flat|nested] 9+ messages in thread
* Re: [PATCH v2 01/12] i2c: allow setting the parent device and OF node through the adapter struct [not found] <EDF3FB58-4747-442E-8463-6F1C6E568962@gmail.com> 2026-03-02 11:08 ` [PATCH v2 01/12] i2c: allow setting the parent device and OF node through the adapter struct Bartosz Golaszewski @ 2026-03-02 15:09 ` Andreas Kemnade 2026-03-02 15:42 ` Bartosz Golaszewski 1 sibling, 1 reply; 9+ messages in thread From: Andreas Kemnade @ 2026-03-02 15:09 UTC (permalink / raw) To: Kalle Niemi Cc: Bartosz Golaszewski, Wolfram Sang, Bartosz Golaszewski, Mukesh Kumar Savaliya, Viken Dadhaniya, Andi Shyti, Florian Fainelli, Ray Jui, Branden Scott, bcm-kernel-feedback-list, Vignesh R, Aaro Koskinen, Janusz Krzysztofik, Tony Lindgren, Kevin Hilman, Roger Quadros, Geert Uytterhoeven, Magnus Damm, Patrice Chotard, Shawn Guo, Sascha Hauer, Pengutronix Kernel Team, Fabio Estevam, Linus Walleij, Frank Li, linux-i2c, linux-kernel, linux-arm-msm, linux-omap, linux-renesas-soc, linux-arm-kernel, imx, linux-rpi-kernel, Matti Vaittinen On Mon, 2 Mar 2026 12:38:27 +0200 Kalle Niemi <kaleposti@gmail.com> wrote: > On 3/2/26 10:55, Bartosz Golaszewski wrote: > > On Mon, Mar 2, 2026 at 8:47 AM Kalle Niemi <kaleposti@gmail.com> wrote: > >> On 2/23/26 11:05, Bartosz Golaszewski wrote: > >>> In order to stop i2c bus drivers from dereferencing the struct device > >>> embedded in struct i2c_adapter, let's allow configuring the parent > >>> device and OF-node of the adapter directly through dedicated fields. > >>> Signed-off-by: Bartosz Golaszewski <bartosz.golaszewski@oss.qualcomm.com> > >>> --- > >> Hello, > >> Automated driver test system bisected this commit to be the first bad > >> commit, linux-next next-20260227 was tested. Failed tests include driver > >> tests for ROHM PMIC and accelerometers, which are connected to > >> BeagleBone Black. > >> The failed driver tests all fail to first i2cget and the tests stop > >> there: "Could not open file '/dev/i2c-2' or 'dev/i2c/2': No such file or > >> directory". > > Wolfram: well, now it would actually be useful to know which commit > > exactly is the culprit so maybe splitting the changes is not a bad > > idea after all. > > Kalle: which i2c bus driver fails here? Any errors in kernel log? > > Bart > > Hello Bart, > > i2c-1 and i2c-2 are failing. I am not seeing any i2c errors in kernel log. I got two failures without the dmesg available (this is bugged test sequence, and not a kernel crash), but those got the same stdout message "Could not open file ...." as all others. > Probably I am using the same host driver tested on OMAP3 DM3730, result: i2c drivers get bound to their devices, no obvious trouble. But controllers are registered with high indexes. localhost:~# i2cdetect -l i2c-3 i2c OMAP I2C adapter I2C adapter i2c-4 i2c OMAP I2C adapter I2C adapter i2c-5 i2c OMAP I2C adapter I2C adapter localhost:~# uname -a Linux localhost 7.0.0-rc1-next-20260227 #27 SMP Mon Mar 2 11:56:27 CET 2026 armv7l Linux Regards, Andreas ^ permalink raw reply [flat|nested] 9+ messages in thread
* Re: [PATCH v2 01/12] i2c: allow setting the parent device and OF node through the adapter struct 2026-03-02 15:09 ` Andreas Kemnade @ 2026-03-02 15:42 ` Bartosz Golaszewski 2026-03-02 16:14 ` Andreas Kemnade 0 siblings, 1 reply; 9+ messages in thread From: Bartosz Golaszewski @ 2026-03-02 15:42 UTC (permalink / raw) To: Andreas Kemnade Cc: Kalle Niemi, Wolfram Sang, Bartosz Golaszewski, Mukesh Kumar Savaliya, Viken Dadhaniya, Andi Shyti, Florian Fainelli, Ray Jui, Branden Scott, bcm-kernel-feedback-list, Vignesh R, Aaro Koskinen, Janusz Krzysztofik, Tony Lindgren, Kevin Hilman, Roger Quadros, Geert Uytterhoeven, Magnus Damm, Patrice Chotard, Shawn Guo, Sascha Hauer, Pengutronix Kernel Team, Fabio Estevam, Linus Walleij, Frank Li, linux-i2c, linux-kernel, linux-arm-msm, linux-omap, linux-renesas-soc, linux-arm-kernel, imx, linux-rpi-kernel, Matti Vaittinen On Mon, Mar 2, 2026 at 4:11 PM Andreas Kemnade <andreas@kemnade.info> wrote: > > On Mon, 2 Mar 2026 12:38:27 +0200 > Kalle Niemi <kaleposti@gmail.com> wrote: > > > On 3/2/26 10:55, Bartosz Golaszewski wrote: > > > On Mon, Mar 2, 2026 at 8:47 AM Kalle Niemi <kaleposti@gmail.com> wrote: > > >> On 2/23/26 11:05, Bartosz Golaszewski wrote: > > >>> In order to stop i2c bus drivers from dereferencing the struct device > > >>> embedded in struct i2c_adapter, let's allow configuring the parent > > >>> device and OF-node of the adapter directly through dedicated fields. > > >>> Signed-off-by: Bartosz Golaszewski <bartosz.golaszewski@oss.qualcomm.com> > > >>> --- > > >> Hello, > > >> Automated driver test system bisected this commit to be the first bad > > >> commit, linux-next next-20260227 was tested. Failed tests include driver > > >> tests for ROHM PMIC and accelerometers, which are connected to > > >> BeagleBone Black. > > >> The failed driver tests all fail to first i2cget and the tests stop > > >> there: "Could not open file '/dev/i2c-2' or 'dev/i2c/2': No such file or > > >> directory". > > > Wolfram: well, now it would actually be useful to know which commit > > > exactly is the culprit so maybe splitting the changes is not a bad > > > idea after all. > > > Kalle: which i2c bus driver fails here? Any errors in kernel log? > > > Bart > > > > Hello Bart, > > > > i2c-1 and i2c-2 are failing. I am not seeing any i2c errors in kernel log. I got two failures without the dmesg available (this is bugged test sequence, and not a kernel crash), but those got the same stdout message "Could not open file ...." as all others. > > > Probably I am using the same host driver > > tested on OMAP3 DM3730, result: i2c drivers get bound to their devices, > no obvious trouble. But controllers are registered with high indexes. > > localhost:~# i2cdetect -l > i2c-3 i2c OMAP I2C adapter I2C adapter > i2c-4 i2c OMAP I2C adapter I2C adapter > i2c-5 i2c OMAP I2C adapter I2C adapter > localhost:~# uname -a > Linux localhost 7.0.0-rc1-next-20260227 #27 SMP Mon Mar 2 11:56:27 CET 2026 armv7l Linux > > Regards, > Andreas Hi! Does the change I posted earlier in this thread help? Bart ^ permalink raw reply [flat|nested] 9+ messages in thread
* Re: [PATCH v2 01/12] i2c: allow setting the parent device and OF node through the adapter struct 2026-03-02 15:42 ` Bartosz Golaszewski @ 2026-03-02 16:14 ` Andreas Kemnade 0 siblings, 0 replies; 9+ messages in thread From: Andreas Kemnade @ 2026-03-02 16:14 UTC (permalink / raw) To: Bartosz Golaszewski Cc: Kalle Niemi, Wolfram Sang, Bartosz Golaszewski, Mukesh Kumar Savaliya, Viken Dadhaniya, Andi Shyti, Florian Fainelli, Ray Jui, Branden Scott, bcm-kernel-feedback-list, Vignesh R, Aaro Koskinen, Janusz Krzysztofik, Tony Lindgren, Kevin Hilman, Roger Quadros, Geert Uytterhoeven, Magnus Damm, Patrice Chotard, Shawn Guo, Sascha Hauer, Pengutronix Kernel Team, Fabio Estevam, Linus Walleij, Frank Li, linux-i2c, linux-kernel, linux-arm-msm, linux-omap, linux-renesas-soc, linux-arm-kernel, imx, linux-rpi-kernel, Matti Vaittinen On Mon, 2 Mar 2026 16:42:58 +0100 Bartosz Golaszewski <brgl@kernel.org> wrote: > On Mon, Mar 2, 2026 at 4:11 PM Andreas Kemnade <andreas@kemnade.info> wrote: > > > > On Mon, 2 Mar 2026 12:38:27 +0200 > > Kalle Niemi <kaleposti@gmail.com> wrote: > > > > > On 3/2/26 10:55, Bartosz Golaszewski wrote: > > > > On Mon, Mar 2, 2026 at 8:47 AM Kalle Niemi <kaleposti@gmail.com> wrote: > > > >> On 2/23/26 11:05, Bartosz Golaszewski wrote: > > > >>> In order to stop i2c bus drivers from dereferencing the struct device > > > >>> embedded in struct i2c_adapter, let's allow configuring the parent > > > >>> device and OF-node of the adapter directly through dedicated fields. > > > >>> Signed-off-by: Bartosz Golaszewski <bartosz.golaszewski@oss.qualcomm.com> > > > >>> --- > > > >> Hello, > > > >> Automated driver test system bisected this commit to be the first bad > > > >> commit, linux-next next-20260227 was tested. Failed tests include driver > > > >> tests for ROHM PMIC and accelerometers, which are connected to > > > >> BeagleBone Black. > > > >> The failed driver tests all fail to first i2cget and the tests stop > > > >> there: "Could not open file '/dev/i2c-2' or 'dev/i2c/2': No such file or > > > >> directory". > > > > Wolfram: well, now it would actually be useful to know which commit > > > > exactly is the culprit so maybe splitting the changes is not a bad > > > > idea after all. > > > > Kalle: which i2c bus driver fails here? Any errors in kernel log? > > > > Bart > > > > > > Hello Bart, > > > > > > i2c-1 and i2c-2 are failing. I am not seeing any i2c errors in kernel log. I got two failures without the dmesg available (this is bugged test sequence, and not a kernel crash), but those got the same stdout message "Could not open file ...." as all others. > > > > > Probably I am using the same host driver > > > > tested on OMAP3 DM3730, result: i2c drivers get bound to their devices, > > no obvious trouble. But controllers are registered with high indexes. > > > > localhost:~# i2cdetect -l > > i2c-3 i2c OMAP I2C adapter I2C adapter > > i2c-4 i2c OMAP I2C adapter I2C adapter > > i2c-5 i2c OMAP I2C adapter I2C adapter > > localhost:~# uname -a > > Linux localhost 7.0.0-rc1-next-20260227 #27 SMP Mon Mar 2 11:56:27 CET 2026 armv7l Linux > > > > Regards, > > Andreas > > Hi! Does the change I posted earlier in this thread help? > It does *not* as written earlier. Just for comparison, with the offending patch reverted, it looks like this: localhost:~# i2cdetect -l i2c-0 i2c OMAP I2C adapter I2C adapter i2c-1 i2c OMAP I2C adapter I2C adapter i2c-2 i2c OMAP I2C adapter I2C adapter So as long only kernel drivers are used and matched via devicetree compatible nothing seems to care about the change of bus numbers. Regards, Andreas ^ permalink raw reply [flat|nested] 9+ messages in thread
* [PATCH v2 00/12] i2c: configure parent device and OF node through the adapter struct
@ 2026-02-23 9:05 Bartosz Golaszewski
2026-02-23 9:05 ` [PATCH v2 01/12] i2c: allow setting the " Bartosz Golaszewski
0 siblings, 1 reply; 9+ messages in thread
From: Bartosz Golaszewski @ 2026-02-23 9:05 UTC (permalink / raw)
To: Wolfram Sang, Mukesh Kumar Savaliya, Viken Dadhaniya, Andi Shyti,
Florian Fainelli, Ray Jui, Scott Branden,
Broadcom internal kernel review list, Vignesh R, Aaro Koskinen,
Janusz Krzysztofik, Tony Lindgren, Andreas Kemnade, Kevin Hilman,
Roger Quadros, Geert Uytterhoeven, Magnus Damm, Patrice Chotard,
Shawn Guo, Sascha Hauer, Pengutronix Kernel Team, Fabio Estevam,
Linus Walleij, Frank Li
Cc: Bartosz Golaszewski, linux-i2c, linux-kernel, linux-arm-msm,
linux-omap, linux-renesas-soc, linux-arm-kernel, imx,
linux-rpi-kernel, Bartosz Golaszewski
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.
This series addresses the usage of adap->dev in probe() callbacks where
drivers assign the parent device address and the associated OF-node
directly to the struct device embedded in i2c_adapter. We extend the
latter struct to accept the parent struct device and of_node directly
and make it assign it to its internal struct device inside
i2c_register_adapter(). For now just 12 patches but I'll keep on doing it
if these get accepted. Once these get upstream for v6.20/7.0, we'll be
able to also start converting i2c drivers outside of drivers/i2c/.
Link: https://lore.kernel.org/all/20251106152330.11733-1-tzungbi@kernel.org/
Signed-off-by: Bartosz Golaszewski <bartosz.golaszewski@oss.qualcomm.com>
---
Changes in v2:
- fix a NULL-pointer dereference in gpio-rcar (Geert)
- rebase on top of v7.0-rc1
- collect tags
- Link to v1: https://lore.kernel.org/r/20251223-i2c-adap-dev-config-v1-0-4829b1cf0834@oss.qualcomm.com
---
Bartosz Golaszewski (12):
i2c: allow setting the parent device and OF node through the adapter struct
i2c: qcom-geni: set device parent and of_node through the adapter struct
i2c: bcm-kona: set device parent and of_node through the adapter struct
i2c: keba: set device parent and of_node through the adapter struct
i2c: omap: set device parent and of_node through the adapter struct
i2c: rcar: set device parent and of_node through the adapter struct
i2c: st: set device parent and of_node through the adapter struct
i2c: mxs: set device parent and of_node through the adapter struct
i2c: highlander: set device parent and of_node through the adapter struct
i2c: gpio: set device parent and of_node through the adapter struct
i2c: nomadik: set device parent and of_node through the adapter struct
i2c: bcm2835: set device parent and of_node through the adapter struct
drivers/i2c/busses/i2c-bcm-kona.c | 4 ++--
drivers/i2c/busses/i2c-bcm2835.c | 4 ++--
drivers/i2c/busses/i2c-gpio.c | 2 +-
drivers/i2c/busses/i2c-highlander.c | 2 +-
drivers/i2c/busses/i2c-keba.c | 2 +-
drivers/i2c/busses/i2c-mxs.c | 4 ++--
drivers/i2c/busses/i2c-nomadik.c | 4 ++--
drivers/i2c/busses/i2c-omap.c | 4 ++--
drivers/i2c/busses/i2c-qcom-geni.c | 4 ++--
drivers/i2c/busses/i2c-rcar.c | 6 +++---
drivers/i2c/busses/i2c-st.c | 4 ++--
drivers/i2c/i2c-core-base.c | 5 +++++
include/linux/i2c.h | 4 ++++
13 files changed, 29 insertions(+), 20 deletions(-)
---
base-commit: 6de23f81a5e08be8fbf5e8d7e9febc72a5b5f27f
change-id: 20251223-i2c-adap-dev-config-9403ab811795
Best regards,
--
Bartosz Golaszewski <bartosz.golaszewski@oss.qualcomm.com>
^ permalink raw reply [flat|nested] 9+ messages in thread* [PATCH v2 01/12] i2c: allow setting the parent device and OF node through the adapter struct 2026-02-23 9:05 [PATCH v2 00/12] i2c: configure " Bartosz Golaszewski @ 2026-02-23 9:05 ` Bartosz Golaszewski 2026-03-02 7:47 ` Kalle Niemi 0 siblings, 1 reply; 9+ messages in thread From: Bartosz Golaszewski @ 2026-02-23 9:05 UTC (permalink / raw) To: Wolfram Sang, Mukesh Kumar Savaliya, Viken Dadhaniya, Andi Shyti, Florian Fainelli, Ray Jui, Scott Branden, Broadcom internal kernel review list, Vignesh R, Aaro Koskinen, Janusz Krzysztofik, Tony Lindgren, Andreas Kemnade, Kevin Hilman, Roger Quadros, Geert Uytterhoeven, Magnus Damm, Patrice Chotard, Shawn Guo, Sascha Hauer, Pengutronix Kernel Team, Fabio Estevam, Linus Walleij, Frank Li Cc: Bartosz Golaszewski, linux-i2c, linux-kernel, linux-arm-msm, linux-omap, linux-renesas-soc, linux-arm-kernel, imx, linux-rpi-kernel, Bartosz Golaszewski In order to stop i2c bus drivers from dereferencing the struct device embedded in struct i2c_adapter, let's allow configuring the parent device and OF-node of the adapter directly through dedicated fields. Signed-off-by: Bartosz Golaszewski <bartosz.golaszewski@oss.qualcomm.com> --- drivers/i2c/i2c-core-base.c | 5 +++++ include/linux/i2c.h | 4 ++++ 2 files changed, 9 insertions(+) diff --git a/drivers/i2c/i2c-core-base.c b/drivers/i2c/i2c-core-base.c index 9c46147e3506d15d53b9b7d6b592709de56e41b9..dd8cec9b04c64b8340d20e018ab5ba28f1f7f5c9 100644 --- a/drivers/i2c/i2c-core-base.c +++ b/drivers/i2c/i2c-core-base.c @@ -1561,6 +1561,11 @@ static int i2c_register_adapter(struct i2c_adapter *adap) adap->dev.type = &i2c_adapter_type; device_initialize(&adap->dev); + if (!adap->dev.parent) + adap->dev.parent = adap->parent; + if (!adap->dev.of_node) + adap->dev.of_node = adap->of_node; + /* * This adapter can be used as a parent immediately after device_add(), * setup runtime-pm (especially ignore-children) before hand. diff --git a/include/linux/i2c.h b/include/linux/i2c.h index 20fd41b51d5c85ee1665395c07345faafd8e2fca..72677f29aff161530bc3c497d1e07144a44eb9e4 100644 --- a/include/linux/i2c.h +++ b/include/linux/i2c.h @@ -761,6 +761,10 @@ struct i2c_adapter { struct irq_domain *host_notify_domain; struct regulator *bus_regulator; + /* Device configuration. */ + struct device *parent; + struct device_node *of_node; + struct dentry *debugfs; /* 7bit address space */ -- 2.47.3 ^ permalink raw reply related [flat|nested] 9+ messages in thread
* Re: [PATCH v2 01/12] i2c: allow setting the parent device and OF node through the adapter struct 2026-02-23 9:05 ` [PATCH v2 01/12] i2c: allow setting the " Bartosz Golaszewski @ 2026-03-02 7:47 ` Kalle Niemi 2026-03-02 8:55 ` Bartosz Golaszewski 0 siblings, 1 reply; 9+ messages in thread From: Kalle Niemi @ 2026-03-02 7:47 UTC (permalink / raw) To: Bartosz Golaszewski, Wolfram Sang, Mukesh Kumar Savaliya, Viken Dadhaniya, Andi Shyti, Florian Fainelli, Ray Jui, Scott Branden, Broadcom internal kernel review list, Vignesh R, Aaro Koskinen, Janusz Krzysztofik, Tony Lindgren, Andreas Kemnade, Kevin Hilman, Roger Quadros, Geert Uytterhoeven, Magnus Damm, Patrice Chotard, Shawn Guo, Sascha Hauer, Pengutronix Kernel Team, Fabio Estevam, Linus Walleij, Frank Li Cc: Bartosz Golaszewski, linux-i2c, linux-kernel, linux-arm-msm, linux-omap, linux-renesas-soc, linux-arm-kernel, imx, linux-rpi-kernel, Matti Vaittinen On 2/23/26 11:05, Bartosz Golaszewski wrote: > In order to stop i2c bus drivers from dereferencing the struct device > embedded in struct i2c_adapter, let's allow configuring the parent > device and OF-node of the adapter directly through dedicated fields. > > Signed-off-by: Bartosz Golaszewski <bartosz.golaszewski@oss.qualcomm.com> > --- > drivers/i2c/i2c-core-base.c | 5 +++++ > include/linux/i2c.h | 4 ++++ > 2 files changed, 9 insertions(+) > > diff --git a/drivers/i2c/i2c-core-base.c b/drivers/i2c/i2c-core-base.c > index 9c46147e3506d15d53b9b7d6b592709de56e41b9..dd8cec9b04c64b8340d20e018ab5ba28f1f7f5c9 100644 > --- a/drivers/i2c/i2c-core-base.c > +++ b/drivers/i2c/i2c-core-base.c > @@ -1561,6 +1561,11 @@ static int i2c_register_adapter(struct i2c_adapter *adap) > adap->dev.type = &i2c_adapter_type; > device_initialize(&adap->dev); > > + if (!adap->dev.parent) > + adap->dev.parent = adap->parent; > + if (!adap->dev.of_node) > + adap->dev.of_node = adap->of_node; > + > /* > * This adapter can be used as a parent immediately after device_add(), > * setup runtime-pm (especially ignore-children) before hand. > diff --git a/include/linux/i2c.h b/include/linux/i2c.h > index 20fd41b51d5c85ee1665395c07345faafd8e2fca..72677f29aff161530bc3c497d1e07144a44eb9e4 100644 > --- a/include/linux/i2c.h > +++ b/include/linux/i2c.h > @@ -761,6 +761,10 @@ struct i2c_adapter { > struct irq_domain *host_notify_domain; > struct regulator *bus_regulator; > > + /* Device configuration. */ > + struct device *parent; > + struct device_node *of_node; > + > struct dentry *debugfs; > > /* 7bit address space */ > Hello, Automated driver test system bisected this commit to be the first bad commit, linux-next next-20260227 was tested. Failed tests include driver tests for ROHM PMIC and accelerometers, which are connected to BeagleBone Black. The failed driver tests all fail to first i2cget and the tests stop there: "Could not open file '/dev/i2c-2' or 'dev/i2c/2': No such file or directory". BR Kalle Niemi ^ permalink raw reply [flat|nested] 9+ messages in thread
* Re: [PATCH v2 01/12] i2c: allow setting the parent device and OF node through the adapter struct 2026-03-02 7:47 ` Kalle Niemi @ 2026-03-02 8:55 ` Bartosz Golaszewski 0 siblings, 0 replies; 9+ messages in thread From: Bartosz Golaszewski @ 2026-03-02 8:55 UTC (permalink / raw) To: Kalle Niemi, Wolfram Sang Cc: Bartosz Golaszewski, Mukesh Kumar Savaliya, Viken Dadhaniya, Andi Shyti, Florian Fainelli, Ray Jui, Scott Branden, Broadcom internal kernel review list, Vignesh R, Aaro Koskinen, Janusz Krzysztofik, Tony Lindgren, Andreas Kemnade, Kevin Hilman, Roger Quadros, Geert Uytterhoeven, Magnus Damm, Patrice Chotard, Shawn Guo, Sascha Hauer, Pengutronix Kernel Team, Fabio Estevam, Linus Walleij, Frank Li, linux-i2c, linux-kernel, linux-arm-msm, linux-omap, linux-renesas-soc, linux-arm-kernel, imx, linux-rpi-kernel, Matti Vaittinen On Mon, Mar 2, 2026 at 8:47 AM Kalle Niemi <kaleposti@gmail.com> wrote: > > On 2/23/26 11:05, Bartosz Golaszewski wrote: > > In order to stop i2c bus drivers from dereferencing the struct device > > embedded in struct i2c_adapter, let's allow configuring the parent > > device and OF-node of the adapter directly through dedicated fields. > > > > Signed-off-by: Bartosz Golaszewski <bartosz.golaszewski@oss.qualcomm.com> > > --- > > > > Hello, > > Automated driver test system bisected this commit to be the first bad > commit, linux-next next-20260227 was tested. Failed tests include driver > tests for ROHM PMIC and accelerometers, which are connected to > BeagleBone Black. > > The failed driver tests all fail to first i2cget and the tests stop > there: "Could not open file '/dev/i2c-2' or 'dev/i2c/2': No such file or > directory". > Wolfram: well, now it would actually be useful to know which commit exactly is the culprit so maybe splitting the changes is not a bad idea after all. Kalle: which i2c bus driver fails here? Any errors in kernel log? Bart ^ permalink raw reply [flat|nested] 9+ messages in thread
end of thread, other threads:[~2026-03-02 16:59 UTC | newest]
Thread overview: 9+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
[not found] <EDF3FB58-4747-442E-8463-6F1C6E568962@gmail.com>
2026-03-02 11:08 ` [PATCH v2 01/12] i2c: allow setting the parent device and OF node through the adapter struct Bartosz Golaszewski
2026-03-02 15:59 ` Andreas Kemnade
2026-03-02 16:56 ` Andreas Kemnade
2026-03-02 15:09 ` Andreas Kemnade
2026-03-02 15:42 ` Bartosz Golaszewski
2026-03-02 16:14 ` Andreas Kemnade
2026-02-23 9:05 [PATCH v2 00/12] i2c: configure " Bartosz Golaszewski
2026-02-23 9:05 ` [PATCH v2 01/12] i2c: allow setting the " Bartosz Golaszewski
2026-03-02 7:47 ` Kalle Niemi
2026-03-02 8:55 ` Bartosz Golaszewski
This is a public inbox, see mirroring instructions for how to clone and mirror all data and code used for this inbox