[Cbe-oss-dev] [PATCH 1/2] spufs: Fix lost events in poll/epoll on mfc

Kazunori Asayama asayama at sm.sony.co.jp
Thu Jun 21 20:58:03 EST 2007


When waiting for I/O events on mfc in an SPU context by using
poll/epoll syscalls, some of the events can be lost because of wrong
order of poll_wait and MFC status checks in the spufs_mfc_poll
function and non-atomic update of tagwait. Here is a patch to fix the
problem.

Signed-off-by: Kazunori Asayama <asayama at sm.sony.co.jp>

---
 arch/powerpc/platforms/cell/spufs/file.c |    9 +++++----
 1 file changed, 5 insertions(+), 4 deletions(-)

Index: b/arch/powerpc/platforms/cell/spufs/file.c
===================================================================
--- a/arch/powerpc/platforms/cell/spufs/file.c	2007-06-19 11:15:19.000000000 +0900
+++ b/arch/powerpc/platforms/cell/spufs/file.c	2007-06-20 11:09:59.000000000 +0900
@@ -1497,14 +1497,15 @@ static ssize_t spufs_mfc_write(struct fi
 		if (status)
 			ret = status;
 	}
-	spu_release(ctx);
 
 	if (ret)
-		goto out;
+		goto out_unlock;
 
 	ctx->tagwait |= 1 << cmd.tag;
 	ret = size;
 
+out_unlock:
+	spu_release(ctx);
 out:
 	return ret;
 }
@@ -1515,14 +1516,14 @@ static unsigned int spufs_mfc_poll(struc
 	u32 free_elements, tagstatus;
 	unsigned int mask;
 
+	poll_wait(file, &ctx->mfc_wq, wait);
+
 	spu_acquire(ctx);
 	ctx->ops->set_mfc_query(ctx, ctx->tagwait, 2);
 	free_elements = ctx->ops->get_mfc_free_elements(ctx);
 	tagstatus = ctx->ops->read_mfc_tagstatus(ctx);
 	spu_release(ctx);
 
-	poll_wait(file, &ctx->mfc_wq, wait);
-
 	mask = 0;
 	if (free_elements & 0xffff)
 		mask |= POLLOUT | POLLWRNORM;



More information about the cbe-oss-dev mailing list