Received: by 2002:a25:e74b:0:0:0:0:0 with SMTP id e72csp1389951ybh; Thu, 16 Jul 2020 10:42:59 -0700 (PDT) X-Google-Smtp-Source: ABdhPJxplAO1/YZF4vTTMXxL2GCcQWu5qELse99hts1+wW5agZYqLp07rtP0sZFJHrVbXFuL825z X-Received: by 2002:a50:cd1e:: with SMTP id z30mr5300477edi.364.1594921378838; Thu, 16 Jul 2020 10:42:58 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1594921378; cv=none; d=google.com; s=arc-20160816; b=0FEF7IwgDF+9XMGC2yI3NQmbqDsO+CRNJpk7HKk+MSTmPMg1ErDz8Vwnecmd/dv8/U usk/vdl5fgHZuPBSWW0kF/feS0NQpZz7MfFZVwVGxJytiQD2lJ749kgbwQ65qyVnYPTr dHtb96H1KGbpr+/pJ8S3HoiZVLz0CRbOiV+pIMAFhGZndJPqkvXTTEQqfYFGVQC9Hls0 n6gpNdA4m71maQK4iTBmfUVxBUlPG3w8gvKSBMDIKrvnhWTi8wIKxTDdqalWiBR/O85Q oDU1R5BW7FsG/WYAteylvq1iwR/L6Uy6B/llaFkVowj6wHe9TY1gH5JVK6mXvOv2cNGO +/xg== 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=/RSdiBqYj9gACjX3CCkBfOXKE/c3gT+gkZtGJKJpYNU=; b=PftraRc1gwOKH8yJhQ+6/hsw4IOOQVbD/QwMNn17Hxl0lT6wWZf6Fw/VUfYPAu/olx NbkanPAfYCiKuyvlnuReZfN51ZHnpY4FdGQW9x5BU/gAa2aRnSeFsORQnST247G0P+0p u32vLbweX0l3c2pGdSSeB9X+o0jJWilJG7ANnh0wAbC2Q2VSm7yZvOpO3ibIeN98RasU q/mP29AAS/8gwchXM3JuoU7xkNR0BLY5jqn57NDcpB8oWBQ6w+C1UTcxuozSZCFLM4AV NFYK7OsBbpYfnfji8zlGMCXYsRPRNeD2DKh6Hb+FI3D6mE6+3GFNehnymJTMEqm0cpH+ 0Qzw== 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 p27si3731341ejd.590.2020.07.16.10.42.35; Thu, 16 Jul 2020 10:42:58 -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 S1728721AbgGPRm0 (ORCPT + 99 others); Thu, 16 Jul 2020 13:42:26 -0400 Received: from cloudserver094114.home.pl ([79.96.170.134]:42146 "EHLO cloudserver094114.home.pl" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1728257AbgGPRmZ (ORCPT ); Thu, 16 Jul 2020 13:42:25 -0400 Received: from 89-64-86-30.dynamic.chello.pl (89.64.86.30) (HELO kreacher.localnet) by serwer1319399.home.pl (79.96.170.134) with SMTP (IdeaSmtpServer 0.83.415) id fb6e85f8e17426b2; Thu, 16 Jul 2020 19:42:23 +0200 From: "Rafael J. Wysocki" To: Linux PM Cc: Linux Documentation , LKML , Peter Zijlstra , Srinivas Pandruvada , Giovanni Gherdovich , Doug Smythies , Francisco Jerez Subject: [PATCH v2 1/2] cpufreq: intel_pstate: Rearrange the storing of newv EPP values Date: Thu, 16 Jul 2020 19:38:25 +0200 Message-ID: <2185721.1uhhhTEYdH@kreacher> In-Reply-To: <4981405.3kqTVLv5tO@kreacher> References: <4981405.3kqTVLv5tO@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 Move the locking away from intel_pstate_set_energy_pref_index() into its only caller and drop the (now redundant) return_pref label from it. Also move the "raw" EPP value check into the caller of that function, so as to do it before acquiring the mutex, and reduce code duplication related to the "raw" EPP values processing somewhat. No intentional functional impact. Signed-off-by: Rafael J. Wysocki --- drivers/cpufreq/intel_pstate.c | 29 ++++++++++++----------------- 1 file changed, 12 insertions(+), 17 deletions(-) Index: linux-pm/drivers/cpufreq/intel_pstate.c =================================================================== --- linux-pm.orig/drivers/cpufreq/intel_pstate.c +++ linux-pm/drivers/cpufreq/intel_pstate.c @@ -648,28 +648,18 @@ static int intel_pstate_set_energy_pref_ if (!pref_index) epp = cpu_data->epp_default; - mutex_lock(&intel_pstate_limits_lock); - if (boot_cpu_has(X86_FEATURE_HWP_EPP)) { u64 value; ret = rdmsrl_on_cpu(cpu_data->cpu, MSR_HWP_REQUEST, &value); if (ret) - goto return_pref; + return ret; value &= ~GENMASK_ULL(31, 24); - if (use_raw) { - if (raw_epp > 255) { - ret = -EINVAL; - goto return_pref; - } - value |= (u64)raw_epp << 24; - ret = wrmsrl_on_cpu(cpu_data->cpu, MSR_HWP_REQUEST, value); - goto return_pref; - } - - if (epp == -EINVAL) + if (use_raw) + epp = raw_epp; + else if (epp == -EINVAL) epp = epp_values[pref_index - 1]; value |= (u64)epp << 24; @@ -679,8 +669,6 @@ static int intel_pstate_set_energy_pref_ epp = (pref_index - 1) << 2; ret = intel_pstate_set_epb(cpu_data->cpu, epp); } -return_pref: - mutex_unlock(&intel_pstate_limits_lock); return ret; } @@ -723,12 +711,19 @@ static ssize_t store_energy_performance_ if (ret) return ret; + if (epp > 255) + return -EINVAL; + raw = true; } + mutex_lock(&intel_pstate_limits_lock); + ret = intel_pstate_set_energy_pref_index(cpu_data, ret, raw, epp); if (ret) - return ret; + count = ret; + + mutex_unlock(&intel_pstate_limits_lock); return count; }