Re: Should irq_enable/disable be flagging/unflagging gpio lines used as irq?

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



On Sun, Sep 10, 2017 at 4:16 PM, Davide Hug <d@xxxxxxxxxx> wrote:
> On Fri, 8 Sep 2017 16:22:40 +0200
> Linus Walleij <linus.walleij@xxxxxxxxxx> wrote:

>> > 4. Fix the irq problem in the current driver by calling `devm_request_irq` and
>> > `devm_free_irq` instead of just using `disable_irq_nosync` and `enable_irq`,
>> > to prevent setting as output a gpio requested as irq.
>>
>> This makes me feel there is something that needs to be fixed.
>>
>> If IRQs are available we should always try to use them somehow.
>> I don't remember the discussuin fully, but I guess the timer in (3)
>> is started in response to an IRQ? That should work fine.
>
> At each measurement the bidirectional data line is used by the sensor as data
> ready signal. So the IRQ is used only to detect the data ready signal. After that
> the IRQ is disabled to avoid triggering interrupts during the serial
> communication.

That is a fully valid usecase and I think something gpiolib
should be able to support. If it bugs you, it will also soon bug
somebody else.

Somewhere the backing irqchip is talking to gpiochip by
issueing gpiochip_lock_as_irq() on this
line and it should be made to issue gpiochip_unlock_as_irq()
before used as serial line, and then gpiochip_lock_as_irq()
again when the go back to using it as irq.

Currently, this mostly gets done in the .irq_request_resources
and .irq_release_resources of the irqchip.

Intuitively I would say it should be done by
.irq_enable()/.irq_disable() but that has the problem that it
is fastpath, and not all GPIO irqchips can handle that.

Maybe we should do it in .irq_enable()/.irq_disable() in case
the .can_sleep bool on the gpiochip is not set, simply?
This way the irqchip should be able to lock/unlock the GPIO
lines dynamically.

We would need to patch a few drivers, but the generic code
for simple gpio irqchips is in gpiolib.c and can be fixed once
and for all. (Which is kind of why I insist on drivers to use
that...)

Yours,
Linus Walleij
--
To unsubscribe from this list: send the line "unsubscribe linux-gpio" in
the body of a message to majordomo@xxxxxxxxxxxxxxx
More majordomo info at  http://vger.kernel.org/majordomo-info.html



[Index of Archives]     [Linux SPI]     [Linux Kernel]     [Linux ARM (vger)]     [Linux ARM MSM]     [Linux Omap]     [Linux Arm]     [Linux Tegra]     [Fedora ARM]     [Linux for Samsung SOC]     [eCos]     [Linux Fastboot]     [Gcc Help]     [Git]     [DCCP]     [IETF Announce]     [Security]     [Linux MIPS]     [Yosemite Campsites]

  Powered by Linux