From mboxrd@z Thu Jan 1 00:00:00 1970 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 D25DD35505F for ; Wed, 19 Nov 2025 13:55:18 +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=1763560520; cv=none; b=VYbmXycErY/NpJ0iIoPSWHmQ4fVGrXH7IgsUxa3IX0q65VW16CSFV7sJG/chbFnYU4PiVDewFAoV/s1JQOePTqPWx8BSi+/zdqrKFtZ5OKYxEchr01ufYO1q+gixKD6aYAs2IoxkjZiLK59UUvSZs8AI/Ls2pRnvMcECWw33pT0= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1763560520; c=relaxed/simple; bh=opPOOG1O6YWZJsndEVn+IOBeaBmKbK+Sds2Gv96QrM4=; h=Message-ID:Date:MIME-Version:Subject:To:Cc:References:From: In-Reply-To:Content-Type; b=eM6EaU7Y0QGNMuazS1P9U+xueBincb03mYuHuLPnBVlyrhbzyplOEL3UohfrguQqTmmyGzGN0/yO7dW9OYU6xtBzOg3R5KNkIiDTjfHugmYnrnfqpkL5CXhTdwoOEU59X9J4KDhINkrfY10+cpb9r3jMJozUbMgSmBJzm9DuiV8= 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=DCQFRJXh; 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="DCQFRJXh" Received: by mail-wm1-f48.google.com with SMTP id 5b1f17b1804b1-477770019e4so70652855e9.3 for ; Wed, 19 Nov 2025 05:55:18 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; t=1763560517; x=1764165317; darn=vger.kernel.org; h=content-transfer-encoding:in-reply-to:from:content-language :references:cc:to:subject:user-agent:mime-version:date:message-id :from:to:cc:subject:date:message-id:reply-to; bh=+q6MH2wUYmWiA2m/aB7uSk/4x8ihBeWt9CWI89JZj8I=; b=DCQFRJXhtKz2Z49BmcV2EWeq/8xcAhpXmNcb+iMni7QlmTenAp2QGBe9sNNZwi/QhA 62FPcB6WKbb/o3807+059x1Gm5UkyTsgnb9Sd2pllOLNydrMduzNNFfJ2aGZB0ydcHJy RyfFrk4DW2z28O1r1Dlg34Aupbgq9Grrf0uqo1hEXI2K2ZFXdxS6FmGYOQPCi7oJ/8Cv km6xX0ECYZXnU9TCKvoCzpx/aG3VikkXuxvAgjlUx1Xhn6tNzpAl9KSjljvfttevMJib Xa2Xjz4NkCvPYG7nU7zpk/t8sprAC9SmyZKH06wFXCwDWbzW03iG2vMKkjG1LfXuH5n/ 6HKQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1763560517; x=1764165317; h=content-transfer-encoding:in-reply-to:from:content-language :references:cc:to:subject:user-agent:mime-version:date:message-id :x-gm-gg:x-gm-message-state:from:to:cc:subject:date:message-id :reply-to; bh=+q6MH2wUYmWiA2m/aB7uSk/4x8ihBeWt9CWI89JZj8I=; b=wzfJ3n4zi+6Ixuw0EEjeJTo2yIjVcDOAC7ESECiuqMgYTFYnFfXaTMfJ4lO5fvVFDE sbxD1k/jhbbHo23Yz518YISwd4K+veWRq6X3T+AWte74QUpRTS2hEWmXCksZjeHWxpD6 G8FQXTUgHR4gZpEutszWeW1gqf3XGrbW1BzKLq3FqIVqBnNsfk6jav/tRiZkgn7pqE+v hI+0DAQbtzgA7hl2jCXLx+UDmiV32YgQ4/FNfru+rGY1PpFQzGfqIYMM03oEI3sqPzKU 4JzPTHUmN20ZcJQcVMsSoKR+Cqh0A1Qa3uoUMxYnxOebTOpqfIGzol61ma8xLT8SjdY7 MmDA== X-Forwarded-Encrypted: i=1; AJvYcCXsL2UqIbzc47dep2gTBr31cBpcH04l1xIgKyHKq4CN3hhkf/C7IRsVl7KlIHVIahLTNM3NQm+QxONstjY=@vger.kernel.org X-Gm-Message-State: AOJu0YzTn3QbwNUwt0V0mzy8WUHtq9APP61/fyj+nfoPWtLqEJedPExH cLHjTS8zT+dl2z4B8G5q6fW/0JPWd+IEyKmbTKMIUdpXWXT79ctFmBK1amIZmRGTz80Nx2E6RsD 7df4CuwE= X-Gm-Gg: ASbGncvdDjrXpZClhTeZW53RPqEjD5ccAQBw7weeKUcZF3bAB8GvggtybgcSeBmH0vM PwlG5lNoS/rErkcKFRBEU5i4uEEWep/to+w6znCRlPlqN0ZavSp5h7EjtkeRclET8N1Dx+0ED// jPS0fidzRulyDa0khFvMYPKZIrTBkYCA/BFhWeWISsrRmsznpR7jX/NQX4JSxGsEDd25xL6VEPI xhRVCx51K41iHdTRPbsR04qAbmbXufa70AAt3uV+aUpPOzmGixocKDdQrIzf370fTl3OWPv5Onf g2LqI6IZ9Q4YF3r1SBf1o+Aw571uXGGMsouTQKVZjpEMDwCcGjMLpTRwD0nqd3orh21cSJvxMLD cAJLOpig1X6y1k6B+oTGr5yhVDzqvBQmUvxm8JC297CaqlsHkYM7bF/94sm304NgFHU1Nrg6yo0 qJYNaSJeHA1L//nWlvbuOpRI6quXPlkN3HEjjZAQ== X-Google-Smtp-Source: AGHT+IEkdbSdxiPZRPo/BfGmPl8Z82ZAzyIqM965RgSEKLzus7ZjC7qYxPL1XYrZ3Hts2RXQnznpcg== X-Received: by 2002:a05:600c:190b:b0:471:131f:85aa with SMTP id 5b1f17b1804b1-4778fe4a039mr165734565e9.13.1763560517126; Wed, 19 Nov 2025 05:55:17 -0800 (PST) Received: from [192.168.1.3] ([185.48.77.170]) by smtp.gmail.com with ESMTPSA id 5b1f17b1804b1-477b1012af0sm49846635e9.6.2025.11.19.05.55.16 (version=TLS1_3 cipher=TLS_AES_128_GCM_SHA256 bits=128/128); Wed, 19 Nov 2025 05:55:16 -0800 (PST) Message-ID: Date: Wed, 19 Nov 2025 13:55:15 +0000 Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 User-Agent: Mozilla Thunderbird Subject: Re: [PATCH v5 08/13] coresight: Interpret perf config with ATTR_CFG_GET_FLD() To: Leo Yan Cc: Mike Leach , Suzuki K Poulose , Alexander Shishkin , Jonathan Corbet , Randy Dunlap , coresight@lists.linaro.org, linux-arm-kernel@lists.infradead.org, linux-kernel@vger.kernel.org, linux-doc@vger.kernel.org References: <20251118-james-cs-syncfreq-v5-0-82efd7b1a751@linaro.org> <20251118-james-cs-syncfreq-v5-8-82efd7b1a751@linaro.org> <416cf32d-d647-46dd-bcef-acc019490561@linaro.org> <43a60afe-5170-4801-ae70-9243cf7b45b8@linaro.org> <20251119123647.GC8204@e132581.arm.com> Content-Language: en-US From: James Clark In-Reply-To: <20251119123647.GC8204@e132581.arm.com> Content-Type: text/plain; charset=UTF-8; format=flowed Content-Transfer-Encoding: 7bit On 19/11/2025 12:36 pm, Leo Yan wrote: > On Wed, Nov 19, 2025 at 12:00:30PM +0000, James Clark wrote: > > [...] > >> ... But then to make >> the code match the warning it might also make sense to change CONFIG_ARM64 >> back to CONFIG_CORESIGHT_SOURCE_ETM4X, which Leo suggested to change. Maybe >> I can just delete the warning text, practically this warning can never be >> hit. > > Armv8 CPUs can runs in aarch32 mode, strictly speaking, we should also > can run ETMv4 driver in aarch32 mode as well. Then CONFIG_ARM64 is the > right choice, this can remind us that `is_kernel_in_hyp_mode()` is > always stick to aarch64 mode. > For the avoidance of confusion, in this case CONFIG_ARM64 and CONFIG_CORESIGHT_SOURCE_ETM4X are 100% equivalent and there's no functional difference. Yes maybe 32 bit userspace can be traced from ETMv4, but that's not really related with how this code is compiled. > static ssize_t format_attr_contextid_show(struct device *dev, > struct device_attribute *attr, > char *page) > { > #if IS_ENABLED(CONFIG_ARM64) > if (is_kernel_in_hyp_mode()) > return contextid2_show(dev, attr, page); > #endif > > return contextid1_show(dev, attr, page); Not having an #else implies that the contextid1_show() part is valid when !CONFIG_ARM64, but that isn't right. That's why I had the WARN_ON because it's dead code. Personally I would drop the is_visible(). It makes sense for dynamically hidden things, but these are all compile time. IMO it's cleaner to just not include them to begin with, rather than include and then hide them. Then the extra condition in format_attr_contextid_show() isn't needed because the function doesn't exist: GEN_PMU_FORMAT_ATTR(cycacc); GEN_PMU_FORMAT_ATTR(timestamp); GEN_PMU_FORMAT_ATTR(retstack); GEN_PMU_FORMAT_ATTR(sinkid); #if IS_ENABLED(CONFIG_CORESIGHT_SOURCE_ETM4X) /* contextid1 enables tracing CONTEXTIDR_EL1 for ETMv4 */ GEN_PMU_FORMAT_ATTR(contextid1); /* contextid2 enables tracing CONTEXTIDR_EL2 for ETMv4 */ GEN_PMU_FORMAT_ATTR(contextid2); GEN_PMU_FORMAT_ATTR(branch_broadcast); /* preset - if sink ID is used as a configuration selector */ GEN_PMU_FORMAT_ATTR(preset); /* config ID - set if a system configuration is selected */ GEN_PMU_FORMAT_ATTR(configid); GEN_PMU_FORMAT_ATTR(cc_threshold); /* * contextid always traces the "PID". The PID is in CONTEXTIDR_EL1 * when the kernel is running at EL1; when the kernel is at EL2, * the PID is in CONTEXTIDR_EL2. */ static ssize_t format_attr_contextid_show(struct device *dev, struct device_attribute *attr, char *page) { if (is_kernel_in_hyp_mode()) return contextid2_show(dev, attr, page); return contextid1_show(dev, attr, page); } static struct device_attribute format_attr_contextid = __ATTR(contextid, 0444, format_attr_contextid_show, NULL); #endif /* * ETMv3 only uses the first 3 attributes for programming itself (see * ETM3X_SUPPORTED_OPTIONS). Sink ID is also supported for selecting a * sink in both, but not used for configuring the ETM. The remaining * attributes are ETMv4 specific. */ static struct attribute *etm_config_formats_attr[] = { &format_attr_cycacc.attr, &format_attr_timestamp.attr, &format_attr_retstack.attr, &format_attr_sinkid.attr, #if IS_ENABLED(CONFIG_CORESIGHT_SOURCE_ETM4X) &format_attr_contextid.attr, &format_attr_contextid1.attr, &format_attr_contextid2.attr, &format_attr_preset.attr, &format_attr_configid.attr, &format_attr_branch_broadcast.attr, &format_attr_cc_threshold.attr, #endif NULL, }; > } > > Thanks, > Leo