From: Hans de Goede <hdegoede@redhat.com>
To: Andy Shevchenko <andriy.shevchenko@linux.intel.com>,
Linus Walleij <linus.walleij@linaro.org>,
Bartosz Golaszewski <bgolaszewski@baylibre.com>,
linux-gpio@vger.kernel.org,
Mika Westerberg <mika.westerberg@linux.intel.com>
Cc: Coiby Xu <coiby.xu@gmail.com>
Subject: Re: [PATCH v4 3/9] gpiolib: acpi: Take into account debounce settings
Date: Sat, 7 Nov 2020 15:44:32 +0100 [thread overview]
Message-ID: <0756cd6c-c0a7-17e8-2e32-de3e6db6a69b@redhat.com> (raw)
In-Reply-To: <20201106192304.49179-4-andriy.shevchenko@linux.intel.com>
Hi,
On 11/6/20 8:22 PM, Andy Shevchenko wrote:
> We didn't take into account the debounce settings supplied by ACPI.
> This change is targeting the mentioned gap.
>
> Reported-by: Coiby Xu <coiby.xu@gmail.com>
> Cc: Hans de Goede <hdegoede@redhat.com>
> Signed-off-by: Andy Shevchenko <andriy.shevchenko@linux.intel.com>
> Acked-by: Linus Walleij <linus.walleij@linaro.org>
I added an older version of this (which only modified acpi_dev_gpio_irq_get())
for testing and when booting a kernel with that version applied to it,
on a Cherry Trail device I noticed that a whole bunch of devices where no
longer seen by the kernel because of acpi_dev_gpio_irq_get() returning
errors now (-ENOTSUPP).
Quoting from the gpiod_set_debounce docs:
/**
* gpiod_set_debounce - sets @debounce time for a GPIO
* @desc: descriptor of the GPIO for which to set debounce time
* @debounce: debounce time in microseconds
*
* Returns:
* 0 on success, %-ENOTSUPP if the controller doesn't support setting the
* debounce time.
*/
This is expected on GPIO chips where setting the debounce time
is not supported. So the error handling should be modified to
ignore -ENOTSUPP errors here.
This certainly MUST NOT be merged as is because it breaks a lot
of things as is.
Regards,
Hans
> ---
> drivers/gpio/gpiolib-acpi.c | 18 ++++++++++++++++++
> drivers/gpio/gpiolib-acpi.h | 2 ++
> 2 files changed, 20 insertions(+)
>
> diff --git a/drivers/gpio/gpiolib-acpi.c b/drivers/gpio/gpiolib-acpi.c
> index c127b410a7a2..b4a0decfeac2 100644
> --- a/drivers/gpio/gpiolib-acpi.c
> +++ b/drivers/gpio/gpiolib-acpi.c
> @@ -299,6 +299,10 @@ static acpi_status acpi_gpiochip_alloc_event(struct acpi_resource *ares,
> return AE_OK;
> }
>
> + ret = gpiod_set_debounce(desc, agpio->debounce_timeout);
> + if (ret)
> + goto fail_free_desc;
> +
> ret = gpiochip_lock_as_irq(chip, pin);
> if (ret) {
> dev_err(chip->parent,
> @@ -664,6 +668,7 @@ static int acpi_populate_gpio_lookup(struct acpi_resource *ares, void *data)
> lookup->desc = acpi_get_gpiod(agpio->resource_source.string_ptr,
> agpio->pin_table[pin_index]);
> lookup->info.pin_config = agpio->pin_config;
> + lookup->info.debounce = agpio->debounce_timeout;
> lookup->info.gpioint = gpioint;
>
> /*
> @@ -961,6 +966,10 @@ int acpi_dev_gpio_irq_get(struct acpi_device *adev, int index)
> if (ret < 0)
> return ret;
>
> + ret = gpiod_set_debounce(desc, info.debounce);
> + if (ret)
> + return ret;
> +
> irq_flags = acpi_dev_get_irq_type(info.triggering,
> info.polarity);
>
> @@ -1048,6 +1057,7 @@ acpi_gpio_adr_space_handler(u32 function, acpi_physical_address address,
> if (!found) {
> enum gpiod_flags flags = acpi_gpio_to_gpiod_flags(agpio);
> const char *label = "ACPI:OpRegion";
> + int ret;
>
> desc = gpiochip_request_own_desc(chip, pin, label,
> GPIO_ACTIVE_HIGH,
> @@ -1058,6 +1068,14 @@ acpi_gpio_adr_space_handler(u32 function, acpi_physical_address address,
> goto out;
> }
>
> + ret = gpiod_set_debounce(desc, agpio->debounce_timeout);
> + if (ret) {
> + status = AE_ERROR;
> + gpiochip_free_own_desc(desc);
> + mutex_unlock(&achip->conn_lock);
> + goto out;
> + }
> +
> conn = kzalloc(sizeof(*conn), GFP_KERNEL);
> if (!conn) {
> status = AE_NO_MEMORY;
> diff --git a/drivers/gpio/gpiolib-acpi.h b/drivers/gpio/gpiolib-acpi.h
> index 1c6d65cf0629..e2edb632b2cc 100644
> --- a/drivers/gpio/gpiolib-acpi.h
> +++ b/drivers/gpio/gpiolib-acpi.h
> @@ -18,6 +18,7 @@ struct acpi_device;
> * @pin_config: pin bias as provided by ACPI
> * @polarity: interrupt polarity as provided by ACPI
> * @triggering: triggering type as provided by ACPI
> + * @debounce: debounce timeout as provided by ACPI
> * @quirks: Linux specific quirks as provided by struct acpi_gpio_mapping
> */
> struct acpi_gpio_info {
> @@ -27,6 +28,7 @@ struct acpi_gpio_info {
> int pin_config;
> int polarity;
> int triggering;
> + unsigned int debounce;
> unsigned int quirks;
> };
>
>
next prev parent reply other threads:[~2020-11-07 14:44 UTC|newest]
Thread overview: 17+ messages / expand[flat|nested] mbox.gz Atom feed top
2020-11-06 19:22 [PATCH v4 0/9] gpiolib: acpi: pin configuration fixes Andy Shevchenko
2020-11-06 19:22 ` [PATCH v4 1/9] gpiolib: acpi: Respect bias settings for GpioInt() resource Andy Shevchenko
2020-11-06 19:22 ` [PATCH v4 2/9] gpiolib: acpi: Use named item for enum gpiod_flags variable Andy Shevchenko
2020-11-06 19:22 ` [PATCH v4 3/9] gpiolib: acpi: Take into account debounce settings Andy Shevchenko
2020-11-07 14:44 ` Hans de Goede [this message]
2020-11-07 15:26 ` Andy Shevchenko
2020-11-08 9:31 ` Hans de Goede
2020-11-08 9:31 ` Hans de Goede
2020-11-09 11:45 ` Andy Shevchenko
2020-11-09 11:53 ` Hans de Goede
2020-11-09 15:43 ` Andy Shevchenko
2020-11-06 19:22 ` [PATCH v4 4/9] gpiolib: acpi: Move acpi_gpio_to_gpiod_flags() upper in the code Andy Shevchenko
2020-11-06 19:23 ` [PATCH v4 5/9] gpiolib: acpi: Make acpi_gpio_to_gpiod_flags() usable for GpioInt() Andy Shevchenko
2020-11-06 19:23 ` [PATCH v4 6/9] gpiolib: acpi: Extract acpi_request_own_gpiod() helper Andy Shevchenko
2020-11-06 19:23 ` [PATCH v4 7/9] gpiolib: acpi: Convert pin_index to be u16 Andy Shevchenko
2020-11-06 19:23 ` [PATCH v4 8/9] gpiolib: acpi: Use BIT() macro to increase readability Andy Shevchenko
2020-11-06 19:23 ` [PATCH v4 9/9] gpiolib: acpi: Make Intel GPIO tree official for GPIO ACPI work Andy Shevchenko
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=0756cd6c-c0a7-17e8-2e32-de3e6db6a69b@redhat.com \
--to=hdegoede@redhat.com \
--cc=andriy.shevchenko@linux.intel.com \
--cc=bgolaszewski@baylibre.com \
--cc=coiby.xu@gmail.com \
--cc=linus.walleij@linaro.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).