From nobody Tue Dec 2 02:20:25 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 C70102E973A for ; Wed, 19 Nov 2025 16:18:21 +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=1763569103; cv=none; b=MpM0An3VB4KVAeP5fgRg7q8t5nCEAvbLdwzVztbryMOJoxx5AvFvTmczd+tngqLNO2pg/eKLjWVZ7hImUBijaAMd6G4yVgCIomliirlIgbYB0bwNzYvxcpL/tvaG9y6JBIAGOYT9hxd/JgNBOV9tYNsb/m+Li9drVuElxFu5yzk= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1763569103; c=relaxed/simple; bh=N8m12iWNCLQKM0X40bESlfOrttHeXy53V/IFqVWUcrY=; h=From:Date:Subject:MIME-Version:Content-Type:Message-Id:References: In-Reply-To:To:Cc; b=JpRVbP+r33M5bPRN9slnIw2IcFq7s4I9WpnVCW+F+xIUe62VFN207vBEHY7Bo3brLraU9z586+3+d2F+jXBZ1Fi1igAV4/M5pE7i77a8oxlq6d+XnHCbT/QFFCGjLxI2vudsdqNlcseBOON03g7eYDyQ0xNu+FqnI6wEVXZlcIc= 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=GMDlHN2F; 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="GMDlHN2F" Received: by mail-wm1-f44.google.com with SMTP id 5b1f17b1804b1-477632b0621so45824185e9.2 for ; Wed, 19 Nov 2025 08:18:21 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; t=1763569100; x=1764173900; 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=tUoArGeF29Uq9ud9txzEkP+4OSzrCHQVStRpO2mMVQU=; b=GMDlHN2Fs8EV/sz8U0ADZlGPhl9Hs/aTyxYxC8UR2M0tgD/2juRTAzaYVr5/qcmotf r2OsylGjLL44JxpokOCqwymzLqY468bQUCL8j+ajychISk7ByrrYU9zXgoe9LRNA4kQJ buftxVWalYJIwfIInLJkxLaohk5nxfd910etY1mZOybzU0zILYukIwICRfdYESCtZgFq AzZ0Li+hSQ3L/jMN4+m6Wosr5uVDVO8K7ulsP3et2R5yYaiPTu7ATrOqX2LjR9Rs2pRx Dx3pQ7BRrQQt2JWu8IyAFgpzZ3BTB5nIVp/m3fcHvNsk5o0zHkMk4J0GNha3t0YN0+pg X6Jw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1763569100; x=1764173900; 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=tUoArGeF29Uq9ud9txzEkP+4OSzrCHQVStRpO2mMVQU=; b=Fn5DYXHSMS/zBStP9bxdEQa8ApzrqHaDOO/qYula89Ln4yMOtcTXImcplov0UTw056 1g17rDBV7XBKOcc/CQb+JFLf/Wgn0ae796S5821r2mh8ZQNkWIwE3y8EfWLps22C9bAy BUjj5LSaMBcULsamAkvzvcGCiUItF/V7HGquy51nb4FNfWMcvcied6m0UVCu3hBFkSvM 74T7PAdn5tA01gZLl82BERG6lfOwsk1od07m1tL+nfWy2kA6zt3bBQ/0JS/HOxDTcEmw MpkSN66j0CCDZu8JsvrdFteNxvzbbu8il7Iz1/Gsa3kktzDnfWOraK/cUAdh7BLRDQQc v7tA== X-Forwarded-Encrypted: i=1; AJvYcCXgI5X8beNluOXZ0keVwqyIQswTh+nHkirbLH++SFEBVqVbLKxyoqe6MBRhYQtpcMQcipiNuImN6SeSDWE=@vger.kernel.org X-Gm-Message-State: AOJu0YwojTDH3ymdCtGj+b8ak2jeo07xztXbeoCZFpJvjVRXgRkinhbR sH7PznPXjIlB1X4LMgbK897qstf1uVu17vtgi4HWUQD7a8Pu3F04GM7vJIyfhcBuEoI= X-Gm-Gg: ASbGncu0DYr5XDkirFx24h71/ZSwzUu3D8FpcKfNiKSGR1s0W7e5FUfs8JFoxP0k3QQ 0cGL4hWcLe2icWGUaogXX9Xce0CJt/vr7B6IOkkKq1rRVvLii4di1c/mN6C9ZDcpE9dfTK5dQf2 3KRTvpgvvNiPWf2TW7ygi03QnS3fJjoLQm17cWdpc9r/GmbA0oNDi1jpgP7RpH38tFMAR1XdNcQ +z1wSg8iQSo0TZ4gNFEpOO8Atd3c6HM/1+vtEtQMyPjZ/8emTdZ8sbqilplZu/phkRrzgTs1MRb 1j2XstBlGdrFOew5wyJswGZeceEhh/RKemg+vMggE/I8pTYUSphyeknUV+zgHQKG8GRgEJBOTKx DzlP+Un2/f/M6eSjcx1wQoaTz8mGDqtH2sF0fo/JYsr/4ieSQsXR+Bl9HzRbQpUlcNBrde3v/5/ gJv+gonVbjIC/WjSwe67/zbzGM+It4E78= X-Google-Smtp-Source: AGHT+IG5zkbyvNDDF+/srY2VnksVzVbMRA7ZXXnfHsHEkkB6nqJQFj2bl5BZT9jLuHwXG4/EzZQ6RQ== X-Received: by 2002:a05:600c:c4a2:b0:477:c37:2ea7 with SMTP id 5b1f17b1804b1-4778fe9ac28mr192001055e9.21.1763569099997; Wed, 19 Nov 2025 08:18:19 -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.19 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 19 Nov 2025 08:18:19 -0800 (PST) From: James Clark Date: Wed, 19 Nov 2025 16:17:57 +0000 Subject: [PATCH v6 01/13] coresight: Change syncfreq to be a u8 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-1-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 TRCSYNCPR.PERIOD is the only functional part of TRCSYNCPR and it only has 5 valid bits so it can be stored in a u8. Reviewed-by: Mike Leach Reviewed-by: Leo Yan Signed-off-by: James Clark --- drivers/hwtracing/coresight/coresight-etm4x.h | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/drivers/hwtracing/coresight/coresight-etm4x.h b/drivers/hwtrac= ing/coresight/coresight-etm4x.h index 012c52fd1933..0287d19ce12e 100644 --- a/drivers/hwtracing/coresight/coresight-etm4x.h +++ b/drivers/hwtracing/coresight/coresight-etm4x.h @@ -825,7 +825,6 @@ struct etmv4_config { u32 eventctrl1; u32 stall_ctrl; u32 ts_ctrl; - u32 syncfreq; u32 ccctlr; u32 bb_ctrl; u32 vinst_ctrl; @@ -833,6 +832,7 @@ struct etmv4_config { u32 vissctlr; u32 vipcssctlr; u8 seq_idx; + u8 syncfreq; u32 seq_ctrl[ETM_MAX_SEQ_STATES]; u32 seq_rst; u32 seq_state; --=20 2.34.1 From nobody Tue Dec 2 02:20:25 2025 Received: from mail-wm1-f48.google.com (mail-wm1-f48.google.com [209.85.128.48]) (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 9CAAA36402A for ; Wed, 19 Nov 2025 16:18:22 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=209.85.128.48 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1763569104; cv=none; b=Ep/SpsvBz/zuE8kvWskM031Yo6D3gM+ZOOWCaM1aHgdvftfawH4u6Ku0+fqLoVVIbkg5hZvCM5vcGlWXWYmR/s2EHrbcmElan1tZiMo+PPAliN1btenAfCihsLuIVZpvxwinn7MnsMHKkbH+mDO+8p6wEVp9cqxgxoH1qtm2mDE= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1763569104; c=relaxed/simple; bh=17jMP5BXtLnUallPdavwL3MYV4FkLZYfFbmfg88Z2tI=; h=From:Date:Subject:MIME-Version:Content-Type:Message-Id:References: In-Reply-To:To:Cc; b=ZDCDArx6FR1WQ+plwXEs1dO+dRudrdTbSmwLW+7S+iJPw/NwaVciSyJxAiITDvnJMk5gvU7lxrRonxvFsBQnyb9YXCrG7ETQOSKsDulIh7ZzetY+X8OjmMUEsLxITN8Lpul3OznDSxkyarL55TxT80f1tbM0nYy4wCYyJ3y9cCg= 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=MkVDnn8c; arc=none smtp.client-ip=209.85.128.48 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="MkVDnn8c" Received: by mail-wm1-f48.google.com with SMTP id 5b1f17b1804b1-477b198f4bcso7273615e9.3 for ; Wed, 19 Nov 2025 08:18:22 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; t=1763569101; x=1764173901; 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=v1jmfj5dStPh0E5zFa2d+xJLlooTKEzGROAwu7cggvA=; b=MkVDnn8crhCrzMa5WBjIxSZIjf/nZ4vs/loMfXKpCUMuOPB839TIfQyYem07or15KH SdnEH3a16PZrlRm8njFW3x+WT/KvIYqeMaOKFaJtkgP/nTXKUYSURADbnDbzMxnSE8Qt 9QCxytJbjYL70x+Ba25EU/JuG72gW3Qm0oNzAmGMJK6FjHVqil0p09U9H5Y30JMOe3yd UaubG5rlmaErsq5G/qYroULwF3gZVTP9STYfQIjMjARlm0ukIFIvH4khAmQG9QC7EzCp 4SgZP+xxTAGIx7WHSZvqaEiiScvi64AMFvcOoofKInIYVxgr+kgs2ghixrjseGC/mORh I/iQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1763569101; x=1764173901; 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=v1jmfj5dStPh0E5zFa2d+xJLlooTKEzGROAwu7cggvA=; b=LX+iZ+w6FrbtPSkmfskShhSM8rF1IoV21pfl5nKjt8pbVtneWhJVGow5+Olgus9hKB /hl9cc3YnlQ05PfAkuhM5YLHWcEHrBJM7veJOMKJ4Orc6OWd8nYh04rJafqD9NeiXjOD 0/wozPyp14hp7XkU67vXZJjZMyQ2N9RMdfGENpZG0Z51X+HwsDZyZuDDrK/jf4HbLvIL fHrg9A2k4lXIuqy322S1s2Z2Ot+YE2kQ9x+ML4kJJddug5YiXKP8A+U9+TFr43Cy4lcP bcMN6lW+UIV+uTOordPzpFQ49fctLGLfd848GCrI+xXiK6fS1a0k0A7Hk8uZJhFcruT2 NnbQ== X-Forwarded-Encrypted: i=1; AJvYcCXcmcmX5icyJoa3OvOPlIBHdZIPln344syzUk/Br/6unaGFOgRZeObJ0rUHy99s7Z4XjWKheG1T4D47wQY=@vger.kernel.org X-Gm-Message-State: AOJu0YwhGFb+TTKJWhQWMEyyt7Gsul63AvDNbdkzbcH0s39xQ6LFmFwM /w4lMZcMNc+uqM6RQ1I+gt2eNehNdrvdt4OQ9WwmOPs4IoZhu2xjWrxGRx5jL8Bs1sU= X-Gm-Gg: ASbGncu5McqVUssVzMfOHrL5vhfMeFOAinmYiqQmfpCXKz7WlpaTt/4gNKQBbt2NHJe hh5zTY9+9AihUrGY+jfDp4wBNPLoGTrjcEFlq12Ce8glZIeqVEBT4DLO/TVys6TzqAYrhhycrCo vKhuHdVK1OCZI1Qy+0VZAnj7HgiRKpWgxr08s9+dT8eSOcx8uuZSJ83zT6JS6xgi97/ZprqV73R 8qOiyw275bLJBgi9zMr+mwH+iXKkc6Pzc0ofhBBSuqoqNvO5r/1fpXl/o3XtCHvwObCstVl9C8s JrAQ2fK6ysvuPYJI0cs9DHRx5TFGjHYEoUsCkXYLK0LQM7O2ObTNqevXTraYOgQhrGOXEM+j9j8 QPyCUrt3UoN8EDxuNbba0OcUseqcIe6Mwe02L4oqLPWFaIR6XkTFVsGu4y+N84mmQXeNqFXeKNF YWOobSHJx6PpueL3vmI46U0QIyUUDvtXs= X-Google-Smtp-Source: AGHT+IGPmIR6fhHuU+9ub6YJI4vO1xz6v6JjUj7F2wFmtYwIjyDK53AsfCqofC6tMxhfeD9BaOKxYQ== X-Received: by 2002:a05:600c:3b8c:b0:477:afc5:fb02 with SMTP id 5b1f17b1804b1-477afc5fbd5mr46500005e9.21.1763569100936; Wed, 19 Nov 2025 08:18:20 -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.20 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 19 Nov 2025 08:18:20 -0800 (PST) From: James Clark Date: Wed, 19 Nov 2025 16:17:58 +0000 Subject: [PATCH v6 02/13] coresight: Repack struct etmv4_drvdata 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-2-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 Fix holes and convert the long list of bools to single bits to save some space because there's one of these for each ETM. Reviewed-by: Leo Yan Reviewed-by: Mike Leach Signed-off-by: James Clark --- drivers/hwtracing/coresight/coresight-etm4x.h | 36 +++++++++++++----------= ---- 1 file changed, 18 insertions(+), 18 deletions(-) diff --git a/drivers/hwtracing/coresight/coresight-etm4x.h b/drivers/hwtrac= ing/coresight/coresight-etm4x.h index 0287d19ce12e..d178d79d9827 100644 --- a/drivers/hwtracing/coresight/coresight-etm4x.h +++ b/drivers/hwtracing/coresight/coresight-etm4x.h @@ -1016,27 +1016,27 @@ struct etmv4_drvdata { u8 ns_ex_level; u8 q_support; u8 os_lock_model; - bool sticky_enable; - bool boot_enable; - bool os_unlock; - bool instrp0; - bool q_filt; - bool trcbb; - bool trccond; - bool retstack; - bool trccci; - bool trc_error; - bool syncpr; - bool stallctl; - bool sysstall; - bool nooverflow; - bool atbtrig; - bool lpoverride; + bool sticky_enable : 1; + bool boot_enable : 1; + bool os_unlock : 1; + bool instrp0 : 1; + bool q_filt : 1; + bool trcbb : 1; + bool trccond : 1; + bool retstack : 1; + bool trccci : 1; + bool trc_error : 1; + bool syncpr : 1; + bool stallctl : 1; + bool sysstall : 1; + bool nooverflow : 1; + bool atbtrig : 1; + bool lpoverride : 1; + bool skip_power_up : 1; + bool paused : 1; u64 trfcr; struct etmv4_config config; struct etmv4_save_state *save_state; - bool skip_power_up; - bool paused; DECLARE_BITMAP(arch_features, ETM4_IMPDEF_FEATURE_MAX); }; =20 --=20 2.34.1 From nobody Tue Dec 2 02:20:25 2025 Received: from mail-wm1-f47.google.com (mail-wm1-f47.google.com [209.85.128.47]) (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 8CE86364E84 for ; Wed, 19 Nov 2025 16:18:23 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=209.85.128.47 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1763569106; cv=none; b=aV5cmuJdrWjg1v0zLHcVme5Xk3dXwiBTmrvFBxEvjwx3Or+9Gn7KVzwnn0lCy3jedV4iE97kKEVJWnmeeZmnSgXAVkhXDhulPZfQrdfp13kJ/CeZi4iic0cxiWlntQn78JOdxG0SjxE5/VmB3Y3UXY2bkNnRY01trJwf2ZT7rQA= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1763569106; c=relaxed/simple; bh=ONkP+P4kDJfi/Sh9u17b+mxs55OiXiOwJM3I+w+oDdI=; h=From:Date:Subject:MIME-Version:Content-Type:Message-Id:References: In-Reply-To:To:Cc; b=spb7OIxg1inbkKJuCkj6mIx/WAO/TjzYXNji5L5cxStT6n5cCcTunXJXstH/h3zsfHa+Y8J/+/IYYFwthY+na1TQgRjYj3WhoGp8jCZrr0F9tZ8BUoPJ0MnN6JJD6Wflpw8VBPQGPqi3avBmSzTfDgxXLDDfAAr/353hq2LIvIQ= 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=dOrwVE0E; arc=none smtp.client-ip=209.85.128.47 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="dOrwVE0E" Received: by mail-wm1-f47.google.com with SMTP id 5b1f17b1804b1-47118259fd8so51676545e9.3 for ; Wed, 19 Nov 2025 08:18:23 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; t=1763569102; x=1764173902; 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=fv3JnFDC0jik+shXFRazxf6/zTl+pNpZZP8z8eh7A8Q=; b=dOrwVE0EJnkfjwY76LYYbZD66nzfLWI3p/WYmuqHOBtuoIFX5fibZvdRK4HF2Cln3v sqv+/VMdPFMB1NeDSNB1Le5wnz6oHi2lpSBFw5bsfLa8g1oKno+mGnigyd+MfILBpJeq np7z/qBSRJlW3NN1Vc9scEYW1JVd2Q7hv9QBN5qtbDCo76iJ5rZM6fvctK/zKm9nW4Ba kpVuLx9qpX0fgNcsh54PQPzYs4pr8nKnt1VWZ8iHzd5N4L/gPXm+a76kpSczELm18B1a 9vW1IVcmg9QKbGSuB54KU3+88eZWUkvp+MwDG7IlKfbwgVjyTDP4CmIzJebQlNWHMGyc oDtQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1763569102; x=1764173902; 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=fv3JnFDC0jik+shXFRazxf6/zTl+pNpZZP8z8eh7A8Q=; b=slQuwqNcFQrk/utoUNHb/w6JcD01Tqx3RCvs0tD6pIgTierrrayX7f1ek1L6230WhE /78+0jF35nM4dsiJ0LjyfpZdq69fgHRE73E75Oru6S+6VTTjO9XXkNUsFcqHL6TcybJC bRj8/ug2EC0QndMYgdK8DUlTEAzXAaxlWRIsmoZ8+XyWshmSs4cFI2p4nlVcEWXNMQjQ o7buEfjsHxzOOLrZnoLFk6HNXW5SZY3CiFTu69i7TjvO/clKha5lAj6iuuSzfIMHf0Zv VVvTLncBsTKbXxLRKg9k+EaGylxkUmXVVrlbO52Kq+c0VEDaScerbtQea9y6Ed+V/p5I xfKA== X-Forwarded-Encrypted: i=1; AJvYcCU/d/YaqOQHNvHZ7qcGB6yO8PQPgDTUhZRC/4Ic0s9oPdhRXr3iB4u6ON3MkuIX+3JDfOw/gaCRo4UxQmc=@vger.kernel.org X-Gm-Message-State: AOJu0Yw1JHOBxqDXFQ/aqGfhzGD77ZOTxsnBN6AKN/jG4Wfg3kqNPPql uyRcFU8lMXDfUW8o/o6zNCcWp+WEhBOEC3kzU/Z89rJOHN3ONqHYcgnYcDQ07uC54fWkBPbDDy5 286Y1fQs= X-Gm-Gg: ASbGncuaKnAlvXn/QW7btfBODrewTks60CMN/WDhD/L1srvwGM37qlqsdR/RsT1Vjgc 2VfUrUrBDI9RYZ76q3zfMkQnf5egQE4qnL86ngKqQWBMdFqQcM/mDKZeVq387rsKby0D+RQwTdO gfQaCkFPOdxyo+3KHend9ucWyMscZW93LfTOXdz0x7JNl6yDAUWsFSFWZclN1h/ZTdp3amWxMGO GjJr2en+jwQDmFYK9ys6JwTxLuyzg6sZVovPRPHLXlxpJnXX83syyaRdCuUQvil/s1FdtD1erXp pqQwZyQxwub2Jzy7tIgowM2DZHto2XbjTgvypgxGlGtvDL8LPVrxUyAq/rns1kYRZhzXsDit4xH LfjPJOnrToi2EOfuEhLUs99TnJ2UIx2acH8TvPLKrgEmPqjmTN9ogHga+ZBjcNOS9WgVsBTsK5h Wq/ztwelSqVdV0zcTDMsRJ X-Google-Smtp-Source: AGHT+IHmdxTsICz9N512i9L283p3Q2gBYmhvmlMjINfcSMOJVvgePV8NVWPmyITDgHhdaid8NLhNtw== X-Received: by 2002:a05:600c:c178:b0:458:a7fa:211d with SMTP id 5b1f17b1804b1-4778feb2401mr186240055e9.29.1763569101830; Wed, 19 Nov 2025 08:18:21 -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.21 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 19 Nov 2025 08:18:21 -0800 (PST) From: James Clark Date: Wed, 19 Nov 2025 16:17:59 +0000 Subject: [PATCH v6 03/13] coresight: Refactor etm4_config_timestamp_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: <20251119-james-cs-syncfreq-v6-3-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 Remove some of the magic numbers and try to clarify some of the documentation so it's clearer how this sets up the timestamp interval. Return errors directly instead of jumping to out and returning ret, nothing needs to be cleaned up at the end and it only obscures the flow and return value. Reviewed-by: Leo Yan Signed-off-by: James Clark --- drivers/hwtracing/coresight/coresight-etm4x-core.c | 96 ++++++++++++++----= ---- drivers/hwtracing/coresight/coresight-etm4x.h | 23 ++++-- 2 files changed, 81 insertions(+), 38 deletions(-) diff --git a/drivers/hwtracing/coresight/coresight-etm4x-core.c b/drivers/h= wtracing/coresight/coresight-etm4x-core.c index 560975b70474..5d21af346799 100644 --- a/drivers/hwtracing/coresight/coresight-etm4x-core.c +++ b/drivers/hwtracing/coresight/coresight-etm4x-core.c @@ -642,18 +642,33 @@ static void etm4_enable_sysfs_smp_call(void *info) * TRCRSCTLR1 (always true) used to get the counter to decrement. From * there a resource selector is configured with the counter and the * timestamp control register to use the resource selector to trigger the - * event that will insert a timestamp packet in the stream. + * event that will insert a timestamp packet in the stream: + * + * +--------------+ + * | Resource 1 | fixed "always-true" resource + * +--------------+ + * | + * +------v-------+ + * | Counter x | (reload to 1 on underflow) + * +--------------+ + * | + * +------v--------------+ + * | Resource Selector y | (trigger on counter x =3D=3D 0) + * +---------------------+ + * | + * +------v---------------+ + * | Timestamp Generator | (timestamp on resource y) + * +----------------------+ */ static int etm4_config_timestamp_event(struct etmv4_drvdata *drvdata) { - int ctridx, ret =3D -EINVAL; - int counter, rselector; - u32 val =3D 0; + int ctridx; + int rselector; struct etmv4_config *config =3D &drvdata->config; =20 /* No point in trying if we don't have at least one counter */ if (!drvdata->nr_cntr) - goto out; + return -EINVAL; =20 /* Find a counter that hasn't been initialised */ for (ctridx =3D 0; ctridx < drvdata->nr_cntr; ctridx++) @@ -663,15 +678,19 @@ static int etm4_config_timestamp_event(struct etmv4_d= rvdata *drvdata) /* All the counters have been configured already, bail out */ if (ctridx =3D=3D drvdata->nr_cntr) { pr_debug("%s: no available counter found\n", __func__); - ret =3D -ENOSPC; - goto out; + return -ENOSPC; } =20 /* - * Searching for an available resource selector to use, starting at - * '2' since every implementation has at least 2 resource selector. - * ETMIDR4 gives the number of resource selector _pairs_, - * hence multiply by 2. + * Searching for an available resource selector to use, starting at '2' + * since resource 0 is the fixed 'always returns false' resource and 1 + * is the fixed 'always returns true' resource. See IHI0064H_b '7.3.64 + * TRCRSCTLRn, Resource Selection Control Registers, n=3D2-31'. If there + * are no resources, there would also be no counters so wouldn't get + * here. + * + * ETMIDR4 gives the number of resource selector _pairs_, hence multiply + * by 2. */ for (rselector =3D 2; rselector < drvdata->nr_resource * 2; rselector++) if (!config->res_ctrl[rselector]) @@ -680,13 +699,9 @@ static int etm4_config_timestamp_event(struct etmv4_dr= vdata *drvdata) if (rselector =3D=3D drvdata->nr_resource * 2) { pr_debug("%s: no available resource selector found\n", __func__); - ret =3D -ENOSPC; - goto out; + return -ENOSPC; } =20 - /* Remember what counter we used */ - counter =3D 1 << ctridx; - /* * Initialise original and reload counter value to the smallest * possible value in order to get as much precision as we can. @@ -694,26 +709,41 @@ static int etm4_config_timestamp_event(struct etmv4_d= rvdata *drvdata) config->cntr_val[ctridx] =3D 1; config->cntrldvr[ctridx] =3D 1; =20 - /* Set the trace counter control register */ - val =3D 0x1 << 16 | /* Bit 16, reload counter automatically */ - 0x0 << 7 | /* Select single resource selector */ - 0x1; /* Resource selector 1, i.e always true */ - - config->cntr_ctrl[ctridx] =3D val; - - val =3D 0x2 << 16 | /* Group 0b0010 - Counter and sequencers */ - counter << 0; /* Counter to use */ - - config->res_ctrl[rselector] =3D val; + /* + * Trace Counter Control Register TRCCNTCTLRn + * + * CNTCHAIN =3D 0, don't reload on the previous counter + * RLDSELF =3D true, reload counter automatically on underflow + * RLDTYPE =3D 0, one reload input resource + * RLDSEL =3D RES_SEL_FALSE (0), reload on false resource (never reload) + * CNTTYPE =3D 0, one count input resource + * CNTSEL =3D RES_SEL_TRUE (1), count fixed 'always true' resource (alway= s decrement) + */ + config->cntr_ctrl[ctridx] =3D TRCCNTCTLRn_RLDSELF | + FIELD_PREP(TRCCNTCTLRn_RLDSEL_MASK, ETM_RES_SEL_FALSE) | + FIELD_PREP(TRCCNTCTLRn_CNTSEL_MASK, ETM_RES_SEL_TRUE); =20 - val =3D 0x0 << 7 | /* Select single resource selector */ - rselector; /* Resource selector */ + /* + * Resource Selection Control Register TRCRSCTLRn + * + * PAIRINV =3D 0, INV =3D 0, don't invert + * GROUP =3D 2, SELECT =3D ctridx, trigger when counter 'ctridx' reaches 0 + * + * Multiple counters can be selected, and each bit signifies a counter, + * so set bit 'ctridx' to select our counter. + */ + config->res_ctrl[rselector] =3D FIELD_PREP(TRCRSCTLRn_GROUP_MASK, 2) | + FIELD_PREP(TRCRSCTLRn_SELECT_MASK, 1 << ctridx); =20 - config->ts_ctrl =3D val; + /* + * Global Timestamp Control Register TRCTSCTLR + * + * TYPE =3D 0, one input resource + * SEL =3D rselector, generate timestamp on resource 'rselector' + */ + config->ts_ctrl =3D FIELD_PREP(TRCTSCTLR_SEL_MASK, rselector); =20 - ret =3D 0; -out: - return ret; + return 0; } =20 static int etm4_parse_event_config(struct coresight_device *csdev, diff --git a/drivers/hwtracing/coresight/coresight-etm4x.h b/drivers/hwtrac= ing/coresight/coresight-etm4x.h index d178d79d9827..b319335e9bc3 100644 --- a/drivers/hwtracing/coresight/coresight-etm4x.h +++ b/drivers/hwtracing/coresight/coresight-etm4x.h @@ -225,6 +225,19 @@ #define TRCRSCTLRn_GROUP_MASK GENMASK(19, 16) #define TRCRSCTLRn_SELECT_MASK GENMASK(15, 0) =20 +#define TRCCNTCTLRn_CNTCHAIN BIT(17) +#define TRCCNTCTLRn_RLDSELF BIT(16) +#define TRCCNTCTLRn_RLDTYPE BIT(15) +#define TRCCNTCTLRn_RLDSEL_MASK GENMASK(12, 8) +#define TRCCNTCTLRn_CNTTYPE_MASK BIT(7) +#define TRCCNTCTLRn_CNTSEL_MASK GENMASK(4, 0) + +#define TRCTSCTLR_TYPE BIT(7) +#define TRCTSCTLR_SEL_MASK GENMASK(4, 0) + +#define ETM_RES_SEL_FALSE 0 /* Fixed function 'always false' resource sele= ctor */ +#define ETM_RES_SEL_TRUE 1 /* Fixed function 'always true' resource selec= tor */ + /* * System instructions to access ETM registers. * See ETMv4.4 spec ARM IHI0064F section 4.3.6 System instructions @@ -824,7 +837,7 @@ struct etmv4_config { u32 eventctrl0; u32 eventctrl1; u32 stall_ctrl; - u32 ts_ctrl; + u32 ts_ctrl; /* TRCTSCTLR */ u32 ccctlr; u32 bb_ctrl; u32 vinst_ctrl; @@ -837,11 +850,11 @@ struct etmv4_config { u32 seq_rst; u32 seq_state; u8 cntr_idx; - u32 cntrldvr[ETMv4_MAX_CNTR]; - u32 cntr_ctrl[ETMv4_MAX_CNTR]; - u32 cntr_val[ETMv4_MAX_CNTR]; + u32 cntrldvr[ETMv4_MAX_CNTR]; /* TRCCNTRLDVRn */ + u32 cntr_ctrl[ETMv4_MAX_CNTR]; /* TRCCNTCTLRn */ + u32 cntr_val[ETMv4_MAX_CNTR]; /* TRCCNTVRn */ u8 res_idx; - u32 res_ctrl[ETM_MAX_RES_SEL]; + u32 res_ctrl[ETM_MAX_RES_SEL]; /* TRCRSCTLRn */ u8 ss_idx; u32 ss_ctrl[ETM_MAX_SS_CMP]; u32 ss_status[ETM_MAX_SS_CMP]; --=20 2.34.1 From nobody Tue Dec 2 02:20:25 2025 Received: from mail-wm1-f49.google.com (mail-wm1-f49.google.com [209.85.128.49]) (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 A3D6B364EBF for ; Wed, 19 Nov 2025 16:18:24 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=209.85.128.49 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1763569107; cv=none; b=rtkrE6dweOjeYnsJMtPHtZznQBgJ/56q3eyc/0yBdvG2fDYXZbFd2XqK6kHVnLxUP1tiQDsbnhHTlPIuGrAWBlEeQtIBrq87qM0DQuduvFo87PWgp50X6+5sa5jXq7rSFBA9c1krCzTBj9A8606x4idtvAfo9wMtUG/4g2ZBRsI= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1763569107; c=relaxed/simple; bh=y0uH2JIsR1ckKfT5XvBYCwc/pjH6dlHjIQGHKnw4WtE=; h=From:Date:Subject:MIME-Version:Content-Type:Message-Id:References: In-Reply-To:To:Cc; b=apH1qVz5G9G6UxqQE1swGYIrz1RTaWUSdHfkz95+IVAOvgPESDaFb3xalnkq3gz89QoAyyX0YxjA050+6gmemksv5V88DTBZbgRRa+gQ/CkldGY+Xjkuxr05vDqr4PYZdYU95AiYv38OWlG0whpo3oG7EWNMbfaAv4tVO8pMyy0= 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=YODsY75K; arc=none smtp.client-ip=209.85.128.49 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="YODsY75K" Received: by mail-wm1-f49.google.com with SMTP id 5b1f17b1804b1-47755a7652eso47014455e9.0 for ; Wed, 19 Nov 2025 08:18:24 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; t=1763569103; x=1764173903; 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=cJnX1IssBDUYwxbPMQpT21RQj6R52sfQCZ+gQVVjaes=; b=YODsY75K5zP2S95alPsqWdFJwU6Io4NGPA0G4uQOq9pf3CrtvoTXSRZJtWnyk3MYPD Cz4TrVnO7gHBMwHThbiiSwntLmohXsSwlBWhN/Ba2ojNBXoB7HM5fgo/wnzynBLB3FQN 8yWxc98z1qFwqRKYG7dImDj5RHXDzS4Rp1N4V/PuOD+w5j+0/n0MtTy8yiAGFCB5XY8l DaYF5Y5XoyYlj4VRGID34LDHUp3/AyJSNdbc4zb8KnM3IZrshAKZvR3cHsqOixsSXxJS l8OtIKbTTj72VNKMkNTEN2yvp3Tey6vSCt/sFeQ+Pp6VWpJ+y0I/O7i9xtaU7H5EADdG 4G+A== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1763569103; x=1764173903; 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=cJnX1IssBDUYwxbPMQpT21RQj6R52sfQCZ+gQVVjaes=; b=nPGUqW7BXSIUaEaCW/xpKXZX2mqvLWFr1B5t/c27s110/4rVWPpxOEe0TV4Sn2AiFJ T+zL5baMB7pyTm2P8wdsb1yJD+AChwQIQEOU5lrfEz78ael962hNUvbYMyLAFamXo853 GiTjgECQ6jFsbFz1QprTXCMGJjA+I9XI/c/TsonGrE0oJ5VfTAimKbA1KrneYUzPNWt9 M+cq02vdAFC5vgmWSmRfJQURa1jrikieJ65gxTUc+gaLXUGpA5eO3y3vDkDo93pBrD0n ljJdgS/BqSt3Y6Ug3at4RpqLyfI3FzDKbdtS6EwyFB0Yw6+Q+GkTgRVfMZ7eoIdlM2Zv g2mQ== X-Forwarded-Encrypted: i=1; AJvYcCW18I43PlL4sXhNhmyXbxe4vr/u1otjCuA8RsCDnhVcCOUOytsHUaT0qikpMERGiQZn/hS+4AttqW7EL94=@vger.kernel.org X-Gm-Message-State: AOJu0YzU5r1jMJR4v1LOaqvbsVk7dnXMZG/FPUGmeCgSAm14uWXC0hx6 hCUqrezB2Op8tYVR19bct41RbpQFRl7n41bnzLTTPYNFjG869p0U4MzUAmMGA0/fg1I= X-Gm-Gg: ASbGncsHUuk6/WLz5NJalpvEWF7OE6PrQmex0hhcypIMhDM+1BqpxrO8QxMzckf4tGg nuvPUC+4aVzpr6/oBumgkFNk7S1fzu+ARxzU2nRmMOUTP8PfgNCShfxLqkeyyNyQMv9iTbKHx0M /2O89h8qkjonhc7vkVK96BIXxdWjkd5FUkopGTXIp+EQ3yykGgn1G2gESEDidmr/w1U7Qoe8dSi XrbGjQ2BdpkLHdlkmuEL6LW67IKvcU2minX9Jm6qYfOKTBrb1QB51IHQG5fqtRQNmaYCSZl2mt2 cs1vYGWNDhfe8YclLLs3SvW99NgxJUpVIBJ3S/Lg/HWUTxyi7l9cnIM9pqlFw3ex324AyWgj+RN rad7rld2kHccg6bnPRz1UAotPTYYlrkwLkNoOu3cq75KGNrbGVi2Y/g5OqpNEBkqlnsjfQLjYP9 4FKQZxOaVhe8Zn6vr1Y9QhY/NKbtGmH1w= X-Google-Smtp-Source: AGHT+IERG1RqFDP/vomohLBpJJq4UxABCONp2aW0eCI+GJF8HXVx2/qdo6JpRsSGCuMFRUh2amzmJA== X-Received: by 2002:a05:600c:3105:b0:477:569c:34e9 with SMTP id 5b1f17b1804b1-4778fe95ff8mr203233935e9.23.1763569102729; Wed, 19 Nov 2025 08:18:22 -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.21 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 19 Nov 2025 08:18:22 -0800 (PST) From: James Clark Date: Wed, 19 Nov 2025 16:18:00 +0000 Subject: [PATCH v6 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: <20251119-james-cs-syncfreq-v6-4-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 ETMv3 only has a few attributes, and setting unused ones results in an error, so hide them to begin with. 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 From nobody Tue Dec 2 02:20:25 2025 Received: from mail-wm1-f47.google.com (mail-wm1-f47.google.com [209.85.128.47]) (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 5DDCF366567 for ; Wed, 19 Nov 2025 16:18:25 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=209.85.128.47 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1763569107; cv=none; b=VTU1oYjLW8uvoHWG2PGfUKomn/4NPshoyndCVBfyvE9SdaxMgX7HWG9x6j4zlfgJTA/an3jTUrpVZk0FqtDe0FgAEPuUC9cDpv0UpNR+IyWHk0F1y6MuJkwCeXLB+Qj1c5jCSyqxTJOMRFBjbHpRAl6qfmcRabR6YiPMEi62/V8= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1763569107; c=relaxed/simple; bh=4A5pPkwY6hQX19oWXUFsatXtn/EWeIfupLOLsNPmp48=; h=From:Date:Subject:MIME-Version:Content-Type:Message-Id:References: In-Reply-To:To:Cc; b=hj51ZYRMqK3vA5hj5juqLIYEHKgjADpRXyGgRdeFNIyB7Vgi5/ccNrIxuqIu+HzfUaHcuww9DmaQ62buI41+wOa0m36TsWuB2cSJbqNnahBJ0mCy+nS4IWGsGEs7L+geF+BO/PcxudLxY3uJ5INUBT3rdZUSP1ITLvp/SFQIWbA= 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=TXdN0uUq; arc=none smtp.client-ip=209.85.128.47 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="TXdN0uUq" Received: by mail-wm1-f47.google.com with SMTP id 5b1f17b1804b1-4779aa4f928so50503245e9.1 for ; Wed, 19 Nov 2025 08:18:25 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; t=1763569104; x=1764173904; 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=9CqXsiWuG8ftmN0OUcZwJJmX94veikCNwJH3neNDlXs=; b=TXdN0uUq/wydNLokDwd1XBp1/g6+f38WZOy06OHqgtjJudKZe4CWpF6YNBtmNzrK/o HKJptY6EGR+vVz073yFZsTBnbexkaywHQHDSqkXQ3/QGgDPhUEuUz4fsOxpWd7wCna50 7eZir8sLPwAuBZUzbeq8K8sS7Pna8m/1BFXwpKa7wAmCZ7322yzWF9InSJuUdNGmKemk 6xgwfwmhUhWYAjSeWETDV3q/CoxYZZeb5+YUZmO6dDcHXlqyz10PhJKNtOBk25MBUj3X +qk6YesrH3bkln7UKJkgGF8Lyvn7PgClv1i6qRXdL5ZU6vPO47yRujaQKxW6L7CLmcIP mhCA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1763569104; x=1764173904; 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=9CqXsiWuG8ftmN0OUcZwJJmX94veikCNwJH3neNDlXs=; b=gkd5bkA4yfHy+a+ZwJARrigwRz9T+ea4zVfBylj2nrbCMn1CTwdHF0pX1uWhDYnCAa ipp2N/7LZfxvxfTHE0/J8zG/gM0tR7TuOo31qTYMmhQm6njHIc7Aj+QynshSZ35VP89h 4R5KihfMI4cCcXaK8PqqHfxd/wf+E5X0kGZcjLI5ZTobQWvP+iUQ88UtTpNRhA5c4WHq TEHSVNkmvDV/BIgxGNn9Lk1H0agu41JX+8GNQBfOawX4sjGApVaSga0/qDQcot6B8/mW c9pX543p4Re+sm09HfWZpCghVHhegW+3dYgCbEySgNzzT3D7eYQInpSxdtMrwaNZ2xnY C8HQ== X-Forwarded-Encrypted: i=1; AJvYcCUrmZrzV6nqlJgwLcKsIelTBzU0djcgQii3RAUQCVzOm2OSbmnJyTgJvzGIwGIvfHVq1LkwX5+AIo2bTrY=@vger.kernel.org X-Gm-Message-State: AOJu0YyIJZOm6ZOkNxeWLmeuE80+VMcZKwRmhjSQZjylAhTDLZHmaA/A lZVvvUe2MsguYq52L7CISHOeePEtQBmTAtsluVVvjKTHCygZGPlVphpMKJC4Hg+dJ7A= X-Gm-Gg: ASbGncsj3W1Yb1v2wDfQZ46o/szwjmLXfV7V8xISaSQr4XYiMsaa+JYFrZfmZucRHn7 fC0FrTLZZ2QVzBTIuBQ0QntlniNg36DI/tzCmPEn7zRnUoPXMdB8jpJnczPclwNJM3ruyc/jVHz SmFurbg2ey8t8gcYl25k+RcO6t3iYZUfab8Z07KCWsjGmb3vexR9c2+mSQAVhzH7jcvZ9I3tpBr deKJEjQry711iA4QCyudE8nM/ZuXes+U2ONXI9QnesEXZTEkaan6dqyRI1kF8WjmYG3HoFoeOxt /oTPyGLs5Ne+h7ViZmMf0YOF0WflGtjL0Wfg9qht0s13RwkT3lCyWmsObJpYCTt1AX1jmpaUMxS v4RBZ63ZV5q7Lu4s7mU6DqNeYHB5s2LmIdn96j3Mbh+bs4YBJBohQHI6WxzNzBux/AVyzZ3hMOm eaNbR6gTVFZnBDOpQ2Cj3ibyIIziKvQ/F0/OVYpu45DQ== X-Google-Smtp-Source: AGHT+IFIpxMsXtL8Djl2C/kcPjmViN58tbjJ6XcizBi2clh7TDM8Exuf/J+ojhsvo8EkMvz/b7GLZw== X-Received: by 2002:a05:600c:3b12:b0:46e:761b:e7ff with SMTP id 5b1f17b1804b1-4778fe89ed9mr164685515e9.28.1763569103694; Wed, 19 Nov 2025 08:18:23 -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.22 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 19 Nov 2025 08:18:23 -0800 (PST) From: James Clark Date: Wed, 19 Nov 2025 16:18:01 +0000 Subject: [PATCH v6 05/13] coresight: Define format attributes with GEN_PMU_FORMAT_ATTR() 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-5-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 This allows us to define and consume them in a unified way in later commits. A lot of the existing code has open coded bit shifts or direct usage of whole config values which is error prone and hides which bits are in use and which are free. Reviewed-by: Leo Yan Signed-off-by: James Clark --- drivers/hwtracing/coresight/coresight-etm-perf.c | 21 ++++++++-------- drivers/hwtracing/coresight/coresight-etm-perf.h | 31 ++++++++++++++++++++= ++++ 2 files changed, 42 insertions(+), 10 deletions(-) diff --git a/drivers/hwtracing/coresight/coresight-etm-perf.c b/drivers/hwt= racing/coresight/coresight-etm-perf.c index 3805282b97e8..bf4b105e0f41 100644 --- a/drivers/hwtracing/coresight/coresight-etm-perf.c +++ b/drivers/hwtracing/coresight/coresight-etm-perf.c @@ -13,6 +13,7 @@ #include #include #include +#include #include #include #include @@ -50,22 +51,22 @@ struct etm_ctxt { static DEFINE_PER_CPU(struct etm_ctxt, etm_ctxt); static DEFINE_PER_CPU(struct coresight_device *, csdev_src); =20 -PMU_FORMAT_ATTR(cycacc, "config:" __stringify(ETM_OPT_CYCACC)); -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"); +GEN_PMU_FORMAT_ATTR(cycacc); +GEN_PMU_FORMAT_ATTR(timestamp); +GEN_PMU_FORMAT_ATTR(retstack); +GEN_PMU_FORMAT_ATTR(sinkid); =20 #if IS_ENABLED(CONFIG_CORESIGHT_SOURCE_ETM4X) -PMU_FORMAT_ATTR(branch_broadcast, "config:"__stringify(ETM_OPT_BRANCH_BROA= DCAST)); +GEN_PMU_FORMAT_ATTR(branch_broadcast); /* contextid1 enables tracing CONTEXTIDR_EL1*/ -PMU_FORMAT_ATTR(contextid1, "config:" __stringify(ETM_OPT_CTXTID)); +GEN_PMU_FORMAT_ATTR(contextid1); /* contextid2 enables tracing CONTEXTIDR_EL2*/ -PMU_FORMAT_ATTR(contextid2, "config:" __stringify(ETM_OPT_CTXTID2)); +GEN_PMU_FORMAT_ATTR(contextid2); /* preset - if sink ID is used as a configuration selector */ -PMU_FORMAT_ATTR(preset, "config:0-3"); +GEN_PMU_FORMAT_ATTR(preset); /* config ID - set if a system configuration is selected */ -PMU_FORMAT_ATTR(configid, "config2:32-63"); -PMU_FORMAT_ATTR(cc_threshold, "config3:0-11"); +GEN_PMU_FORMAT_ATTR(configid); +GEN_PMU_FORMAT_ATTR(cc_threshold); =20 /* * contextid always traces the "PID". The PID is in CONTEXTIDR_EL1 diff --git a/drivers/hwtracing/coresight/coresight-etm-perf.h b/drivers/hwt= racing/coresight/coresight-etm-perf.h index 5febbcdb8696..c794087a0e99 100644 --- a/drivers/hwtracing/coresight/coresight-etm-perf.h +++ b/drivers/hwtracing/coresight/coresight-etm-perf.h @@ -20,6 +20,37 @@ struct cscfg_config_desc; */ #define ETM_ADDR_CMP_MAX 8 =20 +#define ATTR_CFG_FLD_preset_CFG config +#define ATTR_CFG_FLD_preset_LO 0 +#define ATTR_CFG_FLD_preset_HI 3 +#define ATTR_CFG_FLD_branch_broadcast_CFG config +#define ATTR_CFG_FLD_branch_broadcast_LO 8 +#define ATTR_CFG_FLD_branch_broadcast_HI 8 +#define ATTR_CFG_FLD_cycacc_CFG config +#define ATTR_CFG_FLD_cycacc_LO 12 +#define ATTR_CFG_FLD_cycacc_HI 12 +#define ATTR_CFG_FLD_contextid1_CFG config +#define ATTR_CFG_FLD_contextid1_LO 14 +#define ATTR_CFG_FLD_contextid1_HI 14 +#define ATTR_CFG_FLD_contextid2_CFG config +#define ATTR_CFG_FLD_contextid2_LO 15 +#define ATTR_CFG_FLD_contextid2_HI 15 +#define ATTR_CFG_FLD_timestamp_CFG config +#define ATTR_CFG_FLD_timestamp_LO 28 +#define ATTR_CFG_FLD_timestamp_HI 28 +#define ATTR_CFG_FLD_retstack_CFG config +#define ATTR_CFG_FLD_retstack_LO 29 +#define ATTR_CFG_FLD_retstack_HI 29 +#define ATTR_CFG_FLD_sinkid_CFG config2 +#define ATTR_CFG_FLD_sinkid_LO 0 +#define ATTR_CFG_FLD_sinkid_HI 31 +#define ATTR_CFG_FLD_configid_CFG config2 +#define ATTR_CFG_FLD_configid_LO 32 +#define ATTR_CFG_FLD_configid_HI 63 +#define ATTR_CFG_FLD_cc_threshold_CFG config3 +#define ATTR_CFG_FLD_cc_threshold_LO 0 +#define ATTR_CFG_FLD_cc_threshold_HI 11 + /** * struct etm_filter - single instruction range or start/stop configuratio= n. * @start_addr: The address to start tracing on. --=20 2.34.1 From nobody Tue Dec 2 02:20:25 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 718C1366DCB for ; Wed, 19 Nov 2025 16:18:26 +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=1763569108; cv=none; b=B7rTqpRhe9Pz2LDPKk6JfEMj7hNYvRATiTT4tQ+VJidmyXEsD5QvANEU48HbkKm0no7X1RG/TnEcQm+dK187AEkgGNOG54nSP7dcUKZEFSWMLJC6LYR6NX9qk448SNNdonIjk0REc7XA/BOr15oTz424cTNgD0b21rV5jqvk7bQ= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1763569108; c=relaxed/simple; bh=OOb4yNfBq0DxPF8hQvLUI30prmr2dFYr6vUoRd2Wzp0=; h=From:Date:Subject:MIME-Version:Content-Type:Message-Id:References: In-Reply-To:To:Cc; b=iHDUxkKuPmw8G2ErzLTsm738/k0VITpH0GA9OaZWXdc8UsjIQSVkSpFrVcTgZYg+V4SERuCN3lquUu86x7Ok/RI2V8V28T5e6lrYVX6UgIrypcct2ZKGDb4LGnuQpTIioB0VUse9FN4j7GANybzeWyFWLziUYqTeSJq8JpBrxJo= 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=k3hfriSV; 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="k3hfriSV" Received: by mail-wm1-f44.google.com with SMTP id 5b1f17b1804b1-47778b23f64so46606405e9.0 for ; Wed, 19 Nov 2025 08:18:26 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; t=1763569105; x=1764173905; 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=mAj6+rTtj7ATosP9M3WMDyWCja/Ic0j8s2EkvfB39Kc=; b=k3hfriSVoRu0zBMQ+lTNxo+Qfd68VkXUKWfpCKhXhWjW3QKdq0NxFlSaC+f6cpiXW5 q4O+XR8SORA56kxZj8YOBLTsbQYIdIuFxTvAiX8v6Z6IT7+i5/yRqfoyxvTZORABfwpZ N1UNOfe/uFPBPuNztDGefrHQUWb3qBUVgb/RRD2T4wWCQspJfCJp9qLQbRbU3sQd0JV5 ZzjhFE81wBHKPyUgripYkO8SGP6+JrZxvYIGFIBr1C9qwT8agDMzeg1vzj526oDuZu0a 0aSlYXgpYmXpmsx+7loOFVdyGlBHtHSf2TFay8mLqvxoRumlh8NMwdAJ9IB8HyKE4+QF bsjg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1763569105; x=1764173905; 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=mAj6+rTtj7ATosP9M3WMDyWCja/Ic0j8s2EkvfB39Kc=; b=F8LVDiu6r9ce1apeCFDGbj3JmT+YVGj5/YS38umIgKoVLnn4CPbFsgUhAmHwok0YQg RupFFFVQAXpPYzelbhiRBNhdd/v384gM01TdQu+vCGq7qxAomVL4hCnFBtXYDcanmKQu jEUOp2CdVKN2tU9mjgvGxeCWvfLlPMPVUgMmYCm/T2DplzvVP2yK/WvWbLw9sEhujM/c +ZLmfAX2NCxKcVFVwlXd/SdU9c/UtNsh3IErvp6+49ZqeIjgiraw2YdcS7UkM1LyMKRB dDxzt3QSQQvYJ2WMayr9Pxy01jB4NFFLJ7A75lUjk/KBmhacbMf9GpMxY4cgu2Lr065J 0B3A== X-Forwarded-Encrypted: i=1; AJvYcCXBhO8gt2Q5Fdn0k3cUvG4dK7Jbn9PRCetKXF9XPcpD5o4Xmg7Hfl9L2oWHtb/m6qHWgNVawUFea3yo2+E=@vger.kernel.org X-Gm-Message-State: AOJu0YwXt9kY7sV2GTeBTiJ+gfHbqYTmvM4Y1laH4vXeLjwnYk76Svj7 C+rrHGIB4KuS4cVtGwPN1cyNgq4FZf21lv28bjkrjuKZau6Xix0FGVtbTX2//bITI/g= X-Gm-Gg: ASbGncvv/+ou6iYFE6WGVSSs/X9speRdgwbJ/UGUsqCAb1XlNjrsk4qnXrzgeMpW6XT szV7my34yrY9Reyv+YVpt5AsiSP3+RXLBAw+cBadctl2smqiX1z+dBYOTaypfmYJ/XIrKCVTo+V Tdko712XOArxxb5P//AZu/iRpemGDoGdkBZQdS2MJDbdQw26ZYyiVT4/UxKk2NMPl2evrq+Pei7 n6he3SPCQiRzQcmQASYUslTYckeSi54Z61daiU8hsr2gDkVr2+iT2ANYXrqhFtJ3xn+FTRXCmwX 2dSMm6p36RkLTnRTZ8PVCErU1wn87VfZLfpy37/MdSyIe3sxxHtgz5Bir4IPsM+R5rrWQF7yUkS +TtpK+ZISpzUvFuaMS5HnX5kT5Vcj9ImLNMfgpicBdgBESYJo+S0geRUuNPoE83UqpsRGBhWr0H NXkrXhSNvcNHZcFz3Iok8Ts2awz7ukLaY= X-Google-Smtp-Source: AGHT+IHL0Xxnsgm5QROIs0jK7YmdMNHqvM4TUjjLTcMhfd+KYuc1AUdTBzLfbEK0Xqm07NedRv3Q6Q== X-Received: by 2002:a05:600c:4fc5:b0:477:b0b9:312a with SMTP id 5b1f17b1804b1-477b0b932damr42861065e9.7.1763569104659; Wed, 19 Nov 2025 08:18:24 -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.23 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 19 Nov 2025 08:18:24 -0800 (PST) From: James Clark Date: Wed, 19 Nov 2025 16:18:02 +0000 Subject: [PATCH v6 06/13] coresight: Interpret ETMv3 config with ATTR_CFG_GET_FLD() 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-6-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 Currently we're programming attr->config directly into ETMCR after some validation. This obscures which fields are being used, and also makes it impossible to move fields around or use other configN fields in the future. Improve it by only reading the fields that are valid and then setting the appropriate ETMCR bits based on each one. The ETMCR_CTXID_SIZE part can be removed as it was never a valid option because it's not in ETM3X_SUPPORTED_OPTIONS. Reviewed-by: Leo Yan Signed-off-by: James Clark --- drivers/hwtracing/coresight/coresight-etm3x-core.c | 24 ++++++++++++------= ---- 1 file changed, 13 insertions(+), 11 deletions(-) diff --git a/drivers/hwtracing/coresight/coresight-etm3x-core.c b/drivers/h= wtracing/coresight/coresight-etm3x-core.c index a5e809589d3e..4511fc2f8d72 100644 --- a/drivers/hwtracing/coresight/coresight-etm3x-core.c +++ b/drivers/hwtracing/coresight/coresight-etm3x-core.c @@ -28,6 +28,7 @@ #include #include #include +#include #include =20 #include "coresight-etm.h" @@ -339,21 +340,22 @@ static int etm_parse_event_config(struct etm_drvdata = *drvdata, if (attr->config & ~ETM3X_SUPPORTED_OPTIONS) return -EINVAL; =20 - config->ctrl =3D attr->config; + config->ctrl =3D 0; =20 - /* Don't trace contextID when runs in non-root PID namespace */ - if (!task_is_in_init_pid_ns(current)) - config->ctrl &=3D ~ETMCR_CTXID_SIZE; + if (ATTR_CFG_GET_FLD(attr, cycacc)) + config->ctrl |=3D ETMCR_CYC_ACC; + + if (ATTR_CFG_GET_FLD(attr, timestamp)) + config->ctrl |=3D ETMCR_TIMESTAMP_EN; =20 /* - * Possible to have cores with PTM (supports ret stack) and ETM - * (never has ret stack) on the same SoC. So if we have a request - * for return stack that can't be honoured on this core then - * clear the bit - trace will still continue normally + * Possible to have cores with PTM (supports ret stack) and ETM (never + * has ret stack) on the same SoC. So only enable when it can be honored + * - trace will still continue normally otherwise. */ - if ((config->ctrl & ETMCR_RETURN_STACK) && - !(drvdata->etmccer & ETMCCER_RETSTACK)) - config->ctrl &=3D ~ETMCR_RETURN_STACK; + if (ATTR_CFG_GET_FLD(attr, retstack) && + (drvdata->etmccer & ETMCCER_RETSTACK)) + config->ctrl |=3D ETMCR_RETURN_STACK; =20 return 0; } --=20 2.34.1 From nobody Tue Dec 2 02:20:25 2025 Received: from mail-wm1-f52.google.com (mail-wm1-f52.google.com [209.85.128.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 93D6836C5B3 for ; Wed, 19 Nov 2025 16:18:27 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=209.85.128.52 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1763569109; cv=none; b=gXSqMVSjFt8bjufLVpL8F3hqojWZcw83B2ZHd0a0BF5H2NEXzyAs14KJfFloxD0ESKG809vK5V5TCkkX/APAvseaGzV9scSQmyTg4CXP6eA1Kk7q9/EWrGH0j+P2Nv7L1D1XUrjPEu6m7I69me0lCpbSrjOEH9VBevtINHxnzQ4= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1763569109; c=relaxed/simple; bh=N+Q6R1XCPpnjYjCPIVjDvoCYHZZK5o2FhEXZTAuBfSI=; h=From:Date:Subject:MIME-Version:Content-Type:Message-Id:References: In-Reply-To:To:Cc; b=jBiOqgYHUG56vvT9YjArwplWcPXDK3D8YDizVkndS15XZxXpb7NLthUESR1Nw3Z2cDhpqUX0pO6AMSqfIjUHLkf5tPaAOr9lvmuWk2tKSoYNqY6LT4uZKXVKRlKU77KBXMDTlyy+oQfIaOYRTOgg8hv04wqJYB67+RH8wvQ9KW0= 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=l1c4pYum; arc=none smtp.client-ip=209.85.128.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="l1c4pYum" Received: by mail-wm1-f52.google.com with SMTP id 5b1f17b1804b1-477a2ab455fso38902775e9.3 for ; Wed, 19 Nov 2025 08:18:27 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; t=1763569106; x=1764173906; 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=s7Cp0IQzkfAKXAya/Lg64jqfJ1j/YiOKK8shdTQX7JE=; b=l1c4pYumW61zGl7kO6koiKP98jNxJkmDJa9MsOcKV7hii+iJIsZGH9HwDZysYHkUmo F/TFEVwxd8Vb8v5SK1i1cAcIcYHIrtqtGcHTwntQzlEfvMHWyrZzpB7BTnVTBGthzUj4 zQll3nmPvl5v8PpWqzC/095l1CxJG7fiKdu6wkS8jtbZlUC3dqhWVK/PI5NlfFFqFJs4 iIzvOdlG2EmUwRX4sulw3puWesLiqiXDTLeBhgjldpuUuruX8J7vIeQvfgw62wuwOpkh p/8bXONWQAJPu416ZvexOcZHHkEJjGwK9+Ab0d7Be5OXgrNvR+o2OOSmctgE+UgL9qv1 PMnw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1763569106; x=1764173906; 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=s7Cp0IQzkfAKXAya/Lg64jqfJ1j/YiOKK8shdTQX7JE=; b=JUj5eEPZf5OuuJ8P4FPmQgjk20GpbCuNL9YcZQ/Sk0ThbEDGemphbVFX9WTpcttWXq 6bvkVGxCmnlwgWqBT3L/QQZbreLo7T19bi0NFYtaFa2YyRKoOeXnzPshngTwOEIWUUJI E4q+5j1DVg9W52y7veQ4jbykRzcl0W+/lutkSnAEnXAizI3v6onei5O8w77iUBTjT2Hq ZQsrENAbzRiFHTWhN8AXvnaYLi/5WzUjE2cGJMXD1F5wd3B6hHH+7BdesNXwKJQ+JNIK JJkk49hio5zTHVuHC9+3UQ/kolXti0z80P0vG/e+qPe6wBIm9WGEgLnjr6ENH37mHlz7 QVCg== X-Forwarded-Encrypted: i=1; AJvYcCXiOnK0wpG19GcHD9IyG2MqMJdFHABOw1UyxSy7WxaOHyfcsm+Wh5ngbhrVP2yQ+SrSAWHX8c0JHXzdoBE=@vger.kernel.org X-Gm-Message-State: AOJu0YyvvI5937FimTLvHcOCnYdGGdl+BPwFeSLto65lYzxscnoGB4NZ 2ESpZy7FIhhbURt6AKUO8G384dJCxtxFFB1kQaSphv/hpr1e2IsPWUEC/jGon23Gt20= X-Gm-Gg: ASbGncsMn9O/LxYFJiGmG9N7yc2JnZufaz9Hcb5JKGreMTP/9kXiHQ7/CGTNdjhnq5e vCHX3SWkd6iFSBKuvEv5OvqTJJm6N+ReTcT0dRVQoixEh2xLBQKFNfM4UXtkRARjdFJ6HHrkoW0 g26vdsgO7lperjwRyzqUqzN4u0Yc1sBnf2Fxp2icAZAyI8hV15W37KVeqGz5WYsSl7DeWVClIhh 8zncJvs1ZgvO9p8xovwfj2i/GsUel68dzr87DWO/HuZQdL5VywQze+X2PFBFnwT79e0y522FmAk fDFD6/rahWN869dUIGjTE6VkTk9s71b8Y60BQsrESGe5Iyb6jqYYoORnTCcBIacITRvNluHPRDz Jhhd2fm+rTwtVjQYzCPlJa/NYCeJN8spdhUGOmNJH+EGqs++w+GP8I5JJxXdty48exRxJpPC335 cOsyfak+x4OQspWy05dUrs X-Google-Smtp-Source: AGHT+IFq5cBVYvvZ+7oVK13tQ0GTA3nshqd52t9/fz8kEaZfjoRl+N1fTrpRLi6jbMCiDb9ubVJALg== X-Received: by 2002:a05:600c:35d6:b0:477:ae31:1311 with SMTP id 5b1f17b1804b1-477ae3116a6mr51188885e9.13.1763569105548; Wed, 19 Nov 2025 08:18:25 -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.24 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 19 Nov 2025 08:18:25 -0800 (PST) From: James Clark Date: Wed, 19 Nov 2025 16:18:03 +0000 Subject: [PATCH v6 07/13] coresight: Don't reject unrecognized 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: <20251119-james-cs-syncfreq-v6-7-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 config isn't the only field, there are also config1, config2, etc. Rejecting unrecognized attributes is therefore inconsistent as it wasn't done for all fields. It was only necessary when we were directly programming attr->config into ETMCR and didn't hide the unsupported fields, but now it's not needed so remove it. Reviewed-by: Leo Yan Signed-off-by: James Clark --- drivers/hwtracing/coresight/coresight-etm3x-core.c | 7 ------- 1 file changed, 7 deletions(-) diff --git a/drivers/hwtracing/coresight/coresight-etm3x-core.c b/drivers/h= wtracing/coresight/coresight-etm3x-core.c index 4511fc2f8d72..584d653eda81 100644 --- a/drivers/hwtracing/coresight/coresight-etm3x-core.c +++ b/drivers/hwtracing/coresight/coresight-etm3x-core.c @@ -333,13 +333,6 @@ static int etm_parse_event_config(struct etm_drvdata *= drvdata, if (config->mode) etm_config_trace_mode(config); =20 - /* - * At this time only cycle accurate, return stack and timestamp - * options are available. - */ - if (attr->config & ~ETM3X_SUPPORTED_OPTIONS) - return -EINVAL; - config->ctrl =3D 0; =20 if (ATTR_CFG_GET_FLD(attr, cycacc)) --=20 2.34.1 From nobody Tue Dec 2 02:20:25 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 9BA7B36CE15 for ; Wed, 19 Nov 2025 16:18:28 +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=1763569110; cv=none; b=IBtV0w89Wh6dwgPUBrX4RgE14JFfE8HImiyZrFoEqpcBNjOPSlw9Z0T4dZu61cUrmVi398yW6tGoDH7TV+LoYOc7e+KYZXyGdOrstyV0H6yZ8TvnUxvnSTFX35UGL+iP70mneQXMuIVto4i0G7qbbkiykWaUZozrvk9ej9BKTlc= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1763569110; c=relaxed/simple; bh=TNcEQrNzvvULvrZwY1bi1KT31/DfIBlyOCzRtRN9s5s=; h=From:Date:Subject:MIME-Version:Content-Type:Message-Id:References: In-Reply-To:To:Cc; b=qWe6O+knl+8mRBCYxJ1ZTgehIDjb6e5sphhlbdzDLBeHLy+TpKy/UJTxsphYBl2wgUg2V4StEXDMVX6bHs4pGwQeDDPrec7CN8i/LUaedTeWuz3HOkw1k7KVjzgic2HVJVmtLrrcjOqUCsvfs2Reld2z1Y81n2YOfpSPEsBVi98= 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=hYNBGJIJ; 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="hYNBGJIJ" Received: by mail-wm1-f54.google.com with SMTP id 5b1f17b1804b1-47798ded6fcso18230545e9.1 for ; Wed, 19 Nov 2025 08:18:28 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; t=1763569107; x=1764173907; 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=tm65IZSOvcLW22I95NQ1DesGTVpSHNfrfkgnxYh1pRw=; b=hYNBGJIJECxC/TAbaTduMZf/SDNBavclDjlt5/Kw+H2aytvzAxhAfniyGD/E6OHtZq HPs0X0c+8tpZBjXHeMNopNuwSH8JV7OD7zzrgAH8KD8q12lqQ0OcW/f8miz7NnXrIMEG nFZWWkvkwXMeFWO2Rr6pEaxepn0UvlvIvGkCor1E1xSYE9lpn8YWNJEOzSwa6w1zqrv+ j0jwYOsKbp9W9y9T6oM9KLDxon0W0x26XEx/bDAnb3cBF6bA1dNzmAk+eTBfowgF0kOw 5iLfjURiXL5ay818UG9E/sFSc6XAK1rHZesGJBWVcdqc9kL/h7ZLv+smN/bhrpUC9BKD lnRw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1763569107; x=1764173907; 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=tm65IZSOvcLW22I95NQ1DesGTVpSHNfrfkgnxYh1pRw=; b=afI0dBQ51SGtqazSGGDlCXQzwZOc8ZCFJUh0vZI+NKZ886NT/FJPNeWWrQTpODPBWJ jBSFytfVhmIfL7qUrwXyJcg02tkVE2zM+uVdq4mYelp+XrZbjR3fSzu2SuEtB1ctvHVn uXcQTSdocebpFLDqfyfXXBhIu0554i4wx3DCSxZA8kV+MXAjwkUpUbBTfAcWaFw5/4cM Hr8QUpetPfpImkDPEgKpTJpnGdmaV1Ve6aZxZcQMxe4kpBA7WgJih25XjJal70iEWzBh LNwJEGnZSNoUZ4WmHrAsxlpkNVP7gXtjgfhzBxZFxiSA92mQSdIF0UueE93Z6KHwlv9a sbcA== X-Forwarded-Encrypted: i=1; AJvYcCUp9+Gll8VZsjXsQLDZlpWiYHYz2e9viyeew9TTfEc7Gnd8ZxnxhYORT+fG2tkbjRaOd5eBb2FDe15HSbY=@vger.kernel.org X-Gm-Message-State: AOJu0Yx3poWyM5IAKC6JFVyYd6V97siuh0Qrgt1VWi9dy6ZmiH24QhMj sPRiCwxw7fqOsKhs2cyT8CzFdervsOi7VS4nqJMFAw4MDyh95Q5SQnHF9/rCsbvmHHE= X-Gm-Gg: ASbGnctw21XCaSfRB0FfnT2rIsJ+6r1XRxBPDd2n4ozp4e3mamYOA/P7wiCuNeZjtu8 jpkUBA3jGqGrdSdxb1JlL8OtjV9/5ldp+juZ9rIsAjtnNeAQY2XtTwcvNhI4HbOAoS/qAyNPOPe HmQagSeoJm47U5xWxkue7EMJjUPA4CmRD+3mLl075YvyPjUGbY0P+EiqdVx0sT0iOU8YikEMxf3 gu7PXkxL9f24IHWTsthS5zn1JQKxYqQM/yKLZYN/E/RuEmd6lcTmJ5DFmSLkZ4E4H/5bAt+8ye/ Qi8JuYhrjY0lNrZ/EIZM8LU9HBWBiBZiMT6otHeElkBE6c0PXQrEAN775Y1eNQ+96H9BZR5dY+2 Bagc9J32hBKcwWNONqZgnoAGFLHhb7bNn+p6M5onGd4Vgqh2fOyjA0zs97DRMSfgwkBeVPOF1u7 sLYe2hBILdx3Pv05EDHqEV X-Google-Smtp-Source: AGHT+IFFA2/5WMyi43JL9wYl1E+HXHvpaVVjq0ooJOqK0iATycUimsaSxmDoPtbjIuyl7D1kIpWgmw== X-Received: by 2002:a05:600c:8b8a:b0:477:952d:fc11 with SMTP id 5b1f17b1804b1-47795418dcbmr192758345e9.16.1763569106515; Wed, 19 Nov 2025 08:18:26 -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.25 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 19 Nov 2025 08:18:26 -0800 (PST) From: James Clark Date: Wed, 19 Nov 2025 16:18:04 +0000 Subject: [PATCH v6 08/13] coresight: Interpret perf config with ATTR_CFG_GET_FLD() 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-8-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 The "config:" string construction in format_attr_contextid_show() can be removed because it either showed the existing context1 or context2 formats which have already been generated, so can be called themselves. The other conversions are straightforward replacements. Signed-off-by: James Clark --- drivers/hwtracing/coresight/coresight-etm-perf.c | 18 ++++++++---------- 1 file changed, 8 insertions(+), 10 deletions(-) diff --git a/drivers/hwtracing/coresight/coresight-etm-perf.c b/drivers/hwt= racing/coresight/coresight-etm-perf.c index bf4b105e0f41..3c8a6f795094 100644 --- a/drivers/hwtracing/coresight/coresight-etm-perf.c +++ b/drivers/hwtracing/coresight/coresight-etm-perf.c @@ -77,10 +77,9 @@ static ssize_t format_attr_contextid_show(struct device = *dev, struct device_attribute *attr, char *page) { - int pid_fmt =3D ETM_OPT_CTXTID; - - pid_fmt =3D is_kernel_in_hyp_mode() ? ETM_OPT_CTXTID2 : ETM_OPT_CTXTID; - return sprintf(page, "config:%d\n", pid_fmt); + if (is_kernel_in_hyp_mode()) + return contextid2_show(dev, attr, page); + return contextid1_show(dev, attr, page); } =20 static struct device_attribute format_attr_contextid =3D @@ -319,7 +318,7 @@ static bool sinks_compatible(struct coresight_device *a, static void *etm_setup_aux(struct perf_event *event, void **pages, int nr_pages, bool overwrite) { - u32 id, cfg_hash; + u32 sink_hash, cfg_hash; int cpu =3D event->cpu; cpumask_t *mask; struct coresight_device *sink =3D NULL; @@ -332,13 +331,12 @@ static void *etm_setup_aux(struct perf_event *event, = void **pages, INIT_WORK(&event_data->work, free_event_data); =20 /* First get the selected sink from user space. */ - if (event->attr.config2 & GENMASK_ULL(31, 0)) { - id =3D (u32)event->attr.config2; - sink =3D user_sink =3D coresight_get_sink_by_id(id); - } + sink_hash =3D ATTR_CFG_GET_FLD(&event->attr, sinkid); + if (sink_hash) + sink =3D user_sink =3D coresight_get_sink_by_id(sink_hash); =20 /* check if user wants a coresight configuration selected */ - cfg_hash =3D (u32)((event->attr.config2 & GENMASK_ULL(63, 32)) >> 32); + cfg_hash =3D ATTR_CFG_GET_FLD(&event->attr, configid); if (cfg_hash) { if (cscfg_activate_config(cfg_hash)) goto err; --=20 2.34.1 From nobody Tue Dec 2 02:20:25 2025 Received: from mail-wm1-f48.google.com (mail-wm1-f48.google.com [209.85.128.48]) (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 23124366DC4 for ; Wed, 19 Nov 2025 16:18:29 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=209.85.128.48 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1763569111; cv=none; b=H31RWmc6O373qtcyWJvlOsC52Tzp03Pd9m7CIiR2tJQ3JA2bH4H1bjNgYDYfw3fKZ7FEvVb8MIF8agSnIuVfjvSVFarxwB+Q0AAekueVcobDST9DhsFYcgRiJus69Yjn3yS9p6X6B8YZjhnWhU7wZ7Owl3ouhPGsXlAQCOa531U= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1763569111; c=relaxed/simple; bh=S1lAdaCJ1lnshqz4avnLOeP/pLK/1ucm2BsQAjK8ZFc=; h=From:Date:Subject:MIME-Version:Content-Type:Message-Id:References: In-Reply-To:To:Cc; b=I77k/EEPT1ATzJ2ykK7SnYIb1C8kZRCDhjx4VxN6+bPVy/nl6+mco8E2Pf/ULklFjcl1BI5qcj3T/ZTwAuplYeghl6Bhm295dFjHtNKqw2fL/LDjRjLcXuwlOfGj2WghxetmrZ5h45O68SpQOuzNSMS0GqbV3IkBDEKkGwXHjEM= 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=x/qbdPpH; arc=none smtp.client-ip=209.85.128.48 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="x/qbdPpH" Received: by mail-wm1-f48.google.com with SMTP id 5b1f17b1804b1-4779a4fc95aso7885155e9.1 for ; Wed, 19 Nov 2025 08:18:29 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; t=1763569108; x=1764173908; 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=iqeQCDNzyERvoI4uJsKzrMugXzNJjWTyKx7GIItRI68=; b=x/qbdPpHoX1XMqCGJWmi+/2qZBgeSTwoEag6/isI+JTjYJS5HtJ+1GHxp4AHd8NY47 oye8IMaxjvWPsBpUG9OpzTAEWtgTI06h2zrpMYvbOd1b8MXo4SwwKwrcCoSMDDASFRfk MKUnSc0Oy7OcDWP0Hf3GApwgzuFi3AZBCeufnoARGbrdM6xGopsZvRQv34mL7UHLMcRd v6fqYB2uOTMBlAW1oIqZBY/hSSB+jNIWrSmc8Q7lgdcE4vNGsWZPISZdX2S12bg5XOX+ U3Y7KQcVohbSdGoEU5Hx0paobMh0apYkYFtH9cB2zpZAzNUAlK745DiyqVJhvbCOvLJe 3lmw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1763569108; x=1764173908; 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=iqeQCDNzyERvoI4uJsKzrMugXzNJjWTyKx7GIItRI68=; b=ZpUC019Ifsu/WUfszHfnyRFNyVCYplVb2WCDSzR3DzogphxqIS7Aanlydoig5ItaJV KYKLaUqtH6nOYqo/Y4AUxUKLMFm+qHMMmtEibCm+oKerd8Hwx0weeO0eT9hCwyafdqXF 8+Ep/hRIJYU1B7dSeRp6EWwFd3MpBnPKMIe4kc/H6rLMdpCQ0I63DTdbkVk5mqXTzGFM 3OtI1mXUq+3nnqMvwX2IqHDUFPpHxZVnXe7ox6eo1Trgx4Gm3+zmfPn2n9ia4dqRcuhS RpagNawiBxdKbPuYQnRjgFT2/2aWNS4PsGCfaHPu9kPQStOu2tgr3NirXjxxa4q7WZOb WBcA== X-Forwarded-Encrypted: i=1; AJvYcCXlcNtnTFjDYjisJ12agymtRQSoiRoojWeZ5ieZYDKh+YY832yhCXZ2ZQngKFo8CFjsPUVVCSFotSZ3Ds8=@vger.kernel.org X-Gm-Message-State: AOJu0YzXqsiEUGc+5hPUUdA4tzwaAP9I4SF2tNGnc8W/pvJAI2DuUGOu PN7gSv66hed2SMsk3Tg73F/SsWMwT/5XRh/8F2j2ZRUPF2KDJypZHMRwqxXU2yl3xjo= X-Gm-Gg: ASbGnctU6FVBJkfwDf8vlvOzpGkvA07p+8damAPF+luVhTtiggo/+2WA12CCDAC2RsZ RxBS/uX+XU02oDgM36gQ5kCfeI6rcHz+rbm3L+XMjyO6ZCv08Y1NGRpVCLump1+X3jHnf3N1HYy aIk9oQ1ZQywiyPIcXu9UsVEsnyyIuEjtu8xHwVhKER1YXOZ94n/qNIXzGIPaf12K/D47Z671ZbN 5IqxxJC6WMyOwKs4f8m2hFYaC97haYgTd6JuylEH018OrcxyrLgyse/Ae1/v4B41D2s41qpZRyL yJpEKmD4RbeOECqnXppx1FhEI2IgYNNBq+qKIQlMzQ+WL5hzOoxO9iZW6psE5g+6Bsddms+fPH7 XXs8doIEZq6RiSwY4H3dRqegaFIq0evLeQyifyfk4VRyHu2ceKSrsllfDRyxQJVh8CcSS9rytXy EdTCx3OoWeTEeEqSyU/0IzyjmWI2fFcmY= X-Google-Smtp-Source: AGHT+IEM/Fju5p7i2TJe9V7ikGxvi98b6EUCB36YzVh6dnUxOojXzliJKumS8+g6+btvID3Xl1OO4w== X-Received: by 2002:a05:600c:468c:b0:477:bf1:8c82 with SMTP id 5b1f17b1804b1-477b18fb649mr35631295e9.15.1763569107534; Wed, 19 Nov 2025 08:18:27 -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.26 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 19 Nov 2025 08:18:27 -0800 (PST) From: James Clark Date: Wed, 19 Nov 2025 16:18:05 +0000 Subject: [PATCH v6 09/13] coresight: Interpret ETMv4 config with ATTR_CFG_GET_FLD() 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-9-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 Remove hard coded bitfield extractions and shifts and replace with ATTR_CFG_GET_FLD(). ETM4_CFG_BIT_BB was defined to give the register bit positions to userspace, TRCCONFIGR_BB should be used in the kernel so replace it. Reviewed-by: Leo Yan Signed-off-by: James Clark --- drivers/hwtracing/coresight/coresight-etm4x-core.c | 44 ++++++++++--------= ---- 1 file changed, 19 insertions(+), 25 deletions(-) diff --git a/drivers/hwtracing/coresight/coresight-etm4x-core.c b/drivers/h= wtracing/coresight/coresight-etm4x-core.c index 5d21af346799..c7208ffc9432 100644 --- a/drivers/hwtracing/coresight/coresight-etm4x-core.c +++ b/drivers/hwtracing/coresight/coresight-etm4x-core.c @@ -29,6 +29,7 @@ #include #include #include +#include #include #include #include @@ -780,17 +781,17 @@ static int etm4_parse_event_config(struct coresight_d= evice *csdev, goto out; =20 /* Go from generic option to ETMv4 specifics */ - if (attr->config & BIT(ETM_OPT_CYCACC)) { + if (ATTR_CFG_GET_FLD(attr, cycacc)) { config->cfg |=3D TRCCONFIGR_CCI; /* TRM: Must program this for cycacc to work */ - cc_threshold =3D attr->config3 & ETM_CYC_THRESHOLD_MASK; + cc_threshold =3D ATTR_CFG_GET_FLD(attr, cc_threshold); if (!cc_threshold) cc_threshold =3D ETM_CYC_THRESHOLD_DEFAULT; if (cc_threshold < drvdata->ccitmin) cc_threshold =3D drvdata->ccitmin; config->ccctlr =3D cc_threshold; } - if (attr->config & BIT(ETM_OPT_TS)) { + if (ATTR_CFG_GET_FLD(attr, timestamp)) { /* * Configure timestamps to be emitted at regular intervals in * order to correlate instructions executed on different CPUs @@ -810,17 +811,17 @@ static int etm4_parse_event_config(struct coresight_d= evice *csdev, } =20 /* Only trace contextID when runs in root PID namespace */ - if ((attr->config & BIT(ETM_OPT_CTXTID)) && + if (ATTR_CFG_GET_FLD(attr, contextid1) && task_is_in_init_pid_ns(current)) /* bit[6], Context ID tracing bit */ config->cfg |=3D TRCCONFIGR_CID; =20 /* - * If set bit ETM_OPT_CTXTID2 in perf config, this asks to trace VMID - * for recording CONTEXTIDR_EL2. Do not enable VMID tracing if the - * kernel is not running in EL2. + * If set bit contextid2 in perf config, this asks to trace VMID for + * recording CONTEXTIDR_EL2. Do not enable VMID tracing if the kernel + * is not running in EL2. */ - if (attr->config & BIT(ETM_OPT_CTXTID2)) { + if (ATTR_CFG_GET_FLD(attr, contextid2)) { if (!is_kernel_in_hyp_mode()) { ret =3D -EINVAL; goto out; @@ -831,26 +832,22 @@ static int etm4_parse_event_config(struct coresight_d= evice *csdev, } =20 /* return stack - enable if selected and supported */ - if ((attr->config & BIT(ETM_OPT_RETSTK)) && drvdata->retstack) + if (ATTR_CFG_GET_FLD(attr, retstack) && drvdata->retstack) /* bit[12], Return stack enable bit */ config->cfg |=3D TRCCONFIGR_RS; =20 /* - * Set any selected configuration and preset. - * - * This extracts the values of PMU_FORMAT_ATTR(configid) and PMU_FORMAT_A= TTR(preset) - * in the perf attributes defined in coresight-etm-perf.c. - * configid uses bits 63:32 of attr->config2, preset uses bits 3:0 of att= r->config. - * A zero configid means no configuration active, preset =3D 0 means no p= reset selected. + * Set any selected configuration and preset. A zero configid means no + * configuration active, preset =3D 0 means no preset selected. */ - if (attr->config2 & GENMASK_ULL(63, 32)) { - cfg_hash =3D (u32)(attr->config2 >> 32); - preset =3D attr->config & 0xF; + cfg_hash =3D ATTR_CFG_GET_FLD(attr, configid); + if (cfg_hash) { + preset =3D ATTR_CFG_GET_FLD(attr, preset); ret =3D cscfg_csdev_enable_active_config(csdev, cfg_hash, preset); } =20 /* branch broadcast - enable if selected and supported */ - if (attr->config & BIT(ETM_OPT_BRANCH_BROADCAST)) { + if (ATTR_CFG_GET_FLD(attr, branch_broadcast)) { if (!drvdata->trcbb) { /* * Missing BB support could cause silent decode errors @@ -859,7 +856,7 @@ static int etm4_parse_event_config(struct coresight_dev= ice *csdev, ret =3D -EINVAL; goto out; } else { - config->cfg |=3D BIT(ETM4_CFG_BIT_BB); + config->cfg |=3D TRCCONFIGR_BB; } } =20 @@ -1083,11 +1080,8 @@ static int etm4_disable_perf(struct coresight_device= *csdev, return -EINVAL; =20 etm4_disable_hw(drvdata); - /* - * The config_id occupies bits 63:32 of the config2 perf event attr - * field. If this is non-zero then we will have enabled a config. - */ - if (attr->config2 & GENMASK_ULL(63, 32)) + /* If configid is non-zero then we will have enabled a config. */ + if (ATTR_CFG_GET_FLD(attr, configid)) cscfg_csdev_disable_active_config(csdev); =20 /* --=20 2.34.1 From nobody Tue Dec 2 02:20:25 2025 Received: from mail-wm1-f50.google.com (mail-wm1-f50.google.com [209.85.128.50]) (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 37DEB371DD1 for ; Wed, 19 Nov 2025 16:18:30 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=209.85.128.50 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1763569112; cv=none; b=vAtbfSrbzBnwOERSubL4MUUTpdMMKSWztBhgAgyXYNXw1CiZiB+pWeUMYJu0mzAN0TjkmT2JA3itoUW6IfgCFsewHRXC1JhCvVcTqE9NcU8kNx0LrIsKIioAesDD0Na6ip8/wbJBAjo4TTPAgpr+XnQn86YyoeGg4MFKPitZBDM= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1763569112; c=relaxed/simple; bh=49yHZcfRU3JYbttPDuMZA+rvwSlgiEO1pFhN/mGFnMQ=; h=From:Date:Subject:MIME-Version:Content-Type:Message-Id:References: In-Reply-To:To:Cc; b=qvLk7AmM4eyYmBJYCk4OUJfK+wQCwBwR6VoB9CYlZW7tSmLDYTKW1UTue+7GlFdWXvyBStVbGP8SdNk6AoT/SE080EaqHKK9xa6Ub/ozuZdIStfIISn6IMGWEI/+vXqcv66sZaEKU67VO3pWs9kXcf8j0hBAhXrNi2d6voqkfpI= 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=HRGYGvHw; arc=none smtp.client-ip=209.85.128.50 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="HRGYGvHw" Received: by mail-wm1-f50.google.com with SMTP id 5b1f17b1804b1-477b198f4bcso7274655e9.3 for ; Wed, 19 Nov 2025 08:18:29 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; t=1763569108; x=1764173908; 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=d0ofk2DnhJ+xH+9yXlJaWK4ofE7g/nNzRBk1/VuwE+Y=; b=HRGYGvHwIzY3Fy90rYtIFC2shayURTElMCmOzPKj2VU4sV5HD8TybwW1Y/KGTTS83k ztS5dOJL0FNgZm6EaAmLO9213XYYwWQPL2vG5sutRtL+8FNaM1qh4WVuO8Yq7DG0Hste WCy4BrsIZq+AMDVniyhs4R5nxedxMRfkhmPgMKArQ7+d0hlx++uQEdGf/SmNLx0QeTP8 ADeQZmCWcFIb7W5qUCmxL9nlOlsee1lROVjreGp2iUBjoIOAx6xCfz71zDt6kSht/FIj ptE4EVMxfnixafEOB0pNuxuswO89Y/jaV053WyQgydivh9KQQK+TTY/ziZ3bcwXUOVO9 iwjg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1763569108; x=1764173908; 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=d0ofk2DnhJ+xH+9yXlJaWK4ofE7g/nNzRBk1/VuwE+Y=; b=i5dB78S12U88P1ZEn5XUYXrWsQxMnsatSshB0VHMGzh3D/FEEgSeXd0wImDTw8Uikw E1pcrd5Kfd+RXVhw7nH9/hXlOo/XE/12oM6OY/Y3J1mgJcGm4JIrd4Nt6xFXKwJk9n9k SPRExozJhqqfnUFoo2S81MPeXXaNvgruaPdWYmHHlNeQeQA4ARdYMin3mLrgetD37oee p85TWOdSsf7Tr57LB7jsJSIGT2D0b9X0u70a0UCekMQ9nrpLmtYCpqsuVheV4HxKKNoA yRGfSUML+gPEqPZ4lW6xMmFgMunFion1GVIYk7otAruX1vCZFBpeoHIGSgzDJB8sSTm/ 6bCw== X-Forwarded-Encrypted: i=1; AJvYcCXiEgegxJaTyyUUFUxF3DDMGMsu2e/Qzy3fJQoqmegR+uevkKT1Cg8dLfLXQ7r3I6dx8bZ+0VMupz6zxZ4=@vger.kernel.org X-Gm-Message-State: AOJu0YxLe77Q+AJz5xTHTkz9pcST5erQV87cokxxBI7pC2iA3YzX6f38 lviO+dP1COyp9zpj3RKZlxudrXbuElVNbECJ79SnmEOmVmKTWD7RD8ETF50NLC/yN5o= X-Gm-Gg: ASbGnctVaswuPNSMi4GZzCit14qc8IGwG4jqNvCTf6C38PfdRTGFhheYlQe4BcuJ7IW ojsqgTsxkvSn6BD+GMyft90VaVRDGtF/1u5MPO7VPdqCfjmY1DnodFk1ZGRkFJ2ABGJw3O9+BqS AzczMIaCDwyCy+xi5epJQIoncjAc63kg8VIFjteoYlGXRVb+ouLdwA/T6ZZDecvxWHjIgyHrnVN rFHKGpGAzdHbJ1Pt8AcIAp/MUqW4RwEx6DXcllnbPtqtGxVaUzLIMOBsnfmirzjfY6IGGjuRarW eOCh6WrPZBaJHrAo17ovUKCakHASc6L42QE0+LB09WaSyFd4dV2W8oPhvKWZ3Tk6nW7su0NO7aK HLv7GYpm5y5Br2MhDvBQYZw5bSvBHFwIHDYTeWf0Kt3t2a0Yf4gQCYYlGNGRXiTqC8wTOdnjAoh BMD4w5LDdIuMAYyd8I/m4+8pBFlRks6xk= X-Google-Smtp-Source: AGHT+IFsnnLdq4HmiJTipQU11eFgkr91zE4cIVpOobeHeqJ1i8hpmzg559qdmMNA7bAMZf8QSN84zA== X-Received: by 2002:a05:600c:1caa:b0:477:76cb:4812 with SMTP id 5b1f17b1804b1-4778fe0694amr230601115e9.0.1763569108491; Wed, 19 Nov 2025 08:18:28 -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.27 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 19 Nov 2025 08:18:28 -0800 (PST) From: James Clark Date: Wed, 19 Nov 2025 16:18:06 +0000 Subject: [PATCH v6 10/13] coresight: Remove misleading definitions 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-10-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 ETM_OPT_* definitions duplicate the PMU format attributes that have always been published in sysfs. Hardcoding them here makes it misleading as to what the 'real' PMU API is and prevents attributes from being rearranged in the future. ETM4_CFG_BIT_* definitions just define what the Arm Architecture is which is not the responsibility of the kernel to do and doesn't scale to other registers or versions of ETM. It's not an actual software ABI/API and these definitions here mislead that it is. Any tools using the first ones would be broken anyway as they won't work when attributes are moved, so removing them is the right thing to do and will prompt a fix. Tools using the second ones can trivially redefine them locally. Perf also has its own copy of the headers so both of these things can be fixed up at a later date. Reviewed-by: Leo Yan Signed-off-by: James Clark --- include/linux/coresight-pmu.h | 24 ------------------------ 1 file changed, 24 deletions(-) diff --git a/include/linux/coresight-pmu.h b/include/linux/coresight-pmu.h index 89b0ac0014b0..2e179abe472a 100644 --- a/include/linux/coresight-pmu.h +++ b/include/linux/coresight-pmu.h @@ -21,30 +21,6 @@ */ #define CORESIGHT_LEGACY_CPU_TRACE_ID(cpu) (0x10 + (cpu * 2)) =20 -/* - * Below are the definition of bit offsets for perf option, and works as - * arbitrary values for all ETM versions. - * - * Most of them are orignally from ETMv3.5/PTM's ETMCR config, therefore, - * ETMv3.5/PTM doesn't define ETMCR config bits with prefix "ETM3_" and - * directly use below macros as config bits. - */ -#define ETM_OPT_BRANCH_BROADCAST 8 -#define ETM_OPT_CYCACC 12 -#define ETM_OPT_CTXTID 14 -#define ETM_OPT_CTXTID2 15 -#define ETM_OPT_TS 28 -#define ETM_OPT_RETSTK 29 - -/* ETMv4 CONFIGR programming bits for the ETM OPTs */ -#define ETM4_CFG_BIT_BB 3 -#define ETM4_CFG_BIT_CYCACC 4 -#define ETM4_CFG_BIT_CTXTID 6 -#define ETM4_CFG_BIT_VMID 7 -#define ETM4_CFG_BIT_TS 11 -#define ETM4_CFG_BIT_RETSTK 12 -#define ETM4_CFG_BIT_VMID_OPT 15 - /* * Interpretation of the PERF_RECORD_AUX_OUTPUT_HW_ID payload. * Used to associate a CPU with the CoreSight Trace ID. --=20 2.34.1 From nobody Tue Dec 2 02:20:25 2025 Received: from mail-wm1-f53.google.com (mail-wm1-f53.google.com [209.85.128.53]) (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 2C03536C593 for ; Wed, 19 Nov 2025 16:18:30 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=209.85.128.53 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1763569113; cv=none; b=Oye3JelRSehBpkt//8Z3uHTFLQSAc1eWB5UsuqcKHPsVwGsminnKMNJwwhVHEWQ4uYKnvRcuSRsPUzbjmRwbv8OOp0TED5DKG30zJCyGerAm3ff1d4SS+iiDC7SsZaF4ODJwTIDLVR7JZyyoNsuF56AeS5l9qji2eA4ITicSb7g= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1763569113; c=relaxed/simple; bh=NNFr/LjPuIJwgQLBqv1tSqAvrhacpNfmsSLLmV7jXvU=; h=From:Date:Subject:MIME-Version:Content-Type:Message-Id:References: In-Reply-To:To:Cc; b=qXvraTvZpNmohhsurBCGNJlkpMFeQ7D2mBHD1wgGC5ZXaKJs9Fxprt5bqbQIDc/FtVJQgZ0lin6ixqPh7iPYOCzSTcLMbsJrHeZetuYVs6N34aPBD8sdq9erqHP9rSiI3jiDU72LQxP5DvaPH9lzjX2I+Lv1Z+lrLvPnNsRC8t8= 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=FdacGPBV; arc=none smtp.client-ip=209.85.128.53 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="FdacGPBV" Received: by mail-wm1-f53.google.com with SMTP id 5b1f17b1804b1-477549b3082so57158355e9.0 for ; Wed, 19 Nov 2025 08:18:30 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; t=1763569109; x=1764173909; 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=eb0nZRqG3wPO7nucW1Po+d3Kj8IK/8D9zMABw4V5b10=; b=FdacGPBV0Sjd2pVBV6elQNaWvKqQudp2N1rNrQmdcDkChToscqAzSni+cjkdvMSEta m2Wo6HB/pSsCrBNhx+t141itUmwsYplyAPa/KJ0xyD2F/NsugVg0Ls/jloDJBHtoBeD7 OyF7K59+pRhzhGpNPXdO04QiKVyvWd5th9YEollpWINP9VAP75KuPWEPrD0xIiaYaMKX 1K0FJXsX8CEWnwdidGHt765ldNwD2fmwWQWwa2mEIhWGDM0u88yNRHt/A7zBcSK2Oinq Cwjzdr3ovkBVpnz0zxVKSL4EiAiyM6VNEZIXwVeZBT0yHbGawDv1P1f2J4GEHz4v/cPq WMRw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1763569109; x=1764173909; 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=eb0nZRqG3wPO7nucW1Po+d3Kj8IK/8D9zMABw4V5b10=; b=q7LyQURzZDCvRwQLrZsyA9brh1gpm0fDgMMTLuSwTHSscxWviXdA6/kpcY9V88CWJ/ M2QOYOUb9KyOmaGuXh62pKDWD+jcYvCGU7jIUS35ckr/zCS/GC0YfpH73m3fm3HpFa+1 rKXlag1/cdKZwdIa54ck17ZwPkwDvo5PtC1y1cCOXqZPbGosoLq4Kn3u79DKj0elCo4j 6HWJjdk59KYI8f++8xUMoGUbud5kJdGMtoGv6Wgx/VvnD4MYT2tvVerEguAUtQjUM/rA MeRF2I71K7Va0SSQXyweWJHTLrVeG2BPU/EKHfywVKgza1pPWgKFLofio7BpAnxNVg5B KsRQ== X-Forwarded-Encrypted: i=1; AJvYcCWji01Z7OYtekhagLYZVlzP49C2zDMHy1EPP04+HLpBa5gq5SAU7t04jJB0iAcRry8H8WYgwuTJxQwIxjg=@vger.kernel.org X-Gm-Message-State: AOJu0Yw9vS7Kguk9eLx3Okb4uGWZVVb/o1gmxnU4hqa0ePgiFwvWFX5V qWzm+1sNaG0dN1jql5x61719XlI8V94jeuRbMvTelYbCdzyFSr9ksaDqsqP2Ml4Svhs= X-Gm-Gg: ASbGnctIzFAaDSqkpNc4NkxU2eC7ybytyqXt/D0k2W9GH1nm2ggpD4bOxIpKzBStgms 1w4VHKxwu5auRDUo3yAOgjqip0N3h2R70rNEmLQsWJdE9gl1W1Yj6gcwBhZ/A7wFExHTg+39bgL 6nMFV7j/+fd9wXuBTD6AiWTDRnioKFEH24DQ11YYqJZQdrdukCqnPAhQMgHJUoZoYqZcPbqXYzq M78lZ2UAsiNnOSzkvsp8CyHiUla7A1m6XAgA9HANDFdshhHy6bjGf6rBmuwBAfXF+xJABu2lZES Ie5va07jyidNirNSx6fIMidXJKkl26OBZJK53ynPzERSCifiGC+t+lcD7+WkypJ5js5q146P8bx u1ufnqXsYRG34yxJ2C0z3AABIfmxp7UnoV3k3DqZ/uCv2iPUaKsgFKkTNiuylKrD/v7HMHbD2qc adxkDq+9YXrCdBVNLuonK52KNlFKgglP0= X-Google-Smtp-Source: AGHT+IGDAoHjrNiuL0wt3S1CON20jtX8GRGXrTHnizlFbQ1DR9gz3tuquij5PgE+xexhigojLp1k8A== X-Received: by 2002:a05:600c:c4a2:b0:477:c37:2ea7 with SMTP id 5b1f17b1804b1-4778fe9ac28mr192009635e9.21.1763569109415; Wed, 19 Nov 2025 08:18:29 -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.28 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 19 Nov 2025 08:18:29 -0800 (PST) From: James Clark Date: Wed, 19 Nov 2025 16:18:07 +0000 Subject: [PATCH v6 11/13] coresight: Extend width of timestamp format attribute 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-11-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 'timestamp' is currently 1 bit wide for on/off. To enable setting different intervals in a later commit, extend it to 4 bits wide. Keep the old bit position for backward compatibility but don't publish in the format/ folder. It will be removed from the documentation and can be removed completely after enough time has passed. ETM3x doesn't support different intervals, so validate that the value is either 0 or 1. Tools that read the bit positions from the format/ folder will continue to work as before, setting either 0 or 1 for off/on. Tools that incorrectly didn't do this and set the ETM_OPT_TS bit directly will also continue to work because that old bit is still checked. This avoids adding a second timestamp attribute for setting the interval. This would be awkward to use because tools would have to be updated to ensure that the timestamps are always enabled when an interval is set, and the driver would have to validate that both options are provided together. All this does is implement the semantics of a single enum but spread over multiple fields. Reviewed-by: Leo Yan Signed-off-by: James Clark --- drivers/hwtracing/coresight/coresight-etm-perf.h | 13 ++++++++++--- drivers/hwtracing/coresight/coresight-etm3x-core.c | 9 ++++++++- drivers/hwtracing/coresight/coresight-etm4x-core.c | 4 +++- 3 files changed, 21 insertions(+), 5 deletions(-) diff --git a/drivers/hwtracing/coresight/coresight-etm-perf.h b/drivers/hwt= racing/coresight/coresight-etm-perf.h index c794087a0e99..24d929428633 100644 --- a/drivers/hwtracing/coresight/coresight-etm-perf.h +++ b/drivers/hwtracing/coresight/coresight-etm-perf.h @@ -23,6 +23,9 @@ struct cscfg_config_desc; #define ATTR_CFG_FLD_preset_CFG config #define ATTR_CFG_FLD_preset_LO 0 #define ATTR_CFG_FLD_preset_HI 3 +#define ATTR_CFG_FLD_timestamp_CFG config +#define ATTR_CFG_FLD_timestamp_LO 4 +#define ATTR_CFG_FLD_timestamp_HI 7 #define ATTR_CFG_FLD_branch_broadcast_CFG config #define ATTR_CFG_FLD_branch_broadcast_LO 8 #define ATTR_CFG_FLD_branch_broadcast_HI 8 @@ -35,9 +38,13 @@ struct cscfg_config_desc; #define ATTR_CFG_FLD_contextid2_CFG config #define ATTR_CFG_FLD_contextid2_LO 15 #define ATTR_CFG_FLD_contextid2_HI 15 -#define ATTR_CFG_FLD_timestamp_CFG config -#define ATTR_CFG_FLD_timestamp_LO 28 -#define ATTR_CFG_FLD_timestamp_HI 28 +/* + * Old position of 'timestamp' and not published in sysfs. Remove at a lat= er + * date if necessary. + */ +#define ATTR_CFG_FLD_deprecated_timestamp_CFG config +#define ATTR_CFG_FLD_deprecated_timestamp_LO 28 +#define ATTR_CFG_FLD_deprecated_timestamp_HI 28 #define ATTR_CFG_FLD_retstack_CFG config #define ATTR_CFG_FLD_retstack_LO 29 #define ATTR_CFG_FLD_retstack_HI 29 diff --git a/drivers/hwtracing/coresight/coresight-etm3x-core.c b/drivers/h= wtracing/coresight/coresight-etm3x-core.c index 584d653eda81..d4c04e563bf6 100644 --- a/drivers/hwtracing/coresight/coresight-etm3x-core.c +++ b/drivers/hwtracing/coresight/coresight-etm3x-core.c @@ -338,9 +338,16 @@ static int etm_parse_event_config(struct etm_drvdata *= drvdata, if (ATTR_CFG_GET_FLD(attr, cycacc)) config->ctrl |=3D ETMCR_CYC_ACC; =20 - if (ATTR_CFG_GET_FLD(attr, timestamp)) + if (ATTR_CFG_GET_FLD(attr, deprecated_timestamp) || + ATTR_CFG_GET_FLD(attr, timestamp)) config->ctrl |=3D ETMCR_TIMESTAMP_EN; =20 + if (ATTR_CFG_GET_FLD(attr, timestamp) > 1) { + dev_dbg(&drvdata->csdev->dev, + "timestamp format attribute should be 0 (off) or 1 (on)\n"); + return -EINVAL; + } + /* * Possible to have cores with PTM (supports ret stack) and ETM (never * has ret stack) on the same SoC. So only enable when it can be honored diff --git a/drivers/hwtracing/coresight/coresight-etm4x-core.c b/drivers/h= wtracing/coresight/coresight-etm4x-core.c index c7208ffc9432..cfd6d2b7bc50 100644 --- a/drivers/hwtracing/coresight/coresight-etm4x-core.c +++ b/drivers/hwtracing/coresight/coresight-etm4x-core.c @@ -28,6 +28,7 @@ #include #include #include +#include #include #include #include @@ -791,7 +792,8 @@ static int etm4_parse_event_config(struct coresight_dev= ice *csdev, cc_threshold =3D drvdata->ccitmin; config->ccctlr =3D cc_threshold; } - if (ATTR_CFG_GET_FLD(attr, timestamp)) { + if (ATTR_CFG_GET_FLD(attr, deprecated_timestamp) || + ATTR_CFG_GET_FLD(attr, timestamp)) { /* * Configure timestamps to be emitted at regular intervals in * order to correlate instructions executed on different CPUs --=20 2.34.1 From nobody Tue Dec 2 02:20:25 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 From nobody Tue Dec 2 02:20:25 2025 Received: from mail-wm1-f47.google.com (mail-wm1-f47.google.com [209.85.128.47]) (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 3AE0F373750 for ; Wed, 19 Nov 2025 16:18:33 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=209.85.128.47 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1763569115; cv=none; b=ISwG3U2NutjUe4ff/FCAxmCyedijlY8hWjP+nbnSpn5bZa4LYycHgIP+zbLfRdfuhQpMRkY0KfqGYhjLLe0VLU+3l5MqrJGDVWSLrkbXu03twgv3uKQP0H/wP2BMWFlIWN785s5TnebDexdu2oZQh8t7fTsrlgvmwF1i1cGgGzI= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1763569115; c=relaxed/simple; bh=2gYGham6RcUhZnNfLTEyX5K2IIqX9Oa8+TtMYKSDzf0=; h=From:Date:Subject:MIME-Version:Content-Type:Message-Id:References: In-Reply-To:To:Cc; b=aO5ZFL8SfkZ6grwfh+89FC9E3+N/yGD6nBiEqlZIkZmLGlLdssrXZJNYV2cyN2mSIDo8xV/4SDvus33xlmNrSXBdi184QsiwwqRQvOIdlpdmQAKRUco1r9X089xjrJxjsLKdeMlZ8y0oqLj9dReHnSQ29uEesZPplAg4BRe6bpI= 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=xT0TSeGv; arc=none smtp.client-ip=209.85.128.47 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="xT0TSeGv" Received: by mail-wm1-f47.google.com with SMTP id 5b1f17b1804b1-477b1cc8fb4so6225525e9.1 for ; Wed, 19 Nov 2025 08:18:32 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; t=1763569111; x=1764173911; 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=9NYmdp5K7GoriQTdww1h5siZo6lfJrXIe/VnMyhW40E=; b=xT0TSeGv1shStWY8dG2VdnVNTmaOATqx5X4A6etNbikwyUW2v027fqYAP3WksI3Rn5 tmfexNiX6XGmm4MGw8i2JSvUOrsuiIkalV/89pCoVnYZJXrD4ExkS9+P0SET4iTknZK9 G0bDe4SkP8sQJUvj2fhSG4GA5vVClgfcvk1j8a3wNnEHPGREzrt7wqLsgu0Xt5ssR5Zf u4Hf4eBLiJCHVBEJdZiz3UWyoXwR6zcSSKkQPBVhsQPVQp25/5ond0WTaISog6ExwDQT WjrGVVE1RP1cIYJW6c2PJaR0LAOx3Dh4d1TgoKW/6DgurmV8iRznB/vnJXPgCe6oJlBE mlZA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1763569111; x=1764173911; 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=9NYmdp5K7GoriQTdww1h5siZo6lfJrXIe/VnMyhW40E=; b=YSKHSk2PKqPi3iOv46nRxvjJ5bgemwh/i28cJ+KlvqFLb+xmvwtbSX1v3jHsn3AmJt 3aXB8KMij05EuVGUSnl7SsqfU5sQstKpKdaDYzNr+aTqYtxrAy5R37nDEjcC0soEpb5j Zv3/2o9xbcPPQvzam3SW5z3nQHdX1yZPmrcHL9Kui3zXaGzvaQ086Q7dui3vPWeXqwEr T9KEZBCnC2wOhXlWiGAzPaQecroNWUHXomGNRJYMiNELjONA+PARGpwt1m3/d7qXUBrI 6pps/U9ItWN3SWgnwEleGDO9RuVb642faQbaPormwPWQbTu9eBMfjBdXd5sYbc1KheU3 +MeA== X-Forwarded-Encrypted: i=1; AJvYcCU03h7Ej7X6H5owBLqfV5VDijqoQlYzKX2oYeRsGRrZuLfR+9/aEAZEtEVyAc83faHWT3wT6jVy/SGH2Do=@vger.kernel.org X-Gm-Message-State: AOJu0YyB/VChLHx04G1F62sCW1irHmRNJJZ/3/FafaAN/9EuOaKhDC01 7z+rtfE+yqLFlAzRGHV914ymJZFr8Qkux+8IL+8Pp8dMKFu7CvD+tUmzaaYVVXFc4t4= X-Gm-Gg: ASbGncvt3kQoXFPMdzfNsfG0o8UxQyddHLAo71x+1eE45gze9kRA9reBqnUSnNrKw22 lHi32MbDHvXZyj4ZNw7vYUqilUNbOYbp52VB6LB9Xe4C3DBv6Ra/eesLGmghCC/J33xRjsnfvZf JL+DI/2q33CGCjJ35Rmr2ywm6zDpvnIsXhj5IQmVW1FIAQDyq3lgRPeRBAcDliQ6+6X9VgKNtyY FkdPBjnoHMgheJ3HO4vuB93U9PZPbNMUzzfHS+LdqJtcBlrmC5Y7Iiza6+sru8nZt4/33qJfgI9 A/IKGyZIy3aRmPt+AlJZEd6x1FRfTRXING7A5AQKNoIuyZJwjmxHJllGtavEpRvhVYN84JWUxVF Ji+odFAQry/V7wwhGxLA7SmgLm1jTgYBp7Rv9Bj5/PLQfSBnnhSgXIhPRfbOvhVKbYBp9Am1zpm OjI1NxD6FOcKanYIav3KruXgSnkJLQA/k= X-Google-Smtp-Source: AGHT+IHdpfGKmHi4dDxwCxkPLQGkWAFqU0kact4PGhTMGVixHnJV4SZCke4Dbaosdd52MSthTFvACA== X-Received: by 2002:a05:600c:6b47:b0:477:b734:8c22 with SMTP id 5b1f17b1804b1-477b7348cebmr11811715e9.8.1763569111423; Wed, 19 Nov 2025 08:18:31 -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.30 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 19 Nov 2025 08:18:31 -0800 (PST) From: James Clark Date: Wed, 19 Nov 2025 16:18:09 +0000 Subject: [PATCH v6 13/13] coresight: docs: Document etm4x timestamp interval option 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-13-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 Document how the new field is used, maximum value and the interaction with SYNC timestamps. Signed-off-by: James Clark --- Documentation/trace/coresight/coresight.rst | 16 ++++++++++++++-- 1 file changed, 14 insertions(+), 2 deletions(-) diff --git a/Documentation/trace/coresight/coresight.rst b/Documentation/tr= ace/coresight/coresight.rst index 806699871b80..d461de4e067e 100644 --- a/Documentation/trace/coresight/coresight.rst +++ b/Documentation/trace/coresight/coresight.rst @@ -613,8 +613,20 @@ They are also listed in the folder /sys/bus/event_sour= ce/devices/cs_etm/format/ - Session local version of the system wide setting: :ref:`ETM_MODE_RE= TURNSTACK ` * - timestamp - - Session local version of the system wide setting: :ref:`ETMv4_MODE_= TIMESTAMP - ` + - Controls generation and interval of timestamps. + + 0 =3D off, 1 =3D minimum interval .. 15 =3D maximum interval. + + Values 1 - 14 use a counter that decrements every cycle to generate= a + timestamp on underflow. The reload value for the counter is 2 ^ (in= terval + - 1). If the value is 1 then the reload value is 1, if the value is= 11 + then the reload value is 1024 etc. + + Setting the maximum interval (15) will disable the counter generated + timestamps, freeing the counter resource, leaving only ones emitted= when + a SYNC packet is generated. The sync interval is controlled with + TRCSYNCPR.PERIOD which is every 4096 bytes of trace by default. + * - cc_threshold - Cycle count threshold value. If nothing is provided here or the pro= vided value is 0, then the default value i.e 0x100 will be used. If provided value is less tha= n minimum cycles threshold --=20 2.34.1