All of lore.kernel.org
 help / color / mirror / Atom feed
* [PATCH 2/6] TXx9: Microoptimize interrupt handlers
@ 2008-09-01 13:22 Atsushi Nemoto
  2008-09-03 10:13 ` Sergei Shtylyov
  0 siblings, 1 reply; 3+ messages in thread
From: Atsushi Nemoto @ 2008-09-01 13:22 UTC (permalink / raw)
  To: linux-mips; +Cc: ralf

The IOC interrupt status register on RBTX49XX only have 8 bits.  Use
8-bit version of __fls() to optimize interrupt handlers.

Signed-off-by: Atsushi Nemoto <anemo@mba.ocn.ne.jp>
---
 arch/mips/txx9/rbtx4927/irq.c   |    6 +++---
 arch/mips/txx9/rbtx4938/irq.c   |    8 ++++----
 include/asm-mips/txx9/generic.h |   18 ++++++++++++++++++
 3 files changed, 25 insertions(+), 7 deletions(-)

diff --git a/arch/mips/txx9/rbtx4927/irq.c b/arch/mips/txx9/rbtx4927/irq.c
index 22076e3..9c14ebb 100644
--- a/arch/mips/txx9/rbtx4927/irq.c
+++ b/arch/mips/txx9/rbtx4927/irq.c
@@ -133,9 +133,9 @@ static int toshiba_rbtx4927_irq_nested(int sw_irq)
 	u8 level3;
 
 	level3 = readb(rbtx4927_imstat_addr) & 0x1f;
-	if (level3)
-		sw_irq = RBTX4927_IRQ_IOC + fls(level3) - 1;
-	return sw_irq;
+	if (unlikely(!level3))
+		return -1;
+	return RBTX4927_IRQ_IOC + __fls8(level3);
 }
 
 static void __init toshiba_rbtx4927_irq_ioc_init(void)
diff --git a/arch/mips/txx9/rbtx4938/irq.c b/arch/mips/txx9/rbtx4938/irq.c
index ca2f830..7d21bef 100644
--- a/arch/mips/txx9/rbtx4938/irq.c
+++ b/arch/mips/txx9/rbtx4938/irq.c
@@ -85,10 +85,10 @@ static int toshiba_rbtx4938_irq_nested(int sw_irq)
 	u8 level3;
 
 	level3 = readb(rbtx4938_imstat_addr);
-	if (level3)
-		/* must use fls so onboard ATA has priority */
-		sw_irq = RBTX4938_IRQ_IOC + fls(level3) - 1;
-	return sw_irq;
+	if (unlikely(!level3))
+		return -1;
+	/* must use fls so onboard ATA has priority */
+	return RBTX4938_IRQ_IOC + __fls8(level3);
 }
 
 static void __init
diff --git a/include/asm-mips/txx9/generic.h b/include/asm-mips/txx9/generic.h
index 1e1a9f2..dc85515 100644
--- a/include/asm-mips/txx9/generic.h
+++ b/include/asm-mips/txx9/generic.h
@@ -64,4 +64,22 @@ struct physmap_flash_data;
 void txx9_physmap_flash_init(int no, unsigned long addr, unsigned long size,
 			     const struct physmap_flash_data *pdata);
 
+/* 8 bit version of __fls(): find first bit set (returns 0..7) */
+static inline unsigned int __fls8(unsigned char x)
+{
+	int r = 7;
+
+	if (!(x & 0xf0)) {
+		r -= 4;
+		x <<= 4;
+	}
+	if (!(x & 0xc0)) {
+		r -= 2;
+		x <<= 2;
+	}
+	if (!(x & 0x80))
+		r -= 1;
+	return r;
+}
+
 #endif /* __ASM_TXX9_GENERIC_H */
-- 
1.5.6.3

^ permalink raw reply related	[flat|nested] 3+ messages in thread

* Re: [PATCH 2/6] TXx9: Microoptimize interrupt handlers
  2008-09-01 13:22 [PATCH 2/6] TXx9: Microoptimize interrupt handlers Atsushi Nemoto
@ 2008-09-03 10:13 ` Sergei Shtylyov
  2008-09-03 15:52   ` Atsushi Nemoto
  0 siblings, 1 reply; 3+ messages in thread
From: Sergei Shtylyov @ 2008-09-03 10:13 UTC (permalink / raw)
  To: Atsushi Nemoto; +Cc: linux-mips, ralf

Hello.

Atsushi Nemoto wrote:

> The IOC interrupt status register on RBTX49XX only have 8 bits.  Use
> 8-bit version of __fls() to optimize interrupt handlers.
>   

   But doesn't the patch also change the result of 
toshiba_rbtx49{27|38}_irq_nested() if the register reads back as 0?

> Signed-off-by: Atsushi Nemoto <anemo@mba.ocn.ne.jp>
> ---
>  arch/mips/txx9/rbtx4927/irq.c   |    6 +++---
>  arch/mips/txx9/rbtx4938/irq.c   |    8 ++++----
>  include/asm-mips/txx9/generic.h |   18 ++++++++++++++++++
>  3 files changed, 25 insertions(+), 7 deletions(-)
>
> diff --git a/arch/mips/txx9/rbtx4927/irq.c b/arch/mips/txx9/rbtx4927/irq.c
> index 22076e3..9c14ebb 100644
> --- a/arch/mips/txx9/rbtx4927/irq.c
> +++ b/arch/mips/txx9/rbtx4927/irq.c
> @@ -133,9 +133,9 @@ static int toshiba_rbtx4927_irq_nested(int sw_irq)
>  	u8 level3;
>  
>  	level3 = readb(rbtx4927_imstat_addr) & 0x1f;
> -	if (level3)
> -		sw_irq = RBTX4927_IRQ_IOC + fls(level3) - 1;
> -	return sw_irq;
> +	if (unlikely(!level3))
> +		return -1;
> +	return RBTX4927_IRQ_IOC + __fls8(level3);
>  }
>  
>  static void __init toshiba_rbtx4927_irq_ioc_init(void)
> diff --git a/arch/mips/txx9/rbtx4938/irq.c b/arch/mips/txx9/rbtx4938/irq.c
> index ca2f830..7d21bef 100644
> --- a/arch/mips/txx9/rbtx4938/irq.c
> +++ b/arch/mips/txx9/rbtx4938/irq.c
> @@ -85,10 +85,10 @@ static int toshiba_rbtx4938_irq_nested(int sw_irq)
>  	u8 level3;
>  
>  	level3 = readb(rbtx4938_imstat_addr);
> -	if (level3)
> -		/* must use fls so onboard ATA has priority */
> -		sw_irq = RBTX4938_IRQ_IOC + fls(level3) - 1;
> -	return sw_irq;
> +	if (unlikely(!level3))
> +		return -1;
> +	/* must use fls so onboard ATA has priority */
> +	return RBTX4938_IRQ_IOC + __fls8(level3);
>  }
>  
>  static void __init

WBR, Sergei

^ permalink raw reply	[flat|nested] 3+ messages in thread

* Re: [PATCH 2/6] TXx9: Microoptimize interrupt handlers
  2008-09-03 10:13 ` Sergei Shtylyov
@ 2008-09-03 15:52   ` Atsushi Nemoto
  0 siblings, 0 replies; 3+ messages in thread
From: Atsushi Nemoto @ 2008-09-03 15:52 UTC (permalink / raw)
  To: sshtylyov; +Cc: linux-mips, ralf

On Wed, 03 Sep 2008 14:13:26 +0400, Sergei Shtylyov <sshtylyov@ru.mvista.com> wrote:
> > The IOC interrupt status register on RBTX49XX only have 8 bits.  Use
> > 8-bit version of __fls() to optimize interrupt handlers.
> >   
> 
>    But doesn't the patch also change the result of 
> toshiba_rbtx49{27|38}_irq_nested() if the register reads back as 0?

Yes, now _irq_nested() returns -1 if no interrupts, and it will be
counted as spurious interrupts.  I think this is a little bonus ;)

---
Atsushi Nemoto

^ permalink raw reply	[flat|nested] 3+ messages in thread

end of thread, other threads:[~2008-09-03 15:53 UTC | newest]

Thread overview: 3+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2008-09-01 13:22 [PATCH 2/6] TXx9: Microoptimize interrupt handlers Atsushi Nemoto
2008-09-03 10:13 ` Sergei Shtylyov
2008-09-03 15:52   ` Atsushi Nemoto

This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.