From: Jon Hunter <jon-hunter@ti.com>
To: balbi@ti.com
Cc: Kevin Hilman <khilman@linaro.org>,
Santosh Shilimkar <santosh.shilimkar@ti.com>,
Linus Walleij <linus.walleij@linaro.org>,
Tony Lindgren <tony@atomide.com>,
linux-omap <linux-omap@vger.kernel.org>,
linux-arm <linux-arm-kernel@lists.infradead.org>
Subject: Re: [PATCH 1/2] gpio/omap: convert gpio irq domain to linear mapping
Date: Mon, 4 Mar 2013 11:58:23 -0600 [thread overview]
Message-ID: <5134E0BF.7050306@ti.com> (raw)
In-Reply-To: <20130304171159.GB14507@arwen.pp.htv.fi>
On 03/04/2013 11:11 AM, Felipe Balbi wrote:
> On Mon, Mar 04, 2013 at 11:06:12AM -0600, Jon Hunter wrote:
>>
>> On 03/02/2013 05:48 AM, Felipe Balbi wrote:
>>> On Fri, Mar 01, 2013 at 11:22:47AM -0600, Jon Hunter wrote:
>>>> Currently the OMAP GPIO driver uses a legacy mapping for the GPIO IRQ
>>>> domain. This is not necessary because we do not need to assign a
>>>> specific interrupt number to the GPIO IRQ domain. Therefore, convert
>>>> the OMAP GPIO driver to use a linear mapping instead.
>>>>
>>>> Please note that this also allows to simplify the logic in the OMAP
>>>> gpio_irq_handler() routine, by using irq_find_mapping() to obtain the
>>>> virtual irq number from the GPIO bank and bank index.
>>>>
>>>> Reported-by: Linus Walleij <linus.walleij@linaro.org>
>>>> Signed-off-by: Jon Hunter <jon-hunter@ti.com>
>>>
>>> Reviewed-by: Felipe Balbi <balbi@ti.com>
>>>
>>> Just one suggestion below for a later patch.
>>>
>>>> @@ -680,7 +686,7 @@ static void gpio_irq_handler(unsigned int irq, struct irq_desc *desc)
>>>> {
>>>> void __iomem *isr_reg = NULL;
>>>> u32 isr;
>>>> - unsigned int gpio_irq, gpio_index;
>>>> + unsigned int i;
>>>> struct gpio_bank *bank;
>>>> int unmasked = 0;
>>>> struct irq_chip *chip = irq_desc_get_chip(desc);
>>>> @@ -721,15 +727,10 @@ static void gpio_irq_handler(unsigned int irq, struct irq_desc *desc)
>>>> if (!isr)
>>>> break;
>>>>
>>>> - gpio_irq = bank->irq_base;
>>>> - for (; isr != 0; isr >>= 1, gpio_irq++) {
>>>> - int gpio = irq_to_gpio(bank, gpio_irq);
>>>> -
>>>> + for (i = 0; isr != 0; isr >>= 1, i++) {
>>>> if (!(isr & 1))
>>>> continue;
>>>
>>> this will iterate over all 32 GPIOs, a better way to handle this would
>>> be to have something like:
>>
>> Worse case, if only bit 31 was set then I agree this is not that
>> efficient. Or even if one bit is set. However, the loop itself will
>> iterate while isr != 0 so not always over each bit. No different to the
>> existing code.
>>
>>> while (isr) {
>>> unsigned long bit = __ffs(isr);
>>>
>>> /* clear this bit */
>>> isr &= ~bit;
>>>
>>> generic_handle_irq(irq_find_mapping(bank->domain, bit);
>>> }
>>>
>>> this way you will only iterate the amount of bits enabled in the isr
>>> register.
>>
>> Definitely cleaner but I am wondering which approach would be more
>> efficient from an instruction standpoint. This could definitely be much
>> more efficient if there is only a couple bits set.
>
> __ffs() is done with CLZ instruction, so it's pretty fast.
Ok, yes I see that now for ARMv5 onwards. Grant has pushed the patch,
but may be we can update this as an optimisation separately.
Thanks
Jon
next prev parent reply other threads:[~2013-03-04 17:58 UTC|newest]
Thread overview: 15+ messages / expand[flat|nested] mbox.gz Atom feed top
2013-03-01 17:22 [PATCH 0/2] gpio/omap: updates for v3.10 Jon Hunter
2013-03-01 17:22 ` [PATCH 1/2] gpio/omap: convert gpio irq domain to linear mapping Jon Hunter
2013-03-02 5:24 ` Santosh Shilimkar
2013-03-02 11:48 ` Felipe Balbi
2013-03-04 17:06 ` Jon Hunter
2013-03-04 17:11 ` Felipe Balbi
2013-03-04 17:58 ` Jon Hunter [this message]
2013-03-04 18:47 ` Felipe Balbi
2013-03-02 19:39 ` Grant Likely
2013-03-01 17:22 ` [PATCH 2/2] gpio/omap: warn if bank is not enabled on setting irq type Jon Hunter
2013-03-02 5:27 ` Santosh Shilimkar
2013-03-02 11:49 ` Felipe Balbi
2013-03-02 19:40 ` Grant Likely
2013-03-01 17:39 ` [PATCH 0/2] gpio/omap: updates for v3.10 Kevin Hilman
2013-03-01 22:52 ` Javier Martinez Canillas
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=5134E0BF.7050306@ti.com \
--to=jon-hunter@ti.com \
--cc=balbi@ti.com \
--cc=khilman@linaro.org \
--cc=linus.walleij@linaro.org \
--cc=linux-arm-kernel@lists.infradead.org \
--cc=linux-omap@vger.kernel.org \
--cc=santosh.shilimkar@ti.com \
--cc=tony@atomide.com \
/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