From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from smtpbguseast2.qq.com (smtpbguseast2.qq.com [54.204.34.130]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 7E2103AAF49; Fri, 18 Sep 2026 09:12:02 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=54.204.34.130 ARC-Seal:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1789722729; cv=none; b=suqLjXJLaexYBEHK6fd8otI2TDRE2bf9xwzT4N1i9Y+lWnmvzoJ1Bfs/G2EzB+V+6/EzMVlBSvS/feXi5ckBIS57Sv7B568cPbQeyFYOzv7eUTUTE1JekjMiFdF31puAjeIEXNikLte603zqMCbN5zFKMK13/aD6+Yrhz6/pBpM= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1789722729; c=relaxed/simple; bh=g7wfjJEL8gVj/CIJMly7y7ctAD3Uac7c8Z190Y6bP+g=; h=From:To:Cc:Subject:Date:Message-Id:In-Reply-To:References: MIME-Version; b=fGBJOU8r5jqeNtSC1diVn/IlJCtOxpb27i+AAd/OGfBm+v8BaGNM8rlmMhm7ovqOHTDbzxZdGHei/XRpd9Vm5VXAN3S1Zh23BIWoL+JQbVyC+DBERRj9vTuUAgYso7SMuwxMtUpTifd4yVulAxqVYEdUIpWaLZxBEUaUWBK2SZQ= ARC-Authentication-Results:i=1; smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=uniontech.com; spf=pass smtp.mailfrom=uniontech.com; dkim=pass (1024-bit key) header.d=uniontech.com header.i=@uniontech.com header.b=ZaFWGK1z; arc=none smtp.client-ip=54.204.34.130 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=uniontech.com Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=uniontech.com Authentication-Results: smtp.subspace.kernel.org; dkim=pass (1024-bit key) header.d=uniontech.com header.i=@uniontech.com header.b="ZaFWGK1z" DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=uniontech.com; s=onoh2408; t=1789722690; bh=vfmQoCbf3aPR+Q4tJH4y0MAOS76O3srgC81W3d4qba8=; h=From:To:Subject:Date:Message-Id:MIME-Version; b=ZaFWGK1zrdg4tJ78KcIM8AdRqefA3q0kPGdQ1vD9H1a618awmlNfxHkrw1PcD4sXz iJzjOMKF/+BKshfd6aCYJr7QHINKSE+oVPxyRkoK9oSl8KJO+Izp++COvBoWeT5V1M xaR9FKP2bZc4H1USts8EwiEsySFydn+tbf/xXb44= X-QQ-mid: zesmtpsz7t1789722671t3d6fea4e X-QQ-Originating-IP: wUWN+trQuf5Xsuoapoek2ccn3WeJL1Zum6UXO5Gi2Y4= Received: from localhost.localdomain ( [113.57.152.160]) by bizesmtp.qq.com (ESMTP) with id ; Fri, 18 Sep 2026 17:11:09 +0800 (CST) X-QQ-SSF: 0000000000000000000000000000000 X-QQ-GoodBg: 1 X-BIZMAIL-ID: 4785908314946589804 EX-QQ-RecipientCnt: 9 From: Wentao Guan To: kprateek.nayak@amd.com Cc: guanwentao@uniontech.com, linux-kernel@vger.kernel.org, linux-pm@vger.kernel.org, ray.huang@amd.com, ronforever@outlook.com, scardracs@disroot.org, stable@vger.kernel.org, superm1@kernel.org Subject: [PATCH v3] cpufreq/amd-pstate: Skip auto_sel write when it already matches the mode Date: Fri, 18 Sep 2026 17:09:10 +0800 Message-Id: <20260918090909.86544-1-guanwentao@uniontech.com> X-Mailer: git-send-email 2.30.2 In-Reply-To: References: Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-QQ-SENDSIZE: 520 Feedback-ID: zesmtpsz:uniontech.com:qybglogicsvrgz:qybglogicsvrgz3a-0 X-QQ-XMAILINFO: NZDQV+yaJ13ifOX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cjmiiknXRT1ZOSrlfaGaBvY+9u7VM4mVRACcnv3a9nj54 wpb+zrg6TZ/7GSeqnJLCXOdUvC9Mbo1M9OBe5V/FzqvsxudxJrulB7jJH9M5HziH1H/yBzw uMXEGzK3CqyadyiUjYp7f5CPig== X-QQ-XMRINFO: Nq+8W0+stu50tPAe92KXseR0ZZmBTk3gLg== X-QQ-RECHKSPAM: 0 Since commit 9dfd13f80c85 ("cpufreq/amd-pstate: Toggle auto_sel in active mode on shared memory systems"), shmem_init_perf() programs AUTONOMOUS_SELECTION_ENABLE unconditionally, including in active mode. Platforms that exclusively support autonomous selection report this field as an Integer of 1, as required by the ACPI specification, instead of as a register descriptor. cppc_get_reg_val() reads such a field back successfully, but cppc_set_reg_val() rejects the write with -EOPNOTSUPP because the entry is not an ACPI_TYPE_BUFFER. shmem_init_perf() propagates that error, so every amd_pstate_epp_cpu_init() fails, cpufreq_register_driver() ends up with an empty policy list and returns -ENODEV, and amd-pstate refuses to load at all: amd_pstate: failed to set auto_sel, ret: -95 amd_pstate: Failed to initialize CPU 0: -95 ... amd_pstate: failed to register with return -19 Skip the write when the register already holds the value the requested mode needs. Active and guided mode are fixed on these platforms, which report auto_sel as 1, while passive mode still fails to load on a platform that cannot disable autonomous selection, exactly as it did before the offending commit. Fixes: 9dfd13f80c85 ("cpufreq/amd-pstate: Toggle auto_sel in active mode on shared memory systems") Cc: stable@vger.kernel.org Reviewed-by: K Prateek Nayak Tested-by: K Prateek Nayak Tested-by: LFRon Signed-off-by: Wentao Guan --- changelog v3: Include the K Prateek Nayak reviews to remove that ternary op base on current condition now have. v2 link: https://lore.kernel.org/stable/c3eb86bd-70a6-4bb2-8eff-b2a3c0817514@amd.com/#R changelog v2: Accecpt and tested the K Prateek Nayak reviews. v1 link: https://lore.kernel.org/stable/20260918054808.48999-1-guanwentao@uniontech.com/#R --- --- drivers/cpufreq/amd-pstate.c | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/drivers/cpufreq/amd-pstate.c b/drivers/cpufreq/amd-pstate.c index 80d99ba1902c9..2d1f5292d1738 100644 --- a/drivers/cpufreq/amd-pstate.c +++ b/drivers/cpufreq/amd-pstate.c @@ -532,8 +532,10 @@ static int shmem_init_perf(struct amd_cpudata *cpudata) return 0; } - ret = cppc_set_auto_sel(cpudata->cpu, - (cppc_state == AMD_PSTATE_PASSIVE) ? 0 : 1); + if ((cppc_state != AMD_PSTATE_PASSIVE) == auto_sel) + return 0; + + ret = cppc_set_auto_sel(cpudata->cpu, !auto_sel); if (ret) pr_warn("failed to set auto_sel, ret: %d\n", ret); -- 2.30.2