From nobody Mon Dec 1 23:02:29 2025 Received: from mail-wm1-f47.google.com (mail-wm1-f47.google.com [209.85.128.47]) (using TLSv1.2 with cipher ECDHE-RSA-AES128-GCM-SHA256 (128/128 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 37F7F3203B5 for ; Wed, 26 Nov 2025 10:57:49 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=209.85.128.47 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1764154671; cv=none; b=iV5K/OxT7NnIjgUYuBm5IP/i3LLyyLqlDxsj9EGcyrO6tZXFyCiFF1j6Czv6m0VIkbhBZCu74GpfT7qPklz4tev16nXOQ6+4Y2wRDMDJeX/HYfAl40AHmN2hHpwJ2rKDuFNMsvckywa6I70T5U2DdNQkRgGSS8vAKfNNgozHfro= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1764154671; c=relaxed/simple; bh=3RMhptuDb6hntDjRO9PlAJUzplD9xGCbvBdoaETHrSY=; h=From:Date:Subject:MIME-Version:Content-Type:Message-Id:References: In-Reply-To:To:Cc; b=B6WPFo7sGzeKCYoROCExOG+J1QjIksUe8J2ftFQER6TC35OEspPzpQQoo7/P9J0FIEtR/Hi/L07B3ndcJoZ98gb7EB/TAV3WUmvplwVkFfW9pscHqPlk2BS3qtcABlVxl9IV46mirRqh2qMBDWWb9yUeaqyi5LCM6PCDhucj7no= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=linaro.org; spf=pass smtp.mailfrom=linaro.org; dkim=pass (2048-bit key) header.d=linaro.org header.i=@linaro.org header.b=EYlQn71x; arc=none smtp.client-ip=209.85.128.47 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=linaro.org Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=linaro.org Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=linaro.org header.i=@linaro.org header.b="EYlQn71x" Received: by mail-wm1-f47.google.com with SMTP id 5b1f17b1804b1-4775e891b5eso28128925e9.2 for ; Wed, 26 Nov 2025 02:57:48 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; t=1764154667; x=1764759467; darn=vger.kernel.org; h=cc:to:in-reply-to:references:message-id:content-transfer-encoding :mime-version:subject:date:from:from:to:cc:subject:date:message-id :reply-to; bh=+aV97bb+2uBMzq9jHPPNimq5cmAOBpE8XZ5NB2YnSTE=; b=EYlQn71xEyU+Jk6NgAs58J2CycR/w3nTA+pjlr7T8BjNlBmSPNgu/iQFZYTm3qEZMJ GRU888FJJFod9tf9Ks+Qzvc0FHY149NZwf0uS3+mgBGpCxFtIASv3HXzX4+kQVGj74D3 rQs7m4f0DlTvHrMBXGxfrTb1uUUojKY0/FhjUn+fwy2swbytEDfoHF8G7p3/HEpj1JYa 2uzg3+m7wtLPNKfq1AkT2Lxt3or7bAmB8Y1YdgnIAQlEavm3BvcWy/6vntsz8Szkeaae F1WcQBp2jsVn3OSJLMVcYbrv/4l/bdJ8Eff4wCO5jSkniQ5htVkd09Vn+vPAcUJGBo1L aIfw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1764154667; x=1764759467; h=cc:to:in-reply-to:references:message-id:content-transfer-encoding :mime-version:subject:date:from:x-gm-gg:x-gm-message-state:from:to :cc:subject:date:message-id:reply-to; bh=+aV97bb+2uBMzq9jHPPNimq5cmAOBpE8XZ5NB2YnSTE=; b=qJDrIMmtOfs9cJXKIEbZDSDTemhfdGg+bdamCHQihakksRcA3nthWIIQiQgawLPGPj d0ET0xAkpGl57tX0mnIHBhq+sgGtFmYt2M2+mm2W52X824oC/reah2r8WO4ks3rXPtgT 3gQ4c14Sf77MBy9iw8US/O58JZQqmuvrfFxTuTxjTTdWPiZf5bOtIyw0xBjpL6e6ugUJ P785z76+dguLPRaIdIxYLvjH9dqccYjxFUMNzeNu5aQ3SoudZKQ4bvUkXV9e444WYlp7 KpRr9hWwrdFLon4J0VZSuVWhzFF7vW3ZqstWlVT2aLAe+VZXgo10rURCQY4/fVgGcabn MSjA== X-Forwarded-Encrypted: i=1; AJvYcCXoY9b3/x7rdv4KFCvl8jxnK92URNBWoEwHacXkDK0TtUrKIsTvWOUOmLhl9ycbeHHumRhcz38dYwwcok0=@vger.kernel.org X-Gm-Message-State: AOJu0YyWUgBmLGm1N8iueRXGRS5WiWBnrr/pdh4kTWxogfLZGPGHFxde 9gFXsp3yeYZi1x/lSwO4e9xwdLMrM3HjO0+j+DlUe3h5fVwjkGcQnN/kd1hAdiE+6S4= X-Gm-Gg: ASbGncuSXOk+xsJQYT22xgiHj5249ZgYDG47+LJFj4jEIepAIm5wTQ7Be1q8RtYwWut LJjSIaQ/s/qvKP8ua65sDtF/Gkg2pp9x8fvcdh/Ret7WVwRaO857zHgo4xMoW+9yUQ6qCQxhSYB 5EiBanKOpzMRVAkD8D9g0ZeD84EEnZoTRvRzMOvGzQfxZdvLPMD9Q87yHLZRLquUtRdiCugqAyP 8AuCKl8CwHMzmfe8K2WhgsOMr5o2s11kSCnr6ANPw+fwV0u8zQHHMf0eMe2jTUePeerZ36kA748 kNNlE3tzzXEikITlol+dukt6Xd9ba6rYQjRrsHh49Ffg9rN2U4AvYMXA7BwaeDWk3pS7n84fopI FwxIp59MC/lV/RU7n/SY2r9sk/bVU5IUOqMzfhwgA24Ag4JqhEusREN0RLOIO6Y8NvsVM0t29De hr/IJIRQJsnhzue24ve5tR8oh+emPhOKw= X-Google-Smtp-Source: AGHT+IHgGpVirZ77PpHdvUsmYCeB9BGpEg9syRMr1tRkkyQMuBNBfGSh/HLgcNOGSzBrV7ZuKkcwdA== X-Received: by 2002:a05:600c:4e8e:b0:477:9f34:17b8 with SMTP id 5b1f17b1804b1-477c0165bf3mr187105765e9.1.1764154667542; Wed, 26 Nov 2025 02:57:47 -0800 (PST) Received: from ho-tower-lan.lan ([185.48.77.170]) by smtp.gmail.com with ESMTPSA id 5b1f17b1804b1-4790ade13ddsm36991765e9.8.2025.11.26.02.57.46 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 26 Nov 2025 02:57:47 -0800 (PST) From: James Clark Date: Wed, 26 Nov 2025 10:54:35 +0000 Subject: [PATCH v7 06/13] coresight: Interpret ETMv3 config with ATTR_CFG_GET_FLD() Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Type: text/plain; charset="utf-8" Content-Transfer-Encoding: quoted-printable Message-Id: <20251126-james-cs-syncfreq-v7-6-7fae5e0e5e16@linaro.org> References: <20251126-james-cs-syncfreq-v7-0-7fae5e0e5e16@linaro.org> In-Reply-To: <20251126-james-cs-syncfreq-v7-0-7fae5e0e5e16@linaro.org> To: Suzuki K Poulose , Mike Leach , Alexander Shishkin , Jonathan Corbet , Leo Yan , Randy Dunlap Cc: coresight@lists.linaro.org, linux-arm-kernel@lists.infradead.org, linux-kernel@vger.kernel.org, linux-doc@vger.kernel.org, James Clark X-Mailer: b4 0.14.0 Currently we're programming attr->config directly into ETMCR after some validation. This obscures which fields are being used, and also makes it impossible to move fields around or use other configN fields in the future. Improve it by only reading the fields that are valid and then setting the appropriate ETMCR bits based on each one. The ETMCR_CTXID_SIZE part can be removed as it was never a valid option because it's not in ETM3X_SUPPORTED_OPTIONS. Reviewed-by: Leo Yan Reviewed-by: Mike Leach Signed-off-by: James Clark --- 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