[<prev] [next>] [<thread-prev] [thread-next>] [day] [month] [year] [list]
Message-ID: <2185721.1uhhhTEYdH@kreacher>
Date: Thu, 16 Jul 2020 19:38:25 +0200
From: "Rafael J. Wysocki" <rjw@...ysocki.net>
To: Linux PM <linux-pm@...r.kernel.org>
Cc: Linux Documentation <linux-doc@...r.kernel.org>,
LKML <linux-kernel@...r.kernel.org>,
Peter Zijlstra <peterz@...radead.org>,
Srinivas Pandruvada <srinivas.pandruvada@...ux.intel.com>,
Giovanni Gherdovich <ggherdovich@...e.cz>,
Doug Smythies <dsmythies@...us.net>,
Francisco Jerez <francisco.jerez.plata@...el.com>
Subject: [PATCH v2 1/2] cpufreq: intel_pstate: Rearrange the storing of newv EPP values
From: Rafael J. Wysocki <rafael.j.wysocki@...el.com>
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 <rafael.j.wysocki@...el.com>
---
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;
}
Powered by blists - more mailing lists