* [U-Boot] [PATCH 1/2] image: Don't relocate ramdisk to highmem
@ 2013-09-20 13:35 Thierry Reding
2013-09-20 13:35 ` [U-Boot] [PATCH 2/2] image: Only relocate ramdisk when necessary Thierry Reding
0 siblings, 1 reply; 2+ messages in thread
From: Thierry Reding @ 2013-09-20 13:35 UTC (permalink / raw)
To: u-boot
The Linux kernel cannot unpack a ramdisk that's stored in high memory.
Unless the initrd_high environment variable is explicitly set, abide by
that restriction using the getenv_bootm_low() and getenv_bootm_mapsize()
helpers.
Signed-off-by: Thierry Reding <treding@nvidia.com>
---
Changes in v2:
- update function header comment
common/image.c | 7 ++++---
1 file changed, 4 insertions(+), 3 deletions(-)
diff --git a/common/image.c b/common/image.c
index 2c88091..47336f2 100644
--- a/common/image.c
+++ b/common/image.c
@@ -966,7 +966,8 @@ int boot_get_ramdisk(int argc, char * const argv[], bootm_headers_t *images,
* end address (after possible relocation)
*
* boot_ramdisk_high() takes a relocation hint from "initrd_high" environement
- * variable and if requested ramdisk data is moved to a specified location.
+ * variable and if requested ramdisk data is moved to a specified location. If
+ * no such hint is given, the default is to relocate the initrd to low memory.
*
* Initrd_start and initrd_end are set to final (after relocation) ramdisk
* start/end addresses if ramdisk image start and len were provided,
@@ -991,8 +992,8 @@ int boot_ramdisk_high(struct lmb *lmb, ulong rd_data, ulong rd_len,
if (initrd_high == ~0)
initrd_copy_to_ram = 0;
} else {
- /* not set, no restrictions to load high */
- initrd_high = ~0;
+ /* make sure to put ramdisk in low memory */
+ initrd_high = getenv_bootm_low() + getenv_bootm_mapsize();
}
--
1.8.4
^ permalink raw reply related [flat|nested] 2+ messages in thread
* [U-Boot] [PATCH 2/2] image: Only relocate ramdisk when necessary
2013-09-20 13:35 [U-Boot] [PATCH 1/2] image: Don't relocate ramdisk to highmem Thierry Reding
@ 2013-09-20 13:35 ` Thierry Reding
0 siblings, 0 replies; 2+ messages in thread
From: Thierry Reding @ 2013-09-20 13:35 UTC (permalink / raw)
To: u-boot
If a ramdisk has been loaded to low memory to begin with, there's no
need to relocate it.
Signed-off-by: Thierry Reding <treding@nvidia.com>
---
common/image.c | 12 ++++++++++++
1 file changed, 12 insertions(+)
diff --git a/common/image.c b/common/image.c
index 47336f2..d19c0e6 100644
--- a/common/image.c
+++ b/common/image.c
@@ -968,6 +968,8 @@ int boot_get_ramdisk(int argc, char * const argv[], bootm_headers_t *images,
* boot_ramdisk_high() takes a relocation hint from "initrd_high" environement
* variable and if requested ramdisk data is moved to a specified location. If
* no such hint is given, the default is to relocate the initrd to low memory.
+ * If the ramdisk is already in a proper location, skip relocation and use it
+ * in-place.
*
* Initrd_start and initrd_end are set to final (after relocation) ramdisk
* start/end addresses if ramdisk image start and len were provided,
@@ -1006,6 +1008,16 @@ int boot_ramdisk_high(struct lmb *lmb, ulong rd_data, ulong rd_len,
initrd_high, initrd_copy_to_ram);
if (rd_data) {
+ /*
+ * Only copy initrd if necessary. If it has been loaded to
+ * low memory, just skip relocation and use it in-place.
+ */
+ ulong bootm_start = getenv_bootm_low();
+ ulong rd_end = rd_data + rd_len;
+
+ if (rd_data >= bootm_start && rd_end <= initrd_high)
+ initrd_copy_to_ram = 0;
+
if (!initrd_copy_to_ram) { /* zero-copy ramdisk support */
debug(" in-place initrd\n");
*initrd_start = rd_data;
--
1.8.4
^ permalink raw reply related [flat|nested] 2+ messages in thread
end of thread, other threads:[~2013-09-20 13:35 UTC | newest]
Thread overview: 2+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2013-09-20 13:35 [U-Boot] [PATCH 1/2] image: Don't relocate ramdisk to highmem Thierry Reding
2013-09-20 13:35 ` [U-Boot] [PATCH 2/2] image: Only relocate ramdisk when necessary Thierry Reding
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox