diff mbox

[PATCHv4,09/10] linux-generic: schedule: add term_local

Message ID 1424793647-28572-10-git-send-email-robking@cisco.com
State Accepted
Commit 2f464bf3c582483dd61bc5c431a36fc6080beb45
Headers show

Commit Message

Robbie King Feb. 24, 2015, 4 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             | 19 ++++++++++++++++++-
 platform/linux-generic/odp_schedule.c         | 14 ++++++++++++--
 3 files changed, 31 insertions(+), 3 deletions(-)
diff mbox

Patch

diff --git a/platform/linux-generic/include/odp_internal.h b/platform/linux-generic/include/odp_internal.h
index 4b9630c..94103e5 100644
--- a/platform/linux-generic/include/odp_internal.h
+++ b/platform/linux-generic/include/odp_internal.h
@@ -59,6 +59,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_init.c b/platform/linux-generic/odp_init.c
index 0cb6cf8..4c0186a 100644
--- a/platform/linux-generic/odp_init.c
+++ b/platform/linux-generic/odp_init.c
@@ -148,5 +148,22 @@  int odp_init_local(void)
 
 int odp_term_local(void)
 {
-	return (odp_thread_term_local() > 0) ? 1 : 0;
+	int rc = 0;
+	int rc_thd = 0;
+
+	if (odp_schedule_term_local()) {
+		ODP_ERR("ODP schedule local term failed.\n");
+		rc = -1;
+	}
+
+	rc_thd = odp_thread_term_local();
+	if (rc_thd < 0) {
+		ODP_ERR("ODP thread local term failed.\n");
+		rc = -1;
+	} else {
+		if (!rc)
+			rc = rc_thd;
+	}
+
+	return rc;
 }
diff --git a/platform/linux-generic/odp_schedule.c b/platform/linux-generic/odp_schedule.c
index 0749b67..1a96cd9 100644
--- a/platform/linux-generic/odp_schedule.c
+++ b/platform/linux-generic/odp_schedule.c
@@ -4,6 +4,7 @@ 
  * SPDX-License-Identifier:     BSD-3-Clause
  */
 
+#include <string.h>
 #include <odp/schedule.h>
 #include <odp_schedule_internal.h>
 #include <odp/align.h>
@@ -151,8 +152,12 @@  int odp_schedule_term_global(void)
 	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]);
+		for (j = 0; j < QUEUES_PER_PRIO; j++) {
+			if (odp_queue_destroy(sched->pri_queue[i][j])) {
+				ODP_ERR("Sched term: Queue destroy fail.\n");
+				rc = -1;
+			}
+		}
 	}
 
 	if (odp_pool_destroy(sched->pool) != 0) {
@@ -187,6 +192,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)
 {