* [PATCH] i2c: Let users disable "Probe an I2C bus for certain devices" @ 2013-06-04 17:33 Grygorii Strashko 2013-06-04 17:49 ` Wolfram Sang 0 siblings, 1 reply; 13+ messages in thread From: Grygorii Strashko @ 2013-06-04 17:33 UTC (permalink / raw) To: Wolfram Sang; +Cc: Grygorii Strashko, linux-i2c, linux-kernel, linux-omap Currently the I2C devices instantiation Method 3 "Probe an I2C bus for certain devices" (see Documentation/i2c/instantiating-devices) is always enabled for all platforms (boards) and can't be disabled. This feature introduces a system boot time delay for boards, where I2C devices topology is explicitly defined in DT or platform code (Method 1 and Method 2 are used only) and especially when i2c-gpio is used. For example: When CONFIG_SENSORS_LM75 option was enabled for omap4-sdp board - it introduces 5-6 ms boot delay. When CONFIG_SENSORS_LM75 option was enabled for omap5-uevm board, where i2c-gpio is used for HDMI edid reading - it introduces up to 5 sec boot delay. Hence, introduce CONFIG_I2C_DISABLE_DEVICE_DETECTION configuration option to allow disabling of I2C devices instantiation Method 3 "Probe an I2C bus for certain devices" if it's not needed (usually for embedded systems). CC: linux-i2c@vger.kernel.org CC: linux-kernel@vger.kernel.org CC: linux-omap@vger.kernel.org Signed-off-by: Grygorii Strashko <grygorii.strashko@ti.com> --- drivers/i2c/Kconfig | 10 ++++++++++ drivers/i2c/i2c-core.c | 6 ++++++ 2 files changed, 16 insertions(+) diff --git a/drivers/i2c/Kconfig b/drivers/i2c/Kconfig index e380c6e..f7b220b 100644 --- a/drivers/i2c/Kconfig +++ b/drivers/i2c/Kconfig @@ -124,4 +124,14 @@ config I2C_DEBUG_BUS a problem with I2C support and want to see more of what is going on. +config I2C_DISABLE_DEVICE_DETECTION + bool "I2C Disable device detection" + default n + help + Say Y here, if you have explicitly defined I2C device topology in DT + or platform code and don't need to detect presence of supported I2C + devices automatically (Documentation/i2c/instantiating-devices - + Method 1 and Method 2 are used only). Enabling this option allows to + reduce system boot time, especially in case when i2c-gpio driver is used. + endif # I2C diff --git a/drivers/i2c/i2c-core.c b/drivers/i2c/i2c-core.c index 48e31ed..d5ab7a3 100644 --- a/drivers/i2c/i2c-core.c +++ b/drivers/i2c/i2c-core.c @@ -54,7 +54,9 @@ static DEFINE_MUTEX(core_lock); static DEFINE_IDR(i2c_adapter_idr); static struct device_type i2c_client_type; +#ifndef CONFIG_I2C_DISABLE_DEVICE_DETECTION static int i2c_detect(struct i2c_adapter *adapter, struct i2c_driver *driver); +#endif /* ------------------------------------------------------------------------- */ @@ -958,7 +960,9 @@ static int i2c_do_add_adapter(struct i2c_driver *driver, struct i2c_adapter *adap) { /* Detect supported devices on that bus, and instantiate them */ +#ifndef CONFIG_I2C_DISABLE_DEVICE_DETECTION i2c_detect(adap, driver); +#endif /* Let legacy drivers scan this bus for matching devices */ if (driver->attach_adapter) { @@ -1672,6 +1676,7 @@ static int i2c_default_probe(struct i2c_adapter *adap, unsigned short addr) return err >= 0; } +#ifndef CONFIG_I2C_DISABLE_DEVICE_DETECTION static int i2c_detect_address(struct i2c_client *temp_client, struct i2c_driver *driver) { @@ -1760,6 +1765,7 @@ static int i2c_detect(struct i2c_adapter *adapter, struct i2c_driver *driver) kfree(temp_client); return err; } +#endif int i2c_probe_func_quick_read(struct i2c_adapter *adap, unsigned short addr) { -- 1.7.9.5 ^ permalink raw reply related [flat|nested] 13+ messages in thread
* Re: [PATCH] i2c: Let users disable "Probe an I2C bus for certain devices" 2013-06-04 17:33 [PATCH] i2c: Let users disable "Probe an I2C bus for certain devices" Grygorii Strashko @ 2013-06-04 17:49 ` Wolfram Sang 2013-06-05 16:13 ` Grygorii Strashko 0 siblings, 1 reply; 13+ messages in thread From: Wolfram Sang @ 2013-06-04 17:49 UTC (permalink / raw) To: Grygorii Strashko; +Cc: linux-i2c, linux-kernel, linux-omap [-- Attachment #1: Type: text/plain, Size: 405 bytes --] On Tue, Jun 04, 2013 at 08:33:42PM +0300, Grygorii Strashko wrote: > Currently the I2C devices instantiation Method 3 "Probe an I2C bus for > certain devices" (see Documentation/i2c/instantiating-devices) is always > enabled for all platforms (boards) and can't be disabled. Not true. Set .class = 0 for your adapter. I always ask authors of new drivers if they really need to set .class to something. [-- Attachment #2: Digital signature --] [-- Type: application/pgp-signature, Size: 836 bytes --] ^ permalink raw reply [flat|nested] 13+ messages in thread
* Re: [PATCH] i2c: Let users disable "Probe an I2C bus for certain devices" 2013-06-04 17:49 ` Wolfram Sang @ 2013-06-05 16:13 ` Grygorii Strashko 2013-06-07 9:06 ` Wolfram Sang 0 siblings, 1 reply; 13+ messages in thread From: Grygorii Strashko @ 2013-06-05 16:13 UTC (permalink / raw) To: Wolfram Sang; +Cc: linux-i2c, linux-kernel, linux-omap Hi On 06/04/2013 08:49 PM, Wolfram Sang wrote: > On Tue, Jun 04, 2013 at 08:33:42PM +0300, Grygorii Strashko wrote: > >> Currently the I2C devices instantiation Method 3 "Probe an I2C bus for >> certain devices" (see Documentation/i2c/instantiating-devices) is always >> enabled for all platforms (boards) and can't be disabled. > Not true. Set .class = 0 for your adapter. I always ask authors of new > drivers if they really need to set .class to something. > Agree, sorry, my statement is wrong. it would be right to say "..can't be disabled without kernel code modification". Few notes here: 1) boot delay issue isn't related to new drivers. There are hwmon/lm75.c, i2c/busses/i2c-gpio.c and i2c/busses/i2c-omap.c 2) Initially, I've fighted with it on TI K3.4 product kernel where DT isn't supported yet. And first thing, which I've tried to do is to correct .class parameter for adapter, but with assumption: "Default behavior shouldn't be changed as I2C detection might be used by some of OMAP boards". I've started from i2c-omap.c and OMAP4/5 (my target). As result, I was need to make changes in *7* files to set and pass platform parameter to i2c-omap.c driver which will allow to change .class to 0 on demand. At this point, I've realized that i still need to deal with i2c-gpio.c - which is generic driver. 3) Thinking about Mainline: To reach the same target - no I2C detection - and taking into account above assumption "No changes in default behavior" the following will need to be done: - change i2c-omap/i2c-gpio DT bindings and add parameter which will allow to change .class value for adapter. Not sure, it's possible because this parameter will be Linux and not HW specific (smth. like "i2c_disable_detection") - update drivers i2c-omap/i2c-gpio to use "i2c_disable_detection" - update OMAP4/5 DTS files So, It seemed a good solution for me to add 6 lines of code in i2c-core.c instead of doing all that stuff. Thanks/sorry for your time. - grygorii ^ permalink raw reply [flat|nested] 13+ messages in thread
* Re: [PATCH] i2c: Let users disable "Probe an I2C bus for certain devices" 2013-06-05 16:13 ` Grygorii Strashko @ 2013-06-07 9:06 ` Wolfram Sang 2013-06-07 9:09 ` [RFC] i2c: add deprecation warning for class based instantiation Wolfram Sang 2013-06-07 10:10 ` [PATCH] i2c: Let users disable "Probe an I2C bus for certain devices" Grygorii Strashko 0 siblings, 2 replies; 13+ messages in thread From: Wolfram Sang @ 2013-06-07 9:06 UTC (permalink / raw) To: Grygorii Strashko; +Cc: linux-i2c, linux-kernel, linux-omap [-- Attachment #1: Type: text/plain, Size: 1103 bytes --] > 3) Thinking about Mainline: To reach the same target - no I2C > detection - and taking > into account above assumption "No changes in default behavior" > the following will need to be done: > - change i2c-omap/i2c-gpio DT bindings and add parameter which will > allow to change > .class value for adapter. Not sure, it's possible because this parameter > will be Linux and not HW specific (smth. like "i2c_disable_detection") > - update drivers i2c-omap/i2c-gpio to use "i2c_disable_detection" > - update OMAP4/5 DTS files > > So, It seemed a good solution for me to add 6 lines of code in i2c-core.c > instead of doing all that stuff. Well... I understand the "default behaviour" issue, yet I still think that setting class to 0 is the right thing to do. OMAP is an embedded SoC which always had i2c_board_info or devictree which are the preferred ways of instantiating. Given that, I would accept a patch setting it to 0. The more user friendly way might be to introduce a new class which makes users aware of the issue. Proof of concept follows, only compile tested. [-- Attachment #2: Digital signature --] [-- Type: application/pgp-signature, Size: 836 bytes --] ^ permalink raw reply [flat|nested] 13+ messages in thread
* [RFC] i2c: add deprecation warning for class based instantiation 2013-06-07 9:06 ` Wolfram Sang @ 2013-06-07 9:09 ` Wolfram Sang 2013-06-19 10:15 ` Wolfram Sang ` (2 more replies) 2013-06-07 10:10 ` [PATCH] i2c: Let users disable "Probe an I2C bus for certain devices" Grygorii Strashko 1 sibling, 3 replies; 13+ messages in thread From: Wolfram Sang @ 2013-06-07 9:09 UTC (permalink / raw) To: Grygorii Strashko; +Cc: linux-i2c, linux-kernel, linux-omap, Wolfram Sang Class based instantiation can cause huge delays when booting. This mechanism was used when it was not possible to describe slaves on I2C busses. We now have other mechanisms, so most embedded I2C will not need classes and it was explicitly not recommended to use them. Add a deprecation warning for drivers who want to disable class based in the near future to gain boot-up time, so users relying on this technique can switch to something better. They really should. Signed-off-by: Wolfram Sang <wsa@the-dreams.de> --- drivers/i2c/busses/i2c-omap.c | 2 +- drivers/i2c/i2c-core.c | 6 ++++++ include/linux/i2c.h | 1 + 3 files changed, 8 insertions(+), 1 deletion(-) diff --git a/drivers/i2c/busses/i2c-omap.c b/drivers/i2c/busses/i2c-omap.c index e02f9e3..f06109f 100644 --- a/drivers/i2c/busses/i2c-omap.c +++ b/drivers/i2c/busses/i2c-omap.c @@ -1231,7 +1231,7 @@ omap_i2c_probe(struct platform_device *pdev) adap = &dev->adapter; i2c_set_adapdata(adap, dev); adap->owner = THIS_MODULE; - adap->class = I2C_CLASS_HWMON; + adap->class = I2C_CLASS_HWMON | I2C_CLASS_DEPRECATED; strlcpy(adap->name, "OMAP I2C adapter", sizeof(adap->name)); adap->algo = &omap_i2c_algo; adap->dev.parent = &pdev->dev; diff --git a/drivers/i2c/i2c-core.c b/drivers/i2c/i2c-core.c index 48e31ed..47ea1f0 100644 --- a/drivers/i2c/i2c-core.c +++ b/drivers/i2c/i2c-core.c @@ -999,6 +999,12 @@ static int i2c_register_adapter(struct i2c_adapter *adap) return -EINVAL; } + if (adap->class & I2C_CLASS_DEPRECATED) + dev_warn(&adap->dev, "This adapter will soon drop class based " + "instantiation of slaves\nPlease make sure all its I2C " + "devices are instantiated by other means.\nCheck " + "'Documentation/i2c/instantiating-devices' for details\n"); + rt_mutex_init(&adap->bus_lock); mutex_init(&adap->userspace_clients_lock); INIT_LIST_HEAD(&adap->userspace_clients); diff --git a/include/linux/i2c.h b/include/linux/i2c.h index e988fa9..ffab838 100644 --- a/include/linux/i2c.h +++ b/include/linux/i2c.h @@ -473,6 +473,7 @@ void i2c_unlock_adapter(struct i2c_adapter *); #define I2C_CLASS_HWMON (1<<0) /* lm_sensors, ... */ #define I2C_CLASS_DDC (1<<3) /* DDC bus on graphics adapters */ #define I2C_CLASS_SPD (1<<7) /* Memory modules */ +#define I2C_CLASS_DEPRECATED (1<<8) /* Warn users that adapter will stop using classes */ /* Internal numbers to terminate lists */ #define I2C_CLIENT_END 0xfffeU -- 1.7.10.4 ^ permalink raw reply related [flat|nested] 13+ messages in thread
* Re: [RFC] i2c: add deprecation warning for class based instantiation 2013-06-07 9:09 ` [RFC] i2c: add deprecation warning for class based instantiation Wolfram Sang @ 2013-06-19 10:15 ` Wolfram Sang 2013-06-19 18:21 ` Grygorii Strashko 2013-06-19 18:22 ` Grygorii Strashko 2013-06-19 18:22 ` [RFC 1/2] i2c: omap: drop class based instantiation of slaves Grygorii Strashko 2 siblings, 1 reply; 13+ messages in thread From: Wolfram Sang @ 2013-06-19 10:15 UTC (permalink / raw) To: Grygorii Strashko; +Cc: linux-i2c, linux-kernel, linux-omap [-- Attachment #1: Type: text/plain, Size: 650 bytes --] On Fri, Jun 07, 2013 at 11:09:26AM +0200, Wolfram Sang wrote: > Class based instantiation can cause huge delays when booting. This > mechanism was used when it was not possible to describe slaves on I2C > busses. We now have other mechanisms, so most embedded I2C will not need > classes and it was explicitly not recommended to use them. Add a > deprecation warning for drivers who want to disable class based in the > near future to gain boot-up time, so users relying on this technique can > switch to something better. They really should. > > Signed-off-by: Wolfram Sang <wsa@the-dreams.de> No reactions on this, pity. Deferring. [-- Attachment #2: Digital signature --] [-- Type: application/pgp-signature, Size: 836 bytes --] ^ permalink raw reply [flat|nested] 13+ messages in thread
* Re: [RFC] i2c: add deprecation warning for class based instantiation 2013-06-19 10:15 ` Wolfram Sang @ 2013-06-19 18:21 ` Grygorii Strashko 2013-06-20 18:37 ` Wolfram Sang 0 siblings, 1 reply; 13+ messages in thread From: Grygorii Strashko @ 2013-06-19 18:21 UTC (permalink / raw) To: Wolfram Sang; +Cc: linux-i2c, linux-kernel, linux-omap Hi Wolfram, On 06/19/2013 01:15 PM, Wolfram Sang wrote: > On Fri, Jun 07, 2013 at 11:09:26AM +0200, Wolfram Sang wrote: >> Class based instantiation can cause huge delays when booting. This >> mechanism was used when it was not possible to describe slaves on I2C >> busses. We now have other mechanisms, so most embedded I2C will not need >> classes and it was explicitly not recommended to use them. Add a >> deprecation warning for drivers who want to disable class based in the >> near future to gain boot-up time, so users relying on this technique can >> switch to something better. They really should. >> >> Signed-off-by: Wolfram Sang <wsa@the-dreams.de> > No reactions on this, pity. Deferring. > Sorry, for delayed reply - I've had problems with my e-mail. I've tested this patch on our TI K3.4 product kernel with additional change below: diff --git a/drivers/i2c/busses/i2c-gpio.c b/drivers/i2c/busses/i2c-gpio.c index c0330a4..442101d 100644 --- a/drivers/i2c/busses/i2c-gpio.c +++ b/drivers/i2c/busses/i2c-gpio.c @@ -186,7 +186,7 @@ static int __devinit i2c_gpio_probe(struct platform_device *pdev) adap->owner = THIS_MODULE; snprintf(adap->name, sizeof(adap->name), "i2c-gpio%d", pdev->id); adap->algo_data = bit_data; - adap->class = I2C_CLASS_HWMON | I2C_CLASS_SPD; + adap->class = I2C_CLASS_HWMON | I2C_CLASS_SPD | I2C_CLASS_DEPRECATED; adap->dev.parent = &pdev->dev; adap->dev.of_node = pdev->dev.of_node; It works fine, in general - see my minor comment inline. [ 0.662536] omap_i2c omap_i2c.2: bus 2 rev2.4.0 at 400 kHz [ 0.662567] (null): This adapter will soon drop class based instantiation of slaves ^^^^^ invalid adapter device name here [ 0.662567] Please make sure all its I2C devices are instantiated by other means. [ 0.662567] Check 'Documentation/i2c/instantiating-devices' for details Also tested on Linux master - OMAP4 SDP board. In addition, I've found the following users of *i2c-gpio* (just FYI): ./arch/powerpc/boot/dts/wii.dts: compatible = "i2c-gpio"; ./arch/mips/alchemy/board-gpr.c: .name = "i2c-gpio", ./arch/mips/ath79/mach-pb44.c: .name = "i2c-gpio", ./arch/avr32/boards/merisc/setup.c: .name = "i2c-gpio", ./arch/avr32/boards/atngw100/setup.c: .name = "i2c-gpio", ./arch/avr32/boards/hammerhead/setup.c: .name = "i2c-gpio", ./arch/avr32/boards/mimc200/setup.c: .name = "i2c-gpio", ./arch/blackfin/mach-bf533/boards/blackstamp.c: .name = "i2c-gpio", ./arch/blackfin/mach-bf533/boards/ezkit.c: .name = "i2c-gpio", ./arch/blackfin/mach-bf533/boards/stamp.c: .name = "i2c-gpio", ./arch/blackfin/mach-bf561/boards/ezkit.c: .name = "i2c-gpio", ./arch/arm/mach-ep93xx/core.c: .name = "i2c-gpio", ./arch/arm/mach-shmobile/board-armadillo800eva.c: .name = "i2c-gpio", ./arch/arm/mach-pxa/viper.c: .name = "i2c-gpio", ./arch/arm/mach-pxa/viper.c: tpm_device = platform_device_alloc("i2c-gpio", 2); ./arch/arm/mach-pxa/palmz72.c: .name = "i2c-gpio", ./arch/arm/boot/dts/at91sam9g45.dtsi: compatible = "i2c-gpio"; ./arch/arm/boot/dts/at91sam9263.dtsi: compatible = "i2c-gpio"; ./arch/arm/boot/dts/at91sam9x5.dtsi: compatible = "i2c-gpio"; ./arch/arm/boot/dts/at91sam9x5.dtsi: compatible = "i2c-gpio"; ./arch/arm/boot/dts/at91sam9x5.dtsi: compatible = "i2c-gpio"; ./arch/arm/boot/dts/usb_a9g20-dab-mmx.dtsi: i2c-gpio@0 { ./arch/arm/boot/dts/ste-nomadik-stn8815.dtsi: compatible = "i2c-gpio"; ./arch/arm/boot/dts/ste-nomadik-stn8815.dtsi: compatible = "i2c-gpio"; ./arch/arm/boot/dts/ste-nomadik-stn8815.dtsi: compatible = "i2c-gpio"; ./arch/arm/boot/dts/at91sam9260.dtsi: compatible = "i2c-gpio"; ./arch/arm/boot/dts/at91rm9200.dtsi: compatible = "i2c-gpio"; ./arch/arm/boot/dts/at91sam9n12.dtsi: compatible = "i2c-gpio"; ./arch/arm/mach-ks8695/board-acs5k.c: .name = "i2c-gpio", ./arch/arm/mach-s5pv210/mach-goni.c: .name = "i2c-gpio", ./arch/arm/mach-s5pv210/mach-goni.c: .name = "i2c-gpio", ./arch/arm/mach-s5pv210/mach-aquila.c: .name = "i2c-gpio", ./arch/arm/mach-s5pv210/mach-aquila.c: .name = "i2c-gpio", ./arch/arm/mach-sa1100/simpad.c: .name = "i2c-gpio", ./arch/arm/mach-exynos/mach-universal_c210.c: .name = "i2c-gpio", ./arch/arm/mach-exynos/mach-nuri.c: .name = "i2c-gpio", ./arch/arm/mach-at91/at91sam9263_devices.c: .name = "i2c-gpio", ./arch/arm/mach-at91/at91sam9261_devices.c: .name = "i2c-gpio", ./arch/arm/mach-at91/at91sam9g45_devices.c: .name = "i2c-gpio", ./arch/arm/mach-at91/at91sam9g45_devices.c: .name = "i2c-gpio", ./arch/arm/mach-at91/at91rm9200_devices.c: .name = "i2c-gpio", ./arch/arm/mach-at91/at91sam9260_devices.c: .name = "i2c-gpio", ./arch/arm/mach-at91/at91sam9rl_devices.c: .name = "i2c-gpio", ./arch/arm/mach-imx/mach-cpuimx51sd.c: .name = "i2c-gpio", ./arch/arm/mach-ixp4xx/nslu2-setup.c: .name = "i2c-gpio", ./arch/arm/mach-ixp4xx/nas100d-setup.c: .name = "i2c-gpio", ./arch/arm/mach-ixp4xx/goramo_mlr.c: .name = "i2c-gpio", ./arch/arm/mach-ixp4xx/ixdp425-setup.c: .name = "i2c-gpio", ./arch/arm/mach-ixp4xx/fsg-setup.c: .name = "i2c-gpio", ./arch/arm/mach-ixp4xx/dsmg600-setup.c: .name = "i2c-gpio", ./arch/arm/mach-ixp4xx/avila-setup.c: .name = "i2c-gpio", ./drivers/mfd/sm501.c: pdev = sm501_create_subdev(sm, "i2c-gpio", 0, - grygorii ^ permalink raw reply related [flat|nested] 13+ messages in thread
* Re: [RFC] i2c: add deprecation warning for class based instantiation 2013-06-19 18:21 ` Grygorii Strashko @ 2013-06-20 18:37 ` Wolfram Sang 0 siblings, 0 replies; 13+ messages in thread From: Wolfram Sang @ 2013-06-20 18:37 UTC (permalink / raw) To: Grygorii Strashko; +Cc: linux-i2c, linux-kernel, linux-omap [-- Attachment #1: Type: text/plain, Size: 576 bytes --] Hi, > Sorry, for delayed reply - I've had problems with my e-mail. You still have. This message has unwanted linebreaks. > I've tested this patch on our TI K3.4 product kernel with additional > change below: Thanks. > [ 0.662567] (null): This adapter will soon drop class based > instantiation of slaves > ^^^^^ invalid adapter device name here Good point, thanks! Will send an updated patch in a minute. > In addition, I've found the following users of *i2c-gpio* (just FYI): Ehrm, okay, and why exactly did you post it? :) Regards, Wolfram [-- Attachment #2: Digital signature --] [-- Type: application/pgp-signature, Size: 836 bytes --] ^ permalink raw reply [flat|nested] 13+ messages in thread
* Re: [RFC] i2c: add deprecation warning for class based instantiation 2013-06-07 9:09 ` [RFC] i2c: add deprecation warning for class based instantiation Wolfram Sang 2013-06-19 10:15 ` Wolfram Sang @ 2013-06-19 18:22 ` Grygorii Strashko 2013-06-19 18:22 ` [RFC 1/2] i2c: omap: drop class based instantiation of slaves Grygorii Strashko 2 siblings, 0 replies; 13+ messages in thread From: Grygorii Strashko @ 2013-06-19 18:22 UTC (permalink / raw) To: Wolfram Sang; +Cc: linux-i2c, linux-kernel, linux-omap On 06/07/2013 12:09 PM, Wolfram Sang wrote: > Class based instantiation can cause huge delays when booting. This > mechanism was used when it was not possible to describe slaves on I2C > busses. We now have other mechanisms, so most embedded I2C will not need > classes and it was explicitly not recommended to use them. Add a > deprecation warning for drivers who want to disable class based in the > near future to gain boot-up time, so users relying on this technique can > switch to something better. They really should. > > Signed-off-by: Wolfram Sang <wsa@the-dreams.de> > --- > drivers/i2c/busses/i2c-omap.c | 2 +- > drivers/i2c/i2c-core.c | 6 ++++++ > include/linux/i2c.h | 1 + > 3 files changed, 8 insertions(+), 1 deletion(-) > > diff --git a/drivers/i2c/busses/i2c-omap.c b/drivers/i2c/busses/i2c-omap.c > index e02f9e3..f06109f 100644 > --- a/drivers/i2c/busses/i2c-omap.c > +++ b/drivers/i2c/busses/i2c-omap.c > @@ -1231,7 +1231,7 @@ omap_i2c_probe(struct platform_device *pdev) > adap = &dev->adapter; > i2c_set_adapdata(adap, dev); > adap->owner = THIS_MODULE; > - adap->class = I2C_CLASS_HWMON; > + adap->class = I2C_CLASS_HWMON | I2C_CLASS_DEPRECATED; > strlcpy(adap->name, "OMAP I2C adapter", sizeof(adap->name)); > adap->algo = &omap_i2c_algo; > adap->dev.parent = &pdev->dev; > diff --git a/drivers/i2c/i2c-core.c b/drivers/i2c/i2c-core.c > index 48e31ed..47ea1f0 100644 > --- a/drivers/i2c/i2c-core.c > +++ b/drivers/i2c/i2c-core.c > @@ -999,6 +999,12 @@ static int i2c_register_adapter(struct i2c_adapter *adap) > return -EINVAL; > } > > + if (adap->class & I2C_CLASS_DEPRECATED) > + dev_warn(&adap->dev, "This adapter will soon drop class based " > + "instantiation of slaves\nPlease make sure all its I2C " > + "devices are instantiated by other means.\nCheck " > + "'Documentation/i2c/instantiating-devices' for details\n"); > + Seems, this need to be moved down - after res = device_register(&adap->dev); - or - right before: bus_for_each_drv(&i2c_bus_type, NULL, adap, __process_new_adapter); > rt_mutex_init(&adap->bus_lock); > mutex_init(&adap->userspace_clients_lock); > INIT_LIST_HEAD(&adap->userspace_clients); > diff --git a/include/linux/i2c.h b/include/linux/i2c.h > index e988fa9..ffab838 100644 > --- a/include/linux/i2c.h > +++ b/include/linux/i2c.h > @@ -473,6 +473,7 @@ void i2c_unlock_adapter(struct i2c_adapter *); > #define I2C_CLASS_HWMON (1<<0) /* lm_sensors, ... */ > #define I2C_CLASS_DDC (1<<3) /* DDC bus on graphics adapters */ > #define I2C_CLASS_SPD (1<<7) /* Memory modules */ > +#define I2C_CLASS_DEPRECATED (1<<8) /* Warn users that adapter will stop using classes */ > > /* Internal numbers to terminate lists */ > #define I2C_CLIENT_END 0xfffeU - grygorii ^ permalink raw reply [flat|nested] 13+ messages in thread
* [RFC 1/2] i2c: omap: drop class based instantiation of slaves 2013-06-07 9:09 ` [RFC] i2c: add deprecation warning for class based instantiation Wolfram Sang 2013-06-19 10:15 ` Wolfram Sang 2013-06-19 18:22 ` Grygorii Strashko @ 2013-06-19 18:22 ` Grygorii Strashko 2013-06-19 18:22 ` [RFC 2/2] i2c: gpio: " Grygorii Strashko 2 siblings, 1 reply; 13+ messages in thread From: Grygorii Strashko @ 2013-06-19 18:22 UTC (permalink / raw) To: Wolfram Sang Cc: linux-kernel, linux-omap, linux-i2c, Grygorii Strashko, Tony Lindgren Class based instantiation mechanism can cause huge delays when booting. For example: when CONFIG_SENSORS_LM75 option is enabled for omap4-sdp board - it introduces 5-6 ms boot delay. It's not recommended to use this mechanism with embedded I2C, so disable it by leaving I2C adapter "class" field undefined (remove I2C_CLASS_HWMON). CC: Tony Lindgren <tony@atomide.com> Signed-off-by: Grygorii Strashko <grygorii.strashko@ti.com> --- drivers/i2c/busses/i2c-omap.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/drivers/i2c/busses/i2c-omap.c b/drivers/i2c/busses/i2c-omap.c index f06109f..ae2b27f 100644 --- a/drivers/i2c/busses/i2c-omap.c +++ b/drivers/i2c/busses/i2c-omap.c @@ -1231,7 +1231,7 @@ omap_i2c_probe(struct platform_device *pdev) adap = &dev->adapter; i2c_set_adapdata(adap, dev); adap->owner = THIS_MODULE; - adap->class = I2C_CLASS_HWMON | I2C_CLASS_DEPRECATED; + adap->class = I2C_CLASS_DEPRECATED; strlcpy(adap->name, "OMAP I2C adapter", sizeof(adap->name)); adap->algo = &omap_i2c_algo; adap->dev.parent = &pdev->dev; -- 1.7.9.5 ^ permalink raw reply related [flat|nested] 13+ messages in thread
* [RFC 2/2] i2c: gpio: drop class based instantiation of slaves 2013-06-19 18:22 ` [RFC 1/2] i2c: omap: drop class based instantiation of slaves Grygorii Strashko @ 2013-06-19 18:22 ` Grygorii Strashko 0 siblings, 0 replies; 13+ messages in thread From: Grygorii Strashko @ 2013-06-19 18:22 UTC (permalink / raw) To: Wolfram Sang Cc: linux-kernel, linux-omap, linux-i2c, Grygorii Strashko, Haavard Skinnemoen Class based instantiation mechanism can cause huge delays when booting. For example: when CONFIG_SENSORS_LM75 option is enabled for or omap5-uevm board, where i2c-gpio is used for HDMI edid reading - it introduces up to 5 sec boot delay. It's not recommended to use this mechanism with embedded I2C, so disable it by leaving I2C adapter "class" field undefined (remove I2C_CLASS_HWMON and I2C_CLASS_SPD) and add a deprecation warning to allow users, relying on this mechanism, to switch to something better. CC: Haavard Skinnemoen <hskinnemoen@gmail.com> Signed-off-by: Grygorii Strashko <grygorii.strashko@ti.com> --- drivers/i2c/busses/i2c-gpio.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/drivers/i2c/busses/i2c-gpio.c b/drivers/i2c/busses/i2c-gpio.c index bc6e139..33e3d0e 100644 --- a/drivers/i2c/busses/i2c-gpio.c +++ b/drivers/i2c/busses/i2c-gpio.c @@ -215,7 +215,7 @@ static int i2c_gpio_probe(struct platform_device *pdev) snprintf(adap->name, sizeof(adap->name), "i2c-gpio%d", pdev->id); adap->algo_data = bit_data; - adap->class = I2C_CLASS_HWMON | I2C_CLASS_SPD; + adap->class = I2C_CLASS_DEPRECATED; adap->dev.parent = &pdev->dev; adap->dev.of_node = pdev->dev.of_node; -- 1.7.9.5 ^ permalink raw reply related [flat|nested] 13+ messages in thread
* Re: [PATCH] i2c: Let users disable "Probe an I2C bus for certain devices" 2013-06-07 9:06 ` Wolfram Sang 2013-06-07 9:09 ` [RFC] i2c: add deprecation warning for class based instantiation Wolfram Sang @ 2013-06-07 10:10 ` Grygorii Strashko 2013-06-07 21:28 ` Wolfram Sang 1 sibling, 1 reply; 13+ messages in thread From: Grygorii Strashko @ 2013-06-07 10:10 UTC (permalink / raw) To: Wolfram Sang; +Cc: linux-i2c, linux-kernel, linux-omap Hi Wolfram, On 06/07/2013 12:06 PM, Wolfram Sang wrote: >> 3) Thinking about Mainline: To reach the same target - no I2C >> detection - and taking >> into account above assumption "No changes in default behavior" >> the following will need to be done: >> - change i2c-omap/i2c-gpio DT bindings and add parameter which will >> allow to change >> .class value for adapter. Not sure, it's possible because this parameter >> will be Linux and not HW specific (smth. like "i2c_disable_detection") >> - update drivers i2c-omap/i2c-gpio to use "i2c_disable_detection" >> - update OMAP4/5 DTS files >> >> So, It seemed a good solution for me to add 6 lines of code in i2c-core.c >> instead of doing all that stuff. > Well... I understand the "default behaviour" issue, yet I still think > that setting class to 0 is the right thing to do. OMAP is an embedded > SoC which always had i2c_board_info or devictree which are the preferred > ways of instantiating. Given that, I would accept a patch setting it to > 0. The more user friendly way might be to introduce a new class which > makes users aware of the issue. Proof of concept follows, only compile > tested. > That sounds good to me - I can prepare patch for i2c-omap.c. But, there is still an open question regarding *i2c-gpio.c* which, actually, a source of biggest part of delay. Potentially, it can be tunned using "timeout" value. But, again, this is additional work/patches to workaround unneeded system feature: - "timeout" should not break interaction with I2C devices on i2c-gpio bus and, at same time, speed up boot; - DTS/board files need to be updated. May be, just may be), we can continue with CONFIG_I2C_DISABLE_DEVICE_DETECTION, and print deprecation warning for each registered adapter if this config option is defined. - grygorii ^ permalink raw reply [flat|nested] 13+ messages in thread
* Re: [PATCH] i2c: Let users disable "Probe an I2C bus for certain devices" 2013-06-07 10:10 ` [PATCH] i2c: Let users disable "Probe an I2C bus for certain devices" Grygorii Strashko @ 2013-06-07 21:28 ` Wolfram Sang 0 siblings, 0 replies; 13+ messages in thread From: Wolfram Sang @ 2013-06-07 21:28 UTC (permalink / raw) To: Grygorii Strashko; +Cc: linux-i2c, linux-kernel, linux-omap [-- Attachment #1: Type: text/plain, Size: 237 bytes --] > That sounds good to me - I can prepare patch for i2c-omap.c. > But, there is still an open question regarding *i2c-gpio.c* which, > actually, a source of biggest part of delay. Why should the DEPRECATED flag not work with i2c-gpio? [-- Attachment #2: Digital signature --] [-- Type: application/pgp-signature, Size: 836 bytes --] ^ permalink raw reply [flat|nested] 13+ messages in thread
end of thread, other threads:[~2013-06-20 18:35 UTC | newest] Thread overview: 13+ messages (download: mbox.gz / follow: Atom feed) -- links below jump to the message on this page -- 2013-06-04 17:33 [PATCH] i2c: Let users disable "Probe an I2C bus for certain devices" Grygorii Strashko 2013-06-04 17:49 ` Wolfram Sang 2013-06-05 16:13 ` Grygorii Strashko 2013-06-07 9:06 ` Wolfram Sang 2013-06-07 9:09 ` [RFC] i2c: add deprecation warning for class based instantiation Wolfram Sang 2013-06-19 10:15 ` Wolfram Sang 2013-06-19 18:21 ` Grygorii Strashko 2013-06-20 18:37 ` Wolfram Sang 2013-06-19 18:22 ` Grygorii Strashko 2013-06-19 18:22 ` [RFC 1/2] i2c: omap: drop class based instantiation of slaves Grygorii Strashko 2013-06-19 18:22 ` [RFC 2/2] i2c: gpio: " Grygorii Strashko 2013-06-07 10:10 ` [PATCH] i2c: Let users disable "Probe an I2C bus for certain devices" Grygorii Strashko 2013-06-07 21:28 ` Wolfram Sang
This is a public inbox, see mirroring instructions for how to clone and mirror all data and code used for this inbox; as well as URLs for NNTP newsgroup(s).