mirror of https://lore.kernel.org/linux-amlogic/
 help / color / mirror / Atom feed
From: marc.zyngier@arm.com (Marc Zyngier)
To: linus-amlogic@lists.infradead.org
Subject: [RFC] gpio: about the need to manage irq mapping dynamically.
Date: Thu, 29 Jun 2017 17:53:09 +0100	[thread overview]
Message-ID: <e0e11852-2ede-abff-7dc3-badbffecf776@arm.com> (raw)
In-Reply-To: <1498748238.27840.5.camel@baylibre.com>

On 29/06/17 15:57, Jerome Brunet wrote:
> On Thu, 2017-06-29 at 16:14 +0200, Linus Walleij wrote:
>> On Tue, Jun 27, 2017 at 8:25 PM, Jerome Brunet <jbrunet@baylibre.com> wrote:
>>
>>> At the time Linus strongly rejected the idea of calling  irq_create_mapping
>>> (or
>>> any sleeping functions) in gpio_to_irq: please see the reply from Oct 26,
>>> 2016
>>> (sorry for quoting such an old discussion but this is really the starting
>>> point)
>>>
>>> * Me: There is really a *lot* of gpio drivers which use irq_create_mapping
>>> in
>>> the to_irq callback, are these all wrong ?
>>> * Linus: Yes they are all wrong. They should all be using
>>> irq_find_mapping().
>>>
>>> * Me: If this should not be used, what should we all do instead ?
>>> * Linus: Call irq_create_mapping() in some other place.
>>>
>>> gpio_prepare_irq is a proposition for this 'other place'.
>>
>> There is a misunderstanding here.
>>
>> I wrote (at the time):
>>
>>> Yes, but you want to call irq_create_mapping() in slowpath (irq setup)
>>> and irq_find_mapping() in fastpath (irq handler). Else the first IRQ
>>> may result in unwelcomed surprises.
>>
>> This does not mean that irq_create_mapping() cannot be called
>> in irq context because I think it can.
>>
>> What it means is that I think that is suboptimal from a performance
>> point of view if called from gpio_to_irq(), because nominally, at this
>> point, the mapping should already exist, since the GPIO and IRQ
>> frameworks are orthogonal.
> 
> Agreed. It should. In such case, irq_create_mapping is just a call to
> irq_find_mapping which is fine. If, for whatever reason this is not the case,
> this is going to call sleeping function in irq context. It should not happen but
> it is not entirely impossible ...
> 
>>
>> But that may not apply to the case with many-to-few interrupt
>> mappings... so I think I was in some 1-to-1-mapping context
>> when I wrote this. Sorry :(
>>
>> So I changed my mind, it is fine for this type of driver to call
>> irq_create_mapping() in gpio_to_irq(). Preferably with some comment
>> around the call.
> 
> What about disposing of the mapping ? there still is no counter part function to
> gpio_to_irq. It seems weird to leave them lying around, don't you think ?
> 
> Here is a real use we will be having a meson:
> * MMC driver load and call gpio_to_irq on its cd pin
>   This is going to create a mapping 
> * MMC driver request an irq with IRQ_EDGE_BOTH trigger (which we don't/can't
>   support at the moment). request_irq fails.
> * MMC defaults to polling the GPIO
> 
> Remember that we have only 8 possibles mappings. Now there is one (useless)
> mapping lying around which can't get rid of.

Which should be dropped by a dispose_mapping() call in the MMC driver
(or ideally some gpio-specific wrapper around this function).

> If there is more drivers doing this sort of tricks, we are going to exhaust the
> ressource pretty quickly.

We can fix those drivers as we go. It's not like there's a huge variety
of potential HW on this particular platform of yours.

Thanks,

	M.
-- 
Jazz is not dead. It just smells funny...

  reply	other threads:[~2017-06-29 16:53 UTC|newest]

Thread overview: 18+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2017-06-15 16:20 Jerome Brunet
2017-06-20  8:39 ` Linus Walleij
2017-06-20 10:26   ` Jerome Brunet
2017-06-20 16:37     ` Linus Walleij
2017-06-20 17:23       ` Jerome Brunet
2017-06-21 20:50         ` Linus Walleij
2017-06-22 14:25           ` Jerome Brunet
2017-06-27 17:49             ` Grygorii Strashko
2017-06-27 18:25               ` Jerome Brunet
2017-06-27 20:43                 ` Grygorii Strashko
2017-06-29 14:16                   ` Linus Walleij
2017-06-30 19:54                     ` Grygorii Strashko
2017-07-02 15:01                       ` Linus Walleij
2017-06-29 14:14                 ` Linus Walleij
2017-06-29 14:57                   ` Jerome Brunet
2017-06-29 16:53                     ` Marc Zyngier [this message]
2017-06-29 18:33                       ` Jerome Brunet
2017-06-29 22:16                     ` Linus Walleij

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=e0e11852-2ede-abff-7dc3-badbffecf776@arm.com \
    --to=marc.zyngier@arm.com \
    --cc=linus-amlogic@lists.infradead.org \
    /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

all inboxes | Powered by JetHome®