2005-04-17 06:20:36 +08:00
|
|
|
/*
|
|
|
|
* This file is subject to the terms and conditions of the GNU General
|
|
|
|
* Public License. See the file "COPYING" in the main directory of this
|
|
|
|
* archive for more details.
|
|
|
|
*
|
|
|
|
* Copyright (C) 2000 - 2001 by Kanoj Sarcar (kanoj@sgi.com)
|
|
|
|
* Copyright (C) 2000 - 2001 by Silicon Graphics, Inc.
|
|
|
|
*/
|
|
|
|
#include <linux/init.h>
|
|
|
|
#include <linux/sched.h>
|
2017-03-08 15:29:31 +08:00
|
|
|
#include <linux/sched/task_stack.h>
|
2017-02-06 17:01:09 +08:00
|
|
|
#include <linux/topology.h>
|
2005-04-17 06:20:36 +08:00
|
|
|
#include <linux/nodemask.h>
|
2017-03-08 15:29:31 +08:00
|
|
|
|
2005-04-17 06:20:36 +08:00
|
|
|
#include <asm/page.h>
|
|
|
|
#include <asm/processor.h>
|
2017-03-08 15:29:31 +08:00
|
|
|
#include <asm/ptrace.h>
|
2020-01-09 20:33:40 +08:00
|
|
|
#include <asm/sn/agent.h>
|
2005-04-17 06:20:36 +08:00
|
|
|
#include <asm/sn/arch.h>
|
|
|
|
#include <asm/sn/gda.h>
|
|
|
|
#include <asm/sn/intr.h>
|
|
|
|
#include <asm/sn/klconfig.h>
|
|
|
|
#include <asm/sn/launch.h>
|
|
|
|
#include <asm/sn/mapped_kernel.h>
|
|
|
|
#include <asm/sn/types.h>
|
|
|
|
|
2019-10-23 00:13:11 +08:00
|
|
|
#include "ip27-common.h"
|
|
|
|
|
2020-01-09 20:33:39 +08:00
|
|
|
static int node_scan_cpus(nasid_t nasid, int highest)
|
2005-04-17 06:20:36 +08:00
|
|
|
{
|
2020-01-09 20:33:39 +08:00
|
|
|
static int cpus_found;
|
2005-04-17 06:20:36 +08:00
|
|
|
lboard_t *brd;
|
|
|
|
klcpu_t *acpu;
|
|
|
|
cpuid_t cpuid;
|
|
|
|
|
|
|
|
brd = find_lboard((lboard_t *)KL_CONFIG_INFO(nasid), KLTYPE_IP27);
|
|
|
|
|
|
|
|
do {
|
|
|
|
acpu = (klcpu_t *)find_first_component(brd, KLSTRUCT_CPU);
|
|
|
|
while (acpu) {
|
|
|
|
cpuid = acpu->cpu_info.virtid;
|
|
|
|
/* Only let it join in if it's marked enabled */
|
|
|
|
if ((acpu->cpu_info.flags & KLINFO_ENABLE) &&
|
2020-01-09 20:33:39 +08:00
|
|
|
(cpus_found != NR_CPUS)) {
|
2019-10-03 20:27:24 +08:00
|
|
|
if (cpuid > highest)
|
|
|
|
highest = cpuid;
|
2012-03-29 13:08:30 +08:00
|
|
|
set_cpu_possible(cpuid, true);
|
2020-01-09 20:33:39 +08:00
|
|
|
cputonasid(cpus_found) = nasid;
|
|
|
|
cputoslice(cpus_found) = acpu->cpu_info.physid;
|
2020-01-09 20:33:50 +08:00
|
|
|
sn_cpu_info[cpus_found].p_speed =
|
|
|
|
acpu->cpu_speed;
|
2005-04-17 06:20:36 +08:00
|
|
|
cpus_found++;
|
|
|
|
}
|
|
|
|
acpu = (klcpu_t *)find_component(brd, (klinfo_t *)acpu,
|
|
|
|
KLSTRUCT_CPU);
|
|
|
|
}
|
|
|
|
brd = KLCF_NEXT(brd);
|
|
|
|
if (!brd)
|
|
|
|
break;
|
|
|
|
|
|
|
|
brd = find_lboard(brd, KLTYPE_IP27);
|
|
|
|
} while (brd);
|
|
|
|
|
|
|
|
return highest;
|
|
|
|
}
|
|
|
|
|
|
|
|
void cpu_node_probe(void)
|
|
|
|
{
|
|
|
|
int i, highest = 0;
|
|
|
|
gda_t *gdap = GDA;
|
|
|
|
|
|
|
|
nodes_clear(node_online_map);
|
2019-10-30 18:51:44 +08:00
|
|
|
for (i = 0; i < MAX_NUMNODES; i++) {
|
2005-04-17 06:20:36 +08:00
|
|
|
nasid_t nasid = gdap->g_nasidtable[i];
|
|
|
|
if (nasid == INVALID_NASID)
|
|
|
|
break;
|
2019-10-03 20:27:24 +08:00
|
|
|
node_set_online(nasid);
|
2020-01-09 20:33:39 +08:00
|
|
|
highest = node_scan_cpus(nasid, highest);
|
2005-04-17 06:20:36 +08:00
|
|
|
}
|
|
|
|
|
|
|
|
printk("Discovered %d cpus on %d nodes\n", highest + 1, num_online_nodes());
|
|
|
|
}
|
|
|
|
|
2005-02-14 07:10:08 +08:00
|
|
|
static __init void intr_clear_all(nasid_t nasid)
|
2005-04-17 06:20:36 +08:00
|
|
|
{
|
|
|
|
int i;
|
|
|
|
|
|
|
|
REMOTE_HUB_S(nasid, PI_INT_MASK0_A, 0);
|
|
|
|
REMOTE_HUB_S(nasid, PI_INT_MASK0_B, 0);
|
|
|
|
REMOTE_HUB_S(nasid, PI_INT_MASK1_A, 0);
|
|
|
|
REMOTE_HUB_S(nasid, PI_INT_MASK1_B, 0);
|
2005-02-14 07:10:08 +08:00
|
|
|
|
|
|
|
for (i = 0; i < 128; i++)
|
|
|
|
REMOTE_HUB_CLR_INTR(nasid, i);
|
2005-04-17 06:20:36 +08:00
|
|
|
}
|
|
|
|
|
2007-11-19 20:23:51 +08:00
|
|
|
static void ip27_send_ipi_single(int destid, unsigned int action)
|
2005-04-17 06:20:36 +08:00
|
|
|
{
|
2007-11-19 20:23:51 +08:00
|
|
|
int irq;
|
2005-04-17 06:20:36 +08:00
|
|
|
|
2007-11-19 20:23:51 +08:00
|
|
|
switch (action) {
|
|
|
|
case SMP_RESCHEDULE_YOURSELF:
|
|
|
|
irq = CPU_RESCHED_A_IRQ;
|
|
|
|
break;
|
|
|
|
case SMP_CALL_FUNCTION:
|
|
|
|
irq = CPU_CALL_A_IRQ;
|
|
|
|
break;
|
|
|
|
default:
|
|
|
|
panic("sendintr");
|
2005-02-14 02:53:26 +08:00
|
|
|
}
|
2005-04-17 06:20:36 +08:00
|
|
|
|
2007-11-19 20:23:51 +08:00
|
|
|
irq += cputoslice(destid);
|
2005-04-17 06:20:36 +08:00
|
|
|
|
|
|
|
/*
|
2019-10-03 20:27:24 +08:00
|
|
|
* Set the interrupt bit associated with the CPU we want to
|
|
|
|
* send the interrupt to.
|
2005-04-17 06:20:36 +08:00
|
|
|
*/
|
2019-10-03 20:27:24 +08:00
|
|
|
REMOTE_HUB_SEND_INTR(cpu_to_node(destid), irq);
|
2005-04-17 06:20:36 +08:00
|
|
|
}
|
|
|
|
|
2009-09-25 22:08:01 +08:00
|
|
|
static void ip27_send_ipi_mask(const struct cpumask *mask, unsigned int action)
|
2007-11-19 20:23:51 +08:00
|
|
|
{
|
|
|
|
unsigned int i;
|
|
|
|
|
2009-09-24 23:34:44 +08:00
|
|
|
for_each_cpu(i, mask)
|
2007-11-19 20:23:51 +08:00
|
|
|
ip27_send_ipi_single(i, action);
|
|
|
|
}
|
|
|
|
|
2019-02-19 23:57:19 +08:00
|
|
|
static void ip27_init_cpu(void)
|
2007-11-19 20:23:51 +08:00
|
|
|
{
|
|
|
|
per_cpu_init();
|
|
|
|
}
|
|
|
|
|
MIPS: Delete __cpuinit/__CPUINIT usage from MIPS code
commit 3747069b25e419f6b51395f48127e9812abc3596 upstream.
The __cpuinit type of throwaway sections might have made sense
some time ago when RAM was more constrained, but now the savings
do not offset the cost and complications. For example, the fix in
commit 5e427ec2d0 ("x86: Fix bit corruption at CPU resume time")
is a good example of the nasty type of bugs that can be created
with improper use of the various __init prefixes.
After a discussion on LKML[1] it was decided that cpuinit should go
the way of devinit and be phased out. Once all the users are gone,
we can then finally remove the macros themselves from linux/init.h.
Note that some harmless section mismatch warnings may result, since
notify_cpu_starting() and cpu_up() are arch independent (kernel/cpu.c)
and are flagged as __cpuinit -- so if we remove the __cpuinit from
the arch specific callers, we will also get section mismatch warnings.
As an intermediate step, we intend to turn the linux/init.h cpuinit
related content into no-ops as early as possible, since that will get
rid of these warnings. In any case, they are temporary and harmless.
Here, we remove all the MIPS __cpuinit from C code and __CPUINIT
from asm files. MIPS is interesting in this respect, because there
are also uasm users hiding behind their own renamed versions of the
__cpuinit macros.
[1] https://lkml.org/lkml/2013/5/20/589
[ralf@linux-mips.org: Folded in Paul's followup fix.]
Signed-off-by: Paul Gortmaker <paul.gortmaker@windriver.com>
Cc: linux-mips@linux-mips.org
Patchwork: https://patchwork.linux-mips.org/patch/5494/
Patchwork: https://patchwork.linux-mips.org/patch/5495/
Patchwork: https://patchwork.linux-mips.org/patch/5509/
Signed-off-by: Ralf Baechle <ralf@linux-mips.org>
2013-06-18 21:38:59 +08:00
|
|
|
static void ip27_smp_finish(void)
|
2007-11-19 20:23:51 +08:00
|
|
|
{
|
2008-04-09 05:43:57 +08:00
|
|
|
hub_rt_clock_event_init();
|
|
|
|
local_irq_enable();
|
2007-11-19 20:23:51 +08:00
|
|
|
}
|
|
|
|
|
2005-04-17 06:20:36 +08:00
|
|
|
/*
|
2013-01-22 19:59:30 +08:00
|
|
|
* Launch a slave into smp_bootstrap(). It doesn't take an argument, and we
|
2005-04-17 06:20:36 +08:00
|
|
|
* set sp to the kernel stack of the newly created idle process, gp to the proc
|
|
|
|
* struct so that current_thread_info() will work.
|
|
|
|
*/
|
2017-08-13 10:49:40 +08:00
|
|
|
static int ip27_boot_secondary(int cpu, struct task_struct *idle)
|
2005-04-17 06:20:36 +08:00
|
|
|
{
|
2006-01-12 17:06:07 +08:00
|
|
|
unsigned long gp = (unsigned long)task_thread_info(idle);
|
|
|
|
unsigned long sp = __KSTK_TOS(idle);
|
2005-04-17 06:20:36 +08:00
|
|
|
|
2007-10-12 06:46:15 +08:00
|
|
|
LAUNCH_SLAVE(cputonasid(cpu), cputoslice(cpu),
|
2005-04-17 06:20:36 +08:00
|
|
|
(launch_proc_t)MAPPED_KERN_RW_TO_K0(smp_bootstrap),
|
|
|
|
0, (void *) sp, (void *) gp);
|
2017-08-13 10:49:40 +08:00
|
|
|
return 0;
|
2005-04-17 06:20:36 +08:00
|
|
|
}
|
|
|
|
|
2007-11-19 20:23:51 +08:00
|
|
|
static void __init ip27_smp_setup(void)
|
2005-04-17 06:20:36 +08:00
|
|
|
{
|
2019-10-03 20:27:24 +08:00
|
|
|
nasid_t nasid;
|
2005-04-17 06:20:36 +08:00
|
|
|
|
2019-10-03 20:27:24 +08:00
|
|
|
for_each_online_node(nasid) {
|
|
|
|
if (nasid == 0)
|
2007-11-19 20:23:51 +08:00
|
|
|
continue;
|
2019-10-03 20:27:24 +08:00
|
|
|
intr_clear_all(nasid);
|
2005-04-17 06:20:36 +08:00
|
|
|
}
|
|
|
|
|
2007-11-19 20:23:51 +08:00
|
|
|
replicate_kernel_text();
|
2005-04-17 06:20:36 +08:00
|
|
|
|
|
|
|
/*
|
2019-10-03 20:27:24 +08:00
|
|
|
* PROM sets up system, that boot cpu is always first CPU on nasid 0
|
2005-04-17 06:20:36 +08:00
|
|
|
*/
|
2020-01-09 20:33:39 +08:00
|
|
|
cputonasid(0) = 0;
|
|
|
|
cputoslice(0) = LOCAL_HUB_L(PI_CPU_NUM);
|
2005-04-17 06:20:36 +08:00
|
|
|
}
|
2007-11-19 20:23:51 +08:00
|
|
|
|
|
|
|
static void __init ip27_prepare_cpus(unsigned int max_cpus)
|
|
|
|
{
|
|
|
|
/* We already did everything necessary earlier */
|
|
|
|
}
|
|
|
|
|
2017-07-19 16:21:03 +08:00
|
|
|
const struct plat_smp_ops ip27_smp_ops = {
|
2007-11-19 20:23:51 +08:00
|
|
|
.send_ipi_single = ip27_send_ipi_single,
|
|
|
|
.send_ipi_mask = ip27_send_ipi_mask,
|
2019-02-19 23:57:19 +08:00
|
|
|
.init_secondary = ip27_init_cpu,
|
2007-11-19 20:23:51 +08:00
|
|
|
.smp_finish = ip27_smp_finish,
|
|
|
|
.boot_secondary = ip27_boot_secondary,
|
|
|
|
.smp_setup = ip27_smp_setup,
|
|
|
|
.prepare_cpus = ip27_prepare_cpus,
|
2019-02-19 23:57:19 +08:00
|
|
|
.prepare_boot_cpu = ip27_init_cpu,
|
2007-11-19 20:23:51 +08:00
|
|
|
};
|