Received: by 2002:a05:6a10:f347:0:0:0:0 with SMTP id d7csp1486386pxu; Thu, 17 Dec 2020 11:04:51 -0800 (PST) X-Google-Smtp-Source: ABdhPJz4K8SrxmkEUn49KIaNeMTWt3y/rHqYSf7bsXZnrkmmNl/53Z6AG3Kvw21NSc9/3VFydhHD X-Received: by 2002:a05:6402:3192:: with SMTP id di18mr821154edb.332.1608231891081; Thu, 17 Dec 2020 11:04:51 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1608231891; cv=none; d=google.com; s=arc-20160816; b=x+JNFtwSmKyKmM40hXQfsNUvZN1CHdZ1F92KON9N3ktgk/Ea2yrtsnLLW0ggo3qgoE bFijYMnOTNUg+/MC3ewuAdM/eos6Fcx4YHx4FQTnCXlIPCrXBGXM5KStTVoMwAYXPGv3 NTu3Jitx9/F3MNH3SvHe4uDOsSErFWd3xvn6StPD4KAoQ1GcIQUt3HkPc7lmK1YBRneB Q3lwdnzK8+enBCG5t9YmaFp1CXx8xUmvrb4UhSo7jxT8Bq1KT8k0yIJ+QLejKRFSpoIq JRmPCAotIkUFfYTgp5TS86olnSLMNgoz0Ta3mh7peSJmTyO3DAzQ1JXCAzMybh4DHYQp eBSw== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:cc:to:subject:message-id:date:from:in-reply-to :references:mime-version; bh=sA9YAi7PjNg63O3S+VOiYgelRrbRgBxhKzHGavIAgAk=; b=vvJX+tBUZGfS7oCzWxCaPm9q1yZM6vdiuLjjRZWEf0RMsB4G1Q3jH3kZXuDddx+oNm sOhLhOpQWBKgs2xfQiWZBM5+dZgy7WPKeDdVbpDX2Du7zN/qecPNPG/YVxmFYalzctou 81BwbC+gHxqEcvTyhgO1/jzpyWbeKapwwExjRX6V8NB6y+1D+ghPWZ2mlzW1PZelZzM7 ZTv3V0SyxdtXOsPTHrjVbfr1O0LqJWEr9YIC3m+GuODljNg3x3Q38bidTKBA7j/Ak/KH 37oSZQ1dbOCkCqbtkNKQxjguOo3Wcjx98QsBYFyylYsFxs5mDtLhsjZhitCMu7hXqeUy X5rw== ARC-Authentication-Results: i=1; mx.google.com; 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 m14si3221339ejr.242.2020.12.17.11.04.27; Thu, 17 Dec 2020 11:04:51 -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; 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 S1728160AbgLQTDA (ORCPT + 99 others); Thu, 17 Dec 2020 14:03:00 -0500 Received: from mail-oi1-f179.google.com ([209.85.167.179]:42623 "EHLO mail-oi1-f179.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1726548AbgLQTDA (ORCPT ); Thu, 17 Dec 2020 14:03:00 -0500 Received: by mail-oi1-f179.google.com with SMTP id l200so15001oig.9; Thu, 17 Dec 2020 11:02:44 -0800 (PST) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:mime-version:references:in-reply-to:from:date :message-id:subject:to:cc; bh=sA9YAi7PjNg63O3S+VOiYgelRrbRgBxhKzHGavIAgAk=; b=ZtZ63/Q05UT//SyNuDC4y5L8glbxhAgsdkxtyUQbH4G2vzDvtuCyj+lzcZAWykOAx3 gqKZ+yOjqTfXEdJhpJGz6WrG2mlo5j0Hfd44LdxVLgVvArnPX+EraAmlmIuEi/BXX7bA aDhPYix9F8l1xKzTIqfqq7Yay8vvTDJEvX1TgGpTk83MsGe9TSJK0jMjLVFCn/XtlETv Qen3J0XHMUMIXOFcEh8lViW32IgLtmAhpCV81o9fXQGogKvbUYeQdpgsANCACyepsXSi bPlpzE39U9mGC2cQU09wrIoCPr4PUUSBQKnEtTPsWQ+vjOTCdVrL+outDgV90ZMruYFU ZW4w== X-Gm-Message-State: AOAM533K7p6aDf0vLGbwX/xhSKJubYI6kSvRx1lVHefrb5yI9q03jOE9 iKk7sKUSNxPa5sOTgZeSkpLOyJaDpf8+fuHbzppwL6gahcY= X-Received: by 2002:aca:5a42:: with SMTP id o63mr404611oib.69.1608231739225; Thu, 17 Dec 2020 11:02:19 -0800 (PST) MIME-Version: 1.0 References: <20201217104215.2544837-1-srinivas.pandruvada@linux.intel.com> <93d4eebb5121ad0497af555c55a6ad74b8a06e64.camel@linux.intel.com> <8153207.dYVdvtsJbe@kreacher> <6ef769aa04ee8e765863fd4af083eb85cdcb4827.camel@linux.intel.com> <16328b6c4531e676f829601e72dee4a5c2f802a7.camel@linux.intel.com> In-Reply-To: From: "Rafael J. Wysocki" Date: Thu, 17 Dec 2020 20:02:07 +0100 Message-ID: Subject: Re: [PATCH] cpufreq: intel_pstate: Use the latest guaranteed freq during verify To: Srinivas Pandruvada Cc: "Rafael J. Wysocki" , "Rafael J. Wysocki" , Len Brown , Viresh Kumar , Linux PM , Linux Kernel Mailing List Content-Type: text/plain; charset="UTF-8" Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On Thu, Dec 17, 2020 at 6:29 PM Rafael J. Wysocki wrote: > > On Thu, Dec 17, 2020 at 6:09 PM Srinivas Pandruvada > wrote: > > > > On Thu, 2020-12-17 at 16:24 +0100, Rafael J. Wysocki wrote: > > > On Thu, Dec 17, 2020 at 4:21 PM Srinivas Pandruvada > > > wrote: [cut] > > > > > Well, would something like the patch below work? > > > > > > > > > > --- > > > > > drivers/cpufreq/intel_pstate.c | 16 +++++++++++++--- > > > > > 1 file changed, 13 insertions(+), 3 deletions(-) > > > > > > > > > > Index: linux-pm/drivers/cpufreq/intel_pstate.c > > > > > ================================================================= > > > > > == > > > > > --- linux-pm.orig/drivers/cpufreq/intel_pstate.c > > > > > +++ linux-pm/drivers/cpufreq/intel_pstate.c > > > > > @@ -2207,9 +2207,9 @@ static void intel_pstate_update_perf_lim > > > > > unsigned int > > > > > policy_min, > > > > > unsigned int > > > > > policy_max) > > > > > { > > > > > - int max_freq = intel_pstate_get_max_freq(cpu); > > > > > int32_t max_policy_perf, min_policy_perf; > > > > > int max_state, turbo_max; > > > > > + int max_freq; > > > > > > > > > > /* > > > > > * HWP needs some special consideration, because on BDX > > > > > the > > > > > @@ -2223,6 +2223,7 @@ static void intel_pstate_update_perf_lim > > > > > cpu->pstate.max_pstate : cpu- > > > > > > pstate.turbo_pstate; > > > > > turbo_max = cpu->pstate.turbo_pstate; > > > > > } > > > > > + max_freq = max_state * cpu->pstate.scaling; > > > > > > > > > > max_policy_perf = max_state * policy_max / max_freq; > > > > > if (policy_max == policy_min) { > > > > > @@ -2325,9 +2326,18 @@ static void intel_pstate_adjust_policy_m > > > > > static void intel_pstate_verify_cpu_policy(struct cpudata *cpu, > > > > > struct > > > > > cpufreq_policy_data > > > > > *policy) > > > > > { > > > > > + int max_freq; > > > > > + > > > > > update_turbo_state(); > > > > > - cpufreq_verify_within_limits(policy, policy- > > > > > > cpuinfo.min_freq, > > > > > - > > > > > intel_pstate_get_max_freq(cpu)); > > > > > + if (hwp_active) { > > > > > + int max_state, turbo_max; > > > > > + > > > > > + intel_pstate_get_hwp_max(cpu->cpu, &turbo_max, > > > > > &max_state); > > > > > + max_freq = max_state * cpu->pstate.scaling; > > > > > + } else { > > > > > + max_freq = intel_pstate_get_max_freq(cpu); > > > > > + } > > > > > + cpufreq_verify_within_limits(policy, policy- > > > > > > cpuinfo.min_freq, max_freq); > > > > > > > > > > intel_pstate_adjust_policy_max(cpu, policy); > > > > > } > > > > > > > > > Should work. > > > > I will test this patch and let you know once I get the system. > > > > > > Please do, thank you! > > > > This works. Please check if you can submit a change for this. > > I can do that, but I'm going to borrow some changelog pieces from the > $subject patch. > > Will submit shortly. Well, this only fixes the setting of the policy max limit AFAICS, but pstate.max_pstate is used in computations in some places, so it looks like it needs to be updated every time HWP_CAP is read, or do I confuse things? And if pstate.max_pstate needs to be updated then, shouldn't pstate.turbo_pstate be updated then too (because it may change too as a result of ISS updates)?