[<prev] [next>] [<thread-prev] [day] [month] [year] [list]
Message-ID: <334a8efc-003b-3971-41bc-4783a6fa5e30@alliedtelesis.co.nz>
Date: Fri, 12 May 2023 03:50:05 +0000
From: Chris Packham <Chris.Packham@...iedtelesis.co.nz>
To: Linus Walleij <linus.walleij@...aro.org>
CC: "andy.shevchenko@...il.com" <andy.shevchenko@...il.com>,
"brgl@...ev.pl" <brgl@...ev.pl>,
Ben Brown <Ben.Brown@...iedtelesis.co.nz>,
"linux-gpio@...r.kernel.org" <linux-gpio@...r.kernel.org>,
"linux-kernel@...r.kernel.org" <linux-kernel@...r.kernel.org>,
Marc Zyngier <maz@...nel.org>,
Hans Verkuil <hverkuil-cisco@...all.nl>
Subject: Re: [PATCH] gpiolib: Don't implicitly disable irq when masking
On 12/05/23 08:36, Chris Packham wrote:
> Hi Linus,
>
> On 11/05/23 20:00, Linus Walleij wrote:
>> On Wed, May 10, 2023 at 10:59 PM Chris Packham
>> <Chris.Packham@...iedtelesis.co.nz> wrote:
>>
>>> The coupling of gpiochip_irq_mask()/gpiochip_irq_unmask() with
>>> gpiochip_disable_irq()/gpiochip_enable_irq() goes back to the same
>>> commit a8173820f441 ("gpio: gpiolib: Allow GPIO IRQs to lazy disable").
>>> It's not immediately obvious to me why the coupling is needed.
>> That is just a refactoring of what existed before.
>>
>> The use case is here:
>> drivers/media/cec/platform/cec-gpio/cec-gpio.c
>>
>> The driver needs to switch, at runtime, between actively driving a GPIO
>> line with gpiod_set_value(), and setting the same line into input mode
>> and listening for signalling triggering IRQs on it, and then back to
>> output mode and driving the line again. It's a bidirectional GPIO line.
>> This use case yields a high need of control.
>>
>>> I was
>>> hoping that someone seeing my patch would confirm that it's not needed
>>> or say why it's needed suggest an alternative approach.
>> Which IRQ-enabled gpiochip is this? Has it been converted to be
>> immutable?
>> I think that could be part of the problem.
>
> For me it's a pca9555. I spent yesterday trying to demonstrate the
> problem on a newer kernel. Some teething issues aside I can trigger
> the warning if I have a gpio-button using one of the pca9555 pins as
> an interrupt and then I export some of the other pins via sysfs.
>
> Interestingly the warning isn't triggered if I use a gpio-hog instead
> of exporting the pins. I haven't figured out why that is but I'm
> assuming it's something to do with the hogged pins being excluded from
> the irq domain before it is registered.
I'm starting to understand things.
When the gpio is exported to userland the irq_desc is created via
device_add()/gpio_is_visible()/gpiod_to_irq()/gpiochip_to_irq(). I think
that might be a bug because if the user wanted an interrupt they would
have said so via edge_store() which also does the gpiod_to_irq() that
ultimately creates the irq_desc. Having the gpio turned into an
interrupt seems like an odd side-effect of gpio_is_visible().
Powered by blists - more mailing lists