Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]


Groups > linux.kernel > #1701331

Re: [RFT PATCH v2] gpiolib: allow gpio irqchip to map irqs dynamically

From Grygorii Strashko <grygorii.strashko@ti.com>
Newsgroups linux.kernel
Subject Re: [RFT PATCH v2] gpiolib: allow gpio irqchip to map irqs dynamically
Date 2017-08-01 20:30 +0200
Message-ID <u9K5A-7tS-27@gated-at.bofh.it> (permalink)
References <u5Jrs-7hV-27@gated-at.bofh.it> <u9AfU-pF-17@gated-at.bofh.it> <u9ApA-HZ-7@gated-at.bofh.it>
Organization linux.* mail to news gateway

Show all headers | View raw



On 08/01/2017 03:03 AM, Jerome Brunet wrote:
> On Tue, 2017-08-01 at 09:52 +0200, Linus Walleij wrote:
>> On Fri, Jul 21, 2017 at 6:49 PM, Grygorii Strashko
>> <grygorii.strashko@ti.com> wrote:
>>
>>> Now IRQ mappings are always created for all (allowed) GPIOs in gpiochip in
>>> gpiochip_irqchip_add_key() which goes against the idea of SPARSE_IRQ and,
>>> as result, leads to:
>>>   - increasing of memory consumption for IRQ descriptors most of which will
>>> never ever be used (espessially on platform with a high number of GPIOs).
>>> (sizeof(struct irq_desc) == 256 on my tested platforms)
>>>   - imposibility to use GPIO irqchip APIs by gpio drivers when HW implements
>>> GPIO IRQ functionality as IRQ crossbar/router which has only limited
>>> number of IRQ outputs (example from [1], all GPIOs can be mapped on only 8
>>> IRQs).
> 
> Sorry, I forgot to reply to this thread until now.
> This patch is generalization of create mapping in the gpio_to_irq, right ?
> 
> So the issue of mapping left lying around until the gpio driver is unloaded is
> still there ?

Yep. But this should unblock you work and allow to use static boot time IRQ
mappings (if you'll be able to implement irq_domain hierarchy properly). 

> 
> Having gpio_irq_prepare/gpio_irq_unprepare would solve that, I suppose
> (Again, sorry I could not send an RFC for this yet ...)

Sry, but still do not see how it will work :( But hope you might find the way :) 
Few notes to take into account:

There is no way now to know when you can release mappings and when it's safe to do :(,
except when gpio driver is unloaded.

1) drivers using GPIO IRQ directly (no gpio_to_irq() calls). IRQ can be shared.
IRQ mappings will happen in platform_get_irq()/of_irq_get().
Drivers may call request_irq/free_irq() many times using the same Linux IRQ number.
Such drivers, in many cases, do not expect to call any kind of GPIO APIs.

2) drivers using GPIO as IRQ (gpio_to_irq() calls).
IRQ mappings will happen in gpio_to_irq(). Theoretically driver can call
some API to dispose mappings as it knows when its safe to do, but...
The same IRQ still can be used by another driver as shared IRQ.

Note. IRQ mappings have no refcount.

Regarding, your use case - MMC issue can be WA using irq_valid_mask.
(don't blame me it's just WA).

-- 
regards,
-grygorii

Back to linux.kernel | Previous | Next — Previous in thread | Next in thread | Find similar | Unroll thread


Thread

Re: [RFT PATCH v2] gpiolib: allow gpio irqchip to map irqs dynamically Linus Walleij <linus.walleij@linaro.org> - 2017-08-01 10:00 +0200
  Re: [RFT PATCH v2] gpiolib: allow gpio irqchip to map irqs  dynamically Jerome Brunet <jbrunet@baylibre.com> - 2017-08-01 10:10 +0200
    Re: [RFT PATCH v2] gpiolib: allow gpio irqchip to map irqs  dynamically Grygorii Strashko <grygorii.strashko@ti.com> - 2017-08-01 20:30 +0200
  Re: [RFT PATCH v2] gpiolib: allow gpio irqchip to map irqs dynamically Bartosz Golaszewski <brgl@bgdev.pl> - 2017-08-01 12:00 +0200

csiph-web