From nobody Sun Dec 14 11:59:44 2025 Received: from mail-ej1-f44.google.com (mail-ej1-f44.google.com [209.85.218.44]) (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 AA9DA2F60A1 for ; Fri, 12 Dec 2025 15:33:06 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=209.85.218.44 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1765553589; cv=none; b=KOCosiXVVYQcfEvU/atDVVLWpve82SpyL473vpuWlSU6XRQHiMATGx+L4/CqxKoNn+NZY0SXWIto4WPNVjHfeddyc4ILy5k9ISSiPHgMyYV5m/2KbG985e5vKaiSXet3U2vyuB4In5Dzib6WyO/sghb0dm8XVFBx73HIgiV1N5E= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1765553589; c=relaxed/simple; bh=+yrQI73Lj/6kyvMP4ZVVuHkJzhmrKrpf7NHGZLhRzg8=; h=From:Date:Subject:MIME-Version:Content-Type:Message-Id:References: In-Reply-To:To:Cc; b=Bc6xFXRT1TUZtoXOtJwgbvseKP8IXYiNtpod6SE6aYOoIsGEV6vBgCVWevobgNpHy/4MSKkmbUIFGpq5IWCeY66dC6gVqwucfAUDNUBsnNxtbYLChE36jnWINutIUmKNzLgjhZ6wus/XGXyrpEEC1U7ZOUpcba7oOKBbjlzQc7s= 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=W1ZbJUyw; arc=none smtp.client-ip=209.85.218.44 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="W1ZbJUyw" Received: by mail-ej1-f44.google.com with SMTP id a640c23a62f3a-b76b5afdf04so250747566b.1 for ; Fri, 12 Dec 2025 07:33:06 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; t=1765553585; x=1766158385; darn=vger.kernel.org; h=cc:to:in-reply-to:references:message-id:content-transfer-encoding :mime-version:subject:date:from:from:to:cc:subject:date:message-id :reply-to; bh=HW9vySL1eLI2H1Kn0+dJzMzzH5Eo6siVgDQRHUDflG4=; b=W1ZbJUywGGe6XrUe9xd1F17131VuF0RZK5XaCYtcbgsh9MC2xCc6wYhjB17KFyTXV+ lfVhQs4On/P2uoWVOgX6smZuoi89gPl74L0REB5lM0dpHBSJEfRUxGr9/3FdFUEkwqLG 8X3KQUQcym5nViTwEN7JPFiPFkdlrFgp5/n1cSlBkvRKuIyvGhvueVTllQfCyzY8nGWr 7k1y+2ibzQcEz4nBqNYrjT1Eu9QCQ2HOHkaF67N87RFk6YvNSMrlk8se1BogOE2iyRwi QMVSPJH4yLF1kmg+0JLLT/gXwMIyowK2RHbooESqTH1iOOpYIdMvh01e6Fe9psRye6vC pF+A== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1765553585; x=1766158385; h=cc:to:in-reply-to:references:message-id:content-transfer-encoding :mime-version:subject:date:from:x-gm-gg:x-gm-message-state:from:to :cc:subject:date:message-id:reply-to; bh=HW9vySL1eLI2H1Kn0+dJzMzzH5Eo6siVgDQRHUDflG4=; b=vjoZN+auLbo4rUeQWMls2x67F/yMaO2J4A3ZXA0nysMmlQYhRhrdrtVRsZxol4OSjV dMXdXswuK8YIWmCEVDgrlau+YaQsrXknKZMmegcEpNzHLacy/P8JVmH5WU+6byPKFeGu ZPrVSckwbjDSYVxMysBb2tqULYPLAuFDNdu7+8qf1K7rQ8GR2A2vJEd2hkpDMkH+BFit LwkArY635X1dUhu9mu089nR4nU3Yl491WTmG56hQ2OMhlOKnr3jdJHouIsAZvY5n5tJA +9KmvcrwQDvqiKLW3jI5dilGWQKh28CYlLcamfnSa+kxOfp8BUQayoTvAOrQOedaSGxw 88qw== X-Forwarded-Encrypted: i=1; AJvYcCWFh4Idr+EZK3KKZcLDU7ECxXGkxDUlE7ac1eyFJWpI3KKDuQp7RJeMrPb0zEf0UtWttMrROrh4U1sKbr0=@vger.kernel.org X-Gm-Message-State: AOJu0YwF0XYEdVrnAit4wwJWO/pIXM2q2MYt5KH4lBOnWaEkRmV1XV8C OQnM+t8ncm8C/kkuFKQgVN2DYKXiVpfjJW5r/O0MkTGrInWFg9Guqr7kVPw48pizIP8= X-Gm-Gg: AY/fxX6InCcSwmtHJ04Rs/4xg8a4bfCppD2qtCmiOLo2//Bdk35TPcKIwuuvIt97HGr RQp53933eVkMDdJLu6wXAbJ2DogEktolD+jLb5aXJdaPJunT+kT7AKyB1k2UicfqBBbGlasrZ7t dAFoCehekOyM6K8tCk6898x0j9XS3wY6gg08ca3HHpS6PkgFED6OJkl7lHRx7u/J13UhUPL1e+9 NFm14qOXWIXjxpP0w9XHkKe7td62USbhpQsC5VZ/pD4tC/h59WErD576wfKXzpW1XwovSL4Kz3X qbFByTCrjuqrq8iDSECbV2a6Rit4gkwJ4Hgi4oC74feKoYvSisubG4HtQiVeVxJx6kt9Ujw0mzT 2s3/ni0+W5ys1KuDdc9KLCnqahQoU39J2KCDlOdtzsBpiWxnf/B8nRyjzVUD3oYNjU8nh84uxy4 eynG5p9dYVN8cYoscrct5t X-Google-Smtp-Source: AGHT+IFzKlUxyQ53WXrw5hS/OfPtHid1213GH5FkblCTWns2qdDPxDDyZ/WVIFJPhZGFwV5zxjVgZA== X-Received: by 2002:a17:907:d22:b0:b76:b76e:112a with SMTP id a640c23a62f3a-b7d235c7f18mr229365366b.11.1765553584541; Fri, 12 Dec 2025 07:33:04 -0800 (PST) Received: from e133063.arm.com ([130.185.218.160]) by smtp.gmail.com with ESMTPSA id 4fb4d7f45d1cf-6498210ed32sm5433234a12.29.2025.12.12.07.33.02 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 12 Dec 2025 07:33:04 -0800 (PST) From: James Clark Date: Fri, 12 Dec 2025 17:32:28 +0200 Subject: [PATCH v3 11/12] perf cs-etm: Don't hard code config attribute when configuring the event Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Type: text/plain; charset="utf-8" Content-Transfer-Encoding: quoted-printable Message-Id: <20251212-james-perf-config-bits-v3-11-aa36a4846776@linaro.org> References: <20251212-james-perf-config-bits-v3-0-aa36a4846776@linaro.org> In-Reply-To: <20251212-james-perf-config-bits-v3-0-aa36a4846776@linaro.org> To: Peter Zijlstra , Ingo Molnar , Arnaldo Carvalho de Melo , Namhyung Kim , Mark Rutland , Alexander Shishkin , Jiri Olsa , Ian Rogers , Adrian Hunter , Suzuki K Poulose , Mike Leach , John Garry , Will Deacon , Leo Yan Cc: linux-perf-users@vger.kernel.org, linux-kernel@vger.kernel.org, coresight@lists.linaro.org, linux-arm-kernel@lists.infradead.org, James Clark X-Mailer: b4 0.14.2 These instances of hard coded config attributes are used for configuring and validating the event options. Use the config attribute that's published by the driver by replacing the open coded operations with evsel__get_config_val() and evsel__set_config_if_unset(). Signed-off-by: James Clark --- tools/perf/arch/arm/util/cs-etm.c | 57 +++++++++++++++++++----------------= ---- 1 file changed, 28 insertions(+), 29 deletions(-) diff --git a/tools/perf/arch/arm/util/cs-etm.c b/tools/perf/arch/arm/util/c= s-etm.c index 4a606b1e90f227aef9915e90439b2a024eeabcfe..bfb573cb587893b7d91b92fed4c= 61f421392fbcf 100644 --- a/tools/perf/arch/arm/util/cs-etm.c +++ b/tools/perf/arch/arm/util/cs-etm.c @@ -103,13 +103,14 @@ static int cs_etm_validate_context_id(struct perf_pmu= *cs_etm_pmu, struct evsel struct perf_cpu cpu) { int err; - __u64 val; - u64 contextid =3D evsel->core.attr.config & - (perf_pmu__format_bits(cs_etm_pmu, "contextid") | - perf_pmu__format_bits(cs_etm_pmu, "contextid1") | - perf_pmu__format_bits(cs_etm_pmu, "contextid2")); + u64 ctxt, ctxt1, ctxt2; + __u64 trcidr2; =20 - if (!contextid) + evsel__get_config_val(cs_etm_pmu, evsel, "contextid", &ctxt); + evsel__get_config_val(cs_etm_pmu, evsel, "contextid1", &ctxt1); + evsel__get_config_val(cs_etm_pmu, evsel, "contextid2", &ctxt2); + + if (!ctxt && !ctxt1 && !ctxt2) return 0; =20 /* Not supported in etmv3 */ @@ -120,12 +121,11 @@ static int cs_etm_validate_context_id(struct perf_pmu= *cs_etm_pmu, struct evsel } =20 /* Get a handle on TRCIDR2 */ - err =3D cs_etm_get_ro(cs_etm_pmu, cpu, metadata_etmv4_ro[CS_ETMV4_TRCIDR2= ], &val); + err =3D cs_etm_get_ro(cs_etm_pmu, cpu, metadata_etmv4_ro[CS_ETMV4_TRCIDR2= ], &trcidr2); if (err) return err; =20 - if (contextid & - perf_pmu__format_bits(cs_etm_pmu, "contextid1")) { + if (ctxt1) { /* * TRCIDR2.CIDSIZE, bit [9-5], indicates whether contextID * tracing is supported: @@ -133,15 +133,14 @@ static int cs_etm_validate_context_id(struct perf_pmu= *cs_etm_pmu, struct evsel * 0b00100 Maximum of 32-bit Context ID size. * All other values are reserved. */ - if (BMVAL(val, 5, 9) !=3D 0x4) { + if (BMVAL(trcidr2, 5, 9) !=3D 0x4) { pr_err("%s: CONTEXTIDR_EL1 isn't supported, disable with %s/contextid1= =3D0/\n", CORESIGHT_ETM_PMU_NAME, CORESIGHT_ETM_PMU_NAME); return -EINVAL; } } =20 - if (contextid & - perf_pmu__format_bits(cs_etm_pmu, "contextid2")) { + if (ctxt2) { /* * TRCIDR2.VMIDOPT[30:29] !=3D 0 and * TRCIDR2.VMIDSIZE[14:10] =3D=3D 0b00100 (32bit virtual contextid) @@ -149,7 +148,7 @@ static int cs_etm_validate_context_id(struct perf_pmu *= cs_etm_pmu, struct evsel * virtual context id is < 32bit. * Any value of VMIDSIZE >=3D 4 (i.e, > 32bit) is fine for us. */ - if (!BMVAL(val, 29, 30) || BMVAL(val, 10, 14) < 4) { + if (!BMVAL(trcidr2, 29, 30) || BMVAL(trcidr2, 10, 14) < 4) { pr_err("%s: CONTEXTIDR_EL2 isn't supported, disable with %s/contextid2= =3D0/\n", CORESIGHT_ETM_PMU_NAME, CORESIGHT_ETM_PMU_NAME); return -EINVAL; @@ -163,10 +162,11 @@ static int cs_etm_validate_timestamp(struct perf_pmu = *cs_etm_pmu, struct evsel * struct perf_cpu cpu) { int err; - __u64 val; + u64 val; + __u64 trcidr0; =20 - if (!(evsel->core.attr.config & - perf_pmu__format_bits(cs_etm_pmu, "timestamp"))) + evsel__get_config_val(cs_etm_pmu, evsel, "timestamp", &val); + if (!val) return 0; =20 if (cs_etm_get_version(cs_etm_pmu, cpu) =3D=3D CS_ETMV3) { @@ -176,7 +176,7 @@ static int cs_etm_validate_timestamp(struct perf_pmu *c= s_etm_pmu, struct evsel * } =20 /* Get a handle on TRCIRD0 */ - err =3D cs_etm_get_ro(cs_etm_pmu, cpu, metadata_etmv4_ro[CS_ETMV4_TRCIDR0= ], &val); + err =3D cs_etm_get_ro(cs_etm_pmu, cpu, metadata_etmv4_ro[CS_ETMV4_TRCIDR0= ], &trcidr0); if (err) return err; =20 @@ -187,10 +187,9 @@ static int cs_etm_validate_timestamp(struct perf_pmu *= cs_etm_pmu, struct evsel * * 0b00110 Implementation supports a maximum timestamp of 48bits. * 0b01000 Implementation supports a maximum timestamp of 64bits. */ - val &=3D GENMASK(28, 24); - if (!val) { + trcidr0 &=3D GENMASK(28, 24); + if (!trcidr0) return -EINVAL; - } =20 return 0; } @@ -273,16 +272,20 @@ static int cs_etm_parse_snapshot_options(struct auxtr= ace_record *itr, return 0; } =20 +/* + * The sink name format "@sink_name" is used, lookup the sink by name to c= onvert + * to "sinkid=3Dsink_hash" format. + * + * If the user has already manually provided a hash then "sinkid" isn't + * overwritten. If neither are provided then the driver will pick the best= sink. + */ static int cs_etm_set_sink_attr(struct perf_pmu *pmu, struct evsel *evsel) { char msg[BUFSIZ], path[PATH_MAX], *sink; struct evsel_config_term *term; - int ret =3D -EINVAL; u32 hash; - - if (evsel->core.attr.config2 & GENMASK(31, 0)) - return 0; + int ret; =20 list_for_each_entry(term, &evsel->config_terms, list) { if (term->type !=3D EVSEL__CONFIG_TERM_DRV_CFG) @@ -305,14 +308,10 @@ static int cs_etm_set_sink_attr(struct perf_pmu *pmu, return ret; } =20 - evsel->core.attr.config2 |=3D hash; + evsel__set_config_if_unset(pmu, evsel, "sinkid", hash); return 0; } =20 - /* - * No sink was provided on the command line - allow the CoreSight - * system to look for a default - */ return 0; } =20 --=20 2.34.1