Re: [PATCH] IRQ: simplify OMAP2 mask_irq/unmask_irq code

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

 



Paul Walmsley wrote:
Hello Kyungmin,

On Wed, 21 May 2008, Kyungmin Park wrote:

On Wed, May 21, 2008 at 3:21 AM, Paul Walmsley <paul@xxxxxxxxx> wrote:
 static void omap_mask_irq(unsigned int irq)
 {
-       int offset = (irq >> 5) << 5;
+       int offset = irq & (~(IRQ_BITS_PER_REG - 1));

-       if (irq >= 64)
-               irq %= 64;
-       else if (irq >= 32)
-               irq %= 32;
+       irq %= IRQ_BITS_PER_REG;
Is it the right conversion?
If the irq is greater then 32 and less then or equal to  64 it's
result is different.
E.g, If irq is 63 then original irq is 63, but new code is 31

Hmm, in that condition, the result looks the same to me: irq % 32, either way?

More practically, if you look at what it does with that irq variable afterwards, it seems to be a bug if irq is ever greater than 31:

intc_bank_write_reg(1 << irq, &irq_banks[0], INTC_MIR_CLEAR0 + offset);

I think the only case where the new code would work differently than the previous code is if irq > 95. But that would be a bug, since the shift value would then be > 32, for a 32-bit register.

And if this code is right, how about to use mask instead of modulo op?
irq &= (IRQ_BITS_PER_REG - 1);

Hehe, very good point, that would probably save even more cycles! If you agree with the above, perhaps I can convert the code to use that also, and add your Signed-off-by also?

On some code where I used % to detect a counter passing multiples of a certain number, oprofile revealed that the % operator burned a lot of CPU cycles. I suspect this had to do with the counter increasing to very large numbers, but ever since, I've tried to avoid the % operator in critical paths.

Philip

Attachment: smime.p7s
Description: S/MIME Cryptographic Signature


[Index of Archives]     [Linux Arm (vger)]     [ARM Kernel]     [ARM MSM]     [Linux Tegra]     [Linux WPAN Networking]     [Linux Wireless Networking]     [Maemo Users]     [Linux USB Devel]     [Video for Linux]     [Linux Audio Users]     [Yosemite Trails]     [Linux Kernel]     [Linux SCSI]

  Powered by Linux