[Cbe-oss-dev] [PATCH 2/2] libspe2: Fix exit status of spe_context_run with events
Kazunori Asayama
asayama at sm.sony.co.jp
Fri Jul 13 17:58:50 EST 2007
The current implementation of spe_context_run in libspe2 doesn't
return correct exit status when spu_run syscall's events are enabled.
This patch fix the problem.
Signed-off-by: Kazunori Asayama <asayama at sm.sony.co.jp>
---
spebase/run.c | 55 ++++++++++++++++++++-----------------------------------
1 file changed, 20 insertions(+), 35 deletions(-)
Index: b/spebase/run.c
===================================================================
--- a/spebase/run.c 2007-07-06 16:50:31.000000000 +0900
+++ b/spebase/run.c 2007-07-06 16:56:02.000000000 +0900
@@ -218,36 +218,29 @@ do_run:
if (run_rc == -1) {
DEBUG_PRINTF("spu_run returned error %d, errno=%d\n",
run_rc, errno);
+ stopinfo->stop_reason = SPE_RUNTIME_FATAL;
+ stopinfo->result.spe_runtime_fatal = errno;
+ retval = -1;
- if (!errno && (spe->base_private->flags & SPE_EVENTS_ENABLE)) {
- /* Report asynchornous error (errno = EIO) when running
- * with SPU events enabled */
- stopinfo->stop_reason = SPE_RUNTIME_EXCEPTION;
- stopinfo->result.spe_runtime_exception = run_status;
- errno = EIO;
-
- } else {
- /* Other fatal runtime error */
- stopinfo->stop_reason = SPE_RUNTIME_FATAL;
- stopinfo->result.spe_runtime_fatal = errno;
-
- /* For isolated contexts, pass EPERM up to the
- * caller.
- */
- if (!(spe->base_private->flags & SPE_ISOLATE
- && errno == EPERM))
- errno = EFAULT;
-
- }
+ /* For isolated contexts, pass EPERM up to the
+ * caller.
+ */
+ if (!(spe->base_private->flags & SPE_ISOLATE
+ && errno == EPERM))
+ errno = EFAULT;
- freespeinfo();
- return -1;
- }
+ } else if (run_rc & SPE_SPU_INVALID_INSTR) {
+ DEBUG_PRINTF("SPU has tried to execute an invalid "
+ "instruction. %d\n", run_rc);
+ stopinfo->stop_reason = SPE_RUNTIME_ERROR;
+ stopinfo->result.spe_runtime_error = SPE_SPU_INVALID_INSTR;
+ errno = EFAULT;
+ retval = -1;
- if ((spe->base_private->flags & SPE_EVENTS_ENABLE)
- && (run_status & 0xFFF)) {
- /* Report asynchronous error if upper 16 bits of the return val
- * are set and SPU events are enabled. */
+ } else if ((spe->base_private->flags & SPE_EVENTS_ENABLE) && run_status) {
+ /* Report asynchronous error if return val are set and
+ * SPU events are enabled.
+ */
stopinfo->stop_reason = SPE_RUNTIME_EXCEPTION;
stopinfo->result.spe_runtime_exception = run_status;
stopinfo->spu_status = -1;
@@ -351,14 +344,6 @@ do_run:
errno = EIO;
retval = -1;
- } else if (run_rc & SPE_SPU_INVALID_INSTR) {
- DEBUG_PRINTF("SPU has tried to execute an invalid "
- "instruction. %d\n", run_rc);
- stopinfo->stop_reason = SPE_RUNTIME_ERROR;
- stopinfo->result.spe_runtime_error = SPE_SPU_INVALID_INSTR;
- errno = EFAULT;
- retval = -1;
-
} else if (run_rc & SPE_SPU_INVALID_CHANNEL) {
DEBUG_PRINTF("SPU has tried to access an invalid "
"channel. %d\n", run_rc);
More information about the cbe-oss-dev
mailing list