Received: by 2002:a05:6358:d09b:b0:dc:cd0c:909e with SMTP id jc27csp7888180rwb; Wed, 23 Nov 2022 12:09:03 -0800 (PST) X-Google-Smtp-Source: AA0mqf5JWEGG14NnT+A1c8F126pM6WMNLKbRI7VV65DI3MUOJ+RaYjsdMK/c2qKhx+2ZvZ+cjAmc X-Received: by 2002:a65:60c9:0:b0:470:48c1:aae9 with SMTP id r9-20020a6560c9000000b0047048c1aae9mr9507057pgv.4.1669234143180; Wed, 23 Nov 2022 12:09:03 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1669234143; cv=none; d=google.com; s=arc-20160816; b=fepNRx74wN37e35MRUjSf2QtqgPXP0ctQKXvTICbBtIM4WJ3XuEeApYrBGaZXGnhjf OcYuQGERawqii4Rht2HOgMLaJXyMjCzPCv9/+OrEucWSid9HUaw4H5/YBRg9Nqz6cWu5 /RkPHqGmC760ChwqAPlVuj95VIQa2UFDWvuhyDVJP6ej9RRdlAGV8Gmp+CH/m5LSVjpj mawGQIGOk6Se27VZ1ELr8uEALCp3vTdB4UUzpIpbuH+Vs3QSUPIi8kStC9ax+Qi4r96K 79tVzGaYoqIktCK5vuPuet3upq0B0Kv89mERQkiheOyHEZc4wuye+dq00KcWmZxfxelC 4ayQ== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:references:in-reply-to:message-id:date:subject :cc:to:from:dkim-signature; bh=yRqldm/FdfNyFbQj65h6UroAtQ4UGZzHEB+lTVOfKUo=; b=b1QySja4sSv7HNKvFCCA8nvN0GrvQZYZP9yj39yMkNIqruBJ/VMwtFnnSWqrBGcpw/ ZGndGS2XAEnuta32F0aoTGrsHQ/pp5EaR2yBpOi5s/rBooKvTR9OFL88qyltksr8NEst XF9LuDGDTfewb9uPzh8u/Q2rxhoZ8tGo+d2D+GzykcSIGoDtrkJ7hrXNhcgUKEnTYdDi 7rwtstjnJh6kMRm+6ul7X1rd4+HLq+VZKemH75r/8QJNXOEveSL6NUPzF8j6i2oiSm46 pDsdFcIPUCi/v3LbJ/dap2HnUIIspy6tZsJqI60v0WTxPBA8EdS0HHulwBhUR67CUz8x ySfA== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=zYdjxfGs; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=linaro.org Return-Path: Received: from out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id b17-20020a170902ed1100b00186c3aface9si16823828pld.179.2022.11.23.12.08.51; Wed, 23 Nov 2022 12:09:03 -0800 (PST) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) client-ip=2620:137:e000::1:20; Authentication-Results: mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=zYdjxfGs; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=linaro.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S239322AbiKWTvn (ORCPT + 89 others); Wed, 23 Nov 2022 14:51:43 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:41424 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S239070AbiKWTvC (ORCPT ); Wed, 23 Nov 2022 14:51:02 -0500 Received: from mail-wr1-x42d.google.com (mail-wr1-x42d.google.com [IPv6:2a00:1450:4864:20::42d]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id AA490C2878 for ; Wed, 23 Nov 2022 11:50:36 -0800 (PST) Received: by mail-wr1-x42d.google.com with SMTP id bs21so31037050wrb.4 for ; Wed, 23 Nov 2022 11:50:36 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; h=references:in-reply-to:message-id:date:subject:cc:to:from:from:to :cc:subject:date:message-id:reply-to; bh=yRqldm/FdfNyFbQj65h6UroAtQ4UGZzHEB+lTVOfKUo=; b=zYdjxfGscIhxh6xArFzy4LgvKjYgl/BYqLtsSr8z/AagXcssbIObvxlx4mnbRdvMXs a74MMDvbjDzsZPDpvuU9TJxJNOk6STHL2rwUP/4FXwqmKiYOwfSDLqhkFRvhhAeIZCGL ejNswmM91mfKCJwtWp3HIX1bhNQp+Mq4jHedc4cAIRqMRGpEE9tHiUELY+viQ3+IzktB PAWmD2BCT/OIUgw/wwvNCY95RapbAh9jaJuvznHIxO6/8DwxH2Qe+TkUvOQpLKWWRJYn VBpAfpQh7d6j6OkeHLM/eAyCjkfPvkJdT1EVNY4Z06gq0cRpIZWdPj5lxloYIf15Rm8v 95Eg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=references:in-reply-to:message-id:date:subject:cc:to:from :x-gm-message-state:from:to:cc:subject:date:message-id:reply-to; bh=yRqldm/FdfNyFbQj65h6UroAtQ4UGZzHEB+lTVOfKUo=; b=qIEWblwKkKsgw11WEppq2vUdmZxjyxjqiD2oLAzaBI6C4D9JoZUaYV9RMeogovQDKO YWv0fO/rivoLse+LtjziTI9gdFpW19JuI3gkMm3y7xARWz/3ROxKF4GZQxBwk3IJSnjr Gm6K2JlKn9GUowwOSfHaH3zK3nuYhumvKkvv9oEBk3WgPekPEzE/LVb8EHBVtaL5mFSn I1zoD4j3TjFzTYuyNwrKO0Zf8i7rUy+PGap5v20jDFLAR30FOJrzLXFs/oRUD06XVaJj N1aNQha4k/he16Mal2woAXsr5ZemdE8lkxRghoFtlxU92a59LH9bLawSeQ6a3CQRbJND cwew== X-Gm-Message-State: ANoB5pllNnHL8782vQnmgy20X7QyH5giO5m34hMr+u3KiojkvawdreNw cux24OCftZ+DcNyFx3Y48oTucw== X-Received: by 2002:a5d:66c8:0:b0:241:eabf:3b90 with SMTP id k8-20020a5d66c8000000b00241eabf3b90mr3444720wrw.31.1669233035185; Wed, 23 Nov 2022 11:50:35 -0800 (PST) Received: from linaro.org ([2a00:23c5:6809:2201:fcbc:7b5d:8d6c:43a4]) by smtp.gmail.com with ESMTPSA id w5-20020a5d6805000000b002364c77bcacsm7267414wru.38.2022.11.23.11.50.34 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 23 Nov 2022 11:50:34 -0800 (PST) From: Mike Leach To: coresight@lists.linaro.org, linux-arm-kernel@lists.infradead.org, linux-kernel@vger.kernel.org Cc: mathieu.poirier@linaro.org, suzuki.poulose@arm.com, peterz@infradead.org, mingo@redhat.com, acme@kernel.org, linux-perf-users@vger.kernel.org, leo.yan@linaro.org, quic_jinlmao@quicinc.com, Mike Leach Subject: [PATCH v6 13/14] coresight: events: PERF_RECORD_AUX_OUTPUT_HW_ID used for Trace ID Date: Wed, 23 Nov 2022 19:50:09 +0000 Message-Id: <20221123195010.6859-14-mike.leach@linaro.org> X-Mailer: git-send-email 2.17.1 In-Reply-To: <20221123195010.6859-1-mike.leach@linaro.org> References: <20221123195010.6859-1-mike.leach@linaro.org> X-Spam-Status: No, score=-2.1 required=5.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,RCVD_IN_DNSWL_NONE, SPF_HELO_NONE,SPF_PASS autolearn=unavailable autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on lindbergh.monkeyblade.net Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Use the perf_report_aux_output_id() call to output the CoreSight trace ID and associated CPU as a PERF_RECORD_AUX_OUTPUT_HW_ID record in the perf.data file. Signed-off-by: Mike Leach Reviewed-by: Suzuki K Poulose --- drivers/hwtracing/coresight/coresight-etm-perf.c | 7 +++++++ include/linux/coresight-pmu.h | 14 ++++++++++++++ 2 files changed, 21 insertions(+) diff --git a/drivers/hwtracing/coresight/coresight-etm-perf.c b/drivers/hwtracing/coresight/coresight-etm-perf.c index bdb9ab86173a..12fff661456e 100644 --- a/drivers/hwtracing/coresight/coresight-etm-perf.c +++ b/drivers/hwtracing/coresight/coresight-etm-perf.c @@ -4,6 +4,7 @@ * Author: Mathieu Poirier */ +#include #include #include #include @@ -448,6 +449,7 @@ static void etm_event_start(struct perf_event *event, int flags) struct perf_output_handle *handle = &ctxt->handle; struct coresight_device *sink, *csdev = per_cpu(csdev_src, cpu); struct list_head *path; + u64 hw_id; if (!csdev) goto fail; @@ -493,6 +495,11 @@ static void etm_event_start(struct perf_event *event, int flags) if (source_ops(csdev)->enable(csdev, event, CS_MODE_PERF)) goto fail_disable_path; + /* output cpu / trace ID in perf record */ + hw_id = FIELD_PREP(CS_AUX_HW_ID_VERSION_MASK, CS_AUX_HW_ID_CURR_VERSION); + hw_id |= FIELD_PREP(CS_AUX_HW_ID_TRACE_ID_MASK, coresight_trace_id_read_cpu_id(cpu)); + perf_report_aux_output_id(event, hw_id); + out: /* Tell the perf core the event is alive */ event->hw.state = 0; diff --git a/include/linux/coresight-pmu.h b/include/linux/coresight-pmu.h index 624f4843453e..51ac441a37c3 100644 --- a/include/linux/coresight-pmu.h +++ b/include/linux/coresight-pmu.h @@ -7,6 +7,8 @@ #ifndef _LINUX_CORESIGHT_PMU_H #define _LINUX_CORESIGHT_PMU_H +#include + #define CORESIGHT_ETM_PMU_NAME "cs_etm" /* @@ -43,4 +45,16 @@ #define ETM4_CFG_BIT_RETSTK 12 #define ETM4_CFG_BIT_VMID_OPT 15 +/* + * Interpretation of the PERF_RECORD_AUX_OUTPUT_HW_ID payload. + * Used to associate a CPU with the CoreSight Trace ID. + * [07:00] - Trace ID - uses 8 bits to make value easy to read in file. + * [59:08] - Unused (SBZ) + * [63:60] - Version + */ +#define CS_AUX_HW_ID_TRACE_ID_MASK GENMASK_ULL(7, 0) +#define CS_AUX_HW_ID_VERSION_MASK GENMASK_ULL(63, 60) + +#define CS_AUX_HW_ID_CURR_VERSION 0 + #endif -- 2.17.1