From patchwork Thu Jan 14 21:46:13 2016 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Mathieu Poirier X-Patchwork-Id: 59783 Delivered-To: patch@linaro.org Received: by 10.112.130.2 with SMTP id oa2csp153456lbb; Thu, 14 Jan 2016 13:48:53 -0800 (PST) X-Received: by 10.98.16.139 with SMTP id 11mr9679769pfq.128.1452808133478; Thu, 14 Jan 2016 13:48:53 -0800 (PST) Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id 7si11624815pfa.205.2016.01.14.13.48.53; Thu, 14 Jan 2016 13:48:53 -0800 (PST) Received-SPF: pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) client-ip=209.132.180.67; Authentication-Results: mx.google.com; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dkim=pass header.i=@linaro.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1756448AbcANVst (ORCPT + 29 others); Thu, 14 Jan 2016 16:48:49 -0500 Received: from mail-pf0-f175.google.com ([209.85.192.175]:35513 "EHLO mail-pf0-f175.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1755018AbcANVrc (ORCPT ); Thu, 14 Jan 2016 16:47:32 -0500 Received: by mail-pf0-f175.google.com with SMTP id 65so106068257pff.2 for ; Thu, 14 Jan 2016 13:47:31 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; h=from:to:cc:subject:date:message-id:in-reply-to:references; bh=ziKh+wTQUClJTAiU68Bba7UTQlhIKBpkrFYugCCPNvA=; b=fRwhipwpOiQwA4NtFQjTsNTJxnWzDqHdOFnzVzqXUTvCbp4p+Yit+kHj+Del6XQPzD 968aq7JkSQiBap6BQg7rVywn8KcnwuFlodxjXQpGCppXxu91O8aIRDiZW/ad+UJ0vwK+ 7mEC4RMU6eqqQgdGQskcug250pi/7VE6k2Y6w= X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20130820; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references; bh=ziKh+wTQUClJTAiU68Bba7UTQlhIKBpkrFYugCCPNvA=; b=ZX0XkQ1hW6cqon06smL2ezemylGdx18DyO3xKYjj9aVFusvVWuWaxi7nsDdhousHwL g/5VUMAGS4tebc2mLjA32pdYPegh/4eeh2umsiz9OuJB6U8l+SXyrZ1HM4dRGB28KwXn AlbnS63EdDhECUtClDFjZWBPOfv8lC08XpihB4Rr7oaUzDdug9gdCHgCFa5p18KnAyY9 UaaVe/m2Fc+T1o25O815bSVjK4UspQyeSym8EA5vnh6QzE9T9WpiUf7ZTXfE7SfaN7o/ qPf1Mr2/vgxcT6Mqcc5ATqxxpCipaTU8XVCGN7virSP9EKo+jMlb7D/MXPvm0x4w10VI 8DLQ== X-Gm-Message-State: ALoCoQlTbgu0dQQDOEjbqTpkpQn35rL8SFVqOy6EtzKVBUcdJCR73S+gXKuBs6ZWkAbRcr/0d2p2iwCed5ie5cTVMivcvOLcfQ== X-Received: by 10.98.68.152 with SMTP id m24mr9548199pfi.78.1452808051672; Thu, 14 Jan 2016 13:47:31 -0800 (PST) Received: from t430.cg.shawcable.net ([184.64.168.246]) by smtp.gmail.com with ESMTPSA id c87sm11383309pfj.41.2016.01.14.13.47.30 (version=TLS1_2 cipher=ECDHE-RSA-AES128-SHA bits=128/128); Thu, 14 Jan 2016 13:47:31 -0800 (PST) From: Mathieu Poirier To: linux-arm-kernel@lists.infradead.org, linux-kernel@vger.kernel.org Cc: linux-doc@vger.kernel.org, zhang.chunyan@linaro.org, mike.leach@arm.com, tor@ti.com, al.grant@arm.com, rabin@rab.in, Mathieu Poirier Subject: [PATCH V8 19/23] coresight: introducing a global trace ID function Date: Thu, 14 Jan 2016 14:46:13 -0700 Message-Id: <1452807977-8069-20-git-send-email-mathieu.poirier@linaro.org> X-Mailer: git-send-email 2.1.4 In-Reply-To: <1452807977-8069-1-git-send-email-mathieu.poirier@linaro.org> References: <1452807977-8069-1-git-send-email-mathieu.poirier@linaro.org> Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org TraceID values have to be unique for all tracers and consistent between drivers and user space. As such introducing a central function to be used whenever a traceID value is required. The patch also account for data traceIDs, which are usually I(N) + 1. Signed-off-by: Mathieu Poirier --- drivers/hwtracing/coresight/coresight-etm3x.c | 7 ++----- include/linux/coresight-pmu.h | 12 ++++++++++++ 2 files changed, 14 insertions(+), 5 deletions(-) -- 2.1.4 diff --git a/drivers/hwtracing/coresight/coresight-etm3x.c b/drivers/hwtracing/coresight/coresight-etm3x.c index 8055b2d246ad..70146865ff0d 100644 --- a/drivers/hwtracing/coresight/coresight-etm3x.c +++ b/drivers/hwtracing/coresight/coresight-etm3x.c @@ -27,6 +27,7 @@ #include #include #include +#include #include #include #include @@ -740,11 +741,7 @@ static void etm_init_arch_data(void *info) static void etm_init_trace_id(struct etm_drvdata *drvdata) { - /* - * A trace ID of value 0 is invalid, so let's start at some - * random value that fits in 7 bits and go from there. - */ - drvdata->traceid = 0x10 + drvdata->cpu; + drvdata->traceid = coresight_get_trace_id(drvdata->cpu); } static int etm_probe(struct amba_device *adev, const struct amba_id *id) diff --git a/include/linux/coresight-pmu.h b/include/linux/coresight-pmu.h index 6c5386b23b10..7d410260661b 100644 --- a/include/linux/coresight-pmu.h +++ b/include/linux/coresight-pmu.h @@ -19,9 +19,21 @@ #define _LINUX_CORESIGHT_PMU_H #define CORESIGHT_ETM_PMU_NAME "cs_etm" +#define CORESIGHT_ETM_PMU_SEED 0x10 /* ETMv3.5/PTM's ETMCR config bit */ #define ETM_OPT_CYCACC 12 #define ETM_OPT_TS 28 +static inline int coresight_get_trace_id(int cpu) +{ + /* + * A trace ID of value 0 is invalid, so let's start at some + * random value that fits in 7 bits and go from there. Since + * the common convention is to have data trace IDs be I(N) + 1, + * set instruction trace IDs as a function of the CPU number. + */ + return (CORESIGHT_ETM_PMU_SEED + (cpu * 2)); +} + #endif