Received: by 2002:a05:6a10:f347:0:0:0:0 with SMTP id d7csp623211pxu; Tue, 5 Jan 2021 23:03:04 -0800 (PST) X-Google-Smtp-Source: ABdhPJwS6UCIpbLGEUZljy4an/Dt1gN1hzsjFFd0bzd8G1ofOizZmCOzMZav8JMjomtA0vjO7ot9 X-Received: by 2002:a17:906:76c9:: with SMTP id q9mr2020131ejn.484.1609916584458; Tue, 05 Jan 2021 23:03:04 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1609916584; cv=none; d=google.com; s=arc-20160816; b=WCCZjSoCID/fTHvYuvyLmUjxMJOLyAWG/XHap9BFs7VWUfLke0Fp9z/Y7mmXjz5u0o 3viNnD8OruR47yK95JsXdTwLA84Aod3o9oasBwjZqEX0avKARshOemOsxF++1FK/O5ux NsExqlHpK8dI2Jh6Ra9aqmJz1pvHhLBYXJJNDSJl+Y6zfUK5nQnHNsmO37jAu2pgUwsu iVY4FGiOa5ZnlLR0lA9+e0euaR6pwCoEIMA/e+zkichLaYeXjsmDSi9KbAqq3w+lQdK5 cwec2kOXrVp+uH8SQ5w/d1+mJdtzJMrdG53jGyYzYGBLN96Ea9rCJp5ktG79hpACKzcw w+ng== 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:date:cc:to:from:subject :message-id:ironport-sdr:ironport-sdr; bh=HYYagG4lzSR0zWvt8n1WA6sRnVohbzpIpfxxEYDvTrI=; b=0Og17hKfY+/cB8QTWjhIABYs4qDxDwRbE14qGRT9++vBsmhofCKE+M2Y9RNpggEKx0 wdo1X+pO5m4nwAL/ZO41lVWi2CXrKVyhY+HIRMmWJgQ/AnyiUo5vemk4m8DRKe4VFZGN MfIFmk/VagvGck7PAw0+34IXkApIvL+agh1MH80jzQhnLsozISgS+eX1PH5MYnGeyhl/ Fa0rubcJpXn0rGv7kmCtBW3+kgx0fLdOJ67NRlZa8+EmbtR6YsvtAVMO2MXAH5l8SH4G cVsht1kp6liRvVztaog7UXi5YAD7yhuDzXWDL3bXgeLWT+sk9bVXvOpYvtf6UYPK1Xt4 g0eA== 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=fail (p=NONE sp=NONE dis=NONE) header.from=intel.com Return-Path: Received: from vger.kernel.org (vger.kernel.org. [23.128.96.18]) by mx.google.com with ESMTP id z102si625373ede.307.2021.01.05.23.02.41; Tue, 05 Jan 2021 23:03:04 -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=fail (p=NONE sp=NONE dis=NONE) header.from=intel.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1726125AbhAFHBf (ORCPT + 99 others); Wed, 6 Jan 2021 02:01:35 -0500 Received: from mga14.intel.com ([192.55.52.115]:8058 "EHLO mga14.intel.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1725877AbhAFHBf (ORCPT ); Wed, 6 Jan 2021 02:01:35 -0500 IronPort-SDR: hKPlJKhJD/Vk5FnulSzpjg33L7ZzbkxcpNyInWVflyWuObSX0EOy8GZ21EpUgHtxT/zLBaTc4h 0RVfunksFYzw== X-IronPort-AV: E=McAfee;i="6000,8403,9855"; a="176458239" X-IronPort-AV: E=Sophos;i="5.78,479,1599548400"; d="scan'208";a="176458239" Received: from fmsmga001.fm.intel.com ([10.253.24.23]) by fmsmga103.fm.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 05 Jan 2021 22:59:49 -0800 IronPort-SDR: YkBOHaT7Bgo3kpotuQ8x7/w5WAiUGiP5LtwFpLbZhqW+VWzMIahl5UmJYz1IPkZ9cXvbguQmqV KUJ/pduk06Tg== X-IronPort-AV: E=Sophos;i="5.78,479,1599548400"; d="scan'208";a="462583520" Received: from sabrinaa-mobl.amr.corp.intel.com ([10.213.162.179]) by fmsmga001-auth.fm.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 05 Jan 2021 22:59:47 -0800 Message-ID: Subject: Re: [PATCH] cpufreq: intel_pstate: Use HWP capabilities in intel_cpufreq_adjust_perf() From: Srinivas Pandruvada To: "Rafael J. Wysocki" , Linux PM Cc: LKML Date: Tue, 05 Jan 2021 22:59:43 -0800 In-Reply-To: <1784464.uM0JrOW1fs@kreacher> References: <1784464.uM0JrOW1fs@kreacher> Content-Type: text/plain; charset="UTF-8" User-Agent: Evolution 3.38.2 (3.38.2-1.fc33) MIME-Version: 1.0 Content-Transfer-Encoding: 8bit Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On Tue, 2021-01-05 at 19:20 +0100, Rafael J. Wysocki wrote: > From: Rafael J. Wysocki > > If turbo P-states cannot be used, either due to the configuration of > the processor, or because intel_pstate is not allowed to used them, > the maximum available P-state with HWP enabled corresponds to the > HWP_CAP.GUARANTEED value which is not static.  It can be adjusted by > an out-of-band agent or during an Intel Speed Select performance > level change, so long as it remains less than or equal to > HWP_CAP.MAX. > > However, if turbo P-states cannot be used, > intel_cpufreq_adjust_perf() > always uses pstate.max_pstate (set during the initialization of the > driver only) as the maximum available P-state, so it may miss a > change > of the HWP_CAP.GUARANTEED value. > > Prevent that from happening by modifyig intel_cpufreq_adjust_perf() > to always read the "guaranteed" and "maximum turbo" performance > levels from the cached HWP_CAP value. > > Signed-off-by: Rafael J. Wysocki Acked-by: Srinivas Pandruvada > --- >  drivers/cpufreq/intel_pstate.c |    5 +++-- >  1 file changed, 3 insertions(+), 2 deletions(-) > > Index: linux-pm/drivers/cpufreq/intel_pstate.c > =================================================================== > --- linux-pm.orig/drivers/cpufreq/intel_pstate.c > +++ linux-pm/drivers/cpufreq/intel_pstate.c > @@ -2653,12 +2653,13 @@ static void intel_cpufreq_adjust_perf(un >                                       unsigned long capacity) >  { >         struct cpudata *cpu = all_cpu_data[cpunum]; > +       u64 hwp_cap = READ_ONCE(cpu->hwp_cap_cached); >         int old_pstate = cpu->pstate.current_pstate; >         int cap_pstate, min_pstate, max_pstate, target_pstate; >   >         update_turbo_state(); > -       cap_pstate = global.turbo_disabled ? cpu->pstate.max_pstate : > -                                            cpu- > >pstate.turbo_pstate; > +       cap_pstate = global.turbo_disabled ? > HWP_GUARANTEED_PERF(hwp_cap) : > +                                            > HWP_HIGHEST_PERF(hwp_cap); >   >         /* Optimization: Avoid unnecessary divisions. */ >   > > >