linuxppc-dev.lists.ozlabs.org archive mirror
 help / color / mirror / Atom feed
* [PATCH 1/3] powerpc: Fixup hard_irq_disable semantics
@ 2007-05-10  5:25 Benjamin Herrenschmidt
  2007-05-10  7:44 ` Geert Uytterhoeven
  0 siblings, 1 reply; 3+ messages in thread
From: Benjamin Herrenschmidt @ 2007-05-10  5:25 UTC (permalink / raw)
  To: linux-kernel, linuxppc-dev; +Cc: Andrew Morton, Rusty Russell

This patch renames the raw hard_irq_{enable,disable} into
__hard_irq_{enable,disable} and introduces a higher level
hard_irq_disable() function that can be used by any code
to enforce that IRQs are fully disabled, not only lazy
disabled.

The difference with the __ versions is that it will update
some per-processor fields so that the kernel keeps track and
properly re-enables them in the next local_irq_disable();

This prepares powerpc for my next patch that introduces
hard_irq_disable() generically.

Signed-off-by: Benjamin Herrenschmidt <benh@kernel.crashing.org>

 arch/powerpc/kernel/irq.c               |    2 +-
 arch/powerpc/kernel/swsusp.c            |    4 ----
 arch/powerpc/platforms/cell/pervasive.c |    6 ++----
 include/asm-powerpc/hw_irq.h            |   11 +++++++++--
 4 files changed, 12 insertions(+), 11 deletions(-)

Index: linux-cell/arch/powerpc/kernel/irq.c
===================================================================
--- linux-cell.orig/arch/powerpc/kernel/irq.c	2007-05-10 14:58:56.000000000 +1000
+++ linux-cell/arch/powerpc/kernel/irq.c	2007-05-10 14:58:59.000000000 +1000
@@ -173,7 +173,7 @@ void local_irq_restore(unsigned long en)
 		lv1_get_version_info(&tmp);
 	}
 
-	hard_irq_enable();
+	__hard_irq_enable();
 }
 #endif /* CONFIG_PPC64 */
 
Index: linux-cell/arch/powerpc/kernel/swsusp.c
===================================================================
--- linux-cell.orig/arch/powerpc/kernel/swsusp.c	2007-05-10 14:57:03.000000000 +1000
+++ linux-cell/arch/powerpc/kernel/swsusp.c	2007-05-10 14:57:07.000000000 +1000
@@ -36,8 +36,4 @@ void restore_processor_state(void)
 #ifdef CONFIG_PPC32
 	set_context(current->active_mm->context.id, current->active_mm->pgd);
 #endif
-
-#ifdef CONFIG_PPC64
-	hard_irq_enable();
-#endif
 }
Index: linux-cell/arch/powerpc/platforms/cell/pervasive.c
===================================================================
--- linux-cell.orig/arch/powerpc/platforms/cell/pervasive.c	2007-05-10 14:57:34.000000000 +1000
+++ linux-cell/arch/powerpc/platforms/cell/pervasive.c	2007-05-10 14:57:54.000000000 +1000
@@ -43,12 +43,10 @@ static void cbe_power_save(void)
 	unsigned long ctrl, thread_switch_control;
 
 	/*
-	 * We need to hard disable interrupts, but we also need to mark them
-	 * hard disabled in the PACA so that the local_irq_enable() done by
-	 * our caller upon return propertly hard enables.
+	 * We need to hard disable interrupts, the local_irq_enable() done by
+	 * our caller upon return will hard re-enable.
 	 */
 	hard_irq_disable();
-	get_paca()->hard_enabled = 0;
 
 	ctrl = mfspr(SPRN_CTRLF);
 
Index: linux-cell/include/asm-powerpc/hw_irq.h
===================================================================
--- linux-cell.orig/include/asm-powerpc/hw_irq.h	2007-05-10 14:51:43.000000000 +1000
+++ linux-cell/include/asm-powerpc/hw_irq.h	2007-05-10 14:59:32.000000000 +1000
@@ -48,8 +48,15 @@ extern void iseries_handle_interrupts(vo
 
 #define irqs_disabled()		(local_get_flags() == 0)
 
-#define hard_irq_enable()	__mtmsrd(mfmsr() | MSR_EE, 1)
-#define hard_irq_disable()	__mtmsrd(mfmsr() & ~MSR_EE, 1)
+#define __hard_irq_enable()	__mtmsrd(mfmsr() | MSR_EE, 1)
+#define __hard_irq_disable()	__mtmsrd(mfmsr() & ~MSR_EE, 1)
+
+#define  hard_irq_disable()			\
+	do {					\
+		__hard_irq_disable();		\
+		get_paca()->soft_enabled = 0;	\
+		get_paca()->hard_enabled = 0;	\
+	} while(0)
 
 #else
 

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

* Re: [PATCH 1/3] powerpc: Fixup hard_irq_disable semantics
  2007-05-10  5:25 [PATCH 1/3] powerpc: Fixup hard_irq_disable semantics Benjamin Herrenschmidt
@ 2007-05-10  7:44 ` Geert Uytterhoeven
  2007-05-10  8:44   ` Benjamin Herrenschmidt
  0 siblings, 1 reply; 3+ messages in thread
From: Geert Uytterhoeven @ 2007-05-10  7:44 UTC (permalink / raw)
  To: Benjamin Herrenschmidt
  Cc: linuxppc-dev, Andrew Morton, Rusty Russell, linux-kernel

On Thu, 10 May 2007, Benjamin Herrenschmidt wrote:
> This patch renames the raw hard_irq_{enable,disable} into
> __hard_irq_{enable,disable} and introduces a higher level
> hard_irq_disable() function that can be used by any code
> to enforce that IRQs are fully disabled, not only lazy
> disabled.

Why did you rename hard_irq_enable() too?

Isn't it more logical to have high-level hard_irq_disable() and
hard_irq_enable(), and a special low-level __hard_irq_disable()?

Gr{oetje,eeting}s,

						Geert

--
Geert Uytterhoeven -- Sony Network and Software Technology Center Europe (NSCE)
Geert.Uytterhoeven@sonycom.com ------- The Corporate Village, Da Vincilaan 7-D1
Voice +32-2-7008453 Fax +32-2-7008622 ---------------- B-1935 Zaventem, Belgium

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

* Re: [PATCH 1/3] powerpc: Fixup hard_irq_disable semantics
  2007-05-10  7:44 ` Geert Uytterhoeven
@ 2007-05-10  8:44   ` Benjamin Herrenschmidt
  0 siblings, 0 replies; 3+ messages in thread
From: Benjamin Herrenschmidt @ 2007-05-10  8:44 UTC (permalink / raw)
  To: Geert Uytterhoeven
  Cc: linuxppc-dev, Andrew Morton, Rusty Russell, linux-kernel

On Thu, 2007-05-10 at 09:44 +0200, Geert Uytterhoeven wrote:
> On Thu, 10 May 2007, Benjamin Herrenschmidt wrote:
> > This patch renames the raw hard_irq_{enable,disable} into
> > __hard_irq_{enable,disable} and introduces a higher level
> > hard_irq_disable() function that can be used by any code
> > to enforce that IRQs are fully disabled, not only lazy
> > disabled.
> 
> Why did you rename hard_irq_enable() too?
> 
> Isn't it more logical to have high-level hard_irq_disable() and
> hard_irq_enable(), and a special low-level __hard_irq_disable()?

Not really. If you see my subsequent patch, the idea is to introduce a
single generic hard_irq_disable() which is meant to be called with
irqs already disabled (that is within a local_irq_disable section) to
enforce that if the arch does lazy disabling, it gets hard disabled
at this point.

If we start adding hard_irq_enable() we end up in a can of worms:

 - Do we want all the full set of save/restore etc... ?
 - What if somebody does hard_enable while we are soft-disabled
   -and- have been hard disabled because of a pending interrupt ?
 - What's the point ? :-)

So overall, I want to keep the semantics as simple as they can be. Maybe
I can even add some WARN_ON() to make sure we are in a
local_irq_disable'd section even in the generic one instead of just a
NOP to enfore that.

Cheers,
Ben.

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

end of thread, other threads:[~2007-05-10  8:44 UTC | newest]

Thread overview: 3+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2007-05-10  5:25 [PATCH 1/3] powerpc: Fixup hard_irq_disable semantics Benjamin Herrenschmidt
2007-05-10  7:44 ` Geert Uytterhoeven
2007-05-10  8:44   ` Benjamin Herrenschmidt

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).