From nobody Tue Dec 2 02:29:11 2025 Received: from mail-wm1-f44.google.com (mail-wm1-f44.google.com [209.85.128.44]) (using TLSv1.2 with cipher ECDHE-RSA-AES128-GCM-SHA256 (128/128 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 718C1366DCB for ; Wed, 19 Nov 2025 16:18:26 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=209.85.128.44 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1763569108; cv=none; b=B7rTqpRhe9Pz2LDPKk6JfEMj7hNYvRATiTT4tQ+VJidmyXEsD5QvANEU48HbkKm0no7X1RG/TnEcQm+dK187AEkgGNOG54nSP7dcUKZEFSWMLJC6LYR6NX9qk448SNNdonIjk0REc7XA/BOr15oTz424cTNgD0b21rV5jqvk7bQ= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1763569108; c=relaxed/simple; bh=OOb4yNfBq0DxPF8hQvLUI30prmr2dFYr6vUoRd2Wzp0=; h=From:Date:Subject:MIME-Version:Content-Type:Message-Id:References: In-Reply-To:To:Cc; b=iHDUxkKuPmw8G2ErzLTsm738/k0VITpH0GA9OaZWXdc8UsjIQSVkSpFrVcTgZYg+V4SERuCN3lquUu86x7Ok/RI2V8V28T5e6lrYVX6UgIrypcct2ZKGDb4LGnuQpTIioB0VUse9FN4j7GANybzeWyFWLziUYqTeSJq8JpBrxJo= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=linaro.org; spf=pass smtp.mailfrom=linaro.org; dkim=pass (2048-bit key) header.d=linaro.org header.i=@linaro.org header.b=k3hfriSV; arc=none smtp.client-ip=209.85.128.44 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=linaro.org Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=linaro.org Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=linaro.org header.i=@linaro.org header.b="k3hfriSV" Received: by mail-wm1-f44.google.com with SMTP id 5b1f17b1804b1-47778b23f64so46606405e9.0 for ; Wed, 19 Nov 2025 08:18:26 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; t=1763569105; x=1764173905; darn=vger.kernel.org; h=cc:to:in-reply-to:references:message-id:content-transfer-encoding :mime-version:subject:date:from:from:to:cc:subject:date:message-id :reply-to; bh=mAj6+rTtj7ATosP9M3WMDyWCja/Ic0j8s2EkvfB39Kc=; b=k3hfriSVoRu0zBMQ+lTNxo+Qfd68VkXUKWfpCKhXhWjW3QKdq0NxFlSaC+f6cpiXW5 q4O+XR8SORA56kxZj8YOBLTsbQYIdIuFxTvAiX8v6Z6IT7+i5/yRqfoyxvTZORABfwpZ N1UNOfe/uFPBPuNztDGefrHQUWb3qBUVgb/RRD2T4wWCQspJfCJp9qLQbRbU3sQd0JV5 ZzjhFE81wBHKPyUgripYkO8SGP6+JrZxvYIGFIBr1C9qwT8agDMzeg1vzj526oDuZu0a 0aSlYXgpYmXpmsx+7loOFVdyGlBHtHSf2TFay8mLqvxoRumlh8NMwdAJ9IB8HyKE4+QF bsjg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1763569105; x=1764173905; h=cc:to:in-reply-to:references:message-id:content-transfer-encoding :mime-version:subject:date:from:x-gm-gg:x-gm-message-state:from:to :cc:subject:date:message-id:reply-to; bh=mAj6+rTtj7ATosP9M3WMDyWCja/Ic0j8s2EkvfB39Kc=; b=F8LVDiu6r9ce1apeCFDGbj3JmT+YVGj5/YS38umIgKoVLnn4CPbFsgUhAmHwok0YQg RupFFFVQAXpPYzelbhiRBNhdd/v384gM01TdQu+vCGq7qxAomVL4hCnFBtXYDcanmKQu jEUOp2CdVKN2tU9mjgvGxeCWvfLlPMPVUgMmYCm/T2DplzvVP2yK/WvWbLw9sEhujM/c +ZLmfAX2NCxKcVFVwlXd/SdU9c/UtNsh3IErvp6+49ZqeIjgiraw2YdcS7UkM1LyMKRB dDxzt3QSQQvYJ2WMayr9Pxy01jB4NFFLJ7A75lUjk/KBmhacbMf9GpMxY4cgu2Lr065J 0B3A== X-Forwarded-Encrypted: i=1; AJvYcCXBhO8gt2Q5Fdn0k3cUvG4dK7Jbn9PRCetKXF9XPcpD5o4Xmg7Hfl9L2oWHtb/m6qHWgNVawUFea3yo2+E=@vger.kernel.org X-Gm-Message-State: AOJu0YwXt9kY7sV2GTeBTiJ+gfHbqYTmvM4Y1laH4vXeLjwnYk76Svj7 C+rrHGIB4KuS4cVtGwPN1cyNgq4FZf21lv28bjkrjuKZau6Xix0FGVtbTX2//bITI/g= X-Gm-Gg: ASbGncvv/+ou6iYFE6WGVSSs/X9speRdgwbJ/UGUsqCAb1XlNjrsk4qnXrzgeMpW6XT szV7my34yrY9Reyv+YVpt5AsiSP3+RXLBAw+cBadctl2smqiX1z+dBYOTaypfmYJ/XIrKCVTo+V Tdko712XOArxxb5P//AZu/iRpemGDoGdkBZQdS2MJDbdQw26ZYyiVT4/UxKk2NMPl2evrq+Pei7 n6he3SPCQiRzQcmQASYUslTYckeSi54Z61daiU8hsr2gDkVr2+iT2ANYXrqhFtJ3xn+FTRXCmwX 2dSMm6p36RkLTnRTZ8PVCErU1wn87VfZLfpy37/MdSyIe3sxxHtgz5Bir4IPsM+R5rrWQF7yUkS +TtpK+ZISpzUvFuaMS5HnX5kT5Vcj9ImLNMfgpicBdgBESYJo+S0geRUuNPoE83UqpsRGBhWr0H NXkrXhSNvcNHZcFz3Iok8Ts2awz7ukLaY= X-Google-Smtp-Source: AGHT+IHL0Xxnsgm5QROIs0jK7YmdMNHqvM4TUjjLTcMhfd+KYuc1AUdTBzLfbEK0Xqm07NedRv3Q6Q== X-Received: by 2002:a05:600c:4fc5:b0:477:b0b9:312a with SMTP id 5b1f17b1804b1-477b0b932damr42861065e9.7.1763569104659; Wed, 19 Nov 2025 08:18:24 -0800 (PST) Received: from ho-tower-lan.lan ([185.48.77.170]) by smtp.gmail.com with ESMTPSA id 5b1f17b1804b1-477b10142d3sm63205425e9.5.2025.11.19.08.18.23 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 19 Nov 2025 08:18:24 -0800 (PST) From: James Clark Date: Wed, 19 Nov 2025 16:18:02 +0000 Subject: [PATCH v6 06/13] coresight: Interpret ETMv3 config with ATTR_CFG_GET_FLD() Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Type: text/plain; charset="utf-8" Content-Transfer-Encoding: quoted-printable Message-Id: <20251119-james-cs-syncfreq-v6-6-740d24a29e51@linaro.org> References: <20251119-james-cs-syncfreq-v6-0-740d24a29e51@linaro.org> In-Reply-To: <20251119-james-cs-syncfreq-v6-0-740d24a29e51@linaro.org> To: Suzuki K Poulose , Mike Leach , Alexander Shishkin , Jonathan Corbet , Leo Yan , Randy Dunlap Cc: coresight@lists.linaro.org, linux-arm-kernel@lists.infradead.org, linux-kernel@vger.kernel.org, linux-doc@vger.kernel.org, James Clark X-Mailer: b4 0.14.0 Currently we're programming attr->config directly into ETMCR after some validation. This obscures which fields are being used, and also makes it impossible to move fields around or use other configN fields in the future. Improve it by only reading the fields that are valid and then setting the appropriate ETMCR bits based on each one. The ETMCR_CTXID_SIZE part can be removed as it was never a valid option because it's not in ETM3X_SUPPORTED_OPTIONS. Reviewed-by: Leo Yan Signed-off-by: James Clark --- drivers/hwtracing/coresight/coresight-etm3x-core.c | 24 ++++++++++++------= ---- 1 file changed, 13 insertions(+), 11 deletions(-) diff --git a/drivers/hwtracing/coresight/coresight-etm3x-core.c b/drivers/h= wtracing/coresight/coresight-etm3x-core.c index a5e809589d3e..4511fc2f8d72 100644 --- a/drivers/hwtracing/coresight/coresight-etm3x-core.c +++ b/drivers/hwtracing/coresight/coresight-etm3x-core.c @@ -28,6 +28,7 @@ #include #include #include +#include #include =20 #include "coresight-etm.h" @@ -339,21 +340,22 @@ static int etm_parse_event_config(struct etm_drvdata = *drvdata, if (attr->config & ~ETM3X_SUPPORTED_OPTIONS) return -EINVAL; =20 - config->ctrl =3D attr->config; + config->ctrl =3D 0; =20 - /* Don't trace contextID when runs in non-root PID namespace */ - if (!task_is_in_init_pid_ns(current)) - config->ctrl &=3D ~ETMCR_CTXID_SIZE; + if (ATTR_CFG_GET_FLD(attr, cycacc)) + config->ctrl |=3D ETMCR_CYC_ACC; + + if (ATTR_CFG_GET_FLD(attr, timestamp)) + config->ctrl |=3D ETMCR_TIMESTAMP_EN; =20 /* - * Possible to have cores with PTM (supports ret stack) and ETM - * (never has ret stack) on the same SoC. So if we have a request - * for return stack that can't be honoured on this core then - * clear the bit - trace will still continue normally + * Possible to have cores with PTM (supports ret stack) and ETM (never + * has ret stack) on the same SoC. So only enable when it can be honored + * - trace will still continue normally otherwise. */ - if ((config->ctrl & ETMCR_RETURN_STACK) && - !(drvdata->etmccer & ETMCCER_RETSTACK)) - config->ctrl &=3D ~ETMCR_RETURN_STACK; + if (ATTR_CFG_GET_FLD(attr, retstack) && + (drvdata->etmccer & ETMCCER_RETSTACK)) + config->ctrl |=3D ETMCR_RETURN_STACK; =20 return 0; } --=20 2.34.1