From: John Stultz <john.stultz@linaro.org>
To: LKML <linux-kernel@vger.kernel.org>
Cc: "Arve Hjønnevåg" <arve@android.com>,
"Russell King" <linux@arm.linux.org.uk>,
"Paul Gortmaker" <paul.gortmaker@windriver.com>,
"Alexander Shishkin" <alexander.shishkin@linux.intel.com>,
"Mathieu Poirier" <mathieu.poirier@linaro.org>,
"John Stultz" <john.stultz@linaro.org>
Subject: [PATCH 03/15] ARM: etm: Don't try to clear the buffer full status after reading the buffer
Date: Tue, 12 Jun 2012 19:01:21 -0700 [thread overview]
Message-ID: <1339552887-17204-4-git-send-email-john.stultz@linaro.org> (raw)
In-Reply-To: <1339552887-17204-1-git-send-email-john.stultz@linaro.org>
From: Arve Hjønnevåg <arve@android.com>
If the write address was at the end of the buffer, toggling the trace
capture bit would set the RAM-full status instead of clearing it, and
if any of the stop bits in the formatter is set toggling the trace
capture bit may not do anything.
Instead use the read position to find out if the data has already
been returned.
This also fixes the read function so it works when the trace buffer is
larger than the buffer passed in from user space. The old version
would reset the trace buffer pointers after every read, so the second
call to read would always return 0.
CC: Russell King <linux@arm.linux.org.uk>
CC: Paul Gortmaker <paul.gortmaker@windriver.com>
CC: Alexander Shishkin <alexander.shishkin@linux.intel.com>
CC: Mathieu Poirier <mathieu.poirier@linaro.org>
Acked-by: Alexander Shishkin <alexander.shishkin@linux.intel.com>
Signed-off-by: Arve Hjønnevåg <arve@android.com>
Signed-off-by: John Stultz <john.stultz@linaro.org>
---
arch/arm/kernel/etm.c | 58 ++++++++++++++++++++++---------------------------
1 files changed, 26 insertions(+), 32 deletions(-)
diff --git a/arch/arm/kernel/etm.c b/arch/arm/kernel/etm.c
index d7622f9..a51bccc 100644
--- a/arch/arm/kernel/etm.c
+++ b/arch/arm/kernel/etm.c
@@ -92,6 +92,7 @@ static int trace_start(struct tracectx *t)
etb_unlock(t);
+ etb_writel(t, 0, ETBR_WRITEADDR);
etb_writel(t, 0, ETBR_FORMATTERCTRL);
etb_writel(t, 1, ETBR_CTRL);
@@ -185,24 +186,15 @@ static int trace_stop(struct tracectx *t)
static int etb_getdatalen(struct tracectx *t)
{
u32 v;
- int rp, wp;
+ int wp;
v = etb_readl(t, ETBR_STATUS);
if (v & 1)
return t->etb_bufsz;
- rp = etb_readl(t, ETBR_READADDR);
wp = etb_readl(t, ETBR_WRITEADDR);
-
- if (rp > wp) {
- etb_writel(t, 0, ETBR_READADDR);
- etb_writel(t, 0, ETBR_WRITEADDR);
-
- return 0;
- }
-
- return wp - rp;
+ return wp;
}
/* sysrq+v will always stop the running trace and leave it at that */
@@ -235,14 +227,6 @@ static void etm_dump(void)
printk("%08x", cpu_to_be32(etb_readl(t, ETBR_READMEM)));
printk(KERN_INFO "\n--- ETB buffer end ---\n");
- /* deassert the overflow bit */
- etb_writel(t, 1, ETBR_CTRL);
- etb_writel(t, 0, ETBR_CTRL);
-
- etb_writel(t, 0, ETBR_TRIGGERCOUNT);
- etb_writel(t, 0, ETBR_READADDR);
- etb_writel(t, 0, ETBR_WRITEADDR);
-
etb_lock(t);
}
@@ -276,6 +260,10 @@ static ssize_t etb_read(struct file *file, char __user *data,
struct tracectx *t = file->private_data;
u32 first = 0;
u32 *buf;
+ int wpos;
+ int skip;
+ long wlength;
+ loff_t pos = *ppos;
mutex_lock(&t->mutex);
@@ -290,28 +278,34 @@ static ssize_t etb_read(struct file *file, char __user *data,
if (total == t->etb_bufsz)
first = etb_readl(t, ETBR_WRITEADDR);
+ if (pos > total * 4) {
+ skip = 0;
+ wpos = total;
+ } else {
+ skip = (int)pos % 4;
+ wpos = (int)pos / 4;
+ }
+ total -= wpos;
+ first = (first + wpos) % t->etb_bufsz;
+
etb_writel(t, first, ETBR_READADDR);
- length = min(total * 4, (int)len);
- buf = vmalloc(length);
+ wlength = min(total, DIV_ROUND_UP(skip + (int)len, 4));
+ length = min(total * 4 - skip, (int)len);
+ buf = vmalloc(wlength * 4);
- dev_dbg(t->dev, "ETB buffer length: %d\n", total);
+ dev_dbg(t->dev, "ETB read %ld bytes to %lld from %ld words at %d\n",
+ length, pos, wlength, first);
+ dev_dbg(t->dev, "ETB buffer length: %d\n", total + wpos);
dev_dbg(t->dev, "ETB status reg: %x\n", etb_readl(t, ETBR_STATUS));
- for (i = 0; i < length / 4; i++)
+ for (i = 0; i < wlength; i++)
buf[i] = etb_readl(t, ETBR_READMEM);
- /* the only way to deassert overflow bit in ETB status is this */
- etb_writel(t, 1, ETBR_CTRL);
- etb_writel(t, 0, ETBR_CTRL);
-
- etb_writel(t, 0, ETBR_WRITEADDR);
- etb_writel(t, 0, ETBR_READADDR);
- etb_writel(t, 0, ETBR_TRIGGERCOUNT);
-
etb_lock(t);
- length -= copy_to_user(data, buf, length);
+ length -= copy_to_user(data, (u8 *)buf + skip, length);
vfree(buf);
+ *ppos = pos + length;
out:
mutex_unlock(&t->mutex);
--
1.7.3.2.146.gca209
next prev parent reply other threads:[~2012-06-13 2:03 UTC|newest]
Thread overview: 15+ messages / expand[flat|nested] mbox.gz Atom feed top
2012-06-13 2:01 [PATCH 00/15][RFC] Android ETM driver changes John Stultz
2012-06-13 2:01 ` [PATCH 01/15] ARM: etm: Don't require clock control John Stultz
2012-06-13 8:33 ` Paul Mundt
2012-06-13 23:09 ` John Stultz
2012-06-13 2:01 ` [PATCH 02/15] ARM: etm: Don't limit tracing to only non-secure code John Stultz
2012-06-13 2:01 ` John Stultz [this message]
2012-06-13 2:01 ` [PATCH 04/15] ARM: etm: Allow range selection John Stultz
2012-06-13 2:01 ` [PATCH 05/15] ARM: etm: Configure data tracing John Stultz
2012-06-13 2:01 ` [PATCH 06/15] ARM: etm: Add some missing locks and error checks John Stultz
2012-06-13 2:01 ` [PATCH 07/15] ARM: etm: Return the entire trace buffer if it is empty after reset John Stultz
2012-06-13 2:01 ` [PATCH 08/15] ARM: etm: Support multiple ETMs/PTMs John Stultz
2012-06-13 2:01 ` [PATCH 09/15] ARM: etm: Power down etm(s) when tracing is not enabled John Stultz
2012-06-28 16:13 ` [PATCH 00/15][RFC] Android ETM driver changes Linus Walleij
2012-06-29 20:25 ` John Stultz
2012-06-20 22:47 [PATCH 00/15] " John Stultz
2012-06-20 22:47 ` [PATCH 03/15] ARM: etm: Don't try to clear the buffer full status after reading the buffer John Stultz
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=1339552887-17204-4-git-send-email-john.stultz@linaro.org \
--to=john.stultz@linaro.org \
--cc=alexander.shishkin@linux.intel.com \
--cc=arve@android.com \
--cc=linux-kernel@vger.kernel.org \
--cc=linux@arm.linux.org.uk \
--cc=mathieu.poirier@linaro.org \
--cc=paul.gortmaker@windriver.com \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox
Powered by JetHome