Received: by 2002:a05:6a10:6006:0:0:0:0 with SMTP id w6csp520352pxa; Thu, 27 Aug 2020 08:30:03 -0700 (PDT) X-Google-Smtp-Source: ABdhPJxGkHcxHtzrtWhstg3DfE2ELClhJcu5HK7IsaD/lSzOiw5tuO7VsE0CqN1HF6WIxi2jBksC X-Received: by 2002:a17:906:2a14:: with SMTP id j20mr22666640eje.376.1598542203456; Thu, 27 Aug 2020 08:30:03 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1598542203; cv=none; d=google.com; s=arc-20160816; b=RawUSKisnR9jmgoDLvk7+z6lqXl1x9WmfUmp49r1L1vHkOJafZlyqA0/m1gzQ0yglV Va4GI6TsRNL3in5TCgGy/5qVgHWcdL6T632D1VR5WR8Z/mJGPyG6z85q0egBSgIVpWB2 qTpM9P9PnYt712CiJDHl2Q4+5ELAygRQ+J00Z28zMUOSsBcjsm+3107mpiwZRXFc9XkA oP2cuEXYbgqmp94sM0EUAAFR1AwKmxeFYp1BpYXMYArltOlPK7RjtT1YmpQvbga3UoIn Upkwg7+xOYhNIhTvMV0d7LHQZFF0dhRmc5yBkW1b5frh9xw1u0hh1ISc0la0OPDQVnIZ Qiwg== 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=U3DF4AzNQq5eVPhtwcyyLXa9TQECQRmxb7N+iq8rARo=; b=c2X65eUzIu4nnUjIBEwK7R5c/aXs/ONFiKEp674w8Df7f5dbLJLgBeFRht30vrl1La I0QoS6jay/lQE4OcUw6EIdjGiQvUxp5P8n4CRJ+xHb8CjyHFjXlW8/XhD0WtUCQjgTz3 ViCXaYMdB8R6mZAE612A4EuSDa2PoBFJUO/Wk7pT1T027z+RjmTJJgTaoSck63LHzH8H wX9ajcaQ6DbZ1/4/+6yhPRmZ3MtQ8IQQntHzv8we5ibJYo1LgKVW6zg8scYlDQDsd5if gG8WT3AO8fQ0nQU5u9Af0iWoC7dMTeY6WIyV2jFYhUICSQpnSaI5/q/G9KNqwNgojtHq QpfQ== 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 t14si1582716ejb.435.2020.08.27.08.29.39; Thu, 27 Aug 2020 08:30:03 -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 S1728073AbgH0P2O (ORCPT + 99 others); Thu, 27 Aug 2020 11:28:14 -0400 Received: from cloudserver094114.home.pl ([79.96.170.134]:53246 "EHLO cloudserver094114.home.pl" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1726968AbgH0P1u (ORCPT ); Thu, 27 Aug 2020 11:27:50 -0400 Received: from 89-64-89-85.dynamic.chello.pl (89.64.89.85) (HELO kreacher.localnet) by serwer1319399.home.pl (79.96.170.134) with SMTP (IdeaSmtpServer 0.83.459) id d8641ec3ba7b54ca; Thu, 27 Aug 2020 17:27:48 +0200 From: "Rafael J. Wysocki" To: Linux PM Cc: Srinivas Pandruvada , LKML , Doug Smythies , Artem Bityutskiy Subject: [PATCH v3 2/5] cpufreq: intel_pstate: Update cached EPP in the active mode Date: Thu, 27 Aug 2020 17:13:04 +0200 Message-ID: <2228512.FFnbCeqPFy@kreacher> In-Reply-To: <2240881.fzTuzKk6Gz@kreacher> References: <2240881.fzTuzKk6Gz@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. --- 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