]> git.ipfire.org Git - people/pmueller/ipfire-2.x.git/blob - src/patches/suse-2.6.27.25/patches.arch/ppc-spufs-06-Don-t-require-full-buffer-in-switch_l.patch
Updated xen patches taken from suse.
[people/pmueller/ipfire-2.x.git] / src / patches / suse-2.6.27.25 / patches.arch / ppc-spufs-06-Don-t-require-full-buffer-in-switch_l.patch
1 Subject: Don't require full buffer in switch_log read
2 From: Jeremy Kerr <jk@ozlabs.org>
3 References: 447133 - LTC50070
4
5 Currently, read() on the sputrace log will block until the read buffer
6 is full. This makes it difficult to retrieve the end of the buffer, as
7 the user will need to read with the right-sized buffer.
8
9 In a similar method as 91553a1b5e0df006a3573a88d98ee7cd48a3818a, this
10 change makes the switch_log return if there has already been data
11 read.
12
13 Signed-off-by: Jeremy Kerr <jk@ozlabs.org>
14 Signed-off-by: Olaf Hering <olh@suse.de>
15 ---
16 arch/powerpc/platforms/cell/spufs/file.c | 46 ++++++++++++++++++-------------
17 1 file changed, 27 insertions(+), 19 deletions(-)
18
19 --- a/arch/powerpc/platforms/cell/spufs/file.c
20 +++ b/arch/powerpc/platforms/cell/spufs/file.c
21 @@ -2506,30 +2506,38 @@ static ssize_t spufs_switch_log_read(str
22 char tbuf[128];
23 int width;
24
25 - if (file->f_flags & O_NONBLOCK) {
26 - if (spufs_switch_log_used(ctx) == 0) {
27 + if (spufs_switch_log_used(ctx) == 0) {
28 + if (cnt > 0) {
29 + /* If there's data ready to go, we can
30 + * just return straight away */
31 + break;
32 +
33 + } else if (file->f_flags & O_NONBLOCK) {
34 error = -EAGAIN;
35 break;
36 +
37 + } else {
38 + /* spufs_wait will drop the mutex and
39 + * re-acquire, but since we're in read(), the
40 + * file cannot be _released (and so
41 + * ctx->switch_log is stable).
42 + */
43 + error = spufs_wait(ctx->switch_log->wait,
44 + spufs_switch_log_used(ctx) > 0);
45 +
46 + /* On error, spufs_wait returns without the
47 + * state mutex held */
48 + if (error)
49 + return error;
50 +
51 + /* We may have had entries read from underneath
52 + * us while we dropped the mutex in spufs_wait,
53 + * so re-check */
54 + if (spufs_switch_log_used(ctx) == 0)
55 + continue;
56 }
57 - } else {
58 - /* spufs_wait will drop the mutex and re-acquire,
59 - * but since we're in read(), the file cannot be
60 - * _released (and so ctx->switch_log is stable).
61 - */
62 - error = spufs_wait(ctx->switch_log->wait,
63 - spufs_switch_log_used(ctx) > 0);
64 -
65 - /* On error, spufs_wait returns without the
66 - * state mutex held */
67 - if (error)
68 - return error;
69 }
70
71 - /* We may have had entries read from underneath us while we
72 - * dropped the mutex in spufs_wait, so re-check */
73 - if (ctx->switch_log->head == ctx->switch_log->tail)
74 - continue;
75 -
76 width = switch_log_sprint(ctx, tbuf, sizeof(tbuf));
77 if (width < len)
78 ctx->switch_log->tail =