[Cbe-oss-dev] [PATCH 2/5]base: workload queue module api update
Yuji Mano
yuji.mano at am.sony.com
Wed Mar 25 12:48:19 EST 2009
This patch removes the *_cancel functions from the workload queue and
workload module APIs and provides a cancel param option in the *_end function.
This is to reduce the number of syscalls and to simplify the API.
Signed-off-by: Yuji Mano <yuji.mano at am.sony.com>
---
base/include/host/mars/workload_queue.h | 71 ++++----------------------------
base/include/mpu/mars/module.h | 20 +--------
base/src/common/kernel_internal_types.h | 3 -
base/src/host/lib/workload_queue.c | 51 ++++++----------------
base/src/mpu/kernel/kernel.c | 16 +------
base/src/mpu/lib/module.S | 28 ++++--------
6 files changed, 41 insertions(+), 148 deletions(-)
--- a/base/include/host/mars/workload_queue.h
+++ b/base/include/host/mars/workload_queue.h
@@ -118,6 +118,7 @@ int mars_workload_queue_add_begin(struct
*
* \param[in] mars - address of pointer to MARS context
* \param[in] id - id of workload to end add
+ * \param[in] cancel - cancels the add operation
* \return
* MARS_SUCCESS - workload adding complete
* \n MARS_ERROR_NULL - null pointer specified
@@ -125,27 +126,8 @@ int mars_workload_queue_add_begin(struct
* \n MARS_ERROR_STATE - workload adding not started
*/
int mars_workload_queue_add_end(struct mars_context *mars,
- uint16_t id);
-
-/**
- * \ingroup group_mars_workload_queue
- * \brief <b>[host]</b> Cancels adding of specified workload.
- *
- * This function will cancel an add operation previously initiated with
- * \ref mars_workload_queue_add_begin.
- * If scheduling is canceled, \ref mars_workload_queue_add_end should not
- * be called.
- *
- * \param[in] mars - address of pointer to MARS context
- * \param[in] id - id of workload to cancel add
- * \return
- * MARS_SUCCESS - workload adding canceled
- * \n MARS_ERROR_NULL - null pointer specified
- * \n MARS_ERROR_PARAMS - invalid mars context or workload id specified
- * \n MARS_ERROR_STATE - workload adding not started
- */
-int mars_workload_queue_add_cancel(struct mars_context *mars,
- uint16_t id);
+ uint16_t id,
+ int cancel);
/**
* \ingroup group_mars_workload_queue
@@ -190,32 +172,15 @@ int mars_workload_queue_remove_begin(str
*
* \param[in] mars - address of pointer to MARS context
* \param[in] id - id of workload
+ * \param[in] cancel - cancels the remove operation
* \return
* MARS_SUCCESS - workload removing complete
* \n MARS_ERROR_PARAMS - invalid mars context or workload id specified
* \n MARS_ERROR_STATE - workload removing not started
*/
int mars_workload_queue_remove_end(struct mars_context *mars,
- uint16_t id);
-
-/**
- * \ingroup group_mars_workload_queue
- * \brief <b>[host]</b> Cancels removing of specified workload.
- *
- * This function will cancel a remove operation previously initiated with
- * \ref mars_workload_queue_remove_begin.
- * If removing is canceled, \ref mars_workload_queue_remove_end should not
- * be called.
- *
- * \param[in] mars - address of pointer to MARS context
- * \param[in] id - id of workload
- * \return
- * MARS_SUCCESS - workload removing canceled
- * \n MARS_ERROR_PARAMS - invalid mars context or workload id specified
- * \n MARS_ERROR_STATE - workload removing not started
- */
-int mars_workload_queue_remove_cancel(struct mars_context *mars,
- uint16_t id);
+ uint16_t id,
+ int cancel);
/**
* \ingroup group_mars_workload_queue
@@ -260,6 +225,7 @@ int mars_workload_queue_schedule_begin(s
*
* \param[in] mars - address of pointer to MARS context
* \param[in] id - id of workload
+ * \param[in] cancel - cancels the schedule operation
* \return
* MARS_SUCCESS - workload scheduling complete
* \n MARS_ERROR_NULL - null pointer specified
@@ -267,27 +233,8 @@ int mars_workload_queue_schedule_begin(s
* \n MARS_ERROR_STATE - workload scheduling not started
*/
int mars_workload_queue_schedule_end(struct mars_context *mars,
- uint16_t id);
-
-/**
- * \ingroup group_mars_workload_queue
- * \brief <b>[host]</b> Cancels scheduling of specified workload.
- *
- * This function will cancel a schedule operation previously initiated with
- * \ref mars_workload_queue_schedule_begin.
- * If scheduling is canceled, \ref mars_workload_queue_schedule_end should not
- * be called.
- *
- * \param[in] mars - address of pointer to MARS context
- * \param[in] id - id of workload
- * \return
- * MARS_SUCCESS - workload scheduling canceled
- * \n MARS_ERROR_NULL - null pointer specified
- * \n MARS_ERROR_PARAMS - invalid mars context or workload id specified
- * \n MARS_ERROR_STATE - workload scheduling not started
- */
-int mars_workload_queue_schedule_cancel(struct mars_context *mars,
- uint16_t id);
+ uint16_t id,
+ int cancel);
/**
* \ingroup group_mars_workload_queue
--- a/base/include/mpu/mars/module.h
+++ b/base/include/mpu/mars/module.h
@@ -219,28 +219,14 @@ int mars_module_workload_schedule_begin(
* \ref mars_module_workload_schedule_begin to guarantee the completion of the
* initiated schedule operation.
*
+ * \param[in] id - id of workload
+ * \param[in] cancel - cancels the schedule operation
* \return
* MARS_SUCCESS - workload scheduling complete
* \n MARS_ERROR_PARAMS - invalid workload id specified
* \n MARS_ERROR_STATE - workload scheduling not started
*/
-int mars_module_workload_schedule_end(uint16_t id);
-
-/**
- * \ingroup group_mars_workload_module
- * \brief <b>[MPU]</b> Cancels scheduling of specified workload.
- *
- * This function will cancel a schedule operation previously initiated with
- * \ref mars_module_workload_schedule_begin.
- * If scheduling is canceled, \ref mars_module_workload_schedule_end should not
- * be called.
- *
- * \return
- * MARS_SUCCESS - workload scheduling canceled
- * \n MARS_ERROR_PARAMS - invalid workload id specified
- * \n MARS_ERROR_STATE - workload scheduling not started
- */
-int mars_module_workload_schedule_cancel(uint16_t id);
+int mars_module_workload_schedule_end(uint16_t id, int cancel);
/**
* \ingroup group_mars_workload_module
--- a/base/src/common/kernel_internal_types.h
+++ b/base/src/common/kernel_internal_types.h
@@ -77,8 +77,7 @@ struct mars_kernel_syscalls {
int (*workload_signal_reset)(void);
int (*workload_schedule_begin)(uint16_t id, uint8_t priority,
struct mars_workload_context **workload);
- int (*workload_schedule_end)(uint16_t id);
- int (*workload_schedule_cancel)(uint16_t id);
+ int (*workload_schedule_end)(uint16_t id, int cancel);
int (*host_signal_send)(uint64_t watch_point_ea);
int (*host_callback_set)(uint64_t callback_ea,
--- a/base/src/host/lib/workload_queue.c
+++ b/base/src/host/lib/workload_queue.c
@@ -628,21 +628,14 @@ int mars_workload_queue_add_begin(struct
}
int mars_workload_queue_add_end(struct mars_context *mars,
- uint16_t id)
+ uint16_t id,
+ int cancel)
{
return change_state(mars, id, NULL,
MARS_WORKLOAD_STATE_ADDING,
- MARS_WORKLOAD_STATE_FINISHED,
- NULL);
-}
-
-int mars_workload_queue_add_cancel(struct mars_context *mars,
- uint16_t id)
-{
- return change_state(mars, id, NULL,
- MARS_WORKLOAD_STATE_ADDING,
- MARS_WORKLOAD_STATE_NONE,
- remove_workload_module);
+ cancel ? MARS_WORKLOAD_STATE_NONE :
+ MARS_WORKLOAD_STATE_FINISHED,
+ cancel ? remove_workload_module : NULL);
}
int mars_workload_queue_remove_begin(struct mars_context *mars,
@@ -656,21 +649,14 @@ int mars_workload_queue_remove_begin(str
}
int mars_workload_queue_remove_end(struct mars_context *mars,
- uint16_t id)
-{
- return change_state(mars, id, NULL,
- MARS_WORKLOAD_STATE_REMOVING,
- MARS_WORKLOAD_STATE_NONE,
- remove_workload_module);
-}
-
-int mars_workload_queue_remove_cancel(struct mars_context *mars,
- uint16_t id)
+ uint16_t id,
+ int cancel)
{
return change_state(mars, id, NULL,
MARS_WORKLOAD_STATE_REMOVING,
- MARS_WORKLOAD_STATE_FINISHED,
- NULL);
+ cancel ? MARS_WORKLOAD_STATE_FINISHED :
+ MARS_WORKLOAD_STATE_NONE,
+ cancel ? NULL : remove_workload_module);
}
static uint64_t set_schedule_bits(uint64_t bits, uint64_t priority)
@@ -765,21 +751,14 @@ static void update_header_bits(struct ma
}
int mars_workload_queue_schedule_end(struct mars_context *mars,
- uint16_t id)
-{
- return change_state(mars, id, NULL,
- MARS_WORKLOAD_STATE_SCHEDULING,
- MARS_WORKLOAD_STATE_READY,
- update_header_bits);
-}
-
-int mars_workload_queue_schedule_cancel(struct mars_context *mars,
- uint16_t id)
+ uint16_t id,
+ int cancel)
{
return change_state(mars, id, NULL,
MARS_WORKLOAD_STATE_SCHEDULING,
- MARS_WORKLOAD_STATE_FINISHED,
- NULL);
+ cancel ? MARS_WORKLOAD_STATE_FINISHED:
+ MARS_WORKLOAD_STATE_READY,
+ cancel ? NULL : update_header_bits);
}
static int is_workload_finished(uint32_t upper, void *param)
--- a/base/src/mpu/kernel/kernel.c
+++ b/base/src/mpu/kernel/kernel.c
@@ -465,20 +465,13 @@ static void schedule_end_callback(uint16
update_header_bits(id / MARS_WORKLOAD_PER_BLOCK);
}
-static int workload_schedule_end(uint16_t id)
+static int workload_schedule_end(uint16_t id, int cancel)
{
return change_state(id,
MARS_WORKLOAD_STATE_SCHEDULING,
- MARS_WORKLOAD_STATE_READY,
- schedule_end_callback);
-}
-
-static int workload_schedule_cancel(uint16_t id)
-{
- return change_state(id,
- MARS_WORKLOAD_STATE_SCHEDULING,
- MARS_WORKLOAD_STATE_FINISHED,
- NULL);
+ cancel ? MARS_WORKLOAD_STATE_FINISHED :
+ MARS_WORKLOAD_STATE_READY,
+ cancel ? NULL : schedule_end_callback);
}
static int host_signal_send(uint64_t watch_point_ea)
@@ -585,7 +578,6 @@ static struct mars_kernel_syscalls kerne
workload_signal_reset,
workload_schedule_begin,
workload_schedule_end,
- workload_schedule_cancel,
host_signal_send,
host_callback_set,
host_callback_reset,
--- a/base/src/mpu/lib/module.S
+++ b/base/src/mpu/lib/module.S
@@ -51,15 +51,14 @@
#define workload_signal_reset 44
#define workload_schedule_begin 48
#define workload_schedule_end 52
-#define workload_schedule_cancel 56
-#define host_signal_send 60
-#define host_callback_set 64
-#define host_callback_reset 68
-#define mutex_lock_get 72
-#define mutex_unlock_put 76
-#define dma_get 80
-#define dma_put 84
-#define dma_wait 88
+#define host_signal_send 56
+#define host_callback_set 60
+#define host_callback_reset 64
+#define mutex_lock_get 68
+#define mutex_unlock_put 72
+#define dma_get 76
+#define dma_put 80
+#define dma_wait 84
/* NOTE: Value of defines must equal defines in workload_internal_types.h */
#define WORKLOAD_EXIT_STATE_READY 0x08 /* MARS_WORKLOAD_STATE_READY */
@@ -205,7 +204,7 @@ mars_module_workload_schedule_begin:
.size mars_module_workload_schedule_begin, .-mars_module_workload_schedule_begin
-/* int mars_module_workload_schedule_end(uint16_t id) */
+/* int mars_module_workload_schedule_end(uint16_t id, int cancel) */
.global mars_module_workload_schedule_end
.type mars_module_workload_schedule_end, @function
mars_module_workload_schedule_end:
@@ -214,15 +213,6 @@ mars_module_workload_schedule_end:
.size mars_module_workload_schedule_end, .-mars_module_workload_schedule_end
-/* int mars_module_workload_schedule_cancel(uint16_t id) */
-.global mars_module_workload_schedule_cancel
-.type mars_module_workload_schedule_cancel, @function
-mars_module_workload_schedule_cancel:
- il $2, workload_schedule_cancel
- br call_kernel_syscall
-.size mars_module_workload_schedule_cancel, .-mars_module_workload_schedule_cancel
-
-
/* void mars_module_workload_wait(void) */
.global mars_module_workload_wait
.type mars_module_workload_wait, @function
More information about the cbe-oss-dev
mailing list