diff mbox

[v4,2/2] linux-generic: implement of odp_term_local.

Message ID 1422537026-25694-1-git-send-email-yan.songming@linaro.org
State New
Headers show

Commit Message

yan.songming Jan. 29, 2015, 1:10 p.m. UTC
From: Yan Sonming <yan.songming@linaro.org>

Free local resource of odp.

Signed-off-by: Yan Songming <yan.songming@linaro.org>
---
 platform/linux-generic/include/odp_internal.h |  2 ++
 platform/linux-generic/odp_buffer_pool.c      |  6 ++++++
 platform/linux-generic/odp_init.c             | 10 ++++++++++
 platform/linux-generic/odp_schedule.c         |  8 +++++++-
 4 files changed, 25 insertions(+), 1 deletion(-)
diff mbox

Patch

diff --git a/platform/linux-generic/include/odp_internal.h b/platform/linux-generic/include/odp_internal.h
index 60d89b1..ddf5dd5 100644
--- a/platform/linux-generic/include/odp_internal.h
+++ b/platform/linux-generic/include/odp_internal.h
@@ -37,6 +37,7 @@  int odp_shm_init_local(void);
 
 int odp_buffer_pool_init_global(void);
 int odp_buffer_pool_term_global(void);
+int odp_buffer_pool_term_local(void);
 
 int odp_pktio_init_global(void);
 int odp_pktio_term_global(void);
@@ -54,6 +55,7 @@  int odp_crypto_term_global(void);
 int odp_schedule_init_global(void);
 int odp_schedule_term_global(void);
 int odp_schedule_init_local(void);
+int odp_schedule_term_local(void);
 
 int odp_timer_init_global(void);
 int odp_timer_disarm_all(void);
diff --git a/platform/linux-generic/odp_buffer_pool.c b/platform/linux-generic/odp_buffer_pool.c
index 3f4a3e6..94027d5 100644
--- a/platform/linux-generic/odp_buffer_pool.c
+++ b/platform/linux-generic/odp_buffer_pool.c
@@ -124,6 +124,12 @@  int odp_buffer_pool_term_global(void)
 	return ret;
 }
 
+int odp_buffer_pool_term_local(void)
+{
+	_odp_flush_caches();
+	return 0;
+}
+
 /**
  * Pool creation
  */
diff --git a/platform/linux-generic/odp_init.c b/platform/linux-generic/odp_init.c
index 1351b31..1e0255c 100644
--- a/platform/linux-generic/odp_init.c
+++ b/platform/linux-generic/odp_init.c
@@ -141,5 +141,15 @@  int odp_init_local(void)
 
 int odp_term_local(void)
 {
+	if (odp_schedule_term_local()) {
+		ODP_ERR("ODP schedule local term failed.\n");
+		return -1;
+	}
+
+	if (odp_buffer_pool_term_local()) {
+		ODP_ERR("ODP buffer pool local term failed.\n");
+		return -1;
+	}
+
 	return (odp_thread_term_local() > 0) ? 1 : 0;
 }
diff --git a/platform/linux-generic/odp_schedule.c b/platform/linux-generic/odp_schedule.c
index bff28d9..cbda67f 100644
--- a/platform/linux-generic/odp_schedule.c
+++ b/platform/linux-generic/odp_schedule.c
@@ -20,7 +20,8 @@ 
 #include <odp_hints.h>
 
 #include <odp_queue_internal.h>
-
+#include <string.h>
+#include <stdio.h>
 
 /* Limits to number of scheduled queues */
 #define SCHED_POOL_SIZE (256*1024)
@@ -188,6 +189,11 @@  int odp_schedule_init_local(void)
 	return 0;
 }
 
+int odp_schedule_term_local(void)
+{
+	memset(&sched_local, 0, sizeof(sched_local_t));
+	return 0;
+}
 
 void odp_schedule_mask_set(odp_queue_t queue, int prio)
 {