[RAMEN9610-20734][COMMON] lib: dss: register valid reserved memory
authorDonghyeok Choe <d7271.choe@samsung.com>
Sat, 27 Jul 2019 07:04:00 +0000 (16:04 +0900)
committerrobot <robot@samsung.com>
Sun, 27 Oct 2019 17:53:29 +0000 (02:53 +0900)
for user build, debug snapshot minimize reserved area,
but both node exists in reserved mem node of device tree.
So, skip reserve invalid dss's reserved memory area.

Change-Id: I6d1c24edf61556d0a8c314cee7b2896e8c5c45a3
Signed-off-by: Donghyeok Choe <d7271.choe@samsung.com>
drivers/of/fdt.c
include/linux/debug-snapshot.h
lib/debug-snapshot.c

index b1103e519ef615cc10f4cbb2c9d38ac22429e4a1..942bc9a72e3ce2d801ee642475910a55515a7e33 100644 (file)
@@ -27,6 +27,7 @@
 #include <linux/debugfs.h>
 #include <linux/serial_core.h>
 #include <linux/sysfs.h>
+#include <linux/debug-snapshot.h>
 
 #include <asm/setup.h>  /* for COMMAND_LINE_SIZE */
 #include <asm/page.h>
@@ -605,6 +606,9 @@ static int __init __reserved_mem_reserve_reg(unsigned long node,
                base = dt_mem_next_cell(dt_root_addr_cells, &prop);
                size = dt_mem_next_cell(dt_root_size_cells, &prop);
 
+               if (dbg_snapshot_reserved_mem_check(node, (unsigned long)size))
+                       return -EINVAL;
+
                if (size &&
                    early_init_dt_reserve_memory_arch(base, size, nomap) == 0)
                        pr_debug("Reserved memory: reserved region for node '%s': base %pa, size %ld MiB\n",
index 0c4535661ff4e1956e71ea5ced6dd0bdab155d42..e9d4718800e35756f14ef38657568fbdfa422dee 100644 (file)
@@ -168,7 +168,16 @@ extern void dbg_snapshot_binder(struct trace_binder_transaction_base *base,
 #define dbg_snapshot_binder(a,b,c)     do { } while(0)
 #endif
 
+#ifdef CONFIG_OF_RESERVED_MEM
+extern int dbg_snapshot_reserved_mem_check(unsigned long node, unsigned long size);
 #else
+static inline int dbg_snapshot_reserved_mem_check(unsigned long node, unsigned long size)
+{
+       return 0;
+}
+#endif
+
+#else /* CONFIG_DEBUG_SNAPSHOT */
 #define dbg_snapshot_acpm(a,b,c)               do { } while(0)
 #define dbg_snapshot_task(a,b)         do { } while(0)
 #define dbg_snapshot_work(a,b,c,d)             do { } while(0)
@@ -241,6 +250,10 @@ static inline int dbg_snapshot_get_hardlockup(void)
 
 #define dbg_snapshot_add_bl_item_info(a,b,c)   do { } while(0)
 
+static inline int dbg_snapshot_reserved_mem_check(unsigned long node, unsigned long size)
+{
+       return 0;
+}
 #endif /* CONFIG_DEBUG_SNAPSHOT */
 
 extern void dbg_snapshot_soc_helper_init(void);
index f38f4fa073024243daed2e4866036902f42ec4c4..ea5902d400c78fab7aeb007e3dd89b84a4dbdd07 100644 (file)
@@ -22,6 +22,8 @@
 #include <linux/vmalloc.h>
 #include <linux/module.h>
 #include <linux/memblock.h>
+#include <linux/of.h>
+#include <linux/of_fdt.h>
 #include <linux/of_address.h>
 #include <linux/of_reserved_mem.h>
 #include <linux/sched/clock.h>
@@ -464,6 +466,37 @@ static int __init dbg_snapshot_init_desc(void)
 }
 
 #ifdef CONFIG_OF_RESERVED_MEM
+int __init dbg_snapshot_reserved_mem_check(unsigned long node, unsigned long size)
+{
+       const char *name;
+       int ret = 0;
+
+       name = of_get_flat_dt_prop(node, "compatible", NULL);
+       if (!name)
+               goto out;
+
+       if (!strstr(name, "debug-snapshot"))
+               goto out;
+
+       if (!strstr(name, "log"))
+               goto out;
+
+       if (size == 0) {
+               ret = -EINVAL;
+               goto out;
+       }
+
+#if !defined(CONFIG_DEBUG_SNAPSHOT_USER_MODE)
+       if (strstr(name, "user"))
+               ret = -EINVAL;
+#else
+       if (!strstr(name, "user"))
+               ret = -EINVAL;
+#endif
+out:
+       return ret;
+}
+
 static int __init dbg_snapshot_item_reserved_mem_setup(struct reserved_mem *remem)
 {
        unsigned int i;