From patchwork Wed Nov 23 19:50:09 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Mike Leach X-Patchwork-Id: 13054255 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from bombadil.infradead.org (bombadil.infradead.org [198.137.202.133]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.lore.kernel.org (Postfix) with ESMTPS id 6AB75C433FE for ; Wed, 23 Nov 2022 20:28:08 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=lists.infradead.org; s=bombadil.20210309; h=Sender: Content-Transfer-Encoding:Content-Type:MIME-Version:List-Subscribe:List-Help: List-Post:List-Archive:List-Unsubscribe:List-Id:References:In-Reply-To: Message-Id:Date:Subject:Cc:To:From:Reply-To:Content-ID:Content-Description: Resent-Date:Resent-From:Resent-Sender:Resent-To:Resent-Cc:Resent-Message-ID: List-Owner; bh=bLhdza3xAxdxUqCdKNEOrRLe+rf/jSaf6NTIcV2xxOc=; b=gByhzN5/yM03QZ H0omk4YGSxIrpOx1Cp+afFmlr/mYVMcFHkPS/2IfoSfOWznYd3jBFiI6WTmTGVKEWIIKDclWlOya4 wQ+V0epVCTcUy3tIll2V+qIf5KXitgINvMpX11DTOhbU6CnUFzpShhoqN7BUmq5Ia72H9g/UZ4a07 LtI0HJopfw965GPTCDsT9wfxbEq5IHnLuEuqx4TY3IDHGwNQHFUBcwDTRgbqPmC+Uu/APUyz3II4d dnHjIvsHOnN1NcXTupl6iT8LWKA9Z9au6e0vz2S2MrfPVP+sEIk+TRziTqNRpq39mW9S3bcYj5BCN rm5i6AmZAi06Q5xCgf4g==; Received: from localhost ([::1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.94.2 #2 (Red Hat Linux)) id 1oxwKV-002FwQ-B8; Wed, 23 Nov 2022 20:26:47 +0000 Received: from desiato.infradead.org ([2001:8b0:10b:1:d65d:64ff:fe57:4e05]) by bombadil.infradead.org with esmtps (Exim 4.94.2 #2 (Red Hat Linux)) id 1oxwKT-002FuA-Pf for linux-arm-kernel@bombadil.infradead.org; Wed, 23 Nov 2022 20:26:45 +0000 DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=infradead.org; s=desiato.20200630; h=References:In-Reply-To:Message-Id:Date :Subject:Cc:To:From:Sender:Reply-To:MIME-Version:Content-Type: Content-Transfer-Encoding:Content-ID:Content-Description; bh=yRqldm/FdfNyFbQj65h6UroAtQ4UGZzHEB+lTVOfKUo=; b=XtwS8dCLn1qEkBUvLgGM8cALtw gQZAoS6JsgB26gPPZuCpNnEca5t2Mx5yIGstSchnilicxKSiE5WUGSsCZevNjQZO556Vj33uxoJia dSwC4IfZF0WFJAVvJiX4eHOfKr48AwcVJLO4QYzLMIOFI21AsUSXNLHmPsIZ6a97hXhLdFyKiMvpo UYnfttNK34HlsLUrFBbANdohLBVUI8j2n/iwQxyRxhcfsjMKX6wPbH1ktk6+EhLKOoS25u/TOiw91 qIHrB5R2UrqCoNK+O26pRx/F6inx4RTx9JC6ZZuEVHLYi6es6i2tmBxJh7l/Tjc7kpULgjJS9vYaj iwBGgyYA==; Received: from mail-wr1-x42c.google.com ([2a00:1450:4864:20::42c]) by desiato.infradead.org with esmtps (Exim 4.94.2 #2 (Red Hat Linux)) id 1oxvlU-003us6-Ca for linux-arm-kernel@lists.infradead.org; Wed, 23 Nov 2022 19:50:39 +0000 Received: by mail-wr1-x42c.google.com with SMTP id x5so26966040wrt.7 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=P1cvF1kWQCq6TqSd54ISTPcDfVkmMrFwV1YaZIwKHEsUnNbDP4+tTyp2HdxiR9HYze PGrEi2Hcolg0OUru+ALQiKPZ+zFD51PG6f+1XyAF7xAFoTOxLMvJe5pM+E59ek+Uy4pz j4v8/YpOSWu0nLQ4hyCSdjdnwEvY/k97Qz1lLutl0AcIUMz9XyM+F3DfqSdLbsvjxQ8s tYJNFw04vbYUI1+F2lnpKgar0PpaKQktZWBvTG5v65QFaCap5d8CipX0ZhbHfnUxtkAX 3HL+CqTEJWWcubOzi4WVYZf5OCFy5kRL1g0riWpWvj7XIFOG58+GWC1Y4p5w7Tg9ZpGO V2KQ== X-Gm-Message-State: ANoB5pktYIbQ/3JKIxc7y3lr9h07AcoAKUK8F1wa302Q+K5Pt0kV2hK/ Hif0VX7KdL0KmSNLGBG4DuiKrg== X-Google-Smtp-Source: AA0mqf7TCodPPUK8zhWOAdzPfOYVd7M7RAfUC8tzK5A1ysBZc6lp33olazjEPyxpkpMAIXRiIWs+Mg== 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-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20221123_195036_755769_0E935CDD X-CRM114-Status: GOOD ( 13.81 ) X-BeenThere: linux-arm-kernel@lists.infradead.org X-Mailman-Version: 2.1.34 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , MIME-Version: 1.0 Sender: "linux-arm-kernel" Errors-To: linux-arm-kernel-bounces+linux-arm-kernel=archiver.kernel.org@lists.infradead.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