[Arm-dev] [PATCH v0 18/20] efi: Avoid dt memory node deletion from efistub.

Thu Jul 23 12:37:55 UTC 2015
Vadim Lomovtsev <Vadim.Lomovtsev at caviumnetworks.com>

From: Ganapatrao Kulkarni <gkulkarni at caviumnetworks.com>

Current efistub deletes the memory nodes from the dt before
the dt file is passed to linux to avoid memblocks addition from dt early
memory scan code.

This patch avoids the deletion and still makes sure the memory is not added
from the dt code since, the memory info has to be used from efi tables.

Signed-off-by: Ganapatrao Kulkarni <gkulkarni at caviumnetworks.com>
Signed-off-by: Vadim Lomovtsev <Vadim.Lomovtsev at caviumnetworks.com>
---
 drivers/firmware/efi/libstub/fdt.c | 12 ++++++++----
 1 file changed, 8 insertions(+), 4 deletions(-)

diff --git a/drivers/firmware/efi/libstub/fdt.c b/drivers/firmware/efi/libstub/fdt.c
index ef5d764..ccdb24f 100644
--- a/drivers/firmware/efi/libstub/fdt.c
+++ b/drivers/firmware/efi/libstub/fdt.c
@@ -54,13 +54,15 @@ efi_status_t update_fdt(efi_system_table_t *sys_table, void *orig_fdt,
 		goto fdt_set_fail;
 
 	/*
-	 * Delete any memory nodes present. We must delete nodes which
-	 * early_init_dt_scan_memory may try to use.
+	 * Disable any memory nodes present by adding (or overriding) their
+	 * linux,usable-memory property to (u32)0, which is interpreted as
+	 * a zero sized memory range by the DT code.
 	 */
 	prev = 0;
 	for (;;) {
 		const char *type;
 		int len;
+               static const u32 usable_memory = 0;
 
 		node = fdt_next_node(fdt, prev, NULL);
 		if (node < 0)
@@ -68,8 +70,10 @@ efi_status_t update_fdt(efi_system_table_t *sys_table, void *orig_fdt,
 
 		type = fdt_getprop(fdt, node, "device_type", &len);
 		if (type && strncmp(type, "memory", len) == 0) {
-			fdt_del_node(fdt, node);
-			continue;
+                       status = fdt_setprop(fdt, node, "linux,usable-memory",
+                                            &usable_memory, sizeof(u32));
+                       if (status)
+                               goto fdt_set_fail;
 		}
 
 		prev = node;
-- 
2.4.3