Commit baf39927 authored by Jeremy Kerr's avatar Jeremy Kerr
Browse files

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
Signed-off-by: default avatarJeremy Kerr <>
parent 04ab5918
......@@ -40,6 +40,7 @@ static DECLARE_WAIT_QUEUE_HEAD(sputrace_wait);
static ktime_t sputrace_start;
static unsigned long sputrace_head, sputrace_tail;
static struct sputrace *sputrace_log;
static int sputrace_logging;
static int sputrace_used(void)
......@@ -109,24 +110,49 @@ static ssize_t sputrace_read(struct file *file, char __user *buf,
static int sputrace_open(struct inode *inode, struct file *file)
int rc;
if (sputrace_logging) {
rc = -EBUSY;
goto out;
sputrace_logging = 1;
sputrace_head = sputrace_tail = 0;
sputrace_start = ktime_get();
rc = 0;
return rc;
static int sputrace_release(struct inode *inode, struct file *file)
sputrace_logging = 0;
return 0;
static const struct file_operations sputrace_fops = {
.owner = THIS_MODULE,
.open = sputrace_open,
.read = sputrace_read,
.owner = THIS_MODULE,
.open = sputrace_open,
.read = sputrace_read,
.release = sputrace_release,
static void sputrace_log_item(const char *name, struct spu_context *ctx,
struct spu *spu)
if (!sputrace_logging) {
if (sputrace_avail() > 1) {
struct sputrace *t = sputrace_log + sputrace_head;
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment