From patchwork Mon Feb 17 22:06:50 2025 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Mario Limonciello X-Patchwork-Id: 13978715 X-Patchwork-Delegate: mario.limonciello@amd.com Received: from smtp.kernel.org (aws-us-west-2-korg-mail-1.web.codeaurora.org [10.30.226.201]) (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 0BA741AAA1E; Mon, 17 Feb 2025 22:07:35 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=10.30.226.201 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1739830056; cv=none; b=jkcJqcxNR7aV3EMgpSjTQmV8SL62QtMzKhDMwE8HtvPBRH13z8CXUy5VUmQ/k6cTzs8sEJmQVP1XDuy1FAxYNgvpPCXt9i36gjaJrB5WnWhFPMJx2rPTmNXqqpFlOQ+34G7T/HeqGxDItOtD8yABr8douuIZX91cRhH3bMPZAb0= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1739830056; c=relaxed/simple; bh=qnWckhc5xEP2wymnIaXzYxBCkGAS/iWDlS6Mi83SLwY=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=jO6Y0V5kk14mWhUrwlvmb+zYXzzDjE5Q4TELoxtfAjHAWCvECRd+L51JM7ol1aINOpW5uMDBrKIcNpbf0EQLAOYDhcKVQI82IvT7wjQToe1Kf/8z0vf8dU1vhs8lP3VD+GwCTwEYrcrQKhGcwzjmyzims3MzTU1spDtkFcMdhPI= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=kernel.org header.i=@kernel.org header.b=ubAH0PtP; arc=none smtp.client-ip=10.30.226.201 Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=kernel.org header.i=@kernel.org header.b="ubAH0PtP" Received: by smtp.kernel.org (Postfix) with ESMTPSA id C678AC4CEE4; Mon, 17 Feb 2025 22:07:34 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1739830055; bh=qnWckhc5xEP2wymnIaXzYxBCkGAS/iWDlS6Mi83SLwY=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=ubAH0PtP1lUxpYyc1FzroEWdbQhjqX5b2lS3ZzEnwJGMl997p3TP//kPYmd/A/XSh t1RmPqPB0hvxgCVhkLZF7Drgn0RNAGxitEip/lFHQFkf2C2S8+6NA7dvFBfOp2bz0q t/6bRVY2v1Epx/qdJemHTzNyACll/B4PPVTlfX3KqBlfHmgxjZYMIpZQoXQ0BIyM7G nNQ5akxb8T5cVT6Avj+FDjpH/o7z1G9elHNo8GrEqIO/rnokYlTzE/ft8/uhltgi1S tT1KXpcIvMZ+L2vfEw7q79B7iLzCza2H/7GHEIelX4c8xgjlBQRTRllqsosf2Rs5kv cNk8Y8XplFVcw== From: Mario Limonciello To: "Gautham R . Shenoy" , Perry Yuan Cc: Dhananjay Ugwekar , linux-kernel@vger.kernel.org (open list:X86 ARCHITECTURE (32-BIT AND 64-BIT)), linux-pm@vger.kernel.org (open list:CPU FREQUENCY SCALING FRAMEWORK), Mario Limonciello , Miroslav Pavleski Subject: [PATCH v3 01/18] cpufreq/amd-pstate: Invalidate cppc_req_cached during suspend Date: Mon, 17 Feb 2025 16:06:50 -0600 Message-ID: <20250217220707.1468365-2-superm1@kernel.org> X-Mailer: git-send-email 2.43.0 In-Reply-To: <20250217220707.1468365-1-superm1@kernel.org> References: <20250217220707.1468365-1-superm1@kernel.org> Precedence: bulk X-Mailing-List: linux-pm@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 From: Mario Limonciello During resume it's possible the firmware didn't restore the CPPC request MSR but the kernel thinks the values line up. This leads to incorrect performance after resume from suspend. To fix the issue invalidate the cached value at suspend. During resume use the saved values programmed as cached limits. Reported-by: Miroslav Pavleski Closes: https://bugzilla.kernel.org/show_bug.cgi?id=217931 Signed-off-by: Mario Limonciello Reviewed-by: Gautham R. Shenoy Reviewed-by: Dhananjay Ugwekar --- drivers/cpufreq/amd-pstate.c | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/drivers/cpufreq/amd-pstate.c b/drivers/cpufreq/amd-pstate.c index f425fb7ec77d7..12fb63169a24c 100644 --- a/drivers/cpufreq/amd-pstate.c +++ b/drivers/cpufreq/amd-pstate.c @@ -1611,7 +1611,7 @@ static int amd_pstate_epp_reenable(struct cpufreq_policy *policy) max_perf, policy->boost_enabled); } - return amd_pstate_update_perf(cpudata, 0, 0, max_perf, cpudata->epp_cached, false); + return amd_pstate_epp_update_limit(policy); } static int amd_pstate_epp_cpu_online(struct cpufreq_policy *policy) @@ -1660,6 +1660,9 @@ static int amd_pstate_epp_suspend(struct cpufreq_policy *policy) if (cppc_state != AMD_PSTATE_ACTIVE) return 0; + /* invalidate to ensure it's rewritten during resume */ + cpudata->cppc_req_cached = 0; + /* set this flag to avoid setting core offline*/ cpudata->suspended = true;