From nobody Tue Jun 16 17:04:21 2026 Received: from mail-pj1-f66.google.com (mail-pj1-f66.google.com [209.85.216.66]) (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 270AA3A0B31 for ; Thu, 30 Apr 2026 09:23:03 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=209.85.216.66 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1777540986; cv=none; b=Ea1vDSXtIQXIWFqTRoJbXbVHnfCz5QCMNTH0jN6v/rE98KX85TDNa4eG7CCY8hVqRTHsuYUt9Xvt6bTjOL/PltFP1wvhG/NcmZayU1gumvhLFs50M2SQKWIW+NkL82qExv7Fo7QBCuiroquwQYY3VDhswIj1WFOP5V7rBs6/0vw= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1777540986; c=relaxed/simple; bh=sqq/qPSKz1lViJOySSG2d+4zaWxQDSGoekBXbovqVhs=; h=From:To:Cc:Subject:Date:Message-ID:MIME-Version; b=kSkhuLzBSQWuzcE4TeUGfaNGVU9i8j85anZzWZlfNakX/eSGhhrp1J7OCR/xbWJZggnbb2d+JZv+3NuKKDt9ZEhQLerPb6ZXKqoqOznvRuO58gNxQbUEpz6VbOyYRdWNc3ZP5Pnebcj9Dv0biKK8S18m7yy/958d7hoavGXhOe4= 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.216.66 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-pj1-f66.google.com with SMTP id 98e67ed59e1d1-362bb3260f1so456501a91.2 for ; Thu, 30 Apr 2026 02:23:03 -0700 (PDT) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20251104; t=1777540983; x=1778145783; 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=4qtfW4eKcGs69USuhwrOvQAdJOTpdNYJT///RBfXHr4=; b=W/o9/aDvZZffOeXHVVODQ6WOc/fLHJYkjKwkQ+ICyn3JnNP+rGbCQxP7uvFXrfFrcc WZagl/Y0ESf79Z+R47DHX6r+39GwyzuYguDnhz5cM1sBSwyLXvNvxgf7DEqAOOsUNpAq 5AL8Tdt1iI8NHW9NsdA0/yeKFlPm4RWLTNTyrhyCDlD4LfyUbFJNKPHKTDirImkbuNCK 75g9K3sCdDfcp9wkAsxbIYZ/w8twbEZK6JI27lQ3qBwn0WbMqPgvz0RYPaceqtqU/I1p rQnmEx9rJF7qQLEzhLPgtRMFH74UPv9EyuJpIBhESbPA3TFw9DOJ5clzku3kBE7CvXt6 E/Yg== X-Forwarded-Encrypted: i=1; AFNElJ89NNof02QRMCGVYTBqFU0hjfyPPqewvKZS8ixntR9ncXfmKmygrZs26R34t43dJYc5/g54qvM8ZGzRWqs=@vger.kernel.org X-Gm-Message-State: AOJu0YwlF+Yoo07XBKPl7yf9Byyf0Tmwm6lGrh6SA/pnQouU/Qn7h/mN Az+1TnEub1rxXP8015ZnQh7uwtfw80cyUTphzOgNNE3uxtGkTwBqhLUP X-Gm-Gg: AeBDiesGJ8BxFMkGs/U6JDtmRnrJ7wdcD63uOT17DWyVk1XhbeQgljxviujEwBovsRb /hfnlSCZUU8U2yG9dA1BgwIjREyL3/+41ovLdMnySR5Zok+KuYszCejYAd0T7/B507PrPd8avuJ k6Cn1bk5nDswtudRYhXUXuF0MjLeI5iREyDyBW7ML43636X7awlJnQNp8LU7Hd5pqHc1Pdbhv5f 23CmquDNFUpYTp0VzVWd1X5BbetQvWiIHZiGq6spgcFFNAbeII5srEIi/91h2WrGkJhPP6j4r+7 bCqlR+WDd1la/esKUU5uRCPAtFsZe8hOWYK9qsGm2QhVT97eb6cIdnUz0R/CTLRyRGLwiV2Lyiz mYj6k5NwneBM90fu1dX8aA68qB9/5EnqvciwMz9D2u/3WY7p2KSC2cdOmfuHY0pl8dTft+PDxoJ rgm0MwFGs21JrMKOGtQALRtJkN300F202J9ZsncXQnwHUVBLPa65LLJZHy X-Received: by 2002:a17:90b:4a90:b0:361:472e:3be6 with SMTP id 98e67ed59e1d1-364c3161d69mr2093615a91.26.1777540983253; Thu, 30 Apr 2026 02:23:03 -0700 (PDT) Received: from kylin-XiaoXinPro-16-AHP9.. ([116.128.244.171]) by smtp.gmail.com with ESMTPSA id 98e67ed59e1d1-364bdf81f3fsm2086722a91.14.2026.04.30.02.22.57 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 30 Apr 2026 02:23:02 -0700 (PDT) From: luoxueqin 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 v2] ACPI: CPPC: mask Desired_Excursion when autonomous selection is enabled Date: Thu, 30 Apr 2026 17:22:50 +0800 Message-ID: <20260430092250.380996-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" From: Xueqin luo According to the ACPI 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 --- v2: update subject drivers/cpufreq/cppc_cpufreq.c | 40 ++++++++++++++++++++++++++++++++-- 1 file changed, 38 insertions(+), 2 deletions(-) diff --git a/drivers/cpufreq/cppc_cpufreq.c b/drivers/cpufreq/cppc_cpufreq.c index 7e7f9dfb7a24..c7444a6ceb55 100644 --- a/drivers/cpufreq/cppc_cpufreq.c +++ b/drivers/cpufreq/cppc_cpufreq.c @@ -982,8 +982,44 @@ store_energy_performance_preference_val(struct cpufreq= _policy *policy, return count; } =20 -CPPC_CPUFREQ_ATTR_RW_U64(perf_limited, cppc_get_perf_limited, - cppc_set_perf_limited) +static ssize_t show_perf_limited(struct cpufreq_policy *policy, char *buf) +{ + bool auto_sel_enabled =3D false; + u64 perf_limited; + int ret; + + /* Get Autonomous Selection status */ + ret =3D cppc_get_auto_sel(policy->cpu, &auto_sel_enabled); + if (ret) { + if (ret =3D=3D -EOPNOTSUPP) + auto_sel_enabled =3D false; + else + return ret; + } + + /* Read the Performance Limited register */ + ret =3D cppc_get_perf_limited(policy->cpu, &perf_limited); + if (ret) + return ret; + + /* + * Desired_Excursion is architecturally ignored when Autonomous + * Selection is enabled. Mask it to avoid exposing undefined + * semantics to userspace. + */ + if (auto_sel_enabled) + perf_limited &=3D ~CPPC_PERF_LIMITED_DESIRED_EXCURSION; + + return sysfs_emit(buf, "%llu\n", perf_limited); + +} + +static ssize_t store_perf_limited(struct cpufreq_policy *policy, + const char *buf, size_t count) +{ + return cppc_cpufreq_sysfs_store_u64(policy->cpu, + cppc_set_perf_limited, buf, count); +} =20 cpufreq_freq_attr_ro(freqdomain_cpus); cpufreq_freq_attr_rw(auto_select); --=20 2.43.0