From nobody Tue Dec 2 02:29:11 2025 Received: from mail-wm1-f48.google.com (mail-wm1-f48.google.com [209.85.128.48]) (using TLSv1.2 with cipher ECDHE-RSA-AES128-GCM-SHA256 (128/128 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 23124366DC4 for ; Wed, 19 Nov 2025 16:18:29 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=209.85.128.48 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1763569111; cv=none; b=H31RWmc6O373qtcyWJvlOsC52Tzp03Pd9m7CIiR2tJQ3JA2bH4H1bjNgYDYfw3fKZ7FEvVb8MIF8agSnIuVfjvSVFarxwB+Q0AAekueVcobDST9DhsFYcgRiJus69Yjn3yS9p6X6B8YZjhnWhU7wZ7Owl3ouhPGsXlAQCOa531U= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1763569111; c=relaxed/simple; bh=S1lAdaCJ1lnshqz4avnLOeP/pLK/1ucm2BsQAjK8ZFc=; h=From:Date:Subject:MIME-Version:Content-Type:Message-Id:References: In-Reply-To:To:Cc; b=I77k/EEPT1ATzJ2ykK7SnYIb1C8kZRCDhjx4VxN6+bPVy/nl6+mco8E2Pf/ULklFjcl1BI5qcj3T/ZTwAuplYeghl6Bhm295dFjHtNKqw2fL/LDjRjLcXuwlOfGj2WghxetmrZ5h45O68SpQOuzNSMS0GqbV3IkBDEKkGwXHjEM= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=linaro.org; spf=pass smtp.mailfrom=linaro.org; dkim=pass (2048-bit key) header.d=linaro.org header.i=@linaro.org header.b=x/qbdPpH; arc=none smtp.client-ip=209.85.128.48 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=linaro.org Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=linaro.org Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=linaro.org header.i=@linaro.org header.b="x/qbdPpH" Received: by mail-wm1-f48.google.com with SMTP id 5b1f17b1804b1-4779a4fc95aso7885155e9.1 for ; Wed, 19 Nov 2025 08:18:29 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; t=1763569108; x=1764173908; darn=vger.kernel.org; h=cc:to:in-reply-to:references:message-id:content-transfer-encoding :mime-version:subject:date:from:from:to:cc:subject:date:message-id :reply-to; bh=iqeQCDNzyERvoI4uJsKzrMugXzNJjWTyKx7GIItRI68=; b=x/qbdPpHoX1XMqCGJWmi+/2qZBgeSTwoEag6/isI+JTjYJS5HtJ+1GHxp4AHd8NY47 oye8IMaxjvWPsBpUG9OpzTAEWtgTI06h2zrpMYvbOd1b8MXo4SwwKwrcCoSMDDASFRfk MKUnSc0Oy7OcDWP0Hf3GApwgzuFi3AZBCeufnoARGbrdM6xGopsZvRQv34mL7UHLMcRd v6fqYB2uOTMBlAW1oIqZBY/hSSB+jNIWrSmc8Q7lgdcE4vNGsWZPISZdX2S12bg5XOX+ U3Y7KQcVohbSdGoEU5Hx0paobMh0apYkYFtH9cB2zpZAzNUAlK745DiyqVJhvbCOvLJe 3lmw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1763569108; x=1764173908; h=cc:to:in-reply-to:references:message-id:content-transfer-encoding :mime-version:subject:date:from:x-gm-gg:x-gm-message-state:from:to :cc:subject:date:message-id:reply-to; bh=iqeQCDNzyERvoI4uJsKzrMugXzNJjWTyKx7GIItRI68=; b=ZpUC019Ifsu/WUfszHfnyRFNyVCYplVb2WCDSzR3DzogphxqIS7Aanlydoig5ItaJV KYKLaUqtH6nOYqo/Y4AUxUKLMFm+qHMMmtEibCm+oKerd8Hwx0weeO0eT9hCwyafdqXF 8+Ep/hRIJYU1B7dSeRp6EWwFd3MpBnPKMIe4kc/H6rLMdpCQ0I63DTdbkVk5mqXTzGFM 3OtI1mXUq+3nnqMvwX2IqHDUFPpHxZVnXe7ox6eo1Trgx4Gm3+zmfPn2n9ia4dqRcuhS RpagNawiBxdKbPuYQnRjgFT2/2aWNS4PsGCfaHPu9kPQStOu2tgr3NirXjxxa4q7WZOb WBcA== X-Forwarded-Encrypted: i=1; AJvYcCXlcNtnTFjDYjisJ12agymtRQSoiRoojWeZ5ieZYDKh+YY832yhCXZ2ZQngKFo8CFjsPUVVCSFotSZ3Ds8=@vger.kernel.org X-Gm-Message-State: AOJu0YzXqsiEUGc+5hPUUdA4tzwaAP9I4SF2tNGnc8W/pvJAI2DuUGOu PN7gSv66hed2SMsk3Tg73F/SsWMwT/5XRh/8F2j2ZRUPF2KDJypZHMRwqxXU2yl3xjo= X-Gm-Gg: ASbGnctU6FVBJkfwDf8vlvOzpGkvA07p+8damAPF+luVhTtiggo/+2WA12CCDAC2RsZ RxBS/uX+XU02oDgM36gQ5kCfeI6rcHz+rbm3L+XMjyO6ZCv08Y1NGRpVCLump1+X3jHnf3N1HYy aIk9oQ1ZQywiyPIcXu9UsVEsnyyIuEjtu8xHwVhKER1YXOZ94n/qNIXzGIPaf12K/D47Z671ZbN 5IqxxJC6WMyOwKs4f8m2hFYaC97haYgTd6JuylEH018OrcxyrLgyse/Ae1/v4B41D2s41qpZRyL yJpEKmD4RbeOECqnXppx1FhEI2IgYNNBq+qKIQlMzQ+WL5hzOoxO9iZW6psE5g+6Bsddms+fPH7 XXs8doIEZq6RiSwY4H3dRqegaFIq0evLeQyifyfk4VRyHu2ceKSrsllfDRyxQJVh8CcSS9rytXy EdTCx3OoWeTEeEqSyU/0IzyjmWI2fFcmY= X-Google-Smtp-Source: AGHT+IEM/Fju5p7i2TJe9V7ikGxvi98b6EUCB36YzVh6dnUxOojXzliJKumS8+g6+btvID3Xl1OO4w== X-Received: by 2002:a05:600c:468c:b0:477:bf1:8c82 with SMTP id 5b1f17b1804b1-477b18fb649mr35631295e9.15.1763569107534; Wed, 19 Nov 2025 08:18:27 -0800 (PST) Received: from ho-tower-lan.lan ([185.48.77.170]) by smtp.gmail.com with ESMTPSA id 5b1f17b1804b1-477b10142d3sm63205425e9.5.2025.11.19.08.18.26 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 19 Nov 2025 08:18:27 -0800 (PST) From: James Clark Date: Wed, 19 Nov 2025 16:18:05 +0000 Subject: [PATCH v6 09/13] coresight: Interpret ETMv4 config with ATTR_CFG_GET_FLD() Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Type: text/plain; charset="utf-8" Content-Transfer-Encoding: quoted-printable Message-Id: <20251119-james-cs-syncfreq-v6-9-740d24a29e51@linaro.org> References: <20251119-james-cs-syncfreq-v6-0-740d24a29e51@linaro.org> In-Reply-To: <20251119-james-cs-syncfreq-v6-0-740d24a29e51@linaro.org> To: Suzuki K Poulose , Mike Leach , Alexander Shishkin , Jonathan Corbet , Leo Yan , Randy Dunlap Cc: coresight@lists.linaro.org, linux-arm-kernel@lists.infradead.org, linux-kernel@vger.kernel.org, linux-doc@vger.kernel.org, James Clark X-Mailer: b4 0.14.0 Remove hard coded bitfield extractions and shifts and replace with ATTR_CFG_GET_FLD(). ETM4_CFG_BIT_BB was defined to give the register bit positions to userspace, TRCCONFIGR_BB should be used in the kernel so replace it. Reviewed-by: Leo Yan Signed-off-by: James Clark --- drivers/hwtracing/coresight/coresight-etm4x-core.c | 44 ++++++++++--------= ---- 1 file changed, 19 insertions(+), 25 deletions(-) diff --git a/drivers/hwtracing/coresight/coresight-etm4x-core.c b/drivers/h= wtracing/coresight/coresight-etm4x-core.c index 5d21af346799..c7208ffc9432 100644 --- a/drivers/hwtracing/coresight/coresight-etm4x-core.c +++ b/drivers/hwtracing/coresight/coresight-etm4x-core.c @@ -29,6 +29,7 @@ #include #include #include +#include #include #include #include @@ -780,17 +781,17 @@ static int etm4_parse_event_config(struct coresight_d= evice *csdev, goto out; =20 /* Go from generic option to ETMv4 specifics */ - if (attr->config & BIT(ETM_OPT_CYCACC)) { + if (ATTR_CFG_GET_FLD(attr, cycacc)) { config->cfg |=3D TRCCONFIGR_CCI; /* TRM: Must program this for cycacc to work */ - cc_threshold =3D attr->config3 & ETM_CYC_THRESHOLD_MASK; + cc_threshold =3D ATTR_CFG_GET_FLD(attr, cc_threshold); if (!cc_threshold) cc_threshold =3D ETM_CYC_THRESHOLD_DEFAULT; if (cc_threshold < drvdata->ccitmin) cc_threshold =3D drvdata->ccitmin; config->ccctlr =3D cc_threshold; } - if (attr->config & BIT(ETM_OPT_TS)) { + if (ATTR_CFG_GET_FLD(attr, timestamp)) { /* * Configure timestamps to be emitted at regular intervals in * order to correlate instructions executed on different CPUs @@ -810,17 +811,17 @@ static int etm4_parse_event_config(struct coresight_d= evice *csdev, } =20 /* Only trace contextID when runs in root PID namespace */ - if ((attr->config & BIT(ETM_OPT_CTXTID)) && + if (ATTR_CFG_GET_FLD(attr, contextid1) && task_is_in_init_pid_ns(current)) /* bit[6], Context ID tracing bit */ config->cfg |=3D TRCCONFIGR_CID; =20 /* - * If set bit ETM_OPT_CTXTID2 in perf config, this asks to trace VMID - * for recording CONTEXTIDR_EL2. Do not enable VMID tracing if the - * kernel is not running in EL2. + * If set bit contextid2 in perf config, this asks to trace VMID for + * recording CONTEXTIDR_EL2. Do not enable VMID tracing if the kernel + * is not running in EL2. */ - if (attr->config & BIT(ETM_OPT_CTXTID2)) { + if (ATTR_CFG_GET_FLD(attr, contextid2)) { if (!is_kernel_in_hyp_mode()) { ret =3D -EINVAL; goto out; @@ -831,26 +832,22 @@ static int etm4_parse_event_config(struct coresight_d= evice *csdev, } =20 /* return stack - enable if selected and supported */ - if ((attr->config & BIT(ETM_OPT_RETSTK)) && drvdata->retstack) + if (ATTR_CFG_GET_FLD(attr, retstack) && drvdata->retstack) /* bit[12], Return stack enable bit */ config->cfg |=3D TRCCONFIGR_RS; =20 /* - * Set any selected configuration and preset. - * - * This extracts the values of PMU_FORMAT_ATTR(configid) and PMU_FORMAT_A= TTR(preset) - * in the perf attributes defined in coresight-etm-perf.c. - * configid uses bits 63:32 of attr->config2, preset uses bits 3:0 of att= r->config. - * A zero configid means no configuration active, preset =3D 0 means no p= reset selected. + * Set any selected configuration and preset. A zero configid means no + * configuration active, preset =3D 0 means no preset selected. */ - if (attr->config2 & GENMASK_ULL(63, 32)) { - cfg_hash =3D (u32)(attr->config2 >> 32); - preset =3D attr->config & 0xF; + cfg_hash =3D ATTR_CFG_GET_FLD(attr, configid); + if (cfg_hash) { + preset =3D ATTR_CFG_GET_FLD(attr, preset); ret =3D cscfg_csdev_enable_active_config(csdev, cfg_hash, preset); } =20 /* branch broadcast - enable if selected and supported */ - if (attr->config & BIT(ETM_OPT_BRANCH_BROADCAST)) { + if (ATTR_CFG_GET_FLD(attr, branch_broadcast)) { if (!drvdata->trcbb) { /* * Missing BB support could cause silent decode errors @@ -859,7 +856,7 @@ static int etm4_parse_event_config(struct coresight_dev= ice *csdev, ret =3D -EINVAL; goto out; } else { - config->cfg |=3D BIT(ETM4_CFG_BIT_BB); + config->cfg |=3D TRCCONFIGR_BB; } } =20 @@ -1083,11 +1080,8 @@ static int etm4_disable_perf(struct coresight_device= *csdev, return -EINVAL; =20 etm4_disable_hw(drvdata); - /* - * The config_id occupies bits 63:32 of the config2 perf event attr - * field. If this is non-zero then we will have enabled a config. - */ - if (attr->config2 & GENMASK_ULL(63, 32)) + /* If configid is non-zero then we will have enabled a config. */ + if (ATTR_CFG_GET_FLD(attr, configid)) cscfg_csdev_disable_active_config(csdev); =20 /* --=20 2.34.1