Re: [PATCH 18/22] Fix M68K irqflags

Previous message: [thread] [date] [author]
Next message: [thread] [date] [author]
From: Greg Ungerer
Date: Tuesday, August 31, 2010 - 11:33 pm

On 31/08/10 06:50, David Howells wrote:

Here is a spin of the same patch, only with a single irqflags.h.
It is closely modeled on the mm version, merging (and cleaning)
the non-mmu bits as needed. There is a fair bit of common code
in here.

It does refactor arch_local_irq_save() but I am pretty sure that
makes no impact (performance or code size). I have left
arch_irq_enable as-is for all, it is not clear to me why it is
the way it is for the mm case (Geert?)

This is not run or compile tested...

Regards
Greg



  arch/m68k/include/asm/irqflags.h  |   88 
+++++++++++++++++++++++++++++++++++++
  arch/m68k/include/asm/system_mm.h |   25 +----------
  arch/m68k/include/asm/system_no.h |   49 +--------------------
  3 files changed, 90 insertions(+), 72 deletions(-)
  create mode 100644 arch/m68k/include/asm/irqflags.h

diff --git a/arch/m68k/include/asm/irqflags.h 
b/arch/m68k/include/asm/irqflags.h
new file mode 100644
index 0000000..b61edcc
--- /dev/null
+++ b/arch/m68k/include/asm/irqflags.h
@@ -0,0 +1,88 @@
+#ifndef _M68K_IRQFLAGS_MM_H
+#define _M68K_IRQFLAGS_MM_H
+
+#include <linux/types.h>
+#include <linux/hardirq.h>
+#include <asm/thread_info.h>
+#include <asm/entry.h>
+
+static inline unsigned long arch_local_save_flags(void)
+{
+	unsigned long flags;
+	asm volatile ("movew %%sr,%0": "=d" (flags) : : "memory");
+	return flags;
+}
+
+static inline void arch_local_irq_disable(void)
+{
+#ifdef CONFIG_COLDFIRE
+	asm volatile (
+		"move	%/sr,%%d0	\n\t"
+		"ori.l	#0x0700,%%d0	\n\t"
+		"move	%%d0,%/sr	\n"
+		: /* no outputs */
+		:
+		: "cc", "%d0", "memory");
+#else
+	asm volatile ("oriw  #0x0700,%%sr" : : : "memory");
+#endif
+}
+
+#ifdef CONFIG_MMU
+#if 0
+static inline void arch_local_irq_enable(void)
+{
+		asm volatile ("andiw %0,%%sr" : : "i" (ALLOWINT) : "memory");
+}
+#else
+#define arch_local_irq_enable()						\
+	do {								\
+		if (MACH_IS_Q40 || !hardirq_count())			\
+			asm volatile ("andiw %0,%%sr"			\
+				      : : "i" (ALLOWINT) : "memory");	\
+	} while (0)
+#endif
+#else
+static inline void arch_local_irq_enable(void)
+{
+#ifdef CONFIG_COLDFIRE
+	asm volatile (
+		"move	%/sr,%%d0	\n\t"
+		"andi.l	#0xf8ff,%%d0	\n\t"
+		"move	%%d0,%/sr	\n"
+		: /* no outputs */
+		:
+		: "cc", "%d0", "memory");
+#else
+	asm volatile (
+		"andiw %0,%%sr"
+		:
+		: "i" (ALLOWINT)
+		: "memory")
+#endif
+}
+#endif
+
+static inline unsigned long arch_local_irq_save(void)
+{
+	unsigned long flags = arch_local_save_flags();
+	arch_local_irq_disable();
+	return flags;
+}
+
+static inline void arch_local_irq_restore(unsigned long flags)
+{
+	asm volatile ("movew %0,%%sr": : "d" (flags) : "memory");
+}
+
+static inline bool arch_irqs_disabled_flags(unsigned long flags)
+{
+	return (flags & ~ALLOWINT) != 0;
+}
+
+static inline bool arch_irqs_disabled(void)
+{
+	return arch_irqs_disabled_flags(arch_local_save_flags());
+}
+
+#endif /* _M68K_IRQFLAGS_MM_H */
diff --git a/arch/m68k/include/asm/system_mm.h 
b/arch/m68k/include/asm/system_mm.h
index 485daec..47b01f4 100644
--- a/arch/m68k/include/asm/system_mm.h
+++ b/arch/m68k/include/asm/system_mm.h
@@ -3,6 +3,7 @@

  #include <linux/linkage.h>
  #include <linux/kernel.h>
+#include <linux/irqflags.h>
  #include <asm/segment.h>
  #include <asm/entry.h>

@@ -62,30 +63,6 @@ asmlinkage void resume(void);
  #define smp_wmb()	barrier()
  #define smp_read_barrier_depends()	((void)0)

-/* interrupt control.. */
-#if 0
-#define local_irq_enable() asm volatile ("andiw %0,%%sr": : "i" 
(ALLOWINT) : "memory")
-#else
-#include <linux/hardirq.h>
-#define local_irq_enable() ({							\
-	if (MACH_IS_Q40 || !hardirq_count())					\
-		asm volatile ("andiw %0,%%sr": : "i" (ALLOWINT) : "memory");	\
-})
-#endif
-#define local_irq_disable() asm volatile ("oriw  #0x0700,%%sr": : : 
"memory")
-#define local_save_flags(x) asm volatile ("movew %%sr,%0":"=d" (x) : : 
"memory")
-#define local_irq_restore(x) asm volatile ("movew %0,%%sr": :"d" (x) : 
"memory")
-
-static inline int irqs_disabled(void)
-{
-	unsigned long flags;
-	local_save_flags(flags);
-	return flags & ~ALLOWINT;
-}
-
-/* For spinlocks etc */
-#define local_irq_save(x)	({ local_save_flags(x); local_irq_disable(); })
-
  #define xchg(ptr,x) ((__typeof__(*(ptr)))__xchg((unsigned 
long)(x),(ptr),sizeof(*(ptr))))

  struct __xchg_dummy { unsigned long a[100]; };
diff --git a/arch/m68k/include/asm/system_no.h 
b/arch/m68k/include/asm/system_no.h
index 08f31bd..2bf670d 100644
--- a/arch/m68k/include/asm/system_no.h
+++ b/arch/m68k/include/asm/system_no.h
@@ -2,6 +2,7 @@
  #define _M68KNOMMU_SYSTEM_H

  #include <linux/linkage.h>
+#include <linux/irqflags.h>
  #include <asm/segment.h>
  #include <asm/entry.h>

@@ -46,54 +47,6 @@ asmlinkage void resume(void);
    (last) = _last;						\
  }

-#ifdef CONFIG_COLDFIRE
-#define local_irq_enable() __asm__ __volatile__ (		\
-	"move %/sr,%%d0\n\t"					\
-	"andi.l #0xf8ff,%%d0\n\t"				\
-	"move %%d0,%/sr\n"					\
-	: /* no outputs */					\
-	:							\
-        : "cc", "%d0", "memory")
-#define local_irq_disable() __asm__ __volatile__ (		\
-	"move %/sr,%%d0\n\t"					\
-	"ori.l #0x0700,%%d0\n\t"				\
-	"move %%d0,%/sr\n"					\
-	: /* no outputs */					\
-	:							\
-	: "cc", "%d0", "memory")
-/* For spinlocks etc */
-#define local_irq_save(x) __asm__ __volatile__ (		\
-	"movew %%sr,%0\n\t"					\
-	"movew #0x0700,%%d0\n\t"				\
-	"or.l  %0,%%d0\n\t"					\
-	"movew %%d0,%/sr"					\
-	: "=d" (x)						\
-	:							\
-	: "cc", "%d0", "memory")
-#else
-
-/* portable version */ /* FIXME - see entry.h*/
-#define ALLOWINT 0xf8ff
-
-#define local_irq_enable() asm volatile ("andiw %0,%%sr": : "i" 
(ALLOWINT) : "memory")
-#define local_irq_disable() asm volatile ("oriw  #0x0700,%%sr": : : 
"memory")
-#endif
-
-#define local_save_flags(x) asm volatile ("movew %%sr,%0":"=d" (x) : : 
"memory")
-#define local_irq_restore(x) asm volatile ("movew %0,%%sr": :"d" (x) : 
"memory")
-
-/* For spinlocks etc */
-#ifndef local_irq_save
-#define local_irq_save(x) do { local_save_flags(x); 
local_irq_disable(); } while (0)
-#endif
-
-#define	irqs_disabled()			\
-({					\
-	unsigned long flags;		\
-	local_save_flags(flags);	\
-	((flags & 0x0700) == 0x0700);	\
-})
-
  #define iret() __asm__ __volatile__ ("rte": : :"memory", "sp", "cc")

  /*



--
Previous message: [thread] [date] [author]
Next message: [thread] [date] [author]

Messages in current thread:
[PATCH 00/22] Name the irq flag handling functions sanely, David Howells, (Thu Aug 26, 6:59 pm)
[PATCH 06/22] Blackfin: Add missing dep to asm/irqflags.h, David Howells, (Thu Aug 26, 6:59 pm)
[PATCH 09/22] h8300: Fix die(), David Howells, (Thu Aug 26, 6:59 pm)
[PATCH 12/22] Fix IRQ flag handling naming, David Howells, (Thu Aug 26, 7:00 pm)
[PATCH 13/22] MIPS: Fix IRQ flags handling, David Howells, (Thu Aug 26, 7:00 pm)
[PATCH 14/22] Fix Alpha irqflags, David Howells, (Thu Aug 26, 7:00 pm)
[PATCH 15/22] Fix H8300 arch, David Howells, (Thu Aug 26, 7:00 pm)
[PATCH 16/22] Fix IA64 irqflags, David Howells, (Thu Aug 26, 7:00 pm)
[PATCH 17/22] Fix m32r irqflags, David Howells, (Thu Aug 26, 7:00 pm)
[PATCH 18/22] Fix M68K irqflags, David Howells, (Thu Aug 26, 7:00 pm)
[PATCH 19/22] Fix PA-RISC irqflags, David Howells, (Thu Aug 26, 7:00 pm)
[PATCH 20/22] Fix powerpc irqflags, David Howells, (Thu Aug 26, 7:00 pm)
[PATCH 21/22] Fix SH irqflags, David Howells, (Thu Aug 26, 7:00 pm)
[PATCH 22/22] Fix Sparc irqflags, David Howells, (Thu Aug 26, 7:00 pm)
Re: [PATCH 18/22] Fix M68K irqflags, Greg Ungerer, (Mon Aug 30, 12:12 am)
Re: [PATCH 18/22] Fix M68K irqflags, David Howells, (Mon Aug 30, 1:50 pm)
Re: [PATCH 18/22] Fix M68K irqflags, Geert Uytterhoeven, (Tue Aug 31, 12:36 am)
Re: [PATCH 18/22] Fix M68K irqflags, David Howells, (Tue Aug 31, 9:00 am)
Re: [PATCH 18/22] Fix M68K irqflags, Greg Ungerer, (Tue Aug 31, 11:33 pm)
Re: [PATCH 18/22] Fix M68K irqflags, Greg Ungerer, (Tue Aug 31, 11:38 pm)
Re: [PATCH 18/22] Fix M68K irqflags, David Howells, (Wed Sep 1, 3:43 am)
Re: [PATCH 18/22] Fix M68K irqflags, David Howells, (Wed Sep 1, 3:46 am)
Re: [PATCH 18/22] Fix M68K irqflags, Greg Ungerer, (Wed Sep 1, 4:21 am)
Re: [PATCH 18/22] Fix M68K irqflags, Greg Ungerer, (Wed Sep 1, 4:22 am)
Re: [PATCH 18/22] Fix M68K irqflags, David Howells, (Wed Sep 1, 4:30 am)
Re: [PATCH 18/22] Fix M68K irqflags, David Howells, (Wed Sep 1, 4:31 am)
Re: [PATCH 18/22] Fix M68K irqflags, Greg Ungerer, (Wed Sep 1, 4:36 am)
Re: [PATCH 18/22] Fix M68K irqflags, David Howells, (Wed Sep 1, 5:03 am)
Re: [PATCH 18/22] Fix M68K irqflags, Greg Ungerer, (Wed Sep 1, 6:46 pm)
Re: [PATCH 18/22] Fix M68K irqflags, David Howells, (Thu Sep 2, 3:20 am)
[PATCH 3/3] Fix M68K irqflags, David Howells, (Thu Sep 2, 3:22 am)
Re: [PATCH 2/3] M68K: Use CONFIG_MMU not __uClinux__ to se ..., Geert Uytterhoeven, (Thu Sep 2, 12:53 pm)
Re: [PATCH 3/3] Fix M68K irqflags, Greg Ungerer, (Thu Sep 2, 6:28 pm)
Re: [PATCH 19/22] Fix PA-RISC irqflags, Kyle McMartin, (Thu Sep 2, 6:40 pm)
Re: [PATCH 3/3] Fix M68K irqflags, David Howells, (Thu Sep 2, 11:44 pm)
Re: [PATCH 19/22] Fix PA-RISC irqflags, David Howells, (Thu Sep 2, 11:48 pm)
Re: [PATCH 3/3] Fix M68K irqflags, Greg Ungerer, (Thu Sep 2, 11:53 pm)
Re: [PATCH 3/3] Fix M68K irqflags, David Howells, (Fri Sep 3, 12:28 am)
Re: [PATCH 3/3] Fix M68K irqflags, David Howells, (Fri Sep 3, 1:05 am)
Re: [PATCH 3/3] Fix M68K irqflags, Greg Ungerer, (Fri Sep 3, 2:28 am)
Re: [PATCH 2/3] M68K: Use CONFIG_MMU not __uClinux__ to se ..., Geert Uytterhoeven, (Fri Sep 3, 2:33 am)
Re: [PATCH 2/3] M68K: Use CONFIG_MMU not __uClinux__ to se ..., Geert Uytterhoeven, (Fri Sep 3, 3:02 am)
Re: [PATCH 3/3] Fix M68K irqflags, David Howells, (Fri Sep 3, 3:05 am)
Re: [PATCH 3/3] Fix M68K irqflags, Greg Ungerer, (Fri Sep 3, 3:38 am)
Re: [PATCH 19/22] Fix PA-RISC irqflags, Kyle McMartin, (Fri Sep 3, 6:31 am)