Patchwork sparc32: fix sparcstation 5 boot

login
register
mail settings
Submitter Sam Ravnborg
Date April 21, 2011, 8:29 a.m.
Message ID <20110421082934.GA22659@merkur.ravnborg.org>
Download mbox | patch
Permalink /patch/92386/
State Accepted
Delegated to: David Miller
Headers show

Comments

Sam Ravnborg - April 21, 2011, 8:29 a.m.
From b0777dd526dbc375fa6e35fc07016af82cf71636 Mon Sep 17 00:00:00 2001
From: Sam Ravnborg <sam@ravnborg.org>
Date: Thu, 21 Apr 2011 10:25:41 +0200
Subject: [PATCH] sparc32: fix sparcstation 5 boot

The sparcstation 5 I have available has no MID property for the CPU.
This resulted in a panic when booting a SMP kernel on this box.

The assigned field in cpu_data is never used, so if we fail
to read the MID property then inform user and continue booting.

Signed-off-by: Sam Ravnborg <sam@ravnborg.org>
---
 arch/sparc/kernel/smp_32.c |   10 +++++++---
 1 files changed, 7 insertions(+), 3 deletions(-)
David Miller - April 21, 2011, 11:39 p.m.
From: Sam Ravnborg <sam@ravnborg.org>
Date: Thu, 21 Apr 2011 10:29:34 +0200

>>From b0777dd526dbc375fa6e35fc07016af82cf71636 Mon Sep 17 00:00:00 2001
> From: Sam Ravnborg <sam@ravnborg.org>
> Date: Thu, 21 Apr 2011 10:25:41 +0200
> Subject: [PATCH] sparc32: fix sparcstation 5 boot
> 
> The sparcstation 5 I have available has no MID property for the CPU.
> This resulted in a panic when booting a SMP kernel on this box.
> 
> The assigned field in cpu_data is never used, so if we fail
> to read the MID property then inform user and continue booting.
> 
> Signed-off-by: Sam Ravnborg <sam@ravnborg.org>

Thanks for fixing this.

At least the current code traps the condition, the last time this
stuff worked it was by accident, device_scan() on sparc32 used
to be something like:

void __init
device_scan(void)
{
	char node_str[128];
	int thismid;

	prom_getstring(prom_root_node, "device_type", node_str, sizeof(node_str));
 ...
		int scan;
		scan = prom_getchild(prom_root_node);
		/* One can look it up in PROM instead */
		while ((scan = prom_getsibling(scan)) != 0) {
			prom_getstring(scan, "device_type",
				       node_str, sizeof(node_str));
			if (strcmp(node_str, "cpu") == 0) {
				linux_cpus[linux_num_cpus].prom_node = scan;
				prom_getproperty(scan, "mid",
						 (char *) &thismid, sizeof(thismid));
				linux_cpus[linux_num_cpus].mid = thismid;
				printk("Found CPU %d <node=%08lx,mid=%d>\n",
				       linux_num_cpus, (unsigned long) scan, thismid);
				linux_num_cpus++;
			}
		}

No error checking or anything, which basically writes a random value
into linux_cpus[].mid when the property is not present.

I guess it would up being zero often enough. :-/

And the 'ss5' device tree dump in the prtconf repo:

	git://git.kernel.org/pub/scm/linux/kernel/git/davem/prtconfs.git

confirms no 'mid' property for the 'cpu' device tree node.

Applied and queued for -stable, thanks again!
--
To unsubscribe from this list: send the line "unsubscribe sparclinux" in
the body of a message to majordomo@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html

Patch

diff --git a/arch/sparc/kernel/smp_32.c b/arch/sparc/kernel/smp_32.c
index 91c10fb..850a136 100644
--- a/arch/sparc/kernel/smp_32.c
+++ b/arch/sparc/kernel/smp_32.c
@@ -53,6 +53,7 @@  cpumask_t smp_commenced_mask = CPU_MASK_NONE;
 void __cpuinit smp_store_cpu_info(int id)
 {
 	int cpu_node;
+	int mid;
 
 	cpu_data(id).udelay_val = loops_per_jiffy;
 
@@ -60,10 +61,13 @@  void __cpuinit smp_store_cpu_info(int id)
 	cpu_data(id).clock_tick = prom_getintdefault(cpu_node,
 						     "clock-frequency", 0);
 	cpu_data(id).prom_node = cpu_node;
-	cpu_data(id).mid = cpu_get_hwmid(cpu_node);
+	mid = cpu_get_hwmid(cpu_node);
 
-	if (cpu_data(id).mid < 0)
-		panic("No MID found for CPU%d at node 0x%08d", id, cpu_node);
+	if (mid < 0) {
+		printk(KERN_NOTICE "No MID found for CPU%d at node 0x%08d", id, cpu_node);
+		mid = 0;
+	}
+	cpu_data(id).mid = mid;
 }
 
 void __init smp_cpus_done(unsigned int max_cpus)