From nobody Mon Dec 1 22:35:43 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 621EFEED8 for ; Wed, 26 Nov 2025 10:57:44 +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=1764154666; cv=none; b=Mm+gvv/l8+5HvdQOCwF/FkSjtCncfeCAbC2VHm6tyn60dwMc/Oo6i5Hf2J6gMX51zfl6Hkhrd9AM9xOx2BFK8hXeYukYS1JwkKvo4WDEVftNNBFzsvhRLnDMEn9XpoUQ/loXDRUflyLhJmdoqH4gR+IygFQIiG96jx3oyXrTduA= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1764154666; c=relaxed/simple; bh=N8m12iWNCLQKM0X40bESlfOrttHeXy53V/IFqVWUcrY=; h=From:Date:Subject:MIME-Version:Content-Type:Message-Id:References: In-Reply-To:To:Cc; b=Z7idJWeuIOPbsXUclw6JfOx16HZPjdpN+T9rt5KH4tOsX/BKXp/aW/W74YMpaxty924lPlQwiHCp7Gse9p5vBI+qncDb0UY8DqjcVadL+dPO8UdVotdtpMShnvBUp7Z9hfIOL8zRcDRK0fUbYmi3VHSz7TgXJFitHD8nTbOht3c= 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=g4RtKm9t; 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="g4RtKm9t" Received: by mail-wm1-f53.google.com with SMTP id 5b1f17b1804b1-4775ae5684fso31552765e9.1 for ; Wed, 26 Nov 2025 02:57:44 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; t=1764154663; x=1764759463; 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=g4RtKm9tgoXEcGAroskSTTu38MWZWs/65trKNn+/l/HHE++kv39n2IgfzbKutwz86i gk+z24vRSL+ez7QEIPk4+mUzOAe5tm+B9EZUhApK9LRWu3QOFRGO7fOObxkOZX9Hx6gQ xdsdZwoo/SdSbY+YlxQNw28r6a1kdlEkdI7aqVsbRNJHxKctQ2tnuSV1lVXD1u8YqiB/ u1HSDtxlY5J4uriCqcXmR7mZ4ikZigKPEM4xSp4K6F/dgmZG81ibqs1sfHYm7uuHyjHK cKuuEGIB0bt5xeMKhg+xs8o0ZPxcBfbHtH6q+/JyO/YFNcQCctPb447O6D5pwXt05zOU H7yA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1764154663; x=1764759463; 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=OLSa9pzjxl3SKSKJc2PEyoXj9NJ3HwtsOk4smsnld/uKLMiUDBrdzDnU0Q2esa/Zja TY8mTfntg5tRVcNkrpg8xMFqIECXpT0dMdkzfD4PR0HWaZvcI75tSfdrCS/MShgx132M CCrxNbRCHskiRRSLnQHVThnY5HqYvf2s86TQOgorezJjH/+vhLvVltZk+vBz5yR3JocZ xu6DdiRpf0fZHP/pfAwqCXqDuYHxmq5nxHOw0RtGO42IHwvVCmwthlrUGeNmIO8jL1ha c4TJ4AUxTDrIdaDgDYmCp6r1zQWVuD+1vFLKmeG1fvgI5/FclmuxaSaxcKlYkAs5WY62 wjtQ== X-Forwarded-Encrypted: i=1; AJvYcCUVuZ3neECVoc2KEp465hAcvWgEkdgSaFIm2GWvWoRAZ4/Ary/DuWEPebPhcxi/4WsV12YzlK8Ffe9FtUE=@vger.kernel.org X-Gm-Message-State: AOJu0YzyjpuObarQSi3YhvYy8KTVzkR/pesVom2MAwuhqn5E2wV8q5yT t0A2NcYDWWsLTX8Ujlz7mZJqgeNDu1yXofWVHZQ1b/WY+xNpxRXJ7vOztZmoJ8JNUB0= X-Gm-Gg: ASbGncvjYpaQssacoDvnUQiGmqfzYfrwzKn5eZ5/7Xgq8Sh+KYnzQcaozGWaUbTeKAU jb2/cJp4HTGU9TsNLo8eiOgZpB9y7pKyfbBrFCJPB85nOHSHl57EWAaZkM9mCAXAaRp2XtgZKLY 7AfcSx3uhMVtIRPH6BMpwyODp/LnyUv/dA5hD51HjF87ih1u90fM1M2LP9WZgpoziu/FT/pUFik S7E2gfrQxRXUnHTrHXNSukD8yJBx5jX5pV7xxD0cvpz04h0LJt+XMNhdg+4nm6PPo1up9QlH0Zr RC9GqyRZ/S/kUvLmVflLcAKa5hUSeRnoWvmR4cRHWOEIHSkmPyXRy22r/OW8KIruBM3HbQyctz/ jPmDUGKJJllAUUGNiIWthYDHpb43ulmmuNRa+J7QD+st7F5r4r3YpqCGnr62rsQaitF3BRW/xtb 6gXs0Ry1RtCHhACEkG25jm X-Google-Smtp-Source: AGHT+IEq2h53SMoGIyD2yFtjfs7hfB7ruA13p+JgzFnAxaZ65GfS0NxroszsNqkmBHF8jKJbq34fpQ== X-Received: by 2002:a05:600c:4ece:b0:477:7af8:c8ad with SMTP id 5b1f17b1804b1-477c115db0cmr208004055e9.31.1764154662715; Wed, 26 Nov 2025 02:57:42 -0800 (PST) Received: from ho-tower-lan.lan ([185.48.77.170]) by smtp.gmail.com with ESMTPSA id 5b1f17b1804b1-4790ade13ddsm36991765e9.8.2025.11.26.02.57.41 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 26 Nov 2025 02:57:42 -0800 (PST) From: James Clark Date: Wed, 26 Nov 2025 10:54:30 +0000 Subject: [PATCH v7 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: <20251126-james-cs-syncfreq-v7-1-7fae5e0e5e16@linaro.org> References: <20251126-james-cs-syncfreq-v7-0-7fae5e0e5e16@linaro.org> In-Reply-To: <20251126-james-cs-syncfreq-v7-0-7fae5e0e5e16@linaro.org> To: Suzuki K Poulose , Mike Leach , Alexander Shishkin , Jonathan Corbet , Leo Yan , Randy Dunlap Cc: coresight@lists.linaro.org, linux-arm-kernel@lists.infradead.org, linux-kernel@vger.kernel.org, linux-doc@vger.kernel.org, James Clark X-Mailer: b4 0.14.0 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 Tested-by: Leo Yan --- 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 Mon Dec 1 22:35:43 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 5FEAC31B122 for ; Wed, 26 Nov 2025 10:57:45 +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=1764154667; cv=none; b=tirJZ0I51R5ylkbpVJecSmfxT/jo3eqxXWG5PjDBE1uoYpN5ty0ALSfgnh1zDgOz3vB5+sEuK+IN3dwFvruW3dkf3f+RBw/tGtuMP/sS/ntbsNx19vYreluhNq5FogcKjFIT26dJMGBFogEGALAVyNaaBJyukOEsA7OHDoH46vs= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1764154667; c=relaxed/simple; bh=17jMP5BXtLnUallPdavwL3MYV4FkLZYfFbmfg88Z2tI=; h=From:Date:Subject:MIME-Version:Content-Type:Message-Id:References: In-Reply-To:To:Cc; b=nUvR4YbW+ab1WOcRnXvqi33kbt0uTABcrhpgs+IT71LquSAAe+DL+ZIM7AjhcnkPF3KKZ7J5iAgFrYUUtM6Ml7nAGxdq7Mifa5nwu8egkqi7L+o72r+q3LtJ52Ojptei/sg2r6Wqsst/ECQQlSe83sN9dAgCJn4HWTDFgW4poL4= 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=zCc5C6FI; 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="zCc5C6FI" Received: by mail-wm1-f53.google.com with SMTP id 5b1f17b1804b1-47789cd2083so38851755e9.2 for ; Wed, 26 Nov 2025 02:57:45 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; t=1764154664; x=1764759464; 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=zCc5C6FIIJ/v8ZHvc9Uc4Ip6PhPq9z5j+YWVGnn98HOqo0qO/neoBk9jLP4n35d7QX luCQwle9iFENrRKNB9rTlQCaeoDOmdzg4kyXjQzDTUQt3nafTfhRXfSnPUQKlacr/Lk3 PJOtqasx11A9ZB2/PIQbFDeUgR4i2W2yEX2Hu7yfzGX2A4toSjpqKlbFWw5d38/D2f76 rQndkgxrUcz+hkLNRH+2R0eCT+CaFcGx6wEq4VOMYPje3eSkPNspDsmbC4R1jVvQaU2z tSJUVAF7nFVS4/B8YndgxcVVmYVN44aAJ4DbTZ/GYiAcU3xN/MiWELZkCt+Ud2nvplz7 0Liw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1764154664; x=1764759464; 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=tsRDlEChPoj9gdIgyMA8kASxrb+iBfl4yr9axLCVyYw8Xy2He1pFmq0rLuhfIoMhuS Hi3OyGIu4T2gNQR+OZp+IcLv5Z3npBiB2k93q/jPVjwMoNPh/qnk159xTmWqSbWWM8lG cK1SdTIRkviFwgeYAHvzq/bbkjUv9AQaTBYmpGQEFzh5iKrX0XyuL3KM/1WxB43OKoBC XMBcZd3FIutla3grSW1VjssnPgGHzPczMPjkk59DQ2vj2JJnr90/a5PPm2WiIWjsZDEF T4UUGwlEQvbR3RNfByvNr3bD6zKvDb4/uScG4uh7GkF4JFGkECp803MtTKOwLLc/B2Lf K4SQ== X-Forwarded-Encrypted: i=1; AJvYcCUYLakCtHZpXh7sblCW2KKwlfJy+O78uibOytNOMT7MPfl3GWmUorBaJ+ZnE7TmATUlPqRSHhvONoEZDq8=@vger.kernel.org X-Gm-Message-State: AOJu0Ywbzp03uzFcGQ729a3jppFgZNluihNLTSJ+7dgFno5YmMhoMcav QGJYiz5VLqLT4MELkcO/C62vr6+pO4WCNPwFsvHZEVb2HsesCaVNcpucuXzGWd6TgrE= X-Gm-Gg: ASbGncuihnIVWLwKjN5dUZOn2KZlWvnGLl2NUHE/NYTtzVok+3p31DgQEdc+YgomhW+ 6a7cfMRjIVwha62Wtgx41Ppem6VbpMtrUVWhrsToYDcQMgcEbEmVb6evHvYox7yZpRVtsyyUSlL 6eeAG1CSBPJNU2WEFeYCwNWhDgWs/okyuVLaMZDJ5issDlyc0WpB2yC8AQf3o+zNbS/6NXF1QUF IHbYTsciaPOGXyFk3m++4YM2e00RRQsVDqGqbtLx6YxtptvmoRxJz6Cu/QKssLgJ+l8yp27S8QF E3vhKkVhkHHp1AkPHN7yQnA9eYePaQr6FZXvphIT/oW8FjhJXRaR0aroVEmw8vokYl6QsqX8LEz PAIfTuNjErYIh043wBPL+dTFupvVuE7NTperhhEVNRWTqI54Am60lV6UPPaOEZbUNcAZ77dW3UA VdnWrm4g6uEWzTCZJkqeVq X-Google-Smtp-Source: AGHT+IH2Dz4/STj3d7ezVk3tlaHON/FWp+B+Izg1b3VZb+Q3ynleHjsb/oSUVp5AOHtWtqMGcn67OQ== X-Received: by 2002:a05:600c:4451:b0:459:db7b:988e with SMTP id 5b1f17b1804b1-477c111bab4mr190578555e9.13.1764154663638; Wed, 26 Nov 2025 02:57:43 -0800 (PST) Received: from ho-tower-lan.lan ([185.48.77.170]) by smtp.gmail.com with ESMTPSA id 5b1f17b1804b1-4790ade13ddsm36991765e9.8.2025.11.26.02.57.42 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 26 Nov 2025 02:57:43 -0800 (PST) From: James Clark Date: Wed, 26 Nov 2025 10:54:31 +0000 Subject: [PATCH v7 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: <20251126-james-cs-syncfreq-v7-2-7fae5e0e5e16@linaro.org> References: <20251126-james-cs-syncfreq-v7-0-7fae5e0e5e16@linaro.org> In-Reply-To: <20251126-james-cs-syncfreq-v7-0-7fae5e0e5e16@linaro.org> To: Suzuki K Poulose , Mike Leach , Alexander Shishkin , Jonathan Corbet , Leo Yan , Randy Dunlap Cc: coresight@lists.linaro.org, linux-arm-kernel@lists.infradead.org, linux-kernel@vger.kernel.org, linux-doc@vger.kernel.org, James Clark X-Mailer: b4 0.14.0 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 Tested-by: Leo Yan --- 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 Mon Dec 1 22:35:43 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 A2D3726FD9B for ; Wed, 26 Nov 2025 10:57:46 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=209.85.128.54 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1764154669; cv=none; b=AJvvLIaCDJXGGv9iGtZJuJwCaGZExynPndOlfnuhnhYoaYYqh74SHFaAA2c+Ubru0eIE1Kdv6hjpkUWAjp+dScknZYIvFb7OzhAIEqa1bts0CV4msa/5uEPV4kS2HSIlBDyq9ZjmHhwycOmWEkxz7DNzzFTMl/C80Z72pLek3Tc= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1764154669; c=relaxed/simple; bh=TSKKw4dSMhoGKXZEo+uUgvcqxoTEmiOBgU6fyDHO7w4=; h=From:Date:Subject:MIME-Version:Content-Type:Message-Id:References: In-Reply-To:To:Cc; b=hV48NKUQqA7bg1m2s2maGmEXjxYPHQu43NVGibdlWWiuOmXwZbdHFJApmzx52x3TX2qbW2mZ/KwQiOUObkcc7uEW2IykfOsa9CdfG8ZUCMXnWilRz/CLWuBR8IyZr3uL4+QXe3JDffAU4+CmQf/mems8+aBzB1WKO5FDkaEHpjU= 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=syJqlF5i; 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="syJqlF5i" Received: by mail-wm1-f54.google.com with SMTP id 5b1f17b1804b1-477563e28a3so5157925e9.1 for ; Wed, 26 Nov 2025 02:57:46 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; t=1764154665; x=1764759465; 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=xRll0z28PX9oYYWspSiraPmZN3ssbBscfFFFKlw+WKc=; b=syJqlF5i7+F6xkrGYuzet8rzyta4s9JUOYSKMNJpr55/NDcSSxC1OtXbX8CQAE90Sk dyBnlS466qInlcRE/fKZZ4lHKhH8qUq+paNrvg9lL7lROEkkJ2ktW20/HjbBK6SGWXzd rSEyudwt6gvUW1kjG80pRfqkA3HY2w9MGAWRdYa9HgN8q1QsVWFfFuauAHfJBXipPgdP XwuPzW1QvewgLjkI7biTIn/XC/U3VME8wNKlrktHhh8GVIF2KFi078CDOxP1yY5i1Q4e 3wmO6zd229rY7SsBzy3Znj2wDCKkOmXyw4CFUklxiCAnWj0Fce7l+PKZv93ZMQTXtqKT Un7g== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1764154665; x=1764759465; 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=xRll0z28PX9oYYWspSiraPmZN3ssbBscfFFFKlw+WKc=; b=UTCmOjkuoQOHasAcRYoS06NMhFCcOdifXTnMb3M0U548laxALQT4BA/9G2AkntPtfg sVwiUoPsG+yOWtc+Ppg6vKk+52+TD/1EdrAOD755ixMA1OTbMMMjI2IETTkXw+pa6tZk hOT1eo5vLJvhmwyWX6vZSqnQ3kEbvIhsmAr6c5deQSL2nU6TjcnlCeeyVljTNoRJcR25 zDQoK90oOu4xb+LT8LCXHYQ9IE9tUM6/8wAToT+k2Ksz99moS89/YwC2c/Lb83v9lRHR o/awLzDNejOWukweo/u7gIMBObl04woN26aaGGhVrTn1/F5pWKq32PWpzNd9ljO0+tyP ihMw== X-Forwarded-Encrypted: i=1; AJvYcCXDWYDSeNLMfoRFWehRZb2asVo516eik1fWRQvX6Q7tlhbcu5NuWqlIwaGtT+T+jrjKpmXwzBK37EjEUSk=@vger.kernel.org X-Gm-Message-State: AOJu0YyKMVENSnM24YvCIgbEYXnJPu5Y2iYJa97vdI8ldR2MYha79beq IUzxT89HqOMl2k7gTRYZuzjkBOp3DR4OQ2EET7Li3rpGn9SitSEDn5U7Up4jWHO4wAw= X-Gm-Gg: ASbGncvD/RnIoifdmgs2/1BOSDgCTl7zNQ9WXOL7BfCyUHbJpQfJn78U7NcJquUHE8m j7txn1MoP2mpPCgThhMbAvMfIiEzY6vhnqxG/K4Nyb0WWW2bt1di81fiWldqhCAzwHKX5OnbZ8V yGd3bY6+y+oE193lVQnXYZjR2gCZcTbklTC4144gE12SAv0+UtaChwTWRCQvmY52A2MMYk6Xsea lBAL19Bkw0YSd0QpUiqrMo031E2Sp34r+gC5fLpl8eErUXecjQDz9KY/GCPE8/H1pzQzlEXHBnD ENdXnjP+CIX46MIQul/iaUEklblZAKdGH6zlFtmYho1zFhO1DaapMBmuGFYTp88rqk69ER3fS0X bdgNxNo8T0X+vDR4RpRGHZzaGiIMa855pxH73a17MnnDMpxFCI1V7hXsrHosU/O3HhzcyCKMT9j 7tXRggh7wlUL4yYJVQhtSL X-Google-Smtp-Source: AGHT+IG+wSKB/nJlp2hdV7B+ZukcidbStJET4Io+vE4TA+UKP1A0EgQjVCYy5IHJP+9G/aovhCo/hQ== X-Received: by 2002:a05:600c:204b:b0:477:9d31:9f76 with SMTP id 5b1f17b1804b1-477b9ee4fd0mr168302815e9.12.1764154664628; Wed, 26 Nov 2025 02:57:44 -0800 (PST) Received: from ho-tower-lan.lan ([185.48.77.170]) by smtp.gmail.com with ESMTPSA id 5b1f17b1804b1-4790ade13ddsm36991765e9.8.2025.11.26.02.57.43 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 26 Nov 2025 02:57:44 -0800 (PST) From: James Clark Date: Wed, 26 Nov 2025 10:54:32 +0000 Subject: [PATCH v7 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: <20251126-james-cs-syncfreq-v7-3-7fae5e0e5e16@linaro.org> References: <20251126-james-cs-syncfreq-v7-0-7fae5e0e5e16@linaro.org> In-Reply-To: <20251126-james-cs-syncfreq-v7-0-7fae5e0e5e16@linaro.org> To: Suzuki K Poulose , Mike Leach , Alexander Shishkin , Jonathan Corbet , Leo Yan , Randy Dunlap Cc: coresight@lists.linaro.org, linux-arm-kernel@lists.infradead.org, linux-kernel@vger.kernel.org, linux-doc@vger.kernel.org, James Clark X-Mailer: b4 0.14.0 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. Add utilities for programming resource selectors that do compile time checks for constants or WARN_ONs for non-constant values. FIELD_PREP includes compile time checks so we only need to add an additional BUILD_BUG_ON for resource =3D=3D 0 in pair mode. Signed-off-by: James Clark Tested-by: Leo Yan --- drivers/hwtracing/coresight/coresight-etm4x-core.c | 96 ++++++++++++++----= ---- drivers/hwtracing/coresight/coresight-etm4x.h | 54 ++++++++++-- 2 files changed, 112 insertions(+), 38 deletions(-) diff --git a/drivers/hwtracing/coresight/coresight-etm4x-core.c b/drivers/h= wtracing/coresight/coresight-etm4x-core.c index 560975b70474..2ec2ae1fef58 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 + * RLDEVENT =3D RES_SEL_FALSE (0), reload on single false resource (never= reload) + * CNTEVENT =3D RES_SEL_TRUE (1), count single fixed 'always true' resour= ce (always decrement) + */ + config->cntr_ctrl[ctridx] =3D TRCCNTCTLRn_RLDSELF | + FIELD_PREP(TRCCNTCTLRn_RLDEVENT_MASK, + etm4_res_sel_single(ETM4_RES_SEL_FALSE)) | + FIELD_PREP(TRCCNTCTLRn_CNTEVENT_MASK, + etm4_res_sel_single(ETM4_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 + * + * EVENT =3D generate timestamp on single resource 'rselector' + */ + config->ts_ctrl =3D FIELD_PREP(TRCTSCTLR_EVENT_MASK, + etm4_res_sel_single(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..89d81ce4e04e 100644 --- a/drivers/hwtracing/coresight/coresight-etm4x.h +++ b/drivers/hwtracing/coresight/coresight-etm4x.h @@ -225,6 +225,50 @@ #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_RLDEVENT_MASK GENMASK(15, 8) +#define TRCCNTCTLRn_CNTEVENT_MASK GENMASK(7, 0) + +#define TRCTSCTLR_EVENT_MASK GENMASK(7, 0) + +#define ETM4_RES_SEL_FALSE 0 /* Fixed function 'always false' resource sel= ector */ +#define ETM4_RES_SEL_TRUE 1 /* Fixed function 'always true' resource sele= ctor */ + +#define ETM4_RES_SEL_SINGLE_MASK GENMASK(4, 0) +#define ETM4_RES_SEL_PAIR_MASK GENMASK(3, 0) +#define ETM4_RES_SEL_TYPE_PAIR BIT(7) + +/* + * Utilities for programming EVENT resource selectors, e.g. TRCCNTCTLRn_RL= DEVENT. + * + * Resource selectors have a common format across registers: + * + * 7 6 5 4 0 + * +------+------+-------+ + * | TYPE | RES0 | SEL | + * +------+------+-------+ + * + * Where TYPE indicates whether the selector is for a single event or a pa= ir. + * When TYPE is pair, SEL is 4 bits wide and using pair 0 is UNPREDICTABLE. + * Otherwise for single it's 5 bits wide. + */ +static inline u32 etm4_res_sel_single(u8 res_sel_idx) +{ + WARN_ON_ONCE(!FIELD_FIT(ETM4_RES_SEL_SINGLE_MASK, res_sel_idx)); + return FIELD_PREP(ETM4_RES_SEL_SINGLE_MASK, res_sel_idx); +} + +static inline u32 etm4_res_sel_pair(u8 res_sel_idx) +{ + if (__builtin_constant_p(res_sel_idx)) + BUILD_BUG_ON(res_sel_idx =3D=3D 0); + WARN_ON_ONCE(!FIELD_FIT(ETM4_RES_SEL_PAIR_MASK, res_sel_idx) || + (res_sel_idx =3D=3D 0)); + return FIELD_PREP(ETM4_RES_SEL_PAIR_MASK, res_sel_idx) | + ETM4_RES_SEL_TYPE_PAIR; +} + /* * System instructions to access ETM registers. * See ETMv4.4 spec ARM IHI0064F section 4.3.6 System instructions @@ -824,7 +868,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 +881,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 Mon Dec 1 22:35:43 2025 Received: from mail-wm1-f54.google.com (mail-wm1-f54.google.com [209.85.128.54]) (using TLSv1.2 with cipher ECDHE-RSA-AES128-GCM-SHA256 (128/128 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 66DC531E0E6 for ; Wed, 26 Nov 2025 10:57:47 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=209.85.128.54 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1764154669; cv=none; b=hdrOamvN8Xpuvfo1R1aTo1gFy/IaLsuaFJX/FocNZzin0drg1Az172BwZAjDq5sw9MahDmxrSwjUvbVxP7rbaCnDF6zHF8gq4ZLWdVDvJ+80Rn38DiwIxiXza03a6VSvluhZ/1wYsY0sx+71ED+sY/o6Hfdd2vxu+nwzd/ydiqE= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1764154669; c=relaxed/simple; bh=UMG09p7aajwgYeIvV728JxOY39zfyOs7svUDvZTqzVQ=; h=From:Date:Subject:MIME-Version:Content-Type:Message-Id:References: In-Reply-To:To:Cc; b=jn7bhpLLgCHeJbdCe7T3x4bXUshcYknOmYfgmOXotoZOB/a+mNRYXPtXG4Ya8VfyTzZ0qGoBDi2FRNbIfnRvKXit3CYrGfy8uwXf/ZQOSGxUrEtyhbPh81UsZ+A7OobkOQUpTbnXoNA/sNslIBWxzEfLYFSQRRdRaLIP8mQDssE= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=linaro.org; spf=pass smtp.mailfrom=linaro.org; dkim=pass (2048-bit key) header.d=linaro.org header.i=@linaro.org header.b=pqyXpVV1; arc=none smtp.client-ip=209.85.128.54 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=linaro.org Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=linaro.org Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=linaro.org header.i=@linaro.org header.b="pqyXpVV1" Received: by mail-wm1-f54.google.com with SMTP id 5b1f17b1804b1-4775ae5684fso31553075e9.1 for ; Wed, 26 Nov 2025 02:57:47 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; t=1764154666; x=1764759466; darn=vger.kernel.org; h=cc:to:in-reply-to:references:message-id:content-transfer-encoding :mime-version:subject:date:from:from:to:cc:subject:date:message-id :reply-to; bh=4eB34ho9tLNd3EJt+3+XUDw0cEApe270YLGk56wWE0A=; b=pqyXpVV1i3FjwN5QHXuGksy4qzXyFxGZF1yhvJAUzINrtDVVFk+8wQi6yOQ97xCMkR Xej7NiEPetZ5tEsQPoZz2jcZYEjy3wOoQ6dMLW3KzcGQqvEoxQxzOY6T2Obdgz6z3MMZ /xYpEnl2hpaQuGj7QP8yOEYLLeywfQdcLLkwjB5+XRFy3xTroEdiT4yHd+6iymXToY0X 9gOfvaDSV+6yZOqxi9lRFLO+WPxtW/4rmDyVF87E50YZbGOrH2l98Ta9BDfIVl1mlIq1 lHDLvE+0XblAb60B5tou8Hf+XEzIqNKH6T2//clW1ZMD8NdxByyPY4WaeSLf84ez4Pc3 fckw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1764154666; x=1764759466; h=cc:to:in-reply-to:references:message-id:content-transfer-encoding :mime-version:subject:date:from:x-gm-gg:x-gm-message-state:from:to :cc:subject:date:message-id:reply-to; bh=4eB34ho9tLNd3EJt+3+XUDw0cEApe270YLGk56wWE0A=; b=wLeD5e5mu8wcUl6XKexyWjn/MmoDCyxiTp2wcWqi6bOd0QFAFHxfVWygVcqfw7/pib PgSw9PlBLHcGHd7yHlm/NowMRI/K5e2eVHXnUHgxHMytEj3T1yK2M/znNeZc/iFiion7 ZrLETs0re6iKC1IFlTYuyC7dAf5PRBF2Y3wLjCttyH5okxEjzRMllyc4n2EzwhSaCohE qaVZCmr9/K9sFmk6QTFHYkifehJVSsHBL4XLqtRTBeT8I5XhdjaLD2gBTYCPsNNUUVxw /+ItiiEbygQjC3ilGn8jHX1SR8/+msMiPB//zeE1SEpnI6qXx2ywnMgNXhUBc+z+fMNU hU4g== X-Forwarded-Encrypted: i=1; AJvYcCVU41nRhz66enPWw62xrduPNvwy6mCKDLAkymQyAoaOGqFVA3N75htdn8zbPjPegIY/T+1On/Yk4pWuPEo=@vger.kernel.org X-Gm-Message-State: AOJu0YwZU7g3eWXAHIewUe3k8zUeXRcC5qa50bNmOnmMgAarM6KTRn2Z 9nmOipTVmYI5LGcqNH/nY2P2X9iVdq7cDd98HT+K2cW9YPZ5RoN5TfI+RpGan7usqfeHZmGIgvi 7D0yJH3U= X-Gm-Gg: ASbGnctEOOzU0BXMqr/v26GDQf5xWv6APBcObKMTRCiTDE0iLyeZc/ttzU3+DCUR0DQ opuXmLim2arZdOA1O3HIurCZ/DWXugeXpK4KOOsOJagFnnBkja3ChFdG/1H8L4yjoGtZ2XkJtA4 AUCz/DofZg4QOKH8J3pegS1pCVZ9A81DyIbBtHNKFZxUKQgj7Sj0rOiju+ak4T8WtjiABpGyRhj 15ksWEAKGfYseWP23V1gknr1Y0Xoz1nJzxa+V0OmJAE8Lt5JqBOgSC3GGqrW9IUnAxlzH0D3X4q fbUgHT1dxYvBvXCaXi1uhqXPH+Ia7YPLMxC0kpOYHzQIRb4FxEtOA2bVgubChR++pNf965Emz58 8ti/zX2aN0TO0FxdrbghJ/cenPN9gvPK1Y/ZAmO9QZxg/EFprGFwK9G8Pi7/QFSZNpiFvJBHp3X gHAOre9dcloqIECZj/jPpO X-Google-Smtp-Source: AGHT+IH2BvopeuRT0S9+xRNSYbyM4nOqRmPC8UzC4Hx7OfiHrAR6M+pqTSqQVntjYyB7HV7H6n6VHw== X-Received: by 2002:a05:600c:5491:b0:477:2f7c:314f with SMTP id 5b1f17b1804b1-477c110e391mr180110055e9.10.1764154665624; Wed, 26 Nov 2025 02:57:45 -0800 (PST) Received: from ho-tower-lan.lan ([185.48.77.170]) by smtp.gmail.com with ESMTPSA id 5b1f17b1804b1-4790ade13ddsm36991765e9.8.2025.11.26.02.57.44 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 26 Nov 2025 02:57:45 -0800 (PST) From: James Clark Date: Wed, 26 Nov 2025 10:54:33 +0000 Subject: [PATCH v7 04/13] coresight: Hide unused ETMv3 format attributes Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Type: text/plain; charset="utf-8" Content-Transfer-Encoding: quoted-printable Message-Id: <20251126-james-cs-syncfreq-v7-4-7fae5e0e5e16@linaro.org> References: <20251126-james-cs-syncfreq-v7-0-7fae5e0e5e16@linaro.org> In-Reply-To: <20251126-james-cs-syncfreq-v7-0-7fae5e0e5e16@linaro.org> To: Suzuki K Poulose , Mike Leach , Alexander Shishkin , Jonathan Corbet , Leo Yan , Randy Dunlap Cc: coresight@lists.linaro.org, linux-arm-kernel@lists.infradead.org, linux-kernel@vger.kernel.org, linux-doc@vger.kernel.org, James Clark X-Mailer: b4 0.14.0 ETMv3 only has a few attributes, and setting unused ones results in an error, so hide them to begin with. Reviewed-by: Mike Leach Signed-off-by: James Clark Tested-by: Leo Yan --- 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 Mon Dec 1 22:35:43 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 3EA06320A09 for ; Wed, 26 Nov 2025 10:57:48 +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=1764154672; cv=none; b=gKguLZn0r59aENtIMhSUQ9mnpLxsEa49AFCAU6IYj4nlWmqKXuApZ6bIJgr+lnDc8+PUWHR8XJ+qe1h82e/rIM/uI6iCYMnszI3VGH5glV23fEbdwMLvygMbYU9q5dQDmexRfIn2smGRFLZ8+IpFCMiKX6RyRv0cKoqOLWGxJXU= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1764154672; c=relaxed/simple; bh=89tbL7i+TdjrQPilnH/h2swnrzMhn3VgtWNa5TaRMz8=; h=From:Date:Subject:MIME-Version:Content-Type:Message-Id:References: In-Reply-To:To:Cc; b=nzod1A3+bZ3ufW8qH1b1z0930/tYOKvxQ9eAlZ/qCfLBnpBa+xwrRTox3MDInxVvTXkXOSWa0IenN8xCnwL0r8ByaP6FY3iYxUDBeIT2JTWHrfvn3Ebs8an2r0dvf52w3guf1NyPIcQvRnKhUwP/9A7p+eR1qxuQcFG/5tYyPow= 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=nAVhIWsD; 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="nAVhIWsD" Received: by mail-wm1-f49.google.com with SMTP id 5b1f17b1804b1-477563e28a3so5158325e9.1 for ; Wed, 26 Nov 2025 02:57:48 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; t=1764154666; x=1764759466; darn=vger.kernel.org; h=cc:to:in-reply-to:references:message-id:content-transfer-encoding :mime-version:subject:date:from:from:to:cc:subject:date:message-id :reply-to; bh=iwy1SauvpBsKdoqKcjNK7vrv6yyN6VbL2cB6r1BLjkY=; b=nAVhIWsDEVdJPpTJH1wCIdmThbevE0IySGPrM5/uz4LefUz/L81cVBV/6NoOWmlCyl wWxxZMp1cR9D/dm7hx/7FFsdBz8LowDos+Ch5Arvv/y7CbsNzNVccp/CllPPXXMfYCKs kYd6++f4YDYopFiTGepJ8qDDe7jPDsnoFEXc4/LGU6g6EuAbGymeNCF0PuX7R3qIwgLg J7RtbAPqQrDKtEedvaqMknBjddIEP7nBJ8AKj1RY3ZTDAsm4L7yflxb/OuVRoYtX8VSx uhL4EgI2iytFBcJrRGDSV2qbqPob7YtqSr+8atJo3SPOyNf9KuxAcDhQgtqMXkUd3uZD 5++A== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1764154666; x=1764759466; h=cc:to:in-reply-to:references:message-id:content-transfer-encoding :mime-version:subject:date:from:x-gm-gg:x-gm-message-state:from:to :cc:subject:date:message-id:reply-to; bh=iwy1SauvpBsKdoqKcjNK7vrv6yyN6VbL2cB6r1BLjkY=; b=BgBvdpM3v2WM+Prq+HMKjt74mb2vNomIxTCrGfbkXD+Wr7Mw2mNsX5T1M/Tt1JHFXy R0liIxEdSQeeivlW/M2mrcTNrOpVqiuGH9ArzJPNbw3Kh04Dqxmt8+SUz36lpXjakTWD m1jXehal9KdUJmlPeR4rgFwwhUHPomjmkw4O3O37FKxZ/9fdlUZmazaSVUrIoRnY/EhT QGXARALqspNhkf1OCPrrkkPMxQSg6U4cGD38AQL14RVOCnkOHRV4EPMbIwnmqGlmhogo sjtuw/PdwMQ+hUNGnMHqvXg54tWinIpKe8CH+/o5+qqg13NVmjRwbTlFUgDv05qxQe2+ Vi/A== X-Forwarded-Encrypted: i=1; AJvYcCVhRo7EOU1XFlo6brC/wZV6jOIhVH5H6fF9PHDRfb/Kc1U8JWwm1ABEiv1//Rjad1Te82Jg0w2scO+oaGg=@vger.kernel.org X-Gm-Message-State: AOJu0YwrKbDEA315Dft8qwWDpgoNMR3b+76hGGl1Re8B81vUdU9tLEgC fR/t9r/QB8U+lmlFqHpgX56MExIbPmseAGrIi3VAZTe72bZyZI7Fl5GL3cdQdxpynjA= X-Gm-Gg: ASbGnctxuLM7X69W2FmMr5xbsE1ctOWuqvjKQwepib5Z2kBgLfC5IOHyLlL3yMa84gO Ijk/hbrxRDCHQpgczYm0KLPT5zNobGIQrw/pbuTuKTFanUO9vQgAVEfWkxCLhQduF31W2JmFutc V+7M6m4pkl0YFmTDKWhtdc7gqRfo46hN0kb4TOxNAmn/M5VH9IfPD2BDiwv4nrykfdtUBIbs2Ey G3Er7T5jBCGPYV8O7bMflaAOlUWtvfdz5ZtfQ/M9wrxl/5L5apEogo1DjsoLlZeaWAnUNsY9hXY rkipyuBwLFt8+kOqhUwBOnn75RF0Z7HozKYiDrEZqHUFAL4Ma3p/IxoedQBa9evnmAUdTxScF3t Gmru6X0xcTyR/dvouowY4Qwe3QmgOYBcmqNuJzBPTQoqqhANjTh7LNeXYnMRLcKs0QrIJ+67adr 6I3LfoYBXoLb96p0HAUjRr X-Google-Smtp-Source: AGHT+IHtn8HMaA0Echf9v97EK95rBxusNCmaEB6z8oTn86z7AlsjYTu+w3WdhP9odmi/RB6ItLeU6Q== X-Received: by 2002:a05:600c:c8a:b0:471:5c0:94fc with SMTP id 5b1f17b1804b1-477c04cfb70mr212463515e9.6.1764154666538; Wed, 26 Nov 2025 02:57:46 -0800 (PST) Received: from ho-tower-lan.lan ([185.48.77.170]) by smtp.gmail.com with ESMTPSA id 5b1f17b1804b1-4790ade13ddsm36991765e9.8.2025.11.26.02.57.45 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 26 Nov 2025 02:57:46 -0800 (PST) From: James Clark Date: Wed, 26 Nov 2025 10:54:34 +0000 Subject: [PATCH v7 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: <20251126-james-cs-syncfreq-v7-5-7fae5e0e5e16@linaro.org> References: <20251126-james-cs-syncfreq-v7-0-7fae5e0e5e16@linaro.org> In-Reply-To: <20251126-james-cs-syncfreq-v7-0-7fae5e0e5e16@linaro.org> To: Suzuki K Poulose , Mike Leach , Alexander Shishkin , Jonathan Corbet , Leo Yan , Randy Dunlap Cc: coresight@lists.linaro.org, linux-arm-kernel@lists.infradead.org, linux-kernel@vger.kernel.org, linux-doc@vger.kernel.org, James Clark X-Mailer: b4 0.14.0 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 Reviewed-by: Mike Leach Signed-off-by: James Clark Tested-by: Leo Yan --- 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 Mon Dec 1 22:35:43 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 37F7F3203B5 for ; Wed, 26 Nov 2025 10:57:49 +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=1764154671; cv=none; b=iV5K/OxT7NnIjgUYuBm5IP/i3LLyyLqlDxsj9EGcyrO6tZXFyCiFF1j6Czv6m0VIkbhBZCu74GpfT7qPklz4tev16nXOQ6+4Y2wRDMDJeX/HYfAl40AHmN2hHpwJ2rKDuFNMsvckywa6I70T5U2DdNQkRgGSS8vAKfNNgozHfro= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1764154671; c=relaxed/simple; bh=3RMhptuDb6hntDjRO9PlAJUzplD9xGCbvBdoaETHrSY=; h=From:Date:Subject:MIME-Version:Content-Type:Message-Id:References: In-Reply-To:To:Cc; b=B6WPFo7sGzeKCYoROCExOG+J1QjIksUe8J2ftFQER6TC35OEspPzpQQoo7/P9J0FIEtR/Hi/L07B3ndcJoZ98gb7EB/TAV3WUmvplwVkFfW9pscHqPlk2BS3qtcABlVxl9IV46mirRqh2qMBDWWb9yUeaqyi5LCM6PCDhucj7no= 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=EYlQn71x; 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="EYlQn71x" Received: by mail-wm1-f47.google.com with SMTP id 5b1f17b1804b1-4775e891b5eso28128925e9.2 for ; Wed, 26 Nov 2025 02:57:48 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; t=1764154667; x=1764759467; 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=+aV97bb+2uBMzq9jHPPNimq5cmAOBpE8XZ5NB2YnSTE=; b=EYlQn71xEyU+Jk6NgAs58J2CycR/w3nTA+pjlr7T8BjNlBmSPNgu/iQFZYTm3qEZMJ GRU888FJJFod9tf9Ks+Qzvc0FHY149NZwf0uS3+mgBGpCxFtIASv3HXzX4+kQVGj74D3 rQs7m4f0DlTvHrMBXGxfrTb1uUUojKY0/FhjUn+fwy2swbytEDfoHF8G7p3/HEpj1JYa 2uzg3+m7wtLPNKfq1AkT2Lxt3or7bAmB8Y1YdgnIAQlEavm3BvcWy/6vntsz8Szkeaae F1WcQBp2jsVn3OSJLMVcYbrv/4l/bdJ8Eff4wCO5jSkniQ5htVkd09Vn+vPAcUJGBo1L aIfw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1764154667; x=1764759467; 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=+aV97bb+2uBMzq9jHPPNimq5cmAOBpE8XZ5NB2YnSTE=; b=qJDrIMmtOfs9cJXKIEbZDSDTemhfdGg+bdamCHQihakksRcA3nthWIIQiQgawLPGPj d0ET0xAkpGl57tX0mnIHBhq+sgGtFmYt2M2+mm2W52X824oC/reah2r8WO4ks3rXPtgT 3gQ4c14Sf77MBy9iw8US/O58JZQqmuvrfFxTuTxjTTdWPiZf5bOtIyw0xBjpL6e6ugUJ P785z76+dguLPRaIdIxYLvjH9dqccYjxFUMNzeNu5aQ3SoudZKQ4bvUkXV9e444WYlp7 KpRr9hWwrdFLon4J0VZSuVWhzFF7vW3ZqstWlVT2aLAe+VZXgo10rURCQY4/fVgGcabn MSjA== X-Forwarded-Encrypted: i=1; AJvYcCXoY9b3/x7rdv4KFCvl8jxnK92URNBWoEwHacXkDK0TtUrKIsTvWOUOmLhl9ycbeHHumRhcz38dYwwcok0=@vger.kernel.org X-Gm-Message-State: AOJu0YyWUgBmLGm1N8iueRXGRS5WiWBnrr/pdh4kTWxogfLZGPGHFxde 9gFXsp3yeYZi1x/lSwO4e9xwdLMrM3HjO0+j+DlUe3h5fVwjkGcQnN/kd1hAdiE+6S4= X-Gm-Gg: ASbGncuSXOk+xsJQYT22xgiHj5249ZgYDG47+LJFj4jEIepAIm5wTQ7Be1q8RtYwWut LJjSIaQ/s/qvKP8ua65sDtF/Gkg2pp9x8fvcdh/Ret7WVwRaO857zHgo4xMoW+9yUQ6qCQxhSYB 5EiBanKOpzMRVAkD8D9g0ZeD84EEnZoTRvRzMOvGzQfxZdvLPMD9Q87yHLZRLquUtRdiCugqAyP 8AuCKl8CwHMzmfe8K2WhgsOMr5o2s11kSCnr6ANPw+fwV0u8zQHHMf0eMe2jTUePeerZ36kA748 kNNlE3tzzXEikITlol+dukt6Xd9ba6rYQjRrsHh49Ffg9rN2U4AvYMXA7BwaeDWk3pS7n84fopI FwxIp59MC/lV/RU7n/SY2r9sk/bVU5IUOqMzfhwgA24Ag4JqhEusREN0RLOIO6Y8NvsVM0t29De hr/IJIRQJsnhzue24ve5tR8oh+emPhOKw= X-Google-Smtp-Source: AGHT+IHgGpVirZ77PpHdvUsmYCeB9BGpEg9syRMr1tRkkyQMuBNBfGSh/HLgcNOGSzBrV7ZuKkcwdA== X-Received: by 2002:a05:600c:4e8e:b0:477:9f34:17b8 with SMTP id 5b1f17b1804b1-477c0165bf3mr187105765e9.1.1764154667542; Wed, 26 Nov 2025 02:57:47 -0800 (PST) Received: from ho-tower-lan.lan ([185.48.77.170]) by smtp.gmail.com with ESMTPSA id 5b1f17b1804b1-4790ade13ddsm36991765e9.8.2025.11.26.02.57.46 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 26 Nov 2025 02:57:47 -0800 (PST) From: James Clark Date: Wed, 26 Nov 2025 10:54:35 +0000 Subject: [PATCH v7 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: <20251126-james-cs-syncfreq-v7-6-7fae5e0e5e16@linaro.org> References: <20251126-james-cs-syncfreq-v7-0-7fae5e0e5e16@linaro.org> In-Reply-To: <20251126-james-cs-syncfreq-v7-0-7fae5e0e5e16@linaro.org> To: Suzuki K Poulose , Mike Leach , Alexander Shishkin , Jonathan Corbet , Leo Yan , Randy Dunlap Cc: coresight@lists.linaro.org, linux-arm-kernel@lists.infradead.org, linux-kernel@vger.kernel.org, linux-doc@vger.kernel.org, James Clark X-Mailer: b4 0.14.0 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 Reviewed-by: Mike Leach Signed-off-by: James Clark Tested-by: Leo Yan --- 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 Mon Dec 1 22:35:43 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 2177831BC96 for ; Wed, 26 Nov 2025 10:57:49 +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=1764154672; cv=none; b=KMp1Hr0zhIdgs3iQxpqjLYYsEZ9inmAwq/bPhMzfMg2HqUOIZa7dwr4stMS2KEJ/VjktHuGaXv3Wekq3dTHZsOE/YT9aozaCwkJAHmVQy+G2cMBIOxrzPvnY8GjaMvRSeuoLcScN0k9/l2jSMXJt4sLUWDr8Pf2gTe7SFYFo4Qo= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1764154672; c=relaxed/simple; bh=yKxlaA0VFabZYUg02x6IGTfX6s+yKxOXOrwNzywmdiU=; h=From:Date:Subject:MIME-Version:Content-Type:Message-Id:References: In-Reply-To:To:Cc; b=dmETOXwaFWYNOXcImvANaylAkKm44X3E4NftIVNpgU24hteEl89RAgeR7qSdgZehM/UBfNhuTjsrvUSgquQsakHx5aIClFtVaxORbsTmlDzsWd0GaUZHwIrl3a1NGuZiMRXuhriRqPPTfIqT+OwrdCqvtgeCiCa/TgJvdyDYZA0= 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=IX4DZFP6; 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="IX4DZFP6" Received: by mail-wm1-f47.google.com with SMTP id 5b1f17b1804b1-477b1cc8fb4so37551335e9.1 for ; Wed, 26 Nov 2025 02:57:49 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; t=1764154668; x=1764759468; 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=HUVV/T8T4EDM+0Q4tOFA1c2x/rxW95efuxR6QK7Q7kM=; b=IX4DZFP6GgL6OQMuA1cT04e3F1y/lQlEgcCg/vlA9ZQx/AFPxSfywOPG5APf6RuLsJ +9Jwigd4EiU8GdhAFcaTcW/UPTMZGzGqLFBiyLCftwKbuxtOjCwLSNQW4Wx4tP496JEW jls3cOff3l8I+gfTv6o3E/rhixq2FaPc4O//+XvLVEQUmtuYX9sIOrefBLN0OErlzCj0 qGEHTkcxZnfnYD9+9AwODhiPCF52dxJeLKbQFx10lNRwVku4PfOkHVStQ49QWMsw1yA/ B8mwbi2sHHWkqz2EtvVyjHWOBTNGzk1N+b1NdUgs0En3FNt2kguUOxsBL+oZxmxfeoZq hloQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1764154668; x=1764759468; 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=HUVV/T8T4EDM+0Q4tOFA1c2x/rxW95efuxR6QK7Q7kM=; b=ftTkwPV2aBOk0EKBxDDweP0tNvu5gXAWv3322ZyJcwbmkB6UHvCuTNcaIFnETalqt9 xfh0cBEvhsuR0dqLepL3BWMZNV4Bw+CD8G4gfgRTPstMV4dXwNkODUQEs+Hcwm7nt4vO i1aSax4LLZZ5/W5ODfomkL0kK7q4HH+NEvYYxi56KJ+BusQ4+/obPfMRk65O3W4aKaLn L8GOfrqLq04UhDJ7OmRr3Y10hDMASqI6T8UXEyfrQIzByc5wqUxneVGSSuYPTYd1jQ3K VajCED7sbnH4FbCzS0jBlHqVBgo0jhkbIC6+W6egH+9baVFzC8u1nowvXY71ebtU2Des PQ2g== X-Forwarded-Encrypted: i=1; AJvYcCUGz+o3AuTxcEnTyM0hfD0hEUIDzmKsiod37cDiJhsoXydf1b1qQ8Kchr70fgGRHSI7MCfgzQOd0sce/os=@vger.kernel.org X-Gm-Message-State: AOJu0YwGBzc8ilZfrbSMSfYactbqqYPqgTln85+oge29FSiunKM7GrJY SEB7UhN8UxhXmA/qXIh8E43TcIguKkUvmvyNOldCXNn1MSBs0nEYn4NF6eNBb7+iKixlYNac6Dc /E2Jt1x4= X-Gm-Gg: ASbGncsqTpiZQLcBoFPXRGMEZD+aEzZmmBqr+dYz4H5LuLAEPF6FuYBxReuYEBQS9bY 9P3GCx6AfjPI1Fg62UGVtcxPLbVBp/CRZ3dxjFqyEIXiBfDhRaur318s/+vv32DbPOeBrZLwVDW aFay+LdXh/Oayt3tHAi4/wYNcIkmWMVy1WTwk2/LTW9Yov7j1fKj9NKogjI0D2VsGwUy602Hyw7 3lQ9/4JbFhcbWOFEBo8U1Vtaj/DollDVlQiqZPjC3qLNtSm7+WiCg0pIuZOxKh2p7PWtnOFT4wX p6iTU4gJ3BwEPOKmoHQ9QqvE8uI1uD4chMqcGAixwQbeQRJwQgC+IncyF82vRJkJGr7QjgQv/3o aTcqZnDa5VEMlRT1OMP4Fbu9pQ0DW2PY1Jh6k3yyFbdmd5tqjc8NYVDG6N/VY4Rv5GWJmHQ8Vgh uuvk8Q+5KpPlyCiIwAeHWo4nj4hL67pv8= X-Google-Smtp-Source: AGHT+IHr9OD/bYa7kCE9wYLO/nvBpjL2TDJwlh9xxTIxpSRsCk2PvkdlXc82doB+y4Iey6KXw6usdw== X-Received: by 2002:a05:600c:3b11:b0:477:8ba7:fe17 with SMTP id 5b1f17b1804b1-47904ac464bmr56206475e9.7.1764154668436; Wed, 26 Nov 2025 02:57:48 -0800 (PST) Received: from ho-tower-lan.lan ([185.48.77.170]) by smtp.gmail.com with ESMTPSA id 5b1f17b1804b1-4790ade13ddsm36991765e9.8.2025.11.26.02.57.47 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 26 Nov 2025 02:57:48 -0800 (PST) From: James Clark Date: Wed, 26 Nov 2025 10:54:36 +0000 Subject: [PATCH v7 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: <20251126-james-cs-syncfreq-v7-7-7fae5e0e5e16@linaro.org> References: <20251126-james-cs-syncfreq-v7-0-7fae5e0e5e16@linaro.org> In-Reply-To: <20251126-james-cs-syncfreq-v7-0-7fae5e0e5e16@linaro.org> To: Suzuki K Poulose , Mike Leach , Alexander Shishkin , Jonathan Corbet , Leo Yan , Randy Dunlap Cc: coresight@lists.linaro.org, linux-arm-kernel@lists.infradead.org, linux-kernel@vger.kernel.org, linux-doc@vger.kernel.org, James Clark X-Mailer: b4 0.14.0 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 Reviewed-by: Mike Leach Signed-off-by: James Clark Tested-by: Leo Yan --- 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 Mon Dec 1 22:35:43 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 D9518321457 for ; Wed, 26 Nov 2025 10:57:51 +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=1764154673; cv=none; b=fjXQNBoM6S0zvLhRm87gjDV6bpKyU2FLtbr+8b9KCtAk2QD37jDQKDBg4vL5B0oCvc/au6EusLdQuy0ycRM4NZbdvPKPpV4q5lsZsoKpF1FzqzDK7fautHXxFXFcwmaVQqgK6Qob8YfXnBuschoIC8Dxo11NQIoWMv0ui+CXwfQ= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1764154673; c=relaxed/simple; bh=TNcEQrNzvvULvrZwY1bi1KT31/DfIBlyOCzRtRN9s5s=; h=From:Date:Subject:MIME-Version:Content-Type:Message-Id:References: In-Reply-To:To:Cc; b=S2GFr8o+pLASLOAqZa3OD3w+Txnh/ps6NGmJ2muM4X+jJybsrS+CGuNVBtuS3oGb6JyP7QlKG4H5IfUbYTF9rk+A8H5H1DMF/aLSZQMnyWJqxE2WRWhKMuFP7OyHmiba2gT5NjUfX1uM1oxl4d7ADTGLU8HlFndM36vBPFyyrew= 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=OkyK9M7L; 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="OkyK9M7L" Received: by mail-wm1-f49.google.com with SMTP id 5b1f17b1804b1-47796a837c7so43378535e9.0 for ; Wed, 26 Nov 2025 02:57:51 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; t=1764154670; x=1764759470; 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=OkyK9M7L6IOvvT6J+v0UGLo0uuw5r0xC08qh3dKepdFl4dbEJWPcKzVGNcaZaEcUSj Nib1ZduXnzxXdaJrP51FuHvUvAKJE0n9ms2Uy2nygxVlCwToVUKYfoCYXVIuLAH7XVg5 F6THHDBwFgo+BJUhstFIqTfKVXINubo54iRnLcSqdU6dEZRu6tTX5R28YDN39Noe+IGm yTScUbKMP7PnYPwTRIiotTqxVD785GrICFhl12G6aGQUefAmkk+LslGgJLgqeHN9/l4v JVwfW5z/mA859QMKrvfCXMQfr90jnMQ0Kl+dE8R7e6KsUvL+SVyEg/7qvVmmOYVlwWNQ SogQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1764154670; x=1764759470; 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=gMUoc0D9M5cQ2bFWcAMEdr4AFkZKshuE11+xaJa86mraNRXFpveTv6IBz25sm+uPBw FX1AhUX86EzQtYoC872qA0m7g1ihtTUzrOksavllWv7T0Su+ABgQ/r3vaZ+ejlA4iPz/ Hm6tzS7L5Na+wmkdfrOkNj5y1PWxe6/Qj2jyGwqzx//jG9R4y64PiYncM2XfJPScNxqL q6BRjQkZA3KQ80B+dgN+VipOP03/sbc1xPkrpgTdRWAdElWiW+Lcn/mRXEbOfclTXpyX kM6I3iAirIweanYy4uz8H4ZByQpovp//zeGANGmxygHHaLUEefrkVUXQA8GRUCwghlvG QIUg== X-Forwarded-Encrypted: i=1; AJvYcCUtFvJsH4uvcpzrol5O/5Y7fubd5Kwao6nZygN8wBfO7PNW/B0mKQ5XM43AcM1+x809TuAICnRmB3GdfGE=@vger.kernel.org X-Gm-Message-State: AOJu0YyD43hy+5DSBis+QelD8xzi9pJcaBMGW69dUJu8f08L5uXrMNMV BdZl9lu9JF91gVUDbta5D6NnGC46PPjJhl8F5WJh+L9PzaqbY0rtHkWOa/mKbX66AGo= X-Gm-Gg: ASbGncs/fDAIHrH2UhiIyFuew6+HEKHIqySKL3/R7NPhg18jFcBsyJbThAdjXf5o21p EXB/VSYbVFCWvU+saZTFhhTErfcf6BEOWjABTHfqx1Rg9DCYabfo6ftBx8XeR4TXaUEF9qYL9Tm 2485B8EuermiyXHArXm/11wGM4OSz+65IZg7cUlEnWRIk/q6LDpaKS/p90pnHB2UrCNHG2F8rsW UF7wFkgTyEicI9kifVzNTEwz+VrYhTUceUGGPaj4M/HCdsh477j1o7qkg6dlJpngX0POaM1uSCU w2WJHeGy116w2vVmG/jiJZsyrXitstfEAhYw/0EVN7h/28q87HiymrevWwrFSr1cuPoFwDZHbq+ YyFcsCcDWBKCZAvYUOnWinRsTtTLSSkUhuVAiDbX1VJToR9seadcxqTEuzue3uVAkNMNe0Mkkj5 UTFELMseXOC9Oo1vXcEnzj X-Google-Smtp-Source: AGHT+IGJ2v0yxKZrimXOs4gdJGwyABW10H3d7x7EO5UfBg1Qo/N3VaSJ69gFaHjyPQmsOrFh8yPBvA== X-Received: by 2002:a05:600c:3541:b0:477:7f4a:44b4 with SMTP id 5b1f17b1804b1-477c0162dfamr184534115e9.1.1764154670166; Wed, 26 Nov 2025 02:57:50 -0800 (PST) Received: from ho-tower-lan.lan ([185.48.77.170]) by smtp.gmail.com with ESMTPSA id 5b1f17b1804b1-4790ade13ddsm36991765e9.8.2025.11.26.02.57.48 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 26 Nov 2025 02:57:49 -0800 (PST) From: James Clark Date: Wed, 26 Nov 2025 10:54:37 +0000 Subject: [PATCH v7 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: <20251126-james-cs-syncfreq-v7-8-7fae5e0e5e16@linaro.org> References: <20251126-james-cs-syncfreq-v7-0-7fae5e0e5e16@linaro.org> In-Reply-To: <20251126-james-cs-syncfreq-v7-0-7fae5e0e5e16@linaro.org> To: Suzuki K Poulose , Mike Leach , Alexander Shishkin , Jonathan Corbet , Leo Yan , Randy Dunlap Cc: coresight@lists.linaro.org, linux-arm-kernel@lists.infradead.org, linux-kernel@vger.kernel.org, linux-doc@vger.kernel.org, James Clark X-Mailer: b4 0.14.0 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 Tested-by: Leo Yan --- 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 Mon Dec 1 22:35:43 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 91392322A3E for ; Wed, 26 Nov 2025 10:57:53 +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=1764154676; cv=none; b=tixYDySwzCsIdi0RTZpbJQndS+6psp/qQKui23cqLREDbG+hFy7WUQnh+K0jN6snkvOY7TDGPwGFpvp0gk5JJOBlluS6ep1+/z6NcHFPgsX3tbRbkdl53gUlqBz/3WpjBrFlT0tRbBIkMqgP/a8Zzb/B7qDRNywa5K65bWDBDiE= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1764154676; c=relaxed/simple; bh=LNCyuYyZmkWFZcCqoVNFMP/DsVAdzv6MiorRrcgFSHM=; h=From:Date:Subject:MIME-Version:Content-Type:Message-Id:References: In-Reply-To:To:Cc; b=UXxQvJac5rMfpV19ObTwFR+TYkriJ+vPLZBWda34OME7mDeDMx3TUcQa/XhULuk10PEphjerKGQx8NQRCzJ1eez2fueGzvTpwCCmeW/Iv1j/AD6FV8imZKUvpGUqtsEnIhGbY5Z0gncDC073JZigsYZM60YK8JJCETa0hGRakI8= 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=vYuiwAQj; 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="vYuiwAQj" Received: by mail-wm1-f53.google.com with SMTP id 5b1f17b1804b1-477a2ab455fso70023335e9.3 for ; Wed, 26 Nov 2025 02:57:53 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; t=1764154672; x=1764759472; 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=izIPWfoS9urp2dV3KvMRs2YvnYc7bdRi1OjC6bRCVDU=; b=vYuiwAQjExtVgjiUxJgfJuSREOqO+DrzX8ypIUL53sNMoCjsYZq6MUD2h92fa2sPUA SyXA3PSk3UuC8aqFyBITdminyybWze/Kr3C+pu2VP24YCS48J/iRY2NHZqRxf1F7f+O5 L4TQ3JULkmDIdNmcy0lUwUYFhim29z+UbEpto44jpTtBCcYxSbBuSsBRZUxeIszd0Nbh p8B95okImEOyMg5rz4i59Qhg19Ing/HMWIMMMgIeS6Zvk6dsx46VKECeOZte37Lx8Mh8 2XNrpDbr+f8UvQMxo/7FEGVwcnV1HGLcjsLVAAkQhRe0833xI+greuhNor/La4kHS3nr y7ZQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1764154672; x=1764759472; 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=izIPWfoS9urp2dV3KvMRs2YvnYc7bdRi1OjC6bRCVDU=; b=MzJpHMoZKJopdPxVUG03XNEXVRQSs+o7KDYWLUcomOAf3EpEXcSzYibtcN7KpRknvd Min40jZh8UtUfLvK8EoblTln2GXuS61R1Ak1bSh79n/z1F+g97dZe5cOo1vDwY9UrfUp WTiDUOVdOo/jetV1sBmILE6K+FRbSkyyRbDnKkcu0y7mrfSM0h0SbCCp+yo0OiBg2EsZ SnxdKit30ANJDwusya5PyUBukJXwcUSNwhY/TLEyjVoXuAajkJ4TaC16JPXip3ItB4bL hfArrrn/TePNJ7DsHZWrfLOqvtQOy2TiHQ1TQfaxlWQv/V9r5x/4JUB4TKdAlYWqrLdw oYmQ== X-Forwarded-Encrypted: i=1; AJvYcCXgoCDUwT+Be2zHVQUNANj1dLqm83fXaA25zvDpq56eFPBNC/crcUB4YWlhK0G79Rk9skOm2CdX3b1quGI=@vger.kernel.org X-Gm-Message-State: AOJu0YyZRqLHC1w+1ugBzBeXp+tOS8wgVGif3TfmhZxnGqk0p9iMWBbs RUmc5GFrTnVcHuIrO8X20ItVwBLJ9y5zsfZNvyA+6N17JPHVPMEApf7cz8ro080sMGk= X-Gm-Gg: ASbGncsx5O4lxPnr07DcAS5xj0y0DjiC7a+0tqeZB/G/oKSRyxhe10Nm3R6Z+UEPsIu G3trHcCFmaqcU0Hu2/EHNGaPbeoQcUIFbiug2nMvSdYSKwTQIG7VCGU5jOK6Di8ksG6g6q/PYWT J0RqEfxQllavwN3b4XdH7ewM/M0yCadw1OeECAP3pzR8WcVrZ0CSJoNC8/QQ9XGxjU2KeLURRsZ QB9rqhVOx3X2lnxpCXfzD362X19VUsZ1t2t8iaeJ4Yroj+yC9eP06HBvrBTzV85b861Ir+c+upN IInsCjwlod1o0RQFrOgqy55ULPo5C3wQ4j3FO9LiJHkiqZHGQ/QXAZjMxdBYa5fcSiW0rf9W/7G 8pMb8T6o06o1VlOu1sTVxaA0ZwflOl756mq0H8Xf2PWDRh7QyOnYmr1qhJHxlfuo/b0I8c6DNwf dfkz3e5SYxt2q5VWxABKzC X-Google-Smtp-Source: AGHT+IFAR6c195gOhTQz8dx6OF6n9ZtTYJ2jnLXbzOQvfTE9XO9dATUae/AlsEqPzIc2s5OhSaCgDQ== X-Received: by 2002:a05:600c:46cd:b0:475:dc5c:3a89 with SMTP id 5b1f17b1804b1-477c1136b7fmr175263115e9.34.1764154671907; Wed, 26 Nov 2025 02:57:51 -0800 (PST) Received: from ho-tower-lan.lan ([185.48.77.170]) by smtp.gmail.com with ESMTPSA id 5b1f17b1804b1-4790ade13ddsm36991765e9.8.2025.11.26.02.57.50 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 26 Nov 2025 02:57:50 -0800 (PST) From: James Clark Date: Wed, 26 Nov 2025 10:54:38 +0000 Subject: [PATCH v7 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: <20251126-james-cs-syncfreq-v7-9-7fae5e0e5e16@linaro.org> References: <20251126-james-cs-syncfreq-v7-0-7fae5e0e5e16@linaro.org> In-Reply-To: <20251126-james-cs-syncfreq-v7-0-7fae5e0e5e16@linaro.org> To: Suzuki K Poulose , Mike Leach , Alexander Shishkin , Jonathan Corbet , Leo Yan , Randy Dunlap Cc: coresight@lists.linaro.org, linux-arm-kernel@lists.infradead.org, linux-kernel@vger.kernel.org, linux-doc@vger.kernel.org, James Clark X-Mailer: b4 0.14.0 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 Reviewed-by: Mike Leach Signed-off-by: James Clark Tested-by: Leo Yan --- 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 2ec2ae1fef58..b457f182efbe 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 Mon Dec 1 22:35:43 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 6C51F3233FA for ; Wed, 26 Nov 2025 10:57:54 +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=1764154676; cv=none; b=ZaqxvLkZczNa/CNxm3cq+GkrWYlY+WnbKzM29tbkHxBGkeLev60302vJm1vIsx6Mi0DmmYXN6iENG7T8gKSLIEtZ5BoltWvEepAFD+SHOWS2ithXBdFKL6Wov7Ce7lF26wQJvDTZBogDcb+5SZBcA9TKyv7M94mecMC6+qx8uck= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1764154676; c=relaxed/simple; bh=zhAtZbOFS/+SCTOmEDuRkm71lHxbpzSZO3V+eVr0zZY=; h=From:Date:Subject:MIME-Version:Content-Type:Message-Id:References: In-Reply-To:To:Cc; b=h4M9yISpLAHtvUs5ktBnVWTOuZZQHPvkJ+B9sebIgxxif9dNKdyq1tC0xfpOZ8lEDXxaqMKuOCw8bPjL6tvBHl0lYSLb+ZNXQIL2jkoqOoq4ynTLDnAJMktM7z135+fRDzHRYRlBNxch3bNdsQUqy9R2t19ufJecPivpUyWTvuc= 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=gV2sugNO; 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="gV2sugNO" Received: by mail-wm1-f54.google.com with SMTP id 5b1f17b1804b1-4775e891b5eso28129365e9.2 for ; Wed, 26 Nov 2025 02:57:54 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; t=1764154673; x=1764759473; 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=Q5aXjGQaEIx9QnRUCqph1nXShW3UVlX6C3Ll46vEA/s=; b=gV2sugNOywAB1KZcwgXJ9Jwq/BC7K7W7707dvqsq4Fvh9ryqtUd/8kmpsfPBQVop1U jQ6/iuDg/zLVBwID9SMxWmsHuDRJUxVO55qOG4I3fJP3ee0HBbZxyt8IHWerc8Yrkuvb PFlP31pwwxiiTec93HqWGbf2VJQPvij2bo1HzrLb0Nh42mnxPwEGV2CiFvufOyCIuCq5 KhBXA3Z2sPDOFCPfhL24ufG9RMBOqPlt4G08kzK1h3K7fmSKM7B4MLAsmxMTIdpT95Mf k6SZMpOZvib6gpLp/UO45HSuUEnQ+tE+EiSWY0SQ+4GJkexzGSXFjAQ2DsuBsnn3Oovb cW6Q== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1764154673; x=1764759473; 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=Q5aXjGQaEIx9QnRUCqph1nXShW3UVlX6C3Ll46vEA/s=; b=CYpMVO5yvxQ+cA393fbAxkrGqn6ooWE4SN4eUS4jIzhaiFjoQRljbtaZ3Y2RuNWk55 jVradyfVe68bCbVa7HD0hWbLlpFjk0+5AUtdN9IpnL0h3IQhDcaM6+R7xd0PygCKQoP3 2MxBbagSOVvE/OAc8AGZybuMBRQlZtWspKC1ZYo38CXoX/WSjDQ1vZcCO+ylmheSG3BC 2f/oN8pnO+m/MVX+SHB7hdM3vhAaBt4xCmxVhtt+7Q5OuPnD+1hEgWw0m/qN2mxm9vCX w/gsfA4Y05JAvWezblM/hDXnvtQrQr6rA+lfAjOh43clvCLziGwiWSP95dTwu4hksyAg TiZA== X-Forwarded-Encrypted: i=1; AJvYcCW57smCOC0wIalEPovkUjRcnyA/w90s7B2qcYDpPeFJV4BFWlGJe5udr7ApLj6kzpxdk9TBVs6oe0WrylM=@vger.kernel.org X-Gm-Message-State: AOJu0YxhHKGVZx3cRRSQ1ab0wJ0/g6/2845y9c89U0/IcSE61KRXHham MlyLHJ+vtak8xtXSigdbiMncRmSVT7SxnVFfRKgJVbANnR8huN8tA5PDodMpb8BYfc8= X-Gm-Gg: ASbGncvBxegA90p+olGSK0Jp1DlMBuKmDA5mFvDZNXGpGnJzsPg+b56gNsOj1wr+cUE DDC3d/RCG6IqxOfgvyfh6soCa3qBQTixzSzGHeCxwrKz23eRdS40AUBcsILA0ofREdAMjT1kcbP QPMVhuqZkl8lqsWyjqncP22yvgXdR/Lt1O+F6CB0SNaY0axa/K2ojkPdhXFKyt8ewEPlpCxXZHP lNjOgeGozlgNxceGJociX5imIiRLoGLz0GhhYw98Rz+LAHvC/jUxre3fWWlxI5VglJdb/cWiaqd IyfXNWZCbkIjnY3NhoXlhGrqBAjxJZgjYarNhATW9j3xL43Zf8rQ+MBgNkndvRxmLttsDKiTVle Awl2gOR/E+ZMnTGV6X6Sm5CANSRhTWQ709mpblPT5XHiEYODSmgP4hhMWdCLBrMo87VW4Ia+QES OGfZZmuRYttP+62ZR9o7R9 X-Google-Smtp-Source: AGHT+IGR9TSNU0qxbU9T+pWTN/C7ccbsqOSfxUJvTfeKj2/349hgmV74rQwiM9Qy4pMFnvlnbdm6kQ== X-Received: by 2002:a05:600c:1c88:b0:477:9cdb:e337 with SMTP id 5b1f17b1804b1-477c0165badmr221349105e9.7.1764154672854; Wed, 26 Nov 2025 02:57:52 -0800 (PST) Received: from ho-tower-lan.lan ([185.48.77.170]) by smtp.gmail.com with ESMTPSA id 5b1f17b1804b1-4790ade13ddsm36991765e9.8.2025.11.26.02.57.52 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 26 Nov 2025 02:57:52 -0800 (PST) From: James Clark Date: Wed, 26 Nov 2025 10:54:39 +0000 Subject: [PATCH v7 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: <20251126-james-cs-syncfreq-v7-10-7fae5e0e5e16@linaro.org> References: <20251126-james-cs-syncfreq-v7-0-7fae5e0e5e16@linaro.org> In-Reply-To: <20251126-james-cs-syncfreq-v7-0-7fae5e0e5e16@linaro.org> To: Suzuki K Poulose , Mike Leach , Alexander Shishkin , Jonathan Corbet , Leo Yan , Randy Dunlap Cc: coresight@lists.linaro.org, linux-arm-kernel@lists.infradead.org, linux-kernel@vger.kernel.org, linux-doc@vger.kernel.org, James Clark X-Mailer: b4 0.14.0 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 Reviewed-by: Mike Leach Signed-off-by: James Clark Tested-by: Leo Yan --- 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 Mon Dec 1 22:35:43 2025 Received: from mail-wm1-f51.google.com (mail-wm1-f51.google.com [209.85.128.51]) (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 8014F3246ED for ; Wed, 26 Nov 2025 10:57:55 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=209.85.128.51 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1764154677; cv=none; b=kaGTa+KiCGNQvYhHWETlvKoXBKbmTJAizzZOoZCj4/u4KJRuTvmv8yqsls9/vHOplyQEllI6HQMa3Q08A/55wp+L9o6upqk99cO+xF4mXUSuFlojf1Blmqq0BXdwi/7s+bEQsrUnYPcyCWD845s1yBbw5mz2s15YSvjUF/p+Wzg= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1764154677; c=relaxed/simple; bh=XfsVAbfflmddsFvUZmGMPKpPfRjWdP9dqrqERzlZQE8=; h=From:Date:Subject:MIME-Version:Content-Type:Message-Id:References: In-Reply-To:To:Cc; b=QRBuCrTOlPwdCaVyAyOkGUcHiOcak/DbrKcE9w+MUENEgu6oB5GxB3dQQD20Hu3qz1g4eS9VWNytvxJXsElV6GnxFg+onn1hypxDMyM5zz6ZGxjLCCU/s1GPW83fOoOmkMVJMn90MvgqHC+qX8JX9wtbYoUEoviAxc70AcJnTe0= 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=T5cAPjMR; arc=none smtp.client-ip=209.85.128.51 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="T5cAPjMR" Received: by mail-wm1-f51.google.com with SMTP id 5b1f17b1804b1-47796a837c7so43378855e9.0 for ; Wed, 26 Nov 2025 02:57:55 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; t=1764154674; x=1764759474; 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=Bwt8cEG57tdOF8BASxzVxlljz5Pjbs6lZvjUWFDTXHg=; b=T5cAPjMRmtuQ2af7ao3JdlTedxsZOJpiEJGODWZVks/2QwpGl5ZDVdS61AKB87HYFI 2LSRlJQmo1Tw7zWUFjcz76WIKoQEcUtB//juNA6LUNo4h9D+C7K0EHK1j9cliu5L64Fw 5OQIDqCa9FH/nB4aFN2ewjrw32Qo8Qaj0sgXB0ChfiBrgEXTbYftzQhzZuZEVbOmUHtY tY52rhlZfGo6rCvKGlcr1aOF5eDky2km0uG8w3im+Wy7UfAGzcZ9Iv8WyFtbmkzkEVVl gE3+nPKbnGRAJkC9rGOzw3mnhRcuK1opUu6MF80Ta0arlwPUdDJyTcuBikXnNV8gREIT b7zw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1764154674; x=1764759474; 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=Bwt8cEG57tdOF8BASxzVxlljz5Pjbs6lZvjUWFDTXHg=; b=PZMo8ouUBvzqgAusjcOV8bDrfaDRmbTLbAPDK4fhy+tLgZFoh4g85t6zP9CUcyyFPK TBVUrnMruLtpZ3mxUiyPSJMgUm506mJj7G1OR4SGvPwVZxqX4NdLhRxlH5oOlR84AugT +nsTM2B8sar8vaiOXM+7OQQ/HtTNov4gh10RAPmNzpXN9L9T9yJyQZsjxnQMZWMB8L19 +W/emLuiXHrvOCL5hwTZlmnLIXb9eIDzFL3tzsVs4u71XTpCaaFtOug4TmR8d6S/EDz1 7Jp4DNnky6zUKgmVyPwg/Y4cv8szt5bNwCblsu+12nPLNC+AiKAfZ4WnN74hJWTXdFK6 oZlQ== X-Forwarded-Encrypted: i=1; AJvYcCXERV03M8zhihRC6BcFLcgTFeLWmKnCfOx7FK86jBqn8R+ohlftMr5AV37zq5C4NA96zQxOJqgknwtwoUw=@vger.kernel.org X-Gm-Message-State: AOJu0YxeiQUq5kAll+/0DxMSKDlXXy5Q6hVyidxh+bypDVpJn7yzL3K8 rWHlueVXOlFIOcVSgo0G4B46jRaT1ktu19BTWRl+6V9lCZFkfNRbmn0gP9kLQJ2o6VQ= X-Gm-Gg: ASbGncvmwSO+JFWd+Fs1tpgeb1wOSXjcocHScyX0oNhQW95c2amYHsCfyQGROShSuzW EF5yD5q3XgpPQTzuspQi1yRx84cPrMWzVlYyXwnbIZPQNAaTLIa+lYDs3kM6WWj8A6z8IqLvtVe FNrt5a+OiLr9OV1ohWHToQQv40sB6Q9Xvd0oBYfrkXZ+fKyZkCF1Ns+B731JC3gOPR46q0oS6Fo gYjkCtyi91Qn2gYuqPqnrI41LQ+hxj0khxFfMzZ+n1OTU0AylDK2t50kbX5KRoGBXXLoxCqErir qVSJcomQaYJOGd4hA82lDTf84cP/GAX283Mf3HERkg8RwAAPLQn0+eZIgUNI77psMUS3tn24+6V AAp9XukMqLmyOfHmVFnH+Bj7TakXo13Ouwjk8w8ufcpR2PA/S2a4sNawTZxEvWOdz1TH4atTGcl X4HmHS/eEN33jMmo0LIjv5 X-Google-Smtp-Source: AGHT+IHu3VMV/nia9zExacgXf1CG1quUw46Gmf589tkbMqB6kt7gsqIoCudhkMzjlBbUakuyMJJKdA== X-Received: by 2002:a05:600c:4ec7:b0:46f:b32e:5094 with SMTP id 5b1f17b1804b1-477c01ea075mr176599335e9.32.1764154673792; Wed, 26 Nov 2025 02:57:53 -0800 (PST) Received: from ho-tower-lan.lan ([185.48.77.170]) by smtp.gmail.com with ESMTPSA id 5b1f17b1804b1-4790ade13ddsm36991765e9.8.2025.11.26.02.57.52 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 26 Nov 2025 02:57:53 -0800 (PST) From: James Clark Date: Wed, 26 Nov 2025 10:54:40 +0000 Subject: [PATCH v7 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: <20251126-james-cs-syncfreq-v7-11-7fae5e0e5e16@linaro.org> References: <20251126-james-cs-syncfreq-v7-0-7fae5e0e5e16@linaro.org> In-Reply-To: <20251126-james-cs-syncfreq-v7-0-7fae5e0e5e16@linaro.org> To: Suzuki K Poulose , Mike Leach , Alexander Shishkin , Jonathan Corbet , Leo Yan , Randy Dunlap Cc: coresight@lists.linaro.org, linux-arm-kernel@lists.infradead.org, linux-kernel@vger.kernel.org, linux-doc@vger.kernel.org, James Clark X-Mailer: b4 0.14.0 '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 Tested-by: Leo Yan --- 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 b457f182efbe..c7bf73c8f2d7 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 Mon Dec 1 22:35:43 2025 Received: from mail-wm1-f44.google.com (mail-wm1-f44.google.com [209.85.128.44]) (using TLSv1.2 with cipher ECDHE-RSA-AES128-GCM-SHA256 (128/128 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 8191F2FB990 for ; Wed, 26 Nov 2025 10:57:56 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=209.85.128.44 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1764154678; cv=none; b=aajNacmb1KXSFukj2oRArOj1RUcNF+64L4amQfvyoT6O9f9YWsRmDjw+C8f09NbKkiNh9tX0N8cwO2QlVVyCyi+aTMix1xrM7izwfDEYHocjLBNEYg102HGs2Dnrp7b/572KwuVuRvtBOMndiKGUdc4o0/oNVUW4pVEnogYl6Cg= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1764154678; c=relaxed/simple; bh=Rp3iLFIqXnrF+0pIOR1MFfkShwiH6j/y0U2d1eAux9U=; h=From:Date:Subject:MIME-Version:Content-Type:Message-Id:References: In-Reply-To:To:Cc; b=Ds6N7z7cLJAj/cA9WrqL+1RdDI15Z42XZ1uOmmViaZrALGuzWLELTfSgzIPQXEpS6PNeZ/RpSakQ1dThTWKi4FECoAzW3f/F6vySq0qncTjqn+Hv4lRnL7NPoXpcmdbnhwLE/4umqsphaLSVQ7kIJfIzrStTz//Oc8Id6qBrv9Q= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=linaro.org; spf=pass smtp.mailfrom=linaro.org; dkim=pass (2048-bit key) header.d=linaro.org header.i=@linaro.org header.b=YiE8hWDO; arc=none smtp.client-ip=209.85.128.44 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=linaro.org Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=linaro.org Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=linaro.org header.i=@linaro.org header.b="YiE8hWDO" Received: by mail-wm1-f44.google.com with SMTP id 5b1f17b1804b1-477b1cc8fb4so37552055e9.1 for ; Wed, 26 Nov 2025 02:57:56 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; t=1764154675; x=1764759475; darn=vger.kernel.org; h=cc:to:in-reply-to:references:message-id:content-transfer-encoding :mime-version:subject:date:from:from:to:cc:subject:date:message-id :reply-to; bh=/aL0yo6fi2WmbAku9VkxCsuHLTyCNr7C/0ei4wqWf00=; b=YiE8hWDOEIyEMd3vShVlX0/sf1D6FQB0aUzZv28pjtzOZDSgJwjZW6z44IsbsMt/+0 zDmudnFj4RW51F312R98glVhctXPEGLkaCVOJ4JpE01eRinLxuIBcLbxJQQdU2OeDDsF z+kZTvxMjp4lhDCdy8kiq7soKXBEJX0btwooPssPpZHzVjipgvsHXKfTVtNLC5QX85/p xyy9lpKRk07GDfBeKBvcIBDMWrQH1bq1O3BvGxog7aYn/uKkH7vwzvTXHx6hTv9LEnfD GO5z+CKUqrnDajaH6RUus6m+rr1pOWRuzHLZykO3Uwl2AySHOcbCFPbjA2zwXTJN7t0A uBvg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1764154675; x=1764759475; h=cc:to:in-reply-to:references:message-id:content-transfer-encoding :mime-version:subject:date:from:x-gm-gg:x-gm-message-state:from:to :cc:subject:date:message-id:reply-to; bh=/aL0yo6fi2WmbAku9VkxCsuHLTyCNr7C/0ei4wqWf00=; b=dEbJD2yFw9x/SMaP7OGfdLYY9JxXFSaw87EpVi/SeeOZVArKk+1qfQCP4N3tNOVXkq OsFlskBcK97vGfBYD4R0GayPlwGXYtlhySV0Hrj9sVAI7Edu8SINeqkFdIJ0YhDNh55Q REZLLgjQX2/eVHXQY+Ava/VKxhj2uDOtGEMpb1ukiueNp1c/R7l9RnB1BBoSYvvJYtbp odL6LmfURIROO8+n6kDOY1pPcFVsrq3XKMNFqpxbMZU52+AZUDpKhHGTfYHtFK/OJZuj txa8AXjzH3juZKRyKReiUPG6xsmi7SDe+5NzYQABzA8qlaxIGyXitCugM/EgMgJMFxZa dfOg== X-Forwarded-Encrypted: i=1; AJvYcCX+Kbt4cuPBzgDhgasb97+Cn+tdH3WjH9zTpe46SHu66TV/KawNdz17dgk0bM7ZKYX53n5r98P9jX1vXOo=@vger.kernel.org X-Gm-Message-State: AOJu0Yysdrf6B166SC7MNO9X6ic6zCq3Khm4bT8evR9mY+CYTZj4E9uF HO1FXhBZRzdCW1HhSnoD4vYtj5KeLJpJVzKbqfFx8qtQPDkCRqKdXynl2Nkjl9g0Guc= X-Gm-Gg: ASbGnctlCcDdo+GfbTgrb73ghh/G6GPR7WZHDCGpIuc1Q+h8s+XG/asQM8AFLG5IrNn jU1MqL8X3wQe6ftFNHUnt2vNgEBgQ2JJ+zyFkOCCFM41/dVBcJjx8qZIxpEBWSwa+fZY31KUjsP CZInOZ2RfDqJa35R5Myfea2UADZnbwAJnrCB4lLEHdC1u3T4VxzaXheRBMCL7R/zrflrplkW7LX 0VSG/riaJZYcDbMlnk3OVxHamkdssmvljRwJRdW6NmlKDv81PkhvCK/w9sTzdL6//1Fzux90VWh TddpbA6Rd2IWAK3Mjt9j7376IDxYjBrlkRdfcHj992E2rfdbi+QOOcNOwvSaHuQhdPQkem982hD 08FsRxfiuHhRIm3cbtNQ00c4jfVvUBkZUGYE2eNP7kAnalIyQ1uo/1yL9MQZ97gidu0tA/4hShh LuXgn2hw4Ua1hps9V3w0S1 X-Google-Smtp-Source: AGHT+IGviTrM1sSe4rL++DrBqXnogXlxDeacPexepOhL2fMVFW83P2kdlvQXu27F0Wvm9C0S2kRhBA== X-Received: by 2002:a05:600c:3b11:b0:477:8ba7:fe17 with SMTP id 5b1f17b1804b1-47904ac464bmr56208955e9.7.1764154674704; Wed, 26 Nov 2025 02:57:54 -0800 (PST) Received: from ho-tower-lan.lan ([185.48.77.170]) by smtp.gmail.com with ESMTPSA id 5b1f17b1804b1-4790ade13ddsm36991765e9.8.2025.11.26.02.57.53 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 26 Nov 2025 02:57:54 -0800 (PST) From: James Clark Date: Wed, 26 Nov 2025 10:54:41 +0000 Subject: [PATCH v7 12/13] coresight: Allow setting the timestamp interval Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Type: text/plain; charset="utf-8" Content-Transfer-Encoding: quoted-printable Message-Id: <20251126-james-cs-syncfreq-v7-12-7fae5e0e5e16@linaro.org> References: <20251126-james-cs-syncfreq-v7-0-7fae5e0e5e16@linaro.org> In-Reply-To: <20251126-james-cs-syncfreq-v7-0-7fae5e0e5e16@linaro.org> To: Suzuki K Poulose , Mike Leach , Alexander Shishkin , Jonathan Corbet , Leo Yan , Randy Dunlap Cc: coresight@lists.linaro.org, linux-arm-kernel@lists.infradead.org, linux-kernel@vger.kernel.org, linux-doc@vger.kernel.org, James Clark X-Mailer: b4 0.14.0 Timestamps are currently emitted at the maximum rate possible, which is much too frequent for most use cases. Set the interval using the value from the timestamp field. Granular control is not required, so save space in the config by interpreting it as 2 ^ timestamp. And then 4 bits (0 - 15) is enough to set the interval to be larger than the existing SYNC timestamp interval. No sysfs mode support is needed for this attribute because counter generated timestamps are only configured for Perf mode. Reviewed-by: Leo Yan Tested-by: Leo Yan Signed-off-by: James Clark Tested-by: Jie Gan --- drivers/hwtracing/coresight/coresight-etm-perf.h | 1 + drivers/hwtracing/coresight/coresight-etm4x-core.c | 28 +++++++++++++++---= ---- 2 files changed, 20 insertions(+), 9 deletions(-) diff --git a/drivers/hwtracing/coresight/coresight-etm-perf.h b/drivers/hwt= racing/coresight/coresight-etm-perf.h index 24d929428633..128f80bb1443 100644 --- a/drivers/hwtracing/coresight/coresight-etm-perf.h +++ b/drivers/hwtracing/coresight/coresight-etm-perf.h @@ -7,6 +7,7 @@ #ifndef _CORESIGHT_ETM_PERF_H #define _CORESIGHT_ETM_PERF_H =20 +#include #include #include "coresight-priv.h" =20 diff --git a/drivers/hwtracing/coresight/coresight-etm4x-core.c b/drivers/h= wtracing/coresight/coresight-etm4x-core.c index c7bf73c8f2d7..0129b0502726 100644 --- a/drivers/hwtracing/coresight/coresight-etm4x-core.c +++ b/drivers/hwtracing/coresight/coresight-etm4x-core.c @@ -651,7 +651,7 @@ static void etm4_enable_sysfs_smp_call(void *info) * +--------------+ * | * +------v-------+ - * | Counter x | (reload to 1 on underflow) + * | Counter x | (reload to 2 ^ timestamp on underflow) * +--------------+ * | * +------v--------------+ @@ -662,11 +662,25 @@ static void etm4_enable_sysfs_smp_call(void *info) * | Timestamp Generator | (timestamp on resource y) * +----------------------+ */ -static int etm4_config_timestamp_event(struct etmv4_drvdata *drvdata) +static int etm4_config_timestamp_event(struct etmv4_drvdata *drvdata, + struct perf_event_attr *attr) { int ctridx; int rselector; struct etmv4_config *config =3D &drvdata->config; + struct perf_event_attr max_timestamp =3D { + .ATTR_CFG_FLD_timestamp_CFG =3D U64_MAX, + }; + + /* timestamp may be 0 if deprecated_timestamp is used, so make min 1 */ + u8 ts_level =3D max(1, ATTR_CFG_GET_FLD(attr, timestamp)); + + /* + * Disable counter generated timestamps when timestamp =3D=3D MAX. Leave + * only SYNC timestamps. + */ + if (ts_level =3D=3D ATTR_CFG_GET_FLD(&max_timestamp, timestamp)) + return 0; =20 /* No point in trying if we don't have at least one counter */ if (!drvdata->nr_cntr) @@ -704,12 +718,8 @@ static int etm4_config_timestamp_event(struct etmv4_dr= vdata *drvdata) return -ENOSPC; } =20 - /* - * Initialise original and reload counter value to the smallest - * possible value in order to get as much precision as we can. - */ - config->cntr_val[ctridx] =3D 1; - config->cntrldvr[ctridx] =3D 1; + /* Initialise original and reload counter value. */ + config->cntr_val[ctridx] =3D config->cntrldvr[ctridx] =3D 1 << (ts_level = - 1); =20 /* * Trace Counter Control Register TRCCNTCTLRn @@ -799,7 +809,7 @@ static int etm4_parse_event_config(struct coresight_dev= ice *csdev, * order to correlate instructions executed on different CPUs * (CPU-wide trace scenarios). */ - ret =3D etm4_config_timestamp_event(drvdata); + ret =3D etm4_config_timestamp_event(drvdata, attr); =20 /* * No need to go further if timestamp intervals can't --=20 2.34.1 From nobody Mon Dec 1 22:35:43 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 71FF0324B38 for ; Wed, 26 Nov 2025 10:57:57 +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=1764154679; cv=none; b=gjymKk7IYLODxg21xw6SdjodNGbkyGGQGjPhn7J9n4pX/V/TmPeIftTWx4Hlkyk1k6FI6cCr1LGpPuQICcGeEef82Y3kM8GkRCrlZgKm84VKDb1e7yEvM38vRqK4XBSYhDhA8YhWsVgQOPjZwsH/zLfv9yM8PVKlH52T3gZNs1A= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1764154679; c=relaxed/simple; bh=2gYGham6RcUhZnNfLTEyX5K2IIqX9Oa8+TtMYKSDzf0=; h=From:Date:Subject:MIME-Version:Content-Type:Message-Id:References: In-Reply-To:To:Cc; b=jhXoH8b2Dk/cy2YjAEi/P7sitpKccY8s8cNAXc4mUHM7PYb7x7MecSRiriQDofkBCTZDIu9RvQ4J7ElKmYj+BPWDNT5kSJAAYwsj1pesZYPPFJsSr57fCKO2ZiXeYvt0COX/8Gp0eRa1hqZprWP76K6/Ya7NOkVt8ZQ3dpYoa4Y= 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=jgQX6wIC; 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="jgQX6wIC" Received: by mail-wm1-f44.google.com with SMTP id 5b1f17b1804b1-4779d47be12so50187285e9.2 for ; Wed, 26 Nov 2025 02:57:57 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; t=1764154676; x=1764759476; 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=jgQX6wICwmAcvXYlu5TX/XrbPUBBGFHzeKfrKyASZHxzoIxfYHtcifP6d17o8esp68 jiBpsCNQyssIM97lHprtDzPDAX2szTOra3eOeEiJAWFjpND+OUAiGnNgLAr2pJ4j6hrJ 8+FZRvbqMNVXZK8DYGEYADK5oYIquq9BITwR34A5I2V2VIvbgowRveQcDB/2kRC7+K2N hBGyU95rWlMf5fVqoW+3RktNGWJr4dj6zB8N9YYEtBU2E195gCKNReYmr/u9X6R+TlqN vlo2lD0svY8Cer0Sd4SHeu1+echGyEJC9hNG75yb3dHokyTq5H3Su96aUTivu8Bobql9 eApA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1764154676; x=1764759476; 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=eum+Bg/p1bCh+8bwOqQVMlY7yuGlBLQ0AW0RaUk94I5lwpVS5ufVMWyDSlJqNtQlhw 2fdyb2sT+oGHDKFSLdqo/ECw709NR7yo+J3O/JEo/ImAhv4X6ZB+47zER6JD96ltwDAb 3AcqOZAnKQYx4xx1um7Ha78OJHYexzJmq39doStv8LDwewS0AOgj8rgD24+J5V5rNUBA mI5cJKbhxHfXSrNHMVmfLx/sCSAdRgt8ZNOyzwCUOwFgLZhDHUz5GlpJNrKzXd2hHcRo 9sCugF9j9bOSs0i/42GVrhB7x2x173HRki7FP3okaJM4x8ITqzg56WN8VHIciIwD/+tb LrmA== X-Forwarded-Encrypted: i=1; AJvYcCUy6p2DZ3gxHvyn/q+fwnaXajUoU2LYKF9M2MQ5OQqtnwFPmNqzUN93gOgX4BUxr+dDweaB9qnNSuzDo6g=@vger.kernel.org X-Gm-Message-State: AOJu0YyEBAmadcpJH1GMvr3ovVynVtB6rio09mow7j+L4DtUayJjn9jZ JlS5kTiwyK1lphJGszvRL+Pw+AApE0A4PySoiOWmxL6dsAKE3Yyv/rwe/pq0mIC31dU= X-Gm-Gg: ASbGncuFovYLbw9hK+/6smrYAYmtSuR+dgv8AXIdUFipzLLgSTWQBKocSPmB44hnNbP fEPbSm4zGdaqKAxkFkNMXUNl8iPA436FsoDirtK079hL6ceEapn0mbFh/yWjVqyC9XTJ6DwK+xC z2hx8MRjDHr2SlatkKGxUutafkAgxm44w/XOd9po1WzWAOHSjKIz2tLhGalO+Wq1dAEY3gY6zw0 TkeoK4Y00SaM8P6fDu/tSxqEYrfZCeWWfX287lliTe0AG2QmkPldGE1sJUVgsSzsp4NRqdfzvA/ ucwu56fn+g9VPrWgttYzbor5CK7Ad9E8e1/h5mh+9ZC3UFGNqlZuTFWc8mmMr4ByWXyO8i1s4vV FCXt3RauAIbnjJ6yKZXlcKmFObi0BoDMmM1yZeEoKUAceRIHl4NxbKUfRxMDcnd0+u4Xm7FgVKB zzSdw/YuqEponV0JCuiFYhlaO07zHFaM0= X-Google-Smtp-Source: AGHT+IGI5q1kexToJTcX1Yl/7hYBxLHl5Npy8jahQMf8CLbNWSX46wWWQuRfFFyKaMWwDJ+DY4kHYg== X-Received: by 2002:a7b:c011:0:b0:477:7cac:508d with SMTP id 5b1f17b1804b1-477c01d4ac6mr163405625e9.16.1764154675634; Wed, 26 Nov 2025 02:57:55 -0800 (PST) Received: from ho-tower-lan.lan ([185.48.77.170]) by smtp.gmail.com with ESMTPSA id 5b1f17b1804b1-4790ade13ddsm36991765e9.8.2025.11.26.02.57.54 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 26 Nov 2025 02:57:55 -0800 (PST) From: James Clark Date: Wed, 26 Nov 2025 10:54:42 +0000 Subject: [PATCH v7 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: <20251126-james-cs-syncfreq-v7-13-7fae5e0e5e16@linaro.org> References: <20251126-james-cs-syncfreq-v7-0-7fae5e0e5e16@linaro.org> In-Reply-To: <20251126-james-cs-syncfreq-v7-0-7fae5e0e5e16@linaro.org> To: Suzuki K Poulose , Mike Leach , Alexander Shishkin , Jonathan Corbet , Leo Yan , Randy Dunlap Cc: coresight@lists.linaro.org, linux-arm-kernel@lists.infradead.org, linux-kernel@vger.kernel.org, linux-doc@vger.kernel.org, James Clark X-Mailer: b4 0.14.0 Document how the new field is used, maximum value and the interaction with SYNC timestamps. Signed-off-by: James Clark Reviewed-by: Leo Yan Tested-by: Leo Yan --- 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