Skip to contentSkip to conversation

MN10300: Add SMP support and AM34 CPU core support

PATCH In review David Howells 2 participants 47 messages Oct 26, 2010 – Oct 27, 2010

Subsystems (10)
lore
Share & tools
lore
#0 lore raw

cover MN10300: Add SMP support and AM34 CPU core support

These patches support for the AM34 CPU core variant of the MN10300 arch. This is an SMP capable core, so SMP support is added also.

Further, support for the MN2WS0060 processor (which is AM34 based), and the ASB2364 evaluation board are added to make use of that.

I've placed the SMP caching and TLB code into preliminary patches (#15-#24 and #26-#29) within the series, though the code in them can't be fully utilised until the main SMP patch (#35) is applied. This makes the main SMP cache patch smaller. Similarly, patches for kernel atomic ops (#31) and SMP FPU support (#30) preface the main patch.

There are a couple of patches here that touch code outside of the arch:

(#1) A patch to revert parenthesisation of numbers in asm-offset.h which
breaks the MN10300 assembly code.

(#6) A patch to typedef the smpcall function pointer as it's used in many
places.

(#36) Some changes to the SMSC 911x driver to provide it with hooks by which it
can manipulate the interrupt regs on the ASB2364 board FPGA and find the MAC address in an alternate location.

David

#1 lore raw

PATCH 1/43 Partially revert patch that encloses asm-offset.h numbers in brackets

Partially revert patch:

	commit 3234282f33b29d349bcada40204fc7c8fda7fe72
	Author: Jan Beulich <[email protected]>
	Date:   Tue Oct 19 14:52:26 2010 +0100
	x86, asm: Fix CFI macro invocations to deal with shortcomings in gas

This breaks MN10300 arch as this changes many instances of instructions similar to the following:

MOV number,D0

which represents an immediate value load into:

	MOV	(number),D0

which the assembler then interprets as a load from absolute address.

arch/mn10300/kernel/entry.S:64: Error: Invalid opcode/operands arch/mn10300/kernel/entry.S:65: Error: junk at end of line, first unrecognized character is 0' arch/mn10300/kernel/entry.S:74: Error: Invalid opcode/operands arch/mn10300/kernel/entry.S:74: Error: junk at end of line, first unrecognized character is 1' arch/mn10300/kernel/entry.S:75: Error: Invalid opcode/operands arch/mn10300/kernel/entry.S:76: Error: junk at end of line, first unrecognized character is `0'

cc Jan Beulich <[email protected]>
cc Alexander van Heukelum <[email protected]>
cc H. Peter Anvin <[email protected]>
cc Ingo Molnar <[email protected]>

---

 Kbuild |    2 +-
 1 files changed, 1 insertions(+), 1 deletions(-)
Kbuild +1 -1
index 431f7ca..b00037a 100644
@@ -53,7 +53,7 @@ targets += arch/$(SRCARCH)/kernel/asm-offsets.s
 # Default sed regexp - multiline due to syntax constraints
 define sed-y
 	"/^->/{s:->#\(.*\):/* \1 */:; \
-	s:^->\([^ ]*\) [\$$#]*\([-0-9]*\) \(.*\):#define \1 (\2) /* \3 */:; \
+	s:^->\([^ ]*\) [\$$#]*\([-0-9]*\) \(.*\):#define \1 \2 /* \3 */:; \
 	s:^->\([^ ]*\) [\$$#]*\([^ ]*\) \(.*\):#define \1 \2 /* \3 */:; \
 	s:->::; p;}"
 endef
#2 lore raw

PATCH 2/43 MN10300: BUG to BUG_ON changes

In reply to David Howells

From: Stoyan Gaydarov <[email protected]>

---

 arch/mn10300/kernel/irq.c                      |    3 +--
 arch/mn10300/mm/init.c                         |    3 +--
 arch/mn10300/mm/misalignment.c                 |    3 +--
 arch/mn10300/unit-asb2303/include/unit/timex.h |    3 +--
 arch/mn10300/unit-asb2305/include/unit/timex.h |    3 +--
 5 files changed, 5 insertions(+), 10 deletions(-)
arch/mn10300/kernel/irq.c +1 -2
index e2d5ed8..b5b970d 100644
@@ -159,8 +159,7 @@ asmlinkage void do_IRQ(void)
 	int irq;
 
 	sp = current_stack_pointer();
-	if (sp - (sp & ~(THREAD_SIZE - 1)) < STACK_WARN)
-		BUG();
+	BUG_ON(sp - (sp & ~(THREAD_SIZE - 1)) < STACK_WARN);
 
 	/* make sure local_irq_enable() doesn't muck up the interrupt priority
 	 * setting in EPSW */
arch/mn10300/mm/init.c +1 -2
index 6e6bc0e..f86c283 100644
@@ -84,8 +84,7 @@ void __init mem_init(void)
 	int codesize, reservedpages, datasize, initsize;
 	int tmp;
 
-	if (!mem_map)
-		BUG();
+	BUG_ON(!mem_map);
 
 #define START_PFN	(contig_page_data.bdata->node_min_pfn)
 #define MAX_LOW_PFN	(contig_page_data.bdata->node_low_pfn)
arch/mn10300/mm/misalignment.c +1 -2
index 6dffbf9..eef989c 100644
@@ -449,8 +449,7 @@ found_opcode:
 	       regs->pc, opcode, pop->opcode, pop->params[0], pop->params[1]);
 
 	tmp = format_tbl[pop->format].opsz;
-	if (tmp > noc)
-		BUG(); /* match was less complete than it ought to have been */
+	BUG_ON(tmp > noc); /* match was less complete than it ought to have been */
 
 	if (tmp < noc) {
 		tmp = noc - tmp;
arch/mn10300/unit-asb2303/include/unit/timex.h +1 -2
index f206b63..88cd96b 100644
@@ -50,8 +50,7 @@ static inline void startup_jiffies_counter(void)
 			md = TM0MD_SRC_IOCLK_32;
 			rate = MN10300_JCCLK / 32 / HZ;
 
-			if (rate > TMJCBR_MAX)
-				BUG();
+			BUG_ON(rate > TMJCBR_MAX);
 		}
 	}
 
arch/mn10300/unit-asb2305/include/unit/timex.h +1 -2
index d1c72d5..0860186 100644
@@ -50,8 +50,7 @@ static inline void startup_jiffies_counter(void)
 			md = TM0MD_SRC_IOCLK_32;
 			rate = MN10300_JCCLK / 32 / HZ;
 
-			if (rate > TMJCBR_MAX)
-				BUG();
+			BUG_ON(rate > TMJCBR_MAX);
 		}
 	}
 
#3 lore raw

PATCH 3/43 bitops: Change the bitmap index from int to unsigned long [mn10300]

In reply to David Howells

From: Justin Chen <[email protected]>

Change the index to unsigned long in all bitops for [mn10300]

---

 arch/mn10300/include/asm/bitops.h |   12 ++++++------
 arch/mn10300/lib/bitops.c         |    4 ++--
 2 files changed, 8 insertions(+), 8 deletions(-)
arch/mn10300/include/asm/bitops.h +6 -6
index 3f50e96..6208ea6 100644
@@ -57,7 +57,7 @@
 #define clear_bit(nr, addr) ___clear_bit((nr), (addr))
 
 
-static inline void __clear_bit(int nr, volatile void *addr)
+static inline void __clear_bit(unsigned long nr, volatile void *addr)
 {
 	unsigned int *a = (unsigned int *) addr;
 	int mask;
@@ -70,7 +70,7 @@ static inline void __clear_bit(int nr, volatile void *addr)
 /*
  * test bit
  */
-static inline int test_bit(int nr, const volatile void *addr)
+static inline int test_bit(unsigned long nr, const volatile void *addr)
 {
 	return 1UL & (((const unsigned int *) addr)[nr >> 5] >> (nr & 31));
 }
@@ -78,7 +78,7 @@ static inline int test_bit(int nr, const volatile void *addr)
 /*
  * change bit
  */
-static inline void __change_bit(int nr, volatile void *addr)
+static inline void __change_bit(unsigned long nr, volatile void *addr)
 {
 	int	mask;
 	unsigned int *a = (unsigned int *) addr;
@@ -88,7 +88,7 @@ static inline void __change_bit(int nr, volatile void *addr)
 	*a ^= mask;
 }
 
-extern void change_bit(int nr, volatile void *addr);
+extern void change_bit(unsigned long nr, volatile void *addr);
 
 /*
  * test and set bit
@@ -135,7 +135,7 @@ extern void change_bit(int nr, volatile void *addr);
 /*
  * test and change bit
  */
-static inline int __test_and_change_bit(int nr, volatile void *addr)
+static inline int __test_and_change_bit(unsigned long nr, volatile void *addr)
 {
 	int	mask, retval;
 	unsigned int *a = (unsigned int *)addr;
@@ -148,7 +148,7 @@ static inline int __test_and_change_bit(int nr, volatile void *addr)
 	return retval;
 }
 
-extern int test_and_change_bit(int nr, volatile void *addr);
+extern int test_and_change_bit(unsigned long nr, volatile void *addr);
 
 #include <asm-generic/bitops/lock.h>
 
arch/mn10300/lib/bitops.c +2 -2
index 440a7dc..a66c6cd 100644
@@ -15,7 +15,7 @@
 /*
  * try flipping a bit using BSET and BCLR
  */
-void change_bit(int nr, volatile void *addr)
+void change_bit(unsigned long nr, volatile void *addr)
 {
 	if (test_bit(nr, addr))
 		goto try_clear_bit;
@@ -34,7 +34,7 @@ try_clear_bit:
 /*
  * try flipping a bit using BSET and BCLR and returning the old value
  */
-int test_and_change_bit(int nr, volatile void *addr)
+int test_and_change_bit(unsigned long nr, volatile void *addr)
 {
 	if (test_bit(nr, addr))
 		goto try_clear_bit;
#4 lore raw

PATCH 4/43 mn10300: Use pci_claim_resource

In reply to David Howells

From: by way of Jesse Barnes [email protected] <Matthew Wilcox [email protected]>

Instead of open-coding pci_find_parent_resource and request_resource, just call pci_claim_resource.

---

 arch/mn10300/unit-asb2305/pci-asb2305.c |   16 ++++++----------
 1 files changed, 6 insertions(+), 10 deletions(-)
arch/mn10300/unit-asb2305/pci-asb2305.c +6 -10
index 45b40ac..8e6763e 100644
@@ -93,7 +93,7 @@ static void __init pcibios_allocate_bus_resources(struct list_head *bus_list)
 	struct pci_bus *bus;
 	struct pci_dev *dev;
 	int idx;
-	struct resource *r, *pr;
+	struct resource *r;
 
 	/* Depth-First Search on bus tree */
 	list_for_each_entry(bus, bus_list, node) {
@@ -105,10 +105,8 @@ static void __init pcibios_allocate_bus_resources(struct list_head *bus_list)
 				r = &dev->resource[idx];
 				if (!r->flags)
 					continue;
-				pr = pci_find_parent_resource(dev, r);
 				if (!r->start ||
-				    !pr ||
-				    request_resource(pr, r) < 0) {
+				    pci_claim_resource(dev, idx) < 0) {
 					printk(KERN_ERR "PCI:"
 					       " Cannot allocate resource"
 					       " region %d of bridge %s\n",
@@ -131,7 +129,7 @@ static void __init pcibios_allocate_resources(int pass)
 	struct pci_dev *dev = NULL;
 	int idx, disabled;
 	u16 command;
-	struct resource *r, *pr;
+	struct resource *r;
 
 	for_each_pci_dev(dev) {
 		pci_read_config_word(dev, PCI_COMMAND, &command);
@@ -150,8 +148,7 @@ static void __init pcibios_allocate_resources(int pass)
 				    " (f=%lx, d=%d, p=%d)\n",
 				    pci_name(dev), r->start, r->end, r->flags,
 				    disabled, pass);
-				pr = pci_find_parent_resource(dev, r);
-				if (!pr || request_resource(pr, r) < 0) {
+				if (pci_claim_resource(dev, idx) < 0) {
 					printk(KERN_ERR "PCI:"
 					       " Cannot allocate resource"
 					       " region %d of device %s\n",
@@ -184,7 +181,7 @@ static void __init pcibios_allocate_resources(int pass)
 static int __init pcibios_assign_resources(void)
 {
 	struct pci_dev *dev = NULL;
-	struct resource *r, *pr;
+	struct resource *r;
 
 	if (!(pci_probe & PCI_ASSIGN_ROMS)) {
 		/* Try to use BIOS settings for ROMs, otherwise let
@@ -194,8 +191,7 @@ static int __init pcibios_assign_resources(void)
 			r = &dev->resource[PCI_ROM_RESOURCE];
 			if (!r->flags || !r->start)
 				continue;
-			pr = pci_find_parent_resource(dev, r);
-			if (!pr || request_resource(pr, r) < 0) {
+			if (pci_claim_resource(dev, PCI_ROM_RESOURCE) < 0) {
 				r->end -= r->start;
 				r->start = 0;
 			}
#5 lore raw

PATCH 5/43 MN10300: Prevent cnt32_to_63() from being preempted in sched_clock()

In reply to David Howells

Prevent cnt32_to_63() from being preempted in sched_clock() because it may read its internal counter, get preempted, get delayed for more than the half period of the 'TSC' and then write the internal counter, thus corrupting it.

Whilst some callers of sched_clock() have interrupts disabled or hold spinlocks, not all do, and so preemption must be held here.

Note that sched_clock() is called from lockdep, but that shouldn't be a problem because although preempt_disable() calls into lockdep, lockdep has a recursion counter to deal with this.

---

 arch/mn10300/kernel/time.c |    5 +++++
 1 files changed, 5 insertions(+), 0 deletions(-)
arch/mn10300/kernel/time.c +5 -0
index 8f7f6d2..0b5c856 100644
@@ -54,6 +54,9 @@ unsigned long long sched_clock(void)
 	unsigned long tsc, tmp;
 	unsigned product[3]; /* 96-bit intermediate value */
 
+	/* cnt32_to_63() is not safe with preemption */
+	preempt_disable();
+
 	/* read the TSC value
 	 */
 	tsc = 0 - get_cycles(); /* get_cycles() counts down */
@@ -64,6 +67,8 @@ unsigned long long sched_clock(void)
 	 */
 	tsc64.ll = cnt32_to_63(tsc) & 0x7fffffffffffffffULL;
 
+	preempt_enable();
+
 	/* scale the 64-bit TSC value to a nanosecond value via a 96-bit
 	 * intermediate
 	 */
#6 lore raw

PATCH 6/43 Typedef SMP call function pointer

In reply to David Howells

Typedef the pointer to the function to be called by smp_call_function() and friends:

	typedef void (*smp_call_func_t)(void *info);

as it is used in a fair number of places.

---

 include/linux/smp.h |   19 ++++++++++---------
 kernel/smp.c        |    8 ++++----
 2 files changed, 14 insertions(+), 13 deletions(-)
include/linux/smp.h +10 -9
index cfa2d20..6dc95ca 100644
@@ -13,9 +13,10 @@
 
 extern void cpu_idle(void);
 
+typedef void (*smp_call_func_t)(void *info);
 struct call_single_data {
 	struct list_head list;
-	void (*func) (void *info);
+	smp_call_func_t func;
 	void *info;
 	u16 flags;
 	u16 priv;
@@ -24,8 +25,8 @@ struct call_single_data {
 /* total number of cpus in this system (may exceed NR_CPUS) */
 extern unsigned int total_cpus;
 
-int smp_call_function_single(int cpuid, void (*func) (void *info), void *info,
-				int wait);
+int smp_call_function_single(int cpuid, smp_call_func_t func, void *info,
+			     int wait);
 
 #ifdef CONFIG_SMP
 
@@ -69,15 +70,15 @@ extern void smp_cpus_done(unsigned int max_cpus);
 /*
  * Call a function on all other processors
  */
-int smp_call_function(void(*func)(void *info), void *info, int wait);
+int smp_call_function(smp_call_func_t func, void *info, int wait);
 void smp_call_function_many(const struct cpumask *mask,
-			    void (*func)(void *info), void *info, bool wait);
+			    smp_call_func_t func, void *info, bool wait);
 
 void __smp_call_function_single(int cpuid, struct call_single_data *data,
 				int wait);
 
 int smp_call_function_any(const struct cpumask *mask,
-			  void (*func)(void *info), void *info, int wait);
+			  smp_call_func_t func, void *info, int wait);
 
 /*
  * Generic and arch helpers
@@ -94,7 +95,7 @@ void ipi_call_unlock_irq(void);
 /*
  * Call a function on all processors
  */
-int on_each_cpu(void (*func) (void *info), void *info, int wait);
+int on_each_cpu(smp_call_func_t func, void *info, int wait);
 
 #define MSG_ALL_BUT_SELF	0x8000	/* Assume <32768 CPU's */
 #define MSG_ALL			0x8001
@@ -122,7 +123,7 @@ static inline void smp_send_stop(void) { }
  *	These macros fold the SMP functionality into a single CPU system
  */
 #define raw_smp_processor_id()			0
-static inline int up_smp_call_function(void (*func)(void *), void *info)
+static inline int up_smp_call_function(smp_call_func_t func, void *info)
 {
 	return 0;
 }
@@ -143,7 +144,7 @@ static inline void smp_send_reschedule(int cpu) { }
 static inline void init_call_single_data(void) { }
 
 static inline int
-smp_call_function_any(const struct cpumask *mask, void (*func)(void *info),
+smp_call_function_any(const struct cpumask *mask, smp_call_func_t func,
 		      void *info, int wait)
 {
 	return smp_call_function_single(0, func, info, wait);
kernel/smp.c +4 -4
index ed6aacf..12ed8b0 100644
@@ -267,7 +267,7 @@ static DEFINE_PER_CPU_SHARED_ALIGNED(struct call_single_data, csd_data);
  *
  * Returns 0 on success, else a negative status code.
  */
-int smp_call_function_single(int cpu, void (*func) (void *info), void *info,
+int smp_call_function_single(int cpu, smp_call_func_t func, void *info,
 			     int wait)
 {
 	struct call_single_data d = {
@@ -336,7 +336,7 @@ EXPORT_SYMBOL(smp_call_function_single);
  *	3) any other online cpu in @mask
  */
 int smp_call_function_any(const struct cpumask *mask,
-			  void (*func)(void *info), void *info, int wait)
+			  smp_call_func_t func, void *info, int wait)
 {
 	unsigned int cpu;
 	const struct cpumask *nodemask;
@@ -416,7 +416,7 @@ void __smp_call_function_single(int cpu, struct call_single_data *data,
  * must be disabled when calling this function.
  */
 void smp_call_function_many(const struct cpumask *mask,
-			    void (*func)(void *), void *info, bool wait)
+			    smp_call_func_t func, void *info, bool wait)
 {
 	struct call_function_data *data;
 	unsigned long flags;
@@ -500,7 +500,7 @@ EXPORT_SYMBOL(smp_call_function_many);
  * You must not call this function with disabled interrupts or from a
  * hardware interrupt handler or from a bottom half handler.
  */
-int smp_call_function(void (*func)(void *), void *info, int wait)
+int smp_call_function(smp_call_func_t func, void *info, int wait)
 {
 	preempt_disable();
 	smp_call_function_many(cpu_online_mask, func, info, wait);
#7 lore raw

PATCH 7/43 MN10300: Don't cast away the volatile in test_bit()

In reply to David Howells

From: Akira Takeuchi <[email protected]>

Don't cast away the volatile in test_bit()'s parameter when we change its type from const volatile void * so that we can dereference it.

---

 arch/mn10300/include/asm/bitops.h |    2 +-
 1 files changed, 1 insertions(+), 1 deletions(-)
arch/mn10300/include/asm/bitops.h +1 -1
index 6208ea6..3b8a868 100644
@@ -72,7 +72,7 @@ static inline void __clear_bit(unsigned long nr, volatile void *addr)
  */
 static inline int test_bit(unsigned long nr, const volatile void *addr)
 {
-	return 1UL & (((const unsigned int *) addr)[nr >> 5] >> (nr & 31));
+	return 1UL & (((const volatile unsigned int *) addr)[nr >> 5] >> (nr & 31));
 }
 
 /*
#8 lore raw

PATCH 8/43 MN10300: Add reads[bwl]() and writes[bwl]()

In reply to David Howells

From: Akira Takeuchi <[email protected]>

Add reads[bwl]() and writes[bwl]() for MN10300.

---

 arch/mn10300/include/asm/io.h |   13 +++++++++++++
 1 files changed, 13 insertions(+), 0 deletions(-)
arch/mn10300/include/asm/io.h +13 -0
index c1a4119..787255d 100644
@@ -206,6 +206,19 @@ static inline void outsl(unsigned long addr, const void *buffer, int count)
 #define iowrite32_rep(p, src, count) \
 	outsl((unsigned long) (p), (src), (count))
 
+#define readsb(p, dst, count) \
+	insb((unsigned long) (p), (dst), (count))
+#define readsw(p, dst, count) \
+	insw((unsigned long) (p), (dst), (count))
+#define readsl(p, dst, count) \
+	insl((unsigned long) (p), (dst), (count))
+
+#define writesb(p, src, count) \
+	outsb((unsigned long) (p), (src), (count))
+#define writesw(p, src, count) \
+	outsw((unsigned long) (p), (src), (count))
+#define writesl(p, src, count) \
+	outsl((unsigned long) (p), (src), (count))
 
 #define IO_SPACE_LIMIT 0xffffffff
 
#9 lore raw

PATCH 9/43 MN10300: Provide the functions to fully disable maskable interrupts

In reply to David Howells

From: Akira Takeuchi <[email protected]>

The local_irq_disable() function and co. merely raise the interrupt mask on the MN10300 arch to exclude normal interrupts. This still lets other, higher priority maskable interrupts through, such as are used to service gdbstub's serial port and the MN10300 on-chip serial port virtual FIFOs.

Provide functions to allow the maskable interrupts to be fully disabled, which will exclude those interrupts.

---

 arch/mn10300/include/asm/irqflags.h |   77 +++++++++++++++++++++++++++++++++++
 1 files changed, 77 insertions(+), 0 deletions(-)
arch/mn10300/include/asm/irqflags.h +77 -0
index 5e529a1..f1b64b2 100644
@@ -119,5 +119,82 @@ static inline void arch_safe_halt(void)
 		: "cc");
 }
 
+static inline void arch_local_cli(void)
+{
+	asm volatile(
+		"	and	%0,epsw		\n"
+		"	nop			\n"
+		"	nop			\n"
+		"	nop			\n"
+		:
+		: "i"(~EPSW_IE)
+		: "memory"
+		);
+}
+
+static inline unsigned long arch_local_cli_save(void)
+{
+	unsigned long flags = arch_local_save_flags();
+	arch_local_cli();
+	return flags;
+}
+
+static inline void arch_local_sti(void)
+{
+	asm volatile(
+		"	or	%0,epsw		\n"
+		:
+		: "i"(EPSW_IE)
+		: "memory");
+}
+
+static inline void arch_local_change_intr_mask_level(unsigned long level)
+{
+	asm volatile(
+		"	and	%0,epsw		\n"
+		"	or	%1,epsw		\n"
+		:
+		: "i"(~EPSW_IM), "i"(EPSW_IE | level)
+		: "cc", "memory");
+}
+
+#else /* !__ASSEMBLY__ */
+
+#define LOCAL_SAVE_FLAGS(reg)			\
+	mov	epsw,reg
+
+#define LOCAL_IRQ_DISABLE				\
+	and	~EPSW_IM,epsw;				\
+	or	EPSW_IE|MN10300_CLI_LEVEL,epsw;		\
+	nop;						\
+	nop;						\
+	nop
+
+#define LOCAL_IRQ_ENABLE		\
+	or	EPSW_IE|EPSW_IM_7,epsw
+
+#define LOCAL_IRQ_RESTORE(reg)	\
+	mov	reg,epsw
+
+#define LOCAL_CLI_SAVE(reg)	\
+	mov	epsw,reg;	\
+	and	~EPSW_IE,epsw;	\
+	nop;			\
+	nop;			\
+	nop
+
+#define LOCAL_CLI		\
+	and	~EPSW_IE,epsw;	\
+	nop;			\
+	nop;			\
+	nop
+
+#define LOCAL_STI		\
+	or	EPSW_IE,epsw
+
+#define LOCAL_CHANGE_INTR_MASK_LEVEL(level)	\
+	and	~EPSW_IM,epsw;			\
+	or	EPSW_IE|(level),epsw
+
 #endif /* __ASSEMBLY__ */
 #endif /* _ASM_IRQFLAGS_H */
#10 lore raw

PATCH 10/43 MN10300: Differentiate AM33_2 and AM33_3 in config

In reply to David Howells

From: Akira Takeuchi <[email protected]>

Differentiate AM33_2 and AM33_3 CPU cores in configuration. The MN103E010 processor contains an AM33_2 core.

Whilst we're at it, prepare for AM34-based stuff by declaring AM34_2 too.

---

 arch/mn10300/Kconfig |   11 +++++++++--
 1 files changed, 9 insertions(+), 2 deletions(-)
arch/mn10300/Kconfig +9 -2
index 7c2a2f7..275963e 100644
@@ -9,8 +9,14 @@ config MN10300
 	def_bool y
 	select HAVE_OPROFILE
 
-config AM33
-	def_bool y
+config AM33_2
+	def_bool n
+
+config AM33_3
+	def_bool n
+
+config AM34_2
+	def_bool n
 
 config MMU
 	def_bool y
@@ -99,6 +105,7 @@ choice
 config MN10300_PROC_MN103E010
 	bool "MN103E010"
 	depends on MN10300_UNIT_ASB2303 || MN10300_UNIT_ASB2305
+	select AM33_2
 	select MN10300_PROC_HAS_TTYSM0
 	select MN10300_PROC_HAS_TTYSM1
 	select MN10300_PROC_HAS_TTYSM2
#11 lore raw

PATCH 11/43 MN10300: Move DMA engine control reg defs to MN103E010 processor directory

In reply to David Howells

From: Akira Takeuchi <[email protected]>

Move the DMA engine control register definitions to the MN103E010 processor directory so that the MN2WS0050 processor can have its own.

---

 arch/mn10300/include/asm/dmactl-regs.h             |   87 -----------------
 .../proc-mn103e010/include/proc/dmactl-regs.h      |  102 ++++++++++++++++++++
 2 files changed, 103 insertions(+), 86 deletions(-)
 create mode 100644 arch/mn10300/proc-mn103e010/include/proc/dmactl-regs.h
arch/mn10300/include/asm/dmactl-regs.h +1 -86
index 58a199d..80337b3 100644
@@ -11,91 +11,6 @@
 #ifndef _ASM_DMACTL_REGS_H
 #define _ASM_DMACTL_REGS_H
 
-#include <asm/cpu-regs.h>
-
-#ifdef __KERNEL__
-
-/* DMA registers */
-#define	DMxCTR(N)		__SYSREG(0xd2000000 + ((N) * 0x100), u32)	/* control reg */
-#define	DMxCTR_BG		0x0000001f	/* transfer request source */
-#define	DMxCTR_BG_SOFT		0x00000000	/* - software source */
-#define	DMxCTR_BG_SC0TX		0x00000002	/* - serial port 0 transmission */
-#define	DMxCTR_BG_SC0RX		0x00000003	/* - serial port 0 reception */
-#define	DMxCTR_BG_SC1TX		0x00000004	/* - serial port 1 transmission */
-#define	DMxCTR_BG_SC1RX		0x00000005	/* - serial port 1 reception */
-#define	DMxCTR_BG_SC2TX		0x00000006	/* - serial port 2 transmission */
-#define	DMxCTR_BG_SC2RX		0x00000007	/* - serial port 2 reception */
-#define	DMxCTR_BG_TM0UFLOW	0x00000008	/* - timer 0 underflow */
-#define	DMxCTR_BG_TM1UFLOW	0x00000009	/* - timer 1 underflow */
-#define	DMxCTR_BG_TM2UFLOW	0x0000000a	/* - timer 2 underflow */
-#define	DMxCTR_BG_TM3UFLOW	0x0000000b	/* - timer 3 underflow */
-#define	DMxCTR_BG_TM6ACMPCAP	0x0000000c	/* - timer 6A compare/capture */
-#define	DMxCTR_BG_AFE		0x0000000d	/* - analogue front-end interrupt source */
-#define	DMxCTR_BG_ADC		0x0000000e	/* - A/D conversion end interrupt source */
-#define	DMxCTR_BG_IRDA		0x0000000f	/* - IrDA interrupt source */
-#define	DMxCTR_BG_RTC		0x00000010	/* - RTC interrupt source */
-#define	DMxCTR_BG_XIRQ0		0x00000011	/* - XIRQ0 pin interrupt source */
-#define	DMxCTR_BG_XIRQ1		0x00000012	/* - XIRQ1 pin interrupt source */
-#define	DMxCTR_BG_XDMR0		0x00000013	/* - external request 0 source (XDMR0 pin) */
-#define	DMxCTR_BG_XDMR1		0x00000014	/* - external request 1 source (XDMR1 pin) */
-#define	DMxCTR_SAM		0x000000e0	/* DMA transfer src addr mode */
-#define	DMxCTR_SAM_INCR		0x00000000	/* - increment */
-#define	DMxCTR_SAM_DECR		0x00000020	/* - decrement */
-#define	DMxCTR_SAM_FIXED	0x00000040	/* - fixed */
-#define	DMxCTR_DAM		0x00000000	/* DMA transfer dest addr mode */
-#define	DMxCTR_DAM_INCR		0x00000000	/* - increment */
-#define	DMxCTR_DAM_DECR		0x00000100	/* - decrement */
-#define	DMxCTR_DAM_FIXED	0x00000200	/* - fixed */
-#define	DMxCTR_TM		0x00001800	/* DMA transfer mode */
-#define	DMxCTR_TM_BATCH		0x00000000	/* - batch transfer */
-#define	DMxCTR_TM_INTERM	0x00001000	/* - intermittent transfer */
-#define	DMxCTR_UT		0x00006000	/* DMA transfer unit */
-#define	DMxCTR_UT_1		0x00000000	/* - 1 byte */
-#define	DMxCTR_UT_2		0x00002000	/* - 2 byte */
-#define	DMxCTR_UT_4		0x00004000	/* - 4 byte */
-#define	DMxCTR_UT_16		0x00006000	/* - 16 byte */
-#define	DMxCTR_TEN		0x00010000	/* DMA channel transfer enable */
-#define	DMxCTR_RQM		0x00060000	/* external request input source mode */
-#define	DMxCTR_RQM_FALLEDGE	0x00000000	/* - falling edge */
-#define	DMxCTR_RQM_RISEEDGE	0x00020000	/* - rising edge */
-#define	DMxCTR_RQM_LOLEVEL	0x00040000	/* - low level */
-#define	DMxCTR_RQM_HILEVEL	0x00060000	/* - high level */
-#define	DMxCTR_RQF		0x01000000	/* DMA transfer request flag */
-#define	DMxCTR_XEND		0x80000000	/* DMA transfer end flag */
-
-#define	DMxSRC(N)		__SYSREG(0xd2000004 + ((N) * 0x100), u32)	/* control reg */
-
-#define	DMxDST(N)		__SYSREG(0xd2000008 + ((N) * 0x100), u32)	/* src addr reg */
-
-#define	DMxSIZ(N)		__SYSREG(0xd200000c + ((N) * 0x100), u32)	/* dest addr reg */
-#define DMxSIZ_CT		0x000fffff	/* number of bytes to transfer */
-
-#define	DMxCYC(N)		__SYSREG(0xd2000010 + ((N) * 0x100), u32)	/* intermittent
-										 * size reg */
-#define DMxCYC_CYC		0x000000ff	/* number of interrmittent transfers -1 */
-
-#define DM0IRQ			16		/* DMA channel 0 complete IRQ */
-#define DM1IRQ			17		/* DMA channel 1 complete IRQ */
-#define DM2IRQ			18		/* DMA channel 2 complete IRQ */
-#define DM3IRQ			19		/* DMA channel 3 complete IRQ */
-
-#define	DM0ICR			GxICR(DM0IRQ)	/* DMA channel 0 complete intr ctrl reg */
-#define	DM1ICR			GxICR(DM0IR1)	/* DMA channel 1 complete intr ctrl reg */
-#define	DM2ICR			GxICR(DM0IR2)	/* DMA channel 2 complete intr ctrl reg */
-#define	DM3ICR			GxICR(DM0IR3)	/* DMA channel 3 complete intr ctrl reg */
-
-#ifndef __ASSEMBLY__
-
-struct mn10300_dmactl_regs {
-	u32		ctr;
-	const void	*src;
-	void		*dst;
-	u32		siz;
-	u32		cyc;
-} __attribute__((aligned(0x100)));
-
-#endif /* __ASSEMBLY__ */
-
-#endif /* __KERNEL__ */
+#include <proc/dmactl-regs.h>
 
 #endif /* _ASM_DMACTL_REGS_H */
arch/mn10300/proc-mn103e010/include/proc/dmactl-regs.h new file +102 -0

102 lines not on this page · raw message

#12 lore raw

PATCH 12/43 MN10300: Don't hard code the cacheline size in register defs

In reply to David Howells

From: Akira Takeuchi <[email protected]>

Don't hard code the cacheline size in the cache control register definitions.

---

 arch/mn10300/include/asm/cache.h |   14 +++++++++-----
 1 files changed, 9 insertions(+), 5 deletions(-)
arch/mn10300/include/asm/cache.h +9 -5
index 781bf61..f29cde2 100644
@@ -43,14 +43,18 @@
 
 /* instruction cache access registers */
 #define ICACHE_DATA(WAY, ENTRY, OFF) \
-	__SYSREG(0xc8000000 + (WAY) * L1_CACHE_WAYDISP + (ENTRY) * 0x10 + (OFF) * 4, u32)
+	__SYSREG(0xc8000000 + (WAY) * L1_CACHE_WAYDISP + \
+		(ENTRY) * L1_CACHE_BYTES + (OFF) * 4, u32)
 #define ICACHE_TAG(WAY, ENTRY)	 \
-	__SYSREG(0xc8100000 + (WAY) * L1_CACHE_WAYDISP + (ENTRY) * 0x10, u32)
+	__SYSREG(0xc8100000 + (WAY) * L1_CACHE_WAYDISP + \
+		(ENTRY) * L1_CACHE_BYTES, u32)
 
-/* instruction cache access registers */
+/* data cache access registers */
 #define DCACHE_DATA(WAY, ENTRY, OFF) \
-	__SYSREG(0xc8200000 + (WAY) * L1_CACHE_WAYDISP + (ENTRY) * 0x10 + (OFF) * 4, u32)
+	__SYSREG(0xc8200000 + (WAY) * L1_CACHE_WAYDISP + \
+		(ENTRY) * L1_CACHE_BYTES + (OFF) * 4, u32)
 #define DCACHE_TAG(WAY, ENTRY)	 \
-	__SYSREG(0xc8300000 + (WAY) * L1_CACHE_WAYDISP + (ENTRY) * 0x10, u32)
+	__SYSREG(0xc8300000 + (WAY) * L1_CACHE_WAYDISP + \
+		(ENTRY) * L1_CACHE_BYTES, u32)
 
 #endif /* _ASM_CACHE_H */
#13 lore raw

PATCH 13/43 MN10300: Add CPU register bits for AM34

In reply to David Howells

From: Akira Takeuchi <[email protected]>

Add CPU register declarations for the AM34 subarch.

---

 arch/mn10300/Kconfig                |    7 +++
 arch/mn10300/include/asm/cpu-regs.h |   72 +++++++++++++++++++++++++++++++++--
 2 files changed, 74 insertions(+), 5 deletions(-)
arch/mn10300/Kconfig +7 -0
index 275963e..eab0c2a 100644
@@ -17,6 +17,7 @@ config AM33_3
 
 config AM34_2
 	def_bool n
+	select MN10300_HAS_ATOMIC_OPS_UNIT
 
 config MMU
 	def_bool y
@@ -124,6 +125,12 @@ config MN10300_CPU_AM33V2
 
 endchoice
 
+config MN10300_HAS_ATOMIC_OPS_UNIT
+	def_bool n
+	help
+	  This should be enabled if the processor has an atomic ops unit
+	  capable of doing LL/SC equivalent operations.
+
 config FPU
 	bool "FPU present"
 	default y
arch/mn10300/include/asm/cpu-regs.h +67 -5

114 lines not on this page · raw message

#14 lore raw

PATCH 14/43 MN10300: Remove monitor/JTAG functions

In reply to David Howells

From: Akira Takeuchi <[email protected]>

Remove the monitor trap function and the set_jtag_stub function as they're not really necessary.

---

 arch/mn10300/include/asm/exceptions.h |    5 ++---
 arch/mn10300/kernel/entry.S           |   25 -------------------------
 arch/mn10300/kernel/traps.c           |   22 ----------------------
 arch/mn10300/mm/fault.c               |    5 -----
 4 files changed, 2 insertions(+), 55 deletions(-)
arch/mn10300/include/asm/exceptions.h +2 -3
index fa16466..3f3826a 100644
@@ -15,8 +15,8 @@
 
 /*
  * define the breakpoint instruction opcode to use
- * - note that the JTAG unit steals 0xFF, so we want to avoid that if we can
- *   (can use 0xF7)
+ * - note that the JTAG unit steals 0xFF, so you can't use JTAG and GDBSTUB at
+ *   the same time.
  */
 #define GDBSTUB_BKPT		0xFF
 
@@ -90,7 +90,6 @@ enum exception_code {
 
 extern void __set_intr_stub(enum exception_code code, void *handler);
 extern void set_intr_stub(enum exception_code code, void *handler);
-extern void set_jtag_stub(enum exception_code code, void *handler);
 
 struct pt_regs;
 
arch/mn10300/kernel/entry.S +0 -25
index 3d394b4..b82ce7b 100644
@@ -216,31 +216,6 @@ ENTRY(irq_handler)
 
 ###############################################################################
 #
-# Monitor Signal handler entry point
-#
-###############################################################################
-ENTRY(monitor_signal)
-	movbu	(0xae000001),d1
-	cmp	1,d1
-	beq	monsignal
-	ret	[],0
-
-monsignal:
-	or	EPSW_NMID,epsw
-	mov	d0,a0
-	mov	a0,sp
-	mov	(REG_EPSW,fp),d1
-	and	~EPSW_nSL,d1
-	mov	d1,(REG_EPSW,fp)
-	movm	(sp),[d2,d3,a2,a3,exreg0,exreg1,exother]
-	mov	(sp),a1
-	mov	a1,usp
-	movm	(sp),[other]
-	add	4,sp
-here:	jmp	0x8e000008-here+0x8e000008
-
-###############################################################################
-#
 # Double Fault handler entry point
 # - note that there will not be a stack, D0/A0 will hold EPSW/PC as were
 #
arch/mn10300/kernel/traps.c +0 -22
index 91365ad..a64604b 100644
@@ -538,28 +538,6 @@ void __init set_intr_stub(enum exception_code code, void *handler)
 }
 
 /*
- * set an interrupt stub to invoke the JTAG unit and then jump to a handler
- */
-void __init set_jtag_stub(enum exception_code code, void *handler)
-{
-	unsigned long addr;
-	u8 *vector = (u8 *)(CONFIG_INTERRUPT_VECTOR_BASE + code);
-
-	addr = (unsigned long) handler - ((unsigned long) vector + 1);
-	vector[0] = 0xff;		/* PI to jump into JTAG debugger */
-	vector[1] = 0xdc;		/* jmp handler */
-	vector[2] = addr;
-	vector[3] = addr >> 8;
-	vector[4] = addr >> 16;
-	vector[5] = addr >> 24;
-	vector[6] = 0xcb;
-	vector[7] = 0xcb;
-
-	mn10300_dcache_flush_inv();
-	flush_icache_range((unsigned long) vector, (unsigned long) vector + 8);
-}
-
-/*
  * initialise the exception table
  */
 void __init trap_init(void)
arch/mn10300/mm/fault.c +0 -5
index 81f153f..906e4c8 100644
@@ -100,8 +100,6 @@ static void print_pagetable_entries(pgd_t *pgdir, unsigned long address)
 }
 #endif
 
-asmlinkage void monitor_signal(struct pt_regs *);
-
 /*
  * This routine handles page faults.  It determines the address,
  * and the problem, and then passes it off to one of the appropriate
@@ -279,7 +277,6 @@ good_area:
  */
 bad_area:
 	up_read(&mm->mmap_sem);
-	monitor_signal(regs);
 
 	/* User mode accesses just cause a SIGSEGV */
 	if ((fault_code & MMUFCR_xFC_ACCESS) == MMUFCR_xFC_ACCESS_USR) {
@@ -292,7 +289,6 @@ bad_area:
 	}
 
 no_context:
-	monitor_signal(regs);
 	/* Are we prepared to handle this kernel fault?  */
 	if (fixup_exception(regs))
 		return;
@@ -345,7 +341,6 @@ out_of_memory:
 
 do_sigbus:
 	up_read(&mm->mmap_sem);
-	monitor_signal(regs);
 
 	/*
 	 * Send a sigbus, regardless of whether we were in kernel
#15 lore raw

PATCH 15/43 MN10300: Cache: Split cache bits out of arch Kconfig

In reply to David Howells

Split the cache bits out of arch/mn10300/Kconfig as they're quite complex.

---

 arch/mn10300/Kconfig          |   29 +----------------------------
 arch/mn10300/mm/Kconfig.cache |   32 ++++++++++++++++++++++++++++++++
 2 files changed, 33 insertions(+), 28 deletions(-)
 create mode 100644 arch/mn10300/mm/Kconfig.cache
arch/mn10300/Kconfig +1 -28
index eab0c2a..069e34d 100644
@@ -136,34 +136,7 @@ config FPU
 	default y
 	depends on MN10300_PROC_MN103E010
 
-choice
-	prompt "CPU Caching mode"
-	default MN10300_CACHE_WBACK
-	help
-	  This option determines the caching mode for the kernel.
-
-	  Write-Back caching mode involves the all reads and writes causing
-	  the affected cacheline to be read into the cache first before being
-	  operated upon. Memory is not then updated by a write until the cache
-	  is filled and a cacheline needs to be displaced from the cache to
-	  make room. Only at that point is it written back.
-
-	  Write-Through caching only fetches cachelines from memory on a
-	  read. Writes always get written directly to memory. If the affected
-	  cacheline is also in cache, it will be updated too.
-
-	  The final option is to turn of caching entirely.
-
-config MN10300_CACHE_WBACK
-	bool "Write-Back"
-
-config MN10300_CACHE_WTHRU
-	bool "Write-Through"
-
-config MN10300_CACHE_DISABLED
-	bool "Disabled"
-
-endchoice
+source "arch/mn10300/mm/Kconfig.cache"
 
 menu "Memory layout options"
 
arch/mn10300/mm/Kconfig.cache new file +32 -0
new file mode 100644
index 0000000..f5599f4
@@ -0,0 +1,32 @@
+#
+# MN10300 CPU cache options
+#
+
+choice
+	prompt "CPU Caching mode"
+	default MN10300_CACHE_WBACK
+	help
+	  This option determines the caching mode for the kernel.
+
+	  Write-Back caching mode involves the all reads and writes causing
+	  the affected cacheline to be read into the cache first before being
+	  operated upon. Memory is not then updated by a write until the cache
+	  is filled and a cacheline needs to be displaced from the cache to
+	  make room. Only at that point is it written back.
+
+	  Write-Through caching only fetches cachelines from memory on a
+	  read. Writes always get written directly to memory. If the affected
+	  cacheline is also in cache, it will be updated too.
+
+	  The final option is to turn of caching entirely.
+
+config MN10300_CACHE_WBACK
+	bool "Write-Back"
+
+config MN10300_CACHE_WTHRU
+	bool "Write-Through"
+
+config MN10300_CACHE_DISABLED
+	bool "Disabled"
+
+endchoice
#16 lore raw

PATCH 16/43 MN10300: Provide a MN10300_CACHE_ENABLED config option

In reply to David Howells

Provide a MN10300_CACHE_ENABLED config option as inverted logic of MN10300_CACHE_DISABLED to make things simpler.

---

 arch/mn10300/include/asm/cacheflush.h |    6 +++---
 arch/mn10300/include/asm/gdb-stub.h   |    2 +-
 arch/mn10300/include/asm/processor.h  |    4 ++--
 arch/mn10300/kernel/Makefile          |    2 +-
 arch/mn10300/kernel/head.S            |    6 +++---
 arch/mn10300/mm/Kconfig.cache         |    3 +++
 6 files changed, 13 insertions(+), 10 deletions(-)
arch/mn10300/include/asm/cacheflush.h +3 -3
index 29e692f..b85be1d 100644
@@ -34,7 +34,7 @@
 /*
  * physically-indexed cache management
  */
-#ifndef CONFIG_MN10300_CACHE_DISABLED
+#ifdef CONFIG_MN10300_CACHE_ENABLED
 
 extern void flush_icache_range(unsigned long start, unsigned long end);
 extern void flush_icache_page(struct vm_area_struct *vma, struct page *pg);
@@ -61,7 +61,7 @@ extern void flush_icache_page(struct vm_area_struct *vma, struct page *pg);
 /*
  * primitive routines
  */
-#ifndef CONFIG_MN10300_CACHE_DISABLED
+#ifdef CONFIG_MN10300_CACHE_ENABLED
 extern void mn10300_icache_inv(void);
 extern void mn10300_dcache_inv(void);
 extern void mn10300_dcache_inv_page(unsigned start);
@@ -103,7 +103,7 @@ extern void mn10300_dcache_flush_inv_range2(unsigned start, unsigned size);
 #define mn10300_dcache_flush_page(start)		do {} while (0)
 #define mn10300_dcache_flush_range(start, end)		do {} while (0)
 #define mn10300_dcache_flush_range2(start, size)	do {} while (0)
-#endif /* CONFIG_MN10300_CACHE_DISABLED */
+#endif /* CONFIG_MN10300_CACHE_ENABLED */
 
 /*
  * internal debugging function
arch/mn10300/include/asm/gdb-stub.h +1 -1
index 41ed267..f5495ad 100644
@@ -110,7 +110,7 @@ extern asmlinkage void gdbstub_exception(struct pt_regs *, enum exception_code);
 extern asmlinkage void __gdbstub_bug_trap(void);
 extern asmlinkage void __gdbstub_pause(void);
 
-#ifndef CONFIG_MN10300_CACHE_DISABLED
+#ifdef CONFIG_MN10300_CACHE_ENABLED
 extern asmlinkage void gdbstub_purge_cache(void);
 #else
 #define gdbstub_purge_cache()	do {} while (0)
arch/mn10300/include/asm/processor.h +2 -2
index f7d4b0d..fd96c18 100644
@@ -157,7 +157,7 @@ unsigned long get_wchan(struct task_struct *p);
 
 static inline void prefetch(const void *x)
 {
-#ifndef CONFIG_MN10300_CACHE_DISABLED
+#ifdef CONFIG_MN10300_CACHE_ENABLED
 #ifdef CONFIG_MN10300_PROC_MN103E010
 	asm volatile ("nop; nop; dcpf (%0)" : : "r"(x));
 #else
@@ -168,7 +168,7 @@ static inline void prefetch(const void *x)
 
 static inline void prefetchw(const void *x)
 {
-#ifndef CONFIG_MN10300_CACHE_DISABLED
+#ifdef CONFIG_MN10300_CACHE_ENABLED
 #ifdef CONFIG_MN10300_PROC_MN103E010
 	asm volatile ("nop; nop; dcpf (%0)" : : "r"(x));
 #else
arch/mn10300/kernel/Makefile +1 -1
index 23f2ab6..c4289e3 100644
@@ -17,7 +17,7 @@ obj-$(CONFIG_GDBSTUB) += gdb-stub.o gdb-low.o
 obj-$(CONFIG_GDBSTUB_ON_TTYSx) += gdb-io-serial.o gdb-io-serial-low.o
 obj-$(CONFIG_GDBSTUB_ON_TTYSMx) += gdb-io-ttysm.o gdb-io-ttysm-low.o
 
-ifneq ($(CONFIG_MN10300_CACHE_DISABLED),y)
+ifeq ($(CONFIG_MN10300_CACHE_ENABLED),y)
 obj-$(CONFIG_GDBSTUB) += gdb-cache.o
 endif
 
arch/mn10300/kernel/head.S +3 -3
index 14f27f3..a81e34f 100644
@@ -61,18 +61,18 @@ _start:
 	btst	CHCTR_ICBUSY|CHCTR_DCBUSY,d0		# wait till not busy
 	lne
 
-#ifndef CONFIG_MN10300_CACHE_DISABLED
+#ifdef CONFIG_MN10300_CACHE_ENABLED
 #ifdef CONFIG_MN10300_CACHE_WBACK
 #ifndef CONFIG_MN10300_CACHE_WBACK_NOWRALLOC
 	mov	CHCTR_ICEN|CHCTR_DCEN|CHCTR_DCWTMD_WRBACK,d0
 #else
 	mov	CHCTR_ICEN|CHCTR_DCEN|CHCTR_DCWTMD_WRBACK|CHCTR_DCALMD,d0
-#endif /* CACHE_DISABLED */
+#endif /* NOWRALLOC */
 #else
 	mov	CHCTR_ICEN|CHCTR_DCEN|CHCTR_DCWTMD_WRTHROUGH,d0
 #endif /* WBACK */
 	movhu	d0,(a0)					# enable
-#endif /* NOWRALLOC */
+#endif /* ENABLED */
 
 	# turn on RTS on the debug serial port if applicable
 #ifdef CONFIG_MN10300_UNIT_ASB2305
arch/mn10300/mm/Kconfig.cache +3 -0
index f5599f4..56a88dd 100644
@@ -30,3 +30,6 @@ config MN10300_CACHE_DISABLED
 	bool "Disabled"
 
 endchoice
+
+config MN10300_CACHE_ENABLED
+	def_bool y if !MN10300_CACHE_DISABLED
#17 lore raw

PATCH 17/43 MN10300: Reorder asm/cacheflush.h to put primitives first

In reply to David Howells

Reorder asm/cacheflush.h to put arch primitives first, before the main functions so that the main functions can be inline asm rather than #defines when non-trivial.

---

 arch/mn10300/include/asm/cacheflush.h |   88 +++++++++++++++++----------------
 1 files changed, 44 insertions(+), 44 deletions(-)
arch/mn10300/include/asm/cacheflush.h +44 -44
index b85be1d..0b5d004 100644
@@ -17,49 +17,7 @@
 #include <linux/mm.h>
 
 /*
- * virtually-indexed cache management (our cache is physically indexed)
- */
-#define flush_cache_all()			do {} while (0)
-#define flush_cache_mm(mm)			do {} while (0)
-#define flush_cache_dup_mm(mm)			do {} while (0)
-#define flush_cache_range(mm, start, end)	do {} while (0)
-#define flush_cache_page(vma, vmaddr, pfn)	do {} while (0)
-#define flush_cache_vmap(start, end)		do {} while (0)
-#define flush_cache_vunmap(start, end)		do {} while (0)
-#define ARCH_IMPLEMENTS_FLUSH_DCACHE_PAGE 0
-#define flush_dcache_page(page)			do {} while (0)
-#define flush_dcache_mmap_lock(mapping)		do {} while (0)
-#define flush_dcache_mmap_unlock(mapping)	do {} while (0)
-
-/*
- * physically-indexed cache management
- */
-#ifdef CONFIG_MN10300_CACHE_ENABLED
-
-extern void flush_icache_range(unsigned long start, unsigned long end);
-extern void flush_icache_page(struct vm_area_struct *vma, struct page *pg);
-
-#else
-
-#define flush_icache_range(start, end)		do {} while (0)
-#define flush_icache_page(vma, pg)		do {} while (0)
-
-#endif
-
-#define flush_icache_user_range(vma, pg, adr, len) \
-	flush_icache_range(adr, adr + len)
-
-#define copy_to_user_page(vma, page, vaddr, dst, src, len) \
-	do {					\
-		memcpy(dst, src, len);		\
-		flush_icache_page(vma, page);	\
-	} while (0)
-
-#define copy_from_user_page(vma, page, vaddr, dst, src, len) \
-	memcpy(dst, src, len)
-
-/*
- * primitive routines
+ * Primitive routines
  */
 #ifdef CONFIG_MN10300_CACHE_ENABLED
 extern void mn10300_icache_inv(void);
@@ -106,7 +64,49 @@ extern void mn10300_dcache_flush_inv_range2(unsigned start, unsigned size);
 #endif /* CONFIG_MN10300_CACHE_ENABLED */
 
 /*
- * internal debugging function
+ * Virtually-indexed cache management (our cache is physically indexed)
+ */
+#define flush_cache_all()			do {} while (0)
+#define flush_cache_mm(mm)			do {} while (0)
+#define flush_cache_dup_mm(mm)			do {} while (0)
+#define flush_cache_range(mm, start, end)	do {} while (0)
+#define flush_cache_page(vma, vmaddr, pfn)	do {} while (0)
+#define flush_cache_vmap(start, end)		do {} while (0)
+#define flush_cache_vunmap(start, end)		do {} while (0)
+#define ARCH_IMPLEMENTS_FLUSH_DCACHE_PAGE 0
+#define flush_dcache_page(page)			do {} while (0)
+#define flush_dcache_mmap_lock(mapping)		do {} while (0)
+#define flush_dcache_mmap_unlock(mapping)	do {} while (0)
+
+/*
+ * Physically-indexed cache management
+ */
+#ifdef CONFIG_MN10300_CACHE_ENABLED
+
+extern void flush_icache_range(unsigned long start, unsigned long end);
+extern void flush_icache_page(struct vm_area_struct *vma, struct page *pg);
+
+#else
+
+#define flush_icache_range(start, end)		do {} while (0)
+#define flush_icache_page(vma, pg)		do {} while (0)
+
+#endif
+
+#define flush_icache_user_range(vma, pg, adr, len) \
+	flush_icache_range(adr, adr + len)
+
+#define copy_to_user_page(vma, page, vaddr, dst, src, len) \
+	do {					\
+		memcpy(dst, src, len);		\
+		flush_icache_page(vma, page);	\
+	} while (0)
+
+#define copy_from_user_page(vma, page, vaddr, dst, src, len) \
+	memcpy(dst, src, len)
+
+/*
+ * Internal debugging function
  */
 #ifdef CONFIG_DEBUG_PAGEALLOC
 extern void kernel_map_pages(struct page *page, int numpages, int enable);
#18 lore raw

PATCH 18/43 MN10300: AM34: The current cacheflush routines operate by controlling tag regs

In reply to David Howells

The current cache flush and invalidate routines operate by controlling the cache tag registers. Rename the files and add config items to select them.

This makes it easier to support the use of other cache flush methods instead, such as the use of AM34's area purge registers, if available.

---

 arch/mn10300/mm/Kconfig.cache         |   20 ++
 arch/mn10300/mm/Makefile              |    5 -
 arch/mn10300/mm/cache-flush-by-tag.S  |  192 ++++++++++++++++++++++
 arch/mn10300/mm/cache-flush-mn10300.S |  192 ----------------------
 arch/mn10300/mm/cache-inv-by-tag.S    |  289 +++++++++++++++++++++++++++++++++
 arch/mn10300/mm/cache-mn10300.S       |  289 ---------------------------------
 6 files changed, 504 insertions(+), 483 deletions(-)
 create mode 100644 arch/mn10300/mm/cache-flush-by-tag.S
 delete mode 100644 arch/mn10300/mm/cache-flush-mn10300.S
 create mode 100644 arch/mn10300/mm/cache-inv-by-tag.S
 delete mode 100644 arch/mn10300/mm/cache-mn10300.S
arch/mn10300/mm/Kconfig.cache +20 -0
index 56a88dd..aa6ff07 100644
@@ -33,3 +33,23 @@ endchoice
 
 config MN10300_CACHE_ENABLED
 	def_bool y if !MN10300_CACHE_DISABLED
+
+
+choice
+	prompt "CPU cache flush/invalidate method"
+	default MN10300_CACHE_MANAGE_BY_TAG
+	depends on MN10300_CACHE_ENABLED
+	help
+	  This determines the method by which CPU cache flushing and
+	  invalidation is performed.
+
+config MN10300_CACHE_MANAGE_BY_TAG
+	bool "Use the cache tag registers directly"
+
+endchoice
+
+config MN10300_CACHE_INV_BY_TAG
+	def_bool y if MN10300_CACHE_MANAGE_BY_TAG && MN10300_CACHE_ENABLED
+
+config MN10300_CACHE_FLUSH_BY_TAG
+	def_bool y if MN10300_CACHE_MANAGE_BY_TAG && MN10300_CACHE_WBACK
arch/mn10300/mm/Makefile +3 -2
index 1557277..dc4b9f0 100644
@@ -2,8 +2,9 @@
 # Makefile for the MN10300-specific memory management code
 #
 
-cacheflush-y	:= cache.o cache-mn10300.o
-cacheflush-$(CONFIG_MN10300_CACHE_WBACK) += cache-flush-mn10300.o
+cacheflush-y	:= cache.o
+cacheflush-$(CONFIG_MN10300_CACHE_INV_BY_TAG) += cache-inv-by-tag.o
+cacheflush-$(CONFIG_MN10300_CACHE_FLUSH_BY_TAG) += cache-flush-by-tag.o
 
 cacheflush-$(CONFIG_MN10300_CACHE_DISABLED) := cache-disabled.o
 
arch/mn10300/mm/cache-flush-by-tag.S new file +192 -0

192 lines not on this page · raw message

arch/mn10300/mm/cache-flush-mn10300.S deleted +0 -192

192 lines not on this page · raw message

arch/mn10300/mm/cache-inv-by-tag.S new file +289 -0

289 lines not on this page · raw message

arch/mn10300/mm/cache-mn10300.S deleted +0 -289

289 lines not on this page · raw message

#19 lore raw

PATCH 19/43 MN10300: Cacheflush functions should take unsigned long addresses

In reply to David Howells

From: Akira Takeuchi <[email protected]>

The functions that perform cache flushing should take addresses of unsigned long type, not unsigned int.

---

 arch/mn10300/include/asm/cacheflush.h |   18 +++++++++---------
 arch/mn10300/mm/cache-flush-by-tag.S  |   12 ++++++------
 2 files changed, 15 insertions(+), 15 deletions(-)
arch/mn10300/include/asm/cacheflush.h +9 -9
index 0b5d004..a9f4168 100644
@@ -22,18 +22,18 @@
 #ifdef CONFIG_MN10300_CACHE_ENABLED
 extern void mn10300_icache_inv(void);
 extern void mn10300_dcache_inv(void);
-extern void mn10300_dcache_inv_page(unsigned start);
-extern void mn10300_dcache_inv_range(unsigned start, unsigned end);
-extern void mn10300_dcache_inv_range2(unsigned start, unsigned size);
+extern void mn10300_dcache_inv_page(unsigned long start);
+extern void mn10300_dcache_inv_range(unsigned long start, unsigned long end);
+extern void mn10300_dcache_inv_range2(unsigned long start, unsigned long size);
 #ifdef CONFIG_MN10300_CACHE_WBACK
 extern void mn10300_dcache_flush(void);
-extern void mn10300_dcache_flush_page(unsigned start);
-extern void mn10300_dcache_flush_range(unsigned start, unsigned end);
-extern void mn10300_dcache_flush_range2(unsigned start, unsigned size);
+extern void mn10300_dcache_flush_page(unsigned long start);
+extern void mn10300_dcache_flush_range(unsigned long start, unsigned long end);
+extern void mn10300_dcache_flush_range2(unsigned long start, unsigned long size);
 extern void mn10300_dcache_flush_inv(void);
-extern void mn10300_dcache_flush_inv_page(unsigned start);
-extern void mn10300_dcache_flush_inv_range(unsigned start, unsigned end);
-extern void mn10300_dcache_flush_inv_range2(unsigned start, unsigned size);
+extern void mn10300_dcache_flush_inv_page(unsigned long start);
+extern void mn10300_dcache_flush_inv_range(unsigned long start, unsigned long end);
+extern void mn10300_dcache_flush_inv_range2(unsigned long start, unsigned long size);
 #else
 #define mn10300_dcache_flush()				do {} while (0)
 #define mn10300_dcache_flush_page(start)		do {} while (0)
arch/mn10300/mm/cache-flush-by-tag.S +6 -6
index c8ed1cb..8fe90e4 100644
@@ -62,9 +62,9 @@ mn10300_dcache_flush_end:
 
 ###############################################################################
 #
-# void mn10300_dcache_flush_page(unsigned start)
-# void mn10300_dcache_flush_range(unsigned start, unsigned end)
-# void mn10300_dcache_flush_range2(unsigned start, unsigned size)
+# void mn10300_dcache_flush_page(unsigned long start)
+# void mn10300_dcache_flush_range(unsigned long start, unsigned long end)
+# void mn10300_dcache_flush_range2(unsigned long start, unsigned long size)
 # Flush a range of addresses on a page in the dcache
 #
 ###############################################################################
@@ -142,9 +142,9 @@ mn10300_dcache_flush_inv_end:
 
 ###############################################################################
 #
-# void mn10300_dcache_flush_inv_page(unsigned start)
-# void mn10300_dcache_flush_inv_range(unsigned start, unsigned end)
-# void mn10300_dcache_flush_inv_range2(unsigned start, unsigned size)
+# void mn10300_dcache_flush_inv_page(unsigned long start)
+# void mn10300_dcache_flush_inv_range(unsigned long start, unsigned long end)
+# void mn10300_dcache_flush_inv_range2(unsigned long start, unsigned long size)
 # Flush and invalidate a range of addresses on a page in the dcache
 #
 ###############################################################################
#20 lore raw

PATCH 20/43 MN10300: SMP: Differentiate local cache flushing

In reply to David Howells

From: Akira Takeuchi <[email protected]>

Differentiate local cache flushing from global cache flushing so that they can be done differently on SMP systems.

Rename the cache functions from:

	mn10300_[id]cache_*()

to:

	mn10300_[id]_localcache_*()

and on a UP system, assign the global labels to the local labels.

---

 arch/mn10300/include/asm/cacheflush.h            |   50 ++++++
 arch/mn10300/mm/cache-flush-by-tag.S             |  143 +++++++++++-----
 arch/mn10300/mm/cache-inv-by-tag.S               |  199 ++++++++++++++--------
 arch/mn10300/proc-mn103e010/include/proc/cache.h |    9 +
 4 files changed, 289 insertions(+), 112 deletions(-)
arch/mn10300/include/asm/cacheflush.h +50 -0
index a9f4168..748143f 100644
@@ -20,12 +20,31 @@
  * Primitive routines
  */
 #ifdef CONFIG_MN10300_CACHE_ENABLED
+extern void mn10300_local_icache_inv(void);
+extern void mn10300_local_icache_inv_page(unsigned long start);
+extern void mn10300_local_icache_inv_range(unsigned long start, unsigned long end);
+extern void mn10300_local_icache_inv_range2(unsigned long start, unsigned long size);
+extern void mn10300_local_dcache_inv(void);
+extern void mn10300_local_dcache_inv_page(unsigned long start);
+extern void mn10300_local_dcache_inv_range(unsigned long start, unsigned long end);
+extern void mn10300_local_dcache_inv_range2(unsigned long start, unsigned long size);
 extern void mn10300_icache_inv(void);
+extern void mn10300_icache_inv_page(unsigned long start);
+extern void mn10300_icache_inv_range(unsigned long start, unsigned long end);
+extern void mn10300_icache_inv_range2(unsigned long start, unsigned long size);
 extern void mn10300_dcache_inv(void);
 extern void mn10300_dcache_inv_page(unsigned long start);
 extern void mn10300_dcache_inv_range(unsigned long start, unsigned long end);
 extern void mn10300_dcache_inv_range2(unsigned long start, unsigned long size);
 #ifdef CONFIG_MN10300_CACHE_WBACK
+extern void mn10300_local_dcache_flush(void);
+extern void mn10300_local_dcache_flush_page(unsigned long start);
+extern void mn10300_local_dcache_flush_range(unsigned long start, unsigned long end);
+extern void mn10300_local_dcache_flush_range2(unsigned long start, unsigned long size);
+extern void mn10300_local_dcache_flush_inv(void);
+extern void mn10300_local_dcache_flush_inv_page(unsigned long start);
+extern void mn10300_local_dcache_flush_inv_range(unsigned long start, unsigned long end);
+extern void mn10300_local_dcache_flush_inv_range2(unsigned long start, unsigned long size);
 extern void mn10300_dcache_flush(void);
 extern void mn10300_dcache_flush_page(unsigned long start);
 extern void mn10300_dcache_flush_range(unsigned long start, unsigned long end);
@@ -35,6 +54,18 @@ extern void mn10300_dcache_flush_inv_page(unsigned long start);
 extern void mn10300_dcache_flush_inv_range(unsigned long start, unsigned long end);
 extern void mn10300_dcache_flush_inv_range2(unsigned long start, unsigned long size);
 #else
+#define mn10300_local_dcache_flush()			do {} while (0)
+#define mn10300_local_dcache_flush_page(start)		do {} while (0)
+#define mn10300_local_dcache_flush_range(start, end)	do {} while (0)
+#define mn10300_local_dcache_flush_range2(start, size)	do {} while (0)
+#define mn10300_local_dcache_flush_inv() \
+		mn10300_local_dcache_inv()
+#define mn10300_local_dcache_flush_inv_page(start) \
+		mn10300_local_dcache_inv_page(start)
+#define mn10300_local_dcache_flush_inv_range(start, end) \
+		mn10300_local_dcache_inv_range(start, end)
+#define mn10300_local_dcache_flush_inv_range2(start, size) \
+		mn10300_local_dcache_inv_range2(start, size)
 #define mn10300_dcache_flush()				do {} while (0)
 #define mn10300_dcache_flush_page(start)		do {} while (0)
 #define mn10300_dcache_flush_range(start, end)		do {} while (0)
@@ -48,7 +79,26 @@ extern void mn10300_dcache_flush_inv_range2(unsigned long start, unsigned long s
 	mn10300_dcache_inv_range2((start), (size))
 #endif /* CONFIG_MN10300_CACHE_WBACK */
 #else
+#define mn10300_local_icache_inv()			do {} while (0)
+#define mn10300_local_icache_inv_page(start)		do {} while (0)
+#define mn10300_local_icache_inv_range(start, end)	do {} while (0)
+#define mn10300_local_icache_inv_range2(start, size)	do {} while (0)
+#define mn10300_local_dcache_inv()			do {} while (0)
+#define mn10300_local_dcache_inv_page(start)		do {} while (0)
+#define mn10300_local_dcache_inv_range(start, end)	do {} while (0)
+#define mn10300_local_dcache_inv_range2(start, size)	do {} while (0)
+#define mn10300_local_dcache_flush()			do {} while (0)
+#define mn10300_local_dcache_flush_inv_page(start)	do {} while (0)
+#define mn10300_local_dcache_flush_inv()		do {} while (0)
+#define mn10300_local_dcache_flush_inv_range(start, end)do {} while (0)
+#define mn10300_local_dcache_flush_inv_range2(start, size) do {} while (0)
+#define mn10300_local_dcache_flush_page(start)		do {} while (0)
+#define mn10300_local_dcache_flush_range(start, end)	do {} while (0)
+#define mn10300_local_dcache_flush_range2(start, size)	do {} while (0)
 #define mn10300_icache_inv()				do {} while (0)
+#define mn10300_icache_inv_page(start)			do {} while (0)
+#define mn10300_icache_inv_range(start, end)		do {} while (0)
+#define mn10300_icache_inv_range2(start, size)		do {} while (0)
 #define mn10300_dcache_inv()				do {} while (0)
 #define mn10300_dcache_inv_page(start)			do {} while (0)
 #define mn10300_dcache_inv_range(start, end)		do {} while (0)
arch/mn10300/mm/cache-flush-by-tag.S +101 -42

247 lines not on this page · raw message

arch/mn10300/mm/cache-inv-by-tag.S +129 -70

335 lines not on this page · raw message

arch/mn10300/proc-mn103e010/include/proc/cache.h +9 -0
index bdc1f9a..c152800 100644
@@ -30,4 +30,13 @@
  */
 #define MN10300_DCACHE_INV_RANGE_INTR_LOG2_INTERVAL	4
 
+/*
+ * The size of range at which it becomes more economical to just flush the
+ * whole cache rather than trying to flush the specified range.
+ */
+#define MN10300_DCACHE_FLUSH_BORDER	\
+	+(L1_CACHE_NWAYS * L1_CACHE_NENTRIES * L1_CACHE_BYTES)
+#define MN10300_DCACHE_FLUSH_INV_BORDER	\
+	+(L1_CACHE_NWAYS * L1_CACHE_NENTRIES * L1_CACHE_BYTES)
+
 #endif /* _ASM_PROC_CACHE_H */
#21 lore raw

PATCH 21/43 MN10300: AM34: Add cacheflushing by using the AM34 purge registers

In reply to David Howells

From: Akira Takeuchi <[email protected]>

The AM34 CPU core provides an automated way of purging the cache rather than manually iterating over all the tags in the cache. Make it possible to use these.

---

 arch/mn10300/mm/Kconfig.cache        |   13 +
 arch/mn10300/mm/Makefile             |    2 
 arch/mn10300/mm/cache-flush-by-reg.S |  308 +++++++++++++++++++++++++++++
 arch/mn10300/mm/cache-inv-by-reg.S   |  356 ++++++++++++++++++++++++++++++++++
 4 files changed, 678 insertions(+), 1 deletions(-)
 create mode 100644 arch/mn10300/mm/cache-flush-by-reg.S
 create mode 100644 arch/mn10300/mm/cache-inv-by-reg.S
arch/mn10300/mm/Kconfig.cache +12 -1
index aa6ff07..97adc06 100644
@@ -37,7 +37,8 @@ config MN10300_CACHE_ENABLED
 
 choice
 	prompt "CPU cache flush/invalidate method"
-	default MN10300_CACHE_MANAGE_BY_TAG
+	default MN10300_CACHE_MANAGE_BY_TAG if !AM34_2
+	default MN10300_CACHE_MANAGE_BY_REG if AM34_2
 	depends on MN10300_CACHE_ENABLED
 	help
 	  This determines the method by which CPU cache flushing and
@@ -46,10 +47,20 @@ choice
 config MN10300_CACHE_MANAGE_BY_TAG
 	bool "Use the cache tag registers directly"
 
+config MN10300_CACHE_MANAGE_BY_REG
+	bool "Flush areas by way of automatic purge registers (AM34 only)"
+	depends on AM34_2
+
 endchoice
 
 config MN10300_CACHE_INV_BY_TAG
 	def_bool y if MN10300_CACHE_MANAGE_BY_TAG && MN10300_CACHE_ENABLED
 
+config MN10300_CACHE_INV_BY_REG
+	def_bool y if MN10300_CACHE_MANAGE_BY_REG && MN10300_CACHE_ENABLED
+
 config MN10300_CACHE_FLUSH_BY_TAG
 	def_bool y if MN10300_CACHE_MANAGE_BY_TAG && MN10300_CACHE_WBACK
+
+config MN10300_CACHE_FLUSH_BY_REG
+	def_bool y if MN10300_CACHE_MANAGE_BY_REG && MN10300_CACHE_WBACK
arch/mn10300/mm/Makefile +2 -0
index dc4b9f0..7b99723 100644
@@ -4,7 +4,9 @@
 
 cacheflush-y	:= cache.o
 cacheflush-$(CONFIG_MN10300_CACHE_INV_BY_TAG) += cache-inv-by-tag.o
+cacheflush-$(CONFIG_MN10300_CACHE_INV_BY_REG) += cache-inv-by-reg.o
 cacheflush-$(CONFIG_MN10300_CACHE_FLUSH_BY_TAG) += cache-flush-by-tag.o
+cacheflush-$(CONFIG_MN10300_CACHE_FLUSH_BY_REG) += cache-flush-by-reg.o
 
 cacheflush-$(CONFIG_MN10300_CACHE_DISABLED) := cache-disabled.o
 
arch/mn10300/mm/cache-flush-by-reg.S new file +308 -0

308 lines not on this page · raw message

arch/mn10300/mm/cache-inv-by-reg.S new file +356 -0

356 lines not on this page · raw message

#22 lore raw

PATCH 22/43 MN10300: Allow some cacheflushes to be avoided if cache snooping is available

In reply to David Howells

The AM34 core is able to do cache snooping, and so can skip some of the cache flushing.

---

 arch/mn10300/Kconfig                  |    1 
 arch/mn10300/include/asm/cacheflush.h |   16 ++--
 arch/mn10300/kernel/kprobes.c         |    4 +
 arch/mn10300/kernel/traps.c           |    2 
 arch/mn10300/mm/Kconfig.cache         |   34 ++++++++
 arch/mn10300/mm/Makefile              |    2 
 arch/mn10300/mm/cache-flush-icache.c  |  137 +++++++++++++++++++++++++++++++++
 arch/mn10300/mm/cache-inv-icache.c    |  119 +++++++++++++++++++++++++++++
 arch/mn10300/mm/cache.c               |   90 ----------------------
 9 files changed, 309 insertions(+), 96 deletions(-)
 create mode 100644 arch/mn10300/mm/cache-flush-icache.c
 create mode 100644 arch/mn10300/mm/cache-inv-icache.c
arch/mn10300/Kconfig +1 -0
index 069e34d..21e2a53 100644
@@ -18,6 +18,7 @@ config AM33_3
 config AM34_2
 	def_bool n
 	select MN10300_HAS_ATOMIC_OPS_UNIT
+	select MN10300_HAS_CACHE_SNOOP
 
 config MMU
 	def_bool y
arch/mn10300/include/asm/cacheflush.h +10 -6
index 748143f..faed902 100644
@@ -131,18 +131,22 @@ extern void mn10300_dcache_flush_inv_range2(unsigned long start, unsigned long s
 /*
  * Physically-indexed cache management
  */
-#ifdef CONFIG_MN10300_CACHE_ENABLED
-
+#if defined(CONFIG_MN10300_CACHE_FLUSH_ICACHE)
+extern void flush_icache_page(struct vm_area_struct *vma, struct page *page);
+extern void flush_icache_range(unsigned long start, unsigned long end);
+#elif defined(CONFIG_MN10300_CACHE_INV_ICACHE)
+static inline void flush_icache_page(struct vm_area_struct *vma,
+				     struct page *page)
+{
+	mn10300_icache_inv_page(page_to_phys(page));
+}
 extern void flush_icache_range(unsigned long start, unsigned long end);
-extern void flush_icache_page(struct vm_area_struct *vma, struct page *pg);
-
 #else
-
 #define flush_icache_range(start, end)		do {} while (0)
 #define flush_icache_page(vma, pg)		do {} while (0)
-
 #endif
 
+
 #define flush_icache_user_range(vma, pg, adr, len) \
 	flush_icache_range(adr, adr + len)
 
arch/mn10300/kernel/kprobes.c +4 -0
index 67e6389..0311a7f 100644
@@ -377,8 +377,10 @@ void __kprobes arch_arm_kprobe(struct kprobe *p)
 
 void __kprobes arch_disarm_kprobe(struct kprobe *p)
 {
+#ifndef CONFIG_MN10300_CACHE_SNOOP
 	mn10300_dcache_flush();
 	mn10300_icache_inv();
+#endif
 }
 
 void arch_remove_kprobe(struct kprobe *p)
@@ -390,8 +392,10 @@ void __kprobes disarm_kprobe(struct kprobe *p, struct pt_regs *regs)
 {
 	*p->addr = p->opcode;
 	regs->pc = (unsigned long) p->addr;
+#ifndef CONFIG_MN10300_CACHE_SNOOP
 	mn10300_dcache_flush();
 	mn10300_icache_inv();
+#endif
 }
 
 static inline
arch/mn10300/kernel/traps.c +2 -0
index a64604b..c7257a1 100644
@@ -533,8 +533,10 @@ void __init set_intr_stub(enum exception_code code, void *handler)
 	vector[6] = 0xcb;
 	vector[7] = 0xcb;
 
+#ifndef CONFIG_MN10300_CACHE_SNOOP
 	mn10300_dcache_flush_inv();
 	mn10300_icache_inv();
+#endif
 }
 
 /*
arch/mn10300/mm/Kconfig.cache +34 -0
index 97adc06..653254a 100644
@@ -22,12 +22,26 @@ choice
 
 config MN10300_CACHE_WBACK
 	bool "Write-Back"
+	help
+	  The dcache operates in delayed write-back mode.  It must be manually
+	  flushed if writes are made that subsequently need to be executed or
+	  to be DMA'd by a device.
 
 config MN10300_CACHE_WTHRU
 	bool "Write-Through"
+	help
+	  The dcache operates in immediate write-through mode.  Writes are
+	  committed to RAM immediately in addition to being stored in the
+	  cache.  This means that the written data is immediately available for
+	  execution or DMA.
+
+	  This is not available for use with an SMP kernel if cache flushing
+	  and invalidation by automatic purge register is not selected.
 
 config MN10300_CACHE_DISABLED
 	bool "Disabled"
+	help
+	  The icache and dcache are disabled.
 
 endchoice
 
@@ -64,3 +78,23 @@ config MN10300_CACHE_FLUSH_BY_TAG
 
 config MN10300_CACHE_FLUSH_BY_REG
 	def_bool y if MN10300_CACHE_MANAGE_BY_REG && MN10300_CACHE_WBACK
+
+
+config MN10300_HAS_CACHE_SNOOP
+	def_bool n
+
+config MN10300_CACHE_SNOOP
+	bool "Use CPU Cache Snooping"
+	depends on MN10300_CACHE_ENABLED && MN10300_HAS_CACHE_SNOOP
+	default y
+
+config MN10300_CACHE_FLUSH_ICACHE
+	def_bool y if MN10300_CACHE_WBACK && !MN10300_CACHE_SNOOP
+	help
+	  Set if we need the dcache flushing before the icache is invalidated.
+
+config MN10300_CACHE_INV_ICACHE
+	def_bool y if MN10300_CACHE_WTHRU && !MN10300_CACHE_SNOOP
+	help
+	  Set if we need the icache to be invalidated, even if the dcache is in
+	  write-through mode and doesn't need flushing.
arch/mn10300/mm/Makefile +2 -0
index 7b99723..56c5af8 100644
@@ -3,6 +3,8 @@
 #
 
 cacheflush-y	:= cache.o
+cacheflush-$(CONFIG_MN10300_CACHE_INV_ICACHE) += cache-inv-icache.o
+cacheflush-$(CONFIG_MN10300_CACHE_FLUSH_ICACHE) += cache-flush-icache.o
 cacheflush-$(CONFIG_MN10300_CACHE_INV_BY_TAG) += cache-inv-by-tag.o
 cacheflush-$(CONFIG_MN10300_CACHE_INV_BY_REG) += cache-inv-by-reg.o
 cacheflush-$(CONFIG_MN10300_CACHE_FLUSH_BY_TAG) += cache-flush-by-tag.o
arch/mn10300/mm/cache-flush-icache.c new file +137 -0

137 lines not on this page · raw message

arch/mn10300/mm/cache-inv-icache.c new file +119 -0

119 lines not on this page · raw message

arch/mn10300/mm/cache.c +0 -90

96 lines not on this page · raw message

#23 lore raw

PATCH 23/43 MN10300: Cache: Implement SMP global cache flushing

In reply to David Howells

From: Akira Takeuchi <[email protected]>

Implement SMP global cache flushing for MN10300. This will be used by the AM34 which is SMP capable.

---

 arch/mn10300/mm/Kconfig.cache        |    1 
 arch/mn10300/mm/Makefile             |    3 +
 arch/mn10300/mm/cache-flush-icache.c |   36 ++++++--
 arch/mn10300/mm/cache-inv-icache.c   |   22 +++--
 arch/mn10300/mm/cache-smp-flush.c    |  156 ++++++++++++++++++++++++++++++++++
 arch/mn10300/mm/cache-smp-inv.c      |  153 +++++++++++++++++++++++++++++++++
 arch/mn10300/mm/cache-smp.c          |  105 +++++++++++++++++++++++
 arch/mn10300/mm/cache-smp.h          |   69 +++++++++++++++
 arch/mn10300/mm/cache.c              |    5 +
 9 files changed, 535 insertions(+), 15 deletions(-)
 create mode 100644 arch/mn10300/mm/cache-smp-flush.c
 create mode 100644 arch/mn10300/mm/cache-smp-inv.c
 create mode 100644 arch/mn10300/mm/cache-smp.c
 create mode 100644 arch/mn10300/mm/cache-smp.h
arch/mn10300/mm/Kconfig.cache +1 -0
index 653254a..c4fd923 100644
@@ -60,6 +60,7 @@ choice
 
 config MN10300_CACHE_MANAGE_BY_TAG
 	bool "Use the cache tag registers directly"
+	depends on !(SMP && MN10300_CACHE_WTHRU)
 
 config MN10300_CACHE_MANAGE_BY_REG
 	bool "Flush areas by way of automatic purge registers (AM34 only)"
arch/mn10300/mm/Makefile +3 -0
index 56c5af8..184745f 100644
@@ -2,7 +2,10 @@
 # Makefile for the MN10300-specific memory management code
 #
 
+cache-smp-wback-$(CONFIG_MN10300_CACHE_WBACK) := cache-smp-flush.o
+
 cacheflush-y	:= cache.o
+cacheflush-$(CONFIG_SMP) += cache-smp.o cache-smp-inv.o $(cache-smp-wback-y)
 cacheflush-$(CONFIG_MN10300_CACHE_INV_ICACHE) += cache-inv-icache.o
 cacheflush-$(CONFIG_MN10300_CACHE_FLUSH_ICACHE) += cache-flush-icache.o
 cacheflush-$(CONFIG_MN10300_CACHE_INV_BY_TAG) += cache-inv-by-tag.o
arch/mn10300/mm/cache-flush-icache.c +27 -9
index 0e471e1..fdb1a9d 100644
@@ -11,6 +11,9 @@
 #include <linux/module.h>
 #include <linux/mm.h>
 #include <asm/cacheflush.h>
+#include <asm/smp.h>
+#include "cache-smp.h"
+
 /**
  * flush_icache_page - Flush a page from the dcache and invalidate the icache
  * @vma: The VMA the page is part of.
@@ -22,9 +25,15 @@
 void flush_icache_page(struct vm_area_struct *vma, struct page *page)
 {
 	unsigned long start = page_to_phys(page);
+	unsigned long flags;
+
+	flags = smp_lock_cache();
+
+	mn10300_local_dcache_flush_page(start);
+	mn10300_local_icache_inv_page(start);
 
-	mn10300_dcache_flush_page(start);
-	mn10300_icache_inv_page(start);
+	smp_cache_call(SMP_IDCACHE_INV_FLUSH_RANGE, start, start + PAGE_SIZE);
+	smp_unlock_cache(flags);
 }
 EXPORT_SYMBOL(flush_icache_page);
 
@@ -82,8 +91,9 @@ static void flush_icache_page_range(unsigned long start, unsigned long end)
 
 	/* flush the dcache and invalidate the icache coverage on that
 	 * region */
-	mn10300_dcache_flush_range2(addr + off, size);
-	mn10300_icache_inv_range2(addr + off, size);
+	mn10300_local_dcache_flush_range2(addr + off, size);
+	mn10300_local_icache_inv_range2(addr + off, size);
+	smp_cache_call(SMP_IDCACHE_INV_FLUSH_RANGE, start, end);
 }
 
 /**
@@ -98,28 +108,32 @@ static void flush_icache_page_range(unsigned long start, unsigned long end)
 void flush_icache_range(unsigned long start, unsigned long end)
 {
 	unsigned long start_page, end_page;
+	unsigned long flags;
+
+	flags = smp_lock_cache();
 
 	if (end > 0x80000000UL) {
 		/* addresses above 0xa0000000 do not go through the cache */
 		if (end > 0xa0000000UL) {
 			end = 0xa0000000UL;
 			if (start >= end)
-				return;
+				goto done;
 		}
 
 		/* kernel addresses between 0x80000000 and 0x9fffffff do not
 		 * require page tables, so we just map such addresses
 		 * directly */
 		start_page = (start >= 0x80000000UL) ? start : 0x80000000UL;
-		mn10300_dcache_flush_range(start_page, end);
-		mn10300_icache_inv_range(start_page, end);
+		mn10300_local_dcache_flush_range(start_page, end);
+		mn10300_local_icache_inv_range(start_page, end);
+		smp_cache_call(SMP_IDCACHE_INV_FLUSH_RANGE, start_page, end);
 		if (start_page == start)
-			return;
+			goto done;
 		end = start_page;
 	}
 
 	start_page = start & PAGE_MASK;
-	end_page = end & PAGE_MASK;
+	end_page = (end - 1) & PAGE_MASK;
 
 	if (start_page == end_page) {
 		/* the first and last bytes are on the same page */
@@ -132,6 +146,10 @@ void flush_icache_range(unsigned long start, unsigned long end)
 		/* more than 2 pages; just flush the entire cache */
 		mn10300_dcache_flush();
 		mn10300_icache_inv();
+		smp_cache_call(SMP_IDCACHE_INV_FLUSH, 0, 0);
 	}
+
+done:
+	smp_unlock_cache(flags);
 }
 EXPORT_SYMBOL(flush_icache_range);
arch/mn10300/mm/cache-inv-icache.c +16 -6
index 4a3f7af..a8933a6 100644
@@ -12,6 +12,8 @@
 #include <linux/module.h>
 #include <linux/mm.h>
 #include <asm/cacheflush.h>
+#include <asm/smp.h>
+#include "cache-smp.h"
 
 /**
  * flush_icache_page_range - Flush dcache and invalidate icache for part of a
@@ -66,7 +68,8 @@ static void flush_icache_page_range(unsigned long start, unsigned long end)
 	addr = page_to_phys(page);
 
 	/* invalidate the icache coverage on that region */
-	mn10300_icache_inv_range2(addr + off, size);
+	mn10300_local_icache_inv_range2(addr + off, size);
+	smp_cache_call(SMP_ICACHE_INV_FLUSH_RANGE, start, end);
 }
 
 /**
@@ -81,28 +84,31 @@ static void flush_icache_page_range(unsigned long start, unsigned long end)
 void flush_icache_range(unsigned long start, unsigned long end)
 {
 	unsigned long start_page, end_page;
+	unsigned long flags;
+
+	flags = smp_lock_cache();
 
 	if (end > 0x80000000UL) {
 		/* addresses above 0xa0000000 do not go through the cache */
 		if (end > 0xa0000000UL) {
 			end = 0xa0000000UL;
 			if (start >= end)
-				return;
+				goto done;
 		}
 
 		/* kernel addresses between 0x80000000 and 0x9fffffff do not
 		 * require page tables, so we just map such addresses
 		 * directly */
 		start_page = (start >= 0x80000000UL) ? start : 0x80000000UL;
-		mn10300_dcache_flush_range(start_page, end);
 		mn10300_icache_inv_range(start_page, end);
+		smp_cache_call(SMP_ICACHE_INV_FLUSH_RANGE, start, end);
 		if (start_page == start)
-			return;
+			goto done;
 		end = start_page;
 	}
 
 	start_page = start & PAGE_MASK;
-	end_page = end & PAGE_MASK;
+	end_page = (end - 1) & PAGE_MASK;
 
 	if (start_page == end_page) {
 		/* the first and last bytes are on the same page */
@@ -113,7 +119,11 @@ void flush_icache_range(unsigned long start, unsigned long end)
 		flush_icache_page_range(end_page, end);
 	} else {
 		/* more than 2 pages; just flush the entire cache */
-		mn10300_icache_inv();
+		mn10300_local_icache_inv();
+		smp_cache_call(SMP_ICACHE_INV, 0, 0);
 	}
+
+done:
+	smp_unlock_cache(flags);
 }
 EXPORT_SYMBOL(flush_icache_range);
arch/mn10300/mm/cache-smp-flush.c new file +156 -0

156 lines not on this page · raw message

arch/mn10300/mm/cache-smp-inv.c new file +153 -0

153 lines not on this page · raw message

arch/mn10300/mm/cache-smp.c new file +105 -0

105 lines not on this page · raw message

arch/mn10300/mm/cache-smp.h new file +69 -0

69 lines not on this page · raw message

arch/mn10300/mm/cache.c +5 -0
index bc35826..0a1f0aa 100644
@@ -18,8 +18,13 @@
 #include <asm/cacheflush.h>
 #include <asm/io.h>
 #include <asm/uaccess.h>
+#include <asm/smp.h>
+#include "cache-smp.h"
 
 EXPORT_SYMBOL(mn10300_icache_inv);
+EXPORT_SYMBOL(mn10300_icache_inv_range);
+EXPORT_SYMBOL(mn10300_icache_inv_range2);
+EXPORT_SYMBOL(mn10300_icache_inv_page);
 EXPORT_SYMBOL(mn10300_dcache_inv);
 EXPORT_SYMBOL(mn10300_dcache_inv_range);
 EXPORT_SYMBOL(mn10300_dcache_inv_range2);
#24 lore raw

PATCH 24/43 MN10300: Make the boot wrapper able to use writeback caching

In reply to David Howells

From: Akira Takeuchi <[email protected]>

Make the boot wrapper able to use writeback caching, including flushing the cache before jumping to the main kernel.

---

 arch/mn10300/boot/compressed/head.S |   49 ++++++++++++++++++++++++++++++++++-
 1 files changed, 48 insertions(+), 1 deletions(-)
arch/mn10300/boot/compressed/head.S +48 -1
index 502e1eb..4ef608a 100644
@@ -14,6 +14,7 @@
 
 #include <linux/linkage.h>
 #include <asm/cpu-regs.h>
+#include <asm/cache.h>
 
 	.globl startup_32
 startup_32:
@@ -37,8 +38,15 @@ startup_32:
 	mov	(a0),d0
 	btst	CHCTR_ICBUSY|CHCTR_DCBUSY,d0		# wait till not busy
 	lne
-	mov	CHCTR_ICEN|CHCTR_DCEN|CHCTR_DCWTMD,d0	# writethru dcache
+
+#ifdef CONFIG_MN10300_CACHE_ENABLED
+#ifdef CONFIG_MN10300_CACHE_WBACK
+	mov	CHCTR_ICEN|CHCTR_DCEN|CHCTR_DCWTMD_WRBACK,d0
+#else
+	mov	CHCTR_ICEN|CHCTR_DCEN|CHCTR_DCWTMD_WRTHROUGH,d0
+#endif /* WBACK */
 	movhu	d0,(a0)					# enable
+#endif /* !ENABLED */
 
 	# clear the BSS area
 	mov	__bss_start,a0
@@ -54,6 +62,9 @@ bssclear_end:
 
 	# decompress the kernel
 	call	decompress_kernel[],0
+#ifdef CONFIG_MN10300_CACHE_WBACK
+	call	mn10300_dcache_flush_inv[],0
+#endif
 
 	# disable caches again
 	mov	CHCTR,a0
@@ -69,10 +80,46 @@ bssclear_end:
 	mov	(4,a0),d1
 	mov	(8,a0),d2
 
+	# jump to the kernel proper entry point
 	mov	a3,sp
 	mov	CONFIG_KERNEL_TEXT_ADDRESS,a0
 	jmp	(a0)
 
+
+###############################################################################
+#
+# Cache flush routines
+#
+###############################################################################
+#ifdef CONFIG_MN10300_CACHE_WBACK
+mn10300_dcache_flush_inv:
+	movhu	(CHCTR),d0
+	btst	CHCTR_DCEN,d0
+	beq	mn10300_dcache_flush_inv_end
+
+	mov	L1_CACHE_NENTRIES,d1
+	clr	a1
+
+mn10300_dcache_flush_inv_loop:
+	mov	(DCACHE_PURGE_WAY0(0),a1),d0	# unconditional purge
+	mov	(DCACHE_PURGE_WAY1(0),a1),d0	# unconditional purge
+	mov	(DCACHE_PURGE_WAY2(0),a1),d0	# unconditional purge
+	mov	(DCACHE_PURGE_WAY3(0),a1),d0	# unconditional purge
+
+	add	L1_CACHE_BYTES,a1
+	add	-1,d1
+	bne	mn10300_dcache_flush_inv_loop
+
+mn10300_dcache_flush_inv_end:
+	ret	[],0
+#endif /* CONFIG_MN10300_CACHE_WBACK */
+
+
+###############################################################################
+#
+# Data areas
+#
+###############################################################################
 	.data
 	.align		4
 param_save_area:
#25 lore raw

PATCH 25/43 MN10300: AM34 erratum requires MMUCTR read and write on exception entry

In reply to David Howells

From: Akira Takeuchi <[email protected]>

An AM34 erratum requires MMUCTR read and write on entry to certain exceptions, prior to EPSW.NMID being cleared to allow NMIs to happen.

---

 arch/mn10300/Kconfig          |    3 +++
 arch/mn10300/kernel/entry.S   |    8 ++++++++
 arch/mn10300/mm/tlb-mn10300.S |   32 ++++++++++++++++++++++++++------
 3 files changed, 37 insertions(+), 6 deletions(-)
arch/mn10300/Kconfig +3 -0
index 21e2a53..dd7b570 100644
@@ -20,6 +20,9 @@ config AM34_2
 	select MN10300_HAS_ATOMIC_OPS_UNIT
 	select MN10300_HAS_CACHE_SNOOP
 
+config ERRATUM_NEED_TO_RELOAD_MMUCTR
+	def_bool y if AM33_3 || AM34_2
+
 config MMU
 	def_bool y
 
arch/mn10300/kernel/entry.S +8 -0
index b82ce7b..355f681 100644
@@ -251,6 +251,10 @@ double_fault_loop:
 ENTRY(raw_bus_error)
 	add	-4,sp
 	mov	d0,(sp)
+#if defined(CONFIG_ERRATUM_NEED_TO_RELOAD_MMUCTR)
+	mov	(MMUCTR),d0
+	mov	d0,(MMUCTR)
+#endif
 	mov	(BCBERR),d0		# what
 	btst	BCBERR_BEMR_DMA,d0	# see if it was an external bus error
 	beq	__common_exception_aux	# it wasn't
@@ -282,6 +286,10 @@ ENTRY(nmi_handler)
 ENTRY(__common_exception)
 	add	-4,sp
 	mov	d0,(sp)
+#if defined(CONFIG_ERRATUM_NEED_TO_RELOAD_MMUCTR)
+	mov	(MMUCTR),d0
+	mov	d0,(MMUCTR)
+#endif
 
 __common_exception_aux:
 	mov	(TBR),d0
arch/mn10300/mm/tlb-mn10300.S +26 -6
index 7095147..ccf6229 100644
@@ -27,7 +27,6 @@
 ###############################################################################
 	.type	itlb_miss,@function
 ENTRY(itlb_miss)
-	and	~EPSW_NMID,epsw
 #ifdef CONFIG_GDBSTUB
 	movm	[d2,d3,a2],(sp)
 #else
@@ -38,6 +37,12 @@ ENTRY(itlb_miss)
 	nop
 #endif
 
+#if defined(CONFIG_ERRATUM_NEED_TO_RELOAD_MMUCTR)
+	mov	(MMUCTR),d2
+	mov	d2,(MMUCTR)
+#endif
+
+	and	~EPSW_NMID,epsw
 	mov	(IPTEU),d3
 	mov	(PTBR),a2
 	mov	d3,d2
@@ -79,7 +84,6 @@ itlb_miss_fault:
 ###############################################################################
 	.type	dtlb_miss,@function
 ENTRY(dtlb_miss)
-	and	~EPSW_NMID,epsw
 #ifdef CONFIG_GDBSTUB
 	movm	[d2,d3,a2],(sp)
 #else
@@ -90,6 +94,12 @@ ENTRY(dtlb_miss)
 	nop
 #endif
 
+#if defined(CONFIG_ERRATUM_NEED_TO_RELOAD_MMUCTR)
+	mov	(MMUCTR),d2
+	mov	d2,(MMUCTR)
+#endif
+
+	and	~EPSW_NMID,epsw
 	mov	(DPTEU),d3
 	mov	(PTBR),a2
 	mov	d3,d2
@@ -130,9 +140,15 @@ dtlb_miss_fault:
 ###############################################################################
 	.type	itlb_aerror,@function
 ENTRY(itlb_aerror)
-	and	~EPSW_NMID,epsw
 	add	-4,sp
 	SAVE_ALL
+
+#if defined(CONFIG_ERRATUM_NEED_TO_RELOAD_MMUCTR)
+	mov	(MMUCTR),d1
+	mov	d1,(MMUCTR)
+#endif
+
+	and	~EPSW_NMID,epsw
 	add	-4,sp				# need to pass three params
 
 	# calculate the fault code
@@ -148,7 +164,6 @@ ENTRY(itlb_aerror)
 	clr	d0
 	mov	d0,(IPTEL)
 
-	and	~EPSW_NMID,epsw
 	or	EPSW_IE,epsw
 	mov	fp,d0
 	call	do_page_fault[],0		# do_page_fault(regs,code,addr
@@ -163,10 +178,16 @@ ENTRY(itlb_aerror)
 ###############################################################################
 	.type	dtlb_aerror,@function
 ENTRY(dtlb_aerror)
-	and	~EPSW_NMID,epsw
 	add	-4,sp
 	SAVE_ALL
+
+#if defined(CONFIG_ERRATUM_NEED_TO_RELOAD_MMUCTR)
+	mov	(MMUCTR),d1
+	mov	d1,(MMUCTR)
+#endif
+
 	add	-4,sp				# need to pass three params
+	and	~EPSW_NMID,epsw
 
 	# calculate the fault code
 	movhu	(MMUFCR_DFC),d1
@@ -180,7 +201,6 @@ ENTRY(dtlb_aerror)
 	clr	d0
 	mov	d0,(DPTEL)
 
-	and	~EPSW_NMID,epsw
 	or	EPSW_IE,epsw
 	mov	fp,d0
 	call	do_page_fault[],0		# do_page_fault(regs,code,addr
#26 lore raw

PATCH 26/43 MN10300: Rename __flush_tlb*() to local_flush_tlb*()

In reply to David Howells

Rename __flush_tlb*() to local_flush_tlb*() as it's more appropriate, and ready to differentiate local from global TLB flushes when SMP is introduced.

Whilst we're at it, get rid of __flush_tlb_global() and make local_flush_tlb_page() take an mm_struct pointer rather than VMA pointer.

---

 arch/mn10300/include/asm/highmem.h     |    4 +-
 arch/mn10300/include/asm/mmu_context.h |    2 +
 arch/mn10300/include/asm/tlbflush.h    |   56 ++++++++++++++++++++------------
 arch/mn10300/mm/init.c                 |    2 +
 arch/mn10300/mm/mmu-context.c          |    4 +-
 arch/mn10300/mm/pgtable.c              |    2 +
 6 files changed, 42 insertions(+), 28 deletions(-)
arch/mn10300/include/asm/highmem.h +2 -2
index b0b187a..5fd74d8 100644
@@ -86,7 +86,7 @@ static inline unsigned long kmap_atomic(struct page *page, enum km_type type)
 		BUG();
 #endif
 	set_pte(kmap_pte - idx, mk_pte(page, kmap_prot));
-	__flush_tlb_one(vaddr);
+	local_flush_tlb_one(vaddr);
 
 	return vaddr;
 }
@@ -107,7 +107,7 @@ static inline void kunmap_atomic_notypecheck(unsigned long vaddr, enum km_type t
 	 * this pte without first remap it
 	 */
 	pte_clear(kmap_pte - idx);
-	__flush_tlb_one(vaddr);
+	local_flush_tlb_one(vaddr);
 #endif
 }
 
arch/mn10300/include/asm/mmu_context.h +1 -1
index cb294c2..24d63f0 100644
@@ -58,7 +58,7 @@ static inline unsigned long allocate_mmu_context(struct mm_struct *mm)
 	if (!(mc & MMU_CONTEXT_TLBPID_MASK)) {
 		/* we exhausted the TLB PIDs of this version on this CPU, so we
 		 * flush this CPU's TLB in its entirety and start new cycle */
-		flush_tlb_all();
+		local_flush_tlb_all();
 
 		/* fix the TLB version if needed (we avoid version #0 so as to
 		 * distingush MMU_NO_CONTEXT) */
arch/mn10300/include/asm/tlbflush.h +35 -21

91 lines not on this page · raw message

arch/mn10300/mm/init.c +1 -1
index f86c283..1daf97f 100644
@@ -73,7 +73,7 @@ void __init paging_init(void)
 	/* pass the memory from the bootmem allocator to the main allocator */
 	free_area_init(zones_size);
 
-	__flush_tlb_all();
+	local_flush_tlb_all();
 }
 
 /*
arch/mn10300/mm/mmu-context.c +2 -2
index 36ba021..3d83966 100644
@@ -23,7 +23,7 @@ unsigned long mmu_context_cache[NR_CPUS] = {
 /*
  * flush the specified TLB entry
  */
-void flush_tlb_page(struct vm_area_struct *vma, unsigned long addr)
+void local_flush_tlb_page(struct mm_struct *mm, unsigned long addr)
 {
 	unsigned long pteu, cnx, flags;
 
@@ -33,7 +33,7 @@ void flush_tlb_page(struct vm_area_struct *vma, unsigned long addr)
 	 * interference from vmalloc'd regions */
 	local_irq_save(flags);
 
-	cnx = mm_context(vma->vm_mm);
+	cnx = mm_context(mm);
 
 	if (cnx != MMU_NO_CONTEXT) {
 		pteu = addr | (cnx & 0x000000ffUL);
arch/mn10300/mm/pgtable.c +1 -1
index 9c1624c..450f7ba 100644
@@ -59,7 +59,7 @@ void set_pmd_pfn(unsigned long vaddr, unsigned long pfn, pgprot_t flags)
 	 * It's enough to flush this one mapping.
 	 * (PGE mappings get flushed as well)
 	 */
-	__flush_tlb_one(vaddr);
+	local_flush_tlb_one(vaddr);
 }
 
 pte_t *pte_alloc_one_kernel(struct mm_struct *mm, unsigned long address)
#27 lore raw

PATCH 27/43 MN10300: Make the use of PIDR to mark TLB entries controllable

In reply to David Howells

From: Akira Takeuchi <[email protected]>

Make controllable the use of the PIDR register to mark TLB entries as belonging to particular processes.

---

 arch/mn10300/Kconfig                   |    3 ++
 arch/mn10300/include/asm/mmu_context.h |   59 ++++++++++++++++----------------
 arch/mn10300/include/asm/tlbflush.h    |   43 ++++++++++++++++++++++-
 arch/mn10300/mm/mmu-context.c          |   41 ++++++----------------
 4 files changed, 84 insertions(+), 62 deletions(-)
arch/mn10300/Kconfig +3 -0
index dd7b570..7bd920b 100644
@@ -142,6 +142,9 @@ config FPU
 
 source "arch/mn10300/mm/Kconfig.cache"
 
+config MN10300_TLB_USE_PIDR
+	def_bool y
+
 menu "Memory layout options"
 
 config KERNEL_RAM_BASE_ADDRESS
arch/mn10300/include/asm/mmu_context.h +30 -29

92 lines not on this page · raw message

arch/mn10300/include/asm/tlbflush.h +40 -3

66 lines not on this page · raw message

arch/mn10300/mm/mmu-context.c +11 -30

61 lines not on this page · raw message

#28 lore raw

PATCH 28/43 MN10300: Use the [ID]PTEL2 registers rather than [ID]PTEL for TLB control

In reply to David Howells

From: Akira Takeuchi <[email protected]>

Use the [ID]PTEL2 registers rather than [ID]PTEL for TLB control as the bits are a more suitable layout.

---

 arch/mn10300/include/asm/cpu-regs.h |   19 +++++-----
 arch/mn10300/include/asm/pgtable.h  |   66 +++++++++++++++++++----------------
 arch/mn10300/mm/tlb-mn10300.S       |   27 ++++++++++----
 3 files changed, 65 insertions(+), 47 deletions(-)
arch/mn10300/include/asm/cpu-regs.h +10 -9
index 00e306c..90ed4a3 100644
@@ -252,14 +252,6 @@ asm(" .am33_2\n");
 #define xPTEL_PS_4Mb		0x00000c00	/* - 4Mb page */
 #define xPTEL_PPN		0xfffff006	/* physical page number */
 
-#define xPTEL_V_BIT		0	/* bit numbers corresponding to above masks */
-#define xPTEL_UNUSED1_BIT	1
-#define xPTEL_UNUSED2_BIT	2
-#define xPTEL_C_BIT		3
-#define xPTEL_PV_BIT		4
-#define xPTEL_D_BIT		5
-#define xPTEL_G_BIT		9
-
 #define IPTEU			__SYSREG(0xc00000a4, u32)	/* instruction TLB virtual addr */
 #define DPTEU			__SYSREG(0xc00000b4, u32)	/* data TLB virtual addr */
 #define xPTEU_VPN		0xfffffc00	/* virtual page number */
@@ -283,7 +275,16 @@ asm(" .am33_2\n");
 #define xPTEL2_PS_128Kb		0x00000100	/* - 128Kb page */
 #define xPTEL2_PS_1Kb		0x00000200	/* - 1Kb page */
 #define xPTEL2_PS_4Mb		0x00000300	/* - 4Mb page */
-#define xPTEL2_PPN		0xfffffc00	/* physical page number */
+#define xPTEL2_CWT		0x00000400	/* cacheable write-through */
+#define xPTEL2_UNUSED1		0x00000800	/* unused bit (broadcast mask) */
+#define xPTEL2_PPN		0xfffff000	/* physical page number */
+
+#define xPTEL2_V_BIT		0	/* bit numbers corresponding to above masks */
+#define xPTEL2_C_BIT		1
+#define xPTEL2_PV_BIT		2
+#define xPTEL2_D_BIT		3
+#define xPTEL2_G_BIT		7
+#define xPTEL2_UNUSED1_BIT	11
 
 #define MMUFCR			__SYSREGC(0xc000009c, u32)	/* MMU exception cause */
 #define MMUFCR_IFC		__SYSREGC(0xc000009c, u16)	/* MMU instruction excep cause */
arch/mn10300/include/asm/pgtable.h +36 -30

74 lines not on this page · raw message

arch/mn10300/mm/tlb-mn10300.S +19 -8
index ccf6229..b994017 100644
@@ -61,10 +61,16 @@ ENTRY(itlb_miss)
 	btst	_PAGE_VALID,d2
 	beq	itlb_miss_fault		# jump if doesn't point to a page
 					# (might be a swap id)
+#if	((_PAGE_ACCESSED & 0xffffff00) == 0)
 	bset	_PAGE_ACCESSED,(0,a2)
-	and	~(xPTEL_UNUSED1|xPTEL_UNUSED2),d2
+#elif	((_PAGE_ACCESSED & 0xffff00ff) == 0)
+	bset	+(_PAGE_ACCESSED >> 8),(1,a2)
+#else
+#error	"_PAGE_ACCESSED value is out of range"
+#endif
+	and	~xPTEL2_UNUSED1,d2
 itlb_miss_set:
-	mov	d2,(IPTEL)		# change the TLB
+	mov	d2,(IPTEL2)		# change the TLB
 #ifdef CONFIG_GDBSTUB
 	movm	(sp),[d2,d3,a2]
 #endif
@@ -118,10 +124,16 @@ ENTRY(dtlb_miss)
 	btst	_PAGE_VALID,d2
 	beq	dtlb_miss_fault		# jump if doesn't point to a page
 					# (might be a swap id)
+#if	((_PAGE_ACCESSED & 0xffffff00) == 0)
 	bset	_PAGE_ACCESSED,(0,a2)
-	and	~(xPTEL_UNUSED1|xPTEL_UNUSED2),d2
+#elif	((_PAGE_ACCESSED & 0xffff00ff) == 0)
+	bset	+(_PAGE_ACCESSED >> 8),(1,a2)
+#else
+#error	"_PAGE_ACCESSED value is out of range"
+#endif
+	and	~xPTEL2_UNUSED1,d2
 dtlb_miss_set:
-	mov	d2,(DPTEL)		# change the TLB
+	mov	d2,(DPTEL2)		# change the TLB
 #ifdef CONFIG_GDBSTUB
 	movm	(sp),[d2,d3,a2]
 #endif
@@ -156,13 +168,12 @@ ENTRY(itlb_aerror)
 	or	0x00010000,d1			# it's an instruction fetch
 
 	# determine the page address
-	mov	(IPTEU),a2
-	mov	a2,d0
+	mov	(IPTEU),d0
 	and	PAGE_MASK,d0
 	mov	d0,(12,sp)
 
 	clr	d0
-	mov	d0,(IPTEL)
+	mov	d0,(IPTEL2)
 
 	or	EPSW_IE,epsw
 	mov	fp,d0
@@ -199,7 +210,7 @@ ENTRY(dtlb_aerror)
 	mov	d0,(12,sp)
 
 	clr	d0
-	mov	d0,(DPTEL)
+	mov	d0,(DPTEL2)
 
 	or	EPSW_IE,epsw
 	mov	fp,d0
#29 lore raw

PATCH 29/43 MN10300: SMP TLB flushing

In reply to David Howells

From: Akira Takeuchi <[email protected]>

Implement global TLB flushing for MN10300. This will be used by the AM34 which is SMP capable.

---

 arch/mn10300/include/asm/mmu_context.h |   22 +++
 arch/mn10300/include/asm/tlbflush.h    |   81 ++++++++----
 arch/mn10300/mm/Makefile               |    2 
 arch/mn10300/mm/tlb-smp.c              |  214 ++++++++++++++++++++++++++++++++
 4 files changed, 290 insertions(+), 29 deletions(-)
 create mode 100644 arch/mn10300/mm/tlb-smp.c
arch/mn10300/include/asm/mmu_context.h +22 -0
index 5fb3648..c8f6c82 100644
@@ -36,6 +36,22 @@
 
 #define enter_lazy_tlb(mm, tsk)	do {} while (0)
 
+static inline void cpu_ran_vm(int cpu, struct mm_struct *mm)
+{
+#ifdef CONFIG_SMP
+	cpumask_set_cpu(cpu, mm_cpumask(mm));
+#endif
+}
+
+static inline bool cpu_maybe_ran_vm(int cpu, struct mm_struct *mm)
+{
+#ifdef CONFIG_SMP
+	return cpumask_test_and_set_cpu(cpu, mm_cpumask(mm));
+#else
+	return true;
+#endif
+}
+
 #ifdef CONFIG_MN10300_TLB_USE_PIDR
 extern unsigned long mmu_context_cache[NR_CPUS];
 #define mm_context(mm)	(mm->context.tlbpid[smp_processor_id()])
@@ -127,7 +143,13 @@ static inline void activate_context(struct mm_struct *mm)
 static inline void switch_mm(struct mm_struct *prev, struct mm_struct *next,
 			     struct task_struct *tsk)
 {
+	int cpu = smp_processor_id();
+
 	if (prev != next) {
+#ifdef CONFIG_SMP
+		per_cpu(cpu_tlbstate, cpu).active_mm = next;
+#endif
+		cpu_ran_vm(cpu, next);
 		PTBR = (unsigned long) next->pgd;
 		activate_context(next);
 	}
arch/mn10300/include/asm/tlbflush.h +52 -29

97 lines not on this page · raw message

arch/mn10300/mm/Makefile +2 -0
index 184745f..203fee2 100644
@@ -18,3 +18,5 @@ cacheflush-$(CONFIG_MN10300_CACHE_DISABLED) := cache-disabled.o
 obj-y := \
 	init.o fault.o pgtable.o extable.o tlb-mn10300.o mmu-context.o \
 	misalignment.o dma-alloc.o $(cacheflush-y)
+
+obj-$(CONFIG_SMP) += tlb-smp.o
arch/mn10300/mm/tlb-smp.c new file +214 -0

214 lines not on this page · raw message

#30 lore raw

PATCH 30/43 MN10300: Make the FPU operate in non-lazy mode under SMP

In reply to David Howells

From: Akira Takeuchi <[email protected]>

Make the FPU operate in non-lazy mode under SMP so that when the process that is currently using the FPU migrates to a different CPU, we don't have to ping its previous CPU to flush the FPU context.

---

 arch/mn10300/Kconfig                    |   15 ++
 arch/mn10300/include/asm/elf.h          |    2 
 arch/mn10300/include/asm/exceptions.h   |    1 
 arch/mn10300/include/asm/fpu.h          |  157 ++++++++++++------
 arch/mn10300/include/asm/processor.h    |    1 
 arch/mn10300/include/asm/system.h       |   16 ++
 arch/mn10300/kernel/Makefile            |    8 +
 arch/mn10300/kernel/asm-offsets.c       |    9 +
 arch/mn10300/kernel/fpu-low.S           |  265 +++++++++++++++++++------------
 arch/mn10300/kernel/fpu-nofpu-low.S     |   39 +++++
 arch/mn10300/kernel/fpu-nofpu.c         |   30 ++++
 arch/mn10300/kernel/fpu.c               |  141 +++++++---------
 arch/mn10300/kernel/traps.c             |    2 
 arch/mn10300/proc-mn103e010/proc-init.c |    2 
 14 files changed, 440 insertions(+), 248 deletions(-)
 create mode 100644 arch/mn10300/kernel/fpu-nofpu-low.S
 create mode 100644 arch/mn10300/kernel/fpu-nofpu.c
arch/mn10300/Kconfig +15 -0
index 7bd920b..a1f334c 100644
@@ -140,6 +140,21 @@ config FPU
 	default y
 	depends on MN10300_PROC_MN103E010
 
+config LAZY_SAVE_FPU
+	bool "Save FPU state lazily"
+	default y
+	depends on FPU && !SMP
+	help
+	  Enable this to be lazy in the saving of the FPU state to the owning
+	  task's thread struct.  This is useful if most tasks on the system
+	  don't use the FPU as only those tasks that use it will pass it
+	  between them, and the state needn't be saved for a task that isn't
+	  using it.
+
+	  This can't be so easily used on SMP as the process that owns the FPU
+	  state on a CPU may be currently running on another CPU, so for the
+	  moment, it is disabled.
+
 source "arch/mn10300/mm/Kconfig.cache"
 
 config MN10300_TLB_USE_PIDR
arch/mn10300/include/asm/elf.h +0 -2
index e5fa97c..a30d220 100644
@@ -47,8 +47,6 @@ typedef struct {
 	u_int32_t	fpcr;
 } elf_fpregset_t;
 
-extern int dump_fpu(struct pt_regs *, elf_fpregset_t *);
-
 /*
  * This is used to ensure we don't load something for the wrong architecture
  */
arch/mn10300/include/asm/exceptions.h +0 -1
index 3f3826a..7d8080b 100644
@@ -101,7 +101,6 @@ extern asmlinkage void dtlb_aerror(void);
 extern asmlinkage void raw_bus_error(void);
 extern asmlinkage void double_fault(void);
 extern asmlinkage int  system_call(struct pt_regs *);
-extern asmlinkage void fpu_exception(struct pt_regs *, enum exception_code);
 extern asmlinkage void nmi(struct pt_regs *, enum exception_code);
 extern asmlinkage void uninitialised_exception(struct pt_regs *,
 					       enum exception_code);
arch/mn10300/include/asm/fpu.h +104 -53

178 lines not on this page · raw message

arch/mn10300/include/asm/processor.h +1 -0
index fd96c18..0032fc7 100644
@@ -95,6 +95,7 @@ struct thread_struct {
 	struct pt_regs		*__frame;
 	unsigned long		fpu_flags;
 #define THREAD_USING_FPU	0x00000001	/* T if this task is using the FPU */
+#define THREAD_HAS_FPU		0x00000002	/* T if this task owns the FPU right now */
 	struct fpu_state_struct	fpu_state;
 };
 
arch/mn10300/include/asm/system.h +16 -0
index 9f7c7e1..3c272a1 100644
@@ -19,6 +19,21 @@
 #include <linux/kernel.h>
 #include <linux/irqflags.h>
 
+#if !defined(CONFIG_LAZY_SAVE_FPU)
+struct fpu_state_struct;
+extern asmlinkage void fpu_save(struct fpu_state_struct *);
+#define switch_fpu(prev, next)						\
+	do {								\
+		if ((prev)->thread.fpu_flags & THREAD_HAS_FPU) {	\
+			(prev)->thread.fpu_flags &= ~THREAD_HAS_FPU;	\
+			(prev)->thread.uregs->epsw &= ~EPSW_FE;		\
+			fpu_save(&(prev)->thread.fpu_state);		\
+		}							\
+	} while (0)
+#else
+#define switch_fpu(prev, next) do {} while (0)
+#endif
+
 struct task_struct;
 struct thread_struct;
 
@@ -30,6 +45,7 @@ struct task_struct *__switch_to(struct thread_struct *prev,
 /* context switching is now performed out-of-line in switch_to.S */
 #define switch_to(prev, next, last)					\
 do {									\
+	switch_fpu(prev, next);						\
 	current->thread.wchan = (u_long) __builtin_return_address(0);	\
 	(last) = __switch_to(&(prev)->thread, &(next)->thread, (prev));	\
 	mb();								\
arch/mn10300/kernel/Makefile +5 -3
index c4289e3..9902235 100644
@@ -3,13 +3,15 @@
 #
 extra-y := head.o init_task.o vmlinux.lds
 
-obj-y   := process.o signal.o entry.o fpu.o traps.o irq.o \
+fpu-obj-y := fpu-nofpu.o fpu-nofpu-low.o
+fpu-obj-$(CONFIG_FPU) := fpu.o fpu-low.o
+
+obj-y   := process.o signal.o entry.o traps.o irq.o \
 	   ptrace.o setup.o time.o sys_mn10300.o io.o kthread.o \
-	   switch_to.o mn10300_ksyms.o kernel_execve.o
+	   switch_to.o mn10300_ksyms.o kernel_execve.o $(fpu-obj-y)
 
 obj-$(CONFIG_MN10300_WD_TIMER) += mn10300-watchdog.o mn10300-watchdog-low.o
 
-obj-$(CONFIG_FPU) += fpu-low.o
 
 obj-$(CONFIG_MN10300_TTYSM) += mn10300-serial.o mn10300-serial-low.o \
 			       mn10300-debug.o
arch/mn10300/kernel/asm-offsets.c +9 -0
index 02dc7e4..78e290e 100644
@@ -67,6 +67,15 @@ void foo(void)
 	OFFSET(THREAD_A3,		thread_struct, a3);
 	OFFSET(THREAD_USP,		thread_struct, usp);
 	OFFSET(THREAD_FRAME,		thread_struct, __frame);
+#ifdef CONFIG_FPU
+	OFFSET(THREAD_FPU_FLAGS,	thread_struct, fpu_flags);
+	OFFSET(THREAD_FPU_STATE,	thread_struct, fpu_state);
+	DEFINE(__THREAD_USING_FPU,	THREAD_USING_FPU);
+	DEFINE(__THREAD_HAS_FPU,	THREAD_HAS_FPU);
+#endif /* CONFIG_FPU */
+	BLANK();
+
+	OFFSET(TASK_THREAD,		task_struct, thread);
 	BLANK();
 
 	DEFINE(CLONE_VM_asm,		CLONE_VM);
arch/mn10300/kernel/fpu-low.S +163 -102

298 lines not on this page · raw message

arch/mn10300/kernel/fpu-nofpu-low.S new file +39 -0
new file mode 100644
index 0000000..7ea087a
@@ -0,0 +1,39 @@
+/* MN10300 Low level FPU management operations
+ *
+ * Copyright (C) 2007 Red Hat, Inc. All Rights Reserved.
+ * Written by David Howells ([email protected])
+ *
+ * This program is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU General Public Licence
+ * as published by the Free Software Foundation; either version
+ * 2 of the Licence, or (at your option) any later version.
+ */
+#include <linux/linkage.h>
+#include <asm/cpu-regs.h>
+#include <asm/smp.h>
+#include <asm/thread_info.h>
+#include <asm/asm-offsets.h>
+#include <asm/frame.inc>
+
+###############################################################################
+#
+# void fpu_disabled(void)
+# - handle an exception due to the FPU being disabled
+#   when CONFIG_FPU is disabled
+#
+###############################################################################
+	.type	fpu_disabled,@function
+	.globl	fpu_disabled
+fpu_disabled:
+	add	-4,sp
+	SAVE_ALL
+	mov	-1,d0
+	mov	d0,(REG_ORIG_D0,fp)
+
+	and	~EPSW_NMID,epsw
+
+	mov	fp,d0
+	call	unexpected_fpu_exception[],0
+	jmp	ret_from_exception
+
+	.size	fpu_disabled,.-fpu_disabled
arch/mn10300/kernel/fpu-nofpu.c new file +30 -0
new file mode 100644
index 0000000..31c765b
@@ -0,0 +1,30 @@
+/* MN10300 FPU management
+ *
+ * Copyright (C) 2007 Red Hat, Inc. All Rights Reserved.
+ * Written by David Howells ([email protected])
+ *
+ * This program is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU General Public Licence
+ * as published by the Free Software Foundation; either version
+ * 2 of the Licence, or (at your option) any later version.
+ */
+#include <asm/fpu.h>
+
+/*
+ * handle an FPU operational exception
+ * - there's a possibility that if the FPU is asynchronous, the signal might
+ *   be meant for a process other than the current one
+ */
+asmlinkage
+void unexpected_fpu_exception(struct pt_regs *regs, enum exception_code code)
+{
+	panic("An FPU exception was received, but there's no FPU enabled.");
+}
+
+/*
+ * fill in the FPU structure for a core dump
+ */
+int dump_fpu(struct pt_regs *regs, elf_fpregset_t *fpreg)
+{
+	return 0; /* not valid */
+}
arch/mn10300/kernel/fpu.c +56 -85

220 lines not on this page · raw message

arch/mn10300/kernel/traps.c +0 -2
index c7257a1..716a221 100644
@@ -101,7 +101,6 @@ DO_EINFO(SIGILL,  {}, "invalid opcode",		invalid_op,	ILL_ILLOPC);
 DO_EINFO(SIGILL,  {}, "invalid ex opcode",	invalid_exop,	ILL_ILLOPC);
 DO_EINFO(SIGBUS,  {}, "invalid address",	mem_error,	BUS_ADRERR);
 DO_EINFO(SIGBUS,  {}, "bus error",		bus_error,	BUS_ADRERR);
-DO_EINFO(SIGILL,  {}, "FPU invalid opcode", 	fpu_invalid_op,	ILL_COPROC);
 
 DO_ERROR(SIGTRAP,
 #ifndef CONFIG_MN10300_USING_JTAG
@@ -561,7 +560,6 @@ void __init trap_init(void)
 	set_excp_vector(EXCEP_PRIVINSACC,	insn_acc_error);
 	set_excp_vector(EXCEP_PRIVDATACC,	data_acc_error);
 	set_excp_vector(EXCEP_DATINSACC,	insn_acc_error);
-	set_excp_vector(EXCEP_FPU_DISABLED,	fpu_disabled);
 	set_excp_vector(EXCEP_FPU_UNIMPINS,	fpu_invalid_op);
 	set_excp_vector(EXCEP_FPU_OPERATION,	fpu_exception);
 
arch/mn10300/proc-mn103e010/proc-init.c +2 -0
index 9a482ef..0cee787 100644
@@ -9,6 +9,7 @@
  * 2 of the Licence, or (at your option) any later version.
  */
 #include <linux/kernel.h>
+#include <asm/fpu.h>
 #include <asm/rtc.h>
 
 /*
@@ -28,6 +29,7 @@ asmlinkage void __init processor_init(void)
 	__set_intr_stub(EXCEP_DAERROR,		dtlb_aerror);
 	__set_intr_stub(EXCEP_BUSERROR,		raw_bus_error);
 	__set_intr_stub(EXCEP_DOUBLE_FAULT,	double_fault);
+	__set_intr_stub(EXCEP_FPU_DISABLED,	fpu_disabled);
 	__set_intr_stub(EXCEP_SYSCALL0,		system_call);
 
 	__set_intr_stub(EXCEP_NMI,		nmi_handler);
#31 lore raw

PATCH 31/43 MN10300: Implement atomic ops using atomic ops unit

In reply to David Howells

From: Mark Salter <[email protected]>

Implement atomic ops using the atomic ops unit available in the AM34 CPU. This allows the equivalent of the LL/SC instructions to be found on other CPUs.

---

 arch/mn10300/include/asm/atomic.h |  350 +++++++++++++++++++++++++++++++++++++
 arch/mn10300/include/asm/system.h |   48 -----
 2 files changed, 351 insertions(+), 47 deletions(-)
arch/mn10300/include/asm/atomic.h +350 -0
index f0cc1f8..92d2f92 100644
@@ -1 +1,351 @@
+/* MN10300 Atomic counter operations
+ *
+ * Copyright (C) 2007 Red Hat, Inc. All Rights Reserved.
+ * Written by David Howells ([email protected])
+ *
+ * This program is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU General Public Licence
+ * as published by the Free Software Foundation; either version
+ * 2 of the Licence, or (at your option) any later version.
+ */
+#ifndef _ASM_ATOMIC_H
+#define _ASM_ATOMIC_H
+
+#include <asm/irqflags.h>
+
+#ifndef __ASSEMBLY__
+
+#ifdef CONFIG_SMP
+#ifdef CONFIG_MN10300_HAS_ATOMIC_OPS_UNIT
+static inline
+unsigned long __xchg(volatile unsigned long *m, unsigned long val)
+{
+	unsigned long status;
+	unsigned long oldval;
+
+	asm volatile(
+		"1:	mov	%4,(_AAR,%3)	\n"
+		"	mov	(_ADR,%3),%1	\n"
+		"	mov	%5,(_ADR,%3)	\n"
+		"	mov	(_ADR,%3),%0	\n"	/* flush */
+		"	mov	(_ASR,%3),%0	\n"
+		"	or	%0,%0		\n"
+		"	bne	1b		\n"
+		: "=&r"(status), "=&r"(oldval), "=m"(*m)
+		: "a"(ATOMIC_OPS_BASE_ADDR), "r"(m), "r"(val)
+		: "memory", "cc");
+
+	return oldval;
+}
+
+static inline unsigned long __cmpxchg(volatile unsigned long *m,
+				      unsigned long old, unsigned long new)
+{
+	unsigned long status;
+	unsigned long oldval;
+
+	asm volatile(
+		"1:	mov	%4,(_AAR,%3)	\n"
+		"	mov	(_ADR,%3),%1	\n"
+		"	cmp	%5,%1		\n"
+		"	bne	2f		\n"
+		"	mov	%6,(_ADR,%3)	\n"
+		"2:	mov	(_ADR,%3),%0	\n"	/* flush */
+		"	mov	(_ASR,%3),%0	\n"
+		"	or	%0,%0		\n"
+		"	bne	1b		\n"
+		: "=&r"(status), "=&r"(oldval), "=m"(*m)
+		: "a"(ATOMIC_OPS_BASE_ADDR), "r"(m),
+		  "r"(old), "r"(new)
+		: "memory", "cc");
+
+	return oldval;
+}
+#else  /* CONFIG_MN10300_HAS_ATOMIC_OPS_UNIT */
+#error "No SMP atomic operation support!"
+#endif /* CONFIG_MN10300_HAS_ATOMIC_OPS_UNIT */
+
+#else  /* CONFIG_SMP */
+
+/*
+ * Emulate xchg for non-SMP MN10300
+ */
+struct __xchg_dummy { unsigned long a[100]; };
+#define __xg(x) ((struct __xchg_dummy *)(x))
+
+static inline
+unsigned long __xchg(volatile unsigned long *m, unsigned long val)
+{
+	unsigned long oldval;
+	unsigned long flags;
+
+	flags = arch_local_cli_save();
+	oldval = *m;
+	*m = val;
+	arch_local_irq_restore(flags);
+	return oldval;
+}
+
+/*
+ * Emulate cmpxchg for non-SMP MN10300
+ */
+static inline unsigned long __cmpxchg(volatile unsigned long *m,
+				      unsigned long old, unsigned long new)
+{
+	unsigned long oldval;
+	unsigned long flags;
+
+	flags = arch_local_cli_save();
+	oldval = *m;
+	if (oldval == old)
+		*m = new;
+	arch_local_irq_restore(flags);
+	return oldval;
+}
+
+#endif /* CONFIG_SMP */
+
+#define xchg(ptr, v)						\
+	((__typeof__(*(ptr))) __xchg((unsigned long *)(ptr),	\
+				     (unsigned long)(v)))
+
+#define cmpxchg(ptr, o, n)					\
+	((__typeof__(*(ptr))) __cmpxchg((unsigned long *)(ptr), \
+					(unsigned long)(o),	\
+					(unsigned long)(n)))
+
+#define atomic_xchg(ptr, v)		(xchg(&(ptr)->counter, (v)))
+#define atomic_cmpxchg(v, old, new)	(cmpxchg(&((v)->counter), (old), (new)))
+
+#endif /* !__ASSEMBLY__ */
+
+#ifndef CONFIG_SMP
 #include <asm-generic/atomic.h>
+#else
+
+/*
+ * Atomic operations that C can't guarantee us.  Useful for
+ * resource counting etc..
+ */
+
+#define ATOMIC_INIT(i)	{ (i) }
+
+#ifdef __KERNEL__
+
+/**
+ * atomic_read - read atomic variable
+ * @v: pointer of type atomic_t
+ *
+ * Atomically reads the value of @v.  Note that the guaranteed
+ * useful range of an atomic_t is only 24 bits.
+ */
+#define atomic_read(v)	((v)->counter)
+
+/**
+ * atomic_set - set atomic variable
+ * @v: pointer of type atomic_t
+ * @i: required value
+ *
+ * Atomically sets the value of @v to @i.  Note that the guaranteed
+ * useful range of an atomic_t is only 24 bits.
+ */
+#define atomic_set(v, i) (((v)->counter) = (i))
+
+/**
+ * atomic_add_return - add integer to atomic variable
+ * @i: integer value to add
+ * @v: pointer of type atomic_t
+ *
+ * Atomically adds @i to @v and returns the result
+ * Note that the guaranteed useful range of an atomic_t is only 24 bits.
+ */
+static inline int atomic_add_return(int i, atomic_t *v)
+{
+	int retval;
+#ifdef CONFIG_SMP
+	int status;
+
+	asm volatile(
+		"1:	mov	%4,(_AAR,%3)	\n"
+		"	mov	(_ADR,%3),%1	\n"
+		"	add	%5,%1		\n"
+		"	mov	%1,(_ADR,%3)	\n"
+		"	mov	(_ADR,%3),%0	\n"	/* flush */
+		"	mov	(_ASR,%3),%0	\n"
+		"	or	%0,%0		\n"
+		"	bne	1b		\n"
+		: "=&r"(status), "=&r"(retval), "=m"(v->counter)
+		: "a"(ATOMIC_OPS_BASE_ADDR), "r"(&v->counter), "r"(i)
+		: "memory", "cc");
+
+#else
+	unsigned long flags;
+
+	flags = arch_local_cli_save();
+	retval = v->counter;
+	retval += i;
+	v->counter = retval;
+	arch_local_irq_restore(flags);
+#endif
+	return retval;
+}
+
+/**
+ * atomic_sub_return - subtract integer from atomic variable
+ * @i: integer value to subtract
+ * @v: pointer of type atomic_t
+ *
+ * Atomically subtracts @i from @v and returns the result
+ * Note that the guaranteed useful range of an atomic_t is only 24 bits.
+ */
+static inline int atomic_sub_return(int i, atomic_t *v)
+{
+	int retval;
+#ifdef CONFIG_SMP
+	int status;
+
+	asm volatile(
+		"1:	mov	%4,(_AAR,%3)	\n"
+		"	mov	(_ADR,%3),%1	\n"
+		"	sub	%5,%1		\n"
+		"	mov	%1,(_ADR,%3)	\n"
+		"	mov	(_ADR,%3),%0	\n"	/* flush */
+		"	mov	(_ASR,%3),%0	\n"
+		"	or	%0,%0		\n"
+		"	bne	1b		\n"
+		: "=&r"(status), "=&r"(retval), "=m"(v->counter)
+		: "a"(ATOMIC_OPS_BASE_ADDR), "r"(&v->counter), "r"(i)
+		: "memory", "cc");
+
+#else
+	unsigned long flags;
+	flags = arch_local_cli_save();
+	retval = v->counter;
+	retval -= i;
+	v->counter = retval;
+	arch_local_irq_restore(flags);
+#endif
+	return retval;
+}
+
+static inline int atomic_add_negative(int i, atomic_t *v)
+{
+	return atomic_add_return(i, v) < 0;
+}
+
+static inline void atomic_add(int i, atomic_t *v)
+{
+	atomic_add_return(i, v);
+}
+
+static inline void atomic_sub(int i, atomic_t *v)
+{
+	atomic_sub_return(i, v);
+}
+
+static inline void atomic_inc(atomic_t *v)
+{
+	atomic_add_return(1, v);
+}
+
+static inline void atomic_dec(atomic_t *v)
+{
+	atomic_sub_return(1, v);
+}
+
+#define atomic_dec_return(v)		atomic_sub_return(1, (v))
+#define atomic_inc_return(v)		atomic_add_return(1, (v))
+
+#define atomic_sub_and_test(i, v)	(atomic_sub_return((i), (v)) == 0)
+#define atomic_dec_and_test(v)		(atomic_sub_return(1, (v)) == 0)
+#define atomic_inc_and_test(v)		(atomic_add_return(1, (v)) == 0)
+
+#define atomic_add_unless(v, a, u)				\
+({								\
+	int c, old;						\
+	c = atomic_read(v);					\
+	while (c != (u) && (old = atomic_cmpxchg((v), c, c + (a))) != c) \
+		c = old;					\
+	c != (u);						\
+})
+
+#define atomic_inc_not_zero(v) atomic_add_unless((v), 1, 0)
+
+/**
+ * atomic_clear_mask - Atomically clear bits in memory
+ * @mask: Mask of the bits to be cleared
+ * @v: pointer to word in memory
+ *
+ * Atomically clears the bits set in mask from the memory word specified.
+ */
+static inline void atomic_clear_mask(unsigned long mask, unsigned long *addr)
+{
+#ifdef CONFIG_SMP
+	int status;
+
+	asm volatile(
+		"1:	mov	%3,(_AAR,%2)	\n"
+		"	mov	(_ADR,%2),%0	\n"
+		"	and	%4,%0		\n"
+		"	mov	%0,(_ADR,%2)	\n"
+		"	mov	(_ADR,%2),%0	\n"	/* flush */
+		"	mov	(_ASR,%2),%0	\n"
+		"	or	%0,%0		\n"
+		"	bne	1b		\n"
+		: "=&r"(status), "=m"(*addr)
+		: "a"(ATOMIC_OPS_BASE_ADDR), "r"(addr), "r"(~mask)
+		: "memory", "cc");
+#else
+	unsigned long flags;
+
+	mask = ~mask;
+	flags = arch_local_cli_save();
+	*addr &= mask;
+	arch_local_irq_restore(flags);
+#endif
+}
+
+/**
+ * atomic_set_mask - Atomically set bits in memory
+ * @mask: Mask of the bits to be set
+ * @v: pointer to word in memory
+ *
+ * Atomically sets the bits set in mask from the memory word specified.
+ */
+static inline void atomic_set_mask(unsigned long mask, unsigned long *addr)
+{
+#ifdef CONFIG_SMP
+	int status;
+
+	asm volatile(
+		"1:	mov	%3,(_AAR,%2)	\n"
+		"	mov	(_ADR,%2),%0	\n"
+		"	or	%4,%0		\n"
+		"	mov	%0,(_ADR,%2)	\n"
+		"	mov	(_ADR,%2),%0	\n"	/* flush */
+		"	mov	(_ASR,%2),%0	\n"
+		"	or	%0,%0		\n"
+		"	bne	1b		\n"
+		: "=&r"(status), "=m"(*addr)
+		: "a"(ATOMIC_OPS_BASE_ADDR), "r"(addr), "r"(mask)
+		: "memory", "cc");
+#else
+	unsigned long flags;
+
+	flags = arch_local_cli_save();
+	*addr |= mask;
+	arch_local_irq_restore(flags);
+#endif
+}
+
+/* Atomic operations are already serializing on MN10300??? */
+#define smp_mb__before_atomic_dec()	barrier()
+#define smp_mb__after_atomic_dec()	barrier()
+#define smp_mb__before_atomic_inc()	barrier()
+#define smp_mb__after_atomic_inc()	barrier()
+
+#include <asm-generic/atomic-long.h>
+
+#endif /* __KERNEL__ */
+#endif /* CONFIG_SMP */
+#endif /* _ASM_ATOMIC_H */
arch/mn10300/include/asm/system.h +1 -47

59 lines not on this page · raw message

#32 lore raw

PATCH 32/43 MN10300: Optimise do_csum()

In reply to David Howells

From: Akira Takeuchi <[email protected]>

Optimise do_csum() to gang up the loads so they're less likely to get interruptions between.

---

 arch/mn10300/lib/do_csum.S |   49 ++++++++++++++++++++------------------------
 1 files changed, 22 insertions(+), 27 deletions(-)
arch/mn10300/lib/do_csum.S +22 -27
index e138994..1d27bba 100644
@@ -10,26 +10,25 @@
  */
 #include <asm/cache.h>
 
-        .section .text
-        .balign	L1_CACHE_BYTES
+	.section .text
+	.balign	L1_CACHE_BYTES
 
 ###############################################################################
 #
-# unsigned int do_csum(const unsigned char *buff, size_t len)
+# unsigned int do_csum(const unsigned char *buff, int len)
 #
 ###############################################################################
 	.globl	do_csum
-        .type	do_csum,@function
+	.type	do_csum,@function
 do_csum:
 	movm	[d2,d3],(sp)
-	mov	d0,(12,sp)
-	mov	d1,(16,sp)
 	mov	d1,d2				# count
 	mov	d0,a0				# buff
+	mov	a0,a1
 	clr	d1				# accumulator
 
 	cmp	+0,d2
-	beq	do_csum_done			# return if zero-length buffer
+	ble	do_csum_done			# check for zero length or negative
 
 	# 4-byte align the buffer pointer
 	btst	+3,a0
@@ -41,17 +40,15 @@ do_csum:
 	inc	a0
 	asl	+8,d0
 	add	d0,d1
-	addc	+0,d1
 	add	-1,d2
-do_csum_addr_not_odd:
 
+do_csum_addr_not_odd:
 	cmp	+2,d2
 	bcs	do_csum_fewer_than_4
 	btst	+2,a0
 	beq	do_csum_now_4b_aligned
 	movhu	(a0+),d0
 	add	d0,d1
-	addc	+0,d1
 	add	-2,d2
 	cmp	+4,d2
 	bcs	do_csum_fewer_than_4
@@ -66,20 +63,20 @@ do_csum_now_4b_aligned:
 
 do_csum_loop:
 	mov	(a0+),d0
-	add	d0,d1
 	mov	(a0+),e0
-	addc	e0,d1
 	mov	(a0+),e1
-	addc	e1,d1
 	mov	(a0+),e3
+	add	d0,d1
+	addc	e0,d1
+	addc	e1,d1
 	addc	e3,d1
 	mov	(a0+),d0
-	addc	d0,d1
 	mov	(a0+),e0
-	addc	e0,d1
 	mov	(a0+),e1
-	addc	e1,d1
 	mov	(a0+),e3
+	addc	d0,d1
+	addc	e0,d1
+	addc	e1,d1
 	addc	e3,d1
 	addc	+0,d1
 
@@ -94,12 +91,12 @@ do_csum_remainder:
 	cmp	+16,d2
 	bcs	do_csum_fewer_than_16
 	mov	(a0+),d0
-	add	d0,d1
 	mov	(a0+),e0
-	addc	e0,d1
 	mov	(a0+),e1
-	addc	e1,d1
 	mov	(a0+),e3
+	add	d0,d1
+	addc	e0,d1
+	addc	e1,d1
 	addc	e3,d1
 	addc	+0,d1
 	add	-16,d2
@@ -131,9 +128,9 @@ do_csum_fewer_than_4:
 	xor_cmp	d0,d0,+2,d2
 	bcs	do_csum_fewer_than_2
 	movhu	(a0+),d0
-do_csum_fewer_than_2:
 	and	+1,d2
 	beq	do_csum_add_last_bit
+do_csum_fewer_than_2:
 	movbu	(a0),d3
 	add	d3,d0
 do_csum_add_last_bit:
@@ -142,21 +139,19 @@ do_csum_add_last_bit:
 
 do_csum_done:
 	# compress the checksum down to 16 bits
-	mov	+0xffff0000,d2
-	and	d1,d2
+	mov	+0xffff0000,d0
+	and	d1,d0
 	asl	+16,d1
-	add	d2,d1,d0
+	add	d1,d0
 	addc	+0xffff,d0
 	lsr	+16,d0
 
 	# flip the halves of the word result if the buffer was oddly aligned
-	mov	(12,sp),d1
-	and	+1,d1
+	and	+1,a1
 	beq	do_csum_not_oddly_aligned
 	swaph	d0,d0				# exchange bits 15:8 with 7:0
 
 do_csum_not_oddly_aligned:
 	ret	[d2,d3],8
 
-do_csum_end:
-	.size	do_csum, do_csum_end-do_csum
+	.size	do_csum, .-do_csum
#33 lore raw

PATCH 33/43 MN10300: Make various interrupt priority settings configurable

In reply to David Howells

From: Akira Takeuchi <[email protected]>

Make the settings of interrupt priorities used by various services configurable at run time.

---

 arch/mn10300/Kconfig                |   74 +++++++++++++++++++++++++++++++++++
 arch/mn10300/include/asm/irqflags.h |    8 +---
 2 files changed, 76 insertions(+), 6 deletions(-)
arch/mn10300/Kconfig +74 -0
index a1f334c..a0a16e6 100644
@@ -351,6 +351,80 @@ config MN10300_TTYSM2_CTS
 
 endmenu
 
+menu "Interrupt request priority options"
+
+comment "[!] NOTE: A lower number/level indicates a higher priority (0 is highest, 6 is lowest)"
+
+comment "____Non-maskable interrupt levels____"
+comment "The following must be set to a higher priority than local_irq_disable() and on-chip serial"
+
+config GDBSTUB_IRQ_LEVEL
+	int "GDBSTUB interrupt priority"
+	depends on GDBSTUB
+	range 0 1 if LINUX_CLI_LEVEL = 2
+	range 0 2 if LINUX_CLI_LEVEL = 3
+	range 0 3 if LINUX_CLI_LEVEL = 4
+	range 0 4 if LINUX_CLI_LEVEL = 5
+	range 0 5 if LINUX_CLI_LEVEL = 6
+	default 0
+
+comment "The following must be set to a higher priority than local_irq_disable()"
+
+config MN10300_SERIAL_IRQ_LEVEL
+	int "MN10300 on-chip serial interrupt priority"
+	depends on MN10300_TTYSM
+	range 1 1 if LINUX_CLI_LEVEL = 2
+	range 1 2 if LINUX_CLI_LEVEL = 3
+	range 1 3 if LINUX_CLI_LEVEL = 4
+	range 1 4 if LINUX_CLI_LEVEL = 5
+	range 1 5 if LINUX_CLI_LEVEL = 6
+	default 1
+
+comment "-"
+comment "____Maskable interrupt levels____"
+
+config LINUX_CLI_LEVEL
+	int "The highest interrupt priority excluded by local_irq_disable() (2-6)"
+	range 2 6
+	default 2
+	help
+	  local_irq_disable() doesn't actually disable maskable interrupts -
+	  what it does is restrict the levels of interrupt which are permitted
+	  (a lower level indicates a higher priority) by lowering the value in
+	  EPSW.IM from 7.  Any interrupt is permitted for which the level is
+	  lower than EPSW.IM.
+
+	  Certain interrupts, such as GDBSTUB and virtual MN10300 on-chip
+	  serial DMA interrupts are allowed to interrupt normal disabled
+	  sections.
+
+comment "The following must be set to a equal to or lower priority than LINUX_CLI_LEVEL"
+
+config TIMER_IRQ_LEVEL
+	int "Kernel timer interrupt priority"
+	range LINUX_CLI_LEVEL 6
+	default 4
+
+config PCI_IRQ_LEVEL
+	int "PCI interrupt priority"
+	depends on PCI
+	range LINUX_CLI_LEVEL 6
+	default 5
+
+config ETHERNET_IRQ_LEVEL
+	int "Ethernet interrupt priority"
+	depends on SMC91X || SMC911X || SMSC911X
+	range LINUX_CLI_LEVEL 6
+	default 6
+
+config EXT_SERIAL_IRQ_LEVEL
+	int "External serial port interrupt priority"
+	depends on SERIAL_8250
+	range LINUX_CLI_LEVEL 6
+	default 6
+
+endmenu
+
 source "mm/Kconfig"
 
 menu "Power management options"
arch/mn10300/include/asm/irqflags.h +2 -6
index f1b64b2..b3ab207 100644
@@ -23,11 +23,7 @@
  *   - level 6 - timer interrupt
  * - "enabled":  run in IM7
  */
-#ifdef CONFIG_MN10300_TTYSM
-#define MN10300_CLI_LEVEL	EPSW_IM_2
-#else
-#define MN10300_CLI_LEVEL	EPSW_IM_1
-#endif
+#define MN10300_CLI_LEVEL	(CONFIG_LINUX_CLI_LEVEL << EPSW_IM_SHIFT)
 
 #ifndef __ASSEMBLY__
 
@@ -94,7 +90,7 @@ static inline void arch_local_irq_restore(unsigned long flags)
 
 static inline bool arch_irqs_disabled_flags(unsigned long flags)
 {
-	return (flags & EPSW_IM) <= MN10300_CLI_LEVEL;
+	return (flags & (EPSW_IE | EPSW_IM)) != (EPSW_IE | EPSW_IM_7);
 }
 
 static inline bool arch_irqs_disabled(void)
#34 lore raw

PATCH 34/43 MN10300: Delete idle_timestamp from irq_cpustat_t

In reply to David Howells

From: Akira Takeuchi <[email protected]>

Delete idle_timestamp from irq_cpustat_t as it's an unread relic.

---

 arch/mn10300/include/asm/hardirq.h |    1 -
 arch/mn10300/kernel/process.c      |    2 --
 2 files changed, 0 insertions(+), 3 deletions(-)
arch/mn10300/include/asm/hardirq.h +0 -1
index 54d9501..7bd9b7c 100644
@@ -19,7 +19,6 @@
 /* assembly code in softirq.h is sensitive to the offsets of these fields */
 typedef struct {
 	unsigned int	__softirq_pending;
-	unsigned long	idle_timestamp;
 	unsigned int	__nmi_count;	/* arch dependent */
 	unsigned int	__irq_count;	/* arch dependent */
 } ____cacheline_aligned irq_cpustat_t;
arch/mn10300/kernel/process.c +0 -2
index f48373e..243e33c 100644
@@ -88,8 +88,6 @@ void cpu_idle(void)
 			idle = pm_idle;
 			if (!idle)
 				idle = default_idle;
-
-			irq_stat[cpu].idle_timestamp = jiffies;
 			idle();
 		}
 
#35 lore raw

PATCH 35/43 MN10300: And Panasonic AM34 subarch and implement SMP

In reply to David Howells

From: Akira Takeuchi <[email protected]>

Implement the Panasonic MN10300 AM34 CPU subarch and implement SMP support for MN10300. Also implement support for the MN2WS0060 processor and the ASB2364 evaluation board which are AM34 based.

---

 MAINTAINERS                                        |    2 
 arch/mn10300/Kconfig                               |  119 ++
 arch/mn10300/Makefile                              |    6 
 arch/mn10300/boot/compressed/head.S                |   20 
 arch/mn10300/include/asm/exceptions.h              |    2 
 arch/mn10300/include/asm/frame.inc                 |   36 +
 arch/mn10300/include/asm/hardirq.h                 |    2 
 arch/mn10300/include/asm/intctl-regs.h             |   37 -
 arch/mn10300/include/asm/irq.h                     |    4 
 arch/mn10300/include/asm/irqflags.h                |   26 
 arch/mn10300/include/asm/pgtable.h                 |   19 
 arch/mn10300/include/asm/processor.h               |   47 +
 arch/mn10300/include/asm/ptrace.h                  |   15 
 arch/mn10300/include/asm/reset-regs.h              |    2 
 arch/mn10300/include/asm/rtc.h                     |   11 
 arch/mn10300/include/asm/rwlock.h                  |  125 ++
 arch/mn10300/include/asm/serial-regs.h             |   51 +
 arch/mn10300/include/asm/serial.h                  |    8 
 arch/mn10300/include/asm/smp.h                     |  102 ++
 arch/mn10300/include/asm/spinlock.h                |  179 +++
 arch/mn10300/include/asm/spinlock_types.h          |   20 
 arch/mn10300/include/asm/system.h                  |   11 
 arch/mn10300/include/asm/timer-regs.h              |  191 +++
 arch/mn10300/include/asm/timex.h                   |    3 
 arch/mn10300/include/asm/uaccess.h                 |    2 
 arch/mn10300/kernel/Makefile                       |    3 
 arch/mn10300/kernel/asm-offsets.c                  |    2 
 arch/mn10300/kernel/entry.S                        |  113 ++
 arch/mn10300/kernel/gdb-io-serial-low.S            |    5 
 arch/mn10300/kernel/gdb-io-serial.c                |   37 -
 arch/mn10300/kernel/gdb-io-ttysm.c                 |   24 
 arch/mn10300/kernel/gdb-stub.c                     |   17 
 arch/mn10300/kernel/head.S                         |  196 +++
 arch/mn10300/kernel/internal.h                     |   12 
 arch/mn10300/kernel/irq.c                          |  266 ++++-
 arch/mn10300/kernel/mn10300-serial-low.S           |    6 
 arch/mn10300/kernel/mn10300-serial.c               |  210 +++-
 arch/mn10300/kernel/mn10300-watchdog-low.S         |    9 
 arch/mn10300/kernel/mn10300-watchdog.c             |  100 +-
 arch/mn10300/kernel/process.c                      |   41 +
 arch/mn10300/kernel/profile.c                      |    2 
 arch/mn10300/kernel/rtc.c                          |   41 -
 arch/mn10300/kernel/setup.c                        |   75 +
 arch/mn10300/kernel/smp-low.S                      |   97 ++
 arch/mn10300/kernel/smp.c                          | 1141 ++++++++++++++++++++
 arch/mn10300/kernel/switch_to.S                    |   17 
 arch/mn10300/kernel/time.c                         |   32 -
 arch/mn10300/kernel/traps.c                        |   18 
 arch/mn10300/lib/delay.c                           |    8 
 arch/mn10300/mm/fault.c                            |   12 
 arch/mn10300/proc-mn103e010/include/proc/clock.h   |    2 
 .../proc-mn103e010/include/proc/intctl-regs.h      |   29 +
 arch/mn10300/proc-mn103e010/proc-init.c            |   35 +
 arch/mn10300/proc-mn2ws0050/Makefile               |    5 
 arch/mn10300/proc-mn2ws0050/include/proc/cache.h   |   48 +
 arch/mn10300/proc-mn2ws0050/include/proc/clock.h   |   20 
 .../proc-mn2ws0050/include/proc/dmactl-regs.h      |  103 ++
 .../proc-mn2ws0050/include/proc/intctl-regs.h      |   29 +
 arch/mn10300/proc-mn2ws0050/include/proc/irq.h     |   49 +
 .../proc-mn2ws0050/include/proc/nand-regs.h        |  120 ++
 arch/mn10300/proc-mn2ws0050/include/proc/proc.h    |   18 
 .../mn10300/proc-mn2ws0050/include/proc/smp-regs.h |   51 +
 arch/mn10300/proc-mn2ws0050/proc-init.c            |  134 ++
 arch/mn10300/unit-asb2303/include/unit/clock.h     |   25 
 arch/mn10300/unit-asb2303/include/unit/serial.h    |    5 
 arch/mn10300/unit-asb2303/include/unit/timex.h     |   64 +
 arch/mn10300/unit-asb2303/unit-init.c              |   10 
 arch/mn10300/unit-asb2305/include/unit/clock.h     |   25 
 arch/mn10300/unit-asb2305/include/unit/serial.h    |    5 
 arch/mn10300/unit-asb2305/include/unit/timex.h     |   66 +
 arch/mn10300/unit-asb2305/pci.c                    |    2 
 arch/mn10300/unit-asb2305/unit-init.c              |    6 
 arch/mn10300/unit-asb2364/Makefile                 |   10 
 arch/mn10300/unit-asb2364/include/unit/clock.h     |   29 +
 arch/mn10300/unit-asb2364/include/unit/fpga-regs.h |   50 +
 arch/mn10300/unit-asb2364/include/unit/leds.h      |   54 +
 arch/mn10300/unit-asb2364/include/unit/serial.h    |  151 +++
 arch/mn10300/unit-asb2364/include/unit/timex.h     |  125 ++
 arch/mn10300/unit-asb2364/leds.c                   |   98 ++
 arch/mn10300/unit-asb2364/unit-init.c              |   85 +
 80 files changed, 4495 insertions(+), 482 deletions(-)
 create mode 100644 arch/mn10300/include/asm/rwlock.h
 create mode 100644 arch/mn10300/include/asm/spinlock_types.h
 create mode 100644 arch/mn10300/kernel/smp-low.S
 create mode 100644 arch/mn10300/kernel/smp.c
 create mode 100644 arch/mn10300/proc-mn103e010/include/proc/intctl-regs.h
 create mode 100644 arch/mn10300/proc-mn2ws0050/Makefile
 create mode 100644 arch/mn10300/proc-mn2ws0050/include/proc/cache.h
 create mode 100644 arch/mn10300/proc-mn2ws0050/include/proc/clock.h
 create mode 100644 arch/mn10300/proc-mn2ws0050/include/proc/dmactl-regs.h
 create mode 100644 arch/mn10300/proc-mn2ws0050/include/proc/intctl-regs.h
 create mode 100644 arch/mn10300/proc-mn2ws0050/include/proc/irq.h
 create mode 100644 arch/mn10300/proc-mn2ws0050/include/proc/nand-regs.h
 create mode 100644 arch/mn10300/proc-mn2ws0050/include/proc/proc.h
 create mode 100644 arch/mn10300/proc-mn2ws0050/include/proc/smp-regs.h
 create mode 100644 arch/mn10300/proc-mn2ws0050/proc-init.c
 create mode 100644 arch/mn10300/unit-asb2364/Makefile
 create mode 100644 arch/mn10300/unit-asb2364/include/unit/clock.h
 create mode 100644 arch/mn10300/unit-asb2364/include/unit/fpga-regs.h
 create mode 100644 arch/mn10300/unit-asb2364/include/unit/leds.h
 create mode 100644 arch/mn10300/unit-asb2364/include/unit/serial.h
 create mode 100644 arch/mn10300/unit-asb2364/include/unit/timex.h
 create mode 100644 arch/mn10300/unit-asb2364/leds.c
 create mode 100644 arch/mn10300/unit-asb2364/unit-init.c
MAINTAINERS +1 -1
index 146b8a0..5ef7776 100644
@@ -4481,7 +4481,7 @@ L:	[email protected]
 S:	Maintained
 F:	drivers/platform/x86/panasonic-laptop.c
 
-PANASONIC MN10300/AM33 PORT
+PANASONIC MN10300/AM33/AM34 PORT
 M:	David Howells <[email protected]>
 M:	Koichi Yasutake <[email protected]>
 L:	[email protected] (moderated for non-subscribers)
arch/mn10300/Kconfig +86 -33

200 lines not on this page · raw message

arch/mn10300/Makefile +6 -0
index ac5c6bd..7120282 100644
@@ -36,6 +36,9 @@ endif
 ifeq ($(CONFIG_MN10300_PROC_MN103E010),y)
 PROCESSOR	:= mn103e010
 endif
+ifeq ($(CONFIG_MN10300_PROC_MN2WS0050),y)
+PROCESSOR	:= mn2ws0050
+endif
 
 ifeq ($(CONFIG_MN10300_UNIT_ASB2303),y)
 UNIT		:= asb2303
@@ -43,6 +46,9 @@ endif
 ifeq ($(CONFIG_MN10300_UNIT_ASB2305),y)
 UNIT		:= asb2305
 endif
+ifeq ($(CONFIG_MN10300_UNIT_ASB2364),y)
+UNIT		:= asb2364
+endif
 
 
 head-y		:= arch/mn10300/kernel/head.o arch/mn10300/kernel/init_task.o
arch/mn10300/boot/compressed/head.S +19 -1
index 4ef608a..7b50345 100644
@@ -15,10 +15,28 @@
 #include <linux/linkage.h>
 #include <asm/cpu-regs.h>
 #include <asm/cache.h>
+#ifdef CONFIG_SMP
+#include <proc/smp-regs.h>
+#endif
 
 	.globl startup_32
 startup_32:
-	# first save off parameters from bootloader
+#ifdef CONFIG_SMP
+	#
+	# Secondary CPUs jump directly to the kernel entry point
+	#
+	# Must save primary CPU's D0-D2 registers as they hold boot parameters
+	#
+	mov	(CPUID), d3
+	and	CPUID_MASK,d3
+	beq	startup_primary
+	mov	CONFIG_KERNEL_TEXT_ADDRESS,a0
+	jmp	(a0)
+
+startup_primary:
+#endif /* CONFIG_SMP */
+
+	# first save parameters from bootloader
 	mov	param_save_area,a0
 	mov	d0,(a0)
 	mov	d1,(4,a0)
arch/mn10300/include/asm/exceptions.h +2 -0
index 7d8080b..ca3e205 100644
@@ -114,6 +114,8 @@ extern void die(const char *, struct pt_regs *, enum exception_code)
 
 extern int die_if_no_fixup(const char *, struct pt_regs *, enum exception_code);
 
+#define NUM2EXCEP_IRQ_LEVEL(num)	(EXCEP_IRQ_LEVEL0 + (num) * 8)
+
 #endif /* __ASSEMBLY__ */
 
 #endif /* _ASM_EXCEPTIONS_H */
arch/mn10300/include/asm/frame.inc +36 -0
index 5b1949b..406060e 100644
@@ -18,6 +18,9 @@
 #ifndef __ASM_OFFSETS_H__
 #include <asm/asm-offsets.h>
 #endif
+#ifdef CONFIG_SMP
+#include <proc/smp-regs.h>
+#endif
 
 #define pi break
 
@@ -37,9 +40,25 @@
 	movm	[d2,d3,a2,a3,exreg0,exreg1,exother],(sp)
 	mov	sp,fp				# FRAME pointer in A3
 	add	-12,sp				# allow for calls to be made
+#ifdef CONFIG_SMP
+#ifdef CONFIG_PREEMPT /* FIXME */
+	mov	epsw,d2
+	and	~EPSW_IE,epsw
+#endif
+	mov	(CPUID),a0
+	add	a0,a0
+	add	a0,a0
+	mov	(___frame,a0),a1
+	mov	a1,(REG_NEXT,fp)
+	mov	fp,(___frame,a0)
+#ifdef CONFIG_PREEMPT /* FIXME */
+	mov	d2,epsw
+#endif
+#else  /* CONFIG_SMP */
 	mov	(__frame),a1
 	mov	a1,(REG_NEXT,fp)
 	mov	fp,(__frame)
+#endif /* CONFIG_SMP */
 
 	and	~EPSW_FE,epsw			# disable the FPU inside the kernel
 
@@ -57,10 +76,27 @@
 .macro RESTORE_ALL
 	# peel back the stack to the calling frame
 	# - this permits execve() to discard extra frames due to kernel syscalls
+#ifdef  CONFIG_SMP
+#ifdef CONFIG_PREEMPT /* FIXME */
+	mov	epsw,d2
+	and	~EPSW_IE,epsw
+#endif
+	mov	(CPUID),a0
+	add	a0,a0
+	add	a0,a0
+	mov	(___frame,a0),fp
+	mov	fp,sp
+	mov	(REG_NEXT,fp),d0                # userspace has regs->next == 0
+	mov	d0,(___frame,a0)
+#ifdef CONFIG_PREEMPT /* FIXME */
+	mov	d2,epsw
+#endif
+#else   /* CONFIG_SMP */
 	mov	(__frame),fp
 	mov	fp,sp
 	mov	(REG_NEXT,fp),d0                # userspace has regs->next == 0
 	mov	d0,(__frame)
+#endif  /* CONFIG_SMP */
 
 #ifndef CONFIG_MN10300_USING_JTAG
 	mov	(REG_EPSW,fp),d0
arch/mn10300/include/asm/hardirq.h +2 -0
index 7bd9b7c..0000d65 100644
@@ -19,8 +19,10 @@
 /* assembly code in softirq.h is sensitive to the offsets of these fields */
 typedef struct {
 	unsigned int	__softirq_pending;
+#ifdef CONFIG_MN10300_WD_TIMER
 	unsigned int	__nmi_count;	/* arch dependent */
 	unsigned int	__irq_count;	/* arch dependent */
+#endif
 } ____cacheline_aligned irq_cpustat_t;
 
 #include <linux/irq_cpustat.h>	/* Standard mappings for irq_cpustat_t above */
arch/mn10300/include/asm/intctl-regs.h +20 -17
index ba544c7..585b708 100644
@@ -15,24 +15,19 @@
 
 #ifdef __KERNEL__
 
-/* interrupt controller registers */
-#define GxICR(X)		__SYSREG(0xd4000000 + (X) * 4, u16)	/* group irq ctrl regs */
-
-#define IAGR			__SYSREG(0xd4000100, u16)	/* intr acceptance group reg */
-#define IAGR_GN			0x00fc		/* group number register
-						 * (documentation _has_ to be wrong)
-						 */
+/*
+ * Interrupt controller registers
+ * - Registers 64-191 are at addresses offset from the main array
+ */
+#define GxICR(X)						\
+	__SYSREG(0xd4000000 + (X) * 4 +				\
+		 (((X) >= 64) && ((X) < 192)) * 0xf00, u16)
 
-#define EXTMD			__SYSREG(0xd4000200, u16)	/* external pin intr spec reg */
-#define GET_XIRQ_TRIGGER(X) ((EXTMD >> ((X) * 2)) & 3)
+#define GxICR_u8(X)							\
+	__SYSREG(0xd4000000 + (X) * 4 +					\
+		 (((X) >= 64) && ((X) < 192)) * 0xf00, u8)
 
-#define SET_XIRQ_TRIGGER(X,Y)			\
-do {						\
-	u16 x = EXTMD;				\
-	x &= ~(3 << ((X) * 2));			\
-	x |= ((Y) & 3) << ((X) * 2);		\
-	EXTMD = x;				\
-} while (0)
+#include <proc/intctl-regs.h>
 
 #define XIRQ_TRIGGER_LOWLEVEL	0
 #define XIRQ_TRIGGER_HILEVEL	1
@@ -59,10 +54,18 @@ do {						\
 #define GxICR_LEVEL_5		0x5000		/* - level 5 */
 #define GxICR_LEVEL_6		0x6000		/* - level 6 */
 #define GxICR_LEVEL_SHIFT	12
+#define GxICR_NMI		0x8000		/* nmi request flag */
+
+#define NUM2GxICR_LEVEL(num)	((num) << GxICR_LEVEL_SHIFT)
 
 #ifndef __ASSEMBLY__
 extern void set_intr_level(int irq, u16 level);
-extern void set_intr_postackable(int irq);
+extern void mn10300_intc_set_level(unsigned int irq, unsigned int level);
+extern void mn10300_intc_clear(unsigned int irq);
+extern void mn10300_intc_set(unsigned int irq);
+extern void mn10300_intc_enable(unsigned int irq);
+extern void mn10300_intc_disable(unsigned int irq);
+extern void mn10300_set_lateack_irq_type(int irq);
 #endif
 
 /* external interrupts */
arch/mn10300/include/asm/irq.h +4 -0
index 25c045d..b7b8e17 100644
@@ -22,7 +22,11 @@
 #define NO_IRQ		INT_MAX
 
 /* hardware irq numbers */
+#ifdef CONFIG_SMP
+#define NR_IRQS		GxICR_NUM_EXT_IRQS
+#else
 #define NR_IRQS		GxICR_NUM_IRQS
+#endif
 
 /* external hardware irq numbers */
 #define NR_XIRQS	GxICR_NUM_XIRQS
arch/mn10300/include/asm/irqflags.h +23 -3
index b3ab207..7a7ae12 100644
@@ -13,6 +13,9 @@
 #define _ASM_IRQFLAGS_H
 
 #include <asm/cpu-regs.h>
+#ifndef __ASSEMBLY__
+#include <linux/smp.h>
+#endif
 
 /*
  * interrupt control
@@ -60,11 +63,12 @@ static inline unsigned long arch_local_irq_save(void)
 /*
  * we make sure arch_irq_enable() doesn't cause priority inversion
  */
-extern unsigned long __mn10300_irq_enabled_epsw;
+extern unsigned long __mn10300_irq_enabled_epsw[];
 
 static inline void arch_local_irq_enable(void)
 {
 	unsigned long tmp;
+	int cpu = raw_smp_processor_id();
 
 	asm volatile(
 		"	mov	epsw,%0		\n"
@@ -72,8 +76,8 @@ static inline void arch_local_irq_enable(void)
 		"	or	%2,%0		\n"
 		"	mov	%0,epsw		\n"
 		: "=&d"(tmp)
-		: "i"(~EPSW_IM), "r"(__mn10300_irq_enabled_epsw)
-		: "memory");
+		: "i"(~EPSW_IM), "r"(__mn10300_irq_enabled_epsw[cpu])
+		: "memory", "cc");
 }
 
 static inline void arch_local_irq_restore(unsigned long flags)
@@ -105,6 +109,9 @@ static inline bool arch_irqs_disabled(void)
  */
 static inline void arch_safe_halt(void)
 {
+#ifdef CONFIG_SMP
+	arch_local_irq_enable();
+#else
 	asm volatile(
 		"	or	%0,epsw	\n"
 		"	nop		\n"
@@ -113,8 +120,21 @@ static inline void arch_safe_halt(void)
 		:
 		: "i"(EPSW_IE|EPSW_IM), "n"(&CPUM), "i"(CPUM_SLEEP)
 		: "cc");
+#endif
 }
 
+#define __sleep_cpu()				\
+do {						\
+	asm volatile(				\
+		"	bset	%1,(%0)\n"	\
+		"1:	btst	%1,(%0)\n"	\
+		"	bne	1b\n"		\
+		:				\
+		: "i"(&CPUM), "i"(CPUM_SLEEP)	\
+		: "cc"				\
+		);				\
+} while (0)
+
 static inline void arch_local_cli(void)
 {
 	asm volatile(
arch/mn10300/include/asm/pgtable.h +13 -6
index 93c3294..ba66606 100644
@@ -90,9 +90,15 @@ extern pgd_t swapper_pg_dir[PTRS_PER_PGD];
  * The vmalloc() routines also leaves a hole of 4kB between each vmalloced
  * area to catch addressing errors.
  */
+#ifndef __ASSEMBLY__
+#define VMALLOC_OFFSET	(8UL * 1024 * 1024)
+#define VMALLOC_START	(0x70000000UL)
+#define VMALLOC_END	(0x7C000000UL)
+#else
 #define VMALLOC_OFFSET	(8 * 1024 * 1024)
 #define VMALLOC_START	(0x70000000)
 #define VMALLOC_END	(0x7C000000)
+#endif
 
 #ifndef __ASSEMBLY__
 extern pte_t kernel_vmalloc_ptes[(VMALLOC_END - VMALLOC_START) / PAGE_SIZE];
@@ -329,11 +335,7 @@ static inline int pte_exec_kernel(pte_t pte)
 	return 1;
 }
 
-/*
- * Bits 0 and 1 are taken, split up the 29 bits of offset
- * into this range:
- */
-#define PTE_FILE_MAX_BITS	29
+#define PTE_FILE_MAX_BITS	30
 
 #define pte_to_pgoff(pte)	(pte_val(pte) >> 2)
 #define pgoff_to_pte(off)	__pte((off) << 2 | _PAGE_FILE)
@@ -379,8 +381,13 @@ static inline void ptep_mkdirty(pte_t *ptep)
  * Macro to mark a page protection value as "uncacheable".  On processors which
  * do not support it, this is a no-op.
  */
-#define pgprot_noncached(prot)	__pgprot(pgprot_val(prot) | _PAGE_CACHE)
+#define pgprot_noncached(prot)	__pgprot(pgprot_val(prot) & ~_PAGE_CACHE)
 
+/*
+ * Macro to mark a page protection value as "Write-Through".
+ * On processors which do not support it, this is a no-op.
+ */
+#define pgprot_through(prot)	__pgprot(pgprot_val(prot) | _PAGE_CACHE_WT)
 
 /*
  * Conversion functions: convert a page and protection to a page entry,
arch/mn10300/include/asm/processor.h +34 -13

90 lines not on this page · raw message

arch/mn10300/include/asm/ptrace.h +6 -9
index 7c2e911..c2b77bd 100644
@@ -40,7 +40,6 @@
 #define	PT_PC		26
 #define NR_PTREGS	27
 
-#ifndef __ASSEMBLY__
 /*
  * This defines the way registers are stored in the event of an exception
  * - the strange order is due to the MOVM instruction
@@ -75,7 +74,6 @@ struct pt_regs {
 	unsigned long		epsw;
 	unsigned long		pc;
 };
-#endif
 
 /* Arbitrarily choose the same ptrace numbers as used by the Sparc code. */
 #define PTRACE_GETREGS            12
@@ -86,12 +84,13 @@ struct pt_regs {
 /* options set using PTRACE_SETOPTIONS */
 #define PTRACE_O_TRACESYSGOOD     0x00000001
 
-#if defined(__KERNEL__)
+#ifdef __KERNEL__
 
+#ifdef CONFIG_SMP
+extern struct pt_regs *___frame[];	/* current frame pointer */
+#else
 extern struct pt_regs *__frame;		/* current frame pointer */
-
-#if !defined(__ASSEMBLY__)
-struct task_struct;
+#endif
 
 #define user_mode(regs)			(((regs)->epsw & EPSW_nSL) == EPSW_nSL)
 #define instruction_pointer(regs)	((regs)->pc)
@@ -100,9 +99,7 @@ extern void show_regs(struct pt_regs *);
 
 #define arch_has_single_step()	(1)
 
-#endif  /*  !__ASSEMBLY  */
-
 #define profile_pc(regs) ((regs)->pc)
 
-#endif  /*  __KERNEL__  */
+#endif /* __KERNEL__  */
 #endif /* _ASM_PTRACE_H */
arch/mn10300/include/asm/reset-regs.h +1 -1
index 174523d..10c7502 100644
@@ -50,7 +50,7 @@ static inline void mn10300_proc_hard_reset(void)
 	RSTCTR |= RSTCTR_CHIPRST;
 }
 
-extern unsigned int watchdog_alert_counter;
+extern unsigned int watchdog_alert_counter[];
 
 extern void watchdog_go(void);
 extern asmlinkage void watchdog_handler(void);
arch/mn10300/include/asm/rtc.h +0 -11
index c295194..6c14bb1 100644
@@ -15,25 +15,14 @@
 
 #include <linux/init.h>
 
-extern void check_rtc_time(void);
 extern void __init calibrate_clock(void);
-extern unsigned long __init get_initial_rtc_time(void);
 
 #else /* !CONFIG_MN10300_RTC */
 
-static inline void check_rtc_time(void)
-{
-}
-
 static inline void calibrate_clock(void)
 {
 }
 
-static inline unsigned long get_initial_rtc_time(void)
-{
-	return 0;
-}
-
 #endif /* !CONFIG_MN10300_RTC */
 
 #include <asm-generic/rtc.h>
arch/mn10300/include/asm/rwlock.h new file +125 -0

125 lines not on this page · raw message

arch/mn10300/include/asm/serial-regs.h +41 -10

89 lines not on this page · raw message

arch/mn10300/include/asm/serial.h +4 -4
index a29445c..23a7992 100644
@@ -9,10 +9,8 @@
  * 2 of the Licence, or (at your option) any later version.
  */
 
-/*
- * The ASB2305 has an 18.432 MHz clock the UART
- */
-#define BASE_BAUD	(18432000 / 16)
+#ifndef _ASM_SERIAL_H
+#define _ASM_SERIAL_H
 
 /* Standard COM flags (except for COM4, because of the 8514 problem) */
 #ifdef CONFIG_SERIAL_DETECT_IRQ
@@ -34,3 +32,5 @@
 #endif
 
 #include <unit/serial.h>
+
+#endif /* _ASM_SERIAL_H */
arch/mn10300/include/asm/smp.h +101 -1

115 lines not on this page · raw message

arch/mn10300/include/asm/spinlock.h +178 -1

184 lines not on this page · raw message

arch/mn10300/include/asm/spinlock_types.h new file +20 -0
new file mode 100644
index 0000000..653dc51
@@ -0,0 +1,20 @@
+#ifndef _ASM_SPINLOCK_TYPES_H
+#define _ASM_SPINLOCK_TYPES_H
+
+#ifndef __LINUX_SPINLOCK_TYPES_H
+# error "please don't include this file directly"
+#endif
+
+typedef struct arch_spinlock {
+	unsigned int slock;
+} arch_spinlock_t;
+
+#define __ARCH_SPIN_LOCK_UNLOCKED	{ 0 }
+
+typedef struct {
+	unsigned int lock;
+} arch_rwlock_t;
+
+#define __ARCH_RW_LOCK_UNLOCKED		{ RW_LOCK_BIAS }
+
+#endif /* _ASM_SPINLOCK_TYPES_H */
arch/mn10300/include/asm/system.h +6 -5
index 7de90bc..8ff3e5a 100644
@@ -12,6 +12,7 @@
 #define _ASM_SYSTEM_H
 
 #include <asm/cpu-regs.h>
+#include <asm/intctl-regs.h>
 
 #ifdef __KERNEL__
 #ifndef __ASSEMBLY__
@@ -57,8 +58,6 @@ do {									\
 
 #define nop() asm volatile ("nop")
 
-#endif /* !__ASSEMBLY__ */
-
 /*
  * Force strict CPU ordering.
  * And yes, this is required on UP too when we're talking
@@ -85,17 +84,19 @@ do {									\
 #define smp_mb()	mb()
 #define smp_rmb()	rmb()
 #define smp_wmb()	wmb()
-#else
+#define set_mb(var, value)  do { xchg(&var, value); } while (0)
+#else  /* CONFIG_SMP */
 #define smp_mb()	barrier()
 #define smp_rmb()	barrier()
 #define smp_wmb()	barrier()
-#endif
-
 #define set_mb(var, value)  do { var = value;  mb(); } while (0)
+#endif /* CONFIG_SMP */
+
 #define set_wmb(var, value) do { var = value; wmb(); } while (0)
 
 #define read_barrier_depends()		do {} while (0)
 #define smp_read_barrier_depends()	do {} while (0)
 
+#endif /* !__ASSEMBLY__ */
 #endif /* __KERNEL__ */
 #endif /* _ASM_SYSTEM_H */
arch/mn10300/include/asm/timer-regs.h +175 -16

372 lines not on this page · raw message

arch/mn10300/include/asm/timex.h +1 -2
index 8d031f9..ce5719a 100644
@@ -16,8 +16,7 @@
 
 #define TICK_SIZE (tick_nsec / 1000)
 
-#define CLOCK_TICK_RATE 1193180 /* Underlying HZ - this should probably be set
-				 * to something appropriate, but what? */
+#define CLOCK_TICK_RATE MN10300_JCCLK /* Underlying HZ */
 
 extern cycles_t cacheflush_time;
 
arch/mn10300/include/asm/uaccess.h +1 -1
index 197a7af..47e7951 100644
@@ -377,7 +377,7 @@ unsigned long __generic_copy_to_user_nocheck(void *to, const void *from,
 
 
 #if 0
-#error don't use - these macros don't increment to & from pointers
+#error "don't use - these macros don't increment to & from pointers"
 /* Optimize just a little bit when we know the size of the move. */
 #define __constant_copy_user(to, from, size)	\
 do {						\
arch/mn10300/kernel/Makefile +2 -1
index 9902235..5b41192 100644
@@ -10,8 +10,9 @@ obj-y   := process.o signal.o entry.o traps.o irq.o \
 	   ptrace.o setup.o time.o sys_mn10300.o io.o kthread.o \
 	   switch_to.o mn10300_ksyms.o kernel_execve.o $(fpu-obj-y)
 
-obj-$(CONFIG_MN10300_WD_TIMER) += mn10300-watchdog.o mn10300-watchdog-low.o
+obj-$(CONFIG_SMP) += smp.o smp-low.o
 
+obj-$(CONFIG_MN10300_WD_TIMER) += mn10300-watchdog.o mn10300-watchdog-low.o
 
 obj-$(CONFIG_MN10300_TTYSM) += mn10300-serial.o mn10300-serial-low.o \
 			       mn10300-debug.o
arch/mn10300/kernel/asm-offsets.c +1 -1
index 78e290e..54cc5b6 100644
@@ -66,7 +66,7 @@ void foo(void)
 	OFFSET(THREAD_SP,		thread_struct, sp);
 	OFFSET(THREAD_A3,		thread_struct, a3);
 	OFFSET(THREAD_USP,		thread_struct, usp);
-	OFFSET(THREAD_FRAME,		thread_struct, __frame);
+	OFFSET(THREAD_FRAME,		thread_struct, frame);
 #ifdef CONFIG_FPU
 	OFFSET(THREAD_FPU_FLAGS,	thread_struct, fpu_flags);
 	OFFSET(THREAD_FPU_STATE,	thread_struct, fpu_state);
arch/mn10300/kernel/entry.S +90 -23

182 lines not on this page · raw message

arch/mn10300/kernel/gdb-io-serial-low.S +3 -2
index 4998b24..b1d0152 100644
@@ -18,6 +18,7 @@
 #include <asm/thread_info.h>
 #include <asm/frame.inc>
 #include <asm/intctl-regs.h>
+#include <asm/irqflags.h>
 #include <unit/serial.h>
 
 	.text
@@ -69,7 +70,7 @@ gdbstub_io_rx_overflow:
 	bra	gdbstub_io_rx_done
 
 gdbstub_io_rx_enter:
-	or	EPSW_IE|EPSW_IM_1,epsw
+	LOCAL_CHANGE_INTR_MASK_LEVEL(NUM2EPSW_IM(CONFIG_GDBSTUB_IRQ_LEVEL+1))
 	add	-4,sp
 	SAVE_ALL
 
@@ -80,7 +81,7 @@ gdbstub_io_rx_enter:
 	mov	fp,d0
 	call	gdbstub_rx_irq[],0	# gdbstub_rx_irq(regs,excep)
 
-	and	~EPSW_IE,epsw
+	LOCAL_CLI
 	bclr	0x01,(gdbstub_busy)
 
 	.globl gdbstub_return
arch/mn10300/kernel/gdb-io-serial.c +27 -10
index ae663dc..0d5d63c 100644
@@ -23,6 +23,7 @@
 #include <asm/exceptions.h>
 #include <asm/serial-regs.h>
 #include <unit/serial.h>
+#include <asm/smp.h>
 
 /*
  * initialise the GDB stub
@@ -45,22 +46,34 @@ void gdbstub_io_init(void)
 	XIRQxICR(GDBPORT_SERIAL_IRQ) = 0;
 	tmp = XIRQxICR(GDBPORT_SERIAL_IRQ);
 
+#if   CONFIG_GDBSTUB_IRQ_LEVEL == 0
 	IVAR0 = EXCEP_IRQ_LEVEL0;
-	set_intr_stub(EXCEP_IRQ_LEVEL0, gdbstub_io_rx_handler);
+#elif CONFIG_GDBSTUB_IRQ_LEVEL == 1
+	IVAR1 = EXCEP_IRQ_LEVEL1;
+#elif CONFIG_GDBSTUB_IRQ_LEVEL == 2
+	IVAR2 = EXCEP_IRQ_LEVEL2;
+#elif CONFIG_GDBSTUB_IRQ_LEVEL == 3
+	IVAR3 = EXCEP_IRQ_LEVEL3;
+#elif CONFIG_GDBSTUB_IRQ_LEVEL == 4
+	IVAR4 = EXCEP_IRQ_LEVEL4;
+#elif CONFIG_GDBSTUB_IRQ_LEVEL == 5
+	IVAR5 = EXCEP_IRQ_LEVEL5;
+#else
+#error "Unknown irq level for gdbstub."
+#endif
+
+	set_intr_stub(NUM2EXCEP_IRQ_LEVEL(CONFIG_GDBSTUB_IRQ_LEVEL),
+		gdbstub_io_rx_handler);
 
 	XIRQxICR(GDBPORT_SERIAL_IRQ) &= ~GxICR_REQUEST;
-	XIRQxICR(GDBPORT_SERIAL_IRQ) = GxICR_ENABLE | GxICR_LEVEL_0;
+	XIRQxICR(GDBPORT_SERIAL_IRQ) =
+		GxICR_ENABLE | NUM2GxICR_LEVEL(CONFIG_GDBSTUB_IRQ_LEVEL);
 	tmp = XIRQxICR(GDBPORT_SERIAL_IRQ);
 
 	GDBPORT_SERIAL_IER = UART_IER_RDI | UART_IER_RLSI;
 
 	/* permit level 0 IRQs to take place */
-	asm volatile(
-		"	and %0,epsw	\n"
-		"	or %1,epsw	\n"
-		:
-		: "i"(~EPSW_IM), "i"(EPSW_IE | EPSW_IM_1)
-		);
+	local_change_intr_mask_level(NUM2EPSW_IM(CONFIG_GDBSTUB_IRQ_LEVEL + 1));
 }
 
 /*
@@ -87,6 +100,9 @@ int gdbstub_io_rx_char(unsigned char *_ch, int nonblock)
 {
 	unsigned ix;
 	u8 ch, st;
+#if defined(CONFIG_MN10300_WD_TIMER)
+	int cpu;
+#endif
 
 	*_ch = 0xff;
 
@@ -104,8 +120,9 @@ int gdbstub_io_rx_char(unsigned char *_ch, int nonblock)
 		if (nonblock)
 			return -EAGAIN;
 #ifdef CONFIG_MN10300_WD_TIMER
-		watchdog_alert_counter = 0;
-#endif /* CONFIG_MN10300_WD_TIMER */
+	for (cpu = 0; cpu < NR_CPUS; cpu++)
+		watchdog_alert_counter[cpu] = 0;
+#endif
 		goto try_again;
 	}
 
arch/mn10300/kernel/gdb-io-ttysm.c +13 -11
index a560bbc..97dfda2 100644
@@ -58,9 +58,12 @@ void __init gdbstub_io_init(void)
 	gdbstub_io_set_baud(115200);
 
 	/* we want to get serial receive interrupts */
-	set_intr_level(gdbstub_port->rx_irq, GxICR_LEVEL_0);
-	set_intr_level(gdbstub_port->tx_irq, GxICR_LEVEL_0);
-	set_intr_stub(EXCEP_IRQ_LEVEL0, gdbstub_io_rx_handler);
+	set_intr_level(gdbstub_port->rx_irq,
+		NUM2GxICR_LEVEL(CONFIG_GDBSTUB_IRQ_LEVEL));
+	set_intr_level(gdbstub_port->tx_irq,
+		NUM2GxICR_LEVEL(CONFIG_GDBSTUB_IRQ_LEVEL));
+	set_intr_stub(NUM2EXCEP_IRQ_LEVEL(CONFIG_GDBSTUB_IRQ_LEVEL),
+		gdbstub_io_rx_handler);
 
 	*gdbstub_port->rx_icr |= GxICR_ENABLE;
 	tmp = *gdbstub_port->rx_icr;
@@ -84,12 +87,7 @@ void __init gdbstub_io_init(void)
 	tmp = *gdbstub_port->_control;
 
 	/* permit level 0 IRQs only */
-	asm volatile(
-		"	and %0,epsw	\n"
-		"	or %1,epsw	\n"
-		:
-		: "i"(~EPSW_IM), "i"(EPSW_IE|EPSW_IM_1)
-		);
+	local_change_intr_mask_level(NUM2EPSW_IM(CONFIG_GDBSTUB_IRQ_LEVEL + 1));
 }
 
 /*
@@ -184,6 +182,9 @@ int gdbstub_io_rx_char(unsigned char *_ch, int nonblock)
 {
 	unsigned ix;
 	u8 ch, st;
+#if defined(CONFIG_MN10300_WD_TIMER)
+	int cpu;
+#endif
 
 	*_ch = 0xff;
 
@@ -201,8 +202,9 @@ try_again:
 		if (nonblock)
 			return -EAGAIN;
 #ifdef CONFIG_MN10300_WD_TIMER
-		watchdog_alert_counter = 0;
-#endif /* CONFIG_MN10300_WD_TIMER */
+	for (cpu = 0; cpu < NR_CPUS; cpu++)
+		watchdog_alert_counter[cpu] = 0;
+#endif
 		goto try_again;
 	}
 
arch/mn10300/kernel/gdb-stub.c +6 -11
index 41b1170..a5fc3f0 100644
@@ -440,15 +440,11 @@ static const unsigned char gdbstub_insn_sizes[256] =
 
 static int __gdbstub_mark_bp(u8 *addr, int ix)
 {
-	if (addr < (u8 *) 0x70000000UL)
-		return 0;
-	/* 70000000-7fffffff: vmalloc area */
-	if (addr < (u8 *) 0x80000000UL)
+	/* vmalloc area */
+	if (((u8 *) VMALLOC_START <= addr) && (addr < (u8 *) VMALLOC_END))
 		goto okay;
-	if (addr < (u8 *) 0x8c000000UL)
-		return 0;
-	/* 8c000000-93ffffff: SRAM, SDRAM */
-	if (addr < (u8 *) 0x94000000UL)
+	/* SRAM, SDRAM */
+	if (((u8 *) 0x80000000UL <= addr) && (addr < (u8 *) 0xa0000000UL))
 		goto okay;
 	return 0;
 
@@ -1197,9 +1193,8 @@ static int gdbstub(struct pt_regs *regs, enum exception_code excep)
 	mn10300_set_gdbleds(1);
 
 	asm volatile("mov mdr,%0" : "=d"(mdr));
-	asm volatile("mov epsw,%0" : "=d"(epsw));
-	asm volatile("mov %0,epsw"
-		     :: "d"((epsw & ~EPSW_IM) | EPSW_IE | EPSW_IM_1));
+	local_save_flags(epsw);
+	local_change_intr_mask_level(NUM2EPSW_IM(CONFIG_GDBSTUB_IRQ_LEVEL + 1));
 
 	gdbstub_store_fpu();
 
arch/mn10300/kernel/head.S +195 -1

237 lines not on this page · raw message

arch/mn10300/kernel/internal.h +12 -0
index eee2eee..3b1f48b 100644
@@ -18,3 +18,15 @@ extern int kernel_thread_helper(int);
  * entry.S
  */
 extern void ret_from_fork(struct task_struct *) __attribute__((noreturn));
+
+/*
+ * smp-low.S
+ */
+#ifdef CONFIG_SMP
+extern void mn10300_low_ipi_handler(void);
+#endif
+
+/*
+ * time.c
+ */
+extern irqreturn_t local_timer_interrupt(void);
arch/mn10300/kernel/irq.c +241 -25

371 lines not on this page · raw message

arch/mn10300/kernel/mn10300-serial-low.S +3 -3
index 66702d2..dfc1b6f 100644
@@ -39,7 +39,7 @@
 ###############################################################################
 	.balign	L1_CACHE_BYTES
 ENTRY(mn10300_serial_vdma_interrupt)
-	or	EPSW_IE,psw			# permit overriding by
+#	or	EPSW_IE,psw			# permit overriding by
 						# debugging interrupts
 	movm	[d2,d3,a2,a3,exreg0],(sp)
 
@@ -164,7 +164,7 @@ mnsc_vdma_tx_noint:
 	rti
 
 mnsc_vdma_tx_empty:
-	mov	+(GxICR_LEVEL_1|GxICR_DETECT),d2
+	mov	+(NUM2GxICR_LEVEL(CONFIG_MN10300_SERIAL_IRQ_LEVEL)|GxICR_DETECT),d2
 	movhu	d2,(e3)			# disable the interrupt
 	movhu	(e3),d2			# flush
 
@@ -175,7 +175,7 @@ mnsc_vdma_tx_break:
 	movhu	(SCxCTR,e2),d2		# turn on break mode
 	or	SC01CTR_BKE,d2
 	movhu	d2,(SCxCTR,e2)
-	mov	+(GxICR_LEVEL_1|GxICR_DETECT),d2
+	mov	+(NUM2GxICR_LEVEL(CONFIG_MN10300_SERIAL_IRQ_LEVEL)|GxICR_DETECT),d2
 	movhu	d2,(e3)			# disable transmit interrupts on this
 					# channel
 	movhu	(e3),d2			# flush
arch/mn10300/kernel/mn10300-serial.c +181 -29

341 lines not on this page · raw message

arch/mn10300/kernel/mn10300-watchdog-low.S +8 -1
index 9962447..f2f5c9c 100644

Lines of this file are not shown. View the raw message.

arch/mn10300/kernel/mn10300-watchdog.c +61 -39

100 lines not on this page · raw message

arch/mn10300/kernel/process.c +37 -4

41 lines not on this page · raw message

arch/mn10300/kernel/profile.c +1 -1
index 20d7d03..4f342f7 100644

Lines of this file are not shown. View the raw message.

arch/mn10300/kernel/rtc.c +10 -31

41 lines not on this page · raw message

arch/mn10300/kernel/setup.c +41 -34

75 lines not on this page · raw message

arch/mn10300/kernel/smp-low.S new file +97 -0

97 lines not on this page · raw message

arch/mn10300/kernel/smp.c new file +1141 -0

1,141 lines not on this page · raw message

arch/mn10300/kernel/switch_to.S +17 -0
index 630aad7..b08cb2e 100644

Lines of this file are not shown. View the raw message.

arch/mn10300/kernel/time.c +21 -11
index 0b5c856..0cb9bdb 100644

Lines of this file are not shown. View the raw message.

arch/mn10300/kernel/traps.c +16 -2
index 716a221..c924a1d 100644

Lines of this file are not shown. View the raw message.

arch/mn10300/lib/delay.c +4 -4
index fdf6f71..8e7ceb8 100644

Lines of this file are not shown. View the raw message.

arch/mn10300/mm/fault.c +4 -8
index 906e4c8..59c3da4 100644

Lines of this file are not shown. View the raw message.

arch/mn10300/proc-mn103e010/include/proc/clock.h +0 -2
index aa23e14..704a819 100644

Lines of this file are not shown. View the raw message.

arch/mn10300/proc-mn103e010/include/proc/intctl-regs.h new file +29 -0
new file mode 100644
index 0000000..f537801

Lines of this file are not shown. View the raw message.

arch/mn10300/proc-mn103e010/proc-init.c +35 -0
index 0cee787..27b9798 100644

Lines of this file are not shown. View the raw message.

arch/mn10300/proc-mn2ws0050/Makefile new file +5 -0
new file mode 100644
index 0000000..d4ca133

Lines of this file are not shown. View the raw message.

arch/mn10300/proc-mn2ws0050/include/proc/cache.h new file +48 -0

48 lines not on this page · raw message

arch/mn10300/proc-mn2ws0050/include/proc/clock.h new file +20 -0
new file mode 100644
index 0000000..fe4c0a4

Lines of this file are not shown. View the raw message.

arch/mn10300/proc-mn2ws0050/include/proc/dmactl-regs.h new file +103 -0

103 lines not on this page · raw message

arch/mn10300/proc-mn2ws0050/include/proc/intctl-regs.h new file +29 -0
new file mode 100644
index 0000000..a1e9772

Lines of this file are not shown. View the raw message.

arch/mn10300/proc-mn2ws0050/include/proc/irq.h new file +49 -0

49 lines not on this page · raw message

arch/mn10300/proc-mn2ws0050/include/proc/nand-regs.h new file +120 -0

120 lines not on this page · raw message

arch/mn10300/proc-mn2ws0050/include/proc/proc.h new file +18 -0
new file mode 100644
index 0000000..90d5cad

Lines of this file are not shown. View the raw message.

arch/mn10300/proc-mn2ws0050/include/proc/smp-regs.h new file +51 -0

51 lines not on this page · raw message

arch/mn10300/proc-mn2ws0050/proc-init.c new file +134 -0

134 lines not on this page · raw message

arch/mn10300/unit-asb2303/include/unit/clock.h +2 -23
index 2a0bf79..0316907 100644

Lines of this file are not shown. View the raw message.

arch/mn10300/unit-asb2303/include/unit/serial.h +5 -0
index 047566c..991e356 100644

Lines of this file are not shown. View the raw message.

arch/mn10300/unit-asb2303/include/unit/timex.h +43 -21

64 lines not on this page · raw message

arch/mn10300/unit-asb2303/unit-init.c +9 -1
index 70e8cb4..834a76a 100644

Lines of this file are not shown. View the raw message.

arch/mn10300/unit-asb2305/include/unit/clock.h +2 -23
index 67be3f2..29e3425 100644

Lines of this file are not shown. View the raw message.

arch/mn10300/unit-asb2305/include/unit/serial.h +5 -0
index 8086cc0..88c0821 100644

Lines of this file are not shown. View the raw message.

arch/mn10300/unit-asb2305/include/unit/timex.h +44 -22

66 lines not on this page · raw message

arch/mn10300/unit-asb2305/pci.c +1 -1
index 6d8720a..a4954fe 100644

Lines of this file are not shown. View the raw message.

arch/mn10300/unit-asb2305/unit-init.c +4 -2
index a76c8e0..e1becd6 100644

Lines of this file are not shown. View the raw message.

arch/mn10300/unit-asb2364/Makefile new file +10 -0
new file mode 100644
index 0000000..6dd27d6

Lines of this file are not shown. View the raw message.

arch/mn10300/unit-asb2364/include/unit/clock.h new file +29 -0
new file mode 100644
index 0000000..d34ac9a

Lines of this file are not shown. View the raw message.

arch/mn10300/unit-asb2364/include/unit/fpga-regs.h new file +50 -0

50 lines not on this page · raw message

arch/mn10300/unit-asb2364/include/unit/leds.h new file +54 -0

54 lines not on this page · raw message

arch/mn10300/unit-asb2364/include/unit/serial.h new file +151 -0

151 lines not on this page · raw message

arch/mn10300/unit-asb2364/include/unit/timex.h new file +125 -0

125 lines not on this page · raw message

arch/mn10300/unit-asb2364/leds.c new file +98 -0

98 lines not on this page · raw message

arch/mn10300/unit-asb2364/unit-init.c new file +85 -0

85 lines not on this page · raw message

The rest of this diff is not shown. View the raw message.

Part of the diff is not shown here. View the raw message.

#36 lore raw

Re: [Linux-am33-list] [PATCH 35/43] MN10300: And Panasonic AM34 subarch and implement SMP

Hi.

Quoted 11 lines · David Howells

From: Akira Takeuchi <[email protected]>

Implement the Panasonic MN10300 AM34 CPU subarch and implement SMP support for MN10300. Also implement support for the MN2WS0060 processor and the ASB2364 evaluation board which are AM34 based.

---

(snip)

Quoted 10 lines
 arch/mn10300/proc-mn2ws0050/Makefile               |    5
 arch/mn10300/proc-mn2ws0050/include/proc/cache.h   |   48 +
 arch/mn10300/proc-mn2ws0050/include/proc/clock.h   |   20
 .../proc-mn2ws0050/include/proc/dmactl-regs.h      |  103 ++
 .../proc-mn2ws0050/include/proc/intctl-regs.h      |   29 +
 arch/mn10300/proc-mn2ws0050/include/proc/irq.h     |   49 +
 .../proc-mn2ws0050/include/proc/nand-regs.h        |  120 ++
 arch/mn10300/proc-mn2ws0050/include/proc/proc.h    |   18
 .../mn10300/proc-mn2ws0050/include/proc/smp-regs.h |   51 +
 arch/mn10300/proc-mn2ws0050/proc-init.c            |  134 ++

Are these specific to mn2ws0050 or common among AM34 based SoCs? Please dig a proc- directory using proc- group name, not specific SoC name.

Signature · 1 line
Suzuki Takashi
#37 lore raw

Re: [Linux-am33-list] [PATCH 35/43] MN10300: And Panasonic AM34 subarch and implement SMP

Quoted 11 lines · Suzuki Takashi
Quoted 10 lines
 arch/mn10300/proc-mn2ws0050/Makefile               |    5
 arch/mn10300/proc-mn2ws0050/include/proc/cache.h   |   48 +
 arch/mn10300/proc-mn2ws0050/include/proc/clock.h   |   20
 .../proc-mn2ws0050/include/proc/dmactl-regs.h      |  103 ++
 .../proc-mn2ws0050/include/proc/intctl-regs.h      |   29 +
 arch/mn10300/proc-mn2ws0050/include/proc/irq.h     |   49 +
 .../proc-mn2ws0050/include/proc/nand-regs.h        |  120 ++
 arch/mn10300/proc-mn2ws0050/include/proc/proc.h    |   18
 .../mn10300/proc-mn2ws0050/include/proc/smp-regs.h |   51 +
 arch/mn10300/proc-mn2ws0050/proc-init.c            |  134 ++
Quoted 1 line

Are these specific to mn2ws0050 or common among AM34 based SoCs?

These are specific to the MN2WS0050 processor chip. The MN2WS0050 is one example of a chip that has one or more AM34 cores, plus a bunch of on-silicon peripherals.

David

#38 lore raw

PATCH 36/43 MN10300: ASB2364: Add support for SMSC911X and SMC911X

In reply to David Howells

From: Akira Takeuchi <[email protected]>

Add support for SMSC911X and SMC911X for the ASB2364 unit.

---

 arch/mn10300/Kconfig                              |    1 
 arch/mn10300/include/asm/smsc911x.h               |    1 
 arch/mn10300/unit-asb2364/Makefile                |    2 
 arch/mn10300/unit-asb2364/include/unit/smsc911x.h |  198 +++++++++++++++++++++
 arch/mn10300/unit-asb2364/smsc911x.c              |   58 ++++++
 drivers/net/Kconfig                               |   12 +
 drivers/net/smsc911x.c                            |    7 +
 drivers/net/smsc911x.h                            |   17 ++
 8 files changed, 292 insertions(+), 4 deletions(-)
 create mode 100644 arch/mn10300/include/asm/smsc911x.h
 create mode 100644 arch/mn10300/unit-asb2364/include/unit/smsc911x.h
 create mode 100644 arch/mn10300/unit-asb2364/smsc911x.c
arch/mn10300/Kconfig +1 -0
index 81e2781..88901a2 100644
@@ -96,6 +96,7 @@ config MN10300_UNIT_ASB2305
 
 config MN10300_UNIT_ASB2364
 	bool "ASB2364"
+	select SMSC911X_ARCH_HOOKS if SMSC911X
 
 endchoice
 
arch/mn10300/include/asm/smsc911x.h new file +1 -0
new file mode 100644
index 0000000..2fcd108
@@ -0,0 +1 @@
+#include <unit/smsc911x.h>
arch/mn10300/unit-asb2364/Makefile +1 -1
index 6dd27d6..2fdd99b 100644
@@ -7,4 +7,4 @@
 #
 # Note 2! The CFLAGS definitions are now in the main makefile...
 
-obj-y   := unit-init.o leds.o
+obj-y   := unit-init.o leds.o smsc911x.o
arch/mn10300/unit-asb2364/include/unit/smsc911x.h new file +198 -0

198 lines not on this page · raw message

arch/mn10300/unit-asb2364/smsc911x.c new file +58 -0

58 lines not on this page · raw message

drivers/net/Kconfig +10 -2
index 86fe67f..9334539 100644
@@ -1041,7 +1041,7 @@ config SMC911X
 	tristate "SMSC LAN911[5678] support"
 	select CRC32
 	select MII
-	depends on ARM || SUPERH
+	depends on ARM || SUPERH || MN10300
 	help
 	  This is a driver for SMSC's LAN911x series of Ethernet chipsets
 	  including the new LAN9115, LAN9116, LAN9117, and LAN9118.
@@ -1055,7 +1055,7 @@ config SMC911X
 
 config SMSC911X
 	tristate "SMSC LAN911x/LAN921x families embedded ethernet support"
-	depends on ARM || SUPERH || BLACKFIN || MIPS
+	depends on ARM || SUPERH || BLACKFIN || MIPS || MN10300
 	select CRC32
 	select MII
 	select PHYLIB
@@ -1067,6 +1067,14 @@ config SMSC911X
 	  <file:Documentation/networking/net-modules.txt>. The module
 	  will be called smsc911x.
 
+config SMSC911X_ARCH_HOOKS
+	def_bool n
+	depends on SMSC911X
+	help
+	  If the arch enables this, it allows the arch to implement various
+	  hooks for more comprehensive interrupt control and also to override
+	  the source of the MAC address.
+
 config NET_VENDOR_RACAL
 	bool "Racal-Interlan (Micom) NI cards"
 	depends on ISA
drivers/net/smsc911x.c +6 -1
index a8e5856..54b55c1 100644
@@ -1456,6 +1456,7 @@ static irqreturn_t smsc911x_irqhandler(int irq, void *dev_id)
 	int serviced = IRQ_NONE;
 	u32 temp;
 
+	SMSC_CHECK_INTERRUPT();
 	if (unlikely(intsts & inten & INT_STS_SW_INT_)) {
 		temp = smsc911x_reg_read(pdata, INT_EN);
 		temp &= (~INT_EN_SW_INT_EN_);
@@ -1506,6 +1507,7 @@ static irqreturn_t smsc911x_irqhandler(int irq, void *dev_id)
 		serviced = IRQ_HANDLED;
 	}
 
+	SMSC_CLEAR_INTERRUPT();
 	return serviced;
 }
 
@@ -1931,6 +1933,7 @@ static int __devexit smsc911x_drv_remove(struct platform_device *pdev)
 
 	platform_set_drvdata(pdev, NULL);
 	unregister_netdev(dev);
+	SMSC_SET_INTERRUPT_MASK();
 	free_irq(dev->irq, dev);
 	res = platform_get_resource_byname(pdev, IORESOURCE_MEM,
 					   "smsc911x-memory");
@@ -2042,6 +2045,7 @@ static int __devinit smsc911x_drv_probe(struct platform_device *pdev)
 			"Unable to claim requested irq: %d", dev->irq);
 		goto out_unmap_io_3;
 	}
+	SMSC_CLEAR_INTERRUPT_MASK();
 
 	platform_set_drvdata(pdev, dev);
 
@@ -2075,7 +2079,7 @@ static int __devinit smsc911x_drv_probe(struct platform_device *pdev)
 	} else {
 		/* Try reading mac address from device. if EEPROM is present
 		 * it will already have been set */
-		smsc911x_read_mac_address(dev);
+		smsc_get_mac(dev);
 
 		if (is_valid_ether_addr(dev->dev_addr)) {
 			/* eeprom values are valid  so use them */
@@ -2176,6 +2180,7 @@ static struct platform_driver smsc911x_driver = {
 /* Entry point for loading the module */
 static int __init smsc911x_init_module(void)
 {
+	SMSC_INITIALIZE();
 	return platform_driver_register(&smsc911x_driver);
 }
 
drivers/net/smsc911x.h +17 -0
index 016360c..14a7087 100644
@@ -394,4 +394,21 @@
 #define LPA_PAUSE_ALL			(LPA_PAUSE_CAP | \
 					 LPA_PAUSE_ASYM)
 
+/*
+ * Provide hooks to let the arch implement more comprehensive interrupt control
+ * and to override the source of the MAC address.
+ */
+#define SMSC_INITIALIZE()		do {} while (0)
+#define SMSC_CHECK_INTERRUPT()		do {} while (0)
+#define SMSC_CLEAR_INTERRUPT()		do {} while (0)
+#define SMSC_SET_INTERRUPT_MASK()	do {} while (0)
+#define SMSC_CLEAR_INTERRUPT_MASK()	do {} while (0)
+#define smsc_get_mac(dev)		smsc911x_read_mac_address((dev))
+
+#ifdef CONFIG_SMSC911X_ARCH_HOOKS
+#include <asm/smsc911x.h>
+#endif
+
+
+
 #endif				/* __SMSC911X_H__ */
#39 lore raw

PATCH 37/43 MN10300: Map userspace atomic op regs as a vmalloc page

In reply to David Howells

From: Mark Salter <[email protected]>

The AM34 processor has an atomic operation that's the equivalent of LL/SC on other architectures. However, rather than being done through a pair of instructions, it's driven by writing to a pair of memory-mapped CPU control registers.

One set of these registers (AARU/ADRU/ASRU) is available for use by userspace, but for userspace to access them a PTE must be set up to cover the region. This is done by dedicating the first vmalloc region page to this purpose, setting the permissions on its PTE such that userspace can access the page.

glibc is hardcoded to expect the registers to be there.

The way atomic ops are done through these registers is straightforward:

(1) Write the address of the word you wish to access into AARU. This causes the CPU to go and fetch that word and load it into ADRU. The status bits are also cleared in ASRU.

(2) The current data value is read from the ADRU register and modified.

(3) To alter the data in RAM, the revised data is written back to the ADRU register, which causes the CPU to attempt to write it back.

(4) The ASRU.RW flag (ASRU read watch), ASRU.LW flag (bus lock watch), ASRU.IW (interrupt watch) and the ASRU.BW (bus error watch) flags then must be checked to confirm that the operation wasn't aborted. If any of the watches have been set to true, the operation was aborted.

---

 arch/mn10300/include/asm/pgtable.h |    3 +++
 arch/mn10300/mm/init.c             |   21 +++++++++++++++++++++
 2 files changed, 24 insertions(+), 0 deletions(-)
arch/mn10300/include/asm/pgtable.h +3 -0
index ba66606..b6e77f5 100644
@@ -182,6 +182,9 @@ extern pte_t kernel_vmalloc_ptes[(VMALLOC_END - VMALLOC_START) / PAGE_SIZE];
 #define PAGE_KERNEL_LARGE	__pgprot(__PAGE_KERNEL_LARGE)
 #define PAGE_KERNEL_LARGE_EXEC	__pgprot(__PAGE_KERNEL_LARGE_EXEC)
 
+#define __PAGE_USERIO		(__PAGE_KERNEL_BASE | _PAGE_PROT_WKWU | _PAGE_NX)
+#define PAGE_USERIO		__pgprot(__PAGE_USERIO)
+
 /*
  * Whilst the MN10300 can do page protection for execute (given separate data
  * and insn TLBs), we are not supporting it at the moment. Write permission,
arch/mn10300/mm/init.c +21 -0
index 1daf97f..48907cc 100644
@@ -41,6 +41,10 @@ DEFINE_PER_CPU(struct mmu_gather, mmu_gathers);
 
 unsigned long highstart_pfn, highend_pfn;
 
+#ifdef CONFIG_MN10300_HAS_ATOMIC_OPS_UNIT
+static struct vm_struct user_iomap_vm;
+#endif
+
 /*
  * set up paging
  */
@@ -73,6 +77,23 @@ void __init paging_init(void)
 	/* pass the memory from the bootmem allocator to the main allocator */
 	free_area_init(zones_size);
 
+#ifdef CONFIG_MN10300_HAS_ATOMIC_OPS_UNIT
+	/* The Atomic Operation Unit registers need to be mapped to userspace
+	 * for all processes.  The following uses vm_area_register_early() to
+	 * reserve the first page of the vmalloc area and sets the pte for that
+	 * page.
+	 *
+	 * glibc hardcodes this virtual mapping, so we're pretty much stuck with
+	 * it from now on.
+	 */
+	user_iomap_vm.flags = VM_USERMAP;
+	user_iomap_vm.size = 1 << PAGE_SHIFT;
+	vm_area_register_early(&user_iomap_vm, PAGE_SIZE);
+	ppte = kernel_vmalloc_ptes;
+	set_pte(ppte, pfn_pte(USER_ATOMIC_OPS_PAGE_ADDR >> PAGE_SHIFT,
+			      PAGE_USERIO));
+#endif
+
 	local_flush_tlb_all();
 }
 
#40 lore raw

PATCH 38/43 MN10300: Specify an ELF HWCAP flag for MN10300 Atomic Operations Unit support

In reply to David Howells

From: Mark Salter <[email protected]>

Use an ELF HWCAP flag to indicate to the process that the CPU provides LL/SC equivalent atomic operations unit support in addition to BSET/BCLR.

---

 arch/mn10300/include/asm/elf.h |   10 ++++++++++
 1 files changed, 10 insertions(+), 0 deletions(-)
arch/mn10300/include/asm/elf.h +10 -0
index a30d220..8157c92 100644
@@ -32,6 +32,12 @@
 #define R_MN10300_ALIGN 	34	/* Alignment requirement. */
 
 /*
+ * AM33/AM34 HW Capabilities
+ */
+#define HWCAP_MN10300_ATOMIC_OP_UNIT	1	/* Has AM34 Atomic Operations */
+
+
+/*
  * ELF register definitions..
  */
 typedef unsigned long elf_greg_t;
@@ -128,7 +134,11 @@ do {						\
  * instruction set this CPU supports.  This could be done in user space,
  * but it's not easy, and we've already done it here.
  */
+#ifdef CONFIG_MN10300_HAS_ATOMIC_OPS_UNIT
+#define ELF_HWCAP	(HWCAP_MN10300_ATOMIC_OP_UNIT)
+#else
 #define ELF_HWCAP	(0)
+#endif
 
 /*
  * This yields a string that ld.so will use to load implementation
#41 lore raw

PATCH 39/43 MN10300: Generic time support

In reply to David Howells

From: Mark Salter <[email protected]>

Implement generic time support for MN10300.

---

 arch/mn10300/Kconfig                           |   22 ++++
 arch/mn10300/include/asm/timex.h               |   17 +++
 arch/mn10300/kernel/Makefile                   |    2 
 arch/mn10300/kernel/cevt-mn10300.c             |  131 ++++++++++++++++++++++++
 arch/mn10300/kernel/csrc-mn10300.c             |   35 ++++++
 arch/mn10300/kernel/internal.h                 |   13 ++
 arch/mn10300/kernel/irq.c                      |   32 ++----
 arch/mn10300/kernel/smp.c                      |   15 ++-
 arch/mn10300/kernel/time.c                     |   79 +++++++++++---
 arch/mn10300/unit-asb2303/include/unit/timex.h |   48 ++++-----
 arch/mn10300/unit-asb2305/include/unit/timex.h |   48 ++++-----
 arch/mn10300/unit-asb2364/include/unit/timex.h |   74 ++++++++++----
 12 files changed, 401 insertions(+), 115 deletions(-)
 create mode 100644 arch/mn10300/kernel/cevt-mn10300.c
 create mode 100644 arch/mn10300/kernel/csrc-mn10300.c
arch/mn10300/Kconfig +22 -0
index 88901a2..129ca49 100644
@@ -56,6 +56,27 @@ config GENERIC_FIND_NEXT_BIT
 config GENERIC_HWEIGHT
 	def_bool y
 
+config GENERIC_TIME
+	def_bool y
+
+config GENERIC_CLOCKEVENTS
+	def_bool y
+
+config GENERIC_CLOCKEVENTS_BUILD
+	def_bool y
+	depends on GENERIC_CLOCKEVENTS
+
+config GENERIC_CLOCKEVENTS_BROADCAST
+	bool
+
+config CEVT_MN10300
+       def_bool y
+       depends on GENERIC_CLOCKEVENTS
+
+config CSRC_MN10300
+       def_bool y
+       depends on GENERIC_TIME
+
 config GENERIC_BUG
 	def_bool y
 
@@ -246,6 +267,7 @@ config MN10300_USING_JTAG
 	  single-stepping, which are taken over completely by the JTAG unit.
 
 source "kernel/Kconfig.hz"
+source "kernel/time/Kconfig"
 
 config MN10300_RTC
 	bool "Using MN10300 RTC"
arch/mn10300/include/asm/timex.h +15 -2
index ce5719a..bd4e90d 100644
@@ -18,15 +18,28 @@
 
 #define CLOCK_TICK_RATE MN10300_JCCLK /* Underlying HZ */
 
-extern cycles_t cacheflush_time;
-
 #ifdef __KERNEL__
 
+extern cycles_t cacheflush_time;
+
 static inline cycles_t get_cycles(void)
 {
 	return read_timestamp_counter();
 }
 
+extern int init_clockevents(void);
+extern int init_clocksource(void);
+
+static inline void setup_jiffies_interrupt(int irq,
+					   struct irqaction *action)
+{
+	u16 tmp;
+	setup_irq(irq, action);
+	set_intr_level(irq, NUM2GxICR_LEVEL(CONFIG_TIMER_IRQ_LEVEL));
+	GxICR(irq) |= GxICR_ENABLE | GxICR_DETECT | GxICR_REQUEST;
+	tmp = GxICR(irq);
+}
+
 #endif /* __KERNEL__ */
 
 #endif /* _ASM_TIMEX_H */
arch/mn10300/kernel/Makefile +2 -0
index 5b41192..8f5f1e8 100644
@@ -28,3 +28,5 @@ obj-$(CONFIG_MN10300_RTC) += rtc.o
 obj-$(CONFIG_PROFILE) += profile.o profile-low.o
 obj-$(CONFIG_MODULES) += module.o
 obj-$(CONFIG_KPROBES) += kprobes.o
+obj-$(CONFIG_CSRC_MN10300) += csrc-mn10300.o
+obj-$(CONFIG_CEVT_MN10300) += cevt-mn10300.o
arch/mn10300/kernel/cevt-mn10300.c new file +131 -0

131 lines not on this page · raw message

arch/mn10300/kernel/csrc-mn10300.c new file +35 -0
new file mode 100644
index 0000000..ba2f0c4
@@ -0,0 +1,35 @@
+/* MN10300 clocksource
+ *
+ * Copyright (C) 2010 Red Hat, Inc. All Rights Reserved.
+ * Written by Mark Salter ([email protected])
+ *
+ * This program is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU General Public Licence
+ * as published by the Free Software Foundation; either version
+ * 2 of the Licence, or (at your option) any later version.
+ */
+#include <linux/clocksource.h>
+#include <linux/init.h>
+#include <asm/timex.h>
+#include "internal.h"
+
+static cycle_t mn10300_read(struct clocksource *cs)
+{
+	return read_timestamp_counter();
+}
+
+static struct clocksource clocksource_mn10300 = {
+	.name	= "TSC",
+	.rating	= 200,
+	.read	= mn10300_read,
+	.mask	= CLOCKSOURCE_MASK(32),
+	.flags	= CLOCK_SOURCE_IS_CONTINUOUS,
+};
+
+int __init init_clocksource(void)
+{
+	startup_timestamp_counter();
+	clocksource_set_clock(&clocksource_mn10300, MN10300_TSCCLK);
+	clocksource_register(&clocksource_mn10300);
+	return 0;
+}
arch/mn10300/kernel/internal.h +13 -0
index 3b1f48b..6a064ab 100644
@@ -9,6 +9,9 @@
  * 2 of the Licence, or (at your option) any later version.
  */
 
+struct clocksource;
+struct clock_event_device;
+
 /*
  * kthread.S
  */
@@ -30,3 +33,13 @@ extern void mn10300_low_ipi_handler(void);
  * time.c
  */
 extern irqreturn_t local_timer_interrupt(void);
+
+/*
+ * time.c
+ */
+#ifdef CONFIG_CEVT_MN10300
+extern void clockevent_set_clock(struct clock_event_device *, unsigned int);
+#endif
+#ifdef CONFIG_CSRC_MN10300
+extern void clocksource_set_clock(struct clocksource *, unsigned int);
+#endif
arch/mn10300/kernel/irq.c +13 -19
index 80f1572..2f66a45 100644
@@ -16,14 +16,6 @@
 #include <asm/setup.h>
 #include <asm/serial-regs.h>
 
-#ifdef CONFIG_SMP
-#undef  GxICR
-#define GxICR(X) CROSS_GxICR(X, irq_affinity_online[X])
-
-#undef  GxICR_u8
-#define GxICR_u8(X) CROSS_GxICR_u8(X, irq_affinity_online[X])
-#endif /* CONFIG_SMP */
-
 unsigned long __mn10300_irq_enabled_epsw[NR_CPUS] __cacheline_aligned_in_smp = {
 	[0 ... NR_CPUS - 1] = EPSW_IE | EPSW_IM_7
 };
@@ -92,9 +84,11 @@ static void mn10300_cpupic_mask_ack(unsigned int irq)
 		GxICR(irq) = (tmp & GxICR_LEVEL);
 		tmp2 = GxICR(irq);
 
-		irq_affinity_online[irq] = any_online_cpu(*irq_desc[irq].affinity);
-		GxICR(irq) = (tmp & (GxICR_LEVEL | GxICR_ENABLE)) | GxICR_DETECT;
-		tmp = GxICR(irq);
+		irq_affinity_online[irq] =
+			any_online_cpu(*irq_desc[irq].affinity);
+		CROSS_GxICR(irq, irq_affinity_online[irq]) =
+			(tmp & (GxICR_LEVEL | GxICR_ENABLE)) | GxICR_DETECT;
+		tmp = CROSS_GxICR(irq, irq_affinity_online[irq]);
 	}
 
 	arch_local_irq_restore(flags);
@@ -128,8 +122,8 @@ static void mn10300_cpupic_unmask_clear(unsigned int irq)
 		tmp = GxICR(irq);
 
 		irq_affinity_online[irq] = any_online_cpu(*irq_desc[irq].affinity);
-		GxICR(irq) = (tmp & GxICR_LEVEL) | GxICR_ENABLE | GxICR_DETECT;
-		tmp = GxICR(irq);
+		CROSS_GxICR(irq, irq_affinity_online[irq]) = (tmp & GxICR_LEVEL) | GxICR_ENABLE | GxICR_DETECT;
+		tmp = CROSS_GxICR(irq, irq_affinity_online[irq]);
 	}
 
 	arch_local_irq_restore(flags);
@@ -217,7 +211,7 @@ static struct irq_chip mn10300_cpu_pic_level = {
 	.unmask		= mn10300_cpupic_unmask_clear,
 #ifdef CONFIG_SMP
 	.set_affinity	= mn10300_cpupic_setaffinity,
-#endif /* CONFIG_SMP */
+#endif
 };
 
 /*
@@ -235,7 +229,7 @@ static struct irq_chip mn10300_cpu_pic_edge = {
 	.unmask		= mn10300_cpupic_unmask,
 #ifdef CONFIG_SMP
 	.set_affinity	= mn10300_cpupic_setaffinity,
-#endif /* CONFIG_SMP */
+#endif
 };
 
 /*
@@ -446,9 +440,9 @@ void migrate_irqs(void)
 		if (irq_affinity_online[irq] == self) {
 			u16 x, tmp;
 
-			x = CROSS_GxICR(irq, self);
-			CROSS_GxICR(irq, self) = x & GxICR_LEVEL;
-			tmp = CROSS_GxICR(irq, self);
+			x = GxICR(irq);
+			GxICR(irq) = x & GxICR_LEVEL;
+			tmp = GxICR(irq);
 
 			new = any_online_cpu(irq_desc[irq].affinity);
 			irq_affinity_online[irq] = new;
@@ -458,7 +452,7 @@ void migrate_irqs(void)
 			tmp = CROSS_GxICR(irq, new);
 
 			x &= GxICR_LEVEL | GxICR_ENABLE;
-			if (CROSS_GxICR(irq, self) & GxICR_REQUEST)
+			if (GxICR(irq) & GxICR_REQUEST) {
 				x |= GxICR_REQUEST | GxICR_DETECT;
 			CROSS_GxICR(irq, new) = x;
 			tmp = CROSS_GxICR(irq, new);
arch/mn10300/kernel/smp.c +13 -2
index b80234c..0dcd1c6 100644
@@ -126,7 +126,6 @@ static struct irq_chip mn10300_ipi_type = {
 
 static irqreturn_t smp_reschedule_interrupt(int irq, void *dev_id);
 static irqreturn_t smp_call_function_interrupt(int irq, void *dev_id);
-static irqreturn_t smp_ipi_timer_interrupt(int irq, void *dev_id);
 
 static struct irqaction reschedule_ipi = {
 	.handler	= smp_reschedule_interrupt,
@@ -136,11 +135,15 @@ static struct irqaction call_function_ipi = {
 	.handler	= smp_call_function_interrupt,
 	.name		= "smp call function IPI"
 };
+
+#if !defined(CONFIG_GENERIC_CLOCKEVENTS) || defined(CONFIG_GENERIC_CLOCKEVENTS_BROADCAST)
+static irqreturn_t smp_ipi_timer_interrupt(int irq, void *dev_id);
 static struct irqaction local_timer_ipi = {
 	.handler	= smp_ipi_timer_interrupt,
 	.flags		= IRQF_DISABLED,
 	.name		= "smp local timer IPI"
 };
+#endif
 
 /**
  * init_ipi - Initialise the IPI mechanism
@@ -165,11 +168,14 @@ static void init_ipi(void)
 	mn10300_ipi_enable(CALL_FUNC_SINGLE_IPI);
 
 	/* set up the local timer IPI */
+#if !defined(CONFIG_GENERIC_CLOCKEVENTS) || \
+    defined(CONFIG_GENERIC_CLOCKEVENTS_BROADCAST)
 	set_irq_chip_and_handler(LOCAL_TIMER_IPI,
 				 &mn10300_ipi_type, handle_percpu_irq);
 	setup_irq(LOCAL_TIMER_IPI, &local_timer_ipi);
 	set_intr_level(LOCAL_TIMER_IPI, LOCAL_TIMER_GxICR_LV);
 	mn10300_ipi_enable(LOCAL_TIMER_IPI);
+#endif
 
 #ifdef CONFIG_MN10300_CACHE_ENABLED
 	/* set up the cache flush IPI */
@@ -505,6 +511,8 @@ void smp_nmi_call_function_interrupt(void)
 	}
 }
 
+#if !defined(CONFIG_GENERIC_CLOCKEVENTS) || \
+    defined(CONFIG_GENERIC_CLOCKEVENTS_BROADCAST)
 /**
  * smp_ipi_timer_interrupt - Local timer IPI handler
  * @irq: The interrupt number.
@@ -516,6 +524,7 @@ static irqreturn_t smp_ipi_timer_interrupt(int irq, void *dev_id)
 {
 	return local_timer_interrupt();
 }
+#endif
 
 void __init smp_init_cpus(void)
 {
@@ -620,7 +629,6 @@ void smp_prepare_cpu_init(void)
 int __init start_secondary(void *unused)
 {
 	smp_cpu_init();
-
 	smp_callin();
 	while (!cpu_isset(smp_processor_id(), smp_commenced_mask))
 		cpu_relax();
@@ -629,6 +637,9 @@ int __init start_secondary(void *unused)
 	preempt_disable();
 	smp_online();
 
+#ifdef CONFIG_GENERIC_CLOCKEVENTS
+	init_clockevents();
+#endif
 	cpu_idle();
 	return 0;
 }
arch/mn10300/kernel/time.c +61 -18

132 lines not on this page · raw message

arch/mn10300/unit-asb2303/include/unit/timex.h +21 -27

78 lines not on this page · raw message

arch/mn10300/unit-asb2305/include/unit/timex.h +21 -27

78 lines not on this page · raw message

arch/mn10300/unit-asb2364/include/unit/timex.h +54 -20

119 lines not on this page · raw message

#42 lore raw

PATCH 40/43 MN10300: Update the ASB2303 defconfig

In reply to David Howells

From: Akira Takeuchi <[email protected]>

---

 arch/mn10300/configs/asb2303_defconfig |    2 ++
 1 files changed, 2 insertions(+), 0 deletions(-)
arch/mn10300/configs/asb2303_defconfig +2 -0
index d80dfcb..3f749b6 100644
@@ -12,6 +12,8 @@ CONFIG_SLAB=y
 CONFIG_PROFILING=y
 # CONFIG_BLOCK is not set
 CONFIG_PREEMPT=y
+CONFIG_NO_HZ=y
+CONFIG_HIGH_RES_TIMERS=y
 CONFIG_MN10300_RTC=y
 CONFIG_MN10300_TTYSM_CONSOLE=y
 CONFIG_MN10300_TTYSM0=y
#43 lore raw

PATCH 41/43 MN10300: Create a defconfig for the ASB2364 board

In reply to David Howells

From: Akira Takeuchi <[email protected]>

Create a defconfig for the ASB2364 board.

---

 arch/mn10300/configs/asb2364_defconfig |   98 ++++++++++++++++++++++++++++++++
 1 files changed, 98 insertions(+), 0 deletions(-)
 create mode 100644 arch/mn10300/configs/asb2364_defconfig
arch/mn10300/configs/asb2364_defconfig new file +98 -0
new file mode 100644
index 0000000..83ce2f2
@@ -0,0 +1,98 @@
+CONFIG_EXPERIMENTAL=y
+CONFIG_SYSVIPC=y
+CONFIG_POSIX_MQUEUE=y
+CONFIG_BSD_PROCESS_ACCT=y
+CONFIG_TASKSTATS=y
+CONFIG_TASK_DELAY_ACCT=y
+CONFIG_TASK_XACCT=y
+CONFIG_TASK_IO_ACCOUNTING=y
+CONFIG_LOG_BUF_SHIFT=14
+CONFIG_CGROUPS=y
+CONFIG_CGROUP_NS=y
+CONFIG_CGROUP_FREEZER=y
+CONFIG_CGROUP_DEVICE=y
+CONFIG_CGROUP_CPUACCT=y
+CONFIG_RESOURCE_COUNTERS=y
+CONFIG_RELAY=y
+# CONFIG_CC_OPTIMIZE_FOR_SIZE is not set
+CONFIG_EMBEDDED=y
+# CONFIG_KALLSYMS is not set
+# CONFIG_VM_EVENT_COUNTERS is not set
+CONFIG_SLAB=y
+CONFIG_PROFILING=y
+CONFIG_MODULES=y
+CONFIG_MODULE_UNLOAD=y
+# CONFIG_BLOCK is not set
+CONFIG_MN10300_UNIT_ASB2364=y
+CONFIG_PREEMPT=y
+# CONFIG_MN10300_USING_JTAG is not set
+CONFIG_NO_HZ=y
+CONFIG_HIGH_RES_TIMERS=y
+CONFIG_MN10300_TTYSM_CONSOLE=y
+CONFIG_MN10300_TTYSM0=y
+CONFIG_MN10300_TTYSM0_TIMER2=y
+CONFIG_MN10300_TTYSM1=y
+CONFIG_NET=y
+CONFIG_PACKET=y
+CONFIG_UNIX=y
+CONFIG_INET=y
+CONFIG_IP_MULTICAST=y
+CONFIG_IP_PNP=y
+CONFIG_IP_PNP_BOOTP=y
+# CONFIG_INET_XFRM_MODE_TRANSPORT is not set
+# CONFIG_INET_XFRM_MODE_TUNNEL is not set
+# CONFIG_INET_XFRM_MODE_BEET is not set
+# CONFIG_INET_LRO is not set
+# CONFIG_INET_DIAG is not set
+CONFIG_IPV6=y
+# CONFIG_INET6_XFRM_MODE_TRANSPORT is not set
+# CONFIG_INET6_XFRM_MODE_TUNNEL is not set
+# CONFIG_INET6_XFRM_MODE_BEET is not set
+# CONFIG_FIRMWARE_IN_KERNEL is not set
+CONFIG_CONNECTOR=y
+CONFIG_MTD=y
+CONFIG_MTD_DEBUG=y
+CONFIG_MTD_PARTITIONS=y
+CONFIG_MTD_REDBOOT_PARTS=y
+CONFIG_MTD_REDBOOT_PARTS_UNALLOCATED=y
+CONFIG_MTD_CHAR=y
+CONFIG_MTD_CFI=y
+CONFIG_MTD_JEDECPROBE=y
+CONFIG_MTD_CFI_ADV_OPTIONS=y
+CONFIG_MTD_CFI_GEOMETRY=y
+CONFIG_MTD_CFI_I4=y
+CONFIG_MTD_CFI_AMDSTD=y
+CONFIG_MTD_PHYSMAP=y
+CONFIG_NETDEVICES=y
+CONFIG_NET_ETHERNET=y
+CONFIG_SMSC911X=y
+# CONFIG_NETDEV_1000 is not set
+# CONFIG_NETDEV_10000 is not set
+# CONFIG_INPUT_MOUSEDEV is not set
+# CONFIG_INPUT_KEYBOARD is not set
+# CONFIG_INPUT_MOUSE is not set
+# CONFIG_SERIO is not set
+# CONFIG_VT is not set
+CONFIG_SERIAL_8250=y
+CONFIG_SERIAL_8250_CONSOLE=y
+CONFIG_SERIAL_8250_EXTENDED=y
+CONFIG_SERIAL_8250_SHARE_IRQ=y
+# CONFIG_HW_RANDOM is not set
+# CONFIG_HWMON is not set
+# CONFIG_HID_SUPPORT is not set
+# CONFIG_USB_SUPPORT is not set
+CONFIG_PROC_KCORE=y
+# CONFIG_PROC_PAGE_MONITOR is not set
+CONFIG_TMPFS=y
+CONFIG_TMPFS_POSIX_ACL=y
+CONFIG_JFFS2_FS=y
+CONFIG_NFS_FS=y
+CONFIG_NFS_V3=y
+CONFIG_ROOT_NFS=y
+CONFIG_MAGIC_SYSRQ=y
+CONFIG_STRIP_ASM_SYMS=y
+CONFIG_DEBUG_KERNEL=y
+CONFIG_DETECT_HUNG_TASK=y
+# CONFIG_DEBUG_BUGVERBOSE is not set
+CONFIG_DEBUG_INFO=y
+# CONFIG_RCU_CPU_STALL_DETECTOR is not set
#44 lore raw

PATCH 42/43 MN10300: Change "Matsushita" to "Panasonic".

In reply to David Howells

From: Akira Takeuchi <[email protected]>

Change externally visible "Matsushita" instances to "Panasonic" throughout the MN10300 arch code.

---

 arch/mn10300/Kconfig                            |    4 ++--
 arch/mn10300/kernel/setup.c                     |    4 ++--
 arch/mn10300/proc-mn103e010/include/proc/proc.h |    2 +-
 3 files changed, 5 insertions(+), 5 deletions(-)
arch/mn10300/Kconfig +2 -2
index 129ca49..365766a 100644
@@ -93,14 +93,14 @@ config GENERIC_HARDIRQS
 config HOTPLUG_CPU
 	def_bool n
 
-mainmenu "Matsushita MN10300/AM33 Kernel Configuration"
+mainmenu "Panasonic MN10300/AM33 Kernel Configuration"
 
 source "init/Kconfig"
 
 source "kernel/Kconfig.freezer"
 
 
-menu "Matsushita MN10300 system setup"
+menu "Panasonic MN10300 system setup"
 
 choice
 	prompt "Unit type"
arch/mn10300/kernel/setup.c +2 -2
index 1251457..9e7a320 100644
@@ -187,7 +187,7 @@ void __init cpu_init(void)
 	if (type > mn10300_known_cpus)
 		type = mn10300_known_cpus;
 
-	printk(KERN_INFO "Matsushita %s, rev %ld\n",
+	printk(KERN_INFO "Panasonic %s, rev %ld\n",
 	       mn10300_cputypes[type],
 	       (cpurev & CPUREV_REVISION) >> CPUREV_REVISION_S);
 
@@ -246,7 +246,7 @@ static int show_cpuinfo(struct seq_file *m, void *v)
 
 	seq_printf(m,
 		   "processor  : %ld\n"
-		   "vendor_id  : Matsushita\n"
+		   "vendor_id  : " PROCESSOR_VENDOR_NAME "\n"
 		   "cpu core   : %s\n"
 		   "cpu rev    : %lu\n"
 		   "model name : " PROCESSOR_MODEL_NAME		"\n"
arch/mn10300/proc-mn103e010/include/proc/proc.h +1 -1
index 22a2b93..39c4f8e 100644
@@ -12,7 +12,7 @@
 #ifndef _ASM_PROC_PROC_H
 #define _ASM_PROC_PROC_H
 
-#define PROCESSOR_VENDOR_NAME	"Matsushita"
+#define PROCESSOR_VENDOR_NAME	"Panasonic"
 #define PROCESSOR_MODEL_NAME	"mn103e010"
 
 #endif /* _ASM_PROC_PROC_H */
#45 lore raw

PATCH 43/43 MN10300: Save frame pointer in thread_info struct rather than global var

In reply to David Howells

Save the current exception frame pointer in the thread_info struct rather than in a global variable as the latter makes SMP tricky, especially when preemption is also enabled.

This also replaces __frame with current_frame() and rearranges header file inclusions to make it all compile.

---

 arch/mn10300/include/asm/frame.inc     |   56 +++++++-------------------------
 arch/mn10300/include/asm/irq_regs.h    |    6 +++
 arch/mn10300/include/asm/pgalloc.h     |    1 -
 arch/mn10300/include/asm/processor.h   |   46 ++++++++++----------------
 arch/mn10300/include/asm/ptrace.h      |    6 ---
 arch/mn10300/include/asm/smp.h         |   13 -------
 arch/mn10300/include/asm/thread_info.h |   18 ++++++++--
 arch/mn10300/include/asm/uaccess.h     |    4 +-
 arch/mn10300/kernel/asm-offsets.c      |    2 +
 arch/mn10300/kernel/mn10300-watchdog.c |    2 +
 arch/mn10300/kernel/process.c          |   20 ++++++-----
 arch/mn10300/kernel/signal.c           |   20 ++++++-----
 arch/mn10300/kernel/switch_to.S        |   18 ----------
 arch/mn10300/kernel/traps.c            |    8 -----
 mm/maccess.c                           |    2 +
 15 files changed, 76 insertions(+), 146 deletions(-)
arch/mn10300/include/asm/frame.inc +13 -43
index 406060e..2ee58e3 100644
@@ -18,9 +18,7 @@
 #ifndef __ASM_OFFSETS_H__
 #include <asm/asm-offsets.h>
 #endif
-#ifdef CONFIG_SMP
-#include <proc/smp-regs.h>
-#endif
+#include <asm/thread_info.h>
 
 #define pi break
 
@@ -40,27 +38,15 @@
 	movm	[d2,d3,a2,a3,exreg0,exreg1,exother],(sp)
 	mov	sp,fp				# FRAME pointer in A3
 	add	-12,sp				# allow for calls to be made
-#ifdef CONFIG_SMP
-#ifdef CONFIG_PREEMPT /* FIXME */
-	mov	epsw,d2
-	and	~EPSW_IE,epsw
-#endif
-	mov	(CPUID),a0
-	add	a0,a0
-	add	a0,a0
-	mov	(___frame,a0),a1
-	mov	a1,(REG_NEXT,fp)
-	mov	fp,(___frame,a0)
-#ifdef CONFIG_PREEMPT /* FIXME */
-	mov	d2,epsw
-#endif
-#else  /* CONFIG_SMP */
-	mov	(__frame),a1
-	mov	a1,(REG_NEXT,fp)
-	mov	fp,(__frame)
-#endif /* CONFIG_SMP */
 
-	and	~EPSW_FE,epsw			# disable the FPU inside the kernel
+	# push the exception frame onto the front of the list
+	GET_THREAD_INFO a1
+	mov	(TI_frame,a1),a0
+	mov	a0,(REG_NEXT,fp)
+	mov	fp,(TI_frame,a1)
+
+	# disable the FPU inside the kernel
+	and	~EPSW_FE,epsw
 
 	# we may be holding current in E2
 #ifdef CONFIG_MN10300_CURRENT_IN_E2
@@ -76,27 +62,11 @@
 .macro RESTORE_ALL
 	# peel back the stack to the calling frame
 	# - this permits execve() to discard extra frames due to kernel syscalls
-#ifdef  CONFIG_SMP
-#ifdef CONFIG_PREEMPT /* FIXME */
-	mov	epsw,d2
-	and	~EPSW_IE,epsw
-#endif
-	mov	(CPUID),a0
-	add	a0,a0
-	add	a0,a0
-	mov	(___frame,a0),fp
-	mov	fp,sp
-	mov	(REG_NEXT,fp),d0                # userspace has regs->next == 0
-	mov	d0,(___frame,a0)
-#ifdef CONFIG_PREEMPT /* FIXME */
-	mov	d2,epsw
-#endif
-#else   /* CONFIG_SMP */
-	mov	(__frame),fp
+	GET_THREAD_INFO a0
+	mov	(TI_frame,a0),fp
 	mov	fp,sp
-	mov	(REG_NEXT,fp),d0                # userspace has regs->next == 0
-	mov	d0,(__frame)
-#endif  /* CONFIG_SMP */
+	mov	(REG_NEXT,fp),d0
+	mov	d0,(TI_frame,a0)                # userspace has regs->next == 0
 
 #ifndef CONFIG_MN10300_USING_JTAG
 	mov	(REG_EPSW,fp),d0
arch/mn10300/include/asm/irq_regs.h +5 -1
index a848cd2..97d0cb5 100644
@@ -18,7 +18,11 @@
 #define ARCH_HAS_OWN_IRQ_REGS
 
 #ifndef __ASSEMBLY__
-#define get_irq_regs() (__frame)
+static inline __attribute__((const))
+struct pt_regs *get_irq_regs(void)
+{
+	return current_frame();
+}
 #endif
 
 #endif /* _ASM_IRQ_REGS_H */
arch/mn10300/include/asm/pgalloc.h +0 -1
index a19f113..146bacf 100644
@@ -11,7 +11,6 @@
 #ifndef _ASM_PGALLOC_H
 #define _ASM_PGALLOC_H
 
-#include <asm/processor.h>
 #include <asm/page.h>
 #include <linux/threads.h>
 #include <linux/mm.h>		/* for struct page */
arch/mn10300/include/asm/processor.h +18 -28

79 lines not on this page · raw message

arch/mn10300/include/asm/ptrace.h +0 -6
index c2b77bd..b696181 100644
@@ -86,12 +86,6 @@ struct pt_regs {
 
 #ifdef __KERNEL__
 
-#ifdef CONFIG_SMP
-extern struct pt_regs *___frame[];	/* current frame pointer */
-#else
-extern struct pt_regs *__frame;		/* current frame pointer */
-#endif
-
 #define user_mode(regs)			(((regs)->epsw & EPSW_nSL) == EPSW_nSL)
 #define instruction_pointer(regs)	((regs)->pc)
 #define user_stack_pointer(regs)	((regs)->sp)
arch/mn10300/include/asm/smp.h +0 -13
index b8585b4..a3930e4 100644
@@ -93,19 +93,6 @@ extern int __cpu_disable(void);
 extern void __cpu_die(unsigned int cpu);
 #endif /* CONFIG_HOTPLUG_CPU */
 
-#ifdef CONFIG_PREEMPT /* FIXME */
-#define __frame					\
-	({					\
-		struct pt_regs *f;		\
-		preempt_disable();		\
-		f = ___frame[CPUID];		\
-		preempt_enable();		\
-		f;				\
-	})
-#else
-#define __frame ___frame[CPUID]
-#endif
-
 #endif /* __ASSEMBLY__ */
 #else /* CONFIG_SMP */
 #ifndef __ASSEMBLY__
arch/mn10300/include/asm/thread_info.h +14 -4
index 2001cb6..aa07a4a 100644
@@ -16,10 +16,6 @@
 
 #include <asm/page.h>
 
-#ifndef __ASSEMBLY__
-#include <asm/processor.h>
-#endif
-
 #define PREEMPT_ACTIVE		0x10000000
 
 #ifdef CONFIG_4KSTACKS
@@ -38,10 +34,14 @@
  *   must also be changed
  */
 #ifndef __ASSEMBLY__
+typedef struct {
+	unsigned long	seg;
+} mm_segment_t;
 
 struct thread_info {
 	struct task_struct	*task;		/* main task structure */
 	struct exec_domain	*exec_domain;	/* execution domain */
+	struct pt_regs		*frame;		/* current exception frame */
 	unsigned long		flags;		/* low level flags */
 	__u32			cpu;		/* current CPU */
 	__s32			preempt_count;	/* 0 => preemptable, <0 => BUG */
@@ -55,6 +55,10 @@ struct thread_info {
 	__u8			supervisor_stack[0];
 };
 
+#define thread_info_to_uregs(ti)					\
+	((struct pt_regs *)						\
+	 ((unsigned long)ti + THREAD_SIZE - sizeof(struct pt_regs)))
+
 #else /* !__ASSEMBLY__ */
 
 #ifndef __ASM_OFFSETS_H__
@@ -102,6 +106,12 @@ struct thread_info *current_thread_info(void)
 	return ti;
 }
 
+static inline __attribute__((const))
+struct pt_regs *current_frame(void)
+{
+	return current_thread_info()->frame;
+}
+
 /* how to get the current stack pointer from C */
 static inline unsigned long current_stack_pointer(void)
 {
arch/mn10300/include/asm/uaccess.h +1 -3
index 47e7951..679dee0 100644
@@ -14,9 +14,8 @@
 /*
  * User space memory access functions
  */
-#include <linux/sched.h>
+#include <linux/thread_info.h>
 #include <asm/page.h>
-#include <asm/pgtable.h>
 #include <asm/errno.h>
 
 #define VERIFY_READ 0
@@ -29,7 +28,6 @@
  *
  * For historical reasons, these macros are grossly misnamed.
  */
-
 #define MAKE_MM_SEG(s)	((mm_segment_t) { (s) })
 
 #define KERNEL_XDS	MAKE_MM_SEG(0xBFFFFFFF)
arch/mn10300/kernel/asm-offsets.c +1 -1
index 54cc5b6..96f24fa 100644
@@ -23,6 +23,7 @@ void foo(void)
 
 	OFFSET(TI_task,			thread_info, task);
 	OFFSET(TI_exec_domain,		thread_info, exec_domain);
+	OFFSET(TI_frame,		thread_info, frame);
 	OFFSET(TI_flags,		thread_info, flags);
 	OFFSET(TI_cpu,			thread_info, cpu);
 	OFFSET(TI_preempt_count,	thread_info, preempt_count);
@@ -66,7 +67,6 @@ void foo(void)
 	OFFSET(THREAD_SP,		thread_struct, sp);
 	OFFSET(THREAD_A3,		thread_struct, a3);
 	OFFSET(THREAD_USP,		thread_struct, usp);
-	OFFSET(THREAD_FRAME,		thread_struct, frame);
 #ifdef CONFIG_FPU
 	OFFSET(THREAD_FPU_FLAGS,	thread_struct, fpu_flags);
 	OFFSET(THREAD_FPU_STATE,	thread_struct, fpu_state);
arch/mn10300/kernel/mn10300-watchdog.c +1 -1
index 965dd61..c5e12bf 100644
@@ -122,7 +122,7 @@ void __init watchdog_go(void)
 static void watchdog_dump_register(void *dummy)
 {
 	printk(KERN_ERR "--- Register Dump (CPU%d) ---\n", CPUID);
-	show_registers(__frame);
+	show_registers(current_frame());
 }
 #endif
 
arch/mn10300/kernel/process.c +11 -9
index b2e85ed..0d0f804 100644
@@ -228,6 +228,7 @@ int copy_thread(unsigned long clone_flags,
 		unsigned long c_usp, unsigned long ustk_size,
 		struct task_struct *p, struct pt_regs *kregs)
 {
+	struct thread_info *ti = task_thread_info(p);
 	struct pt_regs *c_uregs, *c_kregs, *uregs;
 	unsigned long c_ksp;
 
@@ -248,7 +249,7 @@ int copy_thread(unsigned long clone_flags,
 
 	/* the new TLS pointer is passed in as arg #5 to sys_clone() */
 	if (clone_flags & CLONE_SETTLS)
-		c_uregs->e2 = __frame->d3;
+		c_uregs->e2 = current_frame()->d3;
 
 	/* set up the return kernel frame if called from kernel_thread() */
 	c_kregs = c_uregs;
@@ -266,7 +267,7 @@ int copy_thread(unsigned long clone_flags,
 	}
 
 	/* set up things up so the scheduler can start the new task */
-	p->thread.frame = c_kregs;
+	ti->frame	= c_kregs;
 	p->thread.a3	= (unsigned long) c_kregs;
 	p->thread.sp	= c_ksp;
 	p->thread.pc	= (unsigned long) ret_from_fork;
@@ -278,25 +279,26 @@ int copy_thread(unsigned long clone_flags,
 
 /*
  * clone a process
- * - tlsptr is retrieved by copy_thread() from __frame->d3
+ * - tlsptr is retrieved by copy_thread() from current_frame()->d3
  */
 asmlinkage long sys_clone(unsigned long clone_flags, unsigned long newsp,
 			  int __user *parent_tidptr, int __user *child_tidptr,
 			  int __user *tlsptr)
 {
-	return do_fork(clone_flags, newsp ?: __frame->sp, __frame, 0,
-		       parent_tidptr, child_tidptr);
+	return do_fork(clone_flags, newsp ?: current_frame()->sp,
+		       current_frame(), 0, parent_tidptr, child_tidptr);
 }
 
 asmlinkage long sys_fork(void)
 {
-	return do_fork(SIGCHLD, __frame->sp, __frame, 0, NULL, NULL);
+	return do_fork(SIGCHLD, current_frame()->sp,
+		       current_frame(), 0, NULL, NULL);
 }
 
 asmlinkage long sys_vfork(void)
 {
-	return do_fork(CLONE_VFORK | CLONE_VM | SIGCHLD, __frame->sp, __frame,
-		       0, NULL, NULL);
+	return do_fork(CLONE_VFORK | CLONE_VM | SIGCHLD, current_frame()->sp,
+		       current_frame(), 0, NULL, NULL);
 }
 
 asmlinkage long sys_execve(const char __user *name,
@@ -310,7 +312,7 @@ asmlinkage long sys_execve(const char __user *name,
 	error = PTR_ERR(filename);
 	if (IS_ERR(filename))
 		return error;
-	error = do_execve(filename, argv, envp, __frame);
+	error = do_execve(filename, argv, envp, current_frame());
 	putname(filename);
 	return error;
 }
arch/mn10300/kernel/signal.c +11 -9
index d4de05a..690f4e9 100644
@@ -91,7 +91,7 @@ asmlinkage long sys_sigaction(int sig,
  */
 asmlinkage long sys_sigaltstack(const stack_t __user *uss, stack_t *uoss)
 {
-	return do_sigaltstack(uss, uoss, __frame->sp);
+	return do_sigaltstack(uss, uoss, current_frame()->sp);
 }
 
 /*
@@ -156,10 +156,11 @@ badframe:
  */
 asmlinkage long sys_sigreturn(void)
 {
-	struct sigframe __user *frame = (struct sigframe __user *) __frame->sp;
+	struct sigframe __user *frame;
 	sigset_t set;
 	long d0;
 
+	frame = (struct sigframe __user *) current_frame()->sp;
 	if (verify_area(VERIFY_READ, frame, sizeof(*frame)))
 		goto badframe;
 	if (__get_user(set.sig[0], &frame->sc.oldmask))
@@ -176,7 +177,7 @@ asmlinkage long sys_sigreturn(void)
 	recalc_sigpending();
 	spin_unlock_irq(&current->sighand->siglock);
 
-	if (restore_sigcontext(__frame, &frame->sc, &d0))
+	if (restore_sigcontext(current_frame(), &frame->sc, &d0))
 		goto badframe;
 
 	return d0;
@@ -191,11 +192,11 @@ badframe:
  */
 asmlinkage long sys_rt_sigreturn(void)
 {
-	struct rt_sigframe __user *frame =
-		(struct rt_sigframe __user *) __frame->sp;
+	struct rt_sigframe __user *frame;
 	sigset_t set;
-	unsigned long d0;
+	long d0;
 
+	frame = (struct rt_sigframe __user *) current_frame()->sp;
 	if (verify_area(VERIFY_READ, frame, sizeof(*frame)))
 		goto badframe;
 	if (__copy_from_user(&set, &frame->uc.uc_sigmask, sizeof(set)))
@@ -207,10 +208,11 @@ asmlinkage long sys_rt_sigreturn(void)
 	recalc_sigpending();
 	spin_unlock_irq(&current->sighand->siglock);
 
-	if (restore_sigcontext(__frame, &frame->uc.uc_mcontext, &d0))
+	if (restore_sigcontext(current_frame(), &frame->uc.uc_mcontext, &d0))
 		goto badframe;
 
-	if (do_sigaltstack(&frame->uc.uc_stack, NULL, __frame->sp) == -EFAULT)
+	if (do_sigaltstack(&frame->uc.uc_stack, NULL, current_frame()->sp) ==
+	    -EFAULT)
 		goto badframe;
 
 	return d0;
@@ -572,7 +574,7 @@ asmlinkage void do_notify_resume(struct pt_regs *regs, u32 thread_info_flags)
 
 	if (thread_info_flags & _TIF_NOTIFY_RESUME) {
 		clear_thread_flag(TIF_NOTIFY_RESUME);
-		tracehook_notify_resume(__frame);
+		tracehook_notify_resume(current_frame());
 		if (current->replacement_session_keyring)
 			key_replace_session_keyring();
 	}
arch/mn10300/kernel/switch_to.S +0 -18
index b08cb2e..9074d0f 100644
@@ -38,15 +38,6 @@ ENTRY(__switch_to)
 	mov	d1,a1
 
 	# save prev context
-#ifdef CONFIG_SMP
-	mov	(CPUID),a2
-	add	a2,a2
-	add	a2,a2
-	mov	(___frame,a2),d0
-#else  /* CONFIG_SMP */
-	mov	(__frame),d0
-#endif /* CONFIG_SMP */
-	mov	d0,(THREAD_FRAME,a0)
 	mov	__switch_back,d0
 	mov	d0,(THREAD_PC,a0)
 	mov	sp,a2
@@ -68,15 +59,6 @@ ENTRY(__switch_to)
 	mov	a2,e2
 #endif
 
-	mov	(THREAD_FRAME,a1),a2
-#ifdef CONFIG_SMP
-	mov	(CPUID),a0
-	add	a0,a0
-	add	a0,a0
-	mov	a2,(___frame,a0)
-#else  /* CONFIG_SMP */
-	mov	a2,(__frame)
-#endif /* CONFIG_SMP */
 	mov	(THREAD_PC,a1),a2
 	mov	d2,d0			# for ret_from_fork
 	mov	d0,a0			# for __switch_to
arch/mn10300/kernel/traps.c +0 -8
index c924a1d..b90c3f1 100644
@@ -45,14 +45,6 @@
 #error "INTERRUPT_VECTOR_BASE not aligned to 16MiB boundary!"
 #endif
 
-#ifdef CONFIG_SMP
-struct pt_regs *___frame[NR_CPUS]; /* current frame pointer */
-EXPORT_SYMBOL(___frame);
-#else  /* CONFIG_SMP */
-struct pt_regs *__frame; /* current frame pointer */
-EXPORT_SYMBOL(__frame);
-#endif /* CONFIG_SMP */
-
 int kstack_depth_to_print = 24;
 
 spinlock_t die_lock = __SPIN_LOCK_UNLOCKED(die_lock);
mm/maccess.c +1 -1
index 4e348db..e2b6f56 100644
@@ -1,9 +1,9 @@
 /*
  * Access kernel memory without faulting.
  */
-#include <linux/uaccess.h>
 #include <linux/module.h>
 #include <linux/mm.h>
+#include <linux/uaccess.h>
 
 /**
  * probe_kernel_read(): safely attempt to read from a location