Received: by 2002:a05:6a10:16a7:0:0:0:0 with SMTP id gp39csp3353892pxb; Mon, 9 Nov 2020 09:02:06 -0800 (PST) X-Google-Smtp-Source: ABdhPJzmKevN1Adjcdgw67t/dJfyqnOlCwiwCbOob8Dvi0zk3f2/sJr2XhuFuVQjBZzJdJ0dPmBA X-Received: by 2002:a05:6402:79a:: with SMTP id d26mr10741969edy.113.1604941326696; Mon, 09 Nov 2020 09:02:06 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1604941326; cv=none; d=google.com; s=arc-20160816; b=vEEqnCP7ELcsSoKEtEk3vLvOvCYWp7KYb92Xgh2Gp58mXZQzRaztCkPzDNIyV48ES5 KZpN4QjQeDZKLlmVStXTY9TVGL+MkIDkUk6U0wPEK+UCBJsLxhXOXT2PrYqFeCcBASQ/ f8/BA0WrWgKPWYE9ioB7g7NVEnyCQFHWLHRccAd1wbjqGTZ0dZ36jtBy/khSvO7v6bbn kWTfDUsv4GE5U1dBZdgskyzx4Fl9eiDCHw0ER9tm0RRUnlygQ1iQq+a3eWQ8L+R0cIKB f/aNMiH6WIk1tTumULz0az1dYKOA6c+1nJ8iJjScziuUlX6OaODQmMVMltCpUsixzaqa iJFg== 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=iEChTS2N9ngIEdkRXgFfOpZRJID9ppEVWa1nmSKIY80=; b=kVgO8Sa70Ktx0xa4V9wcI1bjGNZExCxgIr+03cdMcDGkcDFS/fbhLeBIsU1CiZSgYu BatJ4ECCKpjo2rUJwH6MVPgpvmnXutZ4RkFJC76qkMBpWLS41gQ+3DSpsd5eE5FqASQZ j3e7hN6dcIgRH+dCI1leeySOy9jVtygJCtBlzOO1XFCRK6wgnQckVfFA1WIpKgd4QLYr CGLlRdrp3VxFxT9ZkgCnM3RyP/Tjn5rdCXmBcBIKMrtlaJWUd1h2rq3jf7EDJpKI6ZyZ PXjZj8s+iFClwxQCqmHbcsk0Y6rEgGm0BF866SugQjUz7tHBZqeMISbQHu5ybsLD138J ZQ9Q== 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 co26si7377627edb.209.2020.11.09.09.01.40; Mon, 09 Nov 2020 09:02:06 -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 S1731082AbgKIQ5I (ORCPT + 99 others); Mon, 9 Nov 2020 11:57:08 -0500 Received: from cloudserver094114.home.pl ([79.96.170.134]:46558 "EHLO cloudserver094114.home.pl" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1731027AbgKIQ5G (ORCPT ); Mon, 9 Nov 2020 11:57:06 -0500 Received: from 89-64-87-89.dynamic.chello.pl (89.64.87.89) (HELO kreacher.localnet) by serwer1319399.home.pl (79.96.170.134) with SMTP (IdeaSmtpServer 0.83.520) id b729a6806886ddaf; Mon, 9 Nov 2020 17:57:03 +0100 From: "Rafael J. Wysocki" To: Linux PM Cc: "Rafael J. Wysocki" , Viresh Kumar , Srinivas Pandruvada , Zhang Rui , LKML , Doug Smythies Subject: [PATCH v2 4/4] cpufreq: intel_pstate: Take CPUFREQ_GOV_FLAG_STRICT_TARGET into account Date: Mon, 09 Nov 2020 17:55:42 +0100 Message-ID: <2345253.LYi3vV7ftd@kreacher> In-Reply-To: <13269660.K2JYd4sGFX@kreacher> References: <13269660.K2JYd4sGFX@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_FLAG_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 --- 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; }