gpiolib: acpi: Do not set the IRQ type if the IRQ is already in use
PATCH 1/1 gpiolib: acpi: Do not set the IRQ type if the IRQ is already in use
If the IRQ is already in use, then acpi_dev_gpio_irq_get_by() really should not change the type underneath the current owner.
I specifically hit an issue with this an a Chuwi Hi8 Super (CWI509) Bay Trail tablet, when the Boot OS selection in the BIOS is set to Android. In this case _STA for a MAX17047 ACPI I2C device wrongly returns 0xf and the _CRS resources for this device include a GpioInt pointing to a GPIO already in use by an _AEI handler, with a different type then specified in the _CRS for the MAX17047 device. Leading to the acpi_dev_gpio_irq_get() call done by the i2c-core-acpi.c code changing the type breaking the _AEI handler.
Now this clearly is a bug in the DSDT of this tablet (in Android mode), but in general calling irq_set_irq_type() on an IRQ which already is in use seems like a bad idea.
---
Changes in v2:
- Emit a dev_dbg when the IRQ is already in use. Note while making this change I realized that i2c-multi-instantiate.c actually uses acpi_dev_gpio_irq_get_by() with shared interrupts, so I decided to go with a dev_dbg instead of a dev_warn after all
--- drivers/gpio/gpiolib-acpi.c | 15 +++++++++++---- 1 file changed, 11 insertions(+), 4 deletions(-)
drivers/gpio/gpiolib-acpi.c +11 -4
@@ -1056,10 +1056,17 @@ int acpi_dev_gpio_irq_get_by(struct acpi_device *adev, const char *name, int ind irq_flags =acpi_dev_get_irq_type (info.triggering, info.polarity); -/* Set type if specified and different than the current one */ -if (irq_flags !=IRQ_TYPE_NONE && - irq_flags !=irq_get_trigger_type (irq)) -irq_set_irq_type (irq, irq_flags); +/* +* If the IRQ is not already in use then set type +* if specified and different than the current one. +*/ +if (can_request_irq (irq, irq_flags)) { +if (irq_flags !=IRQ_TYPE_NONE && + irq_flags !=irq_get_trigger_type (irq)) +irq_set_irq_type (irq, irq_flags); + }else { +dev_dbg (&adev->dev,"IRQ %d already in use\n" , irq); + }return irq; }
Signature · 1 line
2.33.1
Quoted 16 lines · Hans de Goede
If the IRQ is already in use, then
acpi_dev_gpio_irq_get_by()really should not change the type underneath the current owner.I specifically hit an issue with this an a Chuwi Hi8 Super (CWI509) Bay Trail tablet, when the Boot OS selection in the BIOS is set to Android. In this case
_STAfor a MAX17047 ACPI I2C device wrongly returns0xfand the_CRSresources for this device include a GpioInt pointing to a GPIO already in use by an_AEIhandler, with a different type then specified in the_CRSfor the MAX17047 device. Leading to theacpi_dev_gpio_irq_get()call done by thei2c-core-acpi.ccode changing the type breaking the_AEIhandler.Now this clearly is a bug in the DSDT of this tablet (in Android mode), but in general calling
irq_set_irq_type()on an IRQ which already is in use seems like a bad idea.
Quoted 7 lines
Signed-off-by Hans de Goede <[email protected]>---
Changes in v2:
- Emit adev_dbgwhen the IRQ is already in use. Note while making this change I realized thati2c-multi-instantiate.cactually usesacpi_dev_gpio_irq_get_by()with shared interrupts, so I decided to go with adev_dbginstead of adev_warnafter all
Okay, this explains drop of FW_BUG macro, I suppose.
Pushed to my review and testing queue, thanks!
Quoted 33 lines
--- drivers/gpio/gpiolib-acpi.c | 15 +++++++++++---- 1 file changed, 11 insertions(+), 4 deletions(-)drivers/gpio/gpiolib-acpi.c +11
-4@@ -1056,10 +1056,17 @@ int acpi_dev_gpio_irq_get_by(struct acpi_device *adev, const char *name, int ind irq_flags =acpi_dev_get_irq_type (info.triggering, info.polarity); -/* Set type if specified and different than the current one */ -if (irq_flags !=IRQ_TYPE_NONE && - irq_flags !=irq_get_trigger_type (irq)) -irq_set_irq_type (irq, irq_flags); +/* +* If the IRQ is not already in use then set type +* if specified and different than the current one. +*/ +if (can_request_irq (irq, irq_flags)) { +if (irq_flags !=IRQ_TYPE_NONE && + irq_flags !=irq_get_trigger_type (irq)) +irq_set_irq_type (irq, irq_flags); + }else { +dev_dbg (&adev->dev,"IRQ %d already in use\n" , irq); + }return irq; }Signature · 1 line
2.33.1
Signature · 2 lines
With Best Regards, Andy Shevchenko