aboutsummaryrefslogtreecommitdiffstats
path: root/arch/arm/boot
diff options
context:
space:
mode:
authorGregory CLEMENT <gregory.clement@free-electrons.com>2013-05-15 04:39:17 -0400
committerGreg Kroah-Hartman <gregkh@linuxfoundation.org>2013-08-04 04:50:38 -0400
commit7ca674af75d75aa6755746327f1fd3222e54b338 (patch)
treee5ada058e7d4d1cfc1a3710514b0795574aca5f5 /arch/arm/boot
parente1e97450a25d46c665a634f5073f9555236b7b0b (diff)
ARM: 7722/1: zImage: Convert 32bits memory size and address from ATAG to 64bits DTB
commit faefd550c45d8d314e8f260f21565320355c947f upstream. When CONFIG_ARM_APPENDED_DTB is selected, if the bootloader provides an ATAG_MEM it replaces the memory size and the memory address in the memory node of the device tree. In the case of a system which can handle more than 4GB, the memory node cell size is 4: each data (memory size and memory address) are 64 bits and then use 2 cells. The current code in atags_to_fdt.c made the assumption of a cell size of 2 (one cell for the memory size and one cell for the memory address), this leads to an improper write of the data and ends with a boot hang. This patch writes the memory size and the memory address on the memory node in the device tree depending of the size of the memory node (32 bits or 64 bits). It has been tested in the 2 cases: - with a dtb using skeleton.dtsi - and with a dtb using skeleton64.dtsi Signed-off-by: Gregory CLEMENT <gregory.clement@free-electrons.com> Acked-by: Nicolas Pitre <nico@linaro.org> Signed-off-by: Russell King <rmk+kernel@arm.linux.org.uk> Cc: Willy Tarreau <w@1wt.eu> Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
Diffstat (limited to 'arch/arm/boot')
-rw-r--r--arch/arm/boot/compressed/atags_to_fdt.c44
1 files changed, 38 insertions, 6 deletions
diff --git a/arch/arm/boot/compressed/atags_to_fdt.c b/arch/arm/boot/compressed/atags_to_fdt.c
index aabc02a68482..d1153c8a765a 100644
--- a/arch/arm/boot/compressed/atags_to_fdt.c
+++ b/arch/arm/boot/compressed/atags_to_fdt.c
@@ -53,6 +53,17 @@ static const void *getprop(const void *fdt, const char *node_path,
53 return fdt_getprop(fdt, offset, property, len); 53 return fdt_getprop(fdt, offset, property, len);
54} 54}
55 55
56static uint32_t get_cell_size(const void *fdt)
57{
58 int len;
59 uint32_t cell_size = 1;
60 const uint32_t *size_len = getprop(fdt, "/", "#size-cells", &len);
61
62 if (size_len)
63 cell_size = fdt32_to_cpu(*size_len);
64 return cell_size;
65}
66
56static void merge_fdt_bootargs(void *fdt, const char *fdt_cmdline) 67static void merge_fdt_bootargs(void *fdt, const char *fdt_cmdline)
57{ 68{
58 char cmdline[COMMAND_LINE_SIZE]; 69 char cmdline[COMMAND_LINE_SIZE];
@@ -95,9 +106,11 @@ static void merge_fdt_bootargs(void *fdt, const char *fdt_cmdline)
95int atags_to_fdt(void *atag_list, void *fdt, int total_space) 106int atags_to_fdt(void *atag_list, void *fdt, int total_space)
96{ 107{
97 struct tag *atag = atag_list; 108 struct tag *atag = atag_list;
98 uint32_t mem_reg_property[2 * NR_BANKS]; 109 /* In the case of 64 bits memory size, need to reserve 2 cells for
110 * address and size for each bank */
111 uint32_t mem_reg_property[2 * 2 * NR_BANKS];
99 int memcount = 0; 112 int memcount = 0;
100 int ret; 113 int ret, memsize;
101 114
102 /* make sure we've got an aligned pointer */ 115 /* make sure we've got an aligned pointer */
103 if ((u32)atag_list & 0x3) 116 if ((u32)atag_list & 0x3)
@@ -137,8 +150,25 @@ int atags_to_fdt(void *atag_list, void *fdt, int total_space)
137 continue; 150 continue;
138 if (!atag->u.mem.size) 151 if (!atag->u.mem.size)
139 continue; 152 continue;
140 mem_reg_property[memcount++] = cpu_to_fdt32(atag->u.mem.start); 153 memsize = get_cell_size(fdt);
141 mem_reg_property[memcount++] = cpu_to_fdt32(atag->u.mem.size); 154
155 if (memsize == 2) {
156 /* if memsize is 2, that means that
157 * each data needs 2 cells of 32 bits,
158 * so the data are 64 bits */
159 uint64_t *mem_reg_prop64 =
160 (uint64_t *)mem_reg_property;
161 mem_reg_prop64[memcount++] =
162 cpu_to_fdt64(atag->u.mem.start);
163 mem_reg_prop64[memcount++] =
164 cpu_to_fdt64(atag->u.mem.size);
165 } else {
166 mem_reg_property[memcount++] =
167 cpu_to_fdt32(atag->u.mem.start);
168 mem_reg_property[memcount++] =
169 cpu_to_fdt32(atag->u.mem.size);
170 }
171
142 } else if (atag->hdr.tag == ATAG_INITRD2) { 172 } else if (atag->hdr.tag == ATAG_INITRD2) {
143 uint32_t initrd_start, initrd_size; 173 uint32_t initrd_start, initrd_size;
144 initrd_start = atag->u.initrd.start; 174 initrd_start = atag->u.initrd.start;
@@ -150,8 +180,10 @@ int atags_to_fdt(void *atag_list, void *fdt, int total_space)
150 } 180 }
151 } 181 }
152 182
153 if (memcount) 183 if (memcount) {
154 setprop(fdt, "/memory", "reg", mem_reg_property, 4*memcount); 184 setprop(fdt, "/memory", "reg", mem_reg_property,
185 4 * memcount * memsize);
186 }
155 187
156 return fdt_pack(fdt); 188 return fdt_pack(fdt);
157} 189}