From 5a74228287be661b1b8f1667c9d657345e7f49ae Mon Sep 17 00:00:00 2001 From: Jeremy Kerr Date: Thu, 16 Oct 2008 10:51:46 +1100 Subject: [PATCH] --- yaml --- r: 116915 b: refs/heads/master c: 14f693eeb5b16bc47ffa38d8b8838a654aedd53f h: refs/heads/master i: 116913: 0c75b18f808253a8736d9c619c8e9f197ff0ea5b 116911: 28ce50b651eb1dc9cd674eeffc67dfe2c422e78b v: v3 --- [refs] | 2 +- .../arch/powerpc/platforms/cell/spufs/file.c | 46 +++++++++++-------- 2 files changed, 28 insertions(+), 20 deletions(-) diff --git a/[refs] b/[refs] index 52feabf066b0..dbc33705c9b5 100644 --- a/[refs] +++ b/[refs] @@ -1,2 +1,2 @@ --- -refs/heads/master: f5ed0eb6fe131e8f3847323b4aa569a6f7b36f56 +refs/heads/master: 14f693eeb5b16bc47ffa38d8b8838a654aedd53f diff --git a/trunk/arch/powerpc/platforms/cell/spufs/file.c b/trunk/arch/powerpc/platforms/cell/spufs/file.c index adb5abb9af5d..f139cd8b594d 100644 --- a/trunk/arch/powerpc/platforms/cell/spufs/file.c +++ b/trunk/arch/powerpc/platforms/cell/spufs/file.c @@ -2503,30 +2503,38 @@ static ssize_t spufs_switch_log_read(struct file *file, char __user *buf, char tbuf[128]; int width; - if (file->f_flags & O_NONBLOCK) { - if (spufs_switch_log_used(ctx) == 0) { + if (spufs_switch_log_used(ctx) == 0) { + if (cnt > 0) { + /* If there's data ready to go, we can + * just return straight away */ + break; + + } else if (file->f_flags & O_NONBLOCK) { error = -EAGAIN; break; + + } else { + /* spufs_wait will drop the mutex and + * re-acquire, but since we're in read(), the + * file cannot be _released (and so + * ctx->switch_log is stable). + */ + error = spufs_wait(ctx->switch_log->wait, + spufs_switch_log_used(ctx) > 0); + + /* On error, spufs_wait returns without the + * state mutex held */ + if (error) + return error; + + /* We may have had entries read from underneath + * us while we dropped the mutex in spufs_wait, + * so re-check */ + if (spufs_switch_log_used(ctx) == 0) + continue; } - } else { - /* spufs_wait will drop the mutex and re-acquire, - * but since we're in read(), the file cannot be - * _released (and so ctx->switch_log is stable). - */ - error = spufs_wait(ctx->switch_log->wait, - spufs_switch_log_used(ctx) > 0); - - /* On error, spufs_wait returns without the - * state mutex held */ - if (error) - return error; } - /* We may have had entries read from underneath us while we - * dropped the mutex in spufs_wait, so re-check */ - if (ctx->switch_log->head == ctx->switch_log->tail) - continue; - width = switch_log_sprint(ctx, tbuf, sizeof(tbuf)); if (width < len) ctx->switch_log->tail =