public inbox for linux-kernel@vger.kernel.org
 help / color / mirror / Atom feed
* Re: [PATCH] Optimize i8259 code a bit.
  2007-10-28 23:11 [PATCH] Optimize i8259 code a bit Ralf Baechle
@ 2007-10-28 16:54 ` Thomas Gleixner
  0 siblings, 0 replies; 2+ messages in thread
From: Thomas Gleixner @ 2007-10-28 16:54 UTC (permalink / raw)
  To: Ralf Baechle; +Cc: Andrew Morton, linux-kernel

On Sun, 28 Oct 2007, Ralf Baechle wrote:

> The timer code always calls the clock_event_device set_net_event and
> set_mode methods with interrupts disabled, so no need to use
> spin_lock_irqsave / spin_unlock_irqrestore for those.

Good point,

Acked-by:Thomas Gleixner <tglx@linutronix.de>


> diff --git a/arch/mips/kernel/i8253.c b/arch/mips/kernel/i8253.c
> index 5d9830d..1b54674 100644
> --- a/arch/mips/kernel/i8253.c
> +++ b/arch/mips/kernel/i8253.c
> @@ -23,9 +23,7 @@ static DEFINE_SPINLOCK(i8253_lock);
>  static void init_pit_timer(enum clock_event_mode mode,
>  			   struct clock_event_device *evt)
>  {
> -	unsigned long flags;
> -
> -	spin_lock_irqsave(&i8253_lock, flags);
> +	spin_lock(&i8253_lock);
>  
>  	switch(mode) {
>  	case CLOCK_EVT_MODE_PERIODIC:
> @@ -54,7 +52,7 @@ static void init_pit_timer(enum clock_event_mode mode,
>  		/* Nothing to do here */
>  		break;
>  	}
> -	spin_unlock_irqrestore(&i8253_lock, flags);
> +	spin_unlock(&i8253_lock);
>  }
>  
>  /*
> @@ -64,12 +62,10 @@ static void init_pit_timer(enum clock_event_mode mode,
>   */
>  static int pit_next_event(unsigned long delta, struct clock_event_device *evt)
>  {
> -	unsigned long flags;
> -
> -	spin_lock_irqsave(&i8253_lock, flags);
> +	spin_lock(&i8253_lock);
>  	outb_p(delta & 0xff , PIT_CH0);	/* LSB */
>  	outb(delta >> 8 , PIT_CH0);	/* MSB */
> -	spin_unlock_irqrestore(&i8253_lock, flags);
> +	spin_unlock(&i8253_lock);
>  
>  	return 0;
>  }
> diff --git a/arch/x86/kernel/i8253.c b/arch/x86/kernel/i8253.c
> index a42c807..5246515 100644
> --- a/arch/x86/kernel/i8253.c
> +++ b/arch/x86/kernel/i8253.c
> @@ -31,9 +31,7 @@ struct clock_event_device *global_clock_event;
>  static void init_pit_timer(enum clock_event_mode mode,
>  			   struct clock_event_device *evt)
>  {
> -	unsigned long flags;
> -
> -	spin_lock_irqsave(&i8253_lock, flags);
> +	spin_lock(&i8253_lock);
>  
>  	switch(mode) {
>  	case CLOCK_EVT_MODE_PERIODIC:
> @@ -62,7 +60,7 @@ static void init_pit_timer(enum clock_event_mode mode,
>  		/* Nothing to do here */
>  		break;
>  	}
> -	spin_unlock_irqrestore(&i8253_lock, flags);
> +	spin_unlock(&i8253_lock);
>  }
>  
>  /*
> @@ -72,12 +70,10 @@ static void init_pit_timer(enum clock_event_mode mode,
>   */
>  static int pit_next_event(unsigned long delta, struct clock_event_device *evt)
>  {
> -	unsigned long flags;
> -
> -	spin_lock_irqsave(&i8253_lock, flags);
> +	spin_lock(&i8253_lock);
>  	outb_p(delta & 0xff , PIT_CH0);	/* LSB */
>  	outb(delta >> 8 , PIT_CH0);	/* MSB */
> -	spin_unlock_irqrestore(&i8253_lock, flags);
> +	spin_unlock(&i8253_lock);
>  
>  	return 0;
>  }
> 

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

* [PATCH] Optimize i8259 code a bit.
@ 2007-10-28 23:11 Ralf Baechle
  2007-10-28 16:54 ` Thomas Gleixner
  0 siblings, 1 reply; 2+ messages in thread
From: Ralf Baechle @ 2007-10-28 23:11 UTC (permalink / raw)
  To: Andrew Morton, Thomas Gleixner; +Cc: linux-kernel

The timer code always calls the clock_event_device set_net_event and
set_mode methods with interrupts disabled, so no need to use
spin_lock_irqsave / spin_unlock_irqrestore for those.

 arch/mips/kernel/i8253.c |   12 ++++--------
 arch/x86/kernel/i8253.c  |   12 ++++--------
 2 files changed, 8 insertions(+), 16 deletions(-)

diff --git a/arch/mips/kernel/i8253.c b/arch/mips/kernel/i8253.c
index 5d9830d..1b54674 100644
--- a/arch/mips/kernel/i8253.c
+++ b/arch/mips/kernel/i8253.c
@@ -23,9 +23,7 @@ static DEFINE_SPINLOCK(i8253_lock);
 static void init_pit_timer(enum clock_event_mode mode,
 			   struct clock_event_device *evt)
 {
-	unsigned long flags;
-
-	spin_lock_irqsave(&i8253_lock, flags);
+	spin_lock(&i8253_lock);
 
 	switch(mode) {
 	case CLOCK_EVT_MODE_PERIODIC:
@@ -54,7 +52,7 @@ static void init_pit_timer(enum clock_event_mode mode,
 		/* Nothing to do here */
 		break;
 	}
-	spin_unlock_irqrestore(&i8253_lock, flags);
+	spin_unlock(&i8253_lock);
 }
 
 /*
@@ -64,12 +62,10 @@ static void init_pit_timer(enum clock_event_mode mode,
  */
 static int pit_next_event(unsigned long delta, struct clock_event_device *evt)
 {
-	unsigned long flags;
-
-	spin_lock_irqsave(&i8253_lock, flags);
+	spin_lock(&i8253_lock);
 	outb_p(delta & 0xff , PIT_CH0);	/* LSB */
 	outb(delta >> 8 , PIT_CH0);	/* MSB */
-	spin_unlock_irqrestore(&i8253_lock, flags);
+	spin_unlock(&i8253_lock);
 
 	return 0;
 }
diff --git a/arch/x86/kernel/i8253.c b/arch/x86/kernel/i8253.c
index a42c807..5246515 100644
--- a/arch/x86/kernel/i8253.c
+++ b/arch/x86/kernel/i8253.c
@@ -31,9 +31,7 @@ struct clock_event_device *global_clock_event;
 static void init_pit_timer(enum clock_event_mode mode,
 			   struct clock_event_device *evt)
 {
-	unsigned long flags;
-
-	spin_lock_irqsave(&i8253_lock, flags);
+	spin_lock(&i8253_lock);
 
 	switch(mode) {
 	case CLOCK_EVT_MODE_PERIODIC:
@@ -62,7 +60,7 @@ static void init_pit_timer(enum clock_event_mode mode,
 		/* Nothing to do here */
 		break;
 	}
-	spin_unlock_irqrestore(&i8253_lock, flags);
+	spin_unlock(&i8253_lock);
 }
 
 /*
@@ -72,12 +70,10 @@ static void init_pit_timer(enum clock_event_mode mode,
  */
 static int pit_next_event(unsigned long delta, struct clock_event_device *evt)
 {
-	unsigned long flags;
-
-	spin_lock_irqsave(&i8253_lock, flags);
+	spin_lock(&i8253_lock);
 	outb_p(delta & 0xff , PIT_CH0);	/* LSB */
 	outb(delta >> 8 , PIT_CH0);	/* MSB */
-	spin_unlock_irqrestore(&i8253_lock, flags);
+	spin_unlock(&i8253_lock);
 
 	return 0;
 }

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

end of thread, other threads:[~2007-10-28 16:54 UTC | newest]

Thread overview: 2+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2007-10-28 23:11 [PATCH] Optimize i8259 code a bit Ralf Baechle
2007-10-28 16:54 ` Thomas Gleixner

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox