diff mbox

[RFC] mtd/uclinux: support ROM and allow passing the base address

Message ID 20121012072221.GB639@pengutronix.de
State RFC
Headers show

Commit Message

Uwe Kleine-König Oct. 12, 2012, 7:22 a.m. UTC
Hello,

On Fri, Oct 12, 2012 at 03:57:59PM +1000, Greg Ungerer wrote:
> >so to be clear, Uwe's patch hasn't been picked up by anyone yet so we
> >can get it fixed first ?
ok, so for blackfin uclinux_ram_map must not be static because it is
used in arch/blackfin/kernel/setup.c. If I tried to introduce such code
for an ARM platform people would run away scared maybe after telling me
I should fix my boot loader.  I really don't know the situation on
blackfin, but this really has potential for generalisation. But I don't
even know if you have/need a boot loader at all there. Here is what I
found quickly:


If you had a boot loader, my patch (making the location of the uclinux
map settable by a kernel parameter) should be a move in the right
direction for you, too.

I will fix my patch keeping uclinux_ram_map non-static and resend.

Best regards
Uwe

Comments

Mike Frysinger Oct. 12, 2012, 4:09 p.m. UTC | #1
On Fri, Oct 12, 2012 at 3:22 AM, Uwe Kleine-König wrote:
> On Fri, Oct 12, 2012 at 03:57:59PM +1000, Greg Ungerer wrote:
>> >so to be clear, Uwe's patch hasn't been picked up by anyone yet so we
>> >can get it fixed first ?
>
> ok, so for blackfin uclinux_ram_map must not be static because it is
> used in arch/blackfin/kernel/setup.c. If I tried to introduce such code
> for an ARM platform people would run away scared maybe after telling me
> I should fix my boot loader.

i would point out that code merged many many years ago had a much
lower bar than today.  also, this isn't the boot loader passing the
rootfs into the kernel.  when the kernel is created, the build system
appends the rootfs to it.

> I really don't know the situation on
> blackfin, but this really has potential for generalisation.

sure ... we're open to doing it differently as long as it's backwards compatible

> But I don't even know if you have/need a boot loader at all there.

we run u-boot like everyone else, but u-boot doesn't handle passing
the rootfs in.

> Here is what I found quickly:

updated comments here look nice, thanks
-mike
Mike Frysinger Oct. 12, 2012, 4:22 p.m. UTC | #2
On Fri, Oct 12, 2012 at 12:09 PM, Mike Frysinger wrote:
> On Fri, Oct 12, 2012 at 3:22 AM, Uwe Kleine-König wrote:
>> I really don't know the situation on
>> blackfin, but this really has potential for generalisation.
>
> sure ... we're open to doing it differently as long as it's backwards compatible

thinking a bit more, i think the answer here is:
 - move all the mtd_size checks out of Blackfin's memory_setup() into
the uclinux mtd map's uclinux_mtd_init() logic
 - rename your new physaddr to "uclinux_ram_map_physaddr", drop the
"static", and add a comment that this needs to stay externally visible
 - change Blackfin's memory_setup() logic to set
"uclinux_ram_map_physaddr" rather than "uclinux_ram_map"
-mike
diff mbox

Patch

diff --git a/arch/blackfin/kernel/setup.c b/arch/blackfin/kernel/setup.c
index fb96e60..24478a2 100644
--- a/arch/blackfin/kernel/setup.c
+++ b/arch/blackfin/kernel/setup.c
@@ -583,7 +583,7 @@  static __init void memory_setup(void)
 
 #ifdef CONFIG_MPU
 	/* Round up to multiple of 4MB */
-	memory_start = (_ramstart + 0x3fffff) & ~0x3fffff;
+	memory_start = ALIGN(_ramstart, 0x400000);
 #else
 	memory_start = PAGE_ALIGN(_ramstart);
 #endif
@@ -593,6 +593,13 @@  static __init void memory_setup(void)
 	memory_mtd_end = memory_end;
 
 	mtd_phys = _ramstart;
+
+	/*
+	 * Since the default MTD_UCLINUX has no magic number, we just blindly
+	 * read 8 past the end of the kernel's image, and look at it.
+	 * When no image is attached, mtd_size is set to a random number.
+	 * So do some basic sanity checks before operating on things.
+	 */
 	mtd_size = PAGE_ALIGN(*((unsigned long *)(mtd_phys + 8)));
 
 # if defined(CONFIG_EXT2_FS) || defined(CONFIG_EXT3_FS)
@@ -621,11 +628,6 @@  static __init void memory_setup(void)
 	}
 # endif				/* CONFIG_ROMFS_FS */
 
-	/* Since the default MTD_UCLINUX has no magic number, we just blindly
-	 * read 8 past the end of the kernel's image, and look at it.
-	 * When no image is attached, mtd_size is set to a random number
-	 * Do some basic sanity checks before operating on things
-	 */
 	if (mtd_size == 0 || memory_end <= mtd_size) {
 		pr_emerg("Could not find valid ram mtd attached.\n");
 	} else {