Donate to e Foundation | Murena handsets with /e/OS | Own a part of Murena! Learn more

Commit 10348f59 authored by Benjamin Herrenschmidt's avatar Benjamin Herrenschmidt
Browse files

powerpc: Check return value of instance-to-package OF call



On PA-Semi firmware, the instance-to-package callback doesn't seem
to be implemented. We didn't check for error, however, thus
subsequently passed the -1 value returned into stdout_node to
thins like prom_getprop etc...

Thus caused the firmware to load values around 0 (physical) internally
as node structures. It somewhat "worked" as long as we had a NULL in the
right place (address 8) at the beginning of the kernel, we didn't "see"
the bug. But commit 5c0484e2
"powerpc: Endian safe trampoline" changed the kernel entry point causing
that old bug to now cause a crash early during boot.

This fixes booting on PA-Semi board by properly checking the return
value from instance-to-package.

Signed-off-by: default avatarBenjamin Herrenschmidt <benh@kernel.crashing.org>
Tested-by: default avatarOlof Johansson <olof@lixom.net>
---
parent f991db1c
Loading
Loading
Loading
Loading
+13 −9
Original line number Original line Diff line number Diff line
@@ -1986,13 +1986,16 @@ static void __init prom_init_stdout(void)
	/* Get the full OF pathname of the stdout device */
	/* Get the full OF pathname of the stdout device */
	memset(path, 0, 256);
	memset(path, 0, 256);
	call_prom("instance-to-path", 3, 1, prom.stdout, path, 255);
	call_prom("instance-to-path", 3, 1, prom.stdout, path, 255);
	prom_printf("OF stdout device is: %s\n", of_stdout_device);
	prom_setprop(prom.chosen, "/chosen", "linux,stdout-path",
		     path, strlen(path) + 1);

	/* instance-to-package fails on PA-Semi */
	stdout_node = call_prom("instance-to-package", 1, 1, prom.stdout);
	stdout_node = call_prom("instance-to-package", 1, 1, prom.stdout);
	if (stdout_node != PROM_ERROR) {
		val = cpu_to_be32(stdout_node);
		val = cpu_to_be32(stdout_node);
		prom_setprop(prom.chosen, "/chosen", "linux,stdout-package",
		prom_setprop(prom.chosen, "/chosen", "linux,stdout-package",
			     &val, sizeof(val));
			     &val, sizeof(val));
	prom_printf("OF stdout device is: %s\n", of_stdout_device);
	prom_setprop(prom.chosen, "/chosen", "linux,stdout-path",
		     path, strlen(path) + 1);


		/* If it's a display, note it */
		/* If it's a display, note it */
		memset(type, 0, sizeof(type));
		memset(type, 0, sizeof(type));
@@ -2000,6 +2003,7 @@ static void __init prom_init_stdout(void)
		if (strcmp(type, "display") == 0)
		if (strcmp(type, "display") == 0)
			prom_setprop(stdout_node, path, "linux,boot-display", NULL, 0);
			prom_setprop(stdout_node, path, "linux,boot-display", NULL, 0);
	}
	}
}


static int __init prom_find_machine_type(void)
static int __init prom_find_machine_type(void)
{
{