From nobody Tue Dec 2 02:42:37 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