From nobody Fri Jun 12 12:48:49 2026 Received: from mail-pl1-f194.google.com (mail-pl1-f194.google.com [209.85.214.194]) (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 E50493AA1B5 for ; Fri, 15 May 2026 02:42:53 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=209.85.214.194 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1778812976; cv=none; b=oSGeZok9KwbzZN2P9h0aGusS2gs2r+0n5fLMgWJ9Rrgq2xsIFrIfCdYV+keFomw23yZkeOpJ7CuP/0TpfXazej5cWVsoc+ul0WzfEFqTNrKa4eux2XZED/pbaS5grZhIlzCWRGpw1VtvBFFRnUpmkj9hUS7VtPD99ljhK4Ns1Lk= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1778812976; c=relaxed/simple; bh=wrIY+8IUZxwfG31GnEdEN73Bq00TYFrEyY3K9wmYU38=; h=From:To:Cc:Subject:Date:Message-ID:MIME-Version; b=a6eVhT2OwiYI8v+scrxYvEUTcLc2Q/LxoD727dHXsJUNe+QHuBt6PTQ9k1nqKRetqW9LrrdptOHPe6UQi0XCNJIcJylyWR4dCjKxw7f9MHDnHLgQmydSgYYp4Mg/2SdplZ/WJGMtKB58iWGdqZhC0f89YiAb/Dtp9JOvQiaj2HM= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dmarc=none (p=none dis=none) header.from=kylinos.cn; spf=pass smtp.mailfrom=gmail.com; arc=none smtp.client-ip=209.85.214.194 Authentication-Results: smtp.subspace.kernel.org; dmarc=none (p=none dis=none) header.from=kylinos.cn Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=gmail.com Received: by mail-pl1-f194.google.com with SMTP id d9443c01a7336-2b7d3ecc10dso85516905ad.2 for ; Thu, 14 May 2026 19:42:53 -0700 (PDT) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20251104; t=1778812973; x=1779417773; h=content-transfer-encoding:mime-version:message-id:date:subject:cc :to:from:x-gm-gg:x-gm-message-state:from:to:cc:subject:date :message-id:reply-to; bh=4Aw406Z/bDeAb/8cnQR6EZYZdQ7hDrALLaolxxatQFo=; b=MPXcLZ/MpGb5kSjqk0+O6Gw0oSnVk4DZmM+Ie0gaPhK8nM6K4ZQ0mJxZCQ+YvDv/FU 8eTU7nwR0dK79353GpY04X7fprx3vNtUJiYBeCiWnmVj7rVjWANmFTU+blCk6VCSDLN4 HG8GximEXrVjT8Bz6+ivLOHMoYuMq5+EOEdQRJe9tFSbq3/4AIRLZ+dXunJknLznJuac ifaAHnivCmUhblwzB5en0yrkDusHhNEIQg6/te4ans51sx5oMLMlXPOV6NPIZbDv8pe1 Lsi4/R3ldsPbjtnwtyySixl6fjrFirr2AC9IGIYXVq60HevMpALViA3UIy9M4w7P3AFI 8C9w== X-Forwarded-Encrypted: i=1; AFNElJ9AJ9QTqeUVWz7x3DxnwjVzrGHn0AQ8wBeZNDURmk1PhUBSNI2/X4aB558ud3R936Qgp7LM4EyEZtfiT/Y=@vger.kernel.org X-Gm-Message-State: AOJu0YyCnd4G+AtFo834UONqxG/KoynTjFSHYq83uwawQ0D7Yi92V+R+ XfwIhTlAoLd1/0IL+c/KsVJuoo0Ytg1llFP5d3muWiXh/PL+r3JMEP/1 X-Gm-Gg: Acq92OG3cz5dazYJEX7ycckIPv7jfzhvErZj3ccYKczvGoJk5sykJ/srK5cSsKMH2g2 bH8QxZcZvrJ/lGPjRxjrEcVdV/nV8P28vlGCdv0ACRLaZoe1cTRdhGgGfv4XfprliSbKphz2XH7 dgnz4n7KVS4iasfY3hlRTy5DuySazAijhQFnroBPTREhXQk/vXV/8f8J/jvdu0Ng9ZHgFJuBRux MCBCOik1BP3eSPL7iaNRXLw5GnDy+I/4NmfNluIE0HThUK3EBZVXlirHC9N3iKaarpu1Ks7dcj8 ixwHQIEBw6KdKhYy2D2HKUyPRw3UzY4LGuZUqTH1Hv8RyYaZcI/MvxFyjTx5iUf5r58ecE9rUtc l7QTqqYQnLuuvbLctz5Q6OYT2U+8vul3cVCyy0mEZnMGmFgE6nM6vj9lV47YZU7FgHsTyv5yhje IG+FNrwJ8r6FEGc8HUhd4qtSaj0/fMQSqNTK/j+odj6tSmRiQHbIYHF8s= X-Received: by 2002:a17:902:a618:b0:2ba:83f8:7b7b with SMTP id d9443c01a7336-2bd7e8bd396mr17197255ad.33.1778812972921; Thu, 14 May 2026 19:42:52 -0700 (PDT) Received: from kylin-XiaoXinPro-16-AHP9.. ([116.128.244.171]) by smtp.gmail.com with ESMTPSA id d9443c01a7336-2bd791e0b06sm17134095ad.22.2026.05.14.19.42.48 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 14 May 2026 19:42:52 -0700 (PDT) From: Xueqin Luo To: rafael@kernel.org, viresh.kumar@linaro.org, zhanjie9@hisilicon.com, zhenglifeng1@huawei.com, pierre.gondois@arm.com, sumitg@nvidia.com, linux-pm@vger.kernel.org, linux-kernel@vger.kernel.org Cc: Xueqin Luo Subject: [PATCH v5] cpufreq: cppc: mask Desired_Excursion when autonomous selection is enabled Date: Fri, 15 May 2026 10:42:42 +0800 Message-ID: <20260515024242.14196-1-luoxueqin@kylinos.cn> X-Mailer: git-send-email 2.43.0 Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable Content-Type: text/plain; charset="utf-8" According to the ACPI 6.6 specification, the Desired_Excursion field is not utilized when autonomous selection is enabled. In this mode, the bit is architecturally ignored and does not carry meaningful information. Currently, the kernel exposes the raw Performance Limited register value to userspace through the cpufreq sysfs interface. This may lead to misinterpretation, as userspace may assume Desired_Excursion is valid even when autonomous selection is active. To provide a stable and semantically correct ABI, mask out the Desired_Excursion bit when autonomous selection is enabled, so that userspace does not observe undefined or misleading values. Writes are left unchanged, as the field is architecturally ignored in this mode and write attempts are harmless. Signed-off-by: Xueqin Luo Reviewed-by: Pierre Gondois Reviewed-by: Sumit Gupta --- v4 -> v5 : - Return -EINVAL instead of success when cpufreq policy is unavailable, addressing Sumit Gupta's review comments. --- drivers/cpufreq/cppc_cpufreq.c | 29 ++++++++++++++++++++++++++++- 1 file changed, 28 insertions(+), 1 deletion(-) diff --git a/drivers/cpufreq/cppc_cpufreq.c b/drivers/cpufreq/cppc_cpufreq.c index 7e7f9dfb7a24..bf5175f7551c 100644 --- a/drivers/cpufreq/cppc_cpufreq.c +++ b/drivers/cpufreq/cppc_cpufreq.c @@ -982,7 +982,34 @@ store_energy_performance_preference_val(struct cpufreq= _policy *policy, return count; } =20 -CPPC_CPUFREQ_ATTR_RW_U64(perf_limited, cppc_get_perf_limited, +static int cppc_get_perf_limited_filtered(int cpu, u64 *perf_limited) +{ + struct cpufreq_policy *policy; + struct cppc_cpudata *cpu_data; + int ret; + + ret =3D cppc_get_perf_limited(cpu, perf_limited); + if (ret) + return ret; + + policy =3D cpufreq_cpu_get_raw(cpu); + if (!policy) + return -EINVAL; + + cpu_data =3D policy->driver_data; + + /* + * Desired Excursion is ignored when autonomous selection is + * enabled. Clear the bit to avoid exposing meaningless state + * to userspace. + */ + if (cpu_data && cpu_data->perf_ctrls.auto_sel) + *perf_limited &=3D ~CPPC_PERF_LIMITED_DESIRED_EXCURSION; + + return 0; +} + +CPPC_CPUFREQ_ATTR_RW_U64(perf_limited, cppc_get_perf_limited_filtered, cppc_set_perf_limited) =20 cpufreq_freq_attr_ro(freqdomain_cpus); --=20 2.43.0