diff mbox

[v2,04/10] linux-generic: schedule: add term_global

Message ID 1424116520-20381-5-git-send-email-mike.holmes@linaro.org
State New
Headers show

Commit Message

Mike Holmes Feb. 16, 2015, 7:55 p.m. UTC
From: Yan Sonming <yan.songming@linaro.org>

Signed-off-by: Yan Sonming <yan.songming@linaro.org>
Signed-off-by: Mike Holmes <mike.holmes@linaro.org>
---
 platform/linux-generic/include/odp_internal.h |  1 +
 platform/linux-generic/odp_init.c             |  5 +++++
 platform/linux-generic/odp_schedule.c         | 25 +++++++++++++++++++++++++
 3 files changed, 31 insertions(+)
diff mbox

Patch

diff --git a/platform/linux-generic/include/odp_internal.h b/platform/linux-generic/include/odp_internal.h
index 0120c53..d244c75 100644
--- a/platform/linux-generic/include/odp_internal.h
+++ b/platform/linux-generic/include/odp_internal.h
@@ -53,6 +53,7 @@  int odp_crypto_init_global(void);
 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_timer_init_global(void);
diff --git a/platform/linux-generic/odp_init.c b/platform/linux-generic/odp_init.c
index cdce239..2788e46 100644
--- a/platform/linux-generic/odp_init.c
+++ b/platform/linux-generic/odp_init.c
@@ -91,6 +91,11 @@  int odp_term_global(void)
 		return -1;
 	}
 
+	if (odp_schedule_term_global()) {
+		ODP_ERR("ODP schedule term failed.\n");
+		return -1;
+	}
+
 	return 0;
 }
 
diff --git a/platform/linux-generic/odp_schedule.c b/platform/linux-generic/odp_schedule.c
index 3427082..be5149b 100644
--- a/platform/linux-generic/odp_schedule.c
+++ b/platform/linux-generic/odp_schedule.c
@@ -144,6 +144,31 @@  int odp_schedule_init_global(void)
 	return 0;
 }
 
+int odp_schedule_term_global(void)
+{
+	odp_shm_t shm;
+	int ret = 0;
+	int i, j;
+
+	for (i = 0; i < ODP_CONFIG_SCHED_PRIOS; i++) {
+		for (j = 0; j < QUEUES_PER_PRIO; j++)
+			odp_queue_destroy(sched->pri_queue[i][j]);
+	}
+
+	if (odp_pool_destroy(sched->pool) != 0) {
+		ODP_ERR("Sched term: Pool destroy fail.\n");
+		return -1;
+	}
+
+	shm = odp_shm_lookup("odp_scheduler");
+	if (shm == ODP_SHM_INVALID) {
+		ODP_ERR("Sched term: Shm lookup fail.\n");
+		return -1;
+	}
+	ret = odp_shm_free(shm);
+
+	return ret;
+}
 
 int odp_schedule_init_local(void)
 {