i2c: Allow ACPI_I2C_OPREGION if I2C is built as a module
Subsystems (3)
PATCH v2 1/1 i2c: Allow ACPI_I2C_OPREGION if I2C is built as a module
If I2C is built as a module, ACPI_I2C_OPREGION cannot be set and any ACPI opregion calls targeting I2C fail with no opregion found.
This patch allows ACPI_I2C_OPREGION to be enabled both if I2C is built into the kernel or built as a module.
---
v1 -> v2:
- reword the commit message
--- drivers/i2c/Kconfig | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)
drivers/i2c/Kconfig +1 -1
@@ -26,7 +26,7 @@ config I2C config ACPI_I2C_OPREGION bool "ACPI I2C Operation region support" - depends on I2C=y && ACPI + depends on I2C && ACPI default y help Say Y here if you want to enable ACPI I2C operation region support.
Signature · 1 line
2.5.5
Quoted 7 lines · Eric Auger
If I2C is built as a module,
ACPI_I2C_OPREGIONcannot be set and any ACPI opregion calls targeting I2C fail with no opregion found.This patch allows
ACPI_I2C_OPREGIONto be enabled both if I2C is built into the kernel or built as a module.Signed-off-by Eric Auger <[email protected]>
Hoping this makes to 4.16.
Signature · 3 lines
Sinan Kaya Qualcomm Datacenter Technologies, Inc. as an affiliate of Qualcomm Technologies, Inc. Qualcomm Technologies, Inc. is a member of the Code Aurora Forum, a Linux Foundation Collaborative Project.
Quoted 7 lines · Eric Auger
If I2C is built as a module,
ACPI_I2C_OPREGIONcannot be set and any ACPI opregion calls targeting I2C fail with no opregion found.This patch allows
ACPI_I2C_OPREGIONto be enabled both if I2C is built into the kernel or built as a module.Signed-off-by Eric Auger <[email protected]>
I recall that we had some discussion until ending up with the current solution. And I finally found it again:
http://www.serverphorums.com/read.php?12,1001402
In any case, I surely want Mika's ack on any change to ACPI related Kconfig symbols. Adding him to CC...
Quoted 9 lines · Wolfram Sang
Quoted 7 lines · Eric Auger
If I2C is built as a module,
ACPI_I2C_OPREGIONcannot be set and any ACPI opregion calls targeting I2C fail with no opregion found.This patch allows
ACPI_I2C_OPREGIONto be enabled both if I2C is built into the kernel or built as a module.Signed-off-by Eric Auger <[email protected]>
Quoted 7 lines
I recall that we had some discussion until ending up with the current solution. And I finally found it again:
http://www.serverphorums.com/read.php?12,1001402
In any case, I surely want Mika's ack on any change to ACPI related
Kconfigsymbols. Adding him to CC...
So the problem is/was that what happens if you are in a middle of BIOS AML code touching the opregion and someone unloads the opregion handler? If you can quarantee nothing bad happens, then I'm fine with the patch :)
+linux-acpi
Quoted 13 lines · Mika Westerberg
Quoted 12 lines · Wolfram Sang
Quoted 7 lines · Eric Auger
If I2C is built as a module,
ACPI_I2C_OPREGIONcannot be set and any ACPI opregion calls targeting I2C fail with no opregion found.This patch allows
ACPI_I2C_OPREGIONto be enabled both if I2C is built into the kernel or built as a module.Signed-off-by Eric Auger <[email protected]>I recall that we had some discussion until ending up with the current solution. And I finally found it again:
Quoted 9 lines
Quoted 4 lines
http://www.serverphorums.com/read.php?12,1001402
In any case, I surely want Mika's ack on any change to ACPI related
Kconfigsymbols. Adding him to CC...So the problem is/was that what happens if you are in a middle of BIOS AML code touching the opregion and someone unloads the opregion handler? If you can quarantee nothing bad happens, then I'm fine with the patch :)
Rafael to correct me if I got this right.
The behavior of the operating system is well defined in the ACPI specification.
Here is what I tested recently:
ACPI defines _REG method to inform firmware of presence/removal of an operating region.
When driver gets loaded, ACPI calls the _REG method with 1 argument. When driver gets unloaded, ACPI call the _REG method with 0 argument.
Firmware can use this notification to its advantage to determine when an I2C related functionality should be accessed or not.
If firmware doesn't use the _REG method, ACPI defines that AML statements accessing the operating region are ignored.
You'll also see a warning from ACPICA saying the OperatingRegion 9 is no longer accessible and AML code execution failed.
Also note that someone can always unbind an I2C driver from ACPI even with built-in module.
I think we are talking about an orthogonal issue here.
Signature · 3 lines
Sinan Kaya Qualcomm Datacenter Technologies, Inc. as an affiliate of Qualcomm Technologies, Inc. Qualcomm Technologies, Inc. is a member of the Code Aurora Forum, a Linux Foundation Collaborative Project.
Quoted 41 lines · Sinan Kaya
+linux-acpi
Quoted 13 lines · Mika Westerberg
Quoted 12 lines · Wolfram Sang
Quoted 7 lines · Eric Auger
If I2C is built as a module,
ACPI_I2C_OPREGIONcannot be set and any ACPI opregion calls targeting I2C fail with no opregion found.This patch allows
ACPI_I2C_OPREGIONto be enabled both if I2C is built into the kernel or built as a module.Signed-off-by Eric Auger <[email protected]>I recall that we had some discussion until ending up with the current solution. And I finally found it again:
Quoted 9 lines
Quoted 4 lines
http://www.serverphorums.com/read.php?12,1001402
In any case, I surely want Mika's ack on any change to ACPI related
Kconfigsymbols. Adding him to CC...So the problem is/was that what happens if you are in a middle of BIOS AML code touching the opregion and someone unloads the opregion handler? If you can quarantee nothing bad happens, then I'm fine with the patch :)
Rafael to correct me if I got this right.
The behavior of the operating system is well defined in the ACPI specification.
Here is what I tested recently:
ACPI defines
_REGmethod to inform firmware of presence/removal of an operating region.When driver gets loaded, ACPI calls the
_REGmethod with 1 argument. When driver gets unloaded, ACPI call the_REGmethod with 0 argument.Firmware can use this notification to its advantage to determine when an I2C related functionality should be accessed or not.
Quoted 8 lines
If firmware doesn't use the
_REGmethod, ACPI defines that AML statements accessing the operating region are ignored.You'll also see a warning from ACPICA saying the OperatingRegion 9 is no longer accessible and AML code execution failed.
Also note that someone can always unbind an I2C driver from ACPI even with built-in module.
Yes, that's right.
However, the I2C core parts are not removed when you unbind a driver and the imporant piece is i2c_acpi_space_handler() which then stays in the memory even if any of the drivers get removed. After this patch you can also remove the i2c_acpi_space_handler() which might cause issues if there is AML code running at the same time using the opregion.
Commit da3c6647ee08 ("I2C/ACPI: Clean up I2C ACPI code and Add CONFIG_I2C_ACPI config") says following:
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.
But I don't remember all the details unfortunately so adding Rafael and Tianyu if they can shed some more light into this ;-)
Quoted 1 line · Sinan Kaya
+linux-acpi
+Cc: Hans
Quoted 42 lines · Mika Westerberg
Quoted 13 lines · Wolfram Sang
Quoted 12 lines · Eric Auger
Quoted 7 lines
If I2C is built as a module,
ACPI_I2C_OPREGIONcannot be set and any ACPI opregion calls targeting I2C fail with no opregion found.This patch allows
ACPI_I2C_OPREGIONto be enabled both if I2C is built into the kernel or built as a module.Signed-off-by Eric Auger <[email protected]>I recall that we had some discussion until ending up with the current solution. And I finally found it again:
Quoted 9 lines
Quoted 4 lines
http://www.serverphorums.com/read.php?12,1001402
In any case, I surely want Mika's ack on any change to ACPI related
Kconfigsymbols. Adding him to CC...So the problem is/was that what happens if you are in a middle of BIOS AML code touching the opregion and someone unloads the opregion handler? If you can quarantee nothing bad happens, then I'm fine with the patch :)
Rafael to correct me if I got this right.
The behavior of the operating system is well defined in the ACPI specification.
Here is what I tested recently:
ACPI defines
_REGmethod to inform firmware of presence/removal of an operating region.When driver gets loaded, ACPI calls the
_REGmethod with 1 argument. When driver gets unloaded, ACPI call the_REGmethod with 0 argument.Firmware can use this notification to its advantage to determine when an I2C related functionality should be accessed or not.
If firmware doesn't use the
_REGmethod, ACPI defines that AML statements accessing the operating region are ignored.
Quoted 6 lines
You'll also see a warning from ACPICA saying the OperatingRegion 9 is no longer accessible and AML code execution failed.
Also note that someone can always unbind an I2C driver from ACPI even with built-in module.
No, you can't. There are user(s) of that, i.e. PMIC, otherwise, of course, you may do that.
Quoted 1 line
I think we are talking about an orthogonal issue here.
Signature · 2 lines
With Best Regards, Andy Shevchenko
Hi,
Quoted 4 lines · Andy Shevchenko
Quoted 1 line · Sinan Kaya
+linux-acpi
+Cc: Hans
Thank you.
Quoted 39 lines
Quoted 39 lines · Mika Westerberg
Quoted 13 lines · Wolfram Sang
Quoted 12 lines · Eric Auger
Quoted 7 lines
If I2C is built as a module,
ACPI_I2C_OPREGIONcannot be set and any ACPI opregion calls targeting I2C fail with no opregion found.This patch allows
ACPI_I2C_OPREGIONto be enabled both if I2C is built into the kernel or built as a module.Signed-off-by Eric Auger <[email protected]>I recall that we had some discussion until ending up with the current solution. And I finally found it again:
Quoted 9 lines
Quoted 4 lines
http://www.serverphorums.com/read.php?12,1001402
In any case, I surely want Mika's ack on any change to ACPI related
Kconfigsymbols. Adding him to CC...So the problem is/was that what happens if you are in a middle of BIOS AML code touching the opregion and someone unloads the opregion handler? If you can quarantee nothing bad happens, then I'm fine with the patch :)
Rafael to correct me if I got this right.
The behavior of the operating system is well defined in the ACPI specification.
Here is what I tested recently:
ACPI defines
_REGmethod to inform firmware of presence/removal of an operating region.When driver gets loaded, ACPI calls the
_REGmethod with 1 argument. When driver gets unloaded, ACPI call the_REGmethod with 0 argument.Firmware can use this notification to its advantage to determine when an I2C related functionality should be accessed or not.
Quoted 6 lines
Quoted 6 lines
If firmware doesn't use the
_REGmethod, ACPI defines that AML statements accessing the operating region are ignored.You'll also see a warning from ACPICA saying the OperatingRegion 9 is no longer accessible and AML code execution failed.
There is the ACPI specification, and then there is reality. In reality many DSTDs do not use the typically named AVB? counter-part of _REG to check before accessing OpRegions.
Also OpRegion availability vs probe ordering is a nightmare.
Lets pretend that all DSTDs are perfect and that some device described in ACPI has a _PS0 method which uses an opregion to turn on some regulator powering the device through i2c, but only if the _REG method for that opregion has been called. So now lets say that the driver for this device loads and tries to bind before the i2c-module has loaded. Before the driver's probe method gets called the driver-core will call _PS0 to power-up the device, which is a nop (*). Then the drivers probe function tries to talk to the device, but fails as the device is not powered, so it returns with -ENODEV.
And then later the i2c-module loads, which is to late to get things working, unless the user rmmods and modprobes the driver for the device manually.
TL;DR: I have to NAK this, I'm sorry but with the current state of ACPI we must simply have some stuff builtin to help with probe-ordering issues. Now if the ACPI code where ever to honor the _DEP method everywhere instead of only for battery devices this might change, but even then things will still be tricky.
Regards,
Hans
*) Typically while logging errors about unavailable OpRegions, but as said lets pretend DSTDs actually check the flags set by _REG everywhere.
Quoted 5 lines · Hans de Goede
TL;DR: I have to NAK this, I'm sorry but with the current state of ACPI we must simply have some stuff builtin to help with probe-ordering issues. Now if the ACPI code where ever to honor the
_DEPmethod everywhere instead of only for battery devices this might change, but even then things will still be tricky.
Well, the alternative is even worse.
Redhat and most other distros configure I2C as a module. With this setup, I2C OpRegion support does not get compiled. It doesn't even work let alone to have race conditions.
I2C OpRegion feature is practically dead for most general users unless you recompile your own kernel.
There must be a middle ground somewhere.
I had some conversation with Rafael about _DEP support. He is not a big fan :)
Signature · 3 lines
Sinan Kaya Qualcomm Datacenter Technologies, Inc. as an affiliate of Qualcomm Technologies, Inc. Qualcomm Technologies, Inc. is a member of the Code Aurora Forum, a Linux Foundation Collaborative Project.
Hi,
Quoted 8 lines · Sinan Kaya
Quoted 5 lines · Hans de Goede
TL;DR: I have to NAK this, I'm sorry but with the current state of ACPI we must simply have some stuff builtin to help with probe-ordering issues. Now if the ACPI code where ever to honor the
_DEPmethod everywhere instead of only for battery devices this might change, but even then things will still be tricky.Well, the alternative is even worse.
No it is not, if I2C gets builtin things work fine, you proposal does not fix anything, it merely gives the illusion of being builtin
Quoted 1 line
Redhat and most other distros configure I2C as a module.
Fedora has stopped building I2C as a module a long time ago already and where Fedora goes RHEL typically follows.
Quoted 3 lines
With this setup,
I2C OpRegion support does not get compiled. It doesn't even work let alone to have race conditions.
So at least it is consistent then, which makes for a lot easier debugging.
Quoted 2 lines
I2C OpRegion feature is practically dead for most general users unless you recompile your own kernel.
Then talk to various distro kernel maintainers and ask them to set CONFIG_I2C=y.
Quoted 1 line
There must be a middle ground somewhere.
One thing which comes to mind is to simply not allow building i2c as a module when ACPI is selected, something like this should work I think:
config I2C
tristate "I2C support"
select RT_MUTEXES
select IRQ_DOMAIN
+ # force building I2C in on ACPI systems, for opregion availability
+ depends on y || !ACPI
Quoted 1 line
I had some conversation with Rafael about
_DEPsupport. He is not a big fan :)
Ok.
Regards,
Hans
Quoted 11 lines · Hans de Goede
Quoted 1 line
There must be a middle ground somewhere.
One thing which comes to mind is to simply not allow building i2c as a module when ACPI is selected, something like this should work I think:
config I2C
tristate "I2C support"
selectRT_MUTEXES
selectIRQ_DOMAIN
+ # force building I2C in on ACPI systems, for opregion availability + depends on y || !ACPI
This works for me.
Signature · 3 lines
Sinan Kaya Qualcomm Datacenter Technologies, Inc. as an affiliate of Qualcomm Technologies, Inc. Qualcomm Technologies, Inc. is a member of the Code Aurora Forum, a Linux Foundation Collaborative Project.
Hi,
Quoted 6 lines · Sinan Kaya
Quoted 5 lines · Hans de Goede
Quoted 1 line
There must be a middle ground somewhere.
One thing which comes to mind is to simply not allow building i2c as a module when ACPI is selected, something like this should work I think:
Quoted 8 lines
Quoted 6 lines
config I2C
tristate "I2C support"
selectRT_MUTEXES
selectIRQ_DOMAIN
+ # force building I2C in on ACPI systems, for opregion availability + depends on y || !ACPIThis works for me.
OK, so feel free to turn it into a proper patch and submit it upstream.
Regards,
Hans
Quoted 12 lines · Hans de Goede
Quoted 12 lines
Quoted 11 lines
Quoted 1 line
There must be a middle ground somewhere.
One thing which comes to mind is to simply not allow building i2c as a module when ACPI is selected, something like this should work I think:
config I2C
tristate "I2C support"
selectRT_MUTEXES
selectIRQ_DOMAIN
+ # force building I2C in on ACPI systems, for opregion availability + depends on y || !ACPI
Quoted 4 lines
Quoted 1 line
This works for me.
OK, so feel free to turn it into a proper patch and submit it upstream.
OK. Let me do some build tests.
Signature · 3 lines
Sinan Kaya Qualcomm Datacenter Technologies, Inc. as an affiliate of Qualcomm Technologies, Inc. Qualcomm Technologies, Inc. is a member of the Code Aurora Forum, a Linux Foundation Collaborative Project.
Hi,
Quoted 6 lines · Sinan Kaya
Quoted 5 lines · Hans de Goede
Quoted 5 lines
Quoted 5 lines
Quoted 1 line
There must be a middle ground somewhere.
One thing which comes to mind is to simply not allow building i2c as a module when ACPI is selected, something like this should work I think:
Quoted 8 lines
Quoted 8 lines
Quoted 8 lines
Review
Quoted 6 lines
config I2C
tristate "I2C support"
selectRT_MUTEXES
selectIRQ_DOMAIN(quoted diff) +2
-0+ # force building I2C in on ACPI systems, for opregion availability + depends on y || !ACPIThis works for me.
Yes given all the concerns this patch raised, better make sure I2C is built-in along with ACPI. Sorry for the noise.
Thanks
Eric
Quoted 6 lines
Quoted 3 lines
OK, so feel free to turn it into a proper patch and submit it upstream.
OK. Let me do some build tests.
Quoted 13 lines · Mika Westerberg
Quoted 12 lines · Wolfram Sang
Quoted 7 lines · Eric Auger
If I2C is built as a module,
ACPI_I2C_OPREGIONcannot be set and any ACPI opregion calls targeting I2C fail with no opregion found.This patch allows
ACPI_I2C_OPREGIONto be enabled both if I2C is built into the kernel or built as a module.Signed-off-by Eric Auger <[email protected]>I recall that we had some discussion until ending up with the current solution. And I finally found it again:
Quoted 8 lines
Quoted 4 lines
http://www.serverphorums.com/read.php?12,1001402
In any case, I surely want Mika's ack on any change to ACPI related
Kconfigsymbols. Adding him to CC...So the problem is/was that what happens if you are in a middle of BIOS AML code touching the opregion and someone unloads the opregion handler? If you can quarantee nothing bad happens, then I'm fine with the patch :)
I don't think anyone can guarantee this.
I would be fine with patch if and only if it has been tested on problematic hardware, such as Intel CherryTrail based tablets / laptops.
Signature · 2 lines
With Best Regards, Andy Shevchenko
Quoted 24 lines · Andy Shevchenko
Quoted 13 lines · Mika Westerberg
Quoted 12 lines · Wolfram Sang
Quoted 7 lines · Eric Auger
If I2C is built as a module,
ACPI_I2C_OPREGIONcannot be set and any ACPI opregion calls targeting I2C fail with no opregion found.This patch allows
ACPI_I2C_OPREGIONto be enabled both if I2C is built into the kernel or built as a module.Signed-off-by Eric Auger <[email protected]>I recall that we had some discussion until ending up with the current solution. And I finally found it again:
Quoted 8 lines
Quoted 4 lines
http://www.serverphorums.com/read.php?12,1001402
In any case, I surely want Mika's ack on any change to ACPI related
Kconfigsymbols. Adding him to CC...So the problem is/was that what happens if you are in a middle of BIOS AML code touching the opregion and someone unloads the opregion handler? If you can quarantee nothing bad happens, then I'm fine with the patch :)
Quoted 6 lines
I don't think anyone can guarantee this.
I would be fine with patch if and only if it has been tested on problematic hardware, such as Intel CherryTrail based tablets / laptops.
Need some details on what the actual issue is/was.
One would think that ACPI operating region removal would be serialized with respect to AML execution from 10000 foot view.
I'm hoping one of you guys would chime into Mika's message.
Signature · 3 lines
Sinan Kaya Qualcomm Datacenter Technologies, Inc. as an affiliate of Qualcomm Technologies, Inc. Qualcomm Technologies, Inc. is a member of the Code Aurora Forum, a Linux Foundation Collaborative Project.