| Sam Ravnborg | aba20a8 | 2011-01-28 22:08:20 +0000 | [diff] [blame] | 1 | /* | 
 | 2 |  *  sun4m SMP support. | 
| Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 3 |  * | 
 | 4 |  * Copyright (C) 1996 David S. Miller (davem@caip.rutgers.edu) | 
 | 5 |  */ | 
 | 6 |  | 
| Tkhai Kirill | 62f0828 | 2012-04-04 21:49:26 +0200 | [diff] [blame] | 7 | #include <linux/clockchips.h> | 
| Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 8 | #include <linux/interrupt.h> | 
| Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 9 | #include <linux/profile.h> | 
| Adrian Bunk | 6c81c32 | 2008-02-06 01:37:51 -0800 | [diff] [blame] | 10 | #include <linux/delay.h> | 
| David S. Miller | 5d83d66 | 2012-05-13 20:49:31 -0700 | [diff] [blame] | 11 | #include <linux/sched.h> | 
| Robert Reif | 4245e59 | 2008-10-12 20:52:26 -0700 | [diff] [blame] | 12 | #include <linux/cpu.h> | 
| Adrian Bunk | 6c81c32 | 2008-02-06 01:37:51 -0800 | [diff] [blame] | 13 |  | 
| Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 14 | #include <asm/cacheflush.h> | 
| Sam Ravnborg | bde4d8b | 2012-03-30 15:53:50 +0200 | [diff] [blame] | 15 | #include <asm/switch_to.h> | 
| Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 16 | #include <asm/tlbflush.h> | 
| Tkhai Kirill | 62f0828 | 2012-04-04 21:49:26 +0200 | [diff] [blame] | 17 | #include <asm/timer.h> | 
| David S. Miller | 5d83d66 | 2012-05-13 20:49:31 -0700 | [diff] [blame] | 18 | #include <asm/oplib.h> | 
| Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 19 |  | 
| Al Viro | 32231a6 | 2007-07-21 19:18:57 -0700 | [diff] [blame] | 20 | #include "irq.h" | 
| Sam Ravnborg | aba20a8 | 2011-01-28 22:08:20 +0000 | [diff] [blame] | 21 | #include "kernel.h" | 
| Al Viro | 32231a6 | 2007-07-21 19:18:57 -0700 | [diff] [blame] | 22 |  | 
| Daniel Hellstrom | ecbc42b | 2011-05-02 00:08:53 +0000 | [diff] [blame] | 23 | #define IRQ_IPI_SINGLE		12 | 
 | 24 | #define IRQ_IPI_MASK		13 | 
 | 25 | #define IRQ_IPI_RESCHED		14 | 
| Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 26 | #define IRQ_CROSS_CALL		15 | 
 | 27 |  | 
| Wu Fengguang | 1a8a27c | 2009-01-07 18:09:10 -0800 | [diff] [blame] | 28 | static inline unsigned long | 
 | 29 | swap_ulong(volatile unsigned long *ptr, unsigned long val) | 
| Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 30 | { | 
 | 31 | 	__asm__ __volatile__("swap [%1], %0\n\t" : | 
 | 32 | 			     "=&r" (val), "=&r" (ptr) : | 
 | 33 | 			     "0" (val), "1" (ptr)); | 
 | 34 | 	return val; | 
 | 35 | } | 
 | 36 |  | 
| Sam Ravnborg | f9fd348 | 2013-02-15 15:52:06 +0100 | [diff] [blame] | 37 | void __cpuinit sun4m_cpu_pre_starting(void *arg) | 
 | 38 | { | 
 | 39 | } | 
 | 40 |  | 
 | 41 | void __cpuinit sun4m_cpu_pre_online(void *arg) | 
| Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 42 | { | 
 | 43 | 	int cpuid = hard_smp_processor_id(); | 
 | 44 |  | 
| Sam Ravnborg | f9fd348 | 2013-02-15 15:52:06 +0100 | [diff] [blame] | 45 | 	/* Allow master to continue. The master will then give us the | 
 | 46 | 	 * go-ahead by setting the smp_commenced_mask and will wait without | 
 | 47 | 	 * timeouts until our setup is completed fully (signified by | 
 | 48 | 	 * our bit being set in the cpu_online_mask). | 
| Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 49 | 	 */ | 
| Wu Fengguang | 1a8a27c | 2009-01-07 18:09:10 -0800 | [diff] [blame] | 50 | 	swap_ulong(&cpu_callin_map[cpuid], 1); | 
| Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 51 |  | 
| Bob Breuer | a54123e | 2006-03-23 22:36:19 -0800 | [diff] [blame] | 52 | 	/* XXX: What's up with all the flushes? */ | 
| David S. Miller | 5d83d66 | 2012-05-13 20:49:31 -0700 | [diff] [blame] | 53 | 	local_ops->cache_all(); | 
 | 54 | 	local_ops->tlb_all(); | 
| Sam Ravnborg | aba20a8 | 2011-01-28 22:08:20 +0000 | [diff] [blame] | 55 |  | 
| Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 56 | 	/* Fix idle thread fields. */ | 
 | 57 | 	__asm__ __volatile__("ld [%0], %%g6\n\t" | 
 | 58 | 			     : : "r" (¤t_set[cpuid]) | 
 | 59 | 			     : "memory" /* paranoid */); | 
 | 60 |  | 
 | 61 | 	/* Attach to the address space of init_task. */ | 
 | 62 | 	atomic_inc(&init_mm.mm_count); | 
 | 63 | 	current->active_mm = &init_mm; | 
 | 64 |  | 
| KOSAKI Motohiro | fb1fece | 2011-05-16 13:38:07 -0700 | [diff] [blame] | 65 | 	while (!cpumask_test_cpu(cpuid, &smp_commenced_mask)) | 
| Bob Breuer | a54123e | 2006-03-23 22:36:19 -0800 | [diff] [blame] | 66 | 		mb(); | 
| Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 67 | } | 
 | 68 |  | 
| Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 69 | /* | 
 | 70 |  *	Cycle through the processors asking the PROM to start each one. | 
 | 71 |  */ | 
| Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 72 | void __init smp4m_boot_cpus(void) | 
 | 73 | { | 
| Tkhai Kirill | 62f0828 | 2012-04-04 21:49:26 +0200 | [diff] [blame] | 74 | 	sun4m_unmask_profile_irq(); | 
| David S. Miller | 5d83d66 | 2012-05-13 20:49:31 -0700 | [diff] [blame] | 75 | 	local_ops->cache_all(); | 
| Bob Breuer | a54123e | 2006-03-23 22:36:19 -0800 | [diff] [blame] | 76 | } | 
| Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 77 |  | 
| Thomas Gleixner | f0a2bc7 | 2012-04-20 13:05:56 +0000 | [diff] [blame] | 78 | int __cpuinit smp4m_boot_one_cpu(int i, struct task_struct *idle) | 
| Bob Breuer | a54123e | 2006-03-23 22:36:19 -0800 | [diff] [blame] | 79 | { | 
| Bob Breuer | a54123e | 2006-03-23 22:36:19 -0800 | [diff] [blame] | 80 | 	unsigned long *entry = &sun4m_cpu_startup; | 
| Bob Breuer | a54123e | 2006-03-23 22:36:19 -0800 | [diff] [blame] | 81 | 	int timeout; | 
 | 82 | 	int cpu_node; | 
| Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 83 |  | 
| Bob Breuer | a54123e | 2006-03-23 22:36:19 -0800 | [diff] [blame] | 84 | 	cpu_find_by_mid(i, &cpu_node); | 
| Thomas Gleixner | f0a2bc7 | 2012-04-20 13:05:56 +0000 | [diff] [blame] | 85 | 	current_set[i] = task_thread_info(idle); | 
| Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 86 |  | 
| Bob Breuer | a54123e | 2006-03-23 22:36:19 -0800 | [diff] [blame] | 87 | 	/* See trampoline.S for details... */ | 
| Sam Ravnborg | aba20a8 | 2011-01-28 22:08:20 +0000 | [diff] [blame] | 88 | 	entry += ((i - 1) * 3); | 
| Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 89 |  | 
| Bob Breuer | a54123e | 2006-03-23 22:36:19 -0800 | [diff] [blame] | 90 | 	/* | 
 | 91 | 	 * Initialize the contexts table | 
 | 92 | 	 * Since the call to prom_startcpu() trashes the structure, | 
 | 93 | 	 * we need to re-initialize it for each cpu | 
 | 94 | 	 */ | 
 | 95 | 	smp_penguin_ctable.which_io = 0; | 
 | 96 | 	smp_penguin_ctable.phys_addr = (unsigned int) srmmu_ctx_table_phys; | 
 | 97 | 	smp_penguin_ctable.reg_size = 0; | 
| Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 98 |  | 
| Bob Breuer | a54123e | 2006-03-23 22:36:19 -0800 | [diff] [blame] | 99 | 	/* whirrr, whirrr, whirrrrrrrrr... */ | 
| Sam Ravnborg | aba20a8 | 2011-01-28 22:08:20 +0000 | [diff] [blame] | 100 | 	printk(KERN_INFO "Starting CPU %d at %p\n", i, entry); | 
| David S. Miller | 5d83d66 | 2012-05-13 20:49:31 -0700 | [diff] [blame] | 101 | 	local_ops->cache_all(); | 
| Sam Ravnborg | aba20a8 | 2011-01-28 22:08:20 +0000 | [diff] [blame] | 102 | 	prom_startcpu(cpu_node, &smp_penguin_ctable, 0, (char *)entry); | 
| Bob Breuer | a54123e | 2006-03-23 22:36:19 -0800 | [diff] [blame] | 103 |  | 
 | 104 | 	/* wheee... it's going... */ | 
| Sam Ravnborg | aba20a8 | 2011-01-28 22:08:20 +0000 | [diff] [blame] | 105 | 	for (timeout = 0; timeout < 10000; timeout++) { | 
 | 106 | 		if (cpu_callin_map[i]) | 
| Bob Breuer | a54123e | 2006-03-23 22:36:19 -0800 | [diff] [blame] | 107 | 			break; | 
 | 108 | 		udelay(200); | 
| Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 109 | 	} | 
 | 110 |  | 
| Bob Breuer | a54123e | 2006-03-23 22:36:19 -0800 | [diff] [blame] | 111 | 	if (!(cpu_callin_map[i])) { | 
| Sam Ravnborg | aba20a8 | 2011-01-28 22:08:20 +0000 | [diff] [blame] | 112 | 		printk(KERN_ERR "Processor %d is stuck.\n", i); | 
| Bob Breuer | a54123e | 2006-03-23 22:36:19 -0800 | [diff] [blame] | 113 | 		return -ENODEV; | 
 | 114 | 	} | 
 | 115 |  | 
| David S. Miller | 5d83d66 | 2012-05-13 20:49:31 -0700 | [diff] [blame] | 116 | 	local_ops->cache_all(); | 
| Bob Breuer | a54123e | 2006-03-23 22:36:19 -0800 | [diff] [blame] | 117 | 	return 0; | 
 | 118 | } | 
 | 119 |  | 
 | 120 | void __init smp4m_smp_done(void) | 
 | 121 | { | 
 | 122 | 	int i, first; | 
 | 123 | 	int *prev; | 
 | 124 |  | 
 | 125 | 	/* setup cpu list for irq rotation */ | 
 | 126 | 	first = 0; | 
 | 127 | 	prev = &first; | 
| Rusty Russell | ec7c14b | 2009-03-16 14:40:24 +1030 | [diff] [blame] | 128 | 	for_each_online_cpu(i) { | 
 | 129 | 		*prev = i; | 
 | 130 | 		prev = &cpu_data(i).next; | 
| Bob Breuer | a54123e | 2006-03-23 22:36:19 -0800 | [diff] [blame] | 131 | 	} | 
 | 132 | 	*prev = first; | 
| David S. Miller | 5d83d66 | 2012-05-13 20:49:31 -0700 | [diff] [blame] | 133 | 	local_ops->cache_all(); | 
| Bob Breuer | a54123e | 2006-03-23 22:36:19 -0800 | [diff] [blame] | 134 |  | 
| Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 135 | 	/* Ok, they are spinning and ready to go. */ | 
| Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 136 | } | 
 | 137 |  | 
| Sam Ravnborg | 4ba22b1 | 2012-05-14 15:14:36 +0200 | [diff] [blame] | 138 | static void sun4m_send_ipi(int cpu, int level) | 
| Daniel Hellstrom | ecbc42b | 2011-05-02 00:08:53 +0000 | [diff] [blame] | 139 | { | 
| Sam Ravnborg | 4ba22b1 | 2012-05-14 15:14:36 +0200 | [diff] [blame] | 140 | 	sbus_writel(SUN4M_SOFT_INT(level), &sun4m_irq_percpu[cpu]->set); | 
| Daniel Hellstrom | ecbc42b | 2011-05-02 00:08:53 +0000 | [diff] [blame] | 141 | } | 
 | 142 |  | 
| Sam Ravnborg | 4ba22b1 | 2012-05-14 15:14:36 +0200 | [diff] [blame] | 143 | static void sun4m_ipi_resched(int cpu) | 
| Daniel Hellstrom | ecbc42b | 2011-05-02 00:08:53 +0000 | [diff] [blame] | 144 | { | 
| Sam Ravnborg | 4ba22b1 | 2012-05-14 15:14:36 +0200 | [diff] [blame] | 145 | 	sun4m_send_ipi(cpu, IRQ_IPI_RESCHED); | 
| Daniel Hellstrom | ecbc42b | 2011-05-02 00:08:53 +0000 | [diff] [blame] | 146 | } | 
 | 147 |  | 
| Sam Ravnborg | 4ba22b1 | 2012-05-14 15:14:36 +0200 | [diff] [blame] | 148 | static void sun4m_ipi_single(int cpu) | 
| Daniel Hellstrom | ecbc42b | 2011-05-02 00:08:53 +0000 | [diff] [blame] | 149 | { | 
| Sam Ravnborg | 4ba22b1 | 2012-05-14 15:14:36 +0200 | [diff] [blame] | 150 | 	sun4m_send_ipi(cpu, IRQ_IPI_SINGLE); | 
| Daniel Hellstrom | ecbc42b | 2011-05-02 00:08:53 +0000 | [diff] [blame] | 151 | } | 
 | 152 |  | 
| Sam Ravnborg | 4ba22b1 | 2012-05-14 15:14:36 +0200 | [diff] [blame] | 153 | static void sun4m_ipi_mask_one(int cpu) | 
| Daniel Hellstrom | ecbc42b | 2011-05-02 00:08:53 +0000 | [diff] [blame] | 154 | { | 
| Sam Ravnborg | 4ba22b1 | 2012-05-14 15:14:36 +0200 | [diff] [blame] | 155 | 	sun4m_send_ipi(cpu, IRQ_IPI_MASK); | 
| Daniel Hellstrom | ecbc42b | 2011-05-02 00:08:53 +0000 | [diff] [blame] | 156 | } | 
 | 157 |  | 
| Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 158 | static struct smp_funcall { | 
 | 159 | 	smpfunc_t func; | 
 | 160 | 	unsigned long arg1; | 
 | 161 | 	unsigned long arg2; | 
 | 162 | 	unsigned long arg3; | 
 | 163 | 	unsigned long arg4; | 
 | 164 | 	unsigned long arg5; | 
| Bob Breuer | a54123e | 2006-03-23 22:36:19 -0800 | [diff] [blame] | 165 | 	unsigned long processors_in[SUN4M_NCPUS];  /* Set when ipi entered. */ | 
 | 166 | 	unsigned long processors_out[SUN4M_NCPUS]; /* Set when ipi exited. */ | 
| Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 167 | } ccall_info; | 
 | 168 |  | 
 | 169 | static DEFINE_SPINLOCK(cross_call_lock); | 
 | 170 |  | 
 | 171 | /* Cross calls must be serialized, at least currently. */ | 
| Sam Ravnborg | 4ba22b1 | 2012-05-14 15:14:36 +0200 | [diff] [blame] | 172 | static void sun4m_cross_call(smpfunc_t func, cpumask_t mask, unsigned long arg1, | 
| Adrian Bunk | c61c65c | 2008-06-05 11:40:58 -0700 | [diff] [blame] | 173 | 			     unsigned long arg2, unsigned long arg3, | 
| David S. Miller | 66e4f8c | 2008-08-27 20:03:22 -0700 | [diff] [blame] | 174 | 			     unsigned long arg4) | 
| Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 175 | { | 
| Bob Breuer | a54123e | 2006-03-23 22:36:19 -0800 | [diff] [blame] | 176 | 		register int ncpus = SUN4M_NCPUS; | 
| Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 177 | 		unsigned long flags; | 
 | 178 |  | 
 | 179 | 		spin_lock_irqsave(&cross_call_lock, flags); | 
 | 180 |  | 
 | 181 | 		/* Init function glue. */ | 
 | 182 | 		ccall_info.func = func; | 
 | 183 | 		ccall_info.arg1 = arg1; | 
 | 184 | 		ccall_info.arg2 = arg2; | 
 | 185 | 		ccall_info.arg3 = arg3; | 
 | 186 | 		ccall_info.arg4 = arg4; | 
| David S. Miller | 66e4f8c | 2008-08-27 20:03:22 -0700 | [diff] [blame] | 187 | 		ccall_info.arg5 = 0; | 
| Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 188 |  | 
 | 189 | 		/* Init receive/complete mapping, plus fire the IPI's off. */ | 
 | 190 | 		{ | 
| Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 191 | 			register int i; | 
 | 192 |  | 
| KOSAKI Motohiro | fb1fece | 2011-05-16 13:38:07 -0700 | [diff] [blame] | 193 | 			cpumask_clear_cpu(smp_processor_id(), &mask); | 
 | 194 | 			cpumask_and(&mask, cpu_online_mask, &mask); | 
| Sam Ravnborg | aba20a8 | 2011-01-28 22:08:20 +0000 | [diff] [blame] | 195 | 			for (i = 0; i < ncpus; i++) { | 
| KOSAKI Motohiro | fb1fece | 2011-05-16 13:38:07 -0700 | [diff] [blame] | 196 | 				if (cpumask_test_cpu(i, &mask)) { | 
| Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 197 | 					ccall_info.processors_in[i] = 0; | 
 | 198 | 					ccall_info.processors_out[i] = 0; | 
| Sam Ravnborg | 4ba22b1 | 2012-05-14 15:14:36 +0200 | [diff] [blame] | 199 | 					sun4m_send_ipi(i, IRQ_CROSS_CALL); | 
| Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 200 | 				} else { | 
 | 201 | 					ccall_info.processors_in[i] = 1; | 
 | 202 | 					ccall_info.processors_out[i] = 1; | 
 | 203 | 				} | 
 | 204 | 			} | 
 | 205 | 		} | 
 | 206 |  | 
 | 207 | 		{ | 
 | 208 | 			register int i; | 
 | 209 |  | 
 | 210 | 			i = 0; | 
 | 211 | 			do { | 
| KOSAKI Motohiro | fb1fece | 2011-05-16 13:38:07 -0700 | [diff] [blame] | 212 | 				if (!cpumask_test_cpu(i, &mask)) | 
| David S. Miller | 66e4f8c | 2008-08-27 20:03:22 -0700 | [diff] [blame] | 213 | 					continue; | 
| Sam Ravnborg | aba20a8 | 2011-01-28 22:08:20 +0000 | [diff] [blame] | 214 | 				while (!ccall_info.processors_in[i]) | 
| Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 215 | 					barrier(); | 
| Sam Ravnborg | aba20a8 | 2011-01-28 22:08:20 +0000 | [diff] [blame] | 216 | 			} while (++i < ncpus); | 
| Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 217 |  | 
 | 218 | 			i = 0; | 
 | 219 | 			do { | 
| KOSAKI Motohiro | fb1fece | 2011-05-16 13:38:07 -0700 | [diff] [blame] | 220 | 				if (!cpumask_test_cpu(i, &mask)) | 
| David S. Miller | 66e4f8c | 2008-08-27 20:03:22 -0700 | [diff] [blame] | 221 | 					continue; | 
| Sam Ravnborg | aba20a8 | 2011-01-28 22:08:20 +0000 | [diff] [blame] | 222 | 				while (!ccall_info.processors_out[i]) | 
| Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 223 | 					barrier(); | 
| Sam Ravnborg | aba20a8 | 2011-01-28 22:08:20 +0000 | [diff] [blame] | 224 | 			} while (++i < ncpus); | 
| Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 225 | 		} | 
| Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 226 | 		spin_unlock_irqrestore(&cross_call_lock, flags); | 
| Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 227 | } | 
 | 228 |  | 
 | 229 | /* Running cross calls. */ | 
 | 230 | void smp4m_cross_call_irq(void) | 
 | 231 | { | 
 | 232 | 	int i = smp_processor_id(); | 
 | 233 |  | 
 | 234 | 	ccall_info.processors_in[i] = 1; | 
 | 235 | 	ccall_info.func(ccall_info.arg1, ccall_info.arg2, ccall_info.arg3, | 
 | 236 | 			ccall_info.arg4, ccall_info.arg5); | 
 | 237 | 	ccall_info.processors_out[i] = 1; | 
 | 238 | } | 
 | 239 |  | 
 | 240 | void smp4m_percpu_timer_interrupt(struct pt_regs *regs) | 
 | 241 | { | 
| Al Viro | 0d84438 | 2006-10-08 14:30:44 +0100 | [diff] [blame] | 242 | 	struct pt_regs *old_regs; | 
| Tkhai Kirill | 62f0828 | 2012-04-04 21:49:26 +0200 | [diff] [blame] | 243 | 	struct clock_event_device *ce; | 
| Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 244 | 	int cpu = smp_processor_id(); | 
 | 245 |  | 
| Al Viro | 0d84438 | 2006-10-08 14:30:44 +0100 | [diff] [blame] | 246 | 	old_regs = set_irq_regs(regs); | 
 | 247 |  | 
| Tkhai Kirill | 62f0828 | 2012-04-04 21:49:26 +0200 | [diff] [blame] | 248 | 	ce = &per_cpu(sparc32_clockevent, cpu); | 
| Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 249 |  | 
| Tkhai Kirill | 62f0828 | 2012-04-04 21:49:26 +0200 | [diff] [blame] | 250 | 	if (ce->mode & CLOCK_EVT_MODE_PERIODIC) | 
 | 251 | 		sun4m_clear_profile_irq(cpu); | 
 | 252 | 	else | 
| Sam Ravnborg | 08c9388 | 2012-05-14 17:30:35 +0200 | [diff] [blame] | 253 | 		sparc_config.load_profile_irq(cpu, 0); /* Is this needless? */ | 
| Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 254 |  | 
| Tkhai Kirill | 62f0828 | 2012-04-04 21:49:26 +0200 | [diff] [blame] | 255 | 	irq_enter(); | 
 | 256 | 	ce->event_handler(ce); | 
 | 257 | 	irq_exit(); | 
| Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 258 |  | 
| Al Viro | 0d84438 | 2006-10-08 14:30:44 +0100 | [diff] [blame] | 259 | 	set_irq_regs(old_regs); | 
| Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 260 | } | 
 | 261 |  | 
| Sam Ravnborg | 4ba22b1 | 2012-05-14 15:14:36 +0200 | [diff] [blame] | 262 | static const struct sparc32_ipi_ops sun4m_ipi_ops = { | 
 | 263 | 	.cross_call = sun4m_cross_call, | 
 | 264 | 	.resched    = sun4m_ipi_resched, | 
 | 265 | 	.single     = sun4m_ipi_single, | 
 | 266 | 	.mask_one   = sun4m_ipi_mask_one, | 
 | 267 | }; | 
 | 268 |  | 
| Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 269 | void __init sun4m_init_smp(void) | 
 | 270 | { | 
| Sam Ravnborg | 4ba22b1 | 2012-05-14 15:14:36 +0200 | [diff] [blame] | 271 | 	sparc32_ipi_ops = &sun4m_ipi_ops; | 
| Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 272 | } |