Received: by 2002:a05:6a10:af89:0:0:0:0 with SMTP id iu9csp3718785pxb; Mon, 24 Jan 2022 16:14:24 -0800 (PST) X-Google-Smtp-Source: ABdhPJznrZOA9dnT8281A9oU3uhEfFADNH6Rwe0NIKZLng8FjJU6wvd9y6gEkMU9cyI5JB+DEPRM X-Received: by 2002:a17:90a:5d8c:: with SMTP id t12mr683030pji.189.1643069664781; Mon, 24 Jan 2022 16:14:24 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1643069664; cv=none; d=google.com; s=arc-20160816; b=ZSUbYki4gGijs67dX3thvhQUyCaXzz7tyRf6jNWgHYcq3OD3ER/IzjFUbFdmLjOu33 p0RH31SpL8J1WXe2tbXM5NtOAuBATanb317QjZgi/bjhuRs8iTWI4rfqbfPvq2kFBcPu L/oYbhzCCMKevGRKu0wWvVmZVWxmWUY0Za3yDoG49m9N/ntGK9DfhvC2vVrXkQEYu2f2 90DUUrzIKU6uNjtnm5pB+DoooNWqpDicFNETUcuA9dPDbykpxw+UvGSoRGHPWECtCLtC sPvw+k22HZ2kxxQT5yckWicurzuWF+2KaMlb3l0fi5R1nhWAEl/aO3lp7jeJXBXe2U0g QNHg== 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 :user-agent:references:in-reply-to:message-id:date:subject:cc:to :from:dkim-signature; bh=nR9nw7ZMAQ8IqAG6cMsjAPN0CotTMU6W/aMhNeYV/RQ=; b=nkFfLX7ziVLD81YOqRUEjFXdTjOzKXgQbSeLHpraGvXIq3MnMAyo29ajEKAjkWrlrH M86GRTuv8J1+48soQF/R6t8eitlPTCHjoq0/hVY/IbjqQtPRW7YNzk2oyWb5zNZYfPJu MD73cEjMrE43x5pomZ4xMKS87++xsJ8AFUiGV9XxgWzO+x/Fj92cm1Z3cIOlUc8neE5c lbFWlAxoo10nsQyqYbJ3tB7kGkpeFYTYh4f5TidpRYp2Ona09WB4pWfRhBJlv8G0OH9u hJxw5peO3z4DOdwLb+L9y6iCbiNGcUCPUdBedReRDj0L4uHgRoNetzvtz+o0L+WWJHz2 04dA== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linuxfoundation.org header.s=korg header.b=T1Y8RKxc; 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=linuxfoundation.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [23.128.96.18]) by mx.google.com with ESMTP id t3si15425815pgm.312.2022.01.24.16.14.12; Mon, 24 Jan 2022 16:14:24 -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=@linuxfoundation.org header.s=korg header.b=T1Y8RKxc; 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=linuxfoundation.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S2371947AbiAYAKK (ORCPT + 99 others); Mon, 24 Jan 2022 19:10:10 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:52002 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1848335AbiAXXWP (ORCPT ); Mon, 24 Jan 2022 18:22:15 -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 7B897C01D7CF; Mon, 24 Jan 2022 13:29:03 -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 1801461500; Mon, 24 Jan 2022 21:29:03 +0000 (UTC) Received: by smtp.kernel.org (Postfix) with ESMTPSA id DB4ACC33E60; Mon, 24 Jan 2022 21:29:01 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=linuxfoundation.org; s=korg; t=1643059742; bh=XEBpaPbYCRhgT9ik4uDmR4UvypnIw4Bm8lNnbHJKlNk=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=T1Y8RKxcCcU0iivQgxXqKysMbS+DPvCgV4WCWzPZuHJ3gGyjZIHbJOHETjrYsd7OH Yv+9DzkFmaSU5fWnKOVaFPFEa4dJ+aEDQy3PXkdQt26/i3B1hepF2juYTRif0/6Tdx LlmaxZHbpwIoc1T837cN4JMSqPSRK8YCmpLggHtE= From: Greg Kroah-Hartman To: linux-kernel@vger.kernel.org Cc: Greg Kroah-Hartman , stable@vger.kernel.org, Srinivas Pandruvada , "Rafael J. Wysocki" , Sasha Levin Subject: [PATCH 5.16 0691/1039] cpufreq: intel_pstate: Update cpuinfo.max_freq on HWP_CAP changes Date: Mon, 24 Jan 2022 19:41:20 +0100 Message-Id: <20220124184148.573035013@linuxfoundation.org> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20220124184125.121143506@linuxfoundation.org> References: <20220124184125.121143506@linuxfoundation.org> User-Agent: quilt/0.66 MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 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