Skip to content

Commit 796aade

Browse files
committed
Merge branch 'fixes' of git://git.kernel.org/pub/scm/linux/kernel/git/davej/cpufreq
* 'fixes' of git://git.kernel.org/pub/scm/linux/kernel/git/davej/cpufreq: [CPUFREQ][2/2] preregister support for powernow-k8 [CPUFREQ][1/2] whitespace fix for powernow-k8 [CPUFREQ] Update MAINTAINERS to reflect new mailing list. [CPUFREQ] Fix warning in elanfreq [CPUFREQ] Fix -Wshadow warning in conservative governor. [CPUFREQ] Remove EXPERIMENTAL annotation from VIA C7 powersaver kconfig.
2 parents 56831a1 + 34ae7f3 commit 796aade

File tree

6 files changed

+89
-54
lines changed

6 files changed

+89
-54
lines changed

MAINTAINERS

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1249,7 +1249,7 @@ S: Maintained
12491249
CPU FREQUENCY DRIVERS
12501250
P: Dave Jones
12511251
M: davej@codemonkey.org.uk
1252-
L: cpufreq@lists.linux.org.uk
1252+
L: cpufreq@vger.kernel.org
12531253
W: http://www.codemonkey.org.uk/projects/cpufreq/
12541254
T: git kernel.org/pub/scm/linux/kernel/git/davej/cpufreq.git
12551255
S: Maintained

arch/x86/kernel/cpu/cpufreq/Kconfig

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -235,9 +235,9 @@ config X86_LONGHAUL
235235
If in doubt, say N.
236236

237237
config X86_E_POWERSAVER
238-
tristate "VIA C7 Enhanced PowerSaver (EXPERIMENTAL)"
238+
tristate "VIA C7 Enhanced PowerSaver"
239239
select CPU_FREQ_TABLE
240-
depends on X86_32 && EXPERIMENTAL
240+
depends on X86_32
241241
help
242242
This adds the CPUFreq driver for VIA C7 processors.
243243

arch/x86/kernel/cpu/cpufreq/elanfreq.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -44,7 +44,7 @@ struct s_elan_multiplier {
4444
* It is important that the frequencies
4545
* are listed in ascending order here!
4646
*/
47-
struct s_elan_multiplier elan_multiplier[] = {
47+
static struct s_elan_multiplier elan_multiplier[] = {
4848
{1000, 0x02, 0x18},
4949
{2000, 0x02, 0x10},
5050
{4000, 0x02, 0x08},

arch/x86/kernel/cpu/cpufreq/powernow-k8.c

Lines changed: 73 additions & 39 deletions
Original file line numberDiff line numberDiff line change
@@ -66,7 +66,6 @@ static u32 find_freq_from_fid(u32 fid)
6666
return 800 + (fid * 100);
6767
}
6868

69-
7069
/* Return a frequency in KHz, given an input fid */
7170
static u32 find_khz_freq_from_fid(u32 fid)
7271
{
@@ -78,7 +77,6 @@ static u32 find_khz_freq_from_pstate(struct cpufreq_frequency_table *data, u32 p
7877
return data[pstate].frequency;
7978
}
8079

81-
8280
/* Return the vco fid for an input fid
8381
*
8482
* Each "low" fid has corresponding "high" fid, and you can get to "low" fids
@@ -166,7 +164,6 @@ static void fidvid_msr_init(void)
166164
wrmsr(MSR_FIDVID_CTL, lo, hi);
167165
}
168166

169-
170167
/* write the new fid value along with the other control fields to the msr */
171168
static int write_new_fid(struct powernow_k8_data *data, u32 fid)
172169
{
@@ -740,44 +737,63 @@ static int find_psb_table(struct powernow_k8_data *data)
740737
#ifdef CONFIG_X86_POWERNOW_K8_ACPI
741738
static void powernow_k8_acpi_pst_values(struct powernow_k8_data *data, unsigned int index)
742739
{
743-
if (!data->acpi_data.state_count || (cpu_family == CPU_HW_PSTATE))
740+
if (!data->acpi_data->state_count || (cpu_family == CPU_HW_PSTATE))
744741
return;
745742

746-
data->irt = (data->acpi_data.states[index].control >> IRT_SHIFT) & IRT_MASK;
747-
data->rvo = (data->acpi_data.states[index].control >> RVO_SHIFT) & RVO_MASK;
748-
data->exttype = (data->acpi_data.states[index].control >> EXT_TYPE_SHIFT) & EXT_TYPE_MASK;
749-
data->plllock = (data->acpi_data.states[index].control >> PLL_L_SHIFT) & PLL_L_MASK;
750-
data->vidmvs = 1 << ((data->acpi_data.states[index].control >> MVS_SHIFT) & MVS_MASK);
751-
data->vstable = (data->acpi_data.states[index].control >> VST_SHIFT) & VST_MASK;
743+
data->irt = (data->acpi_data->states[index].control >> IRT_SHIFT) & IRT_MASK;
744+
data->rvo = (data->acpi_data->states[index].control >> RVO_SHIFT) & RVO_MASK;
745+
data->exttype = (data->acpi_data->states[index].control >> EXT_TYPE_SHIFT) & EXT_TYPE_MASK;
746+
data->plllock = (data->acpi_data->states[index].control >> PLL_L_SHIFT) & PLL_L_MASK;
747+
data->vidmvs = 1 << ((data->acpi_data->states[index].control >> MVS_SHIFT) & MVS_MASK);
748+
data->vstable = (data->acpi_data->states[index].control >> VST_SHIFT) & VST_MASK;
749+
}
750+
751+
752+
static struct acpi_processor_performance *acpi_perf_data;
753+
static int preregister_valid;
754+
755+
static int powernow_k8_cpu_preinit_acpi(void)
756+
{
757+
acpi_perf_data = alloc_percpu(struct acpi_processor_performance);
758+
if (!acpi_perf_data)
759+
return -ENODEV;
760+
761+
if (acpi_processor_preregister_performance(acpi_perf_data))
762+
return -ENODEV;
763+
else
764+
preregister_valid = 1;
765+
return 0;
752766
}
753767

754768
static int powernow_k8_cpu_init_acpi(struct powernow_k8_data *data)
755769
{
756770
struct cpufreq_frequency_table *powernow_table;
757771
int ret_val;
772+
int cpu = 0;
758773

759-
if (acpi_processor_register_performance(&data->acpi_data, data->cpu)) {
774+
data->acpi_data = percpu_ptr(acpi_perf_data, cpu);
775+
if (acpi_processor_register_performance(data->acpi_data, data->cpu)) {
760776
dprintk("register performance failed: bad ACPI data\n");
761777
return -EIO;
762778
}
763779

764780
/* verify the data contained in the ACPI structures */
765-
if (data->acpi_data.state_count <= 1) {
781+
if (data->acpi_data->state_count <= 1) {
766782
dprintk("No ACPI P-States\n");
767783
goto err_out;
768784
}
769785

770-
if ((data->acpi_data.control_register.space_id != ACPI_ADR_SPACE_FIXED_HARDWARE) ||
771-
(data->acpi_data.status_register.space_id != ACPI_ADR_SPACE_FIXED_HARDWARE)) {
786+
if ((data->acpi_data->control_register.space_id != ACPI_ADR_SPACE_FIXED_HARDWARE) ||
787+
(data->acpi_data->status_register.space_id != ACPI_ADR_SPACE_FIXED_HARDWARE)) {
772788
dprintk("Invalid control/status registers (%x - %x)\n",
773-
data->acpi_data.control_register.space_id,
774-
data->acpi_data.status_register.space_id);
789+
data->acpi_data->control_register.space_id,
790+
data->acpi_data->status_register.space_id);
775791
goto err_out;
776792
}
777793

778794
/* fill in data->powernow_table */
779795
powernow_table = kmalloc((sizeof(struct cpufreq_frequency_table)
780-
* (data->acpi_data.state_count + 1)), GFP_KERNEL);
796+
* (data->acpi_data->state_count + 1)), GFP_KERNEL);
781797
if (!powernow_table) {
782798
dprintk("powernow_table memory alloc failure\n");
783799
goto err_out;
@@ -790,29 +806,44 @@ static int powernow_k8_cpu_init_acpi(struct powernow_k8_data *data)
790806
if (ret_val)
791807
goto err_out_mem;
792808

793-
powernow_table[data->acpi_data.state_count].frequency = CPUFREQ_TABLE_END;
794-
powernow_table[data->acpi_data.state_count].index = 0;
809+
powernow_table[data->acpi_data->state_count].frequency = CPUFREQ_TABLE_END;
810+
powernow_table[data->acpi_data->state_count].index = 0;
795811
data->powernow_table = powernow_table;
796812

797813
/* fill in data */
798-
data->numps = data->acpi_data.state_count;
814+
data->numps = data->acpi_data->state_count;
799815
if (first_cpu(per_cpu(cpu_core_map, data->cpu)) == data->cpu)
800816
print_basics(data);
801817
powernow_k8_acpi_pst_values(data, 0);
802818

803819
/* notify BIOS that we exist */
804820
acpi_processor_notify_smm(THIS_MODULE);
805821

822+
/* determine affinity, from ACPI if available */
823+
if (preregister_valid) {
824+
if ((data->acpi_data->shared_type == CPUFREQ_SHARED_TYPE_ALL) ||
825+
(data->acpi_data->shared_type == CPUFREQ_SHARED_TYPE_ANY))
826+
data->starting_core_affinity = data->acpi_data->shared_cpu_map;
827+
else
828+
data->starting_core_affinity = cpumask_of_cpu(data->cpu);
829+
} else {
830+
/* best guess from family if not */
831+
if (cpu_family == CPU_HW_PSTATE)
832+
data->starting_core_affinity = cpumask_of_cpu(data->cpu);
833+
else
834+
data->starting_core_affinity = per_cpu(cpu_core_map, data->cpu);
835+
}
836+
806837
return 0;
807838

808839
err_out_mem:
809840
kfree(powernow_table);
810841

811842
err_out:
812-
acpi_processor_unregister_performance(&data->acpi_data, data->cpu);
843+
acpi_processor_unregister_performance(data->acpi_data, data->cpu);
813844

814845
/* data->acpi_data.state_count informs us at ->exit() whether ACPI was used */
815-
data->acpi_data.state_count = 0;
846+
data->acpi_data->state_count = 0;
816847

817848
return -ENODEV;
818849
}
@@ -824,10 +855,10 @@ static int fill_powernow_table_pstate(struct powernow_k8_data *data, struct cpuf
824855
rdmsr(MSR_PSTATE_CUR_LIMIT, hi, lo);
825856
data->max_hw_pstate = (hi & HW_PSTATE_MAX_MASK) >> HW_PSTATE_MAX_SHIFT;
826857

827-
for (i = 0; i < data->acpi_data.state_count; i++) {
858+
for (i = 0; i < data->acpi_data->state_count; i++) {
828859
u32 index;
829860

830-
index = data->acpi_data.states[i].control & HW_PSTATE_MASK;
861+
index = data->acpi_data->states[i].control & HW_PSTATE_MASK;
831862
if (index > data->max_hw_pstate) {
832863
printk(KERN_ERR PFX "invalid pstate %d - bad value %d.\n", i, index);
833864
printk(KERN_ERR PFX "Please report to BIOS manufacturer\n");
@@ -843,7 +874,7 @@ static int fill_powernow_table_pstate(struct powernow_k8_data *data, struct cpuf
843874

844875
powernow_table[i].index = index;
845876

846-
powernow_table[i].frequency = data->acpi_data.states[i].core_frequency * 1000;
877+
powernow_table[i].frequency = data->acpi_data->states[i].core_frequency * 1000;
847878
}
848879
return 0;
849880
}
@@ -852,16 +883,16 @@ static int fill_powernow_table_fidvid(struct powernow_k8_data *data, struct cpuf
852883
{
853884
int i;
854885
int cntlofreq = 0;
855-
for (i = 0; i < data->acpi_data.state_count; i++) {
886+
for (i = 0; i < data->acpi_data->state_count; i++) {
856887
u32 fid;
857888
u32 vid;
858889

859890
if (data->exttype) {
860-
fid = data->acpi_data.states[i].status & EXT_FID_MASK;
861-
vid = (data->acpi_data.states[i].status >> VID_SHIFT) & EXT_VID_MASK;
891+
fid = data->acpi_data->states[i].status & EXT_FID_MASK;
892+
vid = (data->acpi_data->states[i].status >> VID_SHIFT) & EXT_VID_MASK;
862893
} else {
863-
fid = data->acpi_data.states[i].control & FID_MASK;
864-
vid = (data->acpi_data.states[i].control >> VID_SHIFT) & VID_MASK;
894+
fid = data->acpi_data->states[i].control & FID_MASK;
895+
vid = (data->acpi_data->states[i].control >> VID_SHIFT) & VID_MASK;
865896
}
866897

867898
dprintk(" %d : fid 0x%x, vid 0x%x\n", i, fid, vid);
@@ -902,10 +933,10 @@ static int fill_powernow_table_fidvid(struct powernow_k8_data *data, struct cpuf
902933
cntlofreq = i;
903934
}
904935

905-
if (powernow_table[i].frequency != (data->acpi_data.states[i].core_frequency * 1000)) {
936+
if (powernow_table[i].frequency != (data->acpi_data->states[i].core_frequency * 1000)) {
906937
printk(KERN_INFO PFX "invalid freq entries %u kHz vs. %u kHz\n",
907938
powernow_table[i].frequency,
908-
(unsigned int) (data->acpi_data.states[i].core_frequency * 1000));
939+
(unsigned int) (data->acpi_data->states[i].core_frequency * 1000));
909940
powernow_table[i].frequency = CPUFREQ_ENTRY_INVALID;
910941
continue;
911942
}
@@ -915,11 +946,12 @@ static int fill_powernow_table_fidvid(struct powernow_k8_data *data, struct cpuf
915946

916947
static void powernow_k8_cpu_exit_acpi(struct powernow_k8_data *data)
917948
{
918-
if (data->acpi_data.state_count)
919-
acpi_processor_unregister_performance(&data->acpi_data, data->cpu);
949+
if (data->acpi_data->state_count)
950+
acpi_processor_unregister_performance(data->acpi_data, data->cpu);
920951
}
921952

922953
#else
954+
static int powernow_k8_cpu_preinit_acpi(void) { return -ENODEV; }
923955
static int powernow_k8_cpu_init_acpi(struct powernow_k8_data *data) { return -ENODEV; }
924956
static void powernow_k8_cpu_exit_acpi(struct powernow_k8_data *data) { return; }
925957
static void powernow_k8_acpi_pst_values(struct powernow_k8_data *data, unsigned int index) { return; }
@@ -1104,7 +1136,7 @@ static int powernowk8_verify(struct cpufreq_policy *pol)
11041136
static int __cpuinit powernowk8_cpu_init(struct cpufreq_policy *pol)
11051137
{
11061138
struct powernow_k8_data *data;
1107-
cpumask_t oldmask;
1139+
cpumask_t oldmask = CPU_MASK_ALL;
11081140
int rc;
11091141

11101142
if (!cpu_online(pol->cpu))
@@ -1177,10 +1209,7 @@ static int __cpuinit powernowk8_cpu_init(struct cpufreq_policy *pol)
11771209
/* run on any CPU again */
11781210
set_cpus_allowed_ptr(current, &oldmask);
11791211

1180-
if (cpu_family == CPU_HW_PSTATE)
1181-
pol->cpus = cpumask_of_cpu(pol->cpu);
1182-
else
1183-
pol->cpus = per_cpu(cpu_core_map, pol->cpu);
1212+
pol->cpus = data->starting_core_affinity;
11841213
data->available_cores = &(pol->cpus);
11851214

11861215
/* Take a crude guess here.
@@ -1303,6 +1332,7 @@ static int __cpuinit powernowk8_init(void)
13031332
}
13041333

13051334
if (supported_cpus == num_online_cpus()) {
1335+
powernow_k8_cpu_preinit_acpi();
13061336
printk(KERN_INFO PFX "Found %d %s "
13071337
"processors (%d cpu cores) (" VERSION ")\n",
13081338
num_online_nodes(),
@@ -1319,6 +1349,10 @@ static void __exit powernowk8_exit(void)
13191349
dprintk("exit\n");
13201350

13211351
cpufreq_unregister_driver(&cpufreq_amd64_driver);
1352+
1353+
#ifdef CONFIG_X86_POWERNOW_K8_ACPI
1354+
free_percpu(acpi_perf_data);
1355+
#endif
13221356
}
13231357

13241358
MODULE_AUTHOR("Paul Devriendt <paul.devriendt@amd.com> and Mark Langsdorf <mark.langsdorf@amd.com>");

arch/x86/kernel/cpu/cpufreq/powernow-k8.h

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -33,12 +33,13 @@ struct powernow_k8_data {
3333
#ifdef CONFIG_X86_POWERNOW_K8_ACPI
3434
/* the acpi table needs to be kept. it's only available if ACPI was
3535
* used to determine valid frequency/vid/fid states */
36-
struct acpi_processor_performance acpi_data;
36+
struct acpi_processor_performance *acpi_data;
3737
#endif
3838
/* we need to keep track of associated cores, but let cpufreq
3939
* handle hotplug events - so just point at cpufreq pol->cpus
4040
* structure */
4141
cpumask_t *available_cores;
42+
cpumask_t starting_core_affinity;
4243
};
4344

4445

drivers/cpufreq/cpufreq_conservative.c

Lines changed: 10 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -333,7 +333,7 @@ static void dbs_check_cpu(int cpu)
333333
{
334334
unsigned int idle_ticks, up_idle_ticks, down_idle_ticks;
335335
unsigned int tmp_idle_ticks, total_idle_ticks;
336-
unsigned int freq_step;
336+
unsigned int freq_target;
337337
unsigned int freq_down_sampling_rate;
338338
struct cpu_dbs_info_s *this_dbs_info = &per_cpu(cpu_dbs_info, cpu);
339339
struct cpufreq_policy *policy;
@@ -383,13 +383,13 @@ static void dbs_check_cpu(int cpu)
383383
if (this_dbs_info->requested_freq == policy->max)
384384
return;
385385

386-
freq_step = (dbs_tuners_ins.freq_step * policy->max) / 100;
386+
freq_target = (dbs_tuners_ins.freq_step * policy->max) / 100;
387387

388388
/* max freq cannot be less than 100. But who knows.... */
389-
if (unlikely(freq_step == 0))
390-
freq_step = 5;
389+
if (unlikely(freq_target == 0))
390+
freq_target = 5;
391391

392-
this_dbs_info->requested_freq += freq_step;
392+
this_dbs_info->requested_freq += freq_target;
393393
if (this_dbs_info->requested_freq > policy->max)
394394
this_dbs_info->requested_freq = policy->max;
395395

@@ -425,19 +425,19 @@ static void dbs_check_cpu(int cpu)
425425
/*
426426
* if we are already at the lowest speed then break out early
427427
* or if we 'cannot' reduce the speed as the user might want
428-
* freq_step to be zero
428+
* freq_target to be zero
429429
*/
430430
if (this_dbs_info->requested_freq == policy->min
431431
|| dbs_tuners_ins.freq_step == 0)
432432
return;
433433

434-
freq_step = (dbs_tuners_ins.freq_step * policy->max) / 100;
434+
freq_target = (dbs_tuners_ins.freq_step * policy->max) / 100;
435435

436436
/* max freq cannot be less than 100. But who knows.... */
437-
if (unlikely(freq_step == 0))
438-
freq_step = 5;
437+
if (unlikely(freq_target == 0))
438+
freq_target = 5;
439439

440-
this_dbs_info->requested_freq -= freq_step;
440+
this_dbs_info->requested_freq -= freq_target;
441441
if (this_dbs_info->requested_freq < policy->min)
442442
this_dbs_info->requested_freq = policy->min;
443443

0 commit comments

Comments
 (0)