From nobody Tue Jun 16 17:03:59 2026 Received: from mail-pj1-f67.google.com (mail-pj1-f67.google.com [209.85.216.67]) (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 EF88D38F95B for ; Thu, 30 Apr 2026 08:10:47 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=209.85.216.67 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1777536651; cv=none; b=jFxzVLk6CC6sCFiGZ98LuXrXjC/WpNcSfF6N4KtWqfbMb3RAZpXbtAXPEEWzj9XXRW3ICHez31RlLCLCve3ToVktmSMSNuOXYzzbM2r2gaTEcAdGFTK9yrVVh5C23HXPiObZvMG1ChI150fXoJ1Kwe1zWE+w3iqYfx+v5Di0I8E= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1777536651; c=relaxed/simple; bh=gUTTShATbbYifleGHcJx237FPLs17oYKKLqFvMOgfkg=; h=From:To:Cc:Subject:Date:Message-ID:MIME-Version; b=pD214BBNeEw+E2XOEyJ8Fov1NY3TmYCVF0B5WI3l8cWk1sVgaug3FgTke/hO7PZwx/UwW1Kz0CXN9s0PGN56zbyIBulaVCa848FxbYhrmfAj0KNEUItgflHoPV2wtwQ3RgzV7hIHYiCw4ZDfgAQKMU3M5hARAphkpPyDJsXDCDg= 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.67 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-f67.google.com with SMTP id 98e67ed59e1d1-362e30526f8so254074a91.3 for ; Thu, 30 Apr 2026 01:10:47 -0700 (PDT) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20251104; t=1777536647; x=1778141447; 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=7/+MHZ+y0Q4fMJhPFmuJZnC9anV3GSr5sZ/H7ZHsam4=; b=TIPx2cDILHHW60o51rCNkE6BiYEDZgyTKR6oYf3DyUV4hyNdeGRKVz+CejUg3ye44N TiUsVpRLAjqsLR/5XyX9TV8qcOLZqMzaIhydtCwtH694hg6G0ng/7cLihFjuWKdYaR6J zeFiUeg6H51FK6lDLO4pywW4v0Y0yF3J7F+KoHjD1UY42bgKPvqB8xixWgEqVEq+eSPE snP3a3lOarGOXVIjXRn52ds9fEVcaoEB5nAfuOz759NJqyB2doiwT/qnTO70ZzCD+0Pm iaYZ2wL5Dklq7V8+3U1bLdArr1QJwfIl7NbdYHzm5YQSgwbEHGaJCswL4yKg0lHE3VPj +EFw== X-Forwarded-Encrypted: i=1; AFNElJ/hNRaa8Jok9EkAJ/mhJnRkiHxTd7erDVd1VeD+srvHGKNRGzxSYkqze8jMwZ0kQVjNiaSfuXaSUmaHNJY=@vger.kernel.org X-Gm-Message-State: AOJu0YxHRD4t4WuQORWUYvEUkbETlYlxvjqtSUctfijPzPThBEk2qj1P OInNq725YHLbn1KbdUqpklmUf2U3kWvAQlHkoshkt1lSkTYt2xz2YUCP X-Gm-Gg: AeBDieu/RhZ4WQDo0TUPraqu4n0RU3EZiq7XfsJkNv8r2+W3/gOUOns9ZfpLSC6ZGsb w04imzKIHiVA+/pZSGrcAikpUIWG4bi32xgx/sqJ6Xy5Z9nVUdFdFWmkiiGbhFyIEVd4s9PBJS5 J2YrkVaEKH11JGwvYDziY89DiaAFuABbJymFtVlmJMZbOQkf33ntVvg9CNkQP2Fg4j3jEiq/taD U1XP6pBuRMuEtYntlCaPBDV0CvRQojXI548fQKN3MaxBd1Btw0y3JZcUoO3qHeCNe5vvV+Jry9q TB9XZfWA/yPHM4Tv1Vai+8/Dbakm8sGJYyQt1++XTBLXtHGZWKXhAjsHm8AXzO8EILJ98jWwNY8 TkUoB71MTnoEyCcJUk6Hm82nziKiMeqgZKtQ5PcVfWgWMtl0U65tgKUEWb0dLHfVJxQVgIC8iI5 F0TlnrtaaCHHvgxDydkqz50BcL3xd+2CHlRp/qkrRmUS+QEmtxy6++ZJOW X-Received: by 2002:a17:90b:3e4f:b0:35f:bca7:5d22 with SMTP id 98e67ed59e1d1-364c2f8aecamr1831112a91.10.1777536647315; Thu, 30 Apr 2026 01:10:47 -0700 (PDT) Received: from kylin-XiaoXinPro-16-AHP9.. ([116.128.244.171]) by smtp.gmail.com with ESMTPSA id 41be03b00d2f7-c7fd6514e11sm4366458a12.30.2026.04.30.01.10.42 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 30 Apr 2026 01:10:46 -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] ACPIW: CPPC: mask Desired_Excursion when autonomous selection is enabled Date: Thu, 30 Apr 2026 16:10:36 +0800 Message-ID: <20260430081036.373723-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 --- 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