From: Andy Shevchenko <andriy.shevchenko@intel.com>
To: Hans de Goede <hdegoede@redhat.com>
Cc: Mika Westerberg <mika.westerberg@linux.intel.com>,
Andy Shevchenko <andy@kernel.org>,
Linus Walleij <linus.walleij@linaro.org>,
linux-gpio@vger.kernel.org, linux-acpi@vger.kernel.org
Subject: Re: [PATCH] gpiolib: acpi: Do not set the IRQ type if the IRQ is already in use
Date: Thu, 25 Nov 2021 23:39:45 +0200 [thread overview]
Message-ID: <YaACofzJO2/bckS3@smile.fi.intel.com> (raw)
In-Reply-To: <20211125203010.825442-1-hdegoede@redhat.com>
On Thu, Nov 25, 2021 at 09:30:10PM +0100, Hans de Goede wrote:
> 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.
> Signed-off-by: Hans de Goede <hdegoede@redhat.com>
> ---
> 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
Okay, this explains drop of FW_BUG macro, I suppose.
Pushed to my review and testing queue, thanks!
> ---
> drivers/gpio/gpiolib-acpi.c | 15 +++++++++++----
> 1 file changed, 11 insertions(+), 4 deletions(-)
>
> diff --git a/drivers/gpio/gpiolib-acpi.c b/drivers/gpio/gpiolib-acpi.c
> index 985e8589c58b..feb8157d2d67 100644
> --- a/drivers/gpio/gpiolib-acpi.c
> +++ b/drivers/gpio/gpiolib-acpi.c
> @@ -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;
> }
> --
> 2.33.1
>
--
With Best Regards,
Andy Shevchenko
next prev parent reply other threads:[~2021-11-25 21:41 UTC|newest]
Thread overview: 7+ messages / expand[flat|nested] mbox.gz Atom feed top
2021-11-25 20:30 [PATCH] gpiolib: acpi: Do not set the IRQ type if the IRQ is already in use Hans de Goede
2021-11-25 21:39 ` Andy Shevchenko [this message]
-- strict thread matches above, loose matches on Subject: below --
2021-11-22 22:04 Hans de Goede
2021-11-23 9:36 ` Andy Shevchenko
2021-11-23 10:59 ` Hans de Goede
2021-11-23 11:01 ` Andy Shevchenko
2021-11-25 20:35 ` Hans de Goede
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=YaACofzJO2/bckS3@smile.fi.intel.com \
--to=andriy.shevchenko@intel.com \
--cc=andy@kernel.org \
--cc=hdegoede@redhat.com \
--cc=linus.walleij@linaro.org \
--cc=linux-acpi@vger.kernel.org \
--cc=linux-gpio@vger.kernel.org \
--cc=mika.westerberg@linux.intel.com \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
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).