[Cbe-oss-dev] [PATCH 1/2]MARS/base: fix get workload ea

Yuji Mano yuji.mano at am.sony.com
Fri Mar 27 09:44:48 EST 2009


This patch fixes a bug introduced by the
workload-num-blocks-reduce-code-size.patch that caused internal function
get_workload_ea() to return the wrong address.

Signed-off-by: Yuji Mano <yuji.mano at am.sony.com>
---
 base/src/host/lib/callback_cell.c  |    4 +++-
 base/src/host/lib/workload_queue.c |    6 ++++--
 base/src/mpu/kernel/kernel.c       |    5 ++++-
 3 files changed, 11 insertions(+), 4 deletions(-)

--- a/base/src/host/lib/callback_cell.c
+++ b/base/src/host/lib/callback_cell.c
@@ -58,8 +58,10 @@ static inline uint64_t get_workload_ea(u
 		mars_ea_get_uint64(queue_ea +
 				   offsetof(struct mars_workload_queue_header,
 				   context_ea));
+	int context_index =
+		workload_id - (workload_id / MARS_WORKLOAD_PER_BLOCK) - 1;
 
-	return context_ea + workload_id * MARS_WORKLOAD_CONTEXT_SIZE;
+	return context_ea + context_index * MARS_WORKLOAD_CONTEXT_SIZE;
 }
 
 static void callback_process(struct mars_context *mars, uint16_t workload_id)
--- a/base/src/host/lib/workload_queue.c
+++ b/base/src/host/lib/workload_queue.c
@@ -49,14 +49,16 @@
 #include "kernel_internal_types.h"
 #include "workload_internal_types.h"
 
-static inline uint64_t get_workload_ea(uint64_t queue_ea, int workload_id)
+static inline uint64_t get_workload_ea(uint64_t queue_ea, uint16_t workload_id)
 {
 	uint64_t context_ea =
 		mars_ea_get_uint64(queue_ea +
 				   offsetof(struct mars_workload_queue_header,
 				   context_ea));
+	int context_index =
+		workload_id - (workload_id / MARS_WORKLOAD_PER_BLOCK) - 1;
 
-	return context_ea + MARS_WORKLOAD_CONTEXT_SIZE * workload_id;
+	return context_ea + context_index * MARS_WORKLOAD_CONTEXT_SIZE;
 }
 
 static inline uint64_t get_block_ea(uint64_t queue_ea, int block)
--- a/base/src/mpu/kernel/kernel.c
+++ b/base/src/mpu/kernel/kernel.c
@@ -132,7 +132,10 @@ static struct mars_workload_context *get
 
 static uint64_t get_workload_ea(uint16_t id)
 {
-	return queue_header.context_ea + MARS_WORKLOAD_CONTEXT_SIZE * id;
+	int context_index = id - (id / MARS_WORKLOAD_PER_BLOCK) - 1;
+
+	return queue_header.context_ea +
+			context_index * MARS_WORKLOAD_CONTEXT_SIZE;
 }
 
 static struct mars_workload_context *get_workload_by_id(uint16_t id)






More information about the cbe-oss-dev mailing list