[CONF] Enable KERNEL_CMA as default in FastModel
authorDongju Chae <dongju.chae@samsung.com>
Fri, 6 Sep 2019 10:39:25 +0000 (19:39 +0900)
committer파리차이카푸르/On-Device Lab(SR)/Engineer/삼성전자 <pk.kapoor@samsung.com>
Tue, 10 Sep 2019 13:18:27 +0000 (22:18 +0900)
This commit enables KERNEL_CMA as default in FastModel.
A zero-sized reserved memory indicates that the memory allocator used Kernel's CMA allocation.
In order to accept the zero size, ne-conf.c should be changed.

Also, some minor bugs are fixed

Signed-off-by: Dongju Chae <dongju.chae@samsung.com>
meson_options.txt
src/core/ne-conf.c
src/core/ne-mem.c

index 5ab7fdc..6b85e88 100644 (file)
@@ -1,5 +1,5 @@
 option('comm_opt', type : 'string', value : 'ip')
-option('resv_mem_size', type : 'string', value : '512M')
+option('resv_mem_size', type : 'string', value : '0')
 option('working_dir', type : 'string', value : '/tmp/')
 option('log_dir', type : 'string', value : '/tmp/')
 option('enable_test_mode', type : 'boolean', value : true)
index cccae05..f9e827f 100644 (file)
@@ -55,20 +55,19 @@ load_conf_each (const char *resv_mem_size, const char *working_dir,
 
     sscanf (resv_mem_size, "%" SCNu64 "%c", &val, &unit);
 
-    if (val > 0) {
-      if (unit != '\x00') {
-        if (unit == 'K' || unit == 'k') {
-          val *= 1024;
-        } else if (unit == 'M' || unit == 'm') {
-          val *= 1024 * 1024;
-        } else if (unit == 'G' || unit == 'g') {
-          val *= 1024 * 1024 * 1024;
-        } else
-          fprintf (stderr, "Unknown unit for memory size: %c\n", unit);
-      }
-      c->reserved_mem_size = val;
-    } else
-      fprintf (stderr, "Cannot parse 'resv_mem_size': %s\n", resv_mem_size);
+    if (unit != '\x00') {
+      if (unit == 'K' || unit == 'k') {
+        val *= 1024;
+      } else if (unit == 'M' || unit == 'm') {
+        val *= 1024 * 1024;
+      } else if (unit == 'G' || unit == 'g') {
+        val *= 1024 * 1024 * 1024;
+      } else
+        fprintf (stderr, "Unknown unit for memory size: %c\n", unit);
+    }
+
+    /** zero size is now allowed to indicate the KERNEL_CMA mode */
+    c->reserved_mem_size = val;
   }
 
   if (working_dir && strlen(working_dir) < MAX_DIR_LEN) {
index 27e542e..1807e32 100644 (file)
@@ -774,12 +774,12 @@ hwmem_resize (hwmem *hwmem, mem_size_t size)
       return false;
 
     assert (size_in <= size_out);
-
     size = size_out;
-    priv->cma.handle = handle;
 
     /** destory old gem buffer */
     gem_destroy (mpriv.fd, priv->cma.handle);
+
+    priv->cma.handle = handle;
   }
 
   mpriv.used_size -= hwmem->size;