diff --git a/arch/arm/boards/freescale-mx53-qsb/board.c b/arch/arm/boards/freescale-mx53-qsb/board.c index 38d1ee6..0209e07 100644 --- a/arch/arm/boards/freescale-mx53-qsb/board.c +++ b/arch/arm/boards/freescale-mx53-qsb/board.c @@ -84,7 +84,8 @@ struct mc13xxx *mc34708; int rev; - if (!of_machine_is_compatible("fsl,imx53-qsb")) + if (!of_machine_is_compatible("fsl,imx53-qsb") && + !of_machine_is_compatible("fsl,imx53-qsrb")) return 0; device_detect_by_name("mmc0"); @@ -171,7 +172,8 @@ static int loco_postcore_init(void) { - if (!of_machine_is_compatible("fsl,imx53-qsb")) + if (!of_machine_is_compatible("fsl,imx53-qsb") && + !of_machine_is_compatible("fsl,imx53-qsrb")) return 0; imx53_init_lowlevel(1000); diff --git a/arch/arm/lib/bootm.c b/arch/arm/lib/bootm.c index c63cbc0..1d487b9 100644 --- a/arch/arm/lib/bootm.c +++ b/arch/arm/lib/bootm.c @@ -127,7 +127,13 @@ load_address = data->os_address; if (load_address == UIMAGE_INVALID_ADDRESS) { - load_address = mem_start + SZ_32K; + /* + * Just use a conservative default of 4 times the size of the + * compressed image, to avoid the need for the kernel to + * relocate itself before decompression. + */ + load_address = mem_start + PAGE_ALIGN( + uimage_get_size(data->os, data->os_num) * 4); if (bootm_verbose(data)) printf("no os load address, defaulting to 0x%08lx\n", load_address); @@ -138,13 +144,10 @@ return ret; /* - * Put devicetree/initrd at maximum to 128MiB into RAM to not - * risk to put it outside of lowmem. + * put oftree/initrd close behind compressed kernel image to avoid + * placing it outside of the kernels lowmem. */ - if (mem_size > SZ_256M) - mem_free = mem_start + SZ_128M; - else - mem_free = PAGE_ALIGN(data->os_res->end + SZ_1M); + mem_free = PAGE_ALIGN(data->os_res->end + SZ_1M); return __do_bootm_linux(data, mem_free, 0); } @@ -237,7 +240,8 @@ int fd, ret, swap = 0; struct zimage_header __header, *header; void *zimage; - u32 end; + u32 end, start; + size_t image_size; unsigned long load_address = data->os_address; unsigned long mem_start, mem_size, mem_free; @@ -245,23 +249,6 @@ if (ret) return ret; - if (load_address == UIMAGE_INVALID_ADDRESS) { - /* - * The kernel should stay in the first 128MiB of RAM, recommended - * is 32MiB into RAM so that relocation prior to decompression - * can be avoided. - */ - if (mem_size > SZ_64M) - data->os_address = mem_start + SZ_32M; - else - data->os_address = mem_start + SZ_8M; - - load_address = data->os_address; - if (bootm_verbose(data)) - printf("no os load address, defaulting to 0x%08lx\n", - load_address); - } - fd = open(data->os_file, O_RDONLY); if (fd < 0) { perror("open"); @@ -288,14 +275,33 @@ } end = header->end; + start = header->start; - if (swap) + if (swap) { end = swab32(end); + start = swab32(start); + } - data->os_res = request_sdram_region("zimage", load_address, end); + image_size = end - start; + + if (load_address == UIMAGE_INVALID_ADDRESS) { + /* + * Just use a conservative default of 4 times the size of the + * compressed image, to avoid the need for the kernel to + * relocate itself before decompression. + */ + data->os_address = mem_start + PAGE_ALIGN(image_size * 4); + + load_address = data->os_address; + if (bootm_verbose(data)) + printf("no os load address, defaulting to 0x%08lx\n", + load_address); + } + + data->os_res = request_sdram_region("zimage", load_address, image_size); if (!data->os_res) { pr_err("bootm/zImage: failed to request memory at 0x%lx to 0x%lx (%d).\n", - load_address, load_address + end, end); + load_address, load_address + image_size, image_size); ret = -ENOMEM; goto err_out; } @@ -304,10 +310,11 @@ memcpy(zimage, header, sizeof(*header)); - ret = read_full(fd, zimage + sizeof(*header), end - sizeof(*header)); + ret = read_full(fd, zimage + sizeof(*header), + image_size - sizeof(*header)); if (ret < 0) goto err_out; - if (ret < end - sizeof(*header)) { + if (ret < image_size - sizeof(*header)) { printf("premature end of image\n"); ret = -EIO; goto err_out; @@ -326,13 +333,10 @@ close(fd); /* - * Put devicetree/initrd at maximum to 128MiB into RAM to not - * risk to put it outside of lowmem. + * put oftree/initrd close behind compressed kernel image to avoid + * placing it outside of the kernels lowmem. */ - if (mem_size > SZ_256M) - mem_free = mem_start + SZ_128M; - else - mem_free = PAGE_ALIGN(data->os_res->end + SZ_1M); + mem_free = PAGE_ALIGN(data->os_res->end + SZ_1M); return __do_bootm_linux(data, mem_free, swap); diff --git a/drivers/of/partition.c b/drivers/of/partition.c index 5ed44a8..c3a404c 100644 --- a/drivers/of/partition.c +++ b/drivers/of/partition.c @@ -21,6 +21,7 @@ #include #include #include +#include #include struct cdev *of_parse_partition(struct cdev *cdev, struct device_node *node) @@ -60,10 +61,14 @@ filename = asprintf("%s.%s", cdev->name, partname); new = devfs_add_partition(cdev->name, offset, size, flags, filename); + if (IS_ERR(new)) { + new = NULL; + goto out; + } if (cdev->mtd && cdev->mtd->type == MTD_NANDFLASH) dev_add_bb_dev(filename, NULL); - +out: free(filename); return new;