···601601 select SYS_SUPPORTS_64BIT_KERNEL602602 select SYS_SUPPORTS_BIG_ENDIAN603603 select SYS_SUPPORTS_HIGHMEM604604+ select SYS_SUPPORTS_HOTPLUG_CPU604605 select SYS_HAS_CPU_CAVIUM_OCTEON605606 help606607 The Octeon simulator is software performance model of the Cavium···616615 select SYS_SUPPORTS_64BIT_KERNEL617616 select SYS_SUPPORTS_BIG_ENDIAN618617 select SYS_SUPPORTS_HIGHMEM618618+ select SYS_SUPPORTS_HOTPLUG_CPU619619 select SYS_HAS_EARLY_PRINTK620620 select SYS_HAS_CPU_CAVIUM_OCTEON621621 select SWAP_IO_SPACE
+59
arch/mips/cavium-octeon/octeon-irq.c
···501501 }502502 }503503}504504+505505+#ifdef CONFIG_HOTPLUG_CPU506506+static int is_irq_enabled_on_cpu(unsigned int irq, unsigned int cpu)507507+{508508+ unsigned int isset;509509+#ifdef CONFIG_SMP510510+ int coreid = cpu_logical_map(cpu);511511+#else512512+ int coreid = cvmx_get_core_num();513513+#endif514514+ int bit = (irq < OCTEON_IRQ_WDOG0) ?515515+ irq - OCTEON_IRQ_WORKQ0 : irq - OCTEON_IRQ_WDOG0;516516+ if (irq < 64) {517517+ isset = (cvmx_read_csr(CVMX_CIU_INTX_EN0(coreid * 2)) &518518+ (1ull << bit)) >> bit;519519+ } else {520520+ isset = (cvmx_read_csr(CVMX_CIU_INTX_EN1(coreid * 2 + 1)) &521521+ (1ull << bit)) >> bit;522522+ }523523+ return isset;524524+}525525+526526+void fixup_irqs(void)527527+{528528+ int irq;529529+530530+ for (irq = OCTEON_IRQ_SW0; irq <= OCTEON_IRQ_TIMER; irq++)531531+ octeon_irq_core_disable_local(irq);532532+533533+ for (irq = OCTEON_IRQ_WORKQ0; irq <= OCTEON_IRQ_GPIO15; irq++) {534534+ if (is_irq_enabled_on_cpu(irq, smp_processor_id())) {535535+ /* ciu irq migrates to next cpu */536536+ octeon_irq_chip_ciu0.disable(irq);537537+ octeon_irq_ciu0_set_affinity(irq, &cpu_online_map);538538+ }539539+ }540540+541541+#if 0542542+ for (irq = OCTEON_IRQ_MBOX0; irq <= OCTEON_IRQ_MBOX1; irq++)543543+ octeon_irq_mailbox_mask(irq);544544+#endif545545+ for (irq = OCTEON_IRQ_UART0; irq <= OCTEON_IRQ_BOOTDMA; irq++) {546546+ if (is_irq_enabled_on_cpu(irq, smp_processor_id())) {547547+ /* ciu irq migrates to next cpu */548548+ octeon_irq_chip_ciu0.disable(irq);549549+ octeon_irq_ciu0_set_affinity(irq, &cpu_online_map);550550+ }551551+ }552552+553553+ for (irq = OCTEON_IRQ_UART2; irq <= OCTEON_IRQ_RESERVED135; irq++) {554554+ if (is_irq_enabled_on_cpu(irq, smp_processor_id())) {555555+ /* ciu irq migrates to next cpu */556556+ octeon_irq_chip_ciu1.disable(irq);557557+ octeon_irq_ciu1_set_affinity(irq, &cpu_online_map);558558+ }559559+ }560560+}561561+562562+#endif /* CONFIG_HOTPLUG_CPU */
+70
arch/mips/cavium-octeon/octeon_boot.h
···11+/*22+ * (C) Copyright 2004, 2005 Cavium Networks33+ *44+ * This program is free software; you can redistribute it and/or55+ * modify it under the terms of the GNU General Public License as66+ * published by the Free Software Foundation; either version 2 of77+ * the License, or (at your option) any later version.88+ *99+ * This program is distributed in the hope that it will be useful,1010+ * but WITHOUT ANY WARRANTY; without even the implied warranty of1111+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the1212+ * GNU General Public License for more details.1313+ *1414+ * You should have received a copy of the GNU General Public License1515+ * along with this program; if not, write to the Free Software1616+ * Foundation, Inc., 59 Temple Place, Suite 330, Boston,1717+ * MA 02111-1307 USA1818+ */1919+2020+#ifndef __OCTEON_BOOT_H__2121+#define __OCTEON_BOOT_H__2222+2323+#include <linux/types.h>2424+2525+struct boot_init_vector {2626+ uint32_t stack_addr;2727+ uint32_t code_addr;2828+ uint32_t app_start_func_addr;2929+ uint32_t k0_val;3030+ uint32_t flags;3131+ uint32_t boot_info_addr;3232+ uint32_t pad;3333+ uint32_t pad2;3434+};3535+3636+/* similar to bootloader's linux_app_boot_info but without global data */3737+struct linux_app_boot_info {3838+ uint32_t labi_signature;3939+ uint32_t start_core0_addr;4040+ uint32_t avail_coremask;4141+ uint32_t pci_console_active;4242+ uint32_t icache_prefetch_disable;4343+ uint32_t InitTLBStart_addr;4444+ uint32_t start_app_addr;4545+ uint32_t cur_exception_base;4646+ uint32_t no_mark_private_data;4747+ uint32_t compact_flash_common_base_addr;4848+ uint32_t compact_flash_attribute_base_addr;4949+ uint32_t led_display_base_addr;5050+};5151+5252+/* If not to copy a lot of bootloader's structures5353+ here is only offset of requested member */5454+#define AVAIL_COREMASK_OFFSET_IN_LINUX_APP_BOOT_BLOCK 0x765c5555+5656+/* hardcoded in bootloader */5757+#define LABI_ADDR_IN_BOOTLOADER 0x7005858+5959+#define LINUX_APP_BOOT_BLOCK_NAME "linux-app-boot"6060+6161+#define LABI_SIGNATURE 0xAABBCCDD6262+6363+/* from uboot-headers/octeon_mem_map.h */6464+#define EXCEPTION_BASE_INCR (4 * 1024)6565+ /* Increment size for exception base addresses (4k minimum) */6666+#define EXCEPTION_BASE_BASE 06767+#define BOOTLOADER_PRIV_DATA_BASE (EXCEPTION_BASE_BASE + 0x800)6868+#define BOOTLOADER_BOOT_VECTOR (BOOTLOADER_PRIV_DATA_BASE)6969+7070+#endif /* __OCTEON_BOOT_H__ */
+233-1
arch/mips/cavium-octeon/smp.c
···55 *66 * Copyright (C) 2004-2008 Cavium Networks77 */88+#include <linux/cpu.h>89#include <linux/init.h>910#include <linux/delay.h>1011#include <linux/smp.h>···20192120#include <asm/octeon/octeon.h>22212222+#include "octeon_boot.h"2323+2324volatile unsigned long octeon_processor_boot = 0xff;2425volatile unsigned long octeon_processor_sp;2526volatile unsigned long octeon_processor_gp;2727+2828+#ifdef CONFIG_HOTPLUG_CPU2929+static unsigned int InitTLBStart_addr;3030+#endif26312732static irqreturn_t mailbox_interrupt(int irq, void *dev_id)2833{···7467}75687669/**7777- * Detect available CPUs, populate phys_cpu_present_map7070+ * Detect available CPUs, populate cpu_possible_map7871 */7272+static void octeon_smp_hotplug_setup(void)7373+{7474+#ifdef CONFIG_HOTPLUG_CPU7575+ uint32_t labi_signature;7676+7777+ labi_signature =7878+ cvmx_read64_uint32(CVMX_ADD_SEG(CVMX_MIPS_SPACE_XKPHYS,7979+ LABI_ADDR_IN_BOOTLOADER +8080+ offsetof(struct linux_app_boot_info,8181+ labi_signature)));8282+ if (labi_signature != LABI_SIGNATURE)8383+ pr_err("The bootloader version on this board is incorrect\n");8484+ InitTLBStart_addr =8585+ cvmx_read64_uint32(CVMX_ADD_SEG(CVMX_MIPS_SPACE_XKPHYS,8686+ LABI_ADDR_IN_BOOTLOADER +8787+ offsetof(struct linux_app_boot_info,8888+ InitTLBStart_addr)));8989+#endif9090+}9191+7992static void octeon_smp_setup(void)8093{8194 const int coreid = cvmx_get_core_num();···11891 cpus++;11992 }12093 }9494+ cpu_present_map = cpu_possible_map;9595+9696+ octeon_smp_hotplug_setup();12197}1229812399/**···158128 const int coreid = cvmx_get_core_num();159129 union cvmx_ciu_intx_sum0 interrupt_enable;160130131131+#ifdef CONFIG_HOTPLUG_CPU132132+ unsigned int cur_exception_base;133133+134134+ cur_exception_base = cvmx_read64_uint32(135135+ CVMX_ADD_SEG(CVMX_MIPS_SPACE_XKPHYS,136136+ LABI_ADDR_IN_BOOTLOADER +137137+ offsetof(struct linux_app_boot_info,138138+ cur_exception_base)));139139+ /* cur_exception_base is incremented in bootloader after setting */140140+ write_c0_ebase((unsigned int)(cur_exception_base - EXCEPTION_BASE_INCR));141141+#endif161142 octeon_check_cpu_bist();162143 octeon_init_cvmcount();163144 /*···240199#endif241200}242201202202+#ifdef CONFIG_HOTPLUG_CPU203203+204204+/* State of each CPU. */205205+DEFINE_PER_CPU(int, cpu_state);206206+207207+extern void fixup_irqs(void);208208+209209+static DEFINE_SPINLOCK(smp_reserve_lock);210210+211211+static int octeon_cpu_disable(void)212212+{213213+ unsigned int cpu = smp_processor_id();214214+215215+ if (cpu == 0)216216+ return -EBUSY;217217+218218+ spin_lock(&smp_reserve_lock);219219+220220+ cpu_clear(cpu, cpu_online_map);221221+ cpu_clear(cpu, cpu_callin_map);222222+ local_irq_disable();223223+ fixup_irqs();224224+ local_irq_enable();225225+226226+ flush_cache_all();227227+ local_flush_tlb_all();228228+229229+ spin_unlock(&smp_reserve_lock);230230+231231+ return 0;232232+}233233+234234+static void octeon_cpu_die(unsigned int cpu)235235+{236236+ int coreid = cpu_logical_map(cpu);237237+ uint32_t avail_coremask;238238+ struct cvmx_bootmem_named_block_desc *block_desc;239239+240240+#ifdef CONFIG_CAVIUM_OCTEON_WATCHDOG241241+ /* Disable the watchdog */242242+ cvmx_ciu_wdogx_t ciu_wdog;243243+ ciu_wdog.u64 = cvmx_read_csr(CVMX_CIU_WDOGX(cpu));244244+ ciu_wdog.s.mode = 0;245245+ cvmx_write_csr(CVMX_CIU_WDOGX(cpu), ciu_wdog.u64);246246+#endif247247+248248+ while (per_cpu(cpu_state, cpu) != CPU_DEAD)249249+ cpu_relax();250250+251251+ /*252252+ * This is a bit complicated strategics of getting/settig available253253+ * cores mask, copied from bootloader254254+ */255255+ /* LINUX_APP_BOOT_BLOCK is initialized in bootoct binary */256256+ block_desc = cvmx_bootmem_find_named_block(LINUX_APP_BOOT_BLOCK_NAME);257257+258258+ if (!block_desc) {259259+ avail_coremask =260260+ cvmx_read64_uint32(CVMX_ADD_SEG(CVMX_MIPS_SPACE_XKPHYS,261261+ LABI_ADDR_IN_BOOTLOADER +262262+ offsetof263263+ (struct linux_app_boot_info,264264+ avail_coremask)));265265+ } else { /* alternative, already initialized */266266+ avail_coremask =267267+ cvmx_read64_uint32(CVMX_ADD_SEG(CVMX_MIPS_SPACE_XKPHYS,268268+ block_desc->base_addr +269269+ AVAIL_COREMASK_OFFSET_IN_LINUX_APP_BOOT_BLOCK));270270+ }271271+272272+ avail_coremask |= 1 << coreid;273273+274274+ /* Setting avail_coremask for bootoct binary */275275+ if (!block_desc) {276276+ cvmx_write64_uint32(CVMX_ADD_SEG(CVMX_MIPS_SPACE_XKPHYS,277277+ LABI_ADDR_IN_BOOTLOADER +278278+ offsetof(struct linux_app_boot_info,279279+ avail_coremask)),280280+ avail_coremask);281281+ } else {282282+ cvmx_write64_uint32(CVMX_ADD_SEG(CVMX_MIPS_SPACE_XKPHYS,283283+ block_desc->base_addr +284284+ AVAIL_COREMASK_OFFSET_IN_LINUX_APP_BOOT_BLOCK),285285+ avail_coremask);286286+ }287287+288288+ pr_info("Reset core %d. Available Coremask = %x \n", coreid,289289+ avail_coremask);290290+ cvmx_write_csr(CVMX_CIU_PP_RST, 1 << coreid);291291+ cvmx_write_csr(CVMX_CIU_PP_RST, 0);292292+}293293+294294+void play_dead(void)295295+{296296+ int coreid = cvmx_get_core_num();297297+298298+ idle_task_exit();299299+ octeon_processor_boot = 0xff;300300+ per_cpu(cpu_state, coreid) = CPU_DEAD;301301+302302+ while (1) /* core will be reset here */303303+ ;304304+}305305+306306+extern void kernel_entry(unsigned long arg1, ...);307307+308308+static void start_after_reset(void)309309+{310310+ kernel_entry(0, 0, 0); /* set a2 = 0 for secondary core */311311+}312312+313313+int octeon_update_boot_vector(unsigned int cpu)314314+{315315+316316+ int coreid = cpu_logical_map(cpu);317317+ unsigned int avail_coremask;318318+ struct cvmx_bootmem_named_block_desc *block_desc;319319+ struct boot_init_vector *boot_vect =320320+ (struct boot_init_vector *) cvmx_phys_to_ptr(0x0 +321321+ BOOTLOADER_BOOT_VECTOR);322322+323323+ block_desc = cvmx_bootmem_find_named_block(LINUX_APP_BOOT_BLOCK_NAME);324324+325325+ if (!block_desc) {326326+ avail_coremask =327327+ cvmx_read64_uint32(CVMX_ADD_SEG(CVMX_MIPS_SPACE_XKPHYS,328328+ LABI_ADDR_IN_BOOTLOADER +329329+ offsetof(struct linux_app_boot_info,330330+ avail_coremask)));331331+ } else { /* alternative, already initialized */332332+ avail_coremask =333333+ cvmx_read64_uint32(CVMX_ADD_SEG(CVMX_MIPS_SPACE_XKPHYS,334334+ block_desc->base_addr +335335+ AVAIL_COREMASK_OFFSET_IN_LINUX_APP_BOOT_BLOCK));336336+ }337337+338338+ if (!(avail_coremask & (1 << coreid))) {339339+ /* core not available, assume, that catched by simple-executive */340340+ cvmx_write_csr(CVMX_CIU_PP_RST, 1 << coreid);341341+ cvmx_write_csr(CVMX_CIU_PP_RST, 0);342342+ }343343+344344+ boot_vect[coreid].app_start_func_addr =345345+ (uint32_t) (unsigned long) start_after_reset;346346+ boot_vect[coreid].code_addr = InitTLBStart_addr;347347+348348+ CVMX_SYNC;349349+350350+ cvmx_write_csr(CVMX_CIU_NMI, (1 << coreid) & avail_coremask);351351+352352+ return 0;353353+}354354+355355+static int __cpuinit octeon_cpu_callback(struct notifier_block *nfb,356356+ unsigned long action, void *hcpu)357357+{358358+ unsigned int cpu = (unsigned long)hcpu;359359+360360+ switch (action) {361361+ case CPU_UP_PREPARE:362362+ octeon_update_boot_vector(cpu);363363+ break;364364+ case CPU_ONLINE:365365+ pr_info("Cpu %d online\n", cpu);366366+ break;367367+ case CPU_DEAD:368368+ break;369369+ }370370+371371+ return NOTIFY_OK;372372+}373373+374374+static struct notifier_block __cpuinitdata octeon_cpu_notifier = {375375+ .notifier_call = octeon_cpu_callback,376376+};377377+378378+static int __cpuinit register_cavium_notifier(void)379379+{380380+ register_hotcpu_notifier(&octeon_cpu_notifier);381381+382382+ return 0;383383+}384384+385385+late_initcall(register_cavium_notifier);386386+387387+#endif /* CONFIG_HOTPLUG_CPU */388388+243389struct plat_smp_ops octeon_smp_ops = {244390 .send_ipi_single = octeon_send_ipi_single,245391 .send_ipi_mask = octeon_send_ipi_mask,···436208 .boot_secondary = octeon_boot_secondary,437209 .smp_setup = octeon_smp_setup,438210 .prepare_cpus = octeon_prepare_cpus,211211+#ifdef CONFIG_HOTPLUG_CPU212212+ .cpu_disable = octeon_cpu_disable,213213+ .cpu_die = octeon_cpu_die,214214+#endif439215};
+1-1
arch/mips/include/asm/smp.h
···4141/* Octeon - Tell another core to flush its icache */4242#define SMP_ICACHE_FLUSH 0x443434444-extern cpumask_t cpu_callin_map;4444+extern volatile cpumask_t cpu_callin_map;45454646extern void asmlinkage smp_bootstrap(void);4747