hc
2023-12-11 d2ccde1c8e90d38cee87a1b0309ad2827f3fd30d
kernel/arch/mips/sgi-ip27/ip27-smp.c
....@@ -15,55 +15,22 @@
1515 #include <asm/page.h>
1616 #include <asm/processor.h>
1717 #include <asm/ptrace.h>
18
+#include <asm/sn/agent.h>
1819 #include <asm/sn/arch.h>
1920 #include <asm/sn/gda.h>
2021 #include <asm/sn/intr.h>
2122 #include <asm/sn/klconfig.h>
2223 #include <asm/sn/launch.h>
2324 #include <asm/sn/mapped_kernel.h>
24
-#include <asm/sn/sn_private.h>
2525 #include <asm/sn/types.h>
26
-#include <asm/sn/sn0/hubpi.h>
27
-#include <asm/sn/sn0/hubio.h>
28
-#include <asm/sn/sn0/ip27.h>
2926
30
-/*
31
- * Takes as first input the PROM assigned cpu id, and the kernel
32
- * assigned cpu id as the second.
33
- */
34
-static void alloc_cpupda(cpuid_t cpu, int cpunum)
27
+#include "ip27-common.h"
28
+
29
+static int node_scan_cpus(nasid_t nasid, int highest)
3530 {
36
- cnodeid_t node = get_cpu_cnode(cpu);
37
- nasid_t nasid = COMPACT_TO_NASID_NODEID(node);
38
-
39
- cputonasid(cpunum) = nasid;
40
- sn_cpu_info[cpunum].p_nodeid = node;
41
- cputoslice(cpunum) = get_cpu_slice(cpu);
42
-}
43
-
44
-static nasid_t get_actual_nasid(lboard_t *brd)
45
-{
46
- klhub_t *hub;
47
-
48
- if (!brd)
49
- return INVALID_NASID;
50
-
51
- /* find out if we are a completely disabled brd. */
52
- hub = (klhub_t *)find_first_component(brd, KLSTRUCT_HUB);
53
- if (!hub)
54
- return INVALID_NASID;
55
- if (!(hub->hub_info.flags & KLINFO_ENABLE)) /* disabled node brd */
56
- return hub->hub_info.physid;
57
- else
58
- return brd->brd_nasid;
59
-}
60
-
61
-static int do_cpumask(cnodeid_t cnode, nasid_t nasid, int highest)
62
-{
63
- static int tot_cpus_found = 0;
31
+ static int cpus_found;
6432 lboard_t *brd;
6533 klcpu_t *acpu;
66
- int cpus_found = 0;
6734 cpuid_t cpuid;
6835
6936 brd = find_lboard((lboard_t *)KL_CONFIG_INFO(nasid), KLTYPE_IP27);
....@@ -72,18 +39,17 @@
7239 acpu = (klcpu_t *)find_first_component(brd, KLSTRUCT_CPU);
7340 while (acpu) {
7441 cpuid = acpu->cpu_info.virtid;
75
- /* cnode is not valid for completely disabled brds */
76
- if (get_actual_nasid(brd) == brd->brd_nasid)
77
- cpuid_to_compact_node[cpuid] = cnode;
78
- if (cpuid > highest)
79
- highest = cpuid;
8042 /* Only let it join in if it's marked enabled */
8143 if ((acpu->cpu_info.flags & KLINFO_ENABLE) &&
82
- (tot_cpus_found != NR_CPUS)) {
44
+ (cpus_found != NR_CPUS)) {
45
+ if (cpuid > highest)
46
+ highest = cpuid;
8347 set_cpu_possible(cpuid, true);
84
- alloc_cpupda(cpuid, tot_cpus_found);
48
+ cputonasid(cpus_found) = nasid;
49
+ cputoslice(cpus_found) = acpu->cpu_info.physid;
50
+ sn_cpu_info[cpus_found].p_speed =
51
+ acpu->cpu_speed;
8552 cpus_found++;
86
- tot_cpus_found++;
8753 }
8854 acpu = (klcpu_t *)find_component(brd, (klinfo_t *)acpu,
8955 KLSTRUCT_CPU);
....@@ -103,29 +69,13 @@
10369 int i, highest = 0;
10470 gda_t *gdap = GDA;
10571
106
- /*
107
- * Initialize the arrays to invalid nodeid (-1)
108
- */
109
- for (i = 0; i < MAX_COMPACT_NODES; i++)
110
- compact_to_nasid_node[i] = INVALID_NASID;
111
- for (i = 0; i < MAX_NASIDS; i++)
112
- nasid_to_compact_node[i] = INVALID_CNODEID;
113
- for (i = 0; i < MAXCPUS; i++)
114
- cpuid_to_compact_node[i] = INVALID_CNODEID;
115
-
116
- /*
117
- * MCD - this whole "compact node" stuff can probably be dropped,
118
- * as we can handle sparse numbering now
119
- */
12072 nodes_clear(node_online_map);
121
- for (i = 0; i < MAX_COMPACT_NODES; i++) {
73
+ for (i = 0; i < MAX_NUMNODES; i++) {
12274 nasid_t nasid = gdap->g_nasidtable[i];
12375 if (nasid == INVALID_NASID)
12476 break;
125
- compact_to_nasid_node[i] = nasid;
126
- nasid_to_compact_node[nasid] = i;
127
- node_set_online(num_online_nodes());
128
- highest = do_cpumask(i, nasid, highest);
77
+ node_set_online(nasid);
78
+ highest = node_scan_cpus(nasid, highest);
12979 }
13080
13181 printk("Discovered %d cpus on %d nodes\n", highest + 1, num_online_nodes());
....@@ -162,11 +112,10 @@
162112 irq += cputoslice(destid);
163113
164114 /*
165
- * Convert the compact hub number to the NASID to get the correct
166
- * part of the address space. Then set the interrupt bit associated
167
- * with the CPU we want to send the interrupt to.
115
+ * Set the interrupt bit associated with the CPU we want to
116
+ * send the interrupt to.
168117 */
169
- REMOTE_HUB_SEND_INTR(COMPACT_TO_NASID_NODEID(cpu_to_node(destid)), irq);
118
+ REMOTE_HUB_SEND_INTR(cpu_to_node(destid), irq);
170119 }
171120
172121 static void ip27_send_ipi_mask(const struct cpumask *mask, unsigned int action)
....@@ -177,15 +126,13 @@
177126 ip27_send_ipi_single(i, action);
178127 }
179128
180
-static void ip27_init_secondary(void)
129
+static void ip27_init_cpu(void)
181130 {
182131 per_cpu_init();
183132 }
184133
185134 static void ip27_smp_finish(void)
186135 {
187
- extern void hub_rt_clock_event_init(void);
188
-
189136 hub_rt_clock_event_init();
190137 local_irq_enable();
191138 }
....@@ -208,23 +155,21 @@
208155
209156 static void __init ip27_smp_setup(void)
210157 {
211
- cnodeid_t cnode;
158
+ nasid_t nasid;
212159
213
- for_each_online_node(cnode) {
214
- if (cnode == 0)
160
+ for_each_online_node(nasid) {
161
+ if (nasid == 0)
215162 continue;
216
- intr_clear_all(COMPACT_TO_NASID_NODEID(cnode));
163
+ intr_clear_all(nasid);
217164 }
218165
219166 replicate_kernel_text();
220167
221168 /*
222
- * Assumption to be fixed: we're always booted on logical / physical
223
- * processor 0. While we're always running on logical processor 0
224
- * this still means this is physical processor zero; it might for
225
- * example be disabled in the firmware.
169
+ * PROM sets up system, that boot cpu is always first CPU on nasid 0
226170 */
227
- alloc_cpupda(0, 0);
171
+ cputonasid(0) = 0;
172
+ cputoslice(0) = LOCAL_HUB_L(PI_CPU_NUM);
228173 }
229174
230175 static void __init ip27_prepare_cpus(unsigned int max_cpus)
....@@ -235,9 +180,10 @@
235180 const struct plat_smp_ops ip27_smp_ops = {
236181 .send_ipi_single = ip27_send_ipi_single,
237182 .send_ipi_mask = ip27_send_ipi_mask,
238
- .init_secondary = ip27_init_secondary,
183
+ .init_secondary = ip27_init_cpu,
239184 .smp_finish = ip27_smp_finish,
240185 .boot_secondary = ip27_boot_secondary,
241186 .smp_setup = ip27_smp_setup,
242187 .prepare_cpus = ip27_prepare_cpus,
188
+ .prepare_boot_cpu = ip27_init_cpu,
243189 };