From: "Rafael J. Wysocki" <rjw@rjwysocki.net>
To: Linux PM list <linux-pm@vger.kernel.org>
Cc: ACPI Devel Maling List <linux-acpi@vger.kernel.org>,
Linux Kernel Mailing List <linux-kernel@vger.kernel.org>,
Viresh Kumar <viresh.kumar@linaro.org>,
Pan Xinhui <xinhuix.pan@intel.com>
Subject: [PATCH 2/2] cpufreq: acpi-cpufreq: Drop acpi_data from struct acpi_cpufreq_data
Date: Sat, 18 Jul 2015 03:16:23 +0200 [thread overview]
Message-ID: <6540595.sJ2Fvrp64t@vostro.rjw.lan> (raw)
In-Reply-To: <10273534.kyzK8rhvUz@vostro.rjw.lan>
From: Rafael J. Wysocki <rafael.j.wysocki@intel.com>
After commit 8cfcfd39000d (acpi-cpufreq: Fix an ACPI perf unregister
issue) we store both a pointer to per-CPU data of the first policy
CPU and the number of that CPU which are redundant.
Since the CPU number has to be stored anyway for the unregistration,
the pointer to the CPU's per-CPU data may be dropped and we can
access the data in question via per_cpu_ptr().
Signed-off-by: Rafael J. Wysocki <rafael.j.wysocki@intel.com>
---
drivers/cpufreq/acpi-cpufreq.c | 26 +++++++++++++-------------
1 file changed, 13 insertions(+), 13 deletions(-)
Index: linux-pm/drivers/cpufreq/acpi-cpufreq.c
===================================================================
--- linux-pm.orig/drivers/cpufreq/acpi-cpufreq.c
+++ linux-pm/drivers/cpufreq/acpi-cpufreq.c
@@ -65,7 +65,6 @@ enum {
#define MSR_K7_HWCR_CPB_DIS (1ULL << 25)
struct acpi_cpufreq_data {
- struct acpi_processor_performance *acpi_data;
struct cpufreq_frequency_table *freq_table;
unsigned int resume;
unsigned int cpu_feature;
@@ -201,7 +200,7 @@ static unsigned extract_io(u32 value, st
struct acpi_processor_performance *perf;
int i;
- perf = data->acpi_data;
+ perf = per_cpu_ptr(acpi_perf_data, data->acpi_perf_cpu);
for (i = 0; i < perf->state_count; i++) {
if (value == perf->states[i].status)
@@ -220,7 +219,7 @@ static unsigned extract_msr(u32 msr, str
else
msr &= INTEL_MSR_RANGE;
- perf = data->acpi_data;
+ perf = per_cpu_ptr(acpi_perf_data, data->acpi_perf_cpu);
cpufreq_for_each_entry(pos, data->freq_table)
if (msr == perf->states[pos->driver_data].status)
@@ -346,7 +345,7 @@ get_cur_val(const struct cpumask *mask,
break;
case SYSTEM_IO_CAPABLE:
cmd.type = SYSTEM_IO_CAPABLE;
- perf = data->acpi_data;
+ perf = per_cpu_ptr(acpi_perf_data, data->acpi_perf_cpu);
cmd.addr.io.port = perf->control_register.address;
cmd.addr.io.bit_width = perf->control_register.bit_width;
break;
@@ -364,6 +363,7 @@ get_cur_val(const struct cpumask *mask,
static unsigned int get_cur_freq_on_cpu(unsigned int cpu)
{
+ struct acpi_processor_performance *perf;
struct acpi_cpufreq_data *data;
struct cpufreq_policy *policy;
unsigned int freq;
@@ -377,10 +377,11 @@ static unsigned int get_cur_freq_on_cpu(
data = policy->driver_data;
cpufreq_cpu_put(policy);
- if (unlikely(!data || !data->acpi_data || !data->freq_table))
+ if (unlikely(!data || !data->freq_table))
return 0;
- cached_freq = data->freq_table[data->acpi_data->state].frequency;
+ perf = per_cpu_ptr(acpi_perf_data, data->acpi_perf_cpu);
+ cached_freq = data->freq_table[perf->state].frequency;
freq = extract_freq(get_cur_val(cpumask_of(cpu), data), data);
if (freq != cached_freq) {
/*
@@ -419,12 +420,11 @@ static int acpi_cpufreq_target(struct cp
unsigned int next_perf_state = 0; /* Index into perf table */
int result = 0;
- if (unlikely(data == NULL ||
- data->acpi_data == NULL || data->freq_table == NULL)) {
+ if (unlikely(data == NULL || data->freq_table == NULL)) {
return -ENODEV;
}
- perf = data->acpi_data;
+ perf = per_cpu_ptr(acpi_perf_data, data->acpi_perf_cpu);
next_perf_state = data->freq_table[index].driver_data;
if (perf->state == next_perf_state) {
if (unlikely(data->resume)) {
@@ -487,8 +487,9 @@ out:
static unsigned long
acpi_cpufreq_guess_freq(struct acpi_cpufreq_data *data, unsigned int cpu)
{
- struct acpi_processor_performance *perf = data->acpi_data;
+ struct acpi_processor_performance *perf;
+ perf = per_cpu_ptr(acpi_perf_data, data->acpi_perf_cpu);
if (cpu_khz) {
/* search the closest match to cpu_khz */
unsigned int i;
@@ -677,18 +678,17 @@ static int acpi_cpufreq_cpu_init(struct
goto err_free;
}
- data->acpi_data = per_cpu_ptr(acpi_perf_data, cpu);
+ perf = per_cpu_ptr(acpi_perf_data, cpu);
data->acpi_perf_cpu = cpu;
policy->driver_data = data;
if (cpu_has(c, X86_FEATURE_CONSTANT_TSC))
acpi_cpufreq_driver.flags |= CPUFREQ_CONST_LOOPS;
- result = acpi_processor_register_performance(data->acpi_data, cpu);
+ result = acpi_processor_register_performance(perf, cpu);
if (result)
goto err_free_mask;
- perf = data->acpi_data;
policy->shared_type = perf->shared_type;
/*
next prev parent reply other threads:[~2015-07-18 0:49 UTC|newest]
Thread overview: 12+ messages / expand[flat|nested] mbox.gz Atom feed top
2015-07-18 1:13 [PATCH 0/2] ACPI / cpufreq: ACPI processor driver and ACPI cpufreq driver cleanups Rafael J. Wysocki
2015-07-18 1:14 ` [PATCH 1/2] ACPI / processor: Drop an unused argument of a cleanup routine Rafael J. Wysocki
2015-07-20 1:45 ` Pan Xinhui
2015-07-20 21:49 ` Rafael J. Wysocki
2015-07-18 1:16 ` Rafael J. Wysocki [this message]
2015-07-18 6:04 ` [PATCH 0/2] ACPI / cpufreq: ACPI processor driver and ACPI cpufreq driver cleanups Viresh Kumar
2015-07-20 22:40 ` Rafael J. Wysocki
2015-07-20 22:12 ` [PATCH v2 0/3] " Rafael J. Wysocki
2015-07-20 22:13 ` [PATCH v2 1/3] cpufreq: acpi-cpufreq: Fix up the handling of the cpb sysfs attribute Rafael J. Wysocki
2015-07-20 22:14 ` [PATCH v2 2/3] ACPI / processor: Drop an unused argument of a cleanup routine Rafael J. Wysocki
2015-07-20 22:15 ` [PATCH v2 3/3] cpufreq: acpi-cpufreq: Drop acpi_data from struct acpi_cpufreq_data Rafael J. Wysocki
2015-07-21 2:33 ` [PATCH v2 0/3] ACPI / cpufreq: ACPI processor driver and ACPI cpufreq driver cleanups Viresh Kumar
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=6540595.sJ2Fvrp64t@vostro.rjw.lan \
--to=rjw@rjwysocki.net \
--cc=linux-acpi@vger.kernel.org \
--cc=linux-kernel@vger.kernel.org \
--cc=linux-pm@vger.kernel.org \
--cc=viresh.kumar@linaro.org \
--cc=xinhuix.pan@intel.com \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox
Powered by JetHome