From nobody Mon Dec 1 23:02:29 2025 Received: from mail-wm1-f44.google.com (mail-wm1-f44.google.com [209.85.128.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 8191F2FB990 for ; Wed, 26 Nov 2025 10:57:56 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=209.85.128.44 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1764154678; cv=none; b=aajNacmb1KXSFukj2oRArOj1RUcNF+64L4amQfvyoT6O9f9YWsRmDjw+C8f09NbKkiNh9tX0N8cwO2QlVVyCyi+aTMix1xrM7izwfDEYHocjLBNEYg102HGs2Dnrp7b/572KwuVuRvtBOMndiKGUdc4o0/oNVUW4pVEnogYl6Cg= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1764154678; c=relaxed/simple; bh=Rp3iLFIqXnrF+0pIOR1MFfkShwiH6j/y0U2d1eAux9U=; h=From:Date:Subject:MIME-Version:Content-Type:Message-Id:References: In-Reply-To:To:Cc; b=Ds6N7z7cLJAj/cA9WrqL+1RdDI15Z42XZ1uOmmViaZrALGuzWLELTfSgzIPQXEpS6PNeZ/RpSakQ1dThTWKi4FECoAzW3f/F6vySq0qncTjqn+Hv4lRnL7NPoXpcmdbnhwLE/4umqsphaLSVQ7kIJfIzrStTz//Oc8Id6qBrv9Q= 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=YiE8hWDO; arc=none smtp.client-ip=209.85.128.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="YiE8hWDO" Received: by mail-wm1-f44.google.com with SMTP id 5b1f17b1804b1-477b1cc8fb4so37552055e9.1 for ; Wed, 26 Nov 2025 02:57:56 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; t=1764154675; x=1764759475; 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=/aL0yo6fi2WmbAku9VkxCsuHLTyCNr7C/0ei4wqWf00=; b=YiE8hWDOEIyEMd3vShVlX0/sf1D6FQB0aUzZv28pjtzOZDSgJwjZW6z44IsbsMt/+0 zDmudnFj4RW51F312R98glVhctXPEGLkaCVOJ4JpE01eRinLxuIBcLbxJQQdU2OeDDsF z+kZTvxMjp4lhDCdy8kiq7soKXBEJX0btwooPssPpZHzVjipgvsHXKfTVtNLC5QX85/p xyy9lpKRk07GDfBeKBvcIBDMWrQH1bq1O3BvGxog7aYn/uKkH7vwzvTXHx6hTv9LEnfD GO5z+CKUqrnDajaH6RUus6m+rr1pOWRuzHLZykO3Uwl2AySHOcbCFPbjA2zwXTJN7t0A uBvg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1764154675; x=1764759475; 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=/aL0yo6fi2WmbAku9VkxCsuHLTyCNr7C/0ei4wqWf00=; b=dEbJD2yFw9x/SMaP7OGfdLYY9JxXFSaw87EpVi/SeeOZVArKk+1qfQCP4N3tNOVXkq OsFlskBcK97vGfBYD4R0GayPlwGXYtlhySV0Hrj9sVAI7Edu8SINeqkFdIJ0YhDNh55Q REZLLgjQX2/eVHXQY+Ava/VKxhj2uDOtGEMpb1ukiueNp1c/R7l9RnB1BBoSYvvJYtbp odL6LmfURIROO8+n6kDOY1pPcFVsrq3XKMNFqpxbMZU52+AZUDpKhHGTfYHtFK/OJZuj txa8AXjzH3juZKRyKReiUPG6xsmi7SDe+5NzYQABzA8qlaxIGyXitCugM/EgMgJMFxZa dfOg== X-Forwarded-Encrypted: i=1; AJvYcCX+Kbt4cuPBzgDhgasb97+Cn+tdH3WjH9zTpe46SHu66TV/KawNdz17dgk0bM7ZKYX53n5r98P9jX1vXOo=@vger.kernel.org X-Gm-Message-State: AOJu0Yysdrf6B166SC7MNO9X6ic6zCq3Khm4bT8evR9mY+CYTZj4E9uF HO1FXhBZRzdCW1HhSnoD4vYtj5KeLJpJVzKbqfFx8qtQPDkCRqKdXynl2Nkjl9g0Guc= X-Gm-Gg: ASbGnctlCcDdo+GfbTgrb73ghh/G6GPR7WZHDCGpIuc1Q+h8s+XG/asQM8AFLG5IrNn jU1MqL8X3wQe6ftFNHUnt2vNgEBgQ2JJ+zyFkOCCFM41/dVBcJjx8qZIxpEBWSwa+fZY31KUjsP CZInOZ2RfDqJa35R5Myfea2UADZnbwAJnrCB4lLEHdC1u3T4VxzaXheRBMCL7R/zrflrplkW7LX 0VSG/riaJZYcDbMlnk3OVxHamkdssmvljRwJRdW6NmlKDv81PkhvCK/w9sTzdL6//1Fzux90VWh TddpbA6Rd2IWAK3Mjt9j7376IDxYjBrlkRdfcHj992E2rfdbi+QOOcNOwvSaHuQhdPQkem982hD 08FsRxfiuHhRIm3cbtNQ00c4jfVvUBkZUGYE2eNP7kAnalIyQ1uo/1yL9MQZ97gidu0tA/4hShh LuXgn2hw4Ua1hps9V3w0S1 X-Google-Smtp-Source: AGHT+IGviTrM1sSe4rL++DrBqXnogXlxDeacPexepOhL2fMVFW83P2kdlvQXu27F0Wvm9C0S2kRhBA== X-Received: by 2002:a05:600c:3b11:b0:477:8ba7:fe17 with SMTP id 5b1f17b1804b1-47904ac464bmr56208955e9.7.1764154674704; Wed, 26 Nov 2025 02:57:54 -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.53 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 26 Nov 2025 02:57:54 -0800 (PST) From: James Clark Date: Wed, 26 Nov 2025 10:54:41 +0000 Subject: [PATCH v7 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: <20251126-james-cs-syncfreq-v7-12-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 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 Tested-by: Jie Gan --- 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 c7bf73c8f2d7..0129b0502726 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