linuxppc-dev.lists.ozlabs.org archive mirror
 help / color / mirror / Atom feed
* powerpc_flash_init(), wtf!?
@ 2007-05-01  5:18 David Gibson
  2007-05-03  6:35 ` Vitaly Bordug
  2007-05-03 11:47 ` Sergei Shtylyov
  0 siblings, 2 replies; 30+ messages in thread
From: David Gibson @ 2007-05-01  5:18 UTC (permalink / raw)
  To: linuxppc-dev

powerpc_flash_init(), the only function in arch/powerpc/sysdev/rom.c,
goes through the device tree finding anything with device_type=="rom"
and creating of_platform devices for them, which will be picked up by
the physmap_of mtd driver.  This has two serious conceptual errors and
one bad implementation error which is quite an accomplishment for 15
lines of code.

Most seriously, this "find all roms" approach to probing is
fundamentally incompatible with the normal way of probing for
of_platform devices, to wit, using of_platform_bus_probe().  If a
flash is on a bus probed with of_platform_bus_probe()
powerpc_flash_init() will create a duplicate of_platform device for
it.  powerpc_flash_init() could also mistakenly probe roms which
appear on other random busses which should use their own probe logic
instead of going straight off the device tree (admittedly flash is
unlikely to appear on such a bus).

Also, it uses the device node's name without unit address as the
of_platform device's name.  So if a bus somewhere has two flash
devices named, say "flash@0" and "flash@800000", the device code will
give a stack dump during boot as powerpc_flash_init() attempts to
register them both under the name "flash".


I observe that none of the dts files actually present in the kernel
tree use physmap_of's format for describing flash devices (and
therefore don't use this code).  I'm therefore rather tempted to
simply blow arch/powerpc/sysdev/rom.c away, and anyone out-of-tree
relying on this code will have to fix their platform probing code to
create the flash of_platform devices properly.

Unless someone who actually knows how this code was intended to be
used can suggest a more polite way of fixing it.

-- 
David Gibson			| I'll have my music baroque, and my code
david AT gibson.dropbear.id.au	| minimalist, thank you.  NOT _the_ _other_
				| _way_ _around_!
http://www.ozlabs.org/~dgibson

^ permalink raw reply	[flat|nested] 30+ messages in thread
* Re: powerpc_flash_init(), wtf!?
@ 2007-05-23 21:57 Mark A. Greer
  2007-05-24  0:56 ` David Gibson
  0 siblings, 1 reply; 30+ messages in thread
From: Mark A. Greer @ 2007-05-23 21:57 UTC (permalink / raw)
  To: linuxppc-dev

Sorry, I've lost the thread in my inbox so I can't reply to it directly.

Is something like this what everyone agreed upon?

Mark
--

diff --git a/arch/powerpc/platforms/embedded6xx/prpmc2800.c b/arch/powerpc/platforms/embedded6xx/prpmc2800.c
index d9db135..44c3144 100644
--- a/arch/powerpc/platforms/embedded6xx/prpmc2800.c
+++ b/arch/powerpc/platforms/embedded6xx/prpmc2800.c
@@ -20,6 +20,7 @@
 #include <asm/system.h>
 #include <asm/time.h>
 #include <asm/kexec.h>
+#include <asm/of_platform.h>
 
 #include <mm/mmu_decl.h>
 
@@ -134,6 +135,18 @@ void prpmc2800_show_cpuinfo(struct seq_file *m)
 }
 
 /*
+ * Register a platform device for MTD.
+ */
+static int __init prpmc2800_register_mtd(void)
+{
+	struct device_node *np;
+
+	np = of_find_compatible_node(NULL, "rom", "direct-mapped");
+	of_platform_device_create(np, np->name, NULL);
+}
+arch_initcall(prpmc2800_register_mtd);
+
+/*
  * Called very early, device-tree isn't unflattened
  */
 static int __init prpmc2800_probe(void)

^ permalink raw reply related	[flat|nested] 30+ messages in thread

end of thread, other threads:[~2007-05-24  0:56 UTC | newest]

Thread overview: 30+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2007-05-01  5:18 powerpc_flash_init(), wtf!? David Gibson
2007-05-03  6:35 ` Vitaly Bordug
2007-05-03  7:03   ` David Gibson
2007-05-03 12:02     ` Sergei Shtylyov
2007-05-03 12:22       ` David Gibson
2007-05-03 13:28         ` Sergei Shtylyov
2007-05-03 16:21           ` Segher Boessenkool
2007-05-03 16:59             ` Sergei Shtylyov
2007-05-03 17:25               ` Segher Boessenkool
2007-05-03 21:37             ` Benjamin Herrenschmidt
2007-05-03 23:49             ` David Gibson
2007-05-03 12:29       ` Benjamin Herrenschmidt
2007-05-04  0:30         ` Vitaly Bordug
2007-05-04  1:28           ` David Gibson
2007-05-03 11:47 ` Sergei Shtylyov
2007-05-03 12:30   ` David Gibson
2007-05-03 13:04     ` Sergei Shtylyov
2007-05-03 16:20       ` Segher Boessenkool
2007-05-03 17:17         ` Sergei Shtylyov
2007-05-03 17:35           ` Segher Boessenkool
2007-05-03 18:19             ` Sergei Shtylyov
2007-05-03 21:44               ` Benjamin Herrenschmidt
2007-05-03 17:53           ` Sergei Shtylyov
2007-05-03 18:07             ` Segher Boessenkool
2007-05-03 23:56               ` David Gibson
2007-05-04 12:14                 ` Segher Boessenkool
2007-05-05 17:36                 ` Sergei Shtylyov
2007-05-05 20:19                   ` Segher Boessenkool
  -- strict thread matches above, loose matches on Subject: below --
2007-05-23 21:57 Mark A. Greer
2007-05-24  0:56 ` David Gibson

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).