diff mbox

[Resend,9/9] I2C/ACPI: Add CONFIG_I2C_ACPI config

Message ID 1398147855-9868-10-git-send-email-tianyu.lan@intel.com
State Superseded
Headers show

Commit Message

Lan Tianyu April 22, 2014, 6:24 a.m. UTC
This patch is to add CONFIG_I2C_ACPI. Current there is a race between
removing I2C ACPI operation region and ACPI AML code accessing.
So make i2c core built-in if CONFIG_I2C_ACPI is set.

Signed-off-by: Lan Tianyu <tianyu.lan@intel.com>
---
 drivers/i2c/Kconfig  | 17 ++++++++++++++++-
 drivers/i2c/Makefile |  2 +-
 include/linux/i2c.h  |  2 +-
 3 files changed, 18 insertions(+), 3 deletions(-)

Comments

Mika Westerberg April 22, 2014, 11:45 a.m. UTC | #1
On Tue, Apr 22, 2014 at 02:24:15PM +0800, Lan Tianyu wrote:
> This patch is to add CONFIG_I2C_ACPI. Current there is a race between
> removing I2C ACPI operation region and ACPI AML code accessing.
> So make i2c core built-in if CONFIG_I2C_ACPI is set.
> 
> Signed-off-by: Lan Tianyu <tianyu.lan@intel.com>
> ---
>  drivers/i2c/Kconfig  | 17 ++++++++++++++++-
>  drivers/i2c/Makefile |  2 +-
>  include/linux/i2c.h  |  2 +-
>  3 files changed, 18 insertions(+), 3 deletions(-)
> 
> diff --git a/drivers/i2c/Kconfig b/drivers/i2c/Kconfig
> index 7b7ea32..c670d49 100644
> --- a/drivers/i2c/Kconfig
> +++ b/drivers/i2c/Kconfig
> @@ -2,7 +2,9 @@
>  # I2C subsystem configuration
>  #
>  
> -menuconfig I2C
> +menu "I2C support"
> +
> +config I2C
>  	tristate "I2C support"
>  	select RT_MUTEXES
>  	---help---
> @@ -21,6 +23,17 @@ menuconfig I2C
>  	  This I2C support can also be built as a module.  If so, the module
>  	  will be called i2c-core.
>  
> +config I2C_ACPI
> +	bool "I2C ACPI support"
> +	select I2C
> +	depends on ACPI
> +	default y
> +	help
> +	  Say Y here if you want to enable I2C ACPI function. ACPI table
> +	  provides I2C slave devices' information to enumerate these devices.
> +	  This option also allows ACPI AML code to access I2C slave devices
> +	  via I2C ACPI operation region to fulfill ACPI method.
> +

I'm wondering, can we provide some sort of wrapper function from ACPI core
that is guaranteed to be built in to the kernel image and use it instead of
adding new Kconfig options?
--
To unsubscribe from this list: send the line "unsubscribe linux-i2c" in
the body of a message to majordomo@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html
Lan Tianyu April 23, 2014, 5:39 a.m. UTC | #2
On 2014年04月22日 19:45, Mika Westerberg wrote:
> On Tue, Apr 22, 2014 at 02:24:15PM +0800, Lan Tianyu wrote:
>> This patch is to add CONFIG_I2C_ACPI. Current there is a race between
>> removing I2C ACPI operation region and ACPI AML code accessing.
>> So make i2c core built-in if CONFIG_I2C_ACPI is set.
>>
>> Signed-off-by: Lan Tianyu <tianyu.lan@intel.com>
>> ---
>>  drivers/i2c/Kconfig  | 17 ++++++++++++++++-
>>  drivers/i2c/Makefile |  2 +-
>>  include/linux/i2c.h  |  2 +-
>>  3 files changed, 18 insertions(+), 3 deletions(-)
>>
>> diff --git a/drivers/i2c/Kconfig b/drivers/i2c/Kconfig
>> index 7b7ea32..c670d49 100644
>> --- a/drivers/i2c/Kconfig
>> +++ b/drivers/i2c/Kconfig
>> @@ -2,7 +2,9 @@
>>  # I2C subsystem configuration
>>  #
>>  
>> -menuconfig I2C
>> +menu "I2C support"
>> +
>> +config I2C
>>  	tristate "I2C support"
>>  	select RT_MUTEXES
>>  	---help---
>> @@ -21,6 +23,17 @@ menuconfig I2C
>>  	  This I2C support can also be built as a module.  If so, the module
>>  	  will be called i2c-core.
>>  
>> +config I2C_ACPI
>> +	bool "I2C ACPI support"
>> +	select I2C
>> +	depends on ACPI
>> +	default y
>> +	help
>> +	  Say Y here if you want to enable I2C ACPI function. ACPI table
>> +	  provides I2C slave devices' information to enumerate these devices.
>> +	  This option also allows ACPI AML code to access I2C slave devices
>> +	  via I2C ACPI operation region to fulfill ACPI method.
>> +
> 
> I'm wondering, can we provide some sort of wrapper function from ACPI core
> that is guaranteed to be built in to the kernel image and use it instead of
> adding new Kconfig options?
> 
Cc: LV

LV tried to fix the issue via wrapper solution in the ACPI code before.
https://lkml.org/lkml/2013/7/23/87

He has a plan to resolve the issue in ACPICA later.

Other choice is to increase the i2c-core module count to prevent it
being unloaded when i2c operation region handler is installed. Remove
the code When LV finish his job.
Lv Zheng April 23, 2014, 6:47 a.m. UTC | #3
SGksIFRpYW55dQ0KDQo+IEZyb206IExhbiwgVGlhbnl1DQo+IFNlbnQ6IFdlZG5lc2RheSwgQXBy
aWwgMjMsIDIwMTQgMTo0MCBQTQ0KPiANCj4gT24gMjAxNOW5tDA05pyIMjLml6UgMTk6NDUsIE1p
a2EgV2VzdGVyYmVyZyB3cm90ZToNCj4gPiBPbiBUdWUsIEFwciAyMiwgMjAxNCBhdCAwMjoyNDox
NVBNICswODAwLCBMYW4gVGlhbnl1IHdyb3RlOg0KPiA+PiBUaGlzIHBhdGNoIGlzIHRvIGFkZCBD
T05GSUdfSTJDX0FDUEkuIEN1cnJlbnQgdGhlcmUgaXMgYSByYWNlIGJldHdlZW4NCj4gPj4gcmVt
b3ZpbmcgSTJDIEFDUEkgb3BlcmF0aW9uIHJlZ2lvbiBhbmQgQUNQSSBBTUwgY29kZSBhY2Nlc3Np
bmcuDQo+ID4+IFNvIG1ha2UgaTJjIGNvcmUgYnVpbHQtaW4gaWYgQ09ORklHX0kyQ19BQ1BJIGlz
IHNldC4NCj4gPj4NCj4gPj4gU2lnbmVkLW9mZi1ieTogTGFuIFRpYW55dSA8dGlhbnl1LmxhbkBp
bnRlbC5jb20+DQo+ID4+IC0tLQ0KPiA+PiAgZHJpdmVycy9pMmMvS2NvbmZpZyAgfCAxNyArKysr
KysrKysrKysrKysrLQ0KPiA+PiAgZHJpdmVycy9pMmMvTWFrZWZpbGUgfCAgMiArLQ0KPiA+PiAg
aW5jbHVkZS9saW51eC9pMmMuaCAgfCAgMiArLQ0KPiA+PiAgMyBmaWxlcyBjaGFuZ2VkLCAxOCBp
bnNlcnRp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omo@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html
Mika Westerberg April 23, 2014, 7:40 a.m. UTC | #4
On Wed, Apr 23, 2014 at 06:47:05AM +0000, Zheng, Lv wrote:
> Hi, Tianyu
> 
> > From: Lan, Tianyu
> > Sent: Wednesday, April 23, 2014 1:40 PM
> > 
> > On 2014年04月22日 19:45, Mika Westerberg wrote:
> > > On Tue, Apr 22, 2014 at 02:24:15PM +0800, Lan Tianyu wrote:
> > >> This patch is to add CONFIG_I2C_ACPI. Current there is a race between
> > >> removing I2C ACPI operation region and ACPI AML code accessing.
> > >> So make i2c core built-in if CONFIG_I2C_ACPI is set.
> > >>
> > >> Signed-off-by: Lan Tianyu <tianyu.lan@intel.com>
> > >> ---
> > >>  drivers/i2c/Kconfig  | 17 ++++++++++++++++-
> > >>  drivers/i2c/Makefile |  2 +-
> > >>  include/linux/i2c.h  |  2 +-
> > >>  3 files changed, 18 insertions(+), 3 deletions(-)
> > >>
> > >> diff --git a/drivers/i2c/Kconfig b/drivers/i2c/Kconfig
> > >> index 7b7ea32..c670d49 100644
> > >> --- a/drivers/i2c/Kconfig
> > >> +++ b/drivers/i2c/Kconfig
> > >> @@ -2,7 +2,9 @@
> > >>  # I2C subsystem configuration
> > >>  #
> > >>
> > >> -menuconfig I2C
> > >> +menu "I2C support"
> > >> +
> > >> +config I2C
> > >>  	tristate "I2C support"
> > >>  	select RT_MUTEXES
> > >>  	---help---
> > >> @@ -21,6 +23,17 @@ menuconfig I2C
> > >>  	  This I2C support can also be built as a module.  If so, the module
> > >>  	  will be called i2c-core.
> > >>
> > >> +config I2C_ACPI
> > >> +	bool "I2C ACPI support"
> > >> +	select I2C
> > >> +	depends on ACPI
> > >> +	default y
> > >> +	help
> > >> +	  Say Y here if you want to enable I2C ACPI function. ACPI table
> > >> +	  provides I2C slave devices' information to enumerate these devices.
> > >> +	  This option also allows ACPI AML code to access I2C slave devices
> > >> +	  via I2C ACPI operation region to fulfill ACPI method.
> > >> +
> > >
> > > I'm wondering, can we provide some sort of wrapper function from ACPI core
> > > that is guaranteed to be built in to the kernel image and use it instead of
> > > adding new Kconfig options?
> > >
> > Cc: LV
> > 
> > LV tried to fix the issue via wrapper solution in the ACPI code before.
> > https://lkml.org/lkml/2013/7/23/87
> > 
> > He has a plan to resolve the issue in ACPICA later.
> > 
> > Other choice is to increase the i2c-core module count to prevent it
> > being unloaded when i2c operation region handler is installed. Remove
> > the code When LV finish his job.
> 
> You may see it implemented in ACPICA after several release.
> If you need a fix for now, you can use the patch pointed to by the link you've provided,
> Or you could find an updated one here:
>  acpi-ipmi13.patch archived in (https://bugzilla.kernel.org/attachment.cgi?id=112611)
> 
> I think the solution you've provided in this patch is also reasonable for now.
> IPMI also uses a similar solution to solve this issue.
> Please refer to the CONFIG_ACPI_IPMI.
> 
> The story can be found at:
> http://www.spinics.net/lists/linux-acpi/msg49044.html
> And the similar solution can be found at:
> http://www.spinics.net/lists/linux-acpi/msg49184.html

Thanks for the pointers.

Given that the IPMI problem was solved like this I guess I2C operation
regions can follow the same pattern if there is no better solution
available.

Out of curiousity: how did you plan to fix this in ACPICA?
--
To unsubscribe from this list: send the line "unsubscribe linux-i2c" in
the body of a message to majordomo@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html
diff mbox

Patch

diff --git a/drivers/i2c/Kconfig b/drivers/i2c/Kconfig
index 7b7ea32..c670d49 100644
--- a/drivers/i2c/Kconfig
+++ b/drivers/i2c/Kconfig
@@ -2,7 +2,9 @@ 
 # I2C subsystem configuration
 #
 
-menuconfig I2C
+menu "I2C support"
+
+config I2C
 	tristate "I2C support"
 	select RT_MUTEXES
 	---help---
@@ -21,6 +23,17 @@  menuconfig I2C
 	  This I2C support can also be built as a module.  If so, the module
 	  will be called i2c-core.
 
+config I2C_ACPI
+	bool "I2C ACPI support"
+	select I2C
+	depends on ACPI
+	default y
+	help
+	  Say Y here if you want to enable I2C ACPI function. ACPI table
+	  provides I2C slave devices' information to enumerate these devices.
+	  This option also allows ACPI AML code to access I2C slave devices
+	  via I2C ACPI operation region to fulfill ACPI method.
+
 if I2C
 
 config I2C_BOARDINFO
@@ -124,3 +137,5 @@  config I2C_DEBUG_BUS
 	  on.
 
 endif # I2C
+
+endmenu
diff --git a/drivers/i2c/Makefile b/drivers/i2c/Makefile
index 80db307..37464ee 100644
--- a/drivers/i2c/Makefile
+++ b/drivers/i2c/Makefile
@@ -3,7 +3,7 @@ 
 #
 
 i2ccore-y := i2c-core.o
-i2ccore-$(CONFIG_ACPI)		+= i2c-acpi.o
+i2ccore-$(CONFIG_I2C_ACPI)		+= i2c-acpi.o
 
 obj-$(CONFIG_I2C_BOARDINFO)	+= i2c-boardinfo.o
 obj-$(CONFIG_I2C)		+= i2ccore.o
diff --git a/include/linux/i2c.h b/include/linux/i2c.h
index fc1ef42..d0ece9f 100644
--- a/include/linux/i2c.h
+++ b/include/linux/i2c.h
@@ -583,7 +583,7 @@  static inline struct i2c_adapter *of_find_i2c_adapter_by_node(struct device_node
 }
 #endif /* CONFIG_OF */
 
-#ifdef CONFIG_ACPI
+#ifdef CONFIG_I2C_ACPI
 int acpi_i2c_install_space_handler(struct i2c_adapter *adapter);
 void acpi_i2c_remove_space_handler(struct i2c_adapter *adapter);
 void acpi_i2c_register_devices(struct i2c_adapter *adap);