From nobody Tue Dec 2 02:29:11 2025 Received: from mail-wm1-f43.google.com (mail-wm1-f43.google.com [209.85.128.43]) (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 485D23730D8 for ; Wed, 19 Nov 2025 16:18:32 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=209.85.128.43 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1763569114; cv=none; b=EW6yvO7j9iZ3gF3rXZ/+Fh99pFY5ktqMEgHmxeC/LepGCx/MN+jKpnnsVffeFa88lbOBxWUvAn29+utXDLuwzAq5HfuSIMkn2yaZM3mE3mby2myjbrx/J7dmpT2uDMjhXqxKzB81AROJUiX83IIhlPG6mVwkH98KUdjSyM3MGQc= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1763569114; c=relaxed/simple; bh=NnmS95dIHybC4skUiX6A9lTrG4BjKAs84lg0zH2yXbs=; h=From:Date:Subject:MIME-Version:Content-Type:Message-Id:References: In-Reply-To:To:Cc; b=KAplHNJGtbuw0J9ysfpiBTUsrFeSvcsQBbfoQ3kR/xLKH5pZNm8vGOO1PjxPIvipcB5Ea3XUvosEmh4xVNnCMltnh18AlO3Iq84vetbh8gnJEG7Eo+w7O/wADvWFvIzLPYYI8envcuT1m+CaYHHOcTZQ9W75IHdE9xHQM+HKRJo= 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=HmtZlCW8; arc=none smtp.client-ip=209.85.128.43 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="HmtZlCW8" Received: by mail-wm1-f43.google.com with SMTP id 5b1f17b1804b1-477770019e4so72359735e9.3 for ; Wed, 19 Nov 2025 08:18:31 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; t=1763569110; x=1764173910; 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=1J9cD8iib5vPgkzAOKKPeHwOoJIQqK3mSiazT8xg6Hc=; b=HmtZlCW8IuHUOByPvYeelPKhZS7fRAiGlOCzMOj6VMapAn7Mi3dRe0rYjlE+jnMXhr imBdLpxLX207FKTmzNUUZ4JDkKMsenoA5aysX/nMFRl7VrbihmAF6CFco13CdJG4p5jX ZbVr01dV5YOKinBtjem9CkkAtqyw+a6euxocABTVk/WQXNRvSdWrO01ezkZjqfMRfPyu 6+f+bd2nXyRIjsEIFuciHMX2jxKaWbaROoVLHsONJg8KUGentxFLAx8aR1ZHb+L5Dizg P/wEPC0ugxKBUUUmbb9bWLKuKrAvoUfaWNxNvrDwQT1sXqY9mBqFNV64t9AVsPTfosA1 bomg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1763569110; x=1764173910; 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=1J9cD8iib5vPgkzAOKKPeHwOoJIQqK3mSiazT8xg6Hc=; b=QgMWqy+fDcWIPjxS6/+hJYxMU5v6KDeZVI2BAjUZ99g4ve2xVzHmxkYMxBUXf/PAAa iAyTeHU92vw8KGLsc34kNdseu97uArmtzJgcoBl/ptdY4H0ZLStKCxiwbhJV+rcx+3ZC pOHi7XvIMXvdbSHIjjrjMzsxGza1eRnFhJ6WVEhgwuZLb6gkHq6CVBCSkeR1gP+pfShg oTvs5vHecwTZ1U75LhYFO4w+voM4XBEqUTdpl6Syop2gILR53scUf2PMqAEVqhzpYu+/ GP9hfmFtLXHc4cwac0354RvKk4EeC5c9jAox6UXtcwelWWVaqeWeT9sUpPrmd0ZDzPLm cBOA== X-Forwarded-Encrypted: i=1; AJvYcCXXxlQLUtLKaGp86mAHPoWVaYsVDaj7r1bRZejIBd/xbWH0Tl6kIyuM9jKX+vufSeoH8GakHqx+ByShC7U=@vger.kernel.org X-Gm-Message-State: AOJu0YxvpLpflBGlOtFixrQRHk+J27rcFvotVXsWLH4Zk00r6zCZiVpj BkhfjFcbQhAcJ+5poxvdJZ0SPZ4BqbvJ+jTEoEUhQRdH9nabj5ZYe/l+ITQbRnYOg9g= X-Gm-Gg: ASbGncua8644OFkH5flTmiUSnCR6SNk/H9D4ZUBRepskskl8xLCOqf3jAz26Jftnz26 wupkx0s++xiW7ToRZOFEhBfkF7FQGWcocacBCxZvxJ40KyCgfAhjI60uLUyOo5Kjtmuz+mI8tX2 ooXTvdiiotuYxoL3ehxlfaLyXp5NehcfrGWwzlvEE59E2rizlM0lSLHsU+yvTxOzekiCgzZGtUv ua4TTWcYRKaK58lJcORxC3EbCrJQ4oh1p2hI2r304oeyDXDBz4OwhykGMJthJn4kTATXLtzInqI zcA5OvOclRl05x/1me227bDByZ2io09/1aqdsrI8KMGwx2Q1N+eGcmuYcK4K9YcFv0XEBirmQdg qhqjCsQjQ8i6dbL4P3hk2MaW3gSeebJsSV1uK4uVS+TJAv1Lb9RzjTS4/F8nSrjemEyWG6afLjQ XBJBKIFqun6/X/ceBbNeNv X-Google-Smtp-Source: AGHT+IHM6yKtwK40W5LgZNymtrK6A18IlWWcGf9RLGOtTtAdPxJ7lod3/117k5kVxzXBlztAnW+0mQ== X-Received: by 2002:a05:600c:1f10:b0:477:8b77:155e with SMTP id 5b1f17b1804b1-4778fe4a046mr196974135e9.15.1763569110327; Wed, 19 Nov 2025 08:18:30 -0800 (PST) Received: from ho-tower-lan.lan ([185.48.77.170]) by smtp.gmail.com with ESMTPSA id 5b1f17b1804b1-477b10142d3sm63205425e9.5.2025.11.19.08.18.29 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 19 Nov 2025 08:18:30 -0800 (PST) From: James Clark Date: Wed, 19 Nov 2025 16:18:08 +0000 Subject: [PATCH v6 12/13] coresight: Allow setting the timestamp interval 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: <20251119-james-cs-syncfreq-v6-12-740d24a29e51@linaro.org> References: <20251119-james-cs-syncfreq-v6-0-740d24a29e51@linaro.org> In-Reply-To: <20251119-james-cs-syncfreq-v6-0-740d24a29e51@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 Timestamps are currently emitted at the maximum rate possible, which is much too frequent for most use cases. Set the interval using the value from the timestamp field. Granular control is not required, so save space in the config by interpreting it as 2 ^ timestamp. And then 4 bits (0 - 15) is enough to set the interval to be larger than the existing SYNC timestamp interval. No sysfs mode support is needed for this attribute because counter generated timestamps are only configured for Perf mode. Reviewed-by: Leo Yan Tested-by: Leo Yan Signed-off-by: James Clark --- drivers/hwtracing/coresight/coresight-etm-perf.h | 1 + drivers/hwtracing/coresight/coresight-etm4x-core.c | 28 +++++++++++++++---= ---- 2 files changed, 20 insertions(+), 9 deletions(-) diff --git a/drivers/hwtracing/coresight/coresight-etm-perf.h b/drivers/hwt= racing/coresight/coresight-etm-perf.h index 24d929428633..128f80bb1443 100644 --- a/drivers/hwtracing/coresight/coresight-etm-perf.h +++ b/drivers/hwtracing/coresight/coresight-etm-perf.h @@ -7,6 +7,7 @@ #ifndef _CORESIGHT_ETM_PERF_H #define _CORESIGHT_ETM_PERF_H =20 +#include #include #include "coresight-priv.h" =20 diff --git a/drivers/hwtracing/coresight/coresight-etm4x-core.c b/drivers/h= wtracing/coresight/coresight-etm4x-core.c index cfd6d2b7bc50..a91981a651e7 100644 --- a/drivers/hwtracing/coresight/coresight-etm4x-core.c +++ b/drivers/hwtracing/coresight/coresight-etm4x-core.c @@ -651,7 +651,7 @@ static void etm4_enable_sysfs_smp_call(void *info) * +--------------+ * | * +------v-------+ - * | Counter x | (reload to 1 on underflow) + * | Counter x | (reload to 2 ^ timestamp on underflow) * +--------------+ * | * +------v--------------+ @@ -662,11 +662,25 @@ static void etm4_enable_sysfs_smp_call(void *info) * | Timestamp Generator | (timestamp on resource y) * +----------------------+ */ -static int etm4_config_timestamp_event(struct etmv4_drvdata *drvdata) +static int etm4_config_timestamp_event(struct etmv4_drvdata *drvdata, + struct perf_event_attr *attr) { int ctridx; int rselector; struct etmv4_config *config =3D &drvdata->config; + struct perf_event_attr max_timestamp =3D { + .ATTR_CFG_FLD_timestamp_CFG =3D U64_MAX, + }; + + /* timestamp may be 0 if deprecated_timestamp is used, so make min 1 */ + u8 ts_level =3D max(1, ATTR_CFG_GET_FLD(attr, timestamp)); + + /* + * Disable counter generated timestamps when timestamp =3D=3D MAX. Leave + * only SYNC timestamps. + */ + if (ts_level =3D=3D ATTR_CFG_GET_FLD(&max_timestamp, timestamp)) + return 0; =20 /* No point in trying if we don't have at least one counter */ if (!drvdata->nr_cntr) @@ -704,12 +718,8 @@ static int etm4_config_timestamp_event(struct etmv4_dr= vdata *drvdata) return -ENOSPC; } =20 - /* - * Initialise original and reload counter value to the smallest - * possible value in order to get as much precision as we can. - */ - config->cntr_val[ctridx] =3D 1; - config->cntrldvr[ctridx] =3D 1; + /* Initialise original and reload counter value. */ + config->cntr_val[ctridx] =3D config->cntrldvr[ctridx] =3D 1 << (ts_level = - 1); =20 /* * Trace Counter Control Register TRCCNTCTLRn @@ -799,7 +809,7 @@ static int etm4_parse_event_config(struct coresight_dev= ice *csdev, * order to correlate instructions executed on different CPUs * (CPU-wide trace scenarios). */ - ret =3D etm4_config_timestamp_event(drvdata); + ret =3D etm4_config_timestamp_event(drvdata, attr); =20 /* * No need to go further if timestamp intervals can't --=20 2.34.1