summaryrefslogtreecommitdiff
path: root/arch/arm/kernel
diff options
context:
space:
mode:
authorArve Hjønnevåg <arve@android.com>2012-04-03 18:01:03 -0700
committerFrank Li <Frank.Li@freescale.com>2012-09-26 13:26:21 +0800
commit1b7aab024e897875100c331786f55902c6de565d (patch)
tree06e031fb2d6265128c3af93055d198b923adf711 /arch/arm/kernel
parent6c0b910c0e3be3015d60a149fe98e3f89c8604f5 (diff)
ARM: etm: Add sysfs entry to enable return stack if supported
Change-Id: Icb73d60324ad0ddfc3e8a450a28bb3d90c702788 Signed-off-by: Arve Hjønnevåg <arve@android.com>
Diffstat (limited to 'arch/arm/kernel')
-rw-r--r--arch/arm/kernel/etm.c51
1 files changed, 49 insertions, 2 deletions
diff --git a/arch/arm/kernel/etm.c b/arch/arm/kernel/etm.c
index ad1ee5790a0e..93d06ba0fb60 100644
--- a/arch/arm/kernel/etm.c
+++ b/arch/arm/kernel/etm.c
@@ -123,6 +123,9 @@ static int trace_start_etm(struct tracectx *t, int id)
if (t->flags & TRACER_TIMESTAMP)
v |= ETMCTRL_TIMESTAMP_EN;
+ if (t->flags & TRACER_RETURN_STACK)
+ v |= ETMCTRL_RETURN_STACK_EN;
+
etm_unlock(t, id);
etm_writel(t, id, v, ETMR_CTRL);
@@ -702,10 +705,13 @@ static ssize_t trace_branch_output_store(struct kobject *kobj,
return -EINVAL;
mutex_lock(&tracer.mutex);
- if (branch_output)
+ if (branch_output) {
tracer.flags |= TRACER_BRANCHOUTPUT;
- else
+ /* Branch broadcasting is incompatible with the return stack */
+ tracer.flags &= ~TRACER_RETURN_STACK;
+ } else {
tracer.flags &= ~TRACER_BRANCHOUTPUT;
+ }
mutex_unlock(&tracer.mutex);
return n;
@@ -715,6 +721,39 @@ static struct kobj_attribute trace_branch_output_attr =
__ATTR(trace_branch_output, 0644,
trace_branch_output_show, trace_branch_output_store);
+static ssize_t trace_return_stack_show(struct kobject *kobj,
+ struct kobj_attribute *attr,
+ char *buf)
+{
+ return sprintf(buf, "%d\n", !!(tracer.flags & TRACER_RETURN_STACK));
+}
+
+static ssize_t trace_return_stack_store(struct kobject *kobj,
+ struct kobj_attribute *attr,
+ const char *buf, size_t n)
+{
+ unsigned int return_stack;
+
+ if (sscanf(buf, "%u", &return_stack) != 1)
+ return -EINVAL;
+
+ mutex_lock(&tracer.mutex);
+ if (return_stack) {
+ tracer.flags |= TRACER_RETURN_STACK;
+ /* Return stack is incompatible with branch broadcasting */
+ tracer.flags &= ~TRACER_BRANCHOUTPUT;
+ } else {
+ tracer.flags &= ~TRACER_RETURN_STACK;
+ }
+ mutex_unlock(&tracer.mutex);
+
+ return n;
+}
+
+static struct kobj_attribute trace_return_stack_attr =
+ __ATTR(trace_return_stack, 0644,
+ trace_return_stack_show, trace_return_stack_store);
+
static ssize_t trace_timestamp_show(struct kobject *kobj,
struct kobj_attribute *attr,
char *buf)
@@ -899,6 +938,14 @@ static int __devinit etm_probe(struct amba_device *dev, const struct amba_id *id
dev_dbg(&dev->dev,
"Failed to create trace_branch_output in sysfs\n");
+ if (etmccer & ETMCCER_RETURN_STACK_IMPLEMENTED) {
+ ret = sysfs_create_file(&dev->dev.kobj,
+ &trace_return_stack_attr.attr);
+ if (ret)
+ dev_dbg(&dev->dev,
+ "Failed to create trace_return_stack in sysfs\n");
+ }
+
if (etmccer & ETMCCER_TIMESTAMPING_IMPLEMENTED) {
ret = sysfs_create_file(&dev->dev.kobj,
&trace_timestamp_attr.attr);