From nobody Mon Dec 1 22:35:06 2025 Received: from mail-wm1-f41.google.com (mail-wm1-f41.google.com [209.85.128.41]) (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 C3BA0327C07 for ; Fri, 28 Nov 2025 11:55:56 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=209.85.128.41 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1764330959; cv=none; b=IqyAYOingtOT9vM9o8kpiOLKyNadISizEIrRGb7aAq14OWIZfHSQioYKggbdIv1fE3Hjb+ADqjZRipWH+UAzmhRXjLfBBxWo5xzwPAdrxtTVgqgZCiak7zMZEPGRLJWeXNdpRGNx+cVCuSoIaoqOuPXcwHiAf7QSoP31bjEEDyo= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1764330959; c=relaxed/simple; bh=ZGYW4jE22Q+gFfa19AG+ptqVHBHrxJsL1I9dRnhrTgA=; h=From:Date:Subject:MIME-Version:Content-Type:Message-Id:References: In-Reply-To:To:Cc; b=DZXUOKZp+70w6ajVVd/A7SJKPEE03debL+kmZmmk1IiGx0v16MxiQF5fasVyM29m+xVpNGXlwLkhcWU6TrJ1A66zUaY+k1qJqRdxt4OyGXIdTpp47WApfo0bEDaqyDkle+/9jLsU7afPpafuQNZID5b50C2fwwYRNrpLHVhtLjU= 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=xnANFCdr; arc=none smtp.client-ip=209.85.128.41 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="xnANFCdr" Received: by mail-wm1-f41.google.com with SMTP id 5b1f17b1804b1-477563e28a3so12395045e9.1 for ; Fri, 28 Nov 2025 03:55:56 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; t=1764330955; x=1764935755; 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=bRvaTUsN/BOLMraF1V/Jx+sgUDlEB4La/1yBhPfFT5o=; b=xnANFCdrZjf8ZN1GB/7y6E/IIKZgm2gQJ22uAclFt+mE4Yqd0+MlqWQqWgUav1eG3t ywKfzMUjS3JiDVDInL11CfQcqLanTaaGXxuF3WWiOield9Nu3bTz8vYca+K27HaQFFr+ Nj32b3TM8CnSJ1qKs8kyBcd0FCo36AmAHDn7wwuhs0QsMn4U3+WXLITGfqP65tMbzX8M DsK+n/QIVNDItsr8vm/Tv4z6VDjimn7GOKOvG2F3bLBqhGMdyZgoXE9ZdcG89g+qjIiY x4ROG6Gav+28Sprb03aTLyTlao9YLu4/f8PmpuwBDTy624WRnBXNdCG34ApRufenAEZi b5rQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1764330955; x=1764935755; 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=bRvaTUsN/BOLMraF1V/Jx+sgUDlEB4La/1yBhPfFT5o=; b=dcDxuQTTeE6j/RalwXXBWwDRtpUkNldUmSGr2BmMjxkZgRO3z8tKaFexOJI74xu08/ X/qU6lTWZFIJpg5AUuqTOkEAsAcHyTyzhwb0HTKoh2KuDfxxbybmUC4zi/jLp1ZiaSYr il+AoRzRVKfoC80ug7dmC/lB9v8gUt1uSfIS1QkpTjZLXabwQioXXm4q2sC0UV9uyIba LtOwtMl3W2l96wKm/utaNOZV+9xP2DlmKljyvtFfIQib1KY3vTh7IkoIxswhT6dLWwi/ c6QAAnYsztyIp2wTjlqOsr6uDhYIkU3wCLJN3sXwaNGs+FlgVbN+JKBJOwpnK4vlrQGL uvug== X-Forwarded-Encrypted: i=1; AJvYcCWKjlQwzTQeiPddaHMIEdz2iGTNbe45PFmgRGdlZvUh15/kbcU24wcZw+6WoeZVLJCF6tA8CIKUV0OOAe0=@vger.kernel.org X-Gm-Message-State: AOJu0YyUAIVOq6sfC+lwXk2V2ijCfBA+czWmu3ex/1mpxu4HRkLOvGIx i2GpZzp5MGl7Qcv7KbM1VdNUIxr4qAsFqEG3Tvw8dLBM9mVvUaoV60IDJO5VNOWbs7r6RokNdVN DUTMI X-Gm-Gg: ASbGncthqezSEH1KPABb3wTOoHJZdRNLRVswhNQMGSgz87WLJeopbpKeJk2VpGCe4xq og3tGP3/GJtEn1BB5vAWBpEifXfyODQwWy+4Re2XWfvZlzj8YAFsqduwX7NIRosSTUZBUOdqW51 tuPhCcCTn0cVmoGLF5JTDEZTiBo2Ym5A/bRB2RCObM1pP9IWuUOWHG8YEYcxvpUJ6H3AH5x+Knk 003262XZ3byjBJxmMU4XTopAnOsw8en1AVZTSX6mxvmokprEzuuhk7ee8IZd6y5kDqXT1Q3IN1/ QlbvAdGhYnOWbTCpognDIUr3Ajx62W2h7m/ti3F0TauEUcRU+LJ7B1Scdl0Gm8gGaqrnVEk2flC 335M/JvBB2+v3k7Zf7j3HJ9cySunVPuKb6OmaOmbZ9qwmds7rNYqt6Mpwjesv+48tATNQNCKT5X em+NJ71QGmf8dN6C6jhEyb X-Google-Smtp-Source: AGHT+IHHJp7IXs6ZlGHGDXrAuQH/ZDtq9VItsBGhLegTctnw4skk5g13LG6OujHX1TW9GVSOCqfOjA== X-Received: by 2002:a05:600c:154e:b0:46e:2815:8568 with SMTP id 5b1f17b1804b1-477c05137f4mr277419485e9.10.1764330955144; Fri, 28 Nov 2025 03:55:55 -0800 (PST) Received: from ho-tower-lan.lan ([185.48.77.170]) by smtp.gmail.com with ESMTPSA id 5b1f17b1804b1-4790adc8bc7sm158974465e9.1.2025.11.28.03.55.54 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 28 Nov 2025 03:55:54 -0800 (PST) From: James Clark Date: Fri, 28 Nov 2025 11:55:18 +0000 Subject: [PATCH v8 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: <20251128-james-cs-syncfreq-v8-6-4d319764cc58@linaro.org> References: <20251128-james-cs-syncfreq-v8-0-4d319764cc58@linaro.org> In-Reply-To: <20251128-james-cs-syncfreq-v8-0-4d319764cc58@linaro.org> To: Suzuki K Poulose , Mike Leach , Alexander Shishkin , Jonathan Corbet , Leo Yan , Randy Dunlap Cc: coresight@lists.linaro.org, linux-arm-kernel@lists.infradead.org, linux-kernel@vger.kernel.org, linux-doc@vger.kernel.org, James Clark X-Mailer: b4 0.14.0 Currently we're programming attr->config directly into ETMCR after some validation. This obscures which fields are being used, and also makes it impossible to move fields around or use other configN fields in the future. Improve it by only reading the fields that are valid and then setting the appropriate ETMCR bits based on each one. The ETMCR_CTXID_SIZE part can be removed as it was never a valid option because it's not in ETM3X_SUPPORTED_OPTIONS. Reviewed-by: Leo Yan Reviewed-by: Mike Leach Tested-by: Leo Yan Signed-off-by: James Clark --- drivers/hwtracing/coresight/coresight-etm3x-core.c | 24 ++++++++++++------= ---- 1 file changed, 13 insertions(+), 11 deletions(-) diff --git a/drivers/hwtracing/coresight/coresight-etm3x-core.c b/drivers/h= wtracing/coresight/coresight-etm3x-core.c index a5e809589d3e..4511fc2f8d72 100644 --- a/drivers/hwtracing/coresight/coresight-etm3x-core.c +++ b/drivers/hwtracing/coresight/coresight-etm3x-core.c @@ -28,6 +28,7 @@ #include #include #include +#include #include =20 #include "coresight-etm.h" @@ -339,21 +340,22 @@ static int etm_parse_event_config(struct etm_drvdata = *drvdata, if (attr->config & ~ETM3X_SUPPORTED_OPTIONS) return -EINVAL; =20 - config->ctrl =3D attr->config; + config->ctrl =3D 0; =20 - /* Don't trace contextID when runs in non-root PID namespace */ - if (!task_is_in_init_pid_ns(current)) - config->ctrl &=3D ~ETMCR_CTXID_SIZE; + if (ATTR_CFG_GET_FLD(attr, cycacc)) + config->ctrl |=3D ETMCR_CYC_ACC; + + if (ATTR_CFG_GET_FLD(attr, timestamp)) + config->ctrl |=3D ETMCR_TIMESTAMP_EN; =20 /* - * Possible to have cores with PTM (supports ret stack) and ETM - * (never has ret stack) on the same SoC. So if we have a request - * for return stack that can't be honoured on this core then - * clear the bit - trace will still continue normally + * Possible to have cores with PTM (supports ret stack) and ETM (never + * has ret stack) on the same SoC. So only enable when it can be honored + * - trace will still continue normally otherwise. */ - if ((config->ctrl & ETMCR_RETURN_STACK) && - !(drvdata->etmccer & ETMCCER_RETSTACK)) - config->ctrl &=3D ~ETMCR_RETURN_STACK; + if (ATTR_CFG_GET_FLD(attr, retstack) && + (drvdata->etmccer & ETMCCER_RETSTACK)) + config->ctrl |=3D ETMCR_RETURN_STACK; =20 return 0; } --=20 2.34.1