From patchwork Thu Dec 3 21:04:58 2015 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Mathieu Poirier X-Patchwork-Id: 7763621 Return-Path: X-Original-To: patchwork-linux-arm@patchwork.kernel.org Delivered-To: patchwork-parsemail@patchwork2.web.kernel.org Received: from mail.kernel.org (mail.kernel.org [198.145.29.136]) by patchwork2.web.kernel.org (Postfix) with ESMTP id AAE95BEEE1 for ; Thu, 3 Dec 2015 21:16:41 +0000 (UTC) Received: from mail.kernel.org (localhost [127.0.0.1]) by mail.kernel.org (Postfix) with ESMTP id D9D9620503 for ; Thu, 3 Dec 2015 21:16:40 +0000 (UTC) Received: from bombadil.infradead.org (bombadil.infradead.org [198.137.202.9]) (using TLSv1.2 with cipher AES128-GCM-SHA256 (128/128 bits)) (No client certificate requested) by mail.kernel.org (Postfix) with ESMTPS id 08FD820502 for ; Thu, 3 Dec 2015 21:16:40 +0000 (UTC) Received: from localhost ([127.0.0.1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.80.1 #2 (Red Hat Linux)) id 1a4bCm-0004zZ-C7; Thu, 03 Dec 2015 21:14:20 +0000 Received: from mail-io0-x230.google.com ([2607:f8b0:4001:c06::230]) by bombadil.infradead.org with esmtps (Exim 4.80.1 #2 (Red Hat Linux)) id 1a4b4y-0004aA-Gj for linux-arm-kernel@lists.infradead.org; Thu, 03 Dec 2015 21:06:20 +0000 Received: by ioc74 with SMTP id 74so94847172ioc.2 for ; Thu, 03 Dec 2015 13:06:00 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro-org.20150623.gappssmtp.com; s=20150623; h=from:to:cc:subject:date:message-id:in-reply-to:references; bh=ZBf/5k0Muusrmau2IBWGg7SqrlVNlfvLot9LZprMkCo=; b=wSugGWFAbfylG1H8oEE5O4ylP73uX4SnS0v1fQSk8DO0FZ1pQXcq8utl9bvaoWd7OI RoGyYHjEiVb2C9wro2O+ffuCCX/0oVanXsl8uNdw4aNPaaZhVUr62UOEYhE2Su8EPH/Z QUv9WVOrrQwE/LrqC7XHqfTBfk6+/95ExN1fFXo5zygvzgc1zPHSWaqOq7hDmlFaKEgN Qn1mKuWtqujj+ijUAPHGnAxRnCfI6DhPQ38Smvm31ljvVFMuCm962e/9mzNWyXyutsuf pma8nIMWJjB5qbVFcbPJHBW5KSQ62+IhKI/WisOD8O8ur/y8v3CGUywVs1VyHQ0rvbdT fRgA== 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=ZBf/5k0Muusrmau2IBWGg7SqrlVNlfvLot9LZprMkCo=; b=Nl7CeGwik7kgwx9CF5KTzIRHDB1KNNDaT7Vf0Vi8pLPDjgvB1hLmS/8cjAbEWEzL/m Qrpf753oXszRhQXYcOgzvPt5QSjqn6offlBDU6uBJgruXnQvY92ZLNPb0n9h7CNNMW5/ eSBEzSz4l1vWowl6b+cPkgyIZLQHGk3WM0X8ARAdetIPO8U1KOrJIURG69pBHQVO890V 9EfwdBYpcLOCaJO5Vf3efM8gORRiIxnHz1QR4o+9ry9LuXKY8sQMINfcSfAVx7dA8+Ft UAvWTOmTLZB5JsE8oYS3ZVMK2DdaAA0uhZzzrbRpLIbauE/cuV/m+M4o8lUM0SSJ2noP 7rDg== X-Gm-Message-State: ALoCoQmAyT7Pn7Mha/14v6glMaWHy+O0IlAOTlgeOm8kHhAACOKxrQMDm+r6xiTSgKb9ADSitP5E X-Received: by 10.107.14.137 with SMTP id 131mr10192937ioo.69.1449176760637; Thu, 03 Dec 2015 13:06:00 -0800 (PST) Received: from t430.cg.shawcable.net (S0106002369de4dac.cg.shawcable.net. [184.64.168.246]) by smtp.gmail.com with ESMTPSA id d81sm3615433ioj.12.2015.12.03.13.05.58 (version=TLS1_2 cipher=ECDHE-RSA-AES128-SHA bits=128/128); Thu, 03 Dec 2015 13:05:59 -0800 (PST) From: Mathieu Poirier To: gregkh@linuxfoundation.org, alexander.shishkin@linux.intel.com Subject: [PATCH V6 22/26] coresight: introducing a global trace ID function Date: Thu, 3 Dec 2015 14:04:58 -0700 Message-Id: <1449176702-13213-23-git-send-email-mathieu.poirier@linaro.org> X-Mailer: git-send-email 2.1.4 In-Reply-To: <1449176702-13213-1-git-send-email-mathieu.poirier@linaro.org> References: <1449176702-13213-1-git-send-email-mathieu.poirier@linaro.org> X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20151203_130616_842746_1C534152 X-CRM114-Status: GOOD ( 14.37 ) X-Spam-Score: -2.6 (--) X-BeenThere: linux-arm-kernel@lists.infradead.org X-Mailman-Version: 2.1.20 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: al.grant@arm.com, Mathieu Poirier , linux-doc@vger.kernel.org, fainelli@broadcom.com, linux-kernel@vger.kernel.org, tor@ti.com, mike.leach@arm.com, zhang.chunyan@linaro.org, linux-arm-kernel@lists.infradead.org MIME-Version: 1.0 Sender: "linux-arm-kernel" Errors-To: linux-arm-kernel-bounces+patchwork-linux-arm=patchwork.kernel.org@lists.infradead.org X-Spam-Status: No, score=-4.1 required=5.0 tests=BAYES_00,DKIM_SIGNED, RCVD_IN_DNSWL_MED, T_DKIM_INVALID, T_RP_MATCHES_RCVD, UNPARSEABLE_RELAY autolearn=unavailable version=3.3.1 X-Spam-Checker-Version: SpamAssassin 3.3.1 (2010-03-16) on mail.kernel.org X-Virus-Scanned: ClamAV using ClamSMTP 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(-) diff --git a/drivers/hwtracing/coresight/coresight-etm3x.c b/drivers/hwtracing/coresight/coresight-etm3x.c index 6170df1b9e59..02186b722d88 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 @@ -793,11 +794,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