From patchwork Wed Jun 20 22:47:47 2012 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: John Stultz X-Patchwork-Id: 9519 Return-Path: X-Original-To: patchwork@peony.canonical.com Delivered-To: patchwork@peony.canonical.com Received: from fiordland.canonical.com (fiordland.canonical.com [91.189.94.145]) by peony.canonical.com (Postfix) with ESMTP id 8221023E1B for ; Wed, 20 Jun 2012 22:48:17 +0000 (UTC) Received: from mail-gg0-f174.google.com (mail-gg0-f174.google.com [209.85.161.174]) by fiordland.canonical.com (Postfix) with ESMTP id 39FD4A18372 for ; Wed, 20 Jun 2012 22:48:17 +0000 (UTC) Received: by gglu4 with SMTP id u4so6842820ggl.33 for ; Wed, 20 Jun 2012 15:48:16 -0700 (PDT) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=20120113; h=x-forwarded-to:x-forwarded-for:delivered-to:received-spf:from:to:cc :subject:date:message-id:x-mailer:in-reply-to:references :mime-version:content-type:content-transfer-encoding :x-content-scanned:x-cbid:x-gm-message-state; bh=8L38+gvvkAi06hDFr5J/MYmr0zDNjuXqhmsgcWaz9eg=; b=ErCoqazaoFI2OjCIrfoIX3COyLkYqPq4VuWIwImugXUDjzZHgaukLn3Ufx6utPhIn3 HSil/jVKTpQSzgzN9yVQcSpqJdHWLe6H3gPqOgxEH9AxygNi2nfopF5zGN1XYAFte1vo cFwuiaV1MwahOSMK1LHZLYdvW6wahAvcn8CHC2wJg4eITCt2Bx1QLcfIwEShGSzWeQsr V0uZ9XvMhu5YOdhCCHQ0unT7iVLNHdC5wMbO9+pdEq5lybqNz2rbFsBAumW6EOKVKIO6 1qsq4gEZoVgS5a/wA9qBCht2VchlYglpdHfyPqOWbi6ZWtax1mxgfR9nj2iGlB2+Yn9L 2dig== Received: by 10.50.193.196 with SMTP id hq4mr5972300igc.57.1340232496342; Wed, 20 Jun 2012 15:48:16 -0700 (PDT) X-Forwarded-To: linaro-patchwork@canonical.com X-Forwarded-For: patch@linaro.org linaro-patchwork@canonical.com Delivered-To: patches@linaro.org Received: by 10.231.24.148 with SMTP id v20csp204152ibb; Wed, 20 Jun 2012 15:48:15 -0700 (PDT) Received: by 10.236.115.163 with SMTP id e23mr29424039yhh.95.1340232495141; Wed, 20 Jun 2012 15:48:15 -0700 (PDT) Received: from e3.ny.us.ibm.com (e3.ny.us.ibm.com. [32.97.182.143]) by mx.google.com with ESMTPS id f61si973748yhh.70.2012.06.20.15.48.14 (version=TLSv1/SSLv3 cipher=OTHER); Wed, 20 Jun 2012 15:48:15 -0700 (PDT) Received-SPF: neutral (google.com: 32.97.182.143 is neither permitted nor denied by best guess record for domain of john.stultz@linaro.org) client-ip=32.97.182.143; Authentication-Results: mx.google.com; spf=neutral (google.com: 32.97.182.143 is neither permitted nor denied by best guess record for domain of john.stultz@linaro.org) smtp.mail=john.stultz@linaro.org Received: from /spool/local by e3.ny.us.ibm.com with IBM ESMTP SMTP Gateway: Authorized Use Only! Violators will be prosecuted for from ; Wed, 20 Jun 2012 18:48:14 -0400 Received: from d01dlp02.pok.ibm.com (9.56.224.85) by e3.ny.us.ibm.com (192.168.1.103) with IBM ESMTP SMTP Gateway: Authorized Use Only! Violators will be prosecuted; Wed, 20 Jun 2012 18:48:11 -0400 Received: from d01relay04.pok.ibm.com (d01relay04.pok.ibm.com [9.56.227.236]) by d01dlp02.pok.ibm.com (Postfix) with ESMTP id E2D976E804A; Wed, 20 Jun 2012 18:48:10 -0400 (EDT) Received: from d03av01.boulder.ibm.com (d03av01.boulder.ibm.com [9.17.195.167]) by d01relay04.pok.ibm.com (8.13.8/8.13.8/NCO v10.0) with ESMTP id q5KMmATQ226676; Wed, 20 Jun 2012 18:48:10 -0400 Received: from d03av01.boulder.ibm.com (loopback [127.0.0.1]) by d03av01.boulder.ibm.com (8.14.4/8.13.1/NCO v10.0 AVout) with ESMTP id q5KMm99F029650; Wed, 20 Jun 2012 16:48:10 -0600 Received: from kernel.stglabs.ibm.com (kernel.stglabs.ibm.com [9.114.214.19]) by d03av01.boulder.ibm.com (8.14.4/8.13.1/NCO v10.0 AVin) with ESMTP id q5KMls2B028868; Wed, 20 Jun 2012 16:48:09 -0600 From: John Stultz To: LKML Cc: =?UTF-8?q?Arve=20Hj=C3=B8nnev=C3=A5g?= , Russell King , Paul Gortmaker , Alexander Shishkin , John Stultz Subject: [PATCH 15/15] ARM: etm: Add sysfs entry to enable return stack if supported Date: Wed, 20 Jun 2012 18:47:47 -0400 Message-Id: <1340232467-6023-16-git-send-email-john.stultz@linaro.org> X-Mailer: git-send-email 1.7.9.5 In-Reply-To: <1340232467-6023-1-git-send-email-john.stultz@linaro.org> References: <1340232467-6023-1-git-send-email-john.stultz@linaro.org> MIME-Version: 1.0 X-Content-Scanned: Fidelis XPS MAILER x-cbid: 12062022-8974-0000-0000-00000A53EBE5 X-Gm-Message-State: ALoCoQkupUcfmjXvKiW/uwfz7ubU9gQT8+zRVGXL/lprElVEZq1M0sxKyyQ1DfxiD3JW4fnKhFeY From: Arve Hjønnevåg Add sysfs entry to enable return stack if supported CC: Russell King CC: Paul Gortmaker CC: Alexander Shishkin Acked-by: Alexander Shishkin Signed-off-by: Arve Hjønnevåg Signed-off-by: John Stultz --- arch/arm/include/asm/hardware/coresight.h | 4 +++ arch/arm/kernel/etm.c | 51 +++++++++++++++++++++++++++-- 2 files changed, 53 insertions(+), 2 deletions(-) diff --git a/arch/arm/include/asm/hardware/coresight.h b/arch/arm/include/asm/hardware/coresight.h index 727ba0f..dcf74d7 100644 --- a/arch/arm/include/asm/hardware/coresight.h +++ b/arch/arm/include/asm/hardware/coresight.h @@ -20,12 +20,14 @@ #define TRACER_TRACE_DATA_BIT 3 #define TRACER_TIMESTAMP_BIT 4 #define TRACER_BRANCHOUTPUT_BIT 5 +#define TRACER_RETURN_STACK_BIT 6 #define TRACER_ACCESSED BIT(TRACER_ACCESSED_BIT) #define TRACER_RUNNING BIT(TRACER_RUNNING_BIT) #define TRACER_CYCLE_ACC BIT(TRACER_CYCLE_ACC_BIT) #define TRACER_TRACE_DATA BIT(TRACER_TRACE_DATA_BIT) #define TRACER_TIMESTAMP BIT(TRACER_TIMESTAMP_BIT) #define TRACER_BRANCHOUTPUT BIT(TRACER_BRANCHOUTPUT_BIT) +#define TRACER_RETURN_STACK BIT(TRACER_RETURN_STACK_BIT) #define TRACER_TIMEOUT 10000 @@ -62,6 +64,7 @@ #define ETMCTRL_BRANCH_OUTPUT (1 << 8) #define ETMCTRL_CYCLEACCURATE (1 << 12) #define ETMCTRL_TIMESTAMP_EN (1 << 28) +#define ETMCTRL_RETURN_STACK_EN (1 << 29) /* ETM configuration code register */ #define ETMR_CONFCODE (0x04) @@ -136,6 +139,7 @@ #define ETMIDR_VERSION_PFT_1_0 0x30 #define ETMR_CCE 0x1e8 +#define ETMCCER_RETURN_STACK_IMPLEMENTED BIT(23) #define ETMCCER_TIMESTAMPING_IMPLEMENTED BIT(22) #define ETMR_TRACEIDR 0x200 diff --git a/arch/arm/kernel/etm.c b/arch/arm/kernel/etm.c index 8e84d5c..c5fb6c9 100644 --- a/arch/arm/kernel/etm.c +++ b/arch/arm/kernel/etm.c @@ -124,6 +124,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); @@ -703,10 +706,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; @@ -716,6 +722,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) @@ -900,6 +939,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);