Received: by 2002:a05:6a10:22f:0:0:0:0 with SMTP id 15csp1913725pxk; Tue, 1 Sep 2020 10:41:24 -0700 (PDT) X-Google-Smtp-Source: ABdhPJzso3SP5111rkDY8Brlpm6waleF6e2r7eYcnQyZa7TPKVhQo9R73LCedgKS2zSO2GpjGa6n X-Received: by 2002:a17:906:46c2:: with SMTP id k2mr2735062ejs.448.1598982084214; Tue, 01 Sep 2020 10:41:24 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1598982084; cv=none; d=google.com; s=arc-20160816; b=atVlpS8ohLFnilwqggpevsF/i8d/NPrB3K1Vtbnzmv01DuaSX1KU6xNfxV6fQAPDN0 mBcIMq6gxSE+otE6c8QKwHIfm4fwn1LXeGTdU4REVDAvKoZRDhsLIRK2NlJw8S0w8xed bsGIOVWKoH6wWj5eROBhTcWEbL9/DT/14KX8hcHQPUvIWWh07NAqvggF6D3ZHqN5/2YW lDAn4SvEyPBrCstT0Hu/JPI1f3EomHk+p8nIE1x/YXFDCa7WUabsyRsIBFJcQC7UMecX o9gotjtY24j1c7nUyympAoaPCh6zKO1HfG8WH2kCk+yRuiZ/otLON0tyhBjYdegRKEuH ve0g== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:content-transfer-encoding:mime-version :references:in-reply-to:message-id:date:subject:cc:to:from; bh=jeV8OtDVTQo8zKlQ0tyXkvhMtVCOKWlyFJyXIRuTrZE=; b=A5NwAGKPNtI5JACwEyhkahcIG8ZGd32drCHBDPK4xxerHJ9TxrQEcD0duE/cNxpk8f IEft0AuU6/0Mfx/Fu1ziZ4mayNfqUBmyevY48xyqYaXidESCPuDA/86p/fFrru1b3rDx W0lYPwAXfkII5+7o/aDoSWyS/X2b/IAtYxCIE3V0YZ/Sf11EsA7g7Hybb3jeVOggzx0u cAx/UopUdnsGFssWvfW3SRlaBMxdHGbBjZbiUqTCH9wI4Pg3Ty/bY4FlukgIK4Xd/H7X Qj1wtwBmovIoUarQEE/bhepyb1hpNaKNGBaEjw5nMSG8u3WmwiFAo/0jtQlv1iRJMcAN HSoQ== 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 k10si1114055ejr.323.2020.09.01.10.41.01; Tue, 01 Sep 2020 10:41:24 -0700 (PDT) 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 S1729737AbgIARj5 (ORCPT + 99 others); Tue, 1 Sep 2020 13:39:57 -0400 Received: from cloudserver094114.home.pl ([79.96.170.134]:60258 "EHLO cloudserver094114.home.pl" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1728254AbgIARjz (ORCPT ); Tue, 1 Sep 2020 13:39:55 -0400 Received: from 89-64-88-247.dynamic.chello.pl (89.64.88.247) (HELO kreacher.localnet) by serwer1319399.home.pl (79.96.170.134) with SMTP (IdeaSmtpServer 0.83.459) id a294c7eb5a260088; Tue, 1 Sep 2020 19:39:53 +0200 From: "Rafael J. Wysocki" To: Linux PM Cc: Srinivas Pandruvada , LKML , Doug Smythies , Artem Bityutskiy Subject: [PATCH v4 2/5] cpufreq: intel_pstate: Update cached EPP in the active mode Date: Tue, 01 Sep 2020 19:27:18 +0200 Message-ID: <5673678.fo8E7psNGY@kreacher> In-Reply-To: <3748218.V0HrpZKF9g@kreacher> References: <3748218.V0HrpZKF9g@kreacher> MIME-Version: 1.0 Content-Transfer-Encoding: 7Bit Content-Type: text/plain; charset="us-ascii" Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org From: "Rafael J. Wysocki" Make intel_pstate update the cached EPP value when setting the EPP via sysfs in the active mode just like it is the case in the passive mode, for consistency, but also for the benefit of subsequent changes. No intentional functional impact. Signed-off-by: Rafael J. Wysocki --- -> v2: No changes v2 -> v3: * Do not change the read part of the EPP sysfs interface. * Change the subject and update the changelog. v3 -> v4: No changes --- drivers/cpufreq/intel_pstate.c | 20 +++++++++++++++----- 1 file changed, 15 insertions(+), 5 deletions(-) diff --git a/drivers/cpufreq/intel_pstate.c b/drivers/cpufreq/intel_pstate.c index bcda1e700a73..e540448e0bd0 100644 --- a/drivers/cpufreq/intel_pstate.c +++ b/drivers/cpufreq/intel_pstate.c @@ -644,6 +644,8 @@ static int intel_pstate_get_energy_pref_index(struct cpudata *cpu_data, int *raw static int intel_pstate_set_epp(struct cpudata *cpu, u32 epp) { + int ret; + /* * Use the cached HWP Request MSR value, because in the active mode the * register itself may be updated by intel_pstate_hwp_boost_up() or @@ -659,7 +661,11 @@ static int intel_pstate_set_epp(struct cpudata *cpu, u32 epp) * function, so it cannot run in parallel with the update below. */ WRITE_ONCE(cpu->hwp_req_cached, value); - return wrmsrl_on_cpu(cpu->cpu, MSR_HWP_REQUEST, value); + ret = wrmsrl_on_cpu(cpu->cpu, MSR_HWP_REQUEST, value); + if (!ret) + cpu->epp_cached = epp; + + return ret; } static int intel_pstate_set_energy_pref_index(struct cpudata *cpu_data, @@ -762,10 +768,8 @@ static ssize_t store_energy_performance_preference( cpufreq_stop_governor(policy); ret = intel_pstate_set_epp(cpu, epp); err = cpufreq_start_governor(policy); - if (!ret) { - cpu->epp_cached = epp; + if (!ret) ret = err; - } } } @@ -2378,6 +2382,12 @@ static int intel_pstate_cpu_init(struct cpufreq_policy *policy) */ policy->policy = CPUFREQ_POLICY_POWERSAVE; + if (hwp_active) { + struct cpudata *cpu = all_cpu_data[policy->cpu]; + + cpu->epp_cached = intel_pstate_get_epp(cpu, 0); + } + return 0; } @@ -2585,7 +2595,7 @@ static int intel_cpufreq_cpu_init(struct cpufreq_policy *policy) policy->transition_delay_us = INTEL_CPUFREQ_TRANSITION_DELAY_HWP; rdmsrl_on_cpu(cpu->cpu, MSR_HWP_REQUEST, &value); WRITE_ONCE(cpu->hwp_req_cached, value); - cpu->epp_cached = (value & GENMASK_ULL(31, 24)) >> 24; + cpu->epp_cached = intel_pstate_get_epp(cpu, value); } else { turbo_max = cpu->pstate.turbo_pstate; policy->transition_delay_us = INTEL_CPUFREQ_TRANSITION_DELAY; -- 2.26.2