From nobody Tue Feb 10 03:45:19 2026 Received: from mail-wr1-f52.google.com (mail-wr1-f52.google.com [209.85.221.52]) (using TLSv1.2 with cipher ECDHE-RSA-AES128-GCM-SHA256 (128/128 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 3506E171082 for ; Fri, 12 Jul 2024 10:23:24 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=209.85.221.52 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1720779805; cv=none; b=H2ochhkfdzEwAhXc7jIRRpRD+eVPYYtlbETuQyZvVYlN4FIU2nwJLeO4RZHspkd2qmGFYPUe7lvjApWjwIokK0WcPIDKKippMS9Y5vkREcCeUrOwLz2rZySqpY6DZ90MgmRfRcVYxTex+H3rZn2je3OKkCfBnKNEFFUMSxm67iY= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1720779805; c=relaxed/simple; bh=R90ilGzhlmKrnl/Tf2YBzGpAvvaGf6iqWUI2sv9es2g=; h=From:To:Cc:Subject:Date:Message-Id:In-Reply-To:References: MIME-Version; b=jvj/7RGN7zanR2xtVPWWDR+d9D0P8YUXPEy18xULqS/V+D7XOCfTvDlCXaLxBNzI+XqG53ML0akXcDQ1JTLwUlbgaABfnVsgsMdVjcESR1rrCY52wIo7YmWXx+ab8XHR3GI0IAzuu8Eua11JYp114i5PCQebJ2u6DDMEEKQrhN8= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=linaro.org; spf=pass smtp.mailfrom=linaro.org; dkim=pass (2048-bit key) header.d=linaro.org header.i=@linaro.org header.b=Sj8enpWN; arc=none smtp.client-ip=209.85.221.52 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=linaro.org Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=linaro.org Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=linaro.org header.i=@linaro.org header.b="Sj8enpWN" Received: by mail-wr1-f52.google.com with SMTP id ffacd0b85a97d-367a9ab4d81so1073529f8f.1 for ; Fri, 12 Jul 2024 03:23:24 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; t=1720779802; x=1721384602; darn=vger.kernel.org; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:from:to:cc:subject:date :message-id:reply-to; bh=dezHJ0WyvcpI5gEfWfKVPR1yIz5w0V94MRv9cOZmsu4=; b=Sj8enpWNc/IklPGIKS3ft/PIaynnE1WiT6CQf63Tzx7HUY413Sd4d5d6CYK1jnr5PE Lf06t0QSAYTRtgIvajqlyGK//eyGmUjOe6++m/fvGgB5YROQNWgieh0R0xocQEZnNIXU A4bsFc/cOy1V1wp+6Fq4TaOyxB9HpkJeDLzGgou3vaVgJE2NGLhh21qaUhr8rzSM65z3 y+TfN9Fuo5X3TN1bJoe3XlzO8NBsHdwbKXRzAF4eutAtZC5FhHPrdEDp8hKzK+JSgzOJ lCNzo4x0ShrdAisInpBDaxvg7G70nOjXNeaOygtucsiUwEb+nh18E4P9H7CwbA/mYRfQ wjGQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1720779802; x=1721384602; h=content-transfer-encoding:mime-version: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=dezHJ0WyvcpI5gEfWfKVPR1yIz5w0V94MRv9cOZmsu4=; b=l3Uq3GleaFLp6/qs0qVC25S0c56Ao4Qlm6N4TwO3g1eRBwI9hzrU3G5HK3vkOW0oBS QcR6X6Pu8AhLreNWOmS7/33oWegKXwhw0zW4h9WDRjjXOVG4hBK50nlQBfHA3ZvhYmmm heS5Nub23+jxJK5fwxFwRHCOiBcVpGig2DkjQZtQyv1UxUAxxhSfxR6t4ReSLjn8H/ZB xZDjdYiiKSBAbEiLsZEjbND7OOSK98xSU0DB7gEetVhlM5qQubReBASxlqzEia/KiPUb zMAERfckjiA3K0MrWpivN278ZtE0VaS2sS4nwhVz/hBkXKiYLVoHMrT0JGjtqtzErZgj 3LWg== X-Forwarded-Encrypted: i=1; AJvYcCXJJFuAnz48tvh+jqx9sZMTH5z2111Jg6oxpl70sAZkePcuSuxBq20bZr3UC14gjJKIg8ZHfma7MHkZIufKcu7Yy0eJas/A5dU8Nu3r X-Gm-Message-State: AOJu0Yy1+MPx8FR9DFM4gL/NC568Mb0qwRqYEvvAqJF8Ct75tpml22c7 dHsVakGKEXmHgVxdeOk0CAWPz4BQd9IQB4zSqtVIylGxDHA57qt3ZgnBy/LCbOs= X-Google-Smtp-Source: AGHT+IGlRPt4kaRHHz1KeIRpOIRcE7r5fU2p5KJTQlXxdqmYLyhNVtJcwd5simlmXBca/JPpgrLRFw== X-Received: by 2002:adf:fe4f:0:b0:367:8e59:4220 with SMTP id ffacd0b85a97d-367cea73793mr6313926f8f.24.1720779802607; Fri, 12 Jul 2024 03:23:22 -0700 (PDT) Received: from localhost.localdomain ([89.47.253.130]) by smtp.gmail.com with ESMTPSA id ffacd0b85a97d-367cde89164sm9911058f8f.63.2024.07.12.03.23.21 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 12 Jul 2024 03:23:22 -0700 (PDT) From: James Clark To: coresight@lists.linaro.org, suzuki.poulose@arm.com, gankulkarni@os.amperecomputing.com, mike.leach@linaro.org, leo.yan@linux.dev, anshuman.khandual@arm.com Cc: James Clark , James Clark , Alexander Shishkin , Maxime Coquelin , Alexandre Torgue , John Garry , Will Deacon , Peter Zijlstra , Ingo Molnar , Arnaldo Carvalho de Melo , Namhyung Kim , Mark Rutland , Jiri Olsa , Ian Rogers , Adrian Hunter , "Liang, Kan" , linux-kernel@vger.kernel.org, linux-arm-kernel@lists.infradead.org, linux-stm32@st-md-mailman.stormreply.com, linux-perf-users@vger.kernel.org Subject: [PATCH v5 16/17] coresight: Emit sink ID in the HW_ID packets Date: Fri, 12 Jul 2024 11:20:25 +0100 Message-Id: <20240712102029.3697965-17-james.clark@linaro.org> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20240712102029.3697965-1-james.clark@linaro.org> References: <20240712102029.3697965-1-james.clark@linaro.org> Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable Content-Type: text/plain; charset="utf-8" From: James Clark For Perf to be able to decode when per-sink trace IDs are used, emit the sink that's being written to for each ETM. Perf currently errors out if it sees a newer packet version so instead of bumping it, add a new minor version field. This can be used to signify new versions that have backwards compatible fields. Considering this change is only for high core count machines, it doesn't make sense to make a breaking change for everyone. Signed-off-by: James Clark Signed-off-by: James Clark Reviewed-by: Mike Leach --- drivers/hwtracing/coresight/coresight-core.c | 26 ++++++++++--------- .../hwtracing/coresight/coresight-etm-perf.c | 16 ++++++++---- drivers/hwtracing/coresight/coresight-priv.h | 1 + include/linux/coresight-pmu.h | 17 +++++++++--- 4 files changed, 39 insertions(+), 21 deletions(-) diff --git a/drivers/hwtracing/coresight/coresight-core.c b/drivers/hwtraci= ng/coresight/coresight-core.c index faf560ba8d64..c427e9344a84 100644 --- a/drivers/hwtracing/coresight/coresight-core.c +++ b/drivers/hwtracing/coresight/coresight-core.c @@ -487,23 +487,25 @@ struct coresight_device *coresight_get_sink(struct li= st_head *path) return csdev; } =20 +u32 coresight_get_sink_id(struct coresight_device *csdev) +{ + if (!csdev->ea) + return 0; + + /* + * See function etm_perf_add_symlink_sink() to know where + * this comes from. + */ + return (u32) (unsigned long) csdev->ea->var; +} + static int coresight_sink_by_id(struct device *dev, const void *data) { struct coresight_device *csdev =3D to_coresight_device(dev); - unsigned long hash; =20 if (csdev->type =3D=3D CORESIGHT_DEV_TYPE_SINK || - csdev->type =3D=3D CORESIGHT_DEV_TYPE_LINKSINK) { - - if (!csdev->ea) - return 0; - /* - * See function etm_perf_add_symlink_sink() to know where - * this comes from. - */ - hash =3D (unsigned long)csdev->ea->var; - - if ((u32)hash =3D=3D *(u32 *)data) + csdev->type =3D=3D CORESIGHT_DEV_TYPE_LINKSINK) { + if (coresight_get_sink_id(csdev) =3D=3D *(u32 *)data) return 1; } =20 diff --git a/drivers/hwtracing/coresight/coresight-etm-perf.c b/drivers/hwt= racing/coresight/coresight-etm-perf.c index 70c99f0409b2..ad6a8f4b70b6 100644 --- a/drivers/hwtracing/coresight/coresight-etm-perf.c +++ b/drivers/hwtracing/coresight/coresight-etm-perf.c @@ -460,6 +460,7 @@ static void etm_event_start(struct perf_event *event, i= nt flags) struct coresight_device *sink, *csdev =3D per_cpu(csdev_src, cpu); struct list_head *path; u64 hw_id; + u8 trace_id; =20 if (!csdev) goto fail; @@ -512,11 +513,16 @@ static void etm_event_start(struct perf_event *event,= int flags) */ if (!cpumask_test_cpu(cpu, &event_data->aux_hwid_done)) { cpumask_set_cpu(cpu, &event_data->aux_hwid_done); - hw_id =3D FIELD_PREP(CS_AUX_HW_ID_VERSION_MASK, - CS_AUX_HW_ID_CURR_VERSION); - hw_id |=3D FIELD_PREP(CS_AUX_HW_ID_TRACE_ID_MASK, - coresight_trace_id_read_cpu_id_map(cpu, - &sink->perf_sink_id_map)); + + trace_id =3D coresight_trace_id_read_cpu_id_map(cpu, &sink->perf_sink_id= _map); + + hw_id =3D FIELD_PREP(CS_AUX_HW_ID_MAJOR_VERSION_MASK, + CS_AUX_HW_ID_MAJOR_VERSION); + hw_id |=3D FIELD_PREP(CS_AUX_HW_ID_MINOR_VERSION_MASK, + CS_AUX_HW_ID_MINOR_VERSION); + hw_id |=3D FIELD_PREP(CS_AUX_HW_ID_TRACE_ID_MASK, trace_id); + hw_id |=3D FIELD_PREP(CS_AUX_HW_ID_SINK_ID_MASK, coresight_get_sink_id(s= ink)); + perf_report_aux_output_id(event, hw_id); } =20 diff --git a/drivers/hwtracing/coresight/coresight-priv.h b/drivers/hwtraci= ng/coresight/coresight-priv.h index 61a46d3bdcc8..05f891ca6b5c 100644 --- a/drivers/hwtracing/coresight/coresight-priv.h +++ b/drivers/hwtracing/coresight/coresight-priv.h @@ -148,6 +148,7 @@ int coresight_make_links(struct coresight_device *orig, struct coresight_device *target); void coresight_remove_links(struct coresight_device *orig, struct coresight_connection *conn); +u32 coresight_get_sink_id(struct coresight_device *csdev); =20 #if IS_ENABLED(CONFIG_CORESIGHT_SOURCE_ETM3X) extern int etm_readl_cp14(u32 off, unsigned int *val); diff --git a/include/linux/coresight-pmu.h b/include/linux/coresight-pmu.h index 51ac441a37c3..89b0ac0014b0 100644 --- a/include/linux/coresight-pmu.h +++ b/include/linux/coresight-pmu.h @@ -49,12 +49,21 @@ * 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 + * [39:08] - Sink ID - as reported in /sys/bus/event_source/devices/cs_etm= /sinks/ + * Added in minor version 1. + * [55:40] - Unused (SBZ) + * [59:56] - Minor Version - previously existing fields are compatible with + * all minor versions. + * [63:60] - Major Version - previously existing fields mean different thi= ngs + * in new major versions. */ #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_SINK_ID_MASK GENMASK_ULL(39, 8) =20 -#define CS_AUX_HW_ID_CURR_VERSION 0 +#define CS_AUX_HW_ID_MINOR_VERSION_MASK GENMASK_ULL(59, 56) +#define CS_AUX_HW_ID_MAJOR_VERSION_MASK GENMASK_ULL(63, 60) + +#define CS_AUX_HW_ID_MAJOR_VERSION 0 +#define CS_AUX_HW_ID_MINOR_VERSION 1 =20 #endif --=20 2.34.1