On Tue, 2017-08-01 at 13:27 -0500, Grygorii Strashko wrote: > > 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@xxxxxx> 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. You're right. It took me a while to realise there is a (serious) flaw in my plan :( Thanks for pointing it out Grygorii. I initially planned to do some refcounting in the gpio layer but that would make no sense, as you pointed out, the irq could be shared. This refcounting would only make sense at the irq level. On a more general note, I wonder when is it safe for a driver to dispose of the mapping of a possibly shared irq ? There is no way to know if the mapping is still used somewhere else, or am I missing something again ? > > Regarding, your use case - MMC issue can be WA using irq_valid_mask. > (don't blame me it's just WA). > -- 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