From patchwork Wed Jun 13 02:01:22 2012 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: John Stultz X-Patchwork-Id: 9247 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 6317823E37 for ; Wed, 13 Jun 2012 02:01:49 +0000 (UTC) Received: from mail-gh0-f180.google.com (mail-gh0-f180.google.com [209.85.160.180]) by fiordland.canonical.com (Postfix) with ESMTP id 153AEA183A2 for ; Wed, 13 Jun 2012 02:01:48 +0000 (UTC) Received: by ghbz12 with SMTP id z12so33764ghb.11 for ; Tue, 12 Jun 2012 19:01:48 -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=DKMmajl/tIV8x2fgIE5wgcjmNlnGK/kPXOlOW42jYsA=; b=a2B1ZktT0WwHqQmMiHMx74mWEV8vKDw8HiVPR3Q7ZzmzDVOJdSFu7L7/LfggBlAqPE Lj1SF/PAbekWE/Uq/wL/bk+rg76EdwZ6Lgo1V3z5MwvHc97cUVkRydYXh+Tk8aeUrZIF ZgMA2chua57BUmD8xv5/kV++yd6DS5C2HiQyHKu5olaygBy/aO9CpV0nb0uKU9eNCrca TKsb18DbrbTzNhUXCm/03xNnPGE5Jd+7czTxVZ8XiwlhzKdwu1VlThw80I11m/OuIXLD NCAIGhv+MLPGykJuiUMZyTy20+JEDiJc9Pg8W7Q82+2iklIPWmI7STExHg7FMQHs5Xp2 S+QQ== Received: by 10.50.193.196 with SMTP id hq4mr9539998igc.57.1339552907949; Tue, 12 Jun 2012 19:01:47 -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 v20csp200421ibb; Tue, 12 Jun 2012 19:01:46 -0700 (PDT) Received: by 10.236.180.40 with SMTP id i28mr31177019yhm.22.1339552906478; Tue, 12 Jun 2012 19:01:46 -0700 (PDT) Received: from e2.ny.us.ibm.com (e2.ny.us.ibm.com. [32.97.182.142]) by mx.google.com with ESMTPS id v69si1676783yhl.34.2012.06.12.19.01.46 (version=TLSv1/SSLv3 cipher=OTHER); Tue, 12 Jun 2012 19:01:46 -0700 (PDT) Received-SPF: pass (google.com: domain of jstultz@us.ibm.com designates 32.97.182.142 as permitted sender) client-ip=32.97.182.142; Authentication-Results: mx.google.com; spf=pass (google.com: domain of jstultz@us.ibm.com designates 32.97.182.142 as permitted sender) smtp.mail=jstultz@us.ibm.com Received: from /spool/local by e2.ny.us.ibm.com with IBM ESMTP SMTP Gateway: Authorized Use Only! Violators will be prosecuted for from ; Tue, 12 Jun 2012 22:01:45 -0400 Received: from d01dlp02.pok.ibm.com (9.56.224.85) by e2.ny.us.ibm.com (192.168.1.102) with IBM ESMTP SMTP Gateway: Authorized Use Only! Violators will be prosecuted; Tue, 12 Jun 2012 22:01:44 -0400 Received: from d01relay05.pok.ibm.com (d01relay05.pok.ibm.com [9.56.227.237]) by d01dlp02.pok.ibm.com (Postfix) with ESMTP id 1CED86E8053; Tue, 12 Jun 2012 22:01:43 -0400 (EDT) Received: from d01av04.pok.ibm.com (d01av04.pok.ibm.com [9.56.224.64]) by d01relay05.pok.ibm.com (8.13.8/8.13.8/NCO v10.0) with ESMTP id q5D21gPx168588; Tue, 12 Jun 2012 22:01:42 -0400 Received: from d01av04.pok.ibm.com (loopback [127.0.0.1]) by d01av04.pok.ibm.com (8.14.4/8.13.1/NCO v10.0 AVout) with ESMTP id q5D21g4O016233; Tue, 12 Jun 2012 22:01:42 -0400 Received: from kernel.beaverton.ibm.com (kernel.beaverton.ibm.com [9.47.67.96]) by d01av04.pok.ibm.com (8.14.4/8.13.1/NCO v10.0 AVin) with ESMTP id q5D21fEn016126; Tue, 12 Jun 2012 22:01:42 -0400 Received: by kernel.beaverton.ibm.com (Postfix, from userid 1056) id E6658C0625; Tue, 12 Jun 2012 19:01:40 -0700 (PDT) From: John Stultz To: LKML Cc: =?UTF-8?q?Arve=20Hj=C3=B8nnev=C3=A5g?= , Russell King , Paul Gortmaker , Alexander Shishkin , Mathieu Poirier , John Stultz Subject: [PATCH 04/15] ARM: etm: Allow range selection Date: Tue, 12 Jun 2012 19:01:22 -0700 Message-Id: <1339552887-17204-5-git-send-email-john.stultz@linaro.org> X-Mailer: git-send-email 1.7.3.2.146.gca209 In-Reply-To: <1339552887-17204-1-git-send-email-john.stultz@linaro.org> References: <1339552887-17204-1-git-send-email-john.stultz@linaro.org> MIME-Version: 1.0 X-Content-Scanned: Fidelis XPS MAILER x-cbid: 12061302-5112-0000-0000-000008F6914C X-Gm-Message-State: ALoCoQm73ZLEz6cBGb+17fea4Q8mvMc0LG6WdtcO0CJFHrNa9CRdyr92ZZoWenVp2prBKtT+Rp9u From: Arve Hjønnevåg Trace kernel text segment by default as before, allow tracing of other ranges by writing a range to /sys/devices/etm/trace_range, or to trace everything by writing 0 0. CC: Russell King CC: Paul Gortmaker CC: Alexander Shishkin CC: Mathieu Poirier Acked-by: Alexander Shishkin Signed-off-by: Arve Hjønnevåg Signed-off-by: John Stultz --- arch/arm/kernel/etm.c | 49 ++++++++++++++++++++++++++++++++++++++++++++++--- 1 files changed, 46 insertions(+), 3 deletions(-) diff --git a/arch/arm/kernel/etm.c b/arch/arm/kernel/etm.c index a51bccc..bf34d34 100644 --- a/arch/arm/kernel/etm.c +++ b/arch/arm/kernel/etm.c @@ -41,12 +41,17 @@ struct tracectx { unsigned long flags; int ncmppairs; int etm_portsz; + unsigned long range_start; + unsigned long range_end; struct device *dev; struct clk *emu_clk; struct mutex mutex; }; -static struct tracectx tracer; +static struct tracectx tracer = { + .range_start = (unsigned long)_stext, + .range_end = (unsigned long)_etext, +}; static inline bool trace_isrunning(struct tracectx *t) { @@ -116,8 +121,12 @@ static int trace_start(struct tracectx *t) return -EFAULT; } - etm_setup_address_range(t, 1, (unsigned long)_stext, - (unsigned long)_etext, 0, 0); + if (t->range_start || t->range_end) + etm_setup_address_range(t, 1, + t->range_start, t->range_end, 0, 0); + else + etm_writel(t, ETMTE_INCLEXCL, ETMR_TRACEENCTRL); + etm_writel(t, 0, ETMR_TRACEENCTRL2); etm_writel(t, 0, ETMR_TRACESSCTRL); etm_writel(t, 0x6f, ETMR_TRACEENEVT); @@ -526,6 +535,35 @@ static ssize_t trace_mode_store(struct kobject *kobj, static struct kobj_attribute trace_mode_attr = __ATTR(trace_mode, 0644, trace_mode_show, trace_mode_store); +static ssize_t trace_range_show(struct kobject *kobj, + struct kobj_attribute *attr, + char *buf) +{ + return sprintf(buf, "%08lx %08lx\n", + tracer.range_start, tracer.range_end); +} + +static ssize_t trace_range_store(struct kobject *kobj, + struct kobj_attribute *attr, + const char *buf, size_t n) +{ + unsigned long range_start, range_end; + + if (sscanf(buf, "%lx %lx", &range_start, &range_end) != 2) + return -EINVAL; + + mutex_lock(&tracer.mutex); + tracer.range_start = range_start; + tracer.range_end = range_end; + mutex_unlock(&tracer.mutex); + + return n; +} + + +static struct kobj_attribute trace_range_attr = + __ATTR(trace_range, 0644, trace_range_show, trace_range_store); + static int __devinit etm_probe(struct amba_device *dev, const struct amba_id *id) { struct tracectx *t = &tracer; @@ -577,6 +615,10 @@ static int __devinit etm_probe(struct amba_device *dev, const struct amba_id *id if (ret) dev_dbg(&dev->dev, "Failed to create trace_mode in sysfs\n"); + ret = sysfs_create_file(&dev->dev.kobj, &trace_range_attr.attr); + if (ret) + dev_dbg(&dev->dev, "Failed to create trace_range in sysfs\n"); + dev_dbg(t->dev, "ETM AMBA driver initialized.\n"); out: @@ -606,6 +648,7 @@ static int etm_remove(struct amba_device *dev) sysfs_remove_file(&dev->dev.kobj, &trace_running_attr.attr); sysfs_remove_file(&dev->dev.kobj, &trace_info_attr.attr); sysfs_remove_file(&dev->dev.kobj, &trace_mode_attr.attr); + sysfs_remove_file(&dev->dev.kobj, &trace_range_attr.attr); return 0; }