cpumask move patch - RFC

R Sharada sharada at in.ibm.com
Tue Aug 3 23:15:27 EST 2004


Hello,
	This is part of an attempt to clean up some of the kernel data
structure initialisations from prom.c and move to later boot code.

This patch moves the cpumask data structure initialisations from
prom_hold_cpus() to setup_system().
The patch is against the 2.6.8-rc2 linus bitkeeper tree.

Kindly request review and comments on this patch.

Thanks and Regards,
Sharada
-------------- next part --------------
diff -Naur linux-2.6.8-rc2-org/arch/ppc64/kernel/chrp_setup.c linux-2.6.8-rc2-chg/arch/ppc64/kernel/chrp_setup.c
--- linux-2.6.8-rc2-org/arch/ppc64/kernel/chrp_setup.c	2004-08-03 02:12:58.000000000 -0700
+++ linux-2.6.8-rc2-chg/arch/ppc64/kernel/chrp_setup.c	2004-08-04 07:15:25.747997352 -0700
@@ -77,6 +77,8 @@
 void pSeries_calibrate_decr(void);
 void fwnmi_init(void);
 extern void SystemReset_FWNMI(void), MachineCheck_FWNMI(void);	/* from head.S */
+void cpumask_setup(void);
+
 int fwnmi_active;  /* TRUE if an FWNMI handler is present */

 dev_t boot_dev;
@@ -468,3 +470,91 @@

 	setup_default_decr();
 }
+
+void cpumask_setup()
+{
+	unsigned long ind;
+	struct device_node *np = NULL;
+	int cpuid = 0;
+	unsigned int *reg = NULL;
+	char *statusp = NULL;
+	int *propsize = NULL;
+	unsigned int cpu_threads;
+
+	printk(KERN_INFO "cpumask_setup\n");
+	/* On pmac, we just fill out the various global bitmasks and
+	* arrays indicating our CPUs are here, they are actually started
+	* later on from pmac_smp
+	*/
+	if (systemcfg->platform == PLATFORM_POWERMAC) {
+		while ((np = of_find_node_by_type(np, "cpu"))) {
+			reg = (unsigned int *)get_property(np, "reg", NULL);
+#ifdef CONFIG_SMP
+			cpu_set(cpuid, cpu_available_map);
+			cpu_set(cpuid, cpu_possible_map);
+			cpu_set(cpuid, cpu_present_at_boot);
+			if (*reg == 0)
+				cpu_set(cpuid, cpu_online_map);
+#endif /* CONFIG_SMP */
+			cpuid++;
+		}
+		of_node_put(np);
+		return;
+	}
+
+	while ((np = of_find_node_by_type(np, "cpu"))) {
+
+		statusp = (char *)get_property(np, "status", NULL);
+		if (strcmp(statusp, "okay") != 0)
+			continue;
+
+		reg = (unsigned int *)get_property(np, "reg", NULL);
+
+		propsize = (int *)get_property(np, "ibm,ppc-interrupt-server#s", NULL);
+		if (*propsize < 0) {
+			/* no property.  old hardware has no SMT */
+			cpu_threads = 1;
+		} else {
+			/* We have a threaded processor */
+			cpu_threads = *propsize / sizeof(u32);
+			if (cpu_threads > 2)
+			cpu_threads = 1; /* ToDo: panic? */
+		}
+
+#ifdef CONFIG_SMP
+		cpu_set(cpuid, cpu_available_map);
+		cpu_set(cpuid, cpu_possible_map);
+		cpu_set(cpuid, cpu_present_at_boot);
+		if (cpuid == boot_cpuid)
+		cpu_set(cpuid, cpu_online_map);
+
+		/* set the secondary threads into the cpuid mask */
+		for (ind=1; ind < cpu_threads; ind++) {
+			cpuid++;
+			if (cpuid >= NR_CPUS)
+				continue;
+			if (naca->smt_state) {
+				cpu_set(cpuid, cpu_available_map);
+				cpu_set(cpuid, cpu_present_at_boot);
+			}
+		}
+#endif
+		cpuid++;
+	}
+	of_node_put(np);
+
+#ifdef CONFIG_HMT
+	/* Only enable HMT on processors that provide support. */
+	if (__is_processor(PV_PULSAR) ||
+	 __is_processor(PV_ICESTAR) ||
+	 __is_processor(PV_SSTAR)) {
+
+		for (ind = 0; ind < NR_CPUS; ind += 2) {
+			if (!cpu_online(ind))
+				continue;
+			cpu_set(ind+1, cpu_possible_map);
+		}
+	}
+#endif
+	return;
+}
diff -Naur linux-2.6.8-rc2-org/arch/ppc64/kernel/prom.c linux-2.6.8-rc2-chg/arch/ppc64/kernel/prom.c
--- linux-2.6.8-rc2-org/arch/ppc64/kernel/prom.c	2004-08-04 06:10:30.000000000 -0700
+++ linux-2.6.8-rc2-chg/arch/ppc64/kernel/prom.c	2004-08-04 06:12:56.000000000 -0700
@@ -939,13 +939,6 @@
 			prom_getprop(node, "reg", &reg, sizeof(reg));
 			lpaca[cpuid].hw_cpu_id = reg;

-#ifdef CONFIG_SMP
-			cpu_set(cpuid, RELOC(cpu_available_map));
-			cpu_set(cpuid, RELOC(cpu_possible_map));
-			cpu_set(cpuid, RELOC(cpu_present_at_boot));
-			if (reg == 0)
-				cpu_set(cpuid, RELOC(cpu_online_map));
-#endif /* CONFIG_SMP */
 			cpuid++;
 		}
 		return;
@@ -1042,9 +1035,6 @@
 #ifdef CONFIG_SMP
 				/* Set the number of active processors. */
 				_systemcfg->processorCount++;
-				cpu_set(cpuid, RELOC(cpu_available_map));
-				cpu_set(cpuid, RELOC(cpu_possible_map));
-				cpu_set(cpuid, RELOC(cpu_present_at_boot));
 #endif
 			} else {
 				prom_printf("... failed: %x\n", *acknowledge);
@@ -1053,10 +1043,6 @@
 #ifdef CONFIG_SMP
 		else {
 			prom_printf("%x : booting  cpu %s\n", cpuid, path);
-			cpu_set(cpuid, RELOC(cpu_available_map));
-			cpu_set(cpuid, RELOC(cpu_possible_map));
-			cpu_set(cpuid, RELOC(cpu_online_map));
-			cpu_set(cpuid, RELOC(cpu_present_at_boot));
 		}
 #endif
 next:
@@ -1070,8 +1056,6 @@
 			prom_printf("%x : preparing thread ... ",
 				    interrupt_server[i]);
 			if (_naca->smt_state) {
-				cpu_set(cpuid, RELOC(cpu_available_map));
-				cpu_set(cpuid, RELOC(cpu_present_at_boot));
 				prom_printf("available\n");
 			} else {
 				prom_printf("not available\n");
@@ -1102,7 +1086,6 @@
 				}
 			}
 /* 			cpu_set(i+1, cpu_online_map); */
-			cpu_set(i+1, RELOC(cpu_possible_map));
 		}
 		_systemcfg->processorCount *= 2;
 	} else {
diff -Naur linux-2.6.8-rc2-org/arch/ppc64/kernel/setup.c linux-2.6.8-rc2-chg/arch/ppc64/kernel/setup.c
--- linux-2.6.8-rc2-org/arch/ppc64/kernel/setup.c	2004-08-03 02:12:59.000000000 -0700
+++ linux-2.6.8-rc2-chg/arch/ppc64/kernel/setup.c	2004-08-04 06:15:27.000000000 -0700
@@ -76,6 +76,7 @@
 extern void pseries_secondary_smp_init(unsigned long);
 extern int  idle_setup(void);
 extern void vpa_init(int cpu);
+extern void cpumask_setup(void);

 unsigned long decr_overclock = 1;
 unsigned long decr_overclock_proc0 = 1;
@@ -229,6 +230,7 @@
 		register_console(&udbg_console);
 		__irq_offset_value = NUM_ISA_INTERRUPTS;
 		finish_device_tree();
+		cpumask_setup();
 		chrp_init(r3, r4, r5, r6, r7);

 #ifdef CONFIG_SMP
@@ -251,6 +253,7 @@
 #ifdef CONFIG_PPC_PMAC
 	if (systemcfg->platform == PLATFORM_POWERMAC) {
 		finish_device_tree();
+		cpumask_setup();
 		pmac_init(r3, r4, r5, r6, r7);
 	}
 #endif /* CONFIG_PPC_PMAC */


More information about the Linuxppc64-dev mailing list