From nobody Tue Dec 2 02:32:40 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 68337227E95 for ; Tue, 18 Nov 2025 16:28:14 +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=1763483296; cv=none; b=c1PTP5ohvvSiAhcmw7VOghSxHX7yurwIcvT6iuatC4iu6U8avSfPR50C8LN5rH0mJq66qVT7IMUnfaSEwWfdnn3tdxxyXczmFj6DsEFSIhVSLYs3PFPw8m83nEBagIfGy6V2S090fgJVbJiuEmfHdu0OSWZC97ZjItvVRqfzu90= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1763483296; c=relaxed/simple; bh=N8m12iWNCLQKM0X40bESlfOrttHeXy53V/IFqVWUcrY=; h=From:Date:Subject:MIME-Version:Content-Type:Message-Id:References: In-Reply-To:To:Cc; b=YJSU+c4s7lCbqlB+QSL3xiCD3xq2RedMOP0BZfYsmX9ncJbJO5FnzAyBHmOqlQQn5JUKrE8VecpEhA885Gag31ESMj7LiqYX39/M37BgrfgpD9UeB7sGOPEP4o7njm4VEEQx401Nnq9satD6N/rqNjI0O7NNqz9r8rDiJQwwHtE= 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=RdSOVb8N; 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="RdSOVb8N" Received: by mail-wm1-f47.google.com with SMTP id 5b1f17b1804b1-475ca9237c2so32067785e9.3 for ; Tue, 18 Nov 2025 08:28:14 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; t=1763483293; x=1764088093; 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=RdSOVb8NU2lhf1rVX4j37WzWszNoHSpn386gdPu1Qgr3jkzoAbpn6sFohXP0tA58eG Ta+7MkT754SFYgzz/jMQbcDvwthraFsAzBBwxZrhywckIU5xHvYX2lQPlvtqATcM/C6x 5AiJht26rF7+6N+qGM9cLPdl1uQaOqev5YflHCwp/LcH0XZQLUavW6rHcyzsUmnPBdow xK5WKg1G8wXsyEih1Dma+pMwRns20FEC7pM+gO3snFsOnE7Ml13xxH1pRrwGKwsGPYbP i/wI5auciDxiJLJpPtqdmH6yD4TosrIJgsFZegzAuXjdpmzlZCwGOEvQOevn3LV4xxJf 0Wgg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1763483293; x=1764088093; 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=TiRGuJHzve+5JMxMmGGX9D5yA/BaEx90u67SsiM3/uYy9cg2/tb9nk48n6hLI4Rbt6 iL8uWaYDo5m1unMFEKqkuAAEIKZvedIuQzHpckJQsU4vTIp/jStciayKH7jm8RVcqpSr a7ua3+1SySAL6e0tFugdWubd3qIXb5KI04MeS3vUBNUe/QUXVvSjfksVAKpUJm/2bvlk W7v+A5/iXdyHs1CAgyu3T1cubkAUkeT5gHUNAMHd1Pc7+7djv+rBEVrTDbgdsjgR5ERl xsXd9jWX9+YDadpnkIfVw9QwQCGV7rwBtQmhXwRAPEo9CI7+hkwO3HYIm1M+hHnYeFwd XB3w== X-Forwarded-Encrypted: i=1; AJvYcCVnRFkU4AP6SPpTEDMfUTraACSfWr/aZrX+dFyQ/9/rkD974fY4CzzSMu6DSYonjrrVWLyegHI1LKuSWZw=@vger.kernel.org X-Gm-Message-State: AOJu0YzQ4XxXuj6I1iUV3DMObEqQCgQsTeZim8X5qYsEygL0FyhNKcwg YNFtVqWnguPcDL3vzz2abpxXjfpALM1Ll5CdbxnNmQHRhadSZtIG6aaxPJJDThGOogk= X-Gm-Gg: ASbGncuL4N3QyWgfyiXZRlHaEnj0Y97j0OJ72geqdK+auzJCK+Du5TPLVbVi6PyBoW4 I8+E/uvqaPVGCLPTHRWhNt+1GMawA5dWOqA0OnTCGzWkacIqt2z2XAB9E49NrTtRtG0BtexiGVN po/VRMHWEobBjqakcwhhMWKC342aQrTLvFTjBp0HfNhDbaZYt4k04IdvcmVuhmgxdKDhpHCwnxc m+V8br0l4McSzu3OUsOqUWShVTyqtZxVjdUrvpJyzIk+yIkT3ZYohF8Hhw9h77llNzrHwigmQPe 4QeL3ernZkZN9IpTVfXAXREdxiO8MD+f+bQTns/v4UvXPnw88gmh/7xQjXDIc1mMnRQH2YsunYP pkoBB3CBOxP9/HM16rZC6158kv5wQoN8/G0MAVfboJkSM6Jq50K7c9iH1Yv6nih+yboi5NfLzYg LaNAQS727UBt4oEdKweRl4 X-Google-Smtp-Source: AGHT+IGlqA0IJF4lpQfSJdnwbFaKhD4WAxo7jW3OY9aqCkvaIzPhjEfi9eC0wI0y+2UoYEhe+EsPvQ== X-Received: by 2002:a05:600c:4f4e:b0:477:6d96:b3c8 with SMTP id 5b1f17b1804b1-4778fe95399mr169481215e9.23.1763483292720; Tue, 18 Nov 2025 08:28:12 -0800 (PST) Received: from ho-tower-lan.lan ([185.48.77.170]) by smtp.gmail.com with ESMTPSA id 5b1f17b1804b1-477a9dea7fcsm20369125e9.8.2025.11.18.08.28.11 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 18 Nov 2025 08:28:12 -0800 (PST) From: James Clark Date: Tue, 18 Nov 2025 16:27:51 +0000 Subject: [PATCH v5 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: <20251118-james-cs-syncfreq-v5-1-82efd7b1a751@linaro.org> References: <20251118-james-cs-syncfreq-v5-0-82efd7b1a751@linaro.org> In-Reply-To: <20251118-james-cs-syncfreq-v5-0-82efd7b1a751@linaro.org> To: Suzuki K Poulose , Mike Leach , Alexander Shishkin , Jonathan Corbet , Leo Yan , Randy Dunlap Cc: coresight@lists.linaro.org, linux-arm-kernel@lists.infradead.org, linux-kernel@vger.kernel.org, linux-doc@vger.kernel.org, James Clark X-Mailer: b4 0.14.0 TRCSYNCPR.PERIOD is the only functional part of TRCSYNCPR and it only has 5 valid bits so it can be stored in a u8. Reviewed-by: Mike Leach Reviewed-by: Leo Yan Signed-off-by: James Clark --- drivers/hwtracing/coresight/coresight-etm4x.h | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/drivers/hwtracing/coresight/coresight-etm4x.h b/drivers/hwtrac= ing/coresight/coresight-etm4x.h index 012c52fd1933..0287d19ce12e 100644 --- a/drivers/hwtracing/coresight/coresight-etm4x.h +++ b/drivers/hwtracing/coresight/coresight-etm4x.h @@ -825,7 +825,6 @@ struct etmv4_config { u32 eventctrl1; u32 stall_ctrl; u32 ts_ctrl; - u32 syncfreq; u32 ccctlr; u32 bb_ctrl; u32 vinst_ctrl; @@ -833,6 +832,7 @@ struct etmv4_config { u32 vissctlr; u32 vipcssctlr; u8 seq_idx; + u8 syncfreq; u32 seq_ctrl[ETM_MAX_SEQ_STATES]; u32 seq_rst; u32 seq_state; --=20 2.34.1 From nobody Tue Dec 2 02:32:40 2025 Received: from mail-wm1-f52.google.com (mail-wm1-f52.google.com [209.85.128.52]) (using TLSv1.2 with cipher ECDHE-RSA-AES128-GCM-SHA256 (128/128 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 6CB3136827E for ; Tue, 18 Nov 2025 16:28:15 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=209.85.128.52 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1763483298; cv=none; b=nyW8A8tIrChabux3eVDXWsa+9+p2LGmxtqTy2KDNQbJipUYPbPfZvkxD0H/NsjbCtKRccWVFy3FW906K9/Q068jB6qD1cvnKZvy0yyR7TuHho3aUQuWct39/6Vasif3tTgrLRcCzTZapcUw6kvYNLPSdhY9oh506Qihqoe26AO0= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1763483298; c=relaxed/simple; bh=17jMP5BXtLnUallPdavwL3MYV4FkLZYfFbmfg88Z2tI=; h=From:Date:Subject:MIME-Version:Content-Type:Message-Id:References: In-Reply-To:To:Cc; b=bQHzagKqy6CTLGltOWtVwkE2Mg9QKYZh9nIBLJjM1RA5CRSqh4G6dPEqdM/52d6XXJ8PPv6/Pe/0FvH1mMadbE92e4nWtnMhxiHDxX0yaQGKKmUKGZfAlNSVw0I5LKlCrQHp13P2Y9XCpVIViTuyQXC84/ofmHga3mvptXHObeQ= 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=ZChbTctT; arc=none smtp.client-ip=209.85.128.52 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=linaro.org Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=linaro.org Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=linaro.org header.i=@linaro.org header.b="ZChbTctT" Received: by mail-wm1-f52.google.com with SMTP id 5b1f17b1804b1-4779cc419b2so34606595e9.3 for ; Tue, 18 Nov 2025 08:28:15 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; t=1763483294; x=1764088094; 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=ZChbTctTRu9QyZXJDG+6AXxBL0eXTcG4EkQvNnzgERTiIw54BsWPmmmYT6MhmZ9clz +KaIVIwJByea51sgX0v12hS1rSPI0QU0BxqJrfgNxl6+R3SqFVS71udy+QSAg1bv+7ld 2vPaBSHZ+vmrvDZ3cHY1gYhQwU9fLNjdRblxEKOor9UGfQ1dVqDakAX7w7D3mt/LTBSA ncfdzCwx0rq5Ixu/RTkVC4HC/yUROLxjBvp1XZRgyQKDFmCNwQC3817/vBZ5ypQ2T44R ++Oh3EHfgrLjTfBFwj5bNaG4c6P+MRbGG/IeRVBzH/4l51wD4G1Ek2JP7ElyouFeSF9j MJmQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1763483294; x=1764088094; 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=L+lGI68XyHkUagH8yvvA4ZxgDey8tQZ+EaER0EuNOM++Tcn2SnBB9srK+LE14iOLo4 6yxVIm/5M4d5aNYRjeDxYgWiYCngcuHTVhkwbOYKHfmnoWB1vQGZScqmv0CiCdBGL04n ZCF1sUet4dXYb1+kYbL30BLYGYAJzDcLfcR4BW3lbfzi31Jk2bRLl+qq1oM2UGJw20X2 lDesvwiycSCRYLwZJNCUS0uEDNj9FKUHhvw3W6I0HQ6m+gNcruhBlRuPPbJFyz6qpKFJ ER9Mo3SMChMgdc2e8DfRcq+L2oXLGL/S0JL6oni6qvXt+SdeU5vEieOA17KUO2T8yVy1 563A== X-Forwarded-Encrypted: i=1; AJvYcCXe7v90KxsHnnRYkUL5zCM2mb38nnLTxfXeiD8lQjx9Qx8RnPC4+Oq31YqXuP+daHDivVDvwGaXiNYWnTk=@vger.kernel.org X-Gm-Message-State: AOJu0YwJSNwHxhme2+CyMai7JmyjlUWvdymRjGDHsKuLHYWmhRuFrB9v ni/6732t+4ZYGGoXWhKFwTaCjvfUyp+SxBP1iQ/nrYwugi4NxhsFF9RZ2zb7HTvMJq4= X-Gm-Gg: ASbGnctfLUWlfQR+4stET7REqw8ZDhVPRmPd/yiqikySO+9ny34XmdLA9lVfdP1A8a3 9VARUb/DuASY0TpQx5XKsAi0VNlw95aIl0yg+XnlRDlz+cE6x7/CE70ql7o71Gp8OwK5wRwNK68 lVT4ZmakYCyDs6RPuLZS3iAWTy0P4i67GNNzCx2ZnJoUhri8VMoNVKRWP2f8JoHWPyPSUUuCKI2 nGKll0Ohf44mKXoGy8HFJSVkAABjPla2zIir7lOCZACSi7qIrZ/1cyWjA+OxTUNIHh5uJVwI2Lr IUc+5CcqHigySnwgn2aoi3nBMUCh1/X60sHsK6RcuoU80+c4SZv6cfuFLmD0FP1jmFXJkWK0u6I lRTfoK+DCl87W7hrTrrjibgpMrwvoodBFsTzXqMY4fV9wOWH/WvAfwUqSKL0ESIYdNhyLIafF4f 7bJLy0RFkhyEja5sHlDGIr5VfCwHvbG/8= X-Google-Smtp-Source: AGHT+IFC51NmASmxCttbHA51J4ftuaZisW7lGzCpDDloTLqiHxK+S+7Yx2njgihk2700vNnRrGielA== X-Received: by 2002:a05:600c:604f:b0:477:9b35:3e49 with SMTP id 5b1f17b1804b1-4779b3542e2mr78799175e9.3.1763483293681; Tue, 18 Nov 2025 08:28:13 -0800 (PST) Received: from ho-tower-lan.lan ([185.48.77.170]) by smtp.gmail.com with ESMTPSA id 5b1f17b1804b1-477a9dea7fcsm20369125e9.8.2025.11.18.08.28.12 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 18 Nov 2025 08:28:13 -0800 (PST) From: James Clark Date: Tue, 18 Nov 2025 16:27:52 +0000 Subject: [PATCH v5 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: <20251118-james-cs-syncfreq-v5-2-82efd7b1a751@linaro.org> References: <20251118-james-cs-syncfreq-v5-0-82efd7b1a751@linaro.org> In-Reply-To: <20251118-james-cs-syncfreq-v5-0-82efd7b1a751@linaro.org> To: Suzuki K Poulose , Mike Leach , Alexander Shishkin , Jonathan Corbet , Leo Yan , Randy Dunlap Cc: coresight@lists.linaro.org, linux-arm-kernel@lists.infradead.org, linux-kernel@vger.kernel.org, linux-doc@vger.kernel.org, James Clark X-Mailer: b4 0.14.0 Fix holes and convert the long list of bools to single bits to save some space because there's one of these for each ETM. Reviewed-by: Leo Yan Reviewed-by: Mike Leach Signed-off-by: James Clark --- drivers/hwtracing/coresight/coresight-etm4x.h | 36 +++++++++++++----------= ---- 1 file changed, 18 insertions(+), 18 deletions(-) diff --git a/drivers/hwtracing/coresight/coresight-etm4x.h b/drivers/hwtrac= ing/coresight/coresight-etm4x.h index 0287d19ce12e..d178d79d9827 100644 --- a/drivers/hwtracing/coresight/coresight-etm4x.h +++ b/drivers/hwtracing/coresight/coresight-etm4x.h @@ -1016,27 +1016,27 @@ struct etmv4_drvdata { u8 ns_ex_level; u8 q_support; u8 os_lock_model; - bool sticky_enable; - bool boot_enable; - bool os_unlock; - bool instrp0; - bool q_filt; - bool trcbb; - bool trccond; - bool retstack; - bool trccci; - bool trc_error; - bool syncpr; - bool stallctl; - bool sysstall; - bool nooverflow; - bool atbtrig; - bool lpoverride; + bool sticky_enable : 1; + bool boot_enable : 1; + bool os_unlock : 1; + bool instrp0 : 1; + bool q_filt : 1; + bool trcbb : 1; + bool trccond : 1; + bool retstack : 1; + bool trccci : 1; + bool trc_error : 1; + bool syncpr : 1; + bool stallctl : 1; + bool sysstall : 1; + bool nooverflow : 1; + bool atbtrig : 1; + bool lpoverride : 1; + bool skip_power_up : 1; + bool paused : 1; u64 trfcr; struct etmv4_config config; struct etmv4_save_state *save_state; - bool skip_power_up; - bool paused; DECLARE_BITMAP(arch_features, ETM4_IMPDEF_FEATURE_MAX); }; =20 --=20 2.34.1 From nobody Tue Dec 2 02:32:40 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 7B26836B068 for ; Tue, 18 Nov 2025 16:28:16 +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=1763483298; cv=none; b=B4pvvQhtY8ks/EZfkD5gL/0uBwDI1RPt1uSgvy4ge/pQav3beHuI4mUNpOuRqNlWubTX5d20ggIOu0uDfYuvRzpThxEdavx/mvoLNkFnTIn7wO01BbtfDeaVSjL6sKO0f70emhFKo29yV51v3NGCBvaA8sgIdjjrjeTABeRl7fI= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1763483298; c=relaxed/simple; bh=ONkP+P4kDJfi/Sh9u17b+mxs55OiXiOwJM3I+w+oDdI=; h=From:Date:Subject:MIME-Version:Content-Type:Message-Id:References: In-Reply-To:To:Cc; b=BI4b6zUllJnz2gVCwFpK3iFQGtKKI2iZlcJVOyTl3OTdDxBXsMbW1HQu+r7M96FkoDuqAR6IcdCd+Is4ie5Bvm5ASrE37VDodgmvqC4jIW5+mGeZEk4Hc3YPgX6+BMjXcMmEFFMZ6xUYauURfzkxDBTiZf9xR5hIMGIRMhJYKoU= 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=sKbjHnxo; 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="sKbjHnxo" Received: by mail-wm1-f54.google.com with SMTP id 5b1f17b1804b1-47118259fd8so43163785e9.3 for ; Tue, 18 Nov 2025 08:28:16 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; t=1763483295; x=1764088095; darn=vger.kernel.org; h=cc:to:in-reply-to:references:message-id:content-transfer-encoding :mime-version:subject:date:from:from:to:cc:subject:date:message-id :reply-to; bh=fv3JnFDC0jik+shXFRazxf6/zTl+pNpZZP8z8eh7A8Q=; b=sKbjHnxoDPUXmbGPfBxzAXNJQnTFeR1conS/RiDQYOmBJBTzlsmPrlswWGU7ULlMj1 QxKmaK5J/3bVGLAnPBMZ7NRW7YrZwaV6qlLIxn8cYwODN1zxMcfAksZwr+VoS0L7EMQ6 6ZUFrGJaxuUk8rUUuESk9MecfOkUU2ziHACYskJOUwKg2IX1F9ef5F/qfVRhjY3CViuK 0lEBoxGtrLn6bZeY35rT9BsHiGpJa3wREh0WR4hy+qSVmg942jRHgP3ljjrdL0UjaFlj sYXM+wnlZQToOkIvIL+tuJCnDCMF02hnncEi5h7D/Y3Mhe/6Cw+6Pes5/gwp2sH5kkip v6CQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1763483295; x=1764088095; h=cc:to:in-reply-to:references:message-id:content-transfer-encoding :mime-version:subject:date:from:x-gm-gg:x-gm-message-state:from:to :cc:subject:date:message-id:reply-to; bh=fv3JnFDC0jik+shXFRazxf6/zTl+pNpZZP8z8eh7A8Q=; b=CsGRn1FAjbv0bFbc1mZBCgzSz9XHvlejffIN5WWyGr5tWlwCfMrPQa9di0ViWjgO5l rM1+inIBKhKLWXKdokUEq8zMRVoHs+3YbgA8oa8clOGzUYMjhc3V7EvXuYxaGS/6GtbP ID6LEhPB0Zd3p6s2HTBkhBeA/7QMOBWw8ZGGVbLzuJTaKqIC/sejXJmTpOUU/eUVVp88 OTKYW0r7paQISgOaEjXBUb46OAUfQT+mviTmPMZWBzp/RJ9IDvNbB53DAVsd/5+Z0aor B2lGgVlkHzM5SfEk6fN3tYY3b16AvIca0HbBqtieL/Ig7tCnazqvt9WfqLxTHhrjLhue mW0Q== X-Forwarded-Encrypted: i=1; AJvYcCXVviB2uj0q8aUiPgL8s+V14o2qsupOSCjxY+aN/EHZI582gOG4LbRCyGscJuQolNJ1/GSI7ln3fZ/7d/0=@vger.kernel.org X-Gm-Message-State: AOJu0YyN+liGeK3y1aXEpa4lO3OmXFQe5CG65aALjyZAGIOj2jSwltyB srY5jqIfeKHHyTnqEJmzjLoeP6rSrpdJ2SgEK2abUezYbj/TSG5UIR1FXGSy/4+4aTwUULVj7Y5 W1RXvXKQ= X-Gm-Gg: ASbGncsC7kTNWDFcptt7eZvh0lvPTihP9kkQUUus0xbzGX/yLOF8fXdC85oYLZoQZJK wjEeqLD/3ZkjHAjmvAgLoTW6V32JzJseiJs9S4g7gwqpmF560kVPZt6hKQiflG1umLe5jeAQRrw brvw4whLmtGG6UHQw6ViRTXyShCh15n0G3b7zpEZZ2uVpMxzFYYrp7QahXDg8ENHRFw3j88LMYI rWnRAteHRgt7UffpGZyAnKd6ixYDo/7zn23cOU679lHhetgwXFTaikuoNuFXJHQjx09arBFrngw tBzPQWt6TbtvsAokuyX4u9uZZShbQwlH2beDXuekDdiNOXA6MMnGYaG2BReF/k9P4BXYTCHnLbR ccQ8KjIH7qmbWoe4LyeZAZeazQvliDUW7Pyr5qCEFLVFgVela9MRSVl8eX4EnZiW+nIu5vX45CJ msfmLoqNVGb5o0cOXz0k1AfOGZceGMKLg= X-Google-Smtp-Source: AGHT+IGQKNN+SRbZbt0TsbNPr5Hf9OUh6BwWx+gUnvFHRimt37qwL88HnLAz+E/ArRa+r1XIEtdnJQ== X-Received: by 2002:a05:600c:138b:b0:471:700:f281 with SMTP id 5b1f17b1804b1-4778fea7f90mr150234765e9.25.1763483294647; Tue, 18 Nov 2025 08:28:14 -0800 (PST) Received: from ho-tower-lan.lan ([185.48.77.170]) by smtp.gmail.com with ESMTPSA id 5b1f17b1804b1-477a9dea7fcsm20369125e9.8.2025.11.18.08.28.13 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 18 Nov 2025 08:28:14 -0800 (PST) From: James Clark Date: Tue, 18 Nov 2025 16:27:53 +0000 Subject: [PATCH v5 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: <20251118-james-cs-syncfreq-v5-3-82efd7b1a751@linaro.org> References: <20251118-james-cs-syncfreq-v5-0-82efd7b1a751@linaro.org> In-Reply-To: <20251118-james-cs-syncfreq-v5-0-82efd7b1a751@linaro.org> To: Suzuki K Poulose , Mike Leach , Alexander Shishkin , Jonathan Corbet , Leo Yan , Randy Dunlap Cc: coresight@lists.linaro.org, linux-arm-kernel@lists.infradead.org, linux-kernel@vger.kernel.org, linux-doc@vger.kernel.org, James Clark X-Mailer: b4 0.14.0 Remove some of the magic numbers and try to clarify some of the documentation so it's clearer how this sets up the timestamp interval. Return errors directly instead of jumping to out and returning ret, nothing needs to be cleaned up at the end and it only obscures the flow and return value. Reviewed-by: Leo Yan Signed-off-by: James Clark --- drivers/hwtracing/coresight/coresight-etm4x-core.c | 96 ++++++++++++++----= ---- drivers/hwtracing/coresight/coresight-etm4x.h | 23 ++++-- 2 files changed, 81 insertions(+), 38 deletions(-) diff --git a/drivers/hwtracing/coresight/coresight-etm4x-core.c b/drivers/h= wtracing/coresight/coresight-etm4x-core.c index 560975b70474..5d21af346799 100644 --- a/drivers/hwtracing/coresight/coresight-etm4x-core.c +++ b/drivers/hwtracing/coresight/coresight-etm4x-core.c @@ -642,18 +642,33 @@ static void etm4_enable_sysfs_smp_call(void *info) * TRCRSCTLR1 (always true) used to get the counter to decrement. From * there a resource selector is configured with the counter and the * timestamp control register to use the resource selector to trigger the - * event that will insert a timestamp packet in the stream. + * event that will insert a timestamp packet in the stream: + * + * +--------------+ + * | Resource 1 | fixed "always-true" resource + * +--------------+ + * | + * +------v-------+ + * | Counter x | (reload to 1 on underflow) + * +--------------+ + * | + * +------v--------------+ + * | Resource Selector y | (trigger on counter x =3D=3D 0) + * +---------------------+ + * | + * +------v---------------+ + * | Timestamp Generator | (timestamp on resource y) + * +----------------------+ */ static int etm4_config_timestamp_event(struct etmv4_drvdata *drvdata) { - int ctridx, ret =3D -EINVAL; - int counter, rselector; - u32 val =3D 0; + int ctridx; + int rselector; struct etmv4_config *config =3D &drvdata->config; =20 /* No point in trying if we don't have at least one counter */ if (!drvdata->nr_cntr) - goto out; + return -EINVAL; =20 /* Find a counter that hasn't been initialised */ for (ctridx =3D 0; ctridx < drvdata->nr_cntr; ctridx++) @@ -663,15 +678,19 @@ static int etm4_config_timestamp_event(struct etmv4_d= rvdata *drvdata) /* All the counters have been configured already, bail out */ if (ctridx =3D=3D drvdata->nr_cntr) { pr_debug("%s: no available counter found\n", __func__); - ret =3D -ENOSPC; - goto out; + return -ENOSPC; } =20 /* - * Searching for an available resource selector to use, starting at - * '2' since every implementation has at least 2 resource selector. - * ETMIDR4 gives the number of resource selector _pairs_, - * hence multiply by 2. + * Searching for an available resource selector to use, starting at '2' + * since resource 0 is the fixed 'always returns false' resource and 1 + * is the fixed 'always returns true' resource. See IHI0064H_b '7.3.64 + * TRCRSCTLRn, Resource Selection Control Registers, n=3D2-31'. If there + * are no resources, there would also be no counters so wouldn't get + * here. + * + * ETMIDR4 gives the number of resource selector _pairs_, hence multiply + * by 2. */ for (rselector =3D 2; rselector < drvdata->nr_resource * 2; rselector++) if (!config->res_ctrl[rselector]) @@ -680,13 +699,9 @@ static int etm4_config_timestamp_event(struct etmv4_dr= vdata *drvdata) if (rselector =3D=3D drvdata->nr_resource * 2) { pr_debug("%s: no available resource selector found\n", __func__); - ret =3D -ENOSPC; - goto out; + return -ENOSPC; } =20 - /* Remember what counter we used */ - counter =3D 1 << ctridx; - /* * Initialise original and reload counter value to the smallest * possible value in order to get as much precision as we can. @@ -694,26 +709,41 @@ static int etm4_config_timestamp_event(struct etmv4_d= rvdata *drvdata) config->cntr_val[ctridx] =3D 1; config->cntrldvr[ctridx] =3D 1; =20 - /* Set the trace counter control register */ - val =3D 0x1 << 16 | /* Bit 16, reload counter automatically */ - 0x0 << 7 | /* Select single resource selector */ - 0x1; /* Resource selector 1, i.e always true */ - - config->cntr_ctrl[ctridx] =3D val; - - val =3D 0x2 << 16 | /* Group 0b0010 - Counter and sequencers */ - counter << 0; /* Counter to use */ - - config->res_ctrl[rselector] =3D val; + /* + * Trace Counter Control Register TRCCNTCTLRn + * + * CNTCHAIN =3D 0, don't reload on the previous counter + * RLDSELF =3D true, reload counter automatically on underflow + * RLDTYPE =3D 0, one reload input resource + * RLDSEL =3D RES_SEL_FALSE (0), reload on false resource (never reload) + * CNTTYPE =3D 0, one count input resource + * CNTSEL =3D RES_SEL_TRUE (1), count fixed 'always true' resource (alway= s decrement) + */ + config->cntr_ctrl[ctridx] =3D TRCCNTCTLRn_RLDSELF | + FIELD_PREP(TRCCNTCTLRn_RLDSEL_MASK, ETM_RES_SEL_FALSE) | + FIELD_PREP(TRCCNTCTLRn_CNTSEL_MASK, ETM_RES_SEL_TRUE); =20 - val =3D 0x0 << 7 | /* Select single resource selector */ - rselector; /* Resource selector */ + /* + * Resource Selection Control Register TRCRSCTLRn + * + * PAIRINV =3D 0, INV =3D 0, don't invert + * GROUP =3D 2, SELECT =3D ctridx, trigger when counter 'ctridx' reaches 0 + * + * Multiple counters can be selected, and each bit signifies a counter, + * so set bit 'ctridx' to select our counter. + */ + config->res_ctrl[rselector] =3D FIELD_PREP(TRCRSCTLRn_GROUP_MASK, 2) | + FIELD_PREP(TRCRSCTLRn_SELECT_MASK, 1 << ctridx); =20 - config->ts_ctrl =3D val; + /* + * Global Timestamp Control Register TRCTSCTLR + * + * TYPE =3D 0, one input resource + * SEL =3D rselector, generate timestamp on resource 'rselector' + */ + config->ts_ctrl =3D FIELD_PREP(TRCTSCTLR_SEL_MASK, rselector); =20 - ret =3D 0; -out: - return ret; + return 0; } =20 static int etm4_parse_event_config(struct coresight_device *csdev, diff --git a/drivers/hwtracing/coresight/coresight-etm4x.h b/drivers/hwtrac= ing/coresight/coresight-etm4x.h index d178d79d9827..b319335e9bc3 100644 --- a/drivers/hwtracing/coresight/coresight-etm4x.h +++ b/drivers/hwtracing/coresight/coresight-etm4x.h @@ -225,6 +225,19 @@ #define TRCRSCTLRn_GROUP_MASK GENMASK(19, 16) #define TRCRSCTLRn_SELECT_MASK GENMASK(15, 0) =20 +#define TRCCNTCTLRn_CNTCHAIN BIT(17) +#define TRCCNTCTLRn_RLDSELF BIT(16) +#define TRCCNTCTLRn_RLDTYPE BIT(15) +#define TRCCNTCTLRn_RLDSEL_MASK GENMASK(12, 8) +#define TRCCNTCTLRn_CNTTYPE_MASK BIT(7) +#define TRCCNTCTLRn_CNTSEL_MASK GENMASK(4, 0) + +#define TRCTSCTLR_TYPE BIT(7) +#define TRCTSCTLR_SEL_MASK GENMASK(4, 0) + +#define ETM_RES_SEL_FALSE 0 /* Fixed function 'always false' resource sele= ctor */ +#define ETM_RES_SEL_TRUE 1 /* Fixed function 'always true' resource selec= tor */ + /* * System instructions to access ETM registers. * See ETMv4.4 spec ARM IHI0064F section 4.3.6 System instructions @@ -824,7 +837,7 @@ struct etmv4_config { u32 eventctrl0; u32 eventctrl1; u32 stall_ctrl; - u32 ts_ctrl; + u32 ts_ctrl; /* TRCTSCTLR */ u32 ccctlr; u32 bb_ctrl; u32 vinst_ctrl; @@ -837,11 +850,11 @@ struct etmv4_config { u32 seq_rst; u32 seq_state; u8 cntr_idx; - u32 cntrldvr[ETMv4_MAX_CNTR]; - u32 cntr_ctrl[ETMv4_MAX_CNTR]; - u32 cntr_val[ETMv4_MAX_CNTR]; + u32 cntrldvr[ETMv4_MAX_CNTR]; /* TRCCNTRLDVRn */ + u32 cntr_ctrl[ETMv4_MAX_CNTR]; /* TRCCNTCTLRn */ + u32 cntr_val[ETMv4_MAX_CNTR]; /* TRCCNTVRn */ u8 res_idx; - u32 res_ctrl[ETM_MAX_RES_SEL]; + u32 res_ctrl[ETM_MAX_RES_SEL]; /* TRCRSCTLRn */ u8 ss_idx; u32 ss_ctrl[ETM_MAX_SS_CMP]; u32 ss_status[ETM_MAX_SS_CMP]; --=20 2.34.1 From nobody Tue Dec 2 02:32:40 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 6FAD436C5B6 for ; Tue, 18 Nov 2025 16:28:17 +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=1763483299; cv=none; b=E/qi5zGLygB2dZFfkiCfE9VY9jlg8A73sjYLxT8or3ZxEHwN3F69YSmzdiOMvWuRCZ1AoBQSyIijpn3bDS6yMYUowJDgphvQpLI44YSh8XEJAfZM47nqG14ETSDijuuUZNUe/1tAdHfBZfKb2c+m4NvYmJgWf+zNbPIfrCAOi/c= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1763483299; c=relaxed/simple; bh=nwpDrPvo6wsFhTqkdc+mil82YNIIfV6pVmZlogEyGM4=; h=From:Date:Subject:MIME-Version:Content-Type:Message-Id:References: In-Reply-To:To:Cc; b=OH9W17ueL4MbGCxU4g/S1/jXM0yVrAqcMgBLXA8F2/LSS3F7mNothfZqLJsX58TpmYj2GtEuODL7ZO4PvbGkRVL2kyJ5iP1rztFmwcT0OdK8ExtD+VVU+wSHx+/7jiAn7jru40pu3Gj3dYpKLQiBb6pqI1PkxMqia0FPhwzVCY4= 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=Rd4e9ea0; 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="Rd4e9ea0" Received: by mail-wm1-f47.google.com with SMTP id 5b1f17b1804b1-4779aa4f928so36660845e9.1 for ; Tue, 18 Nov 2025 08:28:17 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; t=1763483296; x=1764088096; 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=pfMGtwRScvfZlh/XAQooGxUMOnQFy6aFM90lPPS4zWA=; b=Rd4e9ea0uV0XkSfI9YnF0RciW645RghMAs+rxUsrD4wiAroWlN/pz4EVb95uSkbWd2 6FkOGc/LJbKbaW6PI2OhnZZqQzb7ekMVZcnxWRPtJlu3LDm3vHOxOzCFe7A1eSN6q8fg z2Ksr3il3/nJAZqeMBkM6iwcUS8hpnZuHABJpM4KdQa3zPBodNUlgSqSZBSCQ8s2T/vT EBaewQ9fzZMw/dQvYXHA8pbLME/l4vhUDx2J/CQ7A3716Iz6dgv6QlQKBZi0GFKxeFKx qNrHX0scjZbvLIej0ao6VYEjS3695mjH81bdNCPSIsma5vyr58xmxjUVe3UixVmxh83N YkTQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1763483296; x=1764088096; 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=pfMGtwRScvfZlh/XAQooGxUMOnQFy6aFM90lPPS4zWA=; b=Yd2JCY2UmCDTydt/+X8HBfq9IqexRDH7JpCLDEB6VpMo1UJUkYwpQgqiQ+6S5WBNl+ JUExtDi5Rcku3mIixCoQkubUsWFHlD0awReS4m3taL5YZI1KY4i3bKITeOWa5JtFPSQh nAqdBmfoXXrSwkYCJ6cPPKhhMgCGw5YAhDrAGHoQfH5pOhengLDu3x17k9WxDHG5Bpkb ojhSxOMjWHZg7xVlyenvYnsJ7EJr73KcfeFxVQyo6PjkE/8AWKv50y42u3tdsYYt0Mgx 4f5Q6ZcOLCNUWJ5ja1Kb3IOC66bxeK6qeb5uZYnm79qnqbfspcasMRyWPRJrNQcfjWfX bO2Q== X-Forwarded-Encrypted: i=1; AJvYcCXBQHJDAZa1t/uHhTSDOLI2YnMVOs6vGAS2L+ZiO+dANIegUMKZBzwjZSiRED3RpM8tmO/5wo6ULfH5vf4=@vger.kernel.org X-Gm-Message-State: AOJu0YxhwDQW8IXYRlCwZ97xFmQGnVzMd4kmiX9xoytMSUKUbE9qWLzA cP66729EVWhpR/P4SkuFyPxmXsCrbdPOar1gNyyQsDCwEs36IB475byj3+dBrAi+IoU= X-Gm-Gg: ASbGnctOMrpXjc3sVRxTaBZ3X30nufhJsWK9YN3fEYOEkoPr1Tg5gnEtZn9OiecRrab dWCyNJSABQku7vr+2GKSXYDZHdrthAJw/CqrNPwZ/R3auNzJvJHYVWUzRyyghTlANjOmMOxXncz zRABWvnY5TAHsLFC7JQM5jx+zvy+/xKqVvuZvpyYzKDkxdTksr4U7nrzrEImE4+/NMd3lXARlhT Km/u0yrdtQVqch32YiP9sLb03qoRLU98AtDxwwbVHokLoQRkaSzGx153fss71jvKwEquLMQmBHU H6kLWFPSYJ6R3Mvqk4X9JQXHJKXaDxfzG1mC1Xj2r9aLfpqPY0EU4KxitJtfUY8MzujHKfHNfqP z+83xkXFVLGYi4RdfsOu8euwD9JnFDME6mLXaECK75GNWMV2R4Zj27+U7EsSvtjSrK6Uyv5SQE2 fyke63LNw6NSz08yriK5OroLOGwXU3Zzo= X-Google-Smtp-Source: AGHT+IEQ71MCFFHm9PfsuQns+Y6ohbXSLi6ir1YdpoytYc9NNxUeZy72YPAlDScgcglr1n/v1Qdp8g== X-Received: by 2002:a05:600c:3593:b0:477:557b:6917 with SMTP id 5b1f17b1804b1-4778fe4fdecmr170984385e9.18.1763483295720; Tue, 18 Nov 2025 08:28:15 -0800 (PST) Received: from ho-tower-lan.lan ([185.48.77.170]) by smtp.gmail.com with ESMTPSA id 5b1f17b1804b1-477a9dea7fcsm20369125e9.8.2025.11.18.08.28.14 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 18 Nov 2025 08:28:15 -0800 (PST) From: James Clark Date: Tue, 18 Nov 2025 16:27:54 +0000 Subject: [PATCH v5 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: <20251118-james-cs-syncfreq-v5-4-82efd7b1a751@linaro.org> References: <20251118-james-cs-syncfreq-v5-0-82efd7b1a751@linaro.org> In-Reply-To: <20251118-james-cs-syncfreq-v5-0-82efd7b1a751@linaro.org> To: Suzuki K Poulose , Mike Leach , Alexander Shishkin , Jonathan Corbet , Leo Yan , Randy Dunlap Cc: coresight@lists.linaro.org, linux-arm-kernel@lists.infradead.org, linux-kernel@vger.kernel.org, linux-doc@vger.kernel.org, James Clark X-Mailer: b4 0.14.0 ETMv3 only has a few attributes, and setting unused ones results in an error, so hide them to begin with. Signed-off-by: James Clark Reviewed-by: Mike Leach --- drivers/hwtracing/coresight/coresight-etm-perf.c | 22 ++++++++++++++++++++= ++ 1 file changed, 22 insertions(+) diff --git a/drivers/hwtracing/coresight/coresight-etm-perf.c b/drivers/hwt= racing/coresight/coresight-etm-perf.c index 17afa0f4cdee..faebd7822a77 100644 --- a/drivers/hwtracing/coresight/coresight-etm-perf.c +++ b/drivers/hwtracing/coresight/coresight-etm-perf.c @@ -106,8 +106,30 @@ static struct attribute *etm_config_formats_attr[] =3D= { NULL, }; =20 +static umode_t etm_format_attr_is_visible(struct kobject *kobj, + struct attribute *attr, int unused) +{ + /* ETM4 has all attributes */ + if (IS_ENABLED(CONFIG_CORESIGHT_SOURCE_ETM4X)) + return attr->mode; + + /* + * ETM3 only uses these attributes for programming itself (see + * ETM3X_SUPPORTED_OPTIONS). Sink ID is also supported for selecting a + * sink, but not used for configuring the ETM. + */ + if (attr =3D=3D &format_attr_cycacc.attr || + attr =3D=3D &format_attr_timestamp.attr || + attr =3D=3D &format_attr_retstack.attr || + attr =3D=3D &format_attr_sinkid.attr) + return attr->mode; + + return 0; +} + static const struct attribute_group etm_pmu_format_group =3D { .name =3D "format", + .is_visible =3D etm_format_attr_is_visible, .attrs =3D etm_config_formats_attr, }; =20 --=20 2.34.1 From nobody Tue Dec 2 02:32:40 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 509003730DE for ; Tue, 18 Nov 2025 16:28:19 +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=1763483301; cv=none; b=nBXR0QN1migkSStjbLhaFBCIxBcwJvcpkwO+S8y5ioMx41e68bCtXb6LJzKf4JTtW0lSbc9eI+RPspVd6SpIOSFvadvcdolshM4ZdjJ9iIfEF73ooE9lT/VcNRQFNx/2pVcH8KNf+j31sUmZC4YNyd3C1dibqUDSU2bCbAmEnOg= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1763483301; c=relaxed/simple; bh=d1VZne62bsL7f4YK6muj4cKkqo5VmJzbhqU/Ay9dgxo=; h=From:Date:Subject:MIME-Version:Content-Type:Message-Id:References: In-Reply-To:To:Cc; b=EfVFfJ9K9hdfyHfizTki/3kXUtJqGzN+Wvm5O4WSfsjHSWeHKl5At4gea9UUuZ2SreZ2//OJ8uBvri1xkcZgSBmtH65SRRtebvEnFompNHqO6E3vHrVWFMnyc1l/TOJQLb38SEPjhy/Pm3q0Tijuk8XV5WQgy8kMLoqtVEIwPis= 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=lidRHep0; 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="lidRHep0" Received: by mail-wm1-f54.google.com with SMTP id 5b1f17b1804b1-477549b3082so47144005e9.0 for ; Tue, 18 Nov 2025 08:28:19 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; t=1763483297; x=1764088097; 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=48JreFr5BaTMOPMEs2r/FtKXuXZRpdyc8fhVXjm2c3w=; b=lidRHep0ojviZIz+NsqCUia52I3+DH/uDRMbuXMqhqOtQPo54YkgJfKJmP8uwjP9fy eWi+tbbVnPqPU+DvGWFJtykX68CQ2w/mTF0rdzWCtKjU5DAIU64yo5V5sgVPnuvjIpZ2 T0E2nGs3WnfqI0ozULrRXPax+EQ1lViDoSB3CyfOneAnNxDbtDJnyJRDIVwAeSfWoKDH YQEkJMGxv2duFeT4t1/Wv4mWNEUOokGROTP60yYX4NiAMHiqTVM5ehIlMMcOB/+X7ut4 chC3L0AWJXRiUxy08guRhn8fpU3C8XVsqUnz21v5vr229sM2xnmhGjDNqMk1szdRzEjU OfEQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1763483297; x=1764088097; 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=48JreFr5BaTMOPMEs2r/FtKXuXZRpdyc8fhVXjm2c3w=; b=hlG0/uAYP4WBXgXuoNfqFrZwMe5Ez3ES7Y1yyBhksX28A/IBtPHcT/MEiPF3mI6mGu CyEm8443Vjo1Mpu+o7xOglniH3i5qzxnJN+KJgzhqAsiX7GTGhwITVO/euE3FOOlosDP UewArtZ8x5oX0cp321miterEWIdj1IHDxOa6pppL0+SxkeLu1rmAKJrS7z2HmCtJihrN nuKF2OInUuMQUSzXoVNpaWVlKt/XcJsL6mp6IpJAaVi3CKcOr8awnRp40TtZAy3OoSpE rO95n3iCPmtwdAbTaA1DHK0tYIx4JrxjlG81VGd8zKK5zv1n82BsukrJGE5ZBIfeFORj 5aqg== X-Forwarded-Encrypted: i=1; AJvYcCVFpYlofXszN4CrYrgg/vWaoHQsCMv8axAG82oyTJ/HSsKVLXIv7gqf09UA9S3apT3elIlB2Bs2el1gExk=@vger.kernel.org X-Gm-Message-State: AOJu0YzNrzFi7HpXIluQBefQO8Trx75r9n7GJ233/EiAzGkqaXv1vJ+c KMa0mpr7J2z+OMi85K7bsBL9lQFWWXs3ReQhRR5aLGKHtIEgV87qy/Lh+tgU9w4RjBY= X-Gm-Gg: ASbGnctxLuDLNYM6vPu9XPAbmohEQLaMgbSn5KK99umq9sSsajFBer1qW/b8ym7KCIZ oOFN838zxCx8kkJ+R87XfUo3hgLZUOwlFzRSNgFT82M+fpCI3j3uPw98cyz5rsLOdR3ryHScDr/ bsFDLff76agEwIhIW5LfpoIPSGE0iZPOMoBZ8lnEMuapjpSEy1gMOGVmeerz9aXHwddLcZZfQCn khuS3CIA/eipwdcBn/TxeM4EQPQgS7lMiMegr0OcwOlEULKfEJcexP0Ma0ZvLDlT1kILfQZsyAf l6cUD+zBMYPg60ZmdRnRznV+RcvxS80pHW/Bscx4BFzoa5dmcBszGW5NzKeQUj62JMsgHX5RYmJ 0hNC5HJV01bfqBZ7q47a5lS4re1zbIcl//gDe4ATDpQHwMy5GDNeOCGx3fFhNwAfkhx6hy25+ER q3y+sEWki3+G3Ptkw89UTXlXh/OqY9RE8= X-Google-Smtp-Source: AGHT+IGSuixkn6OuYVtzSeJQdoPs5+G1QrCaXWxHvrng8vSHtjfxGmf2OhXIq27Lrw6E3F/PTbSNaQ== X-Received: by 2002:a05:600c:1f91:b0:475:dae5:d972 with SMTP id 5b1f17b1804b1-4778fe9aaadmr152880415e9.23.1763483297570; Tue, 18 Nov 2025 08:28:17 -0800 (PST) Received: from ho-tower-lan.lan ([185.48.77.170]) by smtp.gmail.com with ESMTPSA id 5b1f17b1804b1-477a9dea7fcsm20369125e9.8.2025.11.18.08.28.15 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 18 Nov 2025 08:28:16 -0800 (PST) From: James Clark Date: Tue, 18 Nov 2025 16:27:55 +0000 Subject: [PATCH v5 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: <20251118-james-cs-syncfreq-v5-5-82efd7b1a751@linaro.org> References: <20251118-james-cs-syncfreq-v5-0-82efd7b1a751@linaro.org> In-Reply-To: <20251118-james-cs-syncfreq-v5-0-82efd7b1a751@linaro.org> To: Suzuki K Poulose , Mike Leach , Alexander Shishkin , Jonathan Corbet , Leo Yan , Randy Dunlap Cc: coresight@lists.linaro.org, linux-arm-kernel@lists.infradead.org, linux-kernel@vger.kernel.org, linux-doc@vger.kernel.org, James Clark X-Mailer: b4 0.14.0 This allows us to define and consume them in a unified way in later commits. A lot of the existing code has open coded bit shifts or direct usage of whole config values which is error prone and hides which bits are in use and which are free. Reviewed-by: Leo Yan Signed-off-by: James Clark Reviewed-by: Mike Leach --- drivers/hwtracing/coresight/coresight-etm-perf.c | 22 ++++++++--------- drivers/hwtracing/coresight/coresight-etm-perf.h | 31 ++++++++++++++++++++= ++++ 2 files changed, 42 insertions(+), 11 deletions(-) diff --git a/drivers/hwtracing/coresight/coresight-etm-perf.c b/drivers/hwt= racing/coresight/coresight-etm-perf.c index faebd7822a77..28f1bfc4579f 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 @@ -54,22 +55,21 @@ static DEFINE_PER_CPU(struct coresight_device *, csdev_= src); * 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)); +GEN_PMU_FORMAT_ATTR(branch_broadcast); +GEN_PMU_FORMAT_ATTR(cycacc); /* contextid1 enables tracing CONTEXTIDR_EL1 for ETMv4 */ -PMU_FORMAT_ATTR(contextid1, "config:" __stringify(ETM_OPT_CTXTID)); +GEN_PMU_FORMAT_ATTR(contextid1); /* 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)); +GEN_PMU_FORMAT_ATTR(contextid2); +GEN_PMU_FORMAT_ATTR(timestamp); +GEN_PMU_FORMAT_ATTR(retstack); /* preset - if sink ID is used as a configuration selector */ -PMU_FORMAT_ATTR(preset, "config:0-3"); +GEN_PMU_FORMAT_ATTR(preset); /* Sink ID - same for all ETMs */ -PMU_FORMAT_ATTR(sinkid, "config2:0-31"); +GEN_PMU_FORMAT_ATTR(sinkid); /* config ID - set if a system configuration is selected */ -PMU_FORMAT_ATTR(configid, "config2:32-63"); -PMU_FORMAT_ATTR(cc_threshold, "config3:0-11"); - +GEN_PMU_FORMAT_ATTR(configid); +GEN_PMU_FORMAT_ATTR(cc_threshold); =20 /* * contextid always traces the "PID". The PID is in CONTEXTIDR_EL1 diff --git a/drivers/hwtracing/coresight/coresight-etm-perf.h b/drivers/hwt= racing/coresight/coresight-etm-perf.h index 5febbcdb8696..c794087a0e99 100644 --- a/drivers/hwtracing/coresight/coresight-etm-perf.h +++ b/drivers/hwtracing/coresight/coresight-etm-perf.h @@ -20,6 +20,37 @@ struct cscfg_config_desc; */ #define ETM_ADDR_CMP_MAX 8 =20 +#define ATTR_CFG_FLD_preset_CFG config +#define ATTR_CFG_FLD_preset_LO 0 +#define ATTR_CFG_FLD_preset_HI 3 +#define ATTR_CFG_FLD_branch_broadcast_CFG config +#define ATTR_CFG_FLD_branch_broadcast_LO 8 +#define ATTR_CFG_FLD_branch_broadcast_HI 8 +#define ATTR_CFG_FLD_cycacc_CFG config +#define ATTR_CFG_FLD_cycacc_LO 12 +#define ATTR_CFG_FLD_cycacc_HI 12 +#define ATTR_CFG_FLD_contextid1_CFG config +#define ATTR_CFG_FLD_contextid1_LO 14 +#define ATTR_CFG_FLD_contextid1_HI 14 +#define ATTR_CFG_FLD_contextid2_CFG config +#define ATTR_CFG_FLD_contextid2_LO 15 +#define ATTR_CFG_FLD_contextid2_HI 15 +#define ATTR_CFG_FLD_timestamp_CFG config +#define ATTR_CFG_FLD_timestamp_LO 28 +#define ATTR_CFG_FLD_timestamp_HI 28 +#define ATTR_CFG_FLD_retstack_CFG config +#define ATTR_CFG_FLD_retstack_LO 29 +#define ATTR_CFG_FLD_retstack_HI 29 +#define ATTR_CFG_FLD_sinkid_CFG config2 +#define ATTR_CFG_FLD_sinkid_LO 0 +#define ATTR_CFG_FLD_sinkid_HI 31 +#define ATTR_CFG_FLD_configid_CFG config2 +#define ATTR_CFG_FLD_configid_LO 32 +#define ATTR_CFG_FLD_configid_HI 63 +#define ATTR_CFG_FLD_cc_threshold_CFG config3 +#define ATTR_CFG_FLD_cc_threshold_LO 0 +#define ATTR_CFG_FLD_cc_threshold_HI 11 + /** * struct etm_filter - single instruction range or start/stop configuratio= n. * @start_addr: The address to start tracing on. --=20 2.34.1 From nobody Tue Dec 2 02:32:40 2025 Received: from mail-wm1-f52.google.com (mail-wm1-f52.google.com [209.85.128.52]) (using TLSv1.2 with cipher ECDHE-RSA-AES128-GCM-SHA256 (128/128 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 365C0227E95 for ; Tue, 18 Nov 2025 16:28:20 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=209.85.128.52 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1763483302; cv=none; b=lFdoJ0Y0v3HEI6tmLiKuukOcNoizTT7oLRO5HAoFGtc5QbP7+J8FlV/brORjzCg55tLCciLLLX0dVojXSkc39orvuhZkg3BZfp4QroiGRJgsL7jULhsWFI0HzP12ZGRdqaTJnyrpltcJerZmfjQOuTpvfiDN1Vlv0LRufkYWyoU= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1763483302; c=relaxed/simple; bh=OOb4yNfBq0DxPF8hQvLUI30prmr2dFYr6vUoRd2Wzp0=; h=From:Date:Subject:MIME-Version:Content-Type:Message-Id:References: In-Reply-To:To:Cc; b=VWmzxmqQxTSlIlkiwuJoln+kqPU67CEkhBycBjlzjHV6C6RdIpKsRho3HDfQqSx81JHx0OglNHRojCdws6Z0EKssip4+oLshe5V+wJCPWyLFh2b29xXwrkbczarRnRUaLY2qTj3/KYBj23Gi4plJVxLQ0F5Gwwco09erZkHhpt4= 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=Le2167YA; arc=none smtp.client-ip=209.85.128.52 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=linaro.org Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=linaro.org Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=linaro.org header.i=@linaro.org header.b="Le2167YA" Received: by mail-wm1-f52.google.com with SMTP id 5b1f17b1804b1-4779adb38d3so26952055e9.2 for ; Tue, 18 Nov 2025 08:28:19 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; t=1763483298; x=1764088098; darn=vger.kernel.org; h=cc:to:in-reply-to:references:message-id:content-transfer-encoding :mime-version:subject:date:from:from:to:cc:subject:date:message-id :reply-to; bh=mAj6+rTtj7ATosP9M3WMDyWCja/Ic0j8s2EkvfB39Kc=; b=Le2167YAw7S2+sW60Fl1EyhQJsv+2hjuvrONkH8jKgZK5DgCxOpQoq6B8qC9K7qkJh 0nZB3JdJoOXpDs5x/3EAAm4s23JY4+3Rn1Y3NbNSf/Sav/fG+YBv5ZyL2Ojmmlq6ylUJ +1s2dYe79v+EO13foCYriSkj6BOQgNq/BcBlv8Rv9xBRzw6obtmEl0Squgy1z27zQip+ 5IJ0c/l3Uimee3cTCDQsfYQTWDry3j0Ut1VGdffdFdSslJIA/gwIOHx5kAudeuqAR8ID Ofzl/X8BjI4t3LzudNLkaOJai0p3VxDBlGwFqGPERFlSXVr63k1GXDo6aYR/BOf2Bdde VrnQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1763483298; x=1764088098; h=cc:to:in-reply-to:references:message-id:content-transfer-encoding :mime-version:subject:date:from:x-gm-gg:x-gm-message-state:from:to :cc:subject:date:message-id:reply-to; bh=mAj6+rTtj7ATosP9M3WMDyWCja/Ic0j8s2EkvfB39Kc=; b=JSwNoR4I4c2ynH093spoiIoO9TEfq8LIap7Gbe988eX90qwRhM3coy/6huf27rYRgP ZU6MQ6S4fioSmmHizVtLq+fuUJ41gRmjVpxWQ2LL2m4O7Z3Nod7ceK3liwRWGf+vaUTw e7u2XhIaujZv8NtsWBlaFXbKc8+WfbO+mZScSFHpIoLmDHdZrGBHPbFgUXDJkuZ8ACsU h3eDfYVMffz8loNN9ctMATTsc1YnWdoCJovaNCvDEmpQkBk64zsAfapvdAlyyuaMzZ2L nP4SZwhyeDdxJzuYBcstbscTVZXYyhfwYDWBDjGRxVeswOtMBMth1F3tGROhOugZ04J4 vmug== X-Forwarded-Encrypted: i=1; AJvYcCXIaOBCcSS5x4dSgRI7Xcws+vNhq3NlkWLJkXsoc/4ScTjIQS8HErVfKC0DGZYRWx1OS/12EWs8zmPYNwE=@vger.kernel.org X-Gm-Message-State: AOJu0Yx8L+8EshtaoZ/GsDZHjFoH7vUiYqqJqi+sWwErdUvLIKJ5L4Rc 2qyxKG8T108oCS/b7oCZY+ZgamYzbS0vzAgeOellF/JitLCm54RKnV/zpczWsHmNj4qnsdCotyH 4SlXAIIk= X-Gm-Gg: ASbGnctHHXtyk5L3/7JIDuk8GKZ1TjvVAjMCHUnclbD4t7gJwN5pY7u8S9745LPPm33 42a6UVoclleCMgZUeoR4UrRAywMDKf6rggewrZyEVhoryvRv8qnxY9ThjF6dJmWpO29EMpvJnM7 Q9DN2Ua6y9zDzPNjB5ivMq/O/YA4MBC8ZFph0GO/7d00c95FEOadOqgSlbv+paeFlUHI/wpeXnW hnVXgXvICpIbEnJPH3u6QfadXYFcxb/PRF7UxIXzzDQrEf2ya/i2GYOVc8vYDZbft0x30yHUcJq i2UrvHVFAA6eGPN2A1YmpzXalJis/xqFC8S7zxQsr6wpF8Y/V22FEVkeOSWqlttK7s60n8d+nyX Q7RYIVv8DhMdNFvlkgjSO8d7aS1nbnEJW7yCN9LB3LdvunQttGWm0lk3WPLIxV0voSwoeG7cuN9 iwF22f1cwBFx/dwO04z//f X-Google-Smtp-Source: AGHT+IHdkgwTmwsezlOoVl1oKxZpwdtFrPVQJMsdiG4hR9IlMAHY8woJY2B8eC7OmFl51DiuSqqZBg== X-Received: by 2002:a05:600c:c178:b0:458:a7fa:211d with SMTP id 5b1f17b1804b1-4778feb2401mr149231795e9.29.1763483298511; Tue, 18 Nov 2025 08:28:18 -0800 (PST) Received: from ho-tower-lan.lan ([185.48.77.170]) by smtp.gmail.com with ESMTPSA id 5b1f17b1804b1-477a9dea7fcsm20369125e9.8.2025.11.18.08.28.17 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 18 Nov 2025 08:28:18 -0800 (PST) From: James Clark Date: Tue, 18 Nov 2025 16:27:56 +0000 Subject: [PATCH v5 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: <20251118-james-cs-syncfreq-v5-6-82efd7b1a751@linaro.org> References: <20251118-james-cs-syncfreq-v5-0-82efd7b1a751@linaro.org> In-Reply-To: <20251118-james-cs-syncfreq-v5-0-82efd7b1a751@linaro.org> To: Suzuki K Poulose , Mike Leach , Alexander Shishkin , Jonathan Corbet , Leo Yan , Randy Dunlap Cc: coresight@lists.linaro.org, linux-arm-kernel@lists.infradead.org, linux-kernel@vger.kernel.org, linux-doc@vger.kernel.org, James Clark X-Mailer: b4 0.14.0 Currently we're programming attr->config directly into ETMCR after some validation. This obscures which fields are being used, and also makes it impossible to move fields around or use other configN fields in the future. Improve it by only reading the fields that are valid and then setting the appropriate ETMCR bits based on each one. The ETMCR_CTXID_SIZE part can be removed as it was never a valid option because it's not in ETM3X_SUPPORTED_OPTIONS. Reviewed-by: Leo Yan Signed-off-by: James Clark Reviewed-by: Mike Leach --- drivers/hwtracing/coresight/coresight-etm3x-core.c | 24 ++++++++++++------= ---- 1 file changed, 13 insertions(+), 11 deletions(-) diff --git a/drivers/hwtracing/coresight/coresight-etm3x-core.c b/drivers/h= wtracing/coresight/coresight-etm3x-core.c index a5e809589d3e..4511fc2f8d72 100644 --- a/drivers/hwtracing/coresight/coresight-etm3x-core.c +++ b/drivers/hwtracing/coresight/coresight-etm3x-core.c @@ -28,6 +28,7 @@ #include #include #include +#include #include =20 #include "coresight-etm.h" @@ -339,21 +340,22 @@ static int etm_parse_event_config(struct etm_drvdata = *drvdata, if (attr->config & ~ETM3X_SUPPORTED_OPTIONS) return -EINVAL; =20 - config->ctrl =3D attr->config; + config->ctrl =3D 0; =20 - /* Don't trace contextID when runs in non-root PID namespace */ - if (!task_is_in_init_pid_ns(current)) - config->ctrl &=3D ~ETMCR_CTXID_SIZE; + if (ATTR_CFG_GET_FLD(attr, cycacc)) + config->ctrl |=3D ETMCR_CYC_ACC; + + if (ATTR_CFG_GET_FLD(attr, timestamp)) + config->ctrl |=3D ETMCR_TIMESTAMP_EN; =20 /* - * Possible to have cores with PTM (supports ret stack) and ETM - * (never has ret stack) on the same SoC. So if we have a request - * for return stack that can't be honoured on this core then - * clear the bit - trace will still continue normally + * Possible to have cores with PTM (supports ret stack) and ETM (never + * has ret stack) on the same SoC. So only enable when it can be honored + * - trace will still continue normally otherwise. */ - if ((config->ctrl & ETMCR_RETURN_STACK) && - !(drvdata->etmccer & ETMCCER_RETSTACK)) - config->ctrl &=3D ~ETMCR_RETURN_STACK; + if (ATTR_CFG_GET_FLD(attr, retstack) && + (drvdata->etmccer & ETMCCER_RETSTACK)) + config->ctrl |=3D ETMCR_RETURN_STACK; =20 return 0; } --=20 2.34.1 From nobody Tue Dec 2 02:32:40 2025 Received: from mail-wm1-f46.google.com (mail-wm1-f46.google.com [209.85.128.46]) (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 BDA3F3A1CE5 for ; Tue, 18 Nov 2025 16:28:21 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=209.85.128.46 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1763483303; cv=none; b=D6bJ7m5o47VDhRYnZerlc6FGPMONOcNXg9/bSLVbMQNEejpEhfqZlNt9YaF+wpEnHl56jq/VV8PetI2ylbPChnYxH0Mps28DI6ORRcKgL77oLlvRgnu7+LKF/2n5JZ8WdSJx9CdPCZ3G7baNZ4LN3rQUwLR058CwuiNUGBuDv3k= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1763483303; c=relaxed/simple; bh=N+Q6R1XCPpnjYjCPIVjDvoCYHZZK5o2FhEXZTAuBfSI=; h=From:Date:Subject:MIME-Version:Content-Type:Message-Id:References: In-Reply-To:To:Cc; b=Wy6GUajnF7KFW0A6IbW61gHVZCsKfw6lSuYiMFc+rxpe74ztNrpcOXBPKptzSnrrWlp7PRsKxv0YByAVu7rEqb2hapyhsTW9/YuVnW+W7GD1yck/wlm2IO+Wiv/veVjGGCiHrWdJzvMV49MSKdixnuG1pj6dTDdE7CdrgcOf0gs= 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=DkR4k6Df; arc=none smtp.client-ip=209.85.128.46 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="DkR4k6Df" Received: by mail-wm1-f46.google.com with SMTP id 5b1f17b1804b1-47775fb6cb4so41174485e9.0 for ; Tue, 18 Nov 2025 08:28:21 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; t=1763483300; x=1764088100; darn=vger.kernel.org; h=cc:to:in-reply-to:references:message-id:content-transfer-encoding :mime-version:subject:date:from:from:to:cc:subject:date:message-id :reply-to; bh=s7Cp0IQzkfAKXAya/Lg64jqfJ1j/YiOKK8shdTQX7JE=; b=DkR4k6DfQXEX41hXJ+VFjkJgiwaGWgeb4zcRDr+BaXJl4y5e2WeVgzRqpG41cTKgZj Ei4HX0Gg9iyLLfhsxBXHbkMC0weWxDYn8NALvZIDmlAzMe0AO1vipxzhJPXzoxaEKJFt r6XBipsFcsepkGSyznV4rDRHZFqnijjRJAkL7MUR+LPHzUxgwrgHYtJs31wfDbLMdIbI FwoXpcAp3L2LHdvwS4yTMKpylYorpuga+okLTeDiBOK0nS+sJ0retiYWocgHKtU0nkeV S08P+Y0KFd4UAzHmp/Rp4OPwnbvxXTiGL8WU1ATxOJkOQLsyx+tQkBlhGYaaCyY8pr9L JCKQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1763483300; x=1764088100; h=cc:to:in-reply-to:references:message-id:content-transfer-encoding :mime-version:subject:date:from:x-gm-gg:x-gm-message-state:from:to :cc:subject:date:message-id:reply-to; bh=s7Cp0IQzkfAKXAya/Lg64jqfJ1j/YiOKK8shdTQX7JE=; b=oCVMRbRo+jwHrKRAZtCsdAeWQybp3qStD7UP60Iw4O6GJSaaxIb3d+CcOU8FPOzo7B P0s43wNpCRspC5JIfOQ072Je9deASN5R2QBSpiG4GZqohgN6N3qTPtvhJuCW4z/mGMZm Sx/68WDTbYwRWXqo8VsDXvrUwIQxaGrGJG5uEAHjJDM36ARcNxjitYvBI8BDzyJBDbtz MBySFsCksj3gzr1aQdaAXeE11rb5wBV8ns2CiTNb5b+5Cy/6CFeGzmWjwuuVZ7vSpggR euQt/poWkBFpM465L5UB2VrzQkX99SvQRfdzI78ZUXlvlccun8HM/5oPTVFs4lwIS5ox eulg== X-Forwarded-Encrypted: i=1; AJvYcCU20G2EkI3sJmmKs4gZ5USvVpTtQbgjdI+DI7HiKrNH4QlI87yCUEY6MYShQOXb1UyRjDxrhTp8/f/QvAM=@vger.kernel.org X-Gm-Message-State: AOJu0YwPa0ICLefC9HQFkAsOMx8AFc8IittAotYDH8rUPKXb1PYIXTG3 eurh+9T/o+msQCs5+i7XT9+Z+d+945pI4l3GtAa44APJyv5GmEFobCCvwLqnScgL393Ir/dVg03 RQlZGHQ8= X-Gm-Gg: ASbGnctS0Z8YiZqH367g6HzFC/0siyATznbp0GZWcDxb4mPTUWNqEDEEMhOLfri7SoL 2gHIij5vs2NJtOOr8LV74AxXAA2RXyHaA1ewReE93ubzRmFEoTSg1cYLcdjVSdN7nDFi+kimLU3 OAeK+g/4e4eF0FxpYQ0KpYf1RMDyw4q5xpQL7q6KFed3QX/5ou5gXPUjsSz35NPdhaQu9aw1EZG MJIKzKLceu5lwSPYkvc4bOkfHk2U2UEUETrEzu2qGSwxwSEFqmiv/EnNVbKMgSFZF010lZwcGxs Fac/Pd2pZenTuLfGs5AJxthUbLJFWKKA9NiYqQV/6wowODhuXxL7SElWH32ZDxq56/DyrNoGEAf RNdYsQbqixV5J5MjMWEpobLbbLy2/sNC9RXiEzS1YdF6JLTdTQ6O0w9Rp35nqoEXfYEQEDRWUBV JYa/g8GLuMdX6+2txQmHHb X-Google-Smtp-Source: AGHT+IGvkVieQt1G4+tUhXjqKDIAxEgYuGjCa+t00ADvjlhFJ4APSPCkFPkbv/kD5N1u2T3cDsB68w== X-Received: by 2002:a05:600c:a49:b0:475:e007:baf1 with SMTP id 5b1f17b1804b1-4778feadb6dmr146870515e9.34.1763483299512; Tue, 18 Nov 2025 08:28:19 -0800 (PST) Received: from ho-tower-lan.lan ([185.48.77.170]) by smtp.gmail.com with ESMTPSA id 5b1f17b1804b1-477a9dea7fcsm20369125e9.8.2025.11.18.08.28.18 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 18 Nov 2025 08:28:19 -0800 (PST) From: James Clark Date: Tue, 18 Nov 2025 16:27:57 +0000 Subject: [PATCH v5 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: <20251118-james-cs-syncfreq-v5-7-82efd7b1a751@linaro.org> References: <20251118-james-cs-syncfreq-v5-0-82efd7b1a751@linaro.org> In-Reply-To: <20251118-james-cs-syncfreq-v5-0-82efd7b1a751@linaro.org> To: Suzuki K Poulose , Mike Leach , Alexander Shishkin , Jonathan Corbet , Leo Yan , Randy Dunlap Cc: coresight@lists.linaro.org, linux-arm-kernel@lists.infradead.org, linux-kernel@vger.kernel.org, linux-doc@vger.kernel.org, James Clark X-Mailer: b4 0.14.0 config isn't the only field, there are also config1, config2, etc. Rejecting unrecognized attributes is therefore inconsistent as it wasn't done for all fields. It was only necessary when we were directly programming attr->config into ETMCR and didn't hide the unsupported fields, but now it's not needed so remove it. Reviewed-by: Leo Yan Signed-off-by: James Clark Reviewed-by: Mike Leach --- drivers/hwtracing/coresight/coresight-etm3x-core.c | 7 ------- 1 file changed, 7 deletions(-) diff --git a/drivers/hwtracing/coresight/coresight-etm3x-core.c b/drivers/h= wtracing/coresight/coresight-etm3x-core.c index 4511fc2f8d72..584d653eda81 100644 --- a/drivers/hwtracing/coresight/coresight-etm3x-core.c +++ b/drivers/hwtracing/coresight/coresight-etm3x-core.c @@ -333,13 +333,6 @@ static int etm_parse_event_config(struct etm_drvdata *= drvdata, if (config->mode) etm_config_trace_mode(config); =20 - /* - * At this time only cycle accurate, return stack and timestamp - * options are available. - */ - if (attr->config & ~ETM3X_SUPPORTED_OPTIONS) - return -EINVAL; - config->ctrl =3D 0; =20 if (ATTR_CFG_GET_FLD(attr, cycacc)) --=20 2.34.1 From nobody Tue Dec 2 02:32:40 2025 Received: from mail-wm1-f42.google.com (mail-wm1-f42.google.com [209.85.128.42]) (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 1D6133A1CFB for ; Tue, 18 Nov 2025 16:28:23 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=209.85.128.42 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1763483306; cv=none; b=rwtG8Gv8sx97lA60x9ph76foxeu6ThzfwSmVGEJF1T9ffvv1Zrwzo/vapy565Z5QJvCrKnWk1r05kMu8gVyDRI1SmuAp34G37p/16wGT/sb1c3h3XZvtbG/y3ZB3b6Aa75WbHBd7vICkRpz4Rk9i74HkfMuKDUxBWHGZdxU2w7s= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1763483306; c=relaxed/simple; bh=dzP9hXvjEFYTJ+sYEH3OS9fqnJEZYSr9lDuXso7NVaA=; h=From:Date:Subject:MIME-Version:Content-Type:Message-Id:References: In-Reply-To:To:Cc; b=j5hD1nH6jmCLcVRQHVtx5l+KCFKodpWP53wl7lUMhcxamPKulktf4XPvcE2rHV9/jgYEg8n8QfXMrYzxAGO57LzFNG1KRHg6ht4aqfJSYviqchf/yBotPn1PbUPl+Fv/vlyDr5VT6xXl0Is8lk/hILUXq8wEASINkRQtv0pMtnE= 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=s6SIGZVQ; arc=none smtp.client-ip=209.85.128.42 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="s6SIGZVQ" Received: by mail-wm1-f42.google.com with SMTP id 5b1f17b1804b1-4779adb38d3so26952715e9.2 for ; Tue, 18 Nov 2025 08:28:23 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; t=1763483302; x=1764088102; 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=l9PmA5gGpR/tWp7wz6WLiRdtF8z1fVXXlKYB4lN3jNM=; b=s6SIGZVQ6ET2YQ244cAn/t/dKNMZXalrQef//gQMJ+9tuyhisGohw1xf76rRHdQUG9 IcMGiWfIN2Dq/r1PDwdQQm0T8VWcbt8B3LQ4npcuD1mtQViwUqvPRDMtEduKHWvFbbfZ 3yWul+N1oxc/ZmJg+BReE7wIBMvw0+6bNh6Cyy5szRyfKgFeIO0zswHzecDVle/CHtjm hTWIswpoM49DIMicoFTmzZTUBWn7f0m2nHSyqmJKNmtEVc9r+ChXN0eQwR9c0hxPy+yD BBPVB1QlL7i1sSUHKQsqtYxsMdo12pFiY7yKIvoZqvjPxI3YyO+lOD6XCXrOZVmOGbRd 4D6A== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1763483302; x=1764088102; 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=l9PmA5gGpR/tWp7wz6WLiRdtF8z1fVXXlKYB4lN3jNM=; b=tf5gCpQydX6ppYb5ffdGtgz/S7XPk+Cmn0shpph09a0pGCeh9+nz3ee02EFkVd4i7b 8Y+GMoQMZoDhmevV+FTq5QPUYo3sKwMR7eG+EyCdfmCWtr+qEtUEelNrn05XNj7v/w03 p4D/iRYRoXbfMgyX5OtLIJb+LO4BhtRW8liCIN9/Pdvak+DF+JACX6V6pN0yFD3lo0Tg yNDe4R+HwA9+f1Ji+qVvrWhYnWoQdTrWhnq+bArW0c7XaX+6pXK0rrdJGo8N1YMzpyUe nVxjDH8iMa8J5ctrPI8UjSpAWitQ4VtLIWiq1WB10J+saWEVimktGq+uvIqJHSSyRiwg Mo4g== X-Forwarded-Encrypted: i=1; AJvYcCWjUGlWGyls6RWzl1nhsaEdm2Qfyg8dG2tQH4nrcV9airn9DCX7URhq/vhFkGRg+5rNQ381UY8+BzgHRmM=@vger.kernel.org X-Gm-Message-State: AOJu0YwGGCEQsXj7fd1q1BELBWXO5lfGCl3JbrBvGpbEC+5RCZ2t7UMs vRvNSxHKsK1YnmXWtfBeirpLAeRml3oF8dquKP+eLNvEOx+xGsRZ0+XPV2p0cPwhtig= X-Gm-Gg: ASbGncu2D8RN5UUCtnb8jJw0eM1eC18o/8rbg0dzZ2RRF/mNbH9FWmTqfRVs+psoHHV PgdHQONfgSlr4KY44VLHQB7vUuHco3Gg9tr7az7yHf2IkyuVZMI/uYjx2Fb9H3l9whIc2lIBF1E Fj7pRY7//R2Wh4Wt5p07PB5TjrtIAd7zXfAV8fb7wCozPd6Otk4d1vuTUUzaLEScRazQlcgGSYQ +ov+4xxPnXojvK++epbJN/yNxGMT/9gQ2OeVkeTJKBFht3anbuEe4vCzQIhMco4egmeCLTVr8/D 0M6Hy/JxQmIS4V1LijjjuHUKiIi9u5lF8bL+7gr1bMAfFMojy+PMnmOvOa3vkdGqlIbat+D/DX9 CYpvpGP/mo7lQlqihPqxUn22BsdhldB+kNTMqWZw+70hmEfK34UoZY8skjNES92b1/Osu4SN10s mTlM1iil1py7Xv5R72F6IniPu6zfpsSSQ= X-Google-Smtp-Source: AGHT+IFBsfyqI4nfvni5vPvJYY1wHrZ3i9XROTrpO6sjMJMIe4fE7Y8UeZdT+PEXWHCYRfnXU1kcgA== X-Received: by 2002:a05:600c:4685:b0:477:7a1a:4b82 with SMTP id 5b1f17b1804b1-4778fe5fb4amr166705645e9.8.1763483302373; Tue, 18 Nov 2025 08:28:22 -0800 (PST) Received: from ho-tower-lan.lan ([185.48.77.170]) by smtp.gmail.com with ESMTPSA id 5b1f17b1804b1-477a9dea7fcsm20369125e9.8.2025.11.18.08.28.19 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 18 Nov 2025 08:28:21 -0800 (PST) From: James Clark Date: Tue, 18 Nov 2025 16:27:58 +0000 Subject: [PATCH v5 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: <20251118-james-cs-syncfreq-v5-8-82efd7b1a751@linaro.org> References: <20251118-james-cs-syncfreq-v5-0-82efd7b1a751@linaro.org> In-Reply-To: <20251118-james-cs-syncfreq-v5-0-82efd7b1a751@linaro.org> To: Suzuki K Poulose , Mike Leach , Alexander Shishkin , Jonathan Corbet , Leo Yan , Randy Dunlap Cc: coresight@lists.linaro.org, linux-arm-kernel@lists.infradead.org, linux-kernel@vger.kernel.org, linux-doc@vger.kernel.org, James Clark X-Mailer: b4 0.14.0 The "config:" string construction in format_attr_contextid_show() can be removed because it either showed the existing context1 or context2 formats which have already been generated, so can be called themselves. The other conversions are straightforward replacements. Signed-off-by: James Clark --- drivers/hwtracing/coresight/coresight-etm-perf.c | 26 +++++++++++++++-----= ---- 1 file changed, 16 insertions(+), 10 deletions(-) diff --git a/drivers/hwtracing/coresight/coresight-etm-perf.c b/drivers/hwt= racing/coresight/coresight-etm-perf.c index 28f1bfc4579f..1b9ae832a576 100644 --- a/drivers/hwtracing/coresight/coresight-etm-perf.c +++ b/drivers/hwtracing/coresight/coresight-etm-perf.c @@ -80,12 +80,19 @@ static ssize_t format_attr_contextid_show(struct device= *dev, struct device_attribute *attr, char *page) { - int pid_fmt =3D ETM_OPT_CTXTID; + /* + * is_kernel_in_hyp_mode() isn't defined in arm32 so avoid calling it + * even though is_visible() prevents this function from being called. + */ +#if IS_ENABLED(CONFIG_ARM64) + if (is_kernel_in_hyp_mode()) + return contextid2_show(dev, attr, page); =20 -#if IS_ENABLED(CONFIG_CORESIGHT_SOURCE_ETM4X) - pid_fmt =3D is_kernel_in_hyp_mode() ? ETM_OPT_CTXTID2 : ETM_OPT_CTXTID; + return contextid1_show(dev, attr, page); +#else + WARN_ONCE(1, "ETM contextid not supported on arm32\n"); + return 0; #endif - return sprintf(page, "config:%d\n", pid_fmt); } =20 static struct device_attribute format_attr_contextid =3D @@ -337,7 +344,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; @@ -350,13 +357,12 @@ static void *etm_setup_aux(struct perf_event *event, = void **pages, INIT_WORK(&event_data->work, free_event_data); =20 /* First get the selected sink from user space. */ - if (event->attr.config2 & GENMASK_ULL(31, 0)) { - id =3D (u32)event->attr.config2; - sink =3D user_sink =3D coresight_get_sink_by_id(id); - } + sink_hash =3D ATTR_CFG_GET_FLD(&event->attr, sinkid); + if (sink_hash) + sink =3D user_sink =3D coresight_get_sink_by_id(sink_hash); =20 /* check if user wants a coresight configuration selected */ - cfg_hash =3D (u32)((event->attr.config2 & GENMASK_ULL(63, 32)) >> 32); + cfg_hash =3D ATTR_CFG_GET_FLD(&event->attr, configid); if (cfg_hash) { if (cscfg_activate_config(cfg_hash)) goto err; --=20 2.34.1 From nobody Tue Dec 2 02:32:40 2025 Received: from mail-wm1-f50.google.com (mail-wm1-f50.google.com [209.85.128.50]) (using TLSv1.2 with cipher ECDHE-RSA-AES128-GCM-SHA256 (128/128 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 188C53A5E77 for ; Tue, 18 Nov 2025 16:28:24 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=209.85.128.50 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1763483307; cv=none; b=ZddGF2t4zTGk4WvOzX6ap6iJzPaSwgOQvXGJpmdX0+UylV9gCVTBXEiFWOgBPMVeulW/oSgBssqIUYAAsgW/91eWW4mR6Uzp9GzKAg/CylP+VQuRAc1ikcoNYNk3f2xMvRGOntUnnHrAkEG24hd9Hv5EfaNlUCbc3sI4icKfM/Q= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1763483307; c=relaxed/simple; bh=S1lAdaCJ1lnshqz4avnLOeP/pLK/1ucm2BsQAjK8ZFc=; h=From:Date:Subject:MIME-Version:Content-Type:Message-Id:References: In-Reply-To:To:Cc; b=sOakKGrfSgl7C5vdIeGmQsIWS9n0xQ7ADL65IG2SSAsgAZORJ8LDfDHF6IKdSAtULDvOvEJ3w2uDVFdrbRbP8Sg/N92/++fbn2tu3LXWzMBb4laUIKaihzCAdL990MhO1n1SN5Fwq5IpzkjuyupMUmH0VWgy0vvtiaqmK1bKoB8= 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=Nhc9rZWR; arc=none smtp.client-ip=209.85.128.50 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=linaro.org Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=linaro.org Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=linaro.org header.i=@linaro.org header.b="Nhc9rZWR" Received: by mail-wm1-f50.google.com with SMTP id 5b1f17b1804b1-477563e28a3so39663275e9.1 for ; Tue, 18 Nov 2025 08:28:24 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; t=1763483303; x=1764088103; darn=vger.kernel.org; h=cc:to:in-reply-to:references:message-id:content-transfer-encoding :mime-version:subject:date:from:from:to:cc:subject:date:message-id :reply-to; bh=iqeQCDNzyERvoI4uJsKzrMugXzNJjWTyKx7GIItRI68=; b=Nhc9rZWRPH86QgcAomjrFZdfx/nBmKb2BnGKvCoH6cnOTJ4uKdhpgAkST6wXhTQJt7 vqdhN9WmhobzkAEI57elUn6mfgepFpws6Yd2NCvTSPfXWR+CpjEaeCKZbAPAhx8t69YY Wv2W3gR21nKQmXo3dzIKvF/N2KWOU+r1vpCXpAKe1Ib2FpvQ9ufs+Krc2Ocdvz1bk5pH f2ZH7F983WHV9VA7lRQyQS9dGdguSF3JbcZQnrm2mmd/Y4liVlHV4kx63hi4kR+Zv7/9 ks30LdetAIJTSX88jSR9GBCe3SuJ46/GahEVNNl7N7q6vrRga9oH1AvkNyJyF4rMY3xS 4XBQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1763483303; x=1764088103; h=cc:to:in-reply-to:references:message-id:content-transfer-encoding :mime-version:subject:date:from:x-gm-gg:x-gm-message-state:from:to :cc:subject:date:message-id:reply-to; bh=iqeQCDNzyERvoI4uJsKzrMugXzNJjWTyKx7GIItRI68=; b=S3ygrHnTZBy6ceoax1UJL40x53o44xiqnIGDSkU9rjcXB4iRAHdgC8DAcbZ7bsRjLz Nenav7bYv0ArKSPIO5CwG7ThGDgMaovjAohzblgRxYtk35lNw4avbbdqN9K++qj4zgId U63sKIjDLr5XU9xpkmWE+Jb56RJJBtE3P4daDeYiN4hnNzuFlDz5c4bYzyfknXk2w079 1a60sv+8kPqDzP2iNOln5zWDUIyxwfeFeBzCJW4NpGv8t/qAy0MsVndPCdv6MJiu8Gwm HFE1Hm+mpklHqs+Ypst85B5NQ3oLXro/HOn7Mn15zcIQNhvxRdSZLjhXR6NaZs8lAMAB nwTw== X-Forwarded-Encrypted: i=1; AJvYcCUA7pNbNpQZOt+elV7UBPc/+z1E4/OGnA2BDAGAWs+Zbet8uekmXS/xJHTPp7MN7SHscZ11pMNIqf+plv0=@vger.kernel.org X-Gm-Message-State: AOJu0YxvCXNE8FJT4snaCp23uMh4P4RilNDFuGA6NttqymijVmooCHI5 GFOeMzO43s8+6aW5KzVLIlyCzNORECT/KT0wPpvJ5C72O8w8TJppjgecLDUugoPkKLk= X-Gm-Gg: ASbGncuNOMQvjyKIayqcuLIwzLGvHG4x2vUZLfAKv3WjPyytN7anFji6JKQboJtWA1E hYkIrOCcSbEp2TmNOpVEeQrBgR7uMw+tORUYKODqQClLiQ3LTtTiZfOoXRdc4hEg/C0+OfeyJhb lYqUVLF8WaAqXhqyXijt8YzHSVXmMogblrA6nbR+2Bgh1F6c7SUcbImnReSbZ2bVOmW2l8h5FRU fosckzzA0GrMOhznTb0ZFzvBGnmlvl7k6PN/5GH01OEw9ZrBVPN2k3RmjcQxG5E9HqHjL08wzsB Ac5FRwyaLiW31QijarAi/Mg4A+zsO+XQIHBxRtoWIVw4+iQfbSCBqFmlW12rlJ1x96OPMHOwC2A ABeHF64bo5NniGrLfCRYTzv1+enOnIrG+p01eKyQ6XA27NDy0hIQfheYp4TNNX43ydEQRVI6fnW Nh9zfSc8YQHRuSA5Uw0p9X0RU9SLJ7Q4U= X-Google-Smtp-Source: AGHT+IHiGNeVqYzY8RnLPJ8E6eZBVePfsLh5VCrTQGhetzIjHKic3zyWZ4+OT6CddGvt4e7P7u0Utw== X-Received: by 2002:a05:600c:4b2a:b0:475:de06:dbaf with SMTP id 5b1f17b1804b1-477b0cd8812mr392975e9.17.1763483303339; Tue, 18 Nov 2025 08:28:23 -0800 (PST) Received: from ho-tower-lan.lan ([185.48.77.170]) by smtp.gmail.com with ESMTPSA id 5b1f17b1804b1-477a9dea7fcsm20369125e9.8.2025.11.18.08.28.22 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 18 Nov 2025 08:28:22 -0800 (PST) From: James Clark Date: Tue, 18 Nov 2025 16:27:59 +0000 Subject: [PATCH v5 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: <20251118-james-cs-syncfreq-v5-9-82efd7b1a751@linaro.org> References: <20251118-james-cs-syncfreq-v5-0-82efd7b1a751@linaro.org> In-Reply-To: <20251118-james-cs-syncfreq-v5-0-82efd7b1a751@linaro.org> To: Suzuki K Poulose , Mike Leach , Alexander Shishkin , Jonathan Corbet , Leo Yan , Randy Dunlap Cc: coresight@lists.linaro.org, linux-arm-kernel@lists.infradead.org, linux-kernel@vger.kernel.org, linux-doc@vger.kernel.org, James Clark X-Mailer: b4 0.14.0 Remove hard coded bitfield extractions and shifts and replace with ATTR_CFG_GET_FLD(). ETM4_CFG_BIT_BB was defined to give the register bit positions to userspace, TRCCONFIGR_BB should be used in the kernel so replace it. Reviewed-by: Leo Yan Signed-off-by: James Clark Reviewed-by: Mike Leach --- drivers/hwtracing/coresight/coresight-etm4x-core.c | 44 ++++++++++--------= ---- 1 file changed, 19 insertions(+), 25 deletions(-) diff --git a/drivers/hwtracing/coresight/coresight-etm4x-core.c b/drivers/h= wtracing/coresight/coresight-etm4x-core.c index 5d21af346799..c7208ffc9432 100644 --- a/drivers/hwtracing/coresight/coresight-etm4x-core.c +++ b/drivers/hwtracing/coresight/coresight-etm4x-core.c @@ -29,6 +29,7 @@ #include #include #include +#include #include #include #include @@ -780,17 +781,17 @@ static int etm4_parse_event_config(struct coresight_d= evice *csdev, goto out; =20 /* Go from generic option to ETMv4 specifics */ - if (attr->config & BIT(ETM_OPT_CYCACC)) { + if (ATTR_CFG_GET_FLD(attr, cycacc)) { config->cfg |=3D TRCCONFIGR_CCI; /* TRM: Must program this for cycacc to work */ - cc_threshold =3D attr->config3 & ETM_CYC_THRESHOLD_MASK; + cc_threshold =3D ATTR_CFG_GET_FLD(attr, cc_threshold); if (!cc_threshold) cc_threshold =3D ETM_CYC_THRESHOLD_DEFAULT; if (cc_threshold < drvdata->ccitmin) cc_threshold =3D drvdata->ccitmin; config->ccctlr =3D cc_threshold; } - if (attr->config & BIT(ETM_OPT_TS)) { + if (ATTR_CFG_GET_FLD(attr, timestamp)) { /* * Configure timestamps to be emitted at regular intervals in * order to correlate instructions executed on different CPUs @@ -810,17 +811,17 @@ static int etm4_parse_event_config(struct coresight_d= evice *csdev, } =20 /* Only trace contextID when runs in root PID namespace */ - if ((attr->config & BIT(ETM_OPT_CTXTID)) && + if (ATTR_CFG_GET_FLD(attr, contextid1) && task_is_in_init_pid_ns(current)) /* bit[6], Context ID tracing bit */ config->cfg |=3D TRCCONFIGR_CID; =20 /* - * If set bit ETM_OPT_CTXTID2 in perf config, this asks to trace VMID - * for recording CONTEXTIDR_EL2. Do not enable VMID tracing if the - * kernel is not running in EL2. + * If set bit contextid2 in perf config, this asks to trace VMID for + * recording CONTEXTIDR_EL2. Do not enable VMID tracing if the kernel + * is not running in EL2. */ - if (attr->config & BIT(ETM_OPT_CTXTID2)) { + if (ATTR_CFG_GET_FLD(attr, contextid2)) { if (!is_kernel_in_hyp_mode()) { ret =3D -EINVAL; goto out; @@ -831,26 +832,22 @@ static int etm4_parse_event_config(struct coresight_d= evice *csdev, } =20 /* return stack - enable if selected and supported */ - if ((attr->config & BIT(ETM_OPT_RETSTK)) && drvdata->retstack) + if (ATTR_CFG_GET_FLD(attr, retstack) && drvdata->retstack) /* bit[12], Return stack enable bit */ config->cfg |=3D TRCCONFIGR_RS; =20 /* - * Set any selected configuration and preset. - * - * This extracts the values of PMU_FORMAT_ATTR(configid) and PMU_FORMAT_A= TTR(preset) - * in the perf attributes defined in coresight-etm-perf.c. - * configid uses bits 63:32 of attr->config2, preset uses bits 3:0 of att= r->config. - * A zero configid means no configuration active, preset =3D 0 means no p= reset selected. + * Set any selected configuration and preset. A zero configid means no + * configuration active, preset =3D 0 means no preset selected. */ - if (attr->config2 & GENMASK_ULL(63, 32)) { - cfg_hash =3D (u32)(attr->config2 >> 32); - preset =3D attr->config & 0xF; + cfg_hash =3D ATTR_CFG_GET_FLD(attr, configid); + if (cfg_hash) { + preset =3D ATTR_CFG_GET_FLD(attr, preset); ret =3D cscfg_csdev_enable_active_config(csdev, cfg_hash, preset); } =20 /* branch broadcast - enable if selected and supported */ - if (attr->config & BIT(ETM_OPT_BRANCH_BROADCAST)) { + if (ATTR_CFG_GET_FLD(attr, branch_broadcast)) { if (!drvdata->trcbb) { /* * Missing BB support could cause silent decode errors @@ -859,7 +856,7 @@ static int etm4_parse_event_config(struct coresight_dev= ice *csdev, ret =3D -EINVAL; goto out; } else { - config->cfg |=3D BIT(ETM4_CFG_BIT_BB); + config->cfg |=3D TRCCONFIGR_BB; } } =20 @@ -1083,11 +1080,8 @@ static int etm4_disable_perf(struct coresight_device= *csdev, return -EINVAL; =20 etm4_disable_hw(drvdata); - /* - * The config_id occupies bits 63:32 of the config2 perf event attr - * field. If this is non-zero then we will have enabled a config. - */ - if (attr->config2 & GENMASK_ULL(63, 32)) + /* If configid is non-zero then we will have enabled a config. */ + if (ATTR_CFG_GET_FLD(attr, configid)) cscfg_csdev_disable_active_config(csdev); =20 /* --=20 2.34.1 From nobody Tue Dec 2 02:32:40 2025 Received: from mail-wm1-f46.google.com (mail-wm1-f46.google.com [209.85.128.46]) (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 154D53A5E8C for ; Tue, 18 Nov 2025 16:28:25 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=209.85.128.46 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1763483308; cv=none; b=QtMbHnrBjiPSeM0VPxGx33Le7VR/+JOBFVk+rO952j218rnl0/H1o+M7vkGrhltOdwrii0SfzbK1VYdVb215Bnyv7en7RExAZZ41A6Hbip5zNDJJ66QJfLH4GQGnQJCOFisCsi7o4GX4G4IwLc1xj7HplEEnNbnqAVAk+TOfzHs= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1763483308; c=relaxed/simple; bh=49yHZcfRU3JYbttPDuMZA+rvwSlgiEO1pFhN/mGFnMQ=; h=From:Date:Subject:MIME-Version:Content-Type:Message-Id:References: In-Reply-To:To:Cc; b=Wrjrf9JjHYLysPPvr3148kgoDEFLv3UoE99VJetvIimZ15Lg0qM+gDUxqd0D59Chw89kYh46ZtK5FaL4ZK8uFzMu3E3h566ZER7s4BB5Nd7EEX651vlbOKWyyZgpfZrNMu9teGXRj/GcVybAMlo2F776KjTIgjv8lQIVtHBZ5uc= 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=k5PdzVip; arc=none smtp.client-ip=209.85.128.46 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="k5PdzVip" Received: by mail-wm1-f46.google.com with SMTP id 5b1f17b1804b1-47775fb6c56so58286515e9.1 for ; Tue, 18 Nov 2025 08:28:25 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; t=1763483304; x=1764088104; darn=vger.kernel.org; h=cc:to:in-reply-to:references:message-id:content-transfer-encoding :mime-version:subject:date:from:from:to:cc:subject:date:message-id :reply-to; bh=d0ofk2DnhJ+xH+9yXlJaWK4ofE7g/nNzRBk1/VuwE+Y=; b=k5PdzVipAFg44lyrdgHJF2sM9KpOvLi4KIfkHWuF1MJjPEDMl2NX3QWjtkfRdE5aOO cj6w8zivpCZKIzS9aIVA+plYOTJNtv37YXnE3GfL2GdNgdDR2RMjC5EycXlirmz71K+r AFDZJPuQvuFS2lRU2LhKKjXvPiAP2Yasiwz+3QFAJkbCI+Nzb7cGTFWeevePyvJMPt0G DgIWC1SxRm473hxvs45lfUywtkdD0LKugnImT826SIiulbv8tzXxJx9WXD2RP0Gd/mfi 8jsQDV96YCxeV4EB80M6xMxG+3feZNRP1eTOjU3OU4xdDW4pzrNqQ4tt6uUVEwCnuJXS lttQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1763483304; x=1764088104; h=cc:to:in-reply-to:references:message-id:content-transfer-encoding :mime-version:subject:date:from:x-gm-gg:x-gm-message-state:from:to :cc:subject:date:message-id:reply-to; bh=d0ofk2DnhJ+xH+9yXlJaWK4ofE7g/nNzRBk1/VuwE+Y=; b=TxxMGKDQGrdUM5Ui0/dzsNJUORxO6kZc9IWH13/CXQrYqEJ9WBydujONyF3t3wfqBv puSarPws8EzTS+6Ub2j9/BxShdJuaVuMIkNTdbi3Vowy5fZx7TtX8/qbENVMmNz43UbJ ZCHtAvmPy5YpDDNi1y0pZCn1CcOt6wbl5fr8Mw6iTBmJqXoNwcDyeks5UUK6VDKcd9c9 AwlpDyyoa3gaf5Ud90wrAj+V/EvnMGbNQpSTPH0PzdgfmnJj3sT4msSSIbNFTHjoC01Z ZXuNAWhmz01eK0RzcykgoHFLM8JDDPBBpU297H72cKhfUNIRP9lw8fH6zVhYbiTUNnQh 2Cjw== X-Forwarded-Encrypted: i=1; AJvYcCWPa6QO2nke0sakMyuzhfn51FJCRoIBNGXs6+oh+LbvO0jhjoNjSwhZ5DkfbGC23pPyDuLXm98IATJBqgc=@vger.kernel.org X-Gm-Message-State: AOJu0Ywb+qSPLEBo3W9doMIKq1OoYsWVLF7N055zL88v2Afkd4Pl1fc6 JyQmqjYiguyE0A96ucVapIKLIHM5wqq9vEbVbLq9M/iIeplAFUeRE9ginTTKrMa8BJQ= X-Gm-Gg: ASbGncvOpXej/z/WmfAk7olnVSh82rs6m2zaL0K6BThQ9FnyYRTXhErrtCq3go9po+o o/WKPTFav18znIGywOwwn1NJ3489PWc3/frcAUnh9yCF5D4kxoIZ66UTGMwtZmhfkPR+YYmMYIE TkFQKKNS/8FgIVcKtG3kHpkI3ksISO1m6mjq4yYAQZyNOPnmoibR9MwcWUpgVbcG93uWbNeqp5B rBS2MzBOldiVGFXs98z4/D6e77i4A+jpiCf4BXnxVErYMz2Y7GDueZ6NXGe6pLSuuPYr0x0Z3G7 zLa/n7HVoS0eIX0R3AQGvbGwzrfzeOWb/mswZUSQk2GYH1KD8oX5ATDLm6joSqr4k/5QTD3dLLt zX8OloHKrkKQ3lYsyl5bHBUVPt+qfbviYfWm3ZE4VivJckNYpWYDfslFX9gV6MKJyKT6A49mxMg AphUCUbB8GtmLdHKvvR7jwSDjwloWej+abXKpazQNiPQ== X-Google-Smtp-Source: AGHT+IEOUUUOt7+haNfNY7f4WMr2XAw5LyRTouQ6puNuomap6F1bvehMt9KTpJ7UVZBkfF6l25TEgg== X-Received: by 2002:a05:600c:630d:b0:477:89d5:fdac with SMTP id 5b1f17b1804b1-4778fea1becmr184750085e9.31.1763483304287; Tue, 18 Nov 2025 08:28:24 -0800 (PST) Received: from ho-tower-lan.lan ([185.48.77.170]) by smtp.gmail.com with ESMTPSA id 5b1f17b1804b1-477a9dea7fcsm20369125e9.8.2025.11.18.08.28.23 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 18 Nov 2025 08:28:23 -0800 (PST) From: James Clark Date: Tue, 18 Nov 2025 16:28:00 +0000 Subject: [PATCH v5 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: <20251118-james-cs-syncfreq-v5-10-82efd7b1a751@linaro.org> References: <20251118-james-cs-syncfreq-v5-0-82efd7b1a751@linaro.org> In-Reply-To: <20251118-james-cs-syncfreq-v5-0-82efd7b1a751@linaro.org> To: Suzuki K Poulose , Mike Leach , Alexander Shishkin , Jonathan Corbet , Leo Yan , Randy Dunlap Cc: coresight@lists.linaro.org, linux-arm-kernel@lists.infradead.org, linux-kernel@vger.kernel.org, linux-doc@vger.kernel.org, James Clark X-Mailer: b4 0.14.0 ETM_OPT_* definitions duplicate the PMU format attributes that have always been published in sysfs. Hardcoding them here makes it misleading as to what the 'real' PMU API is and prevents attributes from being rearranged in the future. ETM4_CFG_BIT_* definitions just define what the Arm Architecture is which is not the responsibility of the kernel to do and doesn't scale to other registers or versions of ETM. It's not an actual software ABI/API and these definitions here mislead that it is. Any tools using the first ones would be broken anyway as they won't work when attributes are moved, so removing them is the right thing to do and will prompt a fix. Tools using the second ones can trivially redefine them locally. Perf also has its own copy of the headers so both of these things can be fixed up at a later date. Reviewed-by: Leo Yan Signed-off-by: James Clark Reviewed-by: Mike Leach --- include/linux/coresight-pmu.h | 24 ------------------------ 1 file changed, 24 deletions(-) diff --git a/include/linux/coresight-pmu.h b/include/linux/coresight-pmu.h index 89b0ac0014b0..2e179abe472a 100644 --- a/include/linux/coresight-pmu.h +++ b/include/linux/coresight-pmu.h @@ -21,30 +21,6 @@ */ #define CORESIGHT_LEGACY_CPU_TRACE_ID(cpu) (0x10 + (cpu * 2)) =20 -/* - * Below are the definition of bit offsets for perf option, and works as - * arbitrary values for all ETM versions. - * - * Most of them are orignally from ETMv3.5/PTM's ETMCR config, therefore, - * ETMv3.5/PTM doesn't define ETMCR config bits with prefix "ETM3_" and - * directly use below macros as config bits. - */ -#define ETM_OPT_BRANCH_BROADCAST 8 -#define ETM_OPT_CYCACC 12 -#define ETM_OPT_CTXTID 14 -#define ETM_OPT_CTXTID2 15 -#define ETM_OPT_TS 28 -#define ETM_OPT_RETSTK 29 - -/* ETMv4 CONFIGR programming bits for the ETM OPTs */ -#define ETM4_CFG_BIT_BB 3 -#define ETM4_CFG_BIT_CYCACC 4 -#define ETM4_CFG_BIT_CTXTID 6 -#define ETM4_CFG_BIT_VMID 7 -#define ETM4_CFG_BIT_TS 11 -#define ETM4_CFG_BIT_RETSTK 12 -#define ETM4_CFG_BIT_VMID_OPT 15 - /* * Interpretation of the PERF_RECORD_AUX_OUTPUT_HW_ID payload. * Used to associate a CPU with the CoreSight Trace ID. --=20 2.34.1 From nobody Tue Dec 2 02:32:40 2025 Received: from mail-wm1-f48.google.com (mail-wm1-f48.google.com [209.85.128.48]) (using TLSv1.2 with cipher ECDHE-RSA-AES128-GCM-SHA256 (128/128 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 0CD703A79A9 for ; Tue, 18 Nov 2025 16:28:26 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=209.85.128.48 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1763483309; cv=none; b=WaGKWIie7hbvTfyyRhVwmvVRVmNOveBoJYlOYMdAkl4xiSqXG2QShDa8l3a8PQuICDuBP3POXDWBVJDNY8WnyH48bOeTcWsQfJzGrDOOm6kEg8njZ4UX0CFqQPbbJDaYy4LlpIy2tXs5Y3ZEhKOeofFT9tplsyuKAE5c5ZMt7SU= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1763483309; c=relaxed/simple; bh=NNFr/LjPuIJwgQLBqv1tSqAvrhacpNfmsSLLmV7jXvU=; h=From:Date:Subject:MIME-Version:Content-Type:Message-Id:References: In-Reply-To:To:Cc; b=ddJF5pVMP8XU2f3Bv3cyneJEfdaSEG84LdzHv7a91peoE0WKqDSmccJ6OzabDzZnmzScuUDkBc/J5r9M4ktwzzhqb1r9tUYa949c1r159+f4zAyKmvaRnO3yTTJwB4KVPlZ6fy2naIv/LuRLPer5UzaHuG3+JRlqnFB4XXZJxco= 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=xFafDVQ1; arc=none smtp.client-ip=209.85.128.48 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=linaro.org Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=linaro.org Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=linaro.org header.i=@linaro.org header.b="xFafDVQ1" Received: by mail-wm1-f48.google.com with SMTP id 5b1f17b1804b1-47775fb6cb4so41175195e9.0 for ; Tue, 18 Nov 2025 08:28:26 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; t=1763483305; x=1764088105; darn=vger.kernel.org; h=cc:to:in-reply-to:references:message-id:content-transfer-encoding :mime-version:subject:date:from:from:to:cc:subject:date:message-id :reply-to; bh=eb0nZRqG3wPO7nucW1Po+d3Kj8IK/8D9zMABw4V5b10=; b=xFafDVQ1WWP4RnnFOpVxfZ0xTh3y6fO4nE/G0lPULSMngkFH4JExauXJ+qnd89TgGo FN1PzBcJoD3Uux8YxFCz+LnHZascbjJQNeeIDEbhiF/83Mgiky+3Ef3//DbRr6GSsCKs MVUKdBp+6zAyHtRubnqPIuULayr/kW2LOAF6OgWBrsID4aNjB3tCuyuYEIbUD91hDG8k kUBkFjqtnHIWAXyKR/0CeeNvHzr/urZyrHbk6vSXnjPDocSxcUmAISJR2H3OTuwdqDx0 wozQg24wYHOXam+O76EukDSkYW9AnELQBNsKL0O9Gfgnbr8lWCp2eDTjv9Jok6oJnE3p Hu8Q== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1763483305; x=1764088105; h=cc:to:in-reply-to:references:message-id:content-transfer-encoding :mime-version:subject:date:from:x-gm-gg:x-gm-message-state:from:to :cc:subject:date:message-id:reply-to; bh=eb0nZRqG3wPO7nucW1Po+d3Kj8IK/8D9zMABw4V5b10=; b=Kk2Um9ZIf1/qWGAci2fteE4g6He5Y58ZMjYUZbsJNsR0dx6dX5tobmVjGOrqKTZenD w6cwV65gfYs+1CQGWchVp4EtGmO7bpL5m508G1buK/rK0HMqUef5lL3oy6nrougDblpQ j07pQrcNw9nYGTGHkYWNJAmOHraOvtZxbEGpHdab1uWMk6toKrRVNCNffSnimQoOXDeJ BHcrEEvC9zekVvdfdLiqNSEyhQFmbN68IZdJ3122aWp014nsooj0RxYRJGLqZYn21w0U 0ShuDWrlOuAlKkf2ITZJNAMFl43gnxHaBgRS5yS/OJd0JdfAyDTLUO2R9MZJagulO3y4 KjPA== X-Forwarded-Encrypted: i=1; AJvYcCUfkCDV7V9FN/75mOLMQVPi3gKWsl0Q8h3L3xBq/QjUfAIMsCHDF9EnV9Dsh4OeeawmOA8AaRWWfVg8jCQ=@vger.kernel.org X-Gm-Message-State: AOJu0Ywj+EOfhsD6uooIj4Wum4NX6sL6Oldqp8Jchu5vvRKSW/Bq9+9f oRU6mSq/w3MmVSfPAr7/GMS/0rg4pE1MpqKiJiPVsRDiFzgYG0HYmPogziYi6JPkqoM= X-Gm-Gg: ASbGncun+szvE61EaC49jUWSvXhWRBRtEprU0qAt0CIULQOTIiw2A2Xku/0LbrDd1Nj jw/caBk/WNqxAzhTCueYq1zG/bzXyUXgA0Qxe4kq3v8giTck/qKW5wfifC93YnLONUA+7zpVIhR zanUf0d3hVCGj6491femc72H3FOYiiUphDtnT+e4Avdo3WeH30W1J153mFBFLEthPF7RuhwANaU x+605yFfKMFaKypVlNDsqUlq1iOHjxvxXaFL389ffma0mM74KT+G9kMGYOaJyqHwvw3e2DsSGjB 8MbV9gInUqOCiRjfzG+Yqyys4UHFds2RTngFvyW8ZKvvR+bkVw9cIqSHjL0LYVlSIaCkXh4IFcJ rMB7m2IMSjM/6Mzvmk4nOZzfxOKS7SRS1oaH6Sj35LEWb5Ej1rRIJ5BMHw11NsQSeW0COq8rglb bv0/hcIhnYLDnAgqIdLeNc04bxALDl4CkRnqfFryPH8A== X-Google-Smtp-Source: AGHT+IEgxjocht+zd5sgZk9UgQUOz1bPvElgaDdpvXL42GO6HQTKk5jhNzNQ67G2WTvucSd0gdRSKg== X-Received: by 2002:a05:600c:8b5b:b0:477:7768:8da4 with SMTP id 5b1f17b1804b1-4778fe59f99mr148261815e9.7.1763483305277; Tue, 18 Nov 2025 08:28:25 -0800 (PST) Received: from ho-tower-lan.lan ([185.48.77.170]) by smtp.gmail.com with ESMTPSA id 5b1f17b1804b1-477a9dea7fcsm20369125e9.8.2025.11.18.08.28.24 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 18 Nov 2025 08:28:24 -0800 (PST) From: James Clark Date: Tue, 18 Nov 2025 16:28:01 +0000 Subject: [PATCH v5 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: <20251118-james-cs-syncfreq-v5-11-82efd7b1a751@linaro.org> References: <20251118-james-cs-syncfreq-v5-0-82efd7b1a751@linaro.org> In-Reply-To: <20251118-james-cs-syncfreq-v5-0-82efd7b1a751@linaro.org> To: Suzuki K Poulose , Mike Leach , Alexander Shishkin , Jonathan Corbet , Leo Yan , Randy Dunlap Cc: coresight@lists.linaro.org, linux-arm-kernel@lists.infradead.org, linux-kernel@vger.kernel.org, linux-doc@vger.kernel.org, James Clark X-Mailer: b4 0.14.0 'timestamp' is currently 1 bit wide for on/off. To enable setting different intervals in a later commit, extend it to 4 bits wide. Keep the old bit position for backward compatibility but don't publish in the format/ folder. It will be removed from the documentation and can be removed completely after enough time has passed. ETM3x doesn't support different intervals, so validate that the value is either 0 or 1. Tools that read the bit positions from the format/ folder will continue to work as before, setting either 0 or 1 for off/on. Tools that incorrectly didn't do this and set the ETM_OPT_TS bit directly will also continue to work because that old bit is still checked. This avoids adding a second timestamp attribute for setting the interval. This would be awkward to use because tools would have to be updated to ensure that the timestamps are always enabled when an interval is set, and the driver would have to validate that both options are provided together. All this does is implement the semantics of a single enum but spread over multiple fields. Reviewed-by: Leo Yan Signed-off-by: James Clark --- drivers/hwtracing/coresight/coresight-etm-perf.h | 13 ++++++++++--- drivers/hwtracing/coresight/coresight-etm3x-core.c | 9 ++++++++- drivers/hwtracing/coresight/coresight-etm4x-core.c | 4 +++- 3 files changed, 21 insertions(+), 5 deletions(-) diff --git a/drivers/hwtracing/coresight/coresight-etm-perf.h b/drivers/hwt= racing/coresight/coresight-etm-perf.h index c794087a0e99..24d929428633 100644 --- a/drivers/hwtracing/coresight/coresight-etm-perf.h +++ b/drivers/hwtracing/coresight/coresight-etm-perf.h @@ -23,6 +23,9 @@ struct cscfg_config_desc; #define ATTR_CFG_FLD_preset_CFG config #define ATTR_CFG_FLD_preset_LO 0 #define ATTR_CFG_FLD_preset_HI 3 +#define ATTR_CFG_FLD_timestamp_CFG config +#define ATTR_CFG_FLD_timestamp_LO 4 +#define ATTR_CFG_FLD_timestamp_HI 7 #define ATTR_CFG_FLD_branch_broadcast_CFG config #define ATTR_CFG_FLD_branch_broadcast_LO 8 #define ATTR_CFG_FLD_branch_broadcast_HI 8 @@ -35,9 +38,13 @@ struct cscfg_config_desc; #define ATTR_CFG_FLD_contextid2_CFG config #define ATTR_CFG_FLD_contextid2_LO 15 #define ATTR_CFG_FLD_contextid2_HI 15 -#define ATTR_CFG_FLD_timestamp_CFG config -#define ATTR_CFG_FLD_timestamp_LO 28 -#define ATTR_CFG_FLD_timestamp_HI 28 +/* + * Old position of 'timestamp' and not published in sysfs. Remove at a lat= er + * date if necessary. + */ +#define ATTR_CFG_FLD_deprecated_timestamp_CFG config +#define ATTR_CFG_FLD_deprecated_timestamp_LO 28 +#define ATTR_CFG_FLD_deprecated_timestamp_HI 28 #define ATTR_CFG_FLD_retstack_CFG config #define ATTR_CFG_FLD_retstack_LO 29 #define ATTR_CFG_FLD_retstack_HI 29 diff --git a/drivers/hwtracing/coresight/coresight-etm3x-core.c b/drivers/h= wtracing/coresight/coresight-etm3x-core.c index 584d653eda81..d4c04e563bf6 100644 --- a/drivers/hwtracing/coresight/coresight-etm3x-core.c +++ b/drivers/hwtracing/coresight/coresight-etm3x-core.c @@ -338,9 +338,16 @@ static int etm_parse_event_config(struct etm_drvdata *= drvdata, if (ATTR_CFG_GET_FLD(attr, cycacc)) config->ctrl |=3D ETMCR_CYC_ACC; =20 - if (ATTR_CFG_GET_FLD(attr, timestamp)) + if (ATTR_CFG_GET_FLD(attr, deprecated_timestamp) || + ATTR_CFG_GET_FLD(attr, timestamp)) config->ctrl |=3D ETMCR_TIMESTAMP_EN; =20 + if (ATTR_CFG_GET_FLD(attr, timestamp) > 1) { + dev_dbg(&drvdata->csdev->dev, + "timestamp format attribute should be 0 (off) or 1 (on)\n"); + return -EINVAL; + } + /* * Possible to have cores with PTM (supports ret stack) and ETM (never * has ret stack) on the same SoC. So only enable when it can be honored diff --git a/drivers/hwtracing/coresight/coresight-etm4x-core.c b/drivers/h= wtracing/coresight/coresight-etm4x-core.c index c7208ffc9432..cfd6d2b7bc50 100644 --- a/drivers/hwtracing/coresight/coresight-etm4x-core.c +++ b/drivers/hwtracing/coresight/coresight-etm4x-core.c @@ -28,6 +28,7 @@ #include #include #include +#include #include #include #include @@ -791,7 +792,8 @@ static int etm4_parse_event_config(struct coresight_dev= ice *csdev, cc_threshold =3D drvdata->ccitmin; config->ccctlr =3D cc_threshold; } - if (ATTR_CFG_GET_FLD(attr, timestamp)) { + if (ATTR_CFG_GET_FLD(attr, deprecated_timestamp) || + ATTR_CFG_GET_FLD(attr, timestamp)) { /* * Configure timestamps to be emitted at regular intervals in * order to correlate instructions executed on different CPUs --=20 2.34.1 From nobody Tue Dec 2 02:32:40 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 05BF03A79C0 for ; Tue, 18 Nov 2025 16:28:27 +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=1763483311; cv=none; b=jGWb0dDE0AhGivp7FHrHpwPMZpsXCWYK9dqDzfg3g4S6eOT0cn0lTewPDSJPiUfzOYqKZpZIzkIG/dWlh4Xhaq3NaQUgTNnxOcGT69hInAKfBrIJPlX4//TzRrqB7JlRa+4VwSPoVOePF8nljQBO2N6w3vWZJVmngn1cBEE0z9k= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1763483311; c=relaxed/simple; bh=NnmS95dIHybC4skUiX6A9lTrG4BjKAs84lg0zH2yXbs=; h=From:Date:Subject:MIME-Version:Content-Type:Message-Id:References: In-Reply-To:To:Cc; b=BMXpohs86VlWFI80SC1FZHGxFmQivF+vV/4ZSEOKz5EF7j9zcpBn6W4KIQCFqq+l4aXHkecLWqjBkKXiMdLxgTLNNOxJoK/JufupuEyh3b9r/9T6ugGfm9rSZDg+Bb3NRNOK78PzTdEWMKvIb68I14xIKV59xjo7ob0W9COWE+4= 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=MxUlGS6m; 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="MxUlGS6m" Received: by mail-wm1-f51.google.com with SMTP id 5b1f17b1804b1-4779adb38d3so26953215e9.2 for ; Tue, 18 Nov 2025 08:28:27 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; t=1763483306; x=1764088106; darn=vger.kernel.org; h=cc:to:in-reply-to:references:message-id:content-transfer-encoding :mime-version:subject:date:from:from:to:cc:subject:date:message-id :reply-to; bh=1J9cD8iib5vPgkzAOKKPeHwOoJIQqK3mSiazT8xg6Hc=; b=MxUlGS6mE16keqPdDSxl4+RyyAcKga4zCXeA6FpCcj7cLJ0F+mGZyGQnD5kJsFwKOD msTtkmdlBx4bdR3ytCJP0aogD9nvXomL+YPOU+11qwUgbPcJqFiA1rK+oB9yevSmhuW2 5bgrhmNiDQB0WqSZRhmrg9MGcNM5MhXPtqCEZB2PSKSq6pmfzfUVtJyFQLEppzOOO+3o sPSl/x0hPiHDGarWAaW7XkkLvrzq7IPQVt10J+bHi6JHQfJCnMBLl5w4A1BXJxfAFStK eVlmviCC3diLELUPrFHVMrZirIhObL42/z2dCe8ZnHhpt/mKRnsAfZ4xPkMxN6zLGgjD rs4Q== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1763483306; x=1764088106; h=cc:to:in-reply-to:references:message-id:content-transfer-encoding :mime-version:subject:date:from:x-gm-gg:x-gm-message-state:from:to :cc:subject:date:message-id:reply-to; bh=1J9cD8iib5vPgkzAOKKPeHwOoJIQqK3mSiazT8xg6Hc=; b=bWxoasg/KHCf2hQx/sOtRQVq2Iw6dsvSnG/HfQrOGaQ5lXzWpG6tkAYlIIGt5xbyba ZZtpl3tpra/K7lUJLlCXZF6QlMXaOc7GcVuteR/o2GlQuFbaaH686adj2YeeEhjHix+5 XlpwVltq5usXrssu6IlS+UEKbH6KrS+S20HEEOd1hr0fVz/GE8RBz9d7/mKi8vvuWtZp yeQ6KhrHbrtBin5Yc+Rc+4O2Q/95TD5QAA9Qm2P6EgjPuiY8yOT2giK+SE5KWGIhXOoZ DpzmPlNT3lmwzf10S7Es2eB7CEiT6ErOkkbOx0NBfLHNenUJl88qD/bdSH4KabhcEV5l SZ8w== X-Forwarded-Encrypted: i=1; AJvYcCWuDNnN4drxJ1H10Q8/q1SQ1cD8568V5NS/usOnhFLAzRoOIveirtLnwSsErZPQ+k+3oX2EvV/H6zJHNis=@vger.kernel.org X-Gm-Message-State: AOJu0YyZT/3ITCX9ta03W3D0+ROURr+/YY6f/p17S5up2kYNwjsRFIRN qLl45a4ugtWjE/ZcUwdNte5KJqUHfmZFGKrEFynlIK9p2AIQ8spu22zzNQt7GXlVzP8= X-Gm-Gg: ASbGncsJylyg1eud+QQuQUso96++iC8ZHkyAF00jcZUZqGHJIxYLR3s67X5HNWiGqbX volHcfEJlRfmcvjrMZPpIdEx8WG3+XaEd9wy0kiG6Fk1sYPW4yHlccvhXkDoRoDiZ4qHcJceLl2 T295uQ3c67MAZo7uz1W4f+OHeuQsWjDlzP3+cT+SHfuGGydfiF8gpHySiO65dUNQlEg7+N7uV12 QTL23JIspdF43oQxDMO0sLNaEfWgRUQMTEaSs0ngnq3r6d6NQA2KzYAZA2r2YzLbk9CmYVBd+s3 BLqdn69G8dpufRcS1orUwlQcLaCFZcCkUystiOd3h75Ciwb8334v0hY8mq4rmKaH7TgFGkUz+VD HkJRjh4JUNYwv6PZPefpVmBENczZcZ5QEff1j+Mylvdf9snR9Vb7uC1U7BDb2l2e1pQOQzal4A+ j3yEO7EUmdcBVWho/VLwBD5ktINrmLGLk= X-Google-Smtp-Source: AGHT+IEIHAY0ieYvrIgM/ktEZhU04EJXyQVK6L5dD7sCe4rwbzMBqRPJwRy/+JJXUFQoMVJ2eeuntA== X-Received: by 2002:a05:600c:3b19:b0:46e:4246:c90d with SMTP id 5b1f17b1804b1-4778fe68378mr157000715e9.11.1763483306313; Tue, 18 Nov 2025 08:28:26 -0800 (PST) Received: from ho-tower-lan.lan ([185.48.77.170]) by smtp.gmail.com with ESMTPSA id 5b1f17b1804b1-477a9dea7fcsm20369125e9.8.2025.11.18.08.28.25 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 18 Nov 2025 08:28:25 -0800 (PST) From: James Clark Date: Tue, 18 Nov 2025 16:28:02 +0000 Subject: [PATCH v5 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: <20251118-james-cs-syncfreq-v5-12-82efd7b1a751@linaro.org> References: <20251118-james-cs-syncfreq-v5-0-82efd7b1a751@linaro.org> In-Reply-To: <20251118-james-cs-syncfreq-v5-0-82efd7b1a751@linaro.org> To: Suzuki K Poulose , Mike Leach , Alexander Shishkin , Jonathan Corbet , Leo Yan , Randy Dunlap Cc: coresight@lists.linaro.org, linux-arm-kernel@lists.infradead.org, linux-kernel@vger.kernel.org, linux-doc@vger.kernel.org, James Clark X-Mailer: b4 0.14.0 Timestamps are currently emitted at the maximum rate possible, which is much too frequent for most use cases. Set the interval using the value from the timestamp field. Granular control is not required, so save space in the config by interpreting it as 2 ^ timestamp. And then 4 bits (0 - 15) is enough to set the interval to be larger than the existing SYNC timestamp interval. No sysfs mode support is needed for this attribute because counter generated timestamps are only configured for Perf mode. Reviewed-by: Leo Yan Tested-by: Leo Yan Signed-off-by: James Clark --- drivers/hwtracing/coresight/coresight-etm-perf.h | 1 + drivers/hwtracing/coresight/coresight-etm4x-core.c | 28 +++++++++++++++---= ---- 2 files changed, 20 insertions(+), 9 deletions(-) diff --git a/drivers/hwtracing/coresight/coresight-etm-perf.h b/drivers/hwt= racing/coresight/coresight-etm-perf.h index 24d929428633..128f80bb1443 100644 --- a/drivers/hwtracing/coresight/coresight-etm-perf.h +++ b/drivers/hwtracing/coresight/coresight-etm-perf.h @@ -7,6 +7,7 @@ #ifndef _CORESIGHT_ETM_PERF_H #define _CORESIGHT_ETM_PERF_H =20 +#include #include #include "coresight-priv.h" =20 diff --git a/drivers/hwtracing/coresight/coresight-etm4x-core.c b/drivers/h= wtracing/coresight/coresight-etm4x-core.c index cfd6d2b7bc50..a91981a651e7 100644 --- a/drivers/hwtracing/coresight/coresight-etm4x-core.c +++ b/drivers/hwtracing/coresight/coresight-etm4x-core.c @@ -651,7 +651,7 @@ static void etm4_enable_sysfs_smp_call(void *info) * +--------------+ * | * +------v-------+ - * | Counter x | (reload to 1 on underflow) + * | Counter x | (reload to 2 ^ timestamp on underflow) * +--------------+ * | * +------v--------------+ @@ -662,11 +662,25 @@ static void etm4_enable_sysfs_smp_call(void *info) * | Timestamp Generator | (timestamp on resource y) * +----------------------+ */ -static int etm4_config_timestamp_event(struct etmv4_drvdata *drvdata) +static int etm4_config_timestamp_event(struct etmv4_drvdata *drvdata, + struct perf_event_attr *attr) { int ctridx; int rselector; struct etmv4_config *config =3D &drvdata->config; + struct perf_event_attr max_timestamp =3D { + .ATTR_CFG_FLD_timestamp_CFG =3D U64_MAX, + }; + + /* timestamp may be 0 if deprecated_timestamp is used, so make min 1 */ + u8 ts_level =3D max(1, ATTR_CFG_GET_FLD(attr, timestamp)); + + /* + * Disable counter generated timestamps when timestamp =3D=3D MAX. Leave + * only SYNC timestamps. + */ + if (ts_level =3D=3D ATTR_CFG_GET_FLD(&max_timestamp, timestamp)) + return 0; =20 /* No point in trying if we don't have at least one counter */ if (!drvdata->nr_cntr) @@ -704,12 +718,8 @@ static int etm4_config_timestamp_event(struct etmv4_dr= vdata *drvdata) return -ENOSPC; } =20 - /* - * Initialise original and reload counter value to the smallest - * possible value in order to get as much precision as we can. - */ - config->cntr_val[ctridx] =3D 1; - config->cntrldvr[ctridx] =3D 1; + /* Initialise original and reload counter value. */ + config->cntr_val[ctridx] =3D config->cntrldvr[ctridx] =3D 1 << (ts_level = - 1); =20 /* * Trace Counter Control Register TRCCNTCTLRn @@ -799,7 +809,7 @@ static int etm4_parse_event_config(struct coresight_dev= ice *csdev, * order to correlate instructions executed on different CPUs * (CPU-wide trace scenarios). */ - ret =3D etm4_config_timestamp_event(drvdata); + ret =3D etm4_config_timestamp_event(drvdata, attr); =20 /* * No need to go further if timestamp intervals can't --=20 2.34.1 From nobody Tue Dec 2 02:32:40 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 0AEC03A79B2 for ; Tue, 18 Nov 2025 16:28:28 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=209.85.128.54 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1763483311; cv=none; b=BlHjgFrHPV4MO7xxWD9SrbudXXWf81IqvbhVgLvRTQInnbv0ymlSq9qv+l8M2nR8Xda3Q7seUDbtej3wKBEeYRCFztDqOaIWm9EpwlfID3NB3lfrP2cVoTKw8i+qIFa3CvlFQgU9cOxkFscXtg40LMxusZ+HsF1FudJ/Cxz5W5I= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1763483311; c=relaxed/simple; bh=2gYGham6RcUhZnNfLTEyX5K2IIqX9Oa8+TtMYKSDzf0=; h=From:Date:Subject:MIME-Version:Content-Type:Message-Id:References: In-Reply-To:To:Cc; b=YJ8XNvTaKczFwVnLBe8WpXeTnxw/FMWWmy9ytB8jxgg7hdfv4hSxt78oB0H/SwYAS4myoSzn60dxPj6FcV9y6B7avBExd8VV1CvPuw3gur3MHAPrvcYBDKPdz2L4LAQKCgALUUKNm8x+F/Zcjlhg0DK4/6fZYH+4lZdy55vLwtk= 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=i2ein0+h; 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="i2ein0+h" Received: by mail-wm1-f54.google.com with SMTP id 5b1f17b1804b1-4775e891b5eso30200895e9.2 for ; Tue, 18 Nov 2025 08:28:28 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; t=1763483307; x=1764088107; 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=i2ein0+hZTZXaud6ghJKswJyyXXLG8tDT7pYqcb8Ypu5pVElLd2dQlyYPSbRMfTedY oD075VEoOixQTExva13woMElboCRkZdPmhEjFAKe792L9gbFlG+1TkROJLQmwOlkXWSP RIzmGdNe11Ygp6pZOWAiuQHB7pZTitARt5I34iNwiBDEsVc1RbxS8MVHKuM9xelIrw9O 8Iz3a20CqSaPDN8ziSC6FfElfPOTETVpLiC625W7sRoJnw3GA0uN98Hxb9HsfWQN1JGD 5ZGM+J5N0zL1b1eu1VA5cXYpHrVWMeRjEiJo6ZEGkCMvgbODx55wyAMTOnRGJgizuKVU Ob0w== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1763483307; x=1764088107; 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=qgXxg8G6CYXqdGgHBA+husNfF29Mz1JBdSnmTP+nCzeD4tglmxf6oZ7Wjhn77Gv4E/ NcSRQsv+mMEJ4DqH3yIXtHScoKoGoxHB0Mf3E+CfysdrCShFAlv/4CKrMfUWxlMYq7WU PqPpKHI64pAv9uKQGqEbRz5bq9RLI9nHoY5ynoY+IW9rHKZZ6NI80DPjrwIz924wbMk6 z97Vo9fvj4sZwfROvcKKAx7vWtnUSwO1C+ezlI2IDrlp56CKnXuuTDGQLueOUAkKr5Ch aK/8n98eKGHqNdF1fTPLs2Ljr/3YVqgmDY52QkKXLBsMBQ5U1DMJJ9/7hbPL/bNhuWZR yDiA== X-Forwarded-Encrypted: i=1; AJvYcCXkUXhf8LZbMCjhcAK15frBwTIxXsmiL5lTlMoeI3tunIYIWqjgFCm4jqXVqhiLrVhuPoPerPmwyEspCb0=@vger.kernel.org X-Gm-Message-State: AOJu0Yyr0+RnwWiL/NDJ0DJCGbBoucn5W1Rq0XUK7dHzpDTuzykOTCXw S22sR1fhgYCsKcYRXKBg3cJnjIeuMY/w4D16Wv5e0IO30jm/YfFTUBMuK1PbaZVW0S4= X-Gm-Gg: ASbGncsssEN9sqckxd3SJ3x4oeLF4HyxsKYCKlZnQLliCd4bxrWQHeIms0O60tw8mak HY3DM0Kw3/TeNDOEEOeM7nOy3GjsqK4+mzEQ2iEFa3Wa+0qgjvQFRrT5w9OIjA365IGdHpdGk/u DO7QNyOEjoPRAjiYuaxe9QsMP5RDIY4PMNJ1wQznn0zD6+XrARwQGQuwzan1On4Xv/W1oZApo8C 3DD2ddu7OC19dpR2EkJypdZ3+sGARZ8SczVP6xj08K0zCuVvd32ZWg3hvNskVq6EPtrrx9T6Mfq 5z+3/8nIMcFsAoV8VVRDqn/I0SXsPlUgF2VVHGm5iQHn+nzFP8F0xuTFHR+Hcon3PNfUHKoExPP VzgdR1/bNcjc9HwRrrjOJlqs4m6ucwCkYjn5xyn3xU4UCTTt2z9wYUBZ15oGMusmuC6yRJ0t6TL Q/ljdOTa9iuK+cOO5IqI/I3SBnQ+WKknM= X-Google-Smtp-Source: AGHT+IHN5ZZ7TsSfy3KB6ZJXobAnrt1PfBhAPwW1cYqyewtyOySvk+eWd5Ld3sR20w2QmFj0p3m0Xw== X-Received: by 2002:a05:600c:1c9b:b0:477:9fa0:74ed with SMTP id 5b1f17b1804b1-4779fa07915mr98104425e9.26.1763483307312; Tue, 18 Nov 2025 08:28:27 -0800 (PST) Received: from ho-tower-lan.lan ([185.48.77.170]) by smtp.gmail.com with ESMTPSA id 5b1f17b1804b1-477a9dea7fcsm20369125e9.8.2025.11.18.08.28.26 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 18 Nov 2025 08:28:26 -0800 (PST) From: James Clark Date: Tue, 18 Nov 2025 16:28:03 +0000 Subject: [PATCH v5 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: <20251118-james-cs-syncfreq-v5-13-82efd7b1a751@linaro.org> References: <20251118-james-cs-syncfreq-v5-0-82efd7b1a751@linaro.org> In-Reply-To: <20251118-james-cs-syncfreq-v5-0-82efd7b1a751@linaro.org> To: Suzuki K Poulose , Mike Leach , Alexander Shishkin , Jonathan Corbet , Leo Yan , Randy Dunlap Cc: coresight@lists.linaro.org, linux-arm-kernel@lists.infradead.org, linux-kernel@vger.kernel.org, linux-doc@vger.kernel.org, James Clark X-Mailer: b4 0.14.0 Document how the new field is used, maximum value and the interaction with SYNC timestamps. Signed-off-by: James Clark --- Documentation/trace/coresight/coresight.rst | 16 ++++++++++++++-- 1 file changed, 14 insertions(+), 2 deletions(-) diff --git a/Documentation/trace/coresight/coresight.rst b/Documentation/tr= ace/coresight/coresight.rst index 806699871b80..d461de4e067e 100644 --- a/Documentation/trace/coresight/coresight.rst +++ b/Documentation/trace/coresight/coresight.rst @@ -613,8 +613,20 @@ They are also listed in the folder /sys/bus/event_sour= ce/devices/cs_etm/format/ - Session local version of the system wide setting: :ref:`ETM_MODE_RE= TURNSTACK ` * - timestamp - - Session local version of the system wide setting: :ref:`ETMv4_MODE_= TIMESTAMP - ` + - Controls generation and interval of timestamps. + + 0 =3D off, 1 =3D minimum interval .. 15 =3D maximum interval. + + Values 1 - 14 use a counter that decrements every cycle to generate= a + timestamp on underflow. The reload value for the counter is 2 ^ (in= terval + - 1). If the value is 1 then the reload value is 1, if the value is= 11 + then the reload value is 1024 etc. + + Setting the maximum interval (15) will disable the counter generated + timestamps, freeing the counter resource, leaving only ones emitted= when + a SYNC packet is generated. The sync interval is controlled with + TRCSYNCPR.PERIOD which is every 4096 bytes of trace by default. + * - cc_threshold - Cycle count threshold value. If nothing is provided here or the pro= vided value is 0, then the default value i.e 0x100 will be used. If provided value is less tha= n minimum cycles threshold --=20 2.34.1