diff mbox series

[API-NEXT,v2,2/2] linux-generic: api schedule unlock lock

Message ID 1503925219-13793-3-git-send-email-odpbot@yandex.ru
State New
Headers show
Series [API-NEXT,v2,1/2] api: schedule: add schedule order unlock lock api | expand

Commit Message

Github ODP bot Aug. 28, 2017, 1 p.m. UTC
From: Balasubramanian Manoharan <bala.manoharan@linaro.org>


Signed-off-by: Balasubramanian Manoharan <bala.manoharan@linaro.org>

---
/** Email created from pull request 129 (bala-manoharan:api_sched_order_lock)
 ** https://github.com/Linaro/odp/pull/129
 ** Patch: https://github.com/Linaro/odp/pull/129.patch
 ** Base sha: 859293ad9b3c862264bb0fbfe8e7037b5e04d084
 ** Merge commit sha: 039de688a242ee44f5495e97b35637c173ef459f
 **/
 platform/linux-generic/include/odp_schedule_if.h |  1 +
 platform/linux-generic/odp_schedule_if.c         |  5 ++++
 platform/linux-generic/odp_schedule_iquery.c     | 29 +++++++++++++++++++++++-
 platform/linux-generic/odp_schedule_scalable.c   |  6 +++++
 platform/linux-generic/odp_schedule_sp.c         |  8 ++++++-
 5 files changed, 47 insertions(+), 2 deletions(-)
diff mbox series

Patch

diff --git a/platform/linux-generic/include/odp_schedule_if.h b/platform/linux-generic/include/odp_schedule_if.h
index 657993b1..b0db67ab 100644
--- a/platform/linux-generic/include/odp_schedule_if.h
+++ b/platform/linux-generic/include/odp_schedule_if.h
@@ -95,6 +95,7 @@  typedef struct {
 				   odp_schedule_group_info_t *);
 	void (*schedule_order_lock)(unsigned);
 	void (*schedule_order_unlock)(unsigned);
+	void (*schedule_order_unlock_lock)(unsigned);
 
 } schedule_api_t;
 
diff --git a/platform/linux-generic/odp_schedule_if.c b/platform/linux-generic/odp_schedule_if.c
index 2f07aafe..35e34b03 100644
--- a/platform/linux-generic/odp_schedule_if.c
+++ b/platform/linux-generic/odp_schedule_if.c
@@ -127,3 +127,8 @@  void odp_schedule_order_unlock(unsigned lock_index)
 {
 	return sched_api->schedule_order_unlock(lock_index);
 }
+
+void odp_schedule_order_unlock_lock(uint32_t lock_index)
+{
+	sched_api->schedule_order_unlock_lock(lock_index);
+}
diff --git a/platform/linux-generic/odp_schedule_iquery.c b/platform/linux-generic/odp_schedule_iquery.c
index 86f5d53e..777bfe24 100644
--- a/platform/linux-generic/odp_schedule_iquery.c
+++ b/platform/linux-generic/odp_schedule_iquery.c
@@ -1294,6 +1294,32 @@  static void schedule_order_unlock(unsigned lock_index)
 	odp_atomic_store_rel_u64(ord_lock, thread_local.ordered.ctx + 1);
 }
 
+static inline uint8_t powerof2(uint32_t n)
+{
+	return n && (! (n & (n - 1)));
+}
+
+static void schedule_order_unlock_lock(unsigned lock_index)
+{
+	uint32_t queue_index;
+	unsigned acquired_lock = 0;
+	uint32_t i;
+
+	queue_index = thread_local.ordered.src_queue;
+
+	ODP_ASSERT(queue_index != NULL_INDEX);
+
+	if (!powerof2(thread_local.ordered.lock_called.all))
+		return;
+
+	for (i = 0; i < CONFIG_QUEUE_MAX_ORD_LOCKS; i++)
+		if (1 == thread_local.ordered.lock_called.u8[i])
+			acquired_lock = i;
+
+	schedule_order_unlock(acquired_lock);
+	schedule_order_lock(lock_index);
+}
+
 static unsigned schedule_max_ordered_locks(void)
 {
 	return CONFIG_QUEUE_MAX_ORD_LOCKS;
@@ -1366,7 +1392,8 @@  const schedule_api_t schedule_iquery_api = {
 	.schedule_group_thrmask   = schedule_group_thrmask,
 	.schedule_group_info      = schedule_group_info,
 	.schedule_order_lock      = schedule_order_lock,
-	.schedule_order_unlock    = schedule_order_unlock
+	.schedule_order_unlock    = schedule_order_unlock,
+	.schedule_order_unlock_lock    = schedule_order_unlock_lock
 };
 
 static void thread_set_interest(sched_thread_local_t *thread,
diff --git a/platform/linux-generic/odp_schedule_scalable.c b/platform/linux-generic/odp_schedule_scalable.c
index 78159b53..5868f1dd 100644
--- a/platform/linux-generic/odp_schedule_scalable.c
+++ b/platform/linux-generic/odp_schedule_scalable.c
@@ -1027,6 +1027,11 @@  static void schedule_order_unlock(unsigned lock_index)
 	rctx->olock_flags |= 1U << lock_index;
 }
 
+static void schedule_order_unlock_lock(unsigned lock_index)
+{
+	(void) lock_index;
+}
+
 static void schedule_release_atomic(void)
 {
 	sched_scalable_thread_state_t *ts;
@@ -1977,4 +1982,5 @@  const schedule_api_t schedule_scalable_api = {
 	.schedule_group_info		= schedule_group_info,
 	.schedule_order_lock		= schedule_order_lock,
 	.schedule_order_unlock		= schedule_order_unlock,
+	.schedule_order_unlock_lock	= schedule_order_unlock_lock,
 };
diff --git a/platform/linux-generic/odp_schedule_sp.c b/platform/linux-generic/odp_schedule_sp.c
index 9829acc5..fb54dd7a 100644
--- a/platform/linux-generic/odp_schedule_sp.c
+++ b/platform/linux-generic/odp_schedule_sp.c
@@ -817,6 +817,11 @@  static void schedule_order_unlock(unsigned lock_index)
 	(void)lock_index;
 }
 
+static void schedule_order_unlock_lock(unsigned lock_index)
+{
+	(void)lock_index;
+}
+
 static void order_lock(void)
 {
 }
@@ -866,5 +871,6 @@  const schedule_api_t schedule_sp_api = {
 	.schedule_group_thrmask   = schedule_group_thrmask,
 	.schedule_group_info      = schedule_group_info,
 	.schedule_order_lock      = schedule_order_lock,
-	.schedule_order_unlock    = schedule_order_unlock
+	.schedule_order_unlock    = schedule_order_unlock,
+	.schedule_order_unlock_lock	= schedule_order_unlock_lock
 };