aboutsummaryrefslogtreecommitdiffstats
path: root/arch/powerpc/platforms
diff options
context:
space:
mode:
authorJeremy Kerr <jk@ozlabs.org>2008-10-14 22:16:18 -0400
committerJeremy Kerr <jk@ozlabs.org>2008-10-20 20:12:54 -0400
commitbaf399273f2ea38e2fcbd4d0b6cc7ba7f7db43eb (patch)
tree02f5b1fcde3b32f3a64143c478c63685067d776e /arch/powerpc/platforms
parent04ab591808565f968d4406f6435090ad671ebdab (diff)
powerpc/spufs: sputrace: Only enable logging on open(), prevent multiple openers
Currently, sputrace will start logging to the event buffer before the log buffer has been open()ed. This results in a heap of "lost samples" warnings if the sputrace file hasn't yet been opened. Since the buffer is reset on open() anyway, there's no need to enable logging when no-one has opened the log. Because open clears the log, make it return EBUSY for mutliple open calls. Signed-off-by: Jeremy Kerr <jk@ozlabs.org>
Diffstat (limited to 'arch/powerpc/platforms')
-rw-r--r--arch/powerpc/platforms/cell/spufs/sputrace.c32
1 files changed, 29 insertions, 3 deletions
diff --git a/arch/powerpc/platforms/cell/spufs/sputrace.c b/arch/powerpc/platforms/cell/spufs/sputrace.c
index 92d20e993ede..50cae0cf0988 100644
--- a/arch/powerpc/platforms/cell/spufs/sputrace.c
+++ b/arch/powerpc/platforms/cell/spufs/sputrace.c
@@ -40,6 +40,7 @@ static DECLARE_WAIT_QUEUE_HEAD(sputrace_wait);
40static ktime_t sputrace_start; 40static ktime_t sputrace_start;
41static unsigned long sputrace_head, sputrace_tail; 41static unsigned long sputrace_head, sputrace_tail;
42static struct sputrace *sputrace_log; 42static struct sputrace *sputrace_log;
43static int sputrace_logging;
43 44
44static int sputrace_used(void) 45static int sputrace_used(void)
45{ 46{
@@ -109,24 +110,49 @@ static ssize_t sputrace_read(struct file *file, char __user *buf,
109 110
110static int sputrace_open(struct inode *inode, struct file *file) 111static int sputrace_open(struct inode *inode, struct file *file)
111{ 112{
113 int rc;
114
112 spin_lock(&sputrace_lock); 115 spin_lock(&sputrace_lock);
116 if (sputrace_logging) {
117 rc = -EBUSY;
118 goto out;
119 }
120
121 sputrace_logging = 1;
113 sputrace_head = sputrace_tail = 0; 122 sputrace_head = sputrace_tail = 0;
114 sputrace_start = ktime_get(); 123 sputrace_start = ktime_get();
124 rc = 0;
125
126out:
115 spin_unlock(&sputrace_lock); 127 spin_unlock(&sputrace_lock);
128 return rc;
129}
116 130
131static int sputrace_release(struct inode *inode, struct file *file)
132{
133 spin_lock(&sputrace_lock);
134 sputrace_logging = 0;
135 spin_unlock(&sputrace_lock);
117 return 0; 136 return 0;
118} 137}
119 138
120static const struct file_operations sputrace_fops = { 139static const struct file_operations sputrace_fops = {
121 .owner = THIS_MODULE, 140 .owner = THIS_MODULE,
122 .open = sputrace_open, 141 .open = sputrace_open,
123 .read = sputrace_read, 142 .read = sputrace_read,
143 .release = sputrace_release,
124}; 144};
125 145
126static void sputrace_log_item(const char *name, struct spu_context *ctx, 146static void sputrace_log_item(const char *name, struct spu_context *ctx,
127 struct spu *spu) 147 struct spu *spu)
128{ 148{
129 spin_lock(&sputrace_lock); 149 spin_lock(&sputrace_lock);
150
151 if (!sputrace_logging) {
152 spin_unlock(&sputrace_lock);
153 return;
154 }
155
130 if (sputrace_avail() > 1) { 156 if (sputrace_avail() > 1) {
131 struct sputrace *t = sputrace_log + sputrace_head; 157 struct sputrace *t = sputrace_log + sputrace_head;
132 158