From patchwork Thu Feb 18 00:52:02 2016 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Mathieu Poirier X-Patchwork-Id: 62139 Delivered-To: patch@linaro.org Received: by 10.112.43.199 with SMTP id y7csp308268lbl; Wed, 17 Feb 2016 16:53:01 -0800 (PST) X-Received: by 10.98.76.194 with SMTP id e63mr6376162pfj.9.1455756779974; Wed, 17 Feb 2016 16:52:59 -0800 (PST) Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id fk1si5385949pad.35.2016.02.17.16.52.59; Wed, 17 Feb 2016 16:52:59 -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 S1424133AbcBRAw5 (ORCPT + 30 others); Wed, 17 Feb 2016 19:52:57 -0500 Received: from mail-ob0-f178.google.com ([209.85.214.178]:34363 "EHLO mail-ob0-f178.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1423286AbcBRAwZ (ORCPT ); Wed, 17 Feb 2016 19:52:25 -0500 Received: by mail-ob0-f178.google.com with SMTP id wb13so43113457obb.1 for ; Wed, 17 Feb 2016 16:52:24 -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=5S9/UCjMOEfel55cx/sgMhLw9npADYrXvJZAaPxrE/I=; b=bLfuO5UvIHqe0gTtuR1/m9F3JCMoc6gRrSwMl1Gfs5MxjYG57UN6LiY411OZRBNndQ afWzWERduW7NeUq/GohYArNxTNlW5YCglDxRYdM6+klA1ZFYpF7IXqvZJASJOJdpDyG5 3dApMmbHB3MG0Ccnyyj9XyZX0T6LeLtqJCsac= 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=5S9/UCjMOEfel55cx/sgMhLw9npADYrXvJZAaPxrE/I=; b=SHpfKzTZqFzc5EmMGo6M+BoWdQTyqNSnIOEdQGE8emF9hSW8bMgTQrgp0vPPS+IRCJ Ct6qKxPlYxe7lREiX02UBCd2SKLnKcjLGY0QSJ1Gpaf+zUTzV1WQ9L0nEWVleNtpiBL+ UPrT4BPuiR6HINJ/X3gvm2dxDbU8djd7CY4BSTu04kz6ftnZgWzztpI2cFjQeZYwcrkO 43JTXvRLyu8VyiGadLgQNJyPwOx+SOZHBrVmF5/jpoStgfqlnOaWVMqSdQFesiVdQmde b5ckYH+J6KL/dOaXXAzOlIiiwSgKxmdJZ4vYrhg/wYuRKX9Z8E3mj2UTEUnukndYioJ7 Vikg== X-Gm-Message-State: AG10YOQCvagw1/m73ncQRYP1Y5Scu8fQvLhQos8t9kLLzPruZgq+MtcPMzPNwDurRtyWCmYV X-Received: by 10.202.219.7 with SMTP id s7mr3602848oig.46.1455756744679; Wed, 17 Feb 2016 16:52:24 -0800 (PST) Received: from t430.globalsuite.net (h58.159.185.173.static.ip.windstream.net. [173.185.159.58]) by smtp.gmail.com with ESMTPSA id gi5sm2357650obb.6.2016.02.17.16.52.23 (version=TLS1_2 cipher=ECDHE-RSA-AES128-SHA bits=128/128); Wed, 17 Feb 2016 16:52:24 -0800 (PST) From: Mathieu Poirier To: gregkh@linuxfoundation.org Cc: linux-arm-kernel@lists.infradead.org, linux-kernel@vger.kernel.org Subject: [PATCH 20/21] coresight: introducing a global trace ID function Date: Wed, 17 Feb 2016 17:52:02 -0700 Message-Id: <1455756723-8456-21-git-send-email-mathieu.poirier@linaro.org> X-Mailer: git-send-email 2.1.4 In-Reply-To: <1455756723-8456-1-git-send-email-mathieu.poirier@linaro.org> References: <1455756723-8456-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 77b37413803f..0ba1a3981373 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