diff mbox

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

Message ID 1424723769-8762-5-git-send-email-robking@cisco.com
State Superseded
Headers show

Commit Message

Robbie King Feb. 23, 2015, 8:36 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>
Signed-off-by: Robbie King <robking@cisco.com>
---
 platform/linux-generic/include/odp_internal.h |  1 +
 platform/linux-generic/odp_init.c             |  5 +++++
 platform/linux-generic/odp_schedule.c         | 24 ++++++++++++++++++++++++
 3 files changed, 30 insertions(+)
diff mbox

Patch

diff --git a/platform/linux-generic/include/odp_internal.h b/platform/linux-generic/include/odp_internal.h
index e43608d..83b0beb 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 48bc9a2..4f6eeb9 100644
--- a/platform/linux-generic/odp_init.c
+++ b/platform/linux-generic/odp_init.c
@@ -93,6 +93,11 @@  int odp_term_global(void)
 		rc = -1;
 	}
 
+	if (odp_schedule_term_global()) {
+		ODP_ERR("ODP schedule term failed.\n");
+		rc = -1;
+	}
+
 	return rc;
 }
 
diff --git a/platform/linux-generic/odp_schedule.c b/platform/linux-generic/odp_schedule.c
index 3427082..0749b67 100644
--- a/platform/linux-generic/odp_schedule.c
+++ b/platform/linux-generic/odp_schedule.c
@@ -144,6 +144,30 @@  int odp_schedule_init_global(void)
 	return 0;
 }
 
+int odp_schedule_term_global(void)
+{
+	int ret = 0;
+	int rc = 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");
+		rc = -1;
+	}
+
+	ret = odp_shm_free(odp_shm_lookup("odp_scheduler"));
+	if (ret < 0) {
+		ODP_ERR("Sched term: shm free failed for odp_scheduler");
+		rc = -1;
+	}
+
+	return rc;
+}
 
 int odp_schedule_init_local(void)
 {