Received: by 2002:a05:6a10:16a7:0:0:0:0 with SMTP id gp39csp4169502pxb; Tue, 10 Nov 2020 09:30:11 -0800 (PST) X-Google-Smtp-Source: ABdhPJxs0Wozn9itkkAWL2Km8Kl1j5Q+mh9ejXK5/1pXT23EqpsUBmFPjdYQfQZHh+u1sKfIchiA X-Received: by 2002:a17:906:3a49:: with SMTP id a9mr21193955ejf.300.1605029410890; Tue, 10 Nov 2020 09:30:10 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1605029410; cv=none; d=google.com; s=arc-20160816; b=YF1PLEPRL0QX8XIOQKh2DYBh9NQzGxY9aDYBki7WuSkI5khg8ZdmrnWKTePoBpY/0x sFBYa+RVJI3uW4XGYeoHGjJD83b+KiUpuhIAFZKujELaTBmoahoVlrXZusQ3Gg39TtEA hpOU4ZHCJSfXELF/SE9xSBdbGgPO/KwatGLpdQZFlQwFG6GFhf90JvZf1UheiFq8KIOm J27nDH1B+60pf4dfdYq7vUmgFBeV66NyjuSSGzRmLSWknsuHbeI04T/89xhgeWBLav74 m4a7yaqf/MgG+JX7FG3n8MXOaXjdxwuaMRRjO4a2byFCEB8cT2cr+KfeqsD+KeGSu2yp piFg== 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; bh=P3nSSF8t9mdLg0Lk0MC58IrcxsGYW9ZcOzjNSXZ4D+k=; b=sjiToyQvUlrHVCVAQXS1VQScvjP3fUkXe1RVGKSylZVFClC68/VNnLV5/q9OIhFC4J YI3luj9JpuXPU48T/1DcKG8dlMJmlNt3wnjpNWr/xZPTdniPDaXu952sA2lsR9o3yHOc TA8b0vnwuCG0CzTPOAlVpthpmeFlrdfV1cxNeNiRrt6wuJp/Og6ZYrbxs15YoRx5KTts ChYFXp9O4DABm0pGzjEjdmRP8iZ0OsaFLAaptb3u0xAo1zN17PsybmuWJI5ccmCpsO5t 7anqJMlUyorkfw8wUyvaw667BY5WGdzi6vV0oqDvic7kjC1b0q2+qzY0LU/UbrxNiZuB 8TQw== 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 Return-Path: Received: from vger.kernel.org (vger.kernel.org. [23.128.96.18]) by mx.google.com with ESMTP id o22si9141440ejb.569.2020.11.10.09.29.45; Tue, 10 Nov 2020 09:30:10 -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 Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1728999AbgKJR2S (ORCPT + 99 others); Tue, 10 Nov 2020 12:28:18 -0500 Received: from cloudserver094114.home.pl ([79.96.170.134]:61634 "EHLO cloudserver094114.home.pl" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1726152AbgKJR2S (ORCPT ); Tue, 10 Nov 2020 12:28:18 -0500 Received: from 89-64-88-129.dynamic.chello.pl (89.64.88.129) (HELO kreacher.localnet) by serwer1319399.home.pl (79.96.170.134) with SMTP (IdeaSmtpServer 0.83.520) id fda285157de01d86; Tue, 10 Nov 2020 18:28:16 +0100 From: "Rafael J. Wysocki" To: Linux PM Cc: "Rafael J. Wysocki" , Viresh Kumar , Srinivas Pandruvada , Zhang Rui , LKML , Doug Smythies Subject: [PATCH v3 4/4] cpufreq: intel_pstate: Take CPUFREQ_GOV_STRICT_TARGET into account Date: Tue, 10 Nov 2020 18:27:40 +0100 Message-ID: <10431634.ybq6RTg3ZS@kreacher> In-Reply-To: <11312387.r5AVKgp8zO@kreacher> References: <13269660.K2JYd4sGFX@kreacher> <11312387.r5AVKgp8zO@kreacher> MIME-Version: 1.0 Content-Transfer-Encoding: 7Bit Content-Type: text/plain; charset="us-ascii" Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org From: Rafael J. Wysocki Make intel_pstate take the new CPUFREQ_GOV_STRICT_TARGET governor flag into account when it operates in the passive mode with HWP enabled, so as to fix the "powersave" governor behavior in that case (currently, HWP is allowed to scale the performance all the way up to the policy max limit when the "powersave" governor is used, but it should be constrained to the policy min limit then). Signed-off-by: Rafael J. Wysocki Acked-by: Viresh Kumar --- drivers/cpufreq/intel_pstate.c | 16 +++++++++------- 1 file changed, 9 insertions(+), 7 deletions(-) Index: linux-pm/drivers/cpufreq/intel_pstate.c =================================================================== --- linux-pm.orig/drivers/cpufreq/intel_pstate.c +++ linux-pm/drivers/cpufreq/intel_pstate.c @@ -2527,7 +2527,7 @@ static void intel_cpufreq_trace(struct c } static void intel_cpufreq_adjust_hwp(struct cpudata *cpu, u32 target_pstate, - bool fast_switch) + bool strict, bool fast_switch) { u64 prev = READ_ONCE(cpu->hwp_req_cached), value = prev; @@ -2539,7 +2539,7 @@ static void intel_cpufreq_adjust_hwp(str * field in it, so opportunistically update the max too if needed. */ value &= ~HWP_MAX_PERF(~0L); - value |= HWP_MAX_PERF(cpu->max_perf_ratio); + value |= HWP_MAX_PERF(strict ? target_pstate : cpu->max_perf_ratio); if (value == prev) return; @@ -2562,14 +2562,16 @@ static void intel_cpufreq_adjust_perf_ct pstate_funcs.get_val(cpu, target_pstate)); } -static int intel_cpufreq_update_pstate(struct cpudata *cpu, int target_pstate, - bool fast_switch) +static int intel_cpufreq_update_pstate(struct cpufreq_policy *policy, + int target_pstate, bool fast_switch) { + struct cpudata *cpu = all_cpu_data[policy->cpu]; int old_pstate = cpu->pstate.current_pstate; target_pstate = intel_pstate_prepare_request(cpu, target_pstate); if (hwp_active) { - intel_cpufreq_adjust_hwp(cpu, target_pstate, fast_switch); + intel_cpufreq_adjust_hwp(cpu, target_pstate, + policy->strict_target, fast_switch); cpu->pstate.current_pstate = target_pstate; } else if (target_pstate != old_pstate) { intel_cpufreq_adjust_perf_ctl(cpu, target_pstate, fast_switch); @@ -2609,7 +2611,7 @@ static int intel_cpufreq_target(struct c break; } - target_pstate = intel_cpufreq_update_pstate(cpu, target_pstate, false); + target_pstate = intel_cpufreq_update_pstate(policy, target_pstate, false); freqs.new = target_pstate * cpu->pstate.scaling; @@ -2628,7 +2630,7 @@ static unsigned int intel_cpufreq_fast_s target_pstate = DIV_ROUND_UP(target_freq, cpu->pstate.scaling); - target_pstate = intel_cpufreq_update_pstate(cpu, target_pstate, true); + target_pstate = intel_cpufreq_update_pstate(policy, target_pstate, true); return target_pstate * cpu->pstate.scaling; }