Received: by 2002:a05:6a10:af89:0:0:0:0 with SMTP id iu9csp4468659pxb; Tue, 18 Jan 2022 20:54:28 -0800 (PST) X-Google-Smtp-Source: ABdhPJwuGyS7u2skgepAVA6sQmqJ0MZUvylSv0ZdiFzUzIEr/SORKW7NfZQIdXm1p/AuX9TRJJB0 X-Received: by 2002:a63:7c07:: with SMTP id x7mr26138242pgc.549.1642568067845; Tue, 18 Jan 2022 20:54:27 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1642568067; cv=none; d=google.com; s=arc-20160816; b=gz+7mvavM4SU5bk8cm5hLVq0VOjk0uySwoMKlAlDNfem5HNJL6oqd3bPNkzRJjFjJE s/h3vYs5l9gvDz2dwi9EUmYyitx4gAESf0A/dLqv0VLuwJWcsTOy3wTc2h3Drk2ITyWg TLGOntTBQJodRQb1CCBe3+AZZHvm8ekwshiMMrnkq8m0+1SNVP2Fd9JJ+vWs0gcF/TRB 7AFz3qhez/RmrVA6/BtwQH/xqM2REMwN01aaLSx4dtoWY7G7ck4COGgCPcVXN3fM3T9T rxxOhQFaLM6hwCIwwQbJGAhWaBknu8oxLyFV3zO/vdudwJ19NTCqhA2rhQTy+PvZxQ1Z d5xg== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:content-transfer-encoding:mime-version :references:in-reply-to:message-id:date:subject:cc:to:from :dkim-signature; bh=OdIkXwN7KOYBDbRBCcxY+9/ORdd5GKVTmtXH1Zhrv5k=; b=KFb2rIKJPadoiFBAFRnwK2KLsk78gg7aFm5aevDBEtj3KuD6AZcPZ2RNpGSRXvCW2j yfROebJk5JVhDSzdq8jXVybwnPFOYYVIrCTfbrneCAQGx8euSqOCSa/lCLKtc0IwwajO 2z3cfhEKVd2goXkmYziywATc5rxwlGD2Y2rSUs8uCsbIeXqmybON1rFADxft1Rkwf5Hm DAdx2PcLyejRT7Ox9fpfTrYihLF4OiZoe+ArYPl79xHsKbK6H97CkgDVrOCSSQAg9OSG 2Zc4sInnTDL5yhSrt/pempaEQVvs9AKE7ovG+I2MzC+yhrHoneHi6M8bPaIcFAYKhC2X yYEA== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@kernel.org header.s=k20201202 header.b=d4nnVjMd; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=kernel.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [23.128.96.18]) by mx.google.com with ESMTP id p10si6242098pgi.19.2022.01.18.20.53.52; Tue, 18 Jan 2022 20:54:27 -0800 (PST) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) client-ip=23.128.96.18; Authentication-Results: mx.google.com; dkim=pass header.i=@kernel.org header.s=k20201202 header.b=d4nnVjMd; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=kernel.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1349726AbiARCuI (ORCPT + 99 others); Mon, 17 Jan 2022 21:50:08 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:58684 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1345445AbiARCbd (ORCPT ); Mon, 17 Jan 2022 21:31:33 -0500 Received: from dfw.source.kernel.org (dfw.source.kernel.org [IPv6:2604:1380:4641:c500::1]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 51F8FC08C5FE; Mon, 17 Jan 2022 18:29:14 -0800 (PST) Received: from smtp.kernel.org (relay.kernel.org [52.25.139.140]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by dfw.source.kernel.org (Postfix) with ESMTPS id E3D4E611E1; Tue, 18 Jan 2022 02:29:13 +0000 (UTC) Received: by smtp.kernel.org (Postfix) with ESMTPSA id 72B2FC36AE3; Tue, 18 Jan 2022 02:29:12 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1642472953; bh=f+dbat/CJSJVFyT6hmh4BxcsvT3LVH/CfNKQCr+Nvgg=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=d4nnVjMdm8Wf5XtFBX478voeqxv3e4yeXWmZwjSGRIVuSSVUkdWi8M6PJKszoyj57 UK3cBJ8O5O6XvYjOG0sk22fdcLItk8csT+sAOpmhJvCy7yQnQTl8POLTi/sXsl31CZ 9yg2/6AyVLMan4+GfrzKi7QHn9IqDjxJbWEaGrTVAT0KqAxFctFyz1hS/g1ZQYB9Vf hNNshFck4LiA/qLMP59L/zXdKTF+lidx+T7Y3nd2QwesWMl97lLszoXTWJ83TE5ISg Fx6ZoPBD99QwQDcby0rFuE3fmHHNP7iwgWG1WUBeRVL8NDzrUem+hsZKwUG2hFxh+o weYy8Uv7SK8wQ== From: Sasha Levin To: linux-kernel@vger.kernel.org, stable@vger.kernel.org Cc: "Rafael J. Wysocki" , Srinivas Pandruvada , Sasha Levin , lenb@kernel.org, rafael@kernel.org, linux-pm@vger.kernel.org Subject: [PATCH AUTOSEL 5.16 174/217] cpufreq: intel_pstate: Update cpuinfo.max_freq on HWP_CAP changes Date: Mon, 17 Jan 2022 21:18:57 -0500 Message-Id: <20220118021940.1942199-174-sashal@kernel.org> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20220118021940.1942199-1-sashal@kernel.org> References: <20220118021940.1942199-1-sashal@kernel.org> MIME-Version: 1.0 X-stable: review X-Patchwork-Hint: Ignore Content-Transfer-Encoding: 8bit Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org From: "Rafael J. Wysocki" [ Upstream commit dfeeedc1bf5772226bddf51ed3f853e5a6707bf1 ] With HWP enabled, when the turbo range of performance levels is disabled by the platform firmware, the CPU capacity is given by the "guaranteed performance" field in MSR_HWP_CAPABILITIES which is generally dynamic. When it changes, the kernel receives an HWP notification interrupt handled by notify_hwp_interrupt(). When the "guaranteed performance" value changes in the above configuration, the CPU performance scaling needs to be adjusted so as to use the new CPU capacity in computations, which means that the cpuinfo.max_freq value needs to be updated for that CPU. Accordingly, modify intel_pstate_notify_work() to read MSR_HWP_CAPABILITIES and update cpuinfo.max_freq to reflect the new configuration (this update can be carried out even if the configuration doesn't actually change, because it simply doesn't matter then and it takes less time to update it than to do extra checks to decide whether or not a change has really occurred). Reported-by: Srinivas Pandruvada Tested-by: Srinivas Pandruvada Signed-off-by: Rafael J. Wysocki Signed-off-by: Sasha Levin --- drivers/cpufreq/intel_pstate.c | 24 +++++++++++++++++------- 1 file changed, 17 insertions(+), 7 deletions(-) diff --git a/drivers/cpufreq/intel_pstate.c b/drivers/cpufreq/intel_pstate.c index dec2a5649ac1a..676edc580fd4f 100644 --- a/drivers/cpufreq/intel_pstate.c +++ b/drivers/cpufreq/intel_pstate.c @@ -1124,19 +1124,22 @@ static void intel_pstate_update_policies(void) cpufreq_update_policy(cpu); } +static void __intel_pstate_update_max_freq(struct cpudata *cpudata, + struct cpufreq_policy *policy) +{ + policy->cpuinfo.max_freq = global.turbo_disabled_mf ? + cpudata->pstate.max_freq : cpudata->pstate.turbo_freq; + refresh_frequency_limits(policy); +} + static void intel_pstate_update_max_freq(unsigned int cpu) { struct cpufreq_policy *policy = cpufreq_cpu_acquire(cpu); - struct cpudata *cpudata; if (!policy) return; - cpudata = all_cpu_data[cpu]; - policy->cpuinfo.max_freq = global.turbo_disabled_mf ? - cpudata->pstate.max_freq : cpudata->pstate.turbo_freq; - - refresh_frequency_limits(policy); + __intel_pstate_update_max_freq(all_cpu_data[cpu], policy); cpufreq_cpu_release(policy); } @@ -1584,8 +1587,15 @@ static void intel_pstate_notify_work(struct work_struct *work) { struct cpudata *cpudata = container_of(to_delayed_work(work), struct cpudata, hwp_notify_work); + struct cpufreq_policy *policy = cpufreq_cpu_acquire(cpudata->cpu); + + if (policy) { + intel_pstate_get_hwp_cap(cpudata); + __intel_pstate_update_max_freq(cpudata, policy); + + cpufreq_cpu_release(policy); + } - cpufreq_update_policy(cpudata->cpu); wrmsrl_on_cpu(cpudata->cpu, MSR_HWP_STATUS, 0); } -- 2.34.1