From nobody Mon Dec 1 23:02:17 2025 Received: from mail-wm1-f54.google.com (mail-wm1-f54.google.com [209.85.128.54]) (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 66DC531E0E6 for ; Wed, 26 Nov 2025 10:57:47 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=209.85.128.54 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1764154669; cv=none; b=hdrOamvN8Xpuvfo1R1aTo1gFy/IaLsuaFJX/FocNZzin0drg1Az172BwZAjDq5sw9MahDmxrSwjUvbVxP7rbaCnDF6zHF8gq4ZLWdVDvJ+80Rn38DiwIxiXza03a6VSvluhZ/1wYsY0sx+71ED+sY/o6Hfdd2vxu+nwzd/ydiqE= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1764154669; c=relaxed/simple; bh=UMG09p7aajwgYeIvV728JxOY39zfyOs7svUDvZTqzVQ=; h=From:Date:Subject:MIME-Version:Content-Type:Message-Id:References: In-Reply-To:To:Cc; b=jn7bhpLLgCHeJbdCe7T3x4bXUshcYknOmYfgmOXotoZOB/a+mNRYXPtXG4Ya8VfyTzZ0qGoBDi2FRNbIfnRvKXit3CYrGfy8uwXf/ZQOSGxUrEtyhbPh81UsZ+A7OobkOQUpTbnXoNA/sNslIBWxzEfLYFSQRRdRaLIP8mQDssE= 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=pqyXpVV1; arc=none smtp.client-ip=209.85.128.54 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="pqyXpVV1" Received: by mail-wm1-f54.google.com with SMTP id 5b1f17b1804b1-4775ae5684fso31553075e9.1 for ; Wed, 26 Nov 2025 02:57:47 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; t=1764154666; x=1764759466; 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=4eB34ho9tLNd3EJt+3+XUDw0cEApe270YLGk56wWE0A=; b=pqyXpVV1i3FjwN5QHXuGksy4qzXyFxGZF1yhvJAUzINrtDVVFk+8wQi6yOQ97xCMkR Xej7NiEPetZ5tEsQPoZz2jcZYEjy3wOoQ6dMLW3KzcGQqvEoxQxzOY6T2Obdgz6z3MMZ /xYpEnl2hpaQuGj7QP8yOEYLLeywfQdcLLkwjB5+XRFy3xTroEdiT4yHd+6iymXToY0X 9gOfvaDSV+6yZOqxi9lRFLO+WPxtW/4rmDyVF87E50YZbGOrH2l98Ta9BDfIVl1mlIq1 lHDLvE+0XblAb60B5tou8Hf+XEzIqNKH6T2//clW1ZMD8NdxByyPY4WaeSLf84ez4Pc3 fckw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1764154666; x=1764759466; 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=4eB34ho9tLNd3EJt+3+XUDw0cEApe270YLGk56wWE0A=; b=wLeD5e5mu8wcUl6XKexyWjn/MmoDCyxiTp2wcWqi6bOd0QFAFHxfVWygVcqfw7/pib PgSw9PlBLHcGHd7yHlm/NowMRI/K5e2eVHXnUHgxHMytEj3T1yK2M/znNeZc/iFiion7 ZrLETs0re6iKC1IFlTYuyC7dAf5PRBF2Y3wLjCttyH5okxEjzRMllyc4n2EzwhSaCohE qaVZCmr9/K9sFmk6QTFHYkifehJVSsHBL4XLqtRTBeT8I5XhdjaLD2gBTYCPsNNUUVxw /+ItiiEbygQjC3ilGn8jHX1SR8/+msMiPB//zeE1SEpnI6qXx2ywnMgNXhUBc+z+fMNU hU4g== X-Forwarded-Encrypted: i=1; AJvYcCVU41nRhz66enPWw62xrduPNvwy6mCKDLAkymQyAoaOGqFVA3N75htdn8zbPjPegIY/T+1On/Yk4pWuPEo=@vger.kernel.org X-Gm-Message-State: AOJu0YwZU7g3eWXAHIewUe3k8zUeXRcC5qa50bNmOnmMgAarM6KTRn2Z 9nmOipTVmYI5LGcqNH/nY2P2X9iVdq7cDd98HT+K2cW9YPZ5RoN5TfI+RpGan7usqfeHZmGIgvi 7D0yJH3U= X-Gm-Gg: ASbGnctEOOzU0BXMqr/v26GDQf5xWv6APBcObKMTRCiTDE0iLyeZc/ttzU3+DCUR0DQ opuXmLim2arZdOA1O3HIurCZ/DWXugeXpK4KOOsOJagFnnBkja3ChFdG/1H8L4yjoGtZ2XkJtA4 AUCz/DofZg4QOKH8J3pegS1pCVZ9A81DyIbBtHNKFZxUKQgj7Sj0rOiju+ak4T8WtjiABpGyRhj 15ksWEAKGfYseWP23V1gknr1Y0Xoz1nJzxa+V0OmJAE8Lt5JqBOgSC3GGqrW9IUnAxlzH0D3X4q fbUgHT1dxYvBvXCaXi1uhqXPH+Ia7YPLMxC0kpOYHzQIRb4FxEtOA2bVgubChR++pNf965Emz58 8ti/zX2aN0TO0FxdrbghJ/cenPN9gvPK1Y/ZAmO9QZxg/EFprGFwK9G8Pi7/QFSZNpiFvJBHp3X gHAOre9dcloqIECZj/jPpO X-Google-Smtp-Source: AGHT+IH2BvopeuRT0S9+xRNSYbyM4nOqRmPC8UzC4Hx7OfiHrAR6M+pqTSqQVntjYyB7HV7H6n6VHw== X-Received: by 2002:a05:600c:5491:b0:477:2f7c:314f with SMTP id 5b1f17b1804b1-477c110e391mr180110055e9.10.1764154665624; Wed, 26 Nov 2025 02:57:45 -0800 (PST) Received: from ho-tower-lan.lan ([185.48.77.170]) by smtp.gmail.com with ESMTPSA id 5b1f17b1804b1-4790ade13ddsm36991765e9.8.2025.11.26.02.57.44 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 26 Nov 2025 02:57:45 -0800 (PST) From: James Clark Date: Wed, 26 Nov 2025 10:54:33 +0000 Subject: [PATCH v7 04/13] coresight: Hide unused ETMv3 format attributes 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: <20251126-james-cs-syncfreq-v7-4-7fae5e0e5e16@linaro.org> References: <20251126-james-cs-syncfreq-v7-0-7fae5e0e5e16@linaro.org> In-Reply-To: <20251126-james-cs-syncfreq-v7-0-7fae5e0e5e16@linaro.org> To: Suzuki K Poulose , Mike Leach , Alexander Shishkin , Jonathan Corbet , Leo Yan , Randy Dunlap Cc: coresight@lists.linaro.org, linux-arm-kernel@lists.infradead.org, linux-kernel@vger.kernel.org, linux-doc@vger.kernel.org, James Clark X-Mailer: b4 0.14.0 ETMv3 only has a few attributes, and setting unused ones results in an error, so hide them to begin with. Reviewed-by: Mike Leach Signed-off-by: James Clark --- drivers/hwtracing/coresight/coresight-etm-perf.c | 37 +++++++++++++-------= ---- 1 file changed, 20 insertions(+), 17 deletions(-) diff --git a/drivers/hwtracing/coresight/coresight-etm-perf.c b/drivers/hwt= racing/coresight/coresight-etm-perf.c index 17afa0f4cdee..3805282b97e8 100644 --- a/drivers/hwtracing/coresight/coresight-etm-perf.c +++ b/drivers/hwtracing/coresight/coresight-etm-perf.c @@ -50,27 +50,23 @@ struct etm_ctxt { static DEFINE_PER_CPU(struct etm_ctxt, etm_ctxt); static DEFINE_PER_CPU(struct coresight_device *, csdev_src); =20 -/* - * The PMU formats were orignally for ETMv3.5/PTM's ETMCR 'config'; - * now take them as general formats and apply on all ETMs. - */ -PMU_FORMAT_ATTR(branch_broadcast, "config:"__stringify(ETM_OPT_BRANCH_BROA= DCAST)); PMU_FORMAT_ATTR(cycacc, "config:" __stringify(ETM_OPT_CYCACC)); -/* contextid1 enables tracing CONTEXTIDR_EL1 for ETMv4 */ -PMU_FORMAT_ATTR(contextid1, "config:" __stringify(ETM_OPT_CTXTID)); -/* contextid2 enables tracing CONTEXTIDR_EL2 for ETMv4 */ -PMU_FORMAT_ATTR(contextid2, "config:" __stringify(ETM_OPT_CTXTID2)); PMU_FORMAT_ATTR(timestamp, "config:" __stringify(ETM_OPT_TS)); PMU_FORMAT_ATTR(retstack, "config:" __stringify(ETM_OPT_RETSTK)); +PMU_FORMAT_ATTR(sinkid, "config2:0-31"); + +#if IS_ENABLED(CONFIG_CORESIGHT_SOURCE_ETM4X) +PMU_FORMAT_ATTR(branch_broadcast, "config:"__stringify(ETM_OPT_BRANCH_BROA= DCAST)); +/* contextid1 enables tracing CONTEXTIDR_EL1*/ +PMU_FORMAT_ATTR(contextid1, "config:" __stringify(ETM_OPT_CTXTID)); +/* contextid2 enables tracing CONTEXTIDR_EL2*/ +PMU_FORMAT_ATTR(contextid2, "config:" __stringify(ETM_OPT_CTXTID2)); /* preset - if sink ID is used as a configuration selector */ PMU_FORMAT_ATTR(preset, "config:0-3"); -/* Sink ID - same for all ETMs */ -PMU_FORMAT_ATTR(sinkid, "config2:0-31"); /* config ID - set if a system configuration is selected */ PMU_FORMAT_ATTR(configid, "config2:32-63"); PMU_FORMAT_ATTR(cc_threshold, "config3:0-11"); =20 - /* * contextid always traces the "PID". The PID is in CONTEXTIDR_EL1 * when the kernel is running at EL1; when the kernel is at EL2, @@ -82,27 +78,34 @@ static ssize_t format_attr_contextid_show(struct device= *dev, { int pid_fmt =3D ETM_OPT_CTXTID; =20 -#if IS_ENABLED(CONFIG_CORESIGHT_SOURCE_ETM4X) pid_fmt =3D is_kernel_in_hyp_mode() ? ETM_OPT_CTXTID2 : ETM_OPT_CTXTID; -#endif return sprintf(page, "config:%d\n", pid_fmt); } =20 static struct device_attribute format_attr_contextid =3D __ATTR(contextid, 0444, format_attr_contextid_show, NULL); +#endif =20 +/* + * ETMv3 only uses the first 3 attributes for programming itself (see + * ETM3X_SUPPORTED_OPTIONS). Sink ID is also supported for selecting a + * sink in both, but not used for configuring the ETM. The remaining + * attributes are ETMv4 specific. + */ static struct attribute *etm_config_formats_attr[] =3D { &format_attr_cycacc.attr, - &format_attr_contextid.attr, - &format_attr_contextid1.attr, - &format_attr_contextid2.attr, &format_attr_timestamp.attr, &format_attr_retstack.attr, &format_attr_sinkid.attr, +#if IS_ENABLED(CONFIG_CORESIGHT_SOURCE_ETM4X) + &format_attr_contextid.attr, + &format_attr_contextid1.attr, + &format_attr_contextid2.attr, &format_attr_preset.attr, &format_attr_configid.attr, &format_attr_branch_broadcast.attr, &format_attr_cc_threshold.attr, +#endif NULL, }; =20 --=20 2.34.1