Orange Pi5 kernel

Deprecated Linux kernel 5.10.110 for OrangePi 5/5B/5+ boards

3 Commits   0 Branches   0 Tags
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300   1) // SPDX-License-Identifier: GPL-2.0
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300   2) /* leon_smp.c: Sparc-Leon SMP support.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300   3)  *
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300   4)  * based on sun4m_smp.c
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300   5)  * Copyright (C) 1996 David S. Miller (davem@caip.rutgers.edu)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300   6)  * Copyright (C) 2009 Daniel Hellstrom (daniel@gaisler.com) Aeroflex Gaisler AB
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300   7)  * Copyright (C) 2009 Konrad Eisele (konrad@gaisler.com) Aeroflex Gaisler AB
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300   8)  */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300   9) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  10) #include <asm/head.h>
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  11) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  12) #include <linux/kernel.h>
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  13) #include <linux/sched/mm.h>
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  14) #include <linux/threads.h>
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  15) #include <linux/smp.h>
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  16) #include <linux/interrupt.h>
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  17) #include <linux/kernel_stat.h>
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  18) #include <linux/of.h>
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  19) #include <linux/init.h>
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  20) #include <linux/spinlock.h>
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  21) #include <linux/mm.h>
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  22) #include <linux/swap.h>
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  23) #include <linux/profile.h>
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  24) #include <linux/pm.h>
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  25) #include <linux/delay.h>
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  26) #include <linux/gfp.h>
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  27) #include <linux/cpu.h>
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  28) #include <linux/clockchips.h>
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  29) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  30) #include <asm/cacheflush.h>
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  31) #include <asm/tlbflush.h>
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  32) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  33) #include <asm/ptrace.h>
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  34) #include <linux/atomic.h>
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  35) #include <asm/irq_regs.h>
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  36) #include <asm/traps.h>
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  37) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  38) #include <asm/delay.h>
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  39) #include <asm/irq.h>
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  40) #include <asm/page.h>
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  41) #include <asm/oplib.h>
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  42) #include <asm/cpudata.h>
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  43) #include <asm/asi.h>
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  44) #include <asm/leon.h>
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  45) #include <asm/leon_amba.h>
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  46) #include <asm/timer.h>
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  47) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  48) #include "kernel.h"
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  49) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  50) #include "irq.h"
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  51) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  52) extern ctxd_t *srmmu_ctx_table_phys;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  53) static int smp_processors_ready;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  54) extern volatile unsigned long cpu_callin_map[NR_CPUS];
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  55) extern cpumask_t smp_commenced_mask;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  56) void leon_configure_cache_smp(void);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  57) static void leon_ipi_init(void);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  58) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  59) /* IRQ number of LEON IPIs */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  60) int leon_ipi_irq = LEON3_IRQ_IPI_DEFAULT;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  61) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  62) static inline unsigned long do_swap(volatile unsigned long *ptr,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  63) 				    unsigned long val)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  64) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  65) 	__asm__ __volatile__("swapa [%2] %3, %0\n\t" : "=&r"(val)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  66) 			     : "0"(val), "r"(ptr), "i"(ASI_LEON_DCACHE_MISS)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  67) 			     : "memory");
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  68) 	return val;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  69) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  70) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  71) void leon_cpu_pre_starting(void *arg)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  72) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  73) 	leon_configure_cache_smp();
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  74) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  75) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  76) void leon_cpu_pre_online(void *arg)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  77) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  78) 	int cpuid = hard_smp_processor_id();
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  79) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  80) 	/* Allow master to continue. The master will then give us the
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  81) 	 * go-ahead by setting the smp_commenced_mask and will wait without
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  82) 	 * timeouts until our setup is completed fully (signified by
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  83) 	 * our bit being set in the cpu_online_mask).
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  84) 	 */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  85) 	do_swap(&cpu_callin_map[cpuid], 1);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  86) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  87) 	local_ops->cache_all();
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  88) 	local_ops->tlb_all();
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  89) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  90) 	/* Fix idle thread fields. */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  91) 	__asm__ __volatile__("ld [%0], %%g6\n\t" : : "r"(&current_set[cpuid])
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  92) 			     : "memory" /* paranoid */);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  93) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  94) 	/* Attach to the address space of init_task. */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  95) 	mmgrab(&init_mm);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  96) 	current->active_mm = &init_mm;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  97) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  98) 	while (!cpumask_test_cpu(cpuid, &smp_commenced_mask))
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  99) 		mb();
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 100) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 101) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 102) /*
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 103)  *	Cycle through the processors asking the PROM to start each one.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 104)  */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 105) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 106) extern struct linux_prom_registers smp_penguin_ctable;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 107) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 108) void leon_configure_cache_smp(void)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 109) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 110) 	unsigned long cfg = sparc_leon3_get_dcachecfg();
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 111) 	int me = smp_processor_id();
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 112) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 113) 	if (ASI_LEON3_SYSCTRL_CFG_SSIZE(cfg) > 4) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 114) 		printk(KERN_INFO "Note: SMP with snooping only works on 4k cache, found %dk(0x%x) on cpu %d, disabling caches\n",
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 115) 		     (unsigned int)ASI_LEON3_SYSCTRL_CFG_SSIZE(cfg),
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 116) 		     (unsigned int)cfg, (unsigned int)me);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 117) 		sparc_leon3_disable_cache();
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 118) 	} else {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 119) 		if (cfg & ASI_LEON3_SYSCTRL_CFG_SNOOPING) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 120) 			sparc_leon3_enable_snooping();
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 121) 		} else {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 122) 			printk(KERN_INFO "Note: You have to enable snooping in the vhdl model cpu %d, disabling caches\n",
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 123) 			     me);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 124) 			sparc_leon3_disable_cache();
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 125) 		}
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 126) 	}
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 127) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 128) 	local_ops->cache_all();
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 129) 	local_ops->tlb_all();
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 130) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 131) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 132) static void leon_smp_setbroadcast(unsigned int mask)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 133) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 134) 	int broadcast =
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 135) 	    ((LEON3_BYPASS_LOAD_PA(&(leon3_irqctrl_regs->mpstatus)) >>
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 136) 	      LEON3_IRQMPSTATUS_BROADCAST) & 1);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 137) 	if (!broadcast) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 138) 		prom_printf("######## !!!! The irqmp-ctrl must have broadcast enabled, smp wont work !!!!! ####### nr cpus: %d\n",
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 139) 		     leon_smp_nrcpus());
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 140) 		if (leon_smp_nrcpus() > 1) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 141) 			BUG();
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 142) 		} else {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 143) 			prom_printf("continue anyway\n");
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 144) 			return;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 145) 		}
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 146) 	}
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 147) 	LEON_BYPASS_STORE_PA(&(leon3_irqctrl_regs->mpbroadcast), mask);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 148) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 149) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 150) int leon_smp_nrcpus(void)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 151) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 152) 	int nrcpu =
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 153) 	    ((LEON3_BYPASS_LOAD_PA(&(leon3_irqctrl_regs->mpstatus)) >>
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 154) 	      LEON3_IRQMPSTATUS_CPUNR) & 0xf) + 1;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 155) 	return nrcpu;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 156) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 157) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 158) void __init leon_boot_cpus(void)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 159) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 160) 	int nrcpu = leon_smp_nrcpus();
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 161) 	int me = smp_processor_id();
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 162) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 163) 	/* Setup IPI */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 164) 	leon_ipi_init();
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 165) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 166) 	printk(KERN_INFO "%d:(%d:%d) cpus mpirq at 0x%x\n", (unsigned int)me,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 167) 	       (unsigned int)nrcpu, (unsigned int)NR_CPUS,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 168) 	       (unsigned int)&(leon3_irqctrl_regs->mpstatus));
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 169) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 170) 	leon_enable_irq_cpu(LEON3_IRQ_CROSS_CALL, me);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 171) 	leon_enable_irq_cpu(LEON3_IRQ_TICKER, me);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 172) 	leon_enable_irq_cpu(leon_ipi_irq, me);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 173) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 174) 	leon_smp_setbroadcast(1 << LEON3_IRQ_TICKER);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 175) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 176) 	leon_configure_cache_smp();
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 177) 	local_ops->cache_all();
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 178) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 179) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 180) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 181) int leon_boot_one_cpu(int i, struct task_struct *idle)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 182) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 183) 	int timeout;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 184) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 185) 	current_set[i] = task_thread_info(idle);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 186) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 187) 	/* See trampoline.S:leon_smp_cpu_startup for details...
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 188) 	 * Initialize the contexts table
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 189) 	 * Since the call to prom_startcpu() trashes the structure,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 190) 	 * we need to re-initialize it for each cpu
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 191) 	 */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 192) 	smp_penguin_ctable.which_io = 0;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 193) 	smp_penguin_ctable.phys_addr = (unsigned int)srmmu_ctx_table_phys;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 194) 	smp_penguin_ctable.reg_size = 0;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 195) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 196) 	/* whirrr, whirrr, whirrrrrrrrr... */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 197) 	printk(KERN_INFO "Starting CPU %d : (irqmp: 0x%x)\n", (unsigned int)i,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 198) 	       (unsigned int)&leon3_irqctrl_regs->mpstatus);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 199) 	local_ops->cache_all();
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 200) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 201) 	/* Make sure all IRQs are of from the start for this new CPU */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 202) 	LEON_BYPASS_STORE_PA(&leon3_irqctrl_regs->mask[i], 0);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 203) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 204) 	/* Wake one CPU */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 205) 	LEON_BYPASS_STORE_PA(&(leon3_irqctrl_regs->mpstatus), 1 << i);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 206) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 207) 	/* wheee... it's going... */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 208) 	for (timeout = 0; timeout < 10000; timeout++) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 209) 		if (cpu_callin_map[i])
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 210) 			break;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 211) 		udelay(200);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 212) 	}
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 213) 	printk(KERN_INFO "Started CPU %d\n", (unsigned int)i);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 214) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 215) 	if (!(cpu_callin_map[i])) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 216) 		printk(KERN_ERR "Processor %d is stuck.\n", i);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 217) 		return -ENODEV;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 218) 	} else {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 219) 		leon_enable_irq_cpu(LEON3_IRQ_CROSS_CALL, i);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 220) 		leon_enable_irq_cpu(LEON3_IRQ_TICKER, i);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 221) 		leon_enable_irq_cpu(leon_ipi_irq, i);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 222) 	}
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 223) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 224) 	local_ops->cache_all();
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 225) 	return 0;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 226) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 227) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 228) void __init leon_smp_done(void)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 229) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 230) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 231) 	int i, first;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 232) 	int *prev;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 233) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 234) 	/* setup cpu list for irq rotation */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 235) 	first = 0;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 236) 	prev = &first;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 237) 	for (i = 0; i < NR_CPUS; i++) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 238) 		if (cpu_online(i)) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 239) 			*prev = i;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 240) 			prev = &cpu_data(i).next;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 241) 		}
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 242) 	}
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 243) 	*prev = first;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 244) 	local_ops->cache_all();
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 245) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 246) 	/* Free unneeded trap tables */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 247) 	if (!cpu_present(1)) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 248) 		free_reserved_page(virt_to_page(&trapbase_cpu1));
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 249) 	}
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 250) 	if (!cpu_present(2)) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 251) 		free_reserved_page(virt_to_page(&trapbase_cpu2));
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 252) 	}
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 253) 	if (!cpu_present(3)) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 254) 		free_reserved_page(virt_to_page(&trapbase_cpu3));
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 255) 	}
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 256) 	/* Ok, they are spinning and ready to go. */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 257) 	smp_processors_ready = 1;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 258) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 259) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 260) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 261) struct leon_ipi_work {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 262) 	int single;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 263) 	int msk;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 264) 	int resched;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 265) };
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 266) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 267) static DEFINE_PER_CPU_SHARED_ALIGNED(struct leon_ipi_work, leon_ipi_work);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 268) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 269) /* Initialize IPIs on the LEON, in order to save IRQ resources only one IRQ
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 270)  * is used for all three types of IPIs.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 271)  */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 272) static void __init leon_ipi_init(void)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 273) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 274) 	int cpu, len;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 275) 	struct leon_ipi_work *work;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 276) 	struct property *pp;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 277) 	struct device_node *rootnp;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 278) 	struct tt_entry *trap_table;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 279) 	unsigned long flags;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 280) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 281) 	/* Find IPI IRQ or stick with default value */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 282) 	rootnp = of_find_node_by_path("/ambapp0");
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 283) 	if (rootnp) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 284) 		pp = of_find_property(rootnp, "ipi_num", &len);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 285) 		if (pp && (*(int *)pp->value))
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 286) 			leon_ipi_irq = *(int *)pp->value;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 287) 	}
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 288) 	printk(KERN_INFO "leon: SMP IPIs at IRQ %d\n", leon_ipi_irq);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 289) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 290) 	/* Adjust so that we jump directly to smpleon_ipi */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 291) 	local_irq_save(flags);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 292) 	trap_table = &sparc_ttable[SP_TRAP_IRQ1 + (leon_ipi_irq - 1)];
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 293) 	trap_table->inst_three += smpleon_ipi - real_irq_entry;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 294) 	local_ops->cache_all();
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 295) 	local_irq_restore(flags);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 296) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 297) 	for_each_possible_cpu(cpu) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 298) 		work = &per_cpu(leon_ipi_work, cpu);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 299) 		work->single = work->msk = work->resched = 0;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 300) 	}
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 301) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 302) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 303) static void leon_send_ipi(int cpu, int level)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 304) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 305) 	unsigned long mask;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 306) 	mask = leon_get_irqmask(level);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 307) 	LEON3_BYPASS_STORE_PA(&leon3_irqctrl_regs->force[cpu], mask);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 308) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 309) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 310) static void leon_ipi_single(int cpu)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 311) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 312) 	struct leon_ipi_work *work = &per_cpu(leon_ipi_work, cpu);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 313) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 314) 	/* Mark work */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 315) 	work->single = 1;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 316) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 317) 	/* Generate IRQ on the CPU */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 318) 	leon_send_ipi(cpu, leon_ipi_irq);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 319) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 320) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 321) static void leon_ipi_mask_one(int cpu)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 322) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 323) 	struct leon_ipi_work *work = &per_cpu(leon_ipi_work, cpu);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 324) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 325) 	/* Mark work */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 326) 	work->msk = 1;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 327) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 328) 	/* Generate IRQ on the CPU */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 329) 	leon_send_ipi(cpu, leon_ipi_irq);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 330) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 331) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 332) static void leon_ipi_resched(int cpu)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 333) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 334) 	struct leon_ipi_work *work = &per_cpu(leon_ipi_work, cpu);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 335) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 336) 	/* Mark work */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 337) 	work->resched = 1;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 338) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 339) 	/* Generate IRQ on the CPU (any IRQ will cause resched) */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 340) 	leon_send_ipi(cpu, leon_ipi_irq);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 341) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 342) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 343) void leonsmp_ipi_interrupt(void)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 344) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 345) 	struct leon_ipi_work *work = this_cpu_ptr(&leon_ipi_work);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 346) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 347) 	if (work->single) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 348) 		work->single = 0;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 349) 		smp_call_function_single_interrupt();
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 350) 	}
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 351) 	if (work->msk) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 352) 		work->msk = 0;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 353) 		smp_call_function_interrupt();
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 354) 	}
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 355) 	if (work->resched) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 356) 		work->resched = 0;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 357) 		smp_resched_interrupt();
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 358) 	}
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 359) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 360) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 361) static struct smp_funcall {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 362) 	smpfunc_t func;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 363) 	unsigned long arg1;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 364) 	unsigned long arg2;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 365) 	unsigned long arg3;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 366) 	unsigned long arg4;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 367) 	unsigned long arg5;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 368) 	unsigned long processors_in[NR_CPUS];	/* Set when ipi entered. */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 369) 	unsigned long processors_out[NR_CPUS];	/* Set when ipi exited. */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 370) } ccall_info __attribute__((aligned(8)));
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 371) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 372) static DEFINE_SPINLOCK(cross_call_lock);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 373) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 374) /* Cross calls must be serialized, at least currently. */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 375) static void leon_cross_call(smpfunc_t func, cpumask_t mask, unsigned long arg1,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 376) 			    unsigned long arg2, unsigned long arg3,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 377) 			    unsigned long arg4)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 378) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 379) 	if (smp_processors_ready) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 380) 		register int high = NR_CPUS - 1;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 381) 		unsigned long flags;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 382) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 383) 		spin_lock_irqsave(&cross_call_lock, flags);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 384) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 385) 		{
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 386) 			/* If you make changes here, make sure gcc generates proper code... */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 387) 			register smpfunc_t f asm("i0") = func;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 388) 			register unsigned long a1 asm("i1") = arg1;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 389) 			register unsigned long a2 asm("i2") = arg2;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 390) 			register unsigned long a3 asm("i3") = arg3;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 391) 			register unsigned long a4 asm("i4") = arg4;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 392) 			register unsigned long a5 asm("i5") = 0;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 393) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 394) 			__asm__ __volatile__("std %0, [%6]\n\t"
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 395) 					     "std %2, [%6 + 8]\n\t"
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 396) 					     "std %4, [%6 + 16]\n\t" : :
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 397) 					     "r"(f), "r"(a1), "r"(a2), "r"(a3),
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 398) 					     "r"(a4), "r"(a5),
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 399) 					     "r"(&ccall_info.func));
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 400) 		}
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 401) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 402) 		/* Init receive/complete mapping, plus fire the IPI's off. */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 403) 		{
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 404) 			register int i;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 405) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 406) 			cpumask_clear_cpu(smp_processor_id(), &mask);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 407) 			cpumask_and(&mask, cpu_online_mask, &mask);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 408) 			for (i = 0; i <= high; i++) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 409) 				if (cpumask_test_cpu(i, &mask)) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 410) 					ccall_info.processors_in[i] = 0;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 411) 					ccall_info.processors_out[i] = 0;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 412) 					leon_send_ipi(i, LEON3_IRQ_CROSS_CALL);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 413) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 414) 				}
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 415) 			}
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 416) 		}
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 417) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 418) 		{
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 419) 			register int i;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 420) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 421) 			i = 0;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 422) 			do {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 423) 				if (!cpumask_test_cpu(i, &mask))
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 424) 					continue;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 425) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 426) 				while (!ccall_info.processors_in[i])
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 427) 					barrier();
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 428) 			} while (++i <= high);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 429) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 430) 			i = 0;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 431) 			do {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 432) 				if (!cpumask_test_cpu(i, &mask))
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 433) 					continue;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 434) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 435) 				while (!ccall_info.processors_out[i])
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 436) 					barrier();
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 437) 			} while (++i <= high);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 438) 		}
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 439) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 440) 		spin_unlock_irqrestore(&cross_call_lock, flags);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 441) 	}
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 442) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 443) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 444) /* Running cross calls. */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 445) void leon_cross_call_irq(void)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 446) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 447) 	int i = smp_processor_id();
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 448) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 449) 	ccall_info.processors_in[i] = 1;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 450) 	ccall_info.func(ccall_info.arg1, ccall_info.arg2, ccall_info.arg3,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 451) 			ccall_info.arg4, ccall_info.arg5);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 452) 	ccall_info.processors_out[i] = 1;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 453) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 454) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 455) static const struct sparc32_ipi_ops leon_ipi_ops = {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 456) 	.cross_call = leon_cross_call,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 457) 	.resched    = leon_ipi_resched,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 458) 	.single     = leon_ipi_single,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 459) 	.mask_one   = leon_ipi_mask_one,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 460) };
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 461) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 462) void __init leon_init_smp(void)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 463) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 464) 	/* Patch ipi15 trap table */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 465) 	t_nmi[1] = t_nmi[1] + (linux_trap_ipi15_leon - linux_trap_ipi15_sun4m);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 466) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 467) 	sparc32_ipi_ops = &leon_ipi_ops;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 468) }