Donate to e Foundation | Murena handsets with /e/OS | Own a part of Murena! Learn more

Commit 26dcce0f authored by Linus Torvalds's avatar Linus Torvalds
Browse files

Merge branch 'cpus4096-for-linus' of...

Merge branch 'cpus4096-for-linus' of git://git.kernel.org/pub/scm/linux/kernel/git/tip/linux-2.6-tip

* 'cpus4096-for-linus' of git://git.kernel.org/pub/scm/linux/kernel/git/tip/linux-2.6-tip: (31 commits)
  NR_CPUS: Replace NR_CPUS in speedstep-centrino.c
  cpumask: Provide a generic set of CPUMASK_ALLOC macros, FIXUP
  NR_CPUS: Replace NR_CPUS in cpufreq userspace routines
  NR_CPUS: Replace per_cpu(..., smp_processor_id()) with __get_cpu_var
  NR_CPUS: Replace NR_CPUS in arch/x86/kernel/genapic_flat_64.c
  NR_CPUS: Replace NR_CPUS in arch/x86/kernel/genx2apic_uv_x.c
  NR_CPUS: Replace NR_CPUS in arch/x86/kernel/cpu/proc.c
  NR_CPUS: Replace NR_CPUS in arch/x86/kernel/cpu/mcheck/mce_64.c
  cpumask: Optimize cpumask_of_cpu in lib/smp_processor_id.c, fix
  cpumask: Use optimized CPUMASK_ALLOC macros in the centrino_target
  cpumask: Provide a generic set of CPUMASK_ALLOC macros
  cpumask: Optimize cpumask_of_cpu in lib/smp_processor_id.c
  cpumask: Optimize cpumask_of_cpu in kernel/time/tick-common.c
  cpumask: Optimize cpumask_of_cpu in drivers/misc/sgi-xp/xpc_main.c
  cpumask: Optimize cpumask_of_cpu in arch/x86/kernel/ldt.c
  cpumask: Optimize cpumask_of_cpu in arch/x86/kernel/io_apic_64.c
  cpumask: Replace cpumask_of_cpu with cpumask_of_cpu_ptr
  Revert "cpumask: introduce new APIs"
  cpumask: make for_each_cpu_mask a bit smaller
  net: Pass reference to cpumask variable in net/sunrpc/svc.c
  ...

Fix up trivial conflicts in drivers/cpufreq/cpufreq.c manually
parents d7b6de14 eb6a12c2
Loading
Loading
Loading
Loading
+2 −1
Original line number Original line Diff line number Diff line
@@ -73,6 +73,7 @@ int acpi_processor_ffh_cstate_probe(unsigned int cpu,
	struct cpuinfo_x86 *c = &cpu_data(cpu);
	struct cpuinfo_x86 *c = &cpu_data(cpu);


	cpumask_t saved_mask;
	cpumask_t saved_mask;
	cpumask_of_cpu_ptr(new_mask, cpu);
	int retval;
	int retval;
	unsigned int eax, ebx, ecx, edx;
	unsigned int eax, ebx, ecx, edx;
	unsigned int edx_part;
	unsigned int edx_part;
@@ -91,7 +92,7 @@ int acpi_processor_ffh_cstate_probe(unsigned int cpu,


	/* Make sure we are running on right CPU */
	/* Make sure we are running on right CPU */
	saved_mask = current->cpus_allowed;
	saved_mask = current->cpus_allowed;
	retval = set_cpus_allowed_ptr(current, &cpumask_of_cpu(cpu));
	retval = set_cpus_allowed_ptr(current, new_mask);
	if (retval)
	if (retval)
		return -1;
		return -1;


+10 −6
Original line number Original line Diff line number Diff line
@@ -200,10 +200,12 @@ static void drv_read(struct drv_cmd *cmd)
static void drv_write(struct drv_cmd *cmd)
static void drv_write(struct drv_cmd *cmd)
{
{
	cpumask_t saved_mask = current->cpus_allowed;
	cpumask_t saved_mask = current->cpus_allowed;
	cpumask_of_cpu_ptr_declare(cpu_mask);
	unsigned int i;
	unsigned int i;


	for_each_cpu_mask(i, cmd->mask) {
	for_each_cpu_mask_nr(i, cmd->mask) {
		set_cpus_allowed_ptr(current, &cpumask_of_cpu(i));
		cpumask_of_cpu_ptr_next(cpu_mask, i);
		set_cpus_allowed_ptr(current, cpu_mask);
		do_drv_write(cmd);
		do_drv_write(cmd);
	}
	}


@@ -267,11 +269,12 @@ static unsigned int get_measured_perf(unsigned int cpu)
	} aperf_cur, mperf_cur;
	} aperf_cur, mperf_cur;


	cpumask_t saved_mask;
	cpumask_t saved_mask;
	cpumask_of_cpu_ptr(cpu_mask, cpu);
	unsigned int perf_percent;
	unsigned int perf_percent;
	unsigned int retval;
	unsigned int retval;


	saved_mask = current->cpus_allowed;
	saved_mask = current->cpus_allowed;
	set_cpus_allowed_ptr(current, &cpumask_of_cpu(cpu));
	set_cpus_allowed_ptr(current, cpu_mask);
	if (get_cpu() != cpu) {
	if (get_cpu() != cpu) {
		/* We were not able to run on requested processor */
		/* We were not able to run on requested processor */
		put_cpu();
		put_cpu();
@@ -337,6 +340,7 @@ static unsigned int get_measured_perf(unsigned int cpu)


static unsigned int get_cur_freq_on_cpu(unsigned int cpu)
static unsigned int get_cur_freq_on_cpu(unsigned int cpu)
{
{
	cpumask_of_cpu_ptr(cpu_mask, cpu);
	struct acpi_cpufreq_data *data = per_cpu(drv_data, cpu);
	struct acpi_cpufreq_data *data = per_cpu(drv_data, cpu);
	unsigned int freq;
	unsigned int freq;
	unsigned int cached_freq;
	unsigned int cached_freq;
@@ -349,7 +353,7 @@ static unsigned int get_cur_freq_on_cpu(unsigned int cpu)
	}
	}


	cached_freq = data->freq_table[data->acpi_data->state].frequency;
	cached_freq = data->freq_table[data->acpi_data->state].frequency;
	freq = extract_freq(get_cur_val(&cpumask_of_cpu(cpu)), data);
	freq = extract_freq(get_cur_val(cpu_mask), data);
	if (freq != cached_freq) {
	if (freq != cached_freq) {
		/*
		/*
		 * The dreaded BIOS frequency change behind our back.
		 * The dreaded BIOS frequency change behind our back.
@@ -451,7 +455,7 @@ static int acpi_cpufreq_target(struct cpufreq_policy *policy,


	freqs.old = perf->states[perf->state].core_frequency * 1000;
	freqs.old = perf->states[perf->state].core_frequency * 1000;
	freqs.new = data->freq_table[next_state].frequency;
	freqs.new = data->freq_table[next_state].frequency;
	for_each_cpu_mask(i, cmd.mask) {
	for_each_cpu_mask_nr(i, cmd.mask) {
		freqs.cpu = i;
		freqs.cpu = i;
		cpufreq_notify_transition(&freqs, CPUFREQ_PRECHANGE);
		cpufreq_notify_transition(&freqs, CPUFREQ_PRECHANGE);
	}
	}
@@ -466,7 +470,7 @@ static int acpi_cpufreq_target(struct cpufreq_policy *policy,
		}
		}
	}
	}


	for_each_cpu_mask(i, cmd.mask) {
	for_each_cpu_mask_nr(i, cmd.mask) {
		freqs.cpu = i;
		freqs.cpu = i;
		cpufreq_notify_transition(&freqs, CPUFREQ_POSTCHANGE);
		cpufreq_notify_transition(&freqs, CPUFREQ_POSTCHANGE);
	}
	}
+3 −3
Original line number Original line Diff line number Diff line
@@ -122,7 +122,7 @@ static int cpufreq_p4_target(struct cpufreq_policy *policy,
		return 0;
		return 0;


	/* notifiers */
	/* notifiers */
	for_each_cpu_mask(i, policy->cpus) {
	for_each_cpu_mask_nr(i, policy->cpus) {
		freqs.cpu = i;
		freqs.cpu = i;
		cpufreq_notify_transition(&freqs, CPUFREQ_PRECHANGE);
		cpufreq_notify_transition(&freqs, CPUFREQ_PRECHANGE);
	}
	}
@@ -130,11 +130,11 @@ static int cpufreq_p4_target(struct cpufreq_policy *policy,
	/* run on each logical CPU, see section 13.15.3 of IA32 Intel Architecture Software
	/* run on each logical CPU, see section 13.15.3 of IA32 Intel Architecture Software
	 * Developer's Manual, Volume 3
	 * Developer's Manual, Volume 3
	 */
	 */
	for_each_cpu_mask(i, policy->cpus)
	for_each_cpu_mask_nr(i, policy->cpus)
		cpufreq_p4_setdc(i, p4clockmod_table[newstate].index);
		cpufreq_p4_setdc(i, p4clockmod_table[newstate].index);


	/* notifiers */
	/* notifiers */
	for_each_cpu_mask(i, policy->cpus) {
	for_each_cpu_mask_nr(i, policy->cpus) {
		freqs.cpu = i;
		freqs.cpu = i;
		cpufreq_notify_transition(&freqs, CPUFREQ_POSTCHANGE);
		cpufreq_notify_transition(&freqs, CPUFREQ_POSTCHANGE);
	}
	}
+14 −9
Original line number Original line Diff line number Diff line
@@ -479,11 +479,12 @@ static int core_voltage_post_transition(struct powernow_k8_data *data, u32 reqvi
static int check_supported_cpu(unsigned int cpu)
static int check_supported_cpu(unsigned int cpu)
{
{
	cpumask_t oldmask;
	cpumask_t oldmask;
	cpumask_of_cpu_ptr(cpu_mask, cpu);
	u32 eax, ebx, ecx, edx;
	u32 eax, ebx, ecx, edx;
	unsigned int rc = 0;
	unsigned int rc = 0;


	oldmask = current->cpus_allowed;
	oldmask = current->cpus_allowed;
	set_cpus_allowed_ptr(current, &cpumask_of_cpu(cpu));
	set_cpus_allowed_ptr(current, cpu_mask);


	if (smp_processor_id() != cpu) {
	if (smp_processor_id() != cpu) {
		printk(KERN_ERR PFX "limiting to cpu %u failed\n", cpu);
		printk(KERN_ERR PFX "limiting to cpu %u failed\n", cpu);
@@ -966,7 +967,7 @@ static int transition_frequency_fidvid(struct powernow_k8_data *data, unsigned i
	freqs.old = find_khz_freq_from_fid(data->currfid);
	freqs.old = find_khz_freq_from_fid(data->currfid);
	freqs.new = find_khz_freq_from_fid(fid);
	freqs.new = find_khz_freq_from_fid(fid);


	for_each_cpu_mask(i, *(data->available_cores)) {
	for_each_cpu_mask_nr(i, *(data->available_cores)) {
		freqs.cpu = i;
		freqs.cpu = i;
		cpufreq_notify_transition(&freqs, CPUFREQ_PRECHANGE);
		cpufreq_notify_transition(&freqs, CPUFREQ_PRECHANGE);
	}
	}
@@ -974,7 +975,7 @@ static int transition_frequency_fidvid(struct powernow_k8_data *data, unsigned i
	res = transition_fid_vid(data, fid, vid);
	res = transition_fid_vid(data, fid, vid);
	freqs.new = find_khz_freq_from_fid(data->currfid);
	freqs.new = find_khz_freq_from_fid(data->currfid);


	for_each_cpu_mask(i, *(data->available_cores)) {
	for_each_cpu_mask_nr(i, *(data->available_cores)) {
		freqs.cpu = i;
		freqs.cpu = i;
		cpufreq_notify_transition(&freqs, CPUFREQ_POSTCHANGE);
		cpufreq_notify_transition(&freqs, CPUFREQ_POSTCHANGE);
	}
	}
@@ -997,7 +998,7 @@ static int transition_frequency_pstate(struct powernow_k8_data *data, unsigned i
	freqs.old = find_khz_freq_from_pstate(data->powernow_table, data->currpstate);
	freqs.old = find_khz_freq_from_pstate(data->powernow_table, data->currpstate);
	freqs.new = find_khz_freq_from_pstate(data->powernow_table, pstate);
	freqs.new = find_khz_freq_from_pstate(data->powernow_table, pstate);


	for_each_cpu_mask(i, *(data->available_cores)) {
	for_each_cpu_mask_nr(i, *(data->available_cores)) {
		freqs.cpu = i;
		freqs.cpu = i;
		cpufreq_notify_transition(&freqs, CPUFREQ_PRECHANGE);
		cpufreq_notify_transition(&freqs, CPUFREQ_PRECHANGE);
	}
	}
@@ -1005,7 +1006,7 @@ static int transition_frequency_pstate(struct powernow_k8_data *data, unsigned i
	res = transition_pstate(data, pstate);
	res = transition_pstate(data, pstate);
	freqs.new = find_khz_freq_from_pstate(data->powernow_table, pstate);
	freqs.new = find_khz_freq_from_pstate(data->powernow_table, pstate);


	for_each_cpu_mask(i, *(data->available_cores)) {
	for_each_cpu_mask_nr(i, *(data->available_cores)) {
		freqs.cpu = i;
		freqs.cpu = i;
		cpufreq_notify_transition(&freqs, CPUFREQ_POSTCHANGE);
		cpufreq_notify_transition(&freqs, CPUFREQ_POSTCHANGE);
	}
	}
@@ -1016,6 +1017,7 @@ static int transition_frequency_pstate(struct powernow_k8_data *data, unsigned i
static int powernowk8_target(struct cpufreq_policy *pol, unsigned targfreq, unsigned relation)
static int powernowk8_target(struct cpufreq_policy *pol, unsigned targfreq, unsigned relation)
{
{
	cpumask_t oldmask;
	cpumask_t oldmask;
	cpumask_of_cpu_ptr(cpu_mask, pol->cpu);
	struct powernow_k8_data *data = per_cpu(powernow_data, pol->cpu);
	struct powernow_k8_data *data = per_cpu(powernow_data, pol->cpu);
	u32 checkfid;
	u32 checkfid;
	u32 checkvid;
	u32 checkvid;
@@ -1030,7 +1032,7 @@ static int powernowk8_target(struct cpufreq_policy *pol, unsigned targfreq, unsi


	/* only run on specific CPU from here on */
	/* only run on specific CPU from here on */
	oldmask = current->cpus_allowed;
	oldmask = current->cpus_allowed;
	set_cpus_allowed_ptr(current, &cpumask_of_cpu(pol->cpu));
	set_cpus_allowed_ptr(current, cpu_mask);


	if (smp_processor_id() != pol->cpu) {
	if (smp_processor_id() != pol->cpu) {
		printk(KERN_ERR PFX "limiting to cpu %u failed\n", pol->cpu);
		printk(KERN_ERR PFX "limiting to cpu %u failed\n", pol->cpu);
@@ -1105,6 +1107,7 @@ static int __cpuinit powernowk8_cpu_init(struct cpufreq_policy *pol)
{
{
	struct powernow_k8_data *data;
	struct powernow_k8_data *data;
	cpumask_t oldmask;
	cpumask_t oldmask;
	cpumask_of_cpu_ptr_declare(newmask);
	int rc;
	int rc;


	if (!cpu_online(pol->cpu))
	if (!cpu_online(pol->cpu))
@@ -1156,7 +1159,8 @@ static int __cpuinit powernowk8_cpu_init(struct cpufreq_policy *pol)


	/* only run on specific CPU from here on */
	/* only run on specific CPU from here on */
	oldmask = current->cpus_allowed;
	oldmask = current->cpus_allowed;
	set_cpus_allowed_ptr(current, &cpumask_of_cpu(pol->cpu));
	cpumask_of_cpu_ptr_next(newmask, pol->cpu);
	set_cpus_allowed_ptr(current, newmask);


	if (smp_processor_id() != pol->cpu) {
	if (smp_processor_id() != pol->cpu) {
		printk(KERN_ERR PFX "limiting to cpu %u failed\n", pol->cpu);
		printk(KERN_ERR PFX "limiting to cpu %u failed\n", pol->cpu);
@@ -1178,7 +1182,7 @@ static int __cpuinit powernowk8_cpu_init(struct cpufreq_policy *pol)
	set_cpus_allowed_ptr(current, &oldmask);
	set_cpus_allowed_ptr(current, &oldmask);


	if (cpu_family == CPU_HW_PSTATE)
	if (cpu_family == CPU_HW_PSTATE)
		pol->cpus = cpumask_of_cpu(pol->cpu);
		pol->cpus = *newmask;
	else
	else
		pol->cpus = per_cpu(cpu_core_map, pol->cpu);
		pol->cpus = per_cpu(cpu_core_map, pol->cpu);
	data->available_cores = &(pol->cpus);
	data->available_cores = &(pol->cpus);
@@ -1244,6 +1248,7 @@ static unsigned int powernowk8_get (unsigned int cpu)
{
{
	struct powernow_k8_data *data;
	struct powernow_k8_data *data;
	cpumask_t oldmask = current->cpus_allowed;
	cpumask_t oldmask = current->cpus_allowed;
	cpumask_of_cpu_ptr(newmask, cpu);
	unsigned int khz = 0;
	unsigned int khz = 0;
	unsigned int first;
	unsigned int first;


@@ -1253,7 +1258,7 @@ static unsigned int powernowk8_get (unsigned int cpu)
	if (!data)
	if (!data)
		return -EINVAL;
		return -EINVAL;


	set_cpus_allowed_ptr(current, &cpumask_of_cpu(cpu));
	set_cpus_allowed_ptr(current, newmask);
	if (smp_processor_id() != cpu) {
	if (smp_processor_id() != cpu) {
		printk(KERN_ERR PFX
		printk(KERN_ERR PFX
			"limiting to CPU %d failed in powernowk8_get\n", cpu);
			"limiting to CPU %d failed in powernowk8_get\n", cpu);
+97 −60
Original line number Original line Diff line number Diff line
@@ -28,7 +28,8 @@
#define PFX		"speedstep-centrino: "
#define PFX		"speedstep-centrino: "
#define MAINTAINER	"cpufreq@lists.linux.org.uk"
#define MAINTAINER	"cpufreq@lists.linux.org.uk"


#define dprintk(msg...) cpufreq_debug_printk(CPUFREQ_DEBUG_DRIVER, "speedstep-centrino", msg)
#define dprintk(msg...) \
	cpufreq_debug_printk(CPUFREQ_DEBUG_DRIVER, "speedstep-centrino", msg)


#define INTEL_MSR_RANGE	(0xffff)
#define INTEL_MSR_RANGE	(0xffff)


@@ -66,11 +67,12 @@ struct cpu_model


	struct cpufreq_frequency_table *op_points; /* clock/voltage pairs */
	struct cpufreq_frequency_table *op_points; /* clock/voltage pairs */
};
};
static int centrino_verify_cpu_id(const struct cpuinfo_x86 *c, const struct cpu_id *x);
static int centrino_verify_cpu_id(const struct cpuinfo_x86 *c,
				  const struct cpu_id *x);


/* Operating points for current CPU */
/* Operating points for current CPU */
static struct cpu_model *centrino_model[NR_CPUS];
static DEFINE_PER_CPU(struct cpu_model *, centrino_model);
static const struct cpu_id *centrino_cpu[NR_CPUS];
static DEFINE_PER_CPU(const struct cpu_id *, centrino_cpu);


static struct cpufreq_driver centrino_driver;
static struct cpufreq_driver centrino_driver;


@@ -255,7 +257,7 @@ static int centrino_cpu_init_table(struct cpufreq_policy *policy)
		return -ENOENT;
		return -ENOENT;
	}
	}


	centrino_model[policy->cpu] = model;
	per_cpu(centrino_model, policy->cpu) = model;


	dprintk("found \"%s\": max frequency: %dkHz\n",
	dprintk("found \"%s\": max frequency: %dkHz\n",
	       model->model_name, model->max_freq);
	       model->model_name, model->max_freq);
@@ -264,10 +266,14 @@ static int centrino_cpu_init_table(struct cpufreq_policy *policy)
}
}


#else
#else
static inline int centrino_cpu_init_table(struct cpufreq_policy *policy) { return -ENODEV; }
static inline int centrino_cpu_init_table(struct cpufreq_policy *policy)
{
	return -ENODEV;
}
#endif /* CONFIG_X86_SPEEDSTEP_CENTRINO_TABLE */
#endif /* CONFIG_X86_SPEEDSTEP_CENTRINO_TABLE */


static int centrino_verify_cpu_id(const struct cpuinfo_x86 *c, const struct cpu_id *x)
static int centrino_verify_cpu_id(const struct cpuinfo_x86 *c,
				  const struct cpu_id *x)
{
{
	if ((c->x86 == x->x86) &&
	if ((c->x86 == x->x86) &&
	    (c->x86_model == x->x86_model) &&
	    (c->x86_model == x->x86_model) &&
@@ -286,23 +292,28 @@ static unsigned extract_clock(unsigned msr, unsigned int cpu, int failsafe)
	 * for centrino, as some DSDTs are buggy.
	 * for centrino, as some DSDTs are buggy.
	 * Ideally, this can be done using the acpi_data structure.
	 * Ideally, this can be done using the acpi_data structure.
	 */
	 */
	if ((centrino_cpu[cpu] == &cpu_ids[CPU_BANIAS]) ||
	if ((per_cpu(centrino_cpu, cpu) == &cpu_ids[CPU_BANIAS]) ||
	    (centrino_cpu[cpu] == &cpu_ids[CPU_DOTHAN_A1]) ||
	    (per_cpu(centrino_cpu, cpu) == &cpu_ids[CPU_DOTHAN_A1]) ||
	    (centrino_cpu[cpu] == &cpu_ids[CPU_DOTHAN_B0])) {
	    (per_cpu(centrino_cpu, cpu) == &cpu_ids[CPU_DOTHAN_B0])) {
		msr = (msr >> 8) & 0xff;
		msr = (msr >> 8) & 0xff;
		return msr * 100000;
		return msr * 100000;
	}
	}


	if ((!centrino_model[cpu]) || (!centrino_model[cpu]->op_points))
	if ((!per_cpu(centrino_model, cpu)) ||
	    (!per_cpu(centrino_model, cpu)->op_points))
		return 0;
		return 0;


	msr &= 0xffff;
	msr &= 0xffff;
	for (i=0;centrino_model[cpu]->op_points[i].frequency != CPUFREQ_TABLE_END; i++) {
	for (i = 0;
		if (msr == centrino_model[cpu]->op_points[i].index)
		per_cpu(centrino_model, cpu)->op_points[i].frequency
			return centrino_model[cpu]->op_points[i].frequency;
							!= CPUFREQ_TABLE_END;
	     i++) {
		if (msr == per_cpu(centrino_model, cpu)->op_points[i].index)
			return per_cpu(centrino_model, cpu)->
							op_points[i].frequency;
	}
	}
	if (failsafe)
	if (failsafe)
		return centrino_model[cpu]->op_points[i-1].frequency;
		return per_cpu(centrino_model, cpu)->op_points[i-1].frequency;
	else
	else
		return 0;
		return 0;
}
}
@@ -313,9 +324,10 @@ static unsigned int get_cur_freq(unsigned int cpu)
	unsigned l, h;
	unsigned l, h;
	unsigned clock_freq;
	unsigned clock_freq;
	cpumask_t saved_mask;
	cpumask_t saved_mask;
	cpumask_of_cpu_ptr(new_mask, cpu);


	saved_mask = current->cpus_allowed;
	saved_mask = current->cpus_allowed;
	set_cpus_allowed_ptr(current, &cpumask_of_cpu(cpu));
	set_cpus_allowed_ptr(current, new_mask);
	if (smp_processor_id() != cpu)
	if (smp_processor_id() != cpu)
		return 0;
		return 0;


@@ -347,7 +359,8 @@ static int centrino_cpu_init(struct cpufreq_policy *policy)
	int i;
	int i;


	/* Only Intel makes Enhanced Speedstep-capable CPUs */
	/* Only Intel makes Enhanced Speedstep-capable CPUs */
	if (cpu->x86_vendor != X86_VENDOR_INTEL || !cpu_has(cpu, X86_FEATURE_EST))
	if (cpu->x86_vendor != X86_VENDOR_INTEL ||
	    !cpu_has(cpu, X86_FEATURE_EST))
		return -ENODEV;
		return -ENODEV;


	if (cpu_has(cpu, X86_FEATURE_CONSTANT_TSC))
	if (cpu_has(cpu, X86_FEATURE_CONSTANT_TSC))
@@ -361,9 +374,9 @@ static int centrino_cpu_init(struct cpufreq_policy *policy)
			break;
			break;


	if (i != N_IDS)
	if (i != N_IDS)
		centrino_cpu[policy->cpu] = &cpu_ids[i];
		per_cpu(centrino_cpu, policy->cpu) = &cpu_ids[i];


	if (!centrino_cpu[policy->cpu]) {
	if (!per_cpu(centrino_cpu, policy->cpu)) {
		dprintk("found unsupported CPU with "
		dprintk("found unsupported CPU with "
		"Enhanced SpeedStep: send /proc/cpuinfo to "
		"Enhanced SpeedStep: send /proc/cpuinfo to "
		MAINTAINER "\n");
		MAINTAINER "\n");
@@ -386,23 +399,26 @@ static int centrino_cpu_init(struct cpufreq_policy *policy)
		/* check to see if it stuck */
		/* check to see if it stuck */
		rdmsr(MSR_IA32_MISC_ENABLE, l, h);
		rdmsr(MSR_IA32_MISC_ENABLE, l, h);
		if (!(l & (1<<16))) {
		if (!(l & (1<<16))) {
			printk(KERN_INFO PFX "couldn't enable Enhanced SpeedStep\n");
			printk(KERN_INFO PFX
				"couldn't enable Enhanced SpeedStep\n");
			return -ENODEV;
			return -ENODEV;
		}
		}
	}
	}


	freq = get_cur_freq(policy->cpu);
	freq = get_cur_freq(policy->cpu);

	policy->cpuinfo.transition_latency = 10000;
	policy->cpuinfo.transition_latency = 10000; /* 10uS transition latency */
						/* 10uS transition latency */
	policy->cur = freq;
	policy->cur = freq;


	dprintk("centrino_cpu_init: cur=%dkHz\n", policy->cur);
	dprintk("centrino_cpu_init: cur=%dkHz\n", policy->cur);


	ret = cpufreq_frequency_table_cpuinfo(policy, centrino_model[policy->cpu]->op_points);
	ret = cpufreq_frequency_table_cpuinfo(policy,
		per_cpu(centrino_model, policy->cpu)->op_points);
	if (ret)
	if (ret)
		return (ret);
		return (ret);


	cpufreq_frequency_table_get_attr(centrino_model[policy->cpu]->op_points, policy->cpu);
	cpufreq_frequency_table_get_attr(
		per_cpu(centrino_model, policy->cpu)->op_points, policy->cpu);


	return 0;
	return 0;
}
}
@@ -411,12 +427,12 @@ static int centrino_cpu_exit(struct cpufreq_policy *policy)
{
{
	unsigned int cpu = policy->cpu;
	unsigned int cpu = policy->cpu;


	if (!centrino_model[cpu])
	if (!per_cpu(centrino_model, cpu))
		return -ENODEV;
		return -ENODEV;


	cpufreq_frequency_table_put_attr(cpu);
	cpufreq_frequency_table_put_attr(cpu);


	centrino_model[cpu] = NULL;
	per_cpu(centrino_model, cpu) = NULL;


	return 0;
	return 0;
}
}
@@ -430,17 +446,26 @@ static int centrino_cpu_exit(struct cpufreq_policy *policy)
 */
 */
static int centrino_verify (struct cpufreq_policy *policy)
static int centrino_verify (struct cpufreq_policy *policy)
{
{
	return cpufreq_frequency_table_verify(policy, centrino_model[policy->cpu]->op_points);
	return cpufreq_frequency_table_verify(policy,
			per_cpu(centrino_model, policy->cpu)->op_points);
}
}


/**
/**
 * centrino_setpolicy - set a new CPUFreq policy
 * centrino_setpolicy - set a new CPUFreq policy
 * @policy: new policy
 * @policy: new policy
 * @target_freq: the target frequency
 * @target_freq: the target frequency
 * @relation: how that frequency relates to achieved frequency (CPUFREQ_RELATION_L or CPUFREQ_RELATION_H)
 * @relation: how that frequency relates to achieved frequency
 *	(CPUFREQ_RELATION_L or CPUFREQ_RELATION_H)
 *
 *
 * Sets a new CPUFreq policy.
 * Sets a new CPUFreq policy.
 */
 */
struct allmasks {
	cpumask_t		online_policy_cpus;
	cpumask_t		saved_mask;
	cpumask_t		set_mask;
	cpumask_t		covered_cpus;
};

static int centrino_target (struct cpufreq_policy *policy,
static int centrino_target (struct cpufreq_policy *policy,
			    unsigned int target_freq,
			    unsigned int target_freq,
			    unsigned int relation)
			    unsigned int relation)
@@ -448,48 +473,55 @@ static int centrino_target (struct cpufreq_policy *policy,
	unsigned int    newstate = 0;
	unsigned int    newstate = 0;
	unsigned int	msr, oldmsr = 0, h = 0, cpu = policy->cpu;
	unsigned int	msr, oldmsr = 0, h = 0, cpu = policy->cpu;
	struct cpufreq_freqs	freqs;
	struct cpufreq_freqs	freqs;
	cpumask_t		online_policy_cpus;
	cpumask_t		saved_mask;
	cpumask_t		set_mask;
	cpumask_t		covered_cpus;
	int			retval = 0;
	int			retval = 0;
	unsigned int		j, k, first_cpu, tmp;
	unsigned int		j, k, first_cpu, tmp;
	CPUMASK_ALLOC(allmasks);
	CPUMASK_PTR(online_policy_cpus, allmasks);
	CPUMASK_PTR(saved_mask, allmasks);
	CPUMASK_PTR(set_mask, allmasks);
	CPUMASK_PTR(covered_cpus, allmasks);


	if (unlikely(centrino_model[cpu] == NULL))
	if (unlikely(allmasks == NULL))
		return -ENODEV;
		return -ENOMEM;

	if (unlikely(per_cpu(centrino_model, cpu) == NULL)) {
		retval = -ENODEV;
		goto out;
	}


	if (unlikely(cpufreq_frequency_table_target(policy,
	if (unlikely(cpufreq_frequency_table_target(policy,
			centrino_model[cpu]->op_points,
			per_cpu(centrino_model, cpu)->op_points,
			target_freq,
			target_freq,
			relation,
			relation,
			&newstate))) {
			&newstate))) {
		return -EINVAL;
		retval = -EINVAL;
		goto out;
	}
	}


#ifdef CONFIG_HOTPLUG_CPU
#ifdef CONFIG_HOTPLUG_CPU
	/* cpufreq holds the hotplug lock, so we are safe from here on */
	/* cpufreq holds the hotplug lock, so we are safe from here on */
	cpus_and(online_policy_cpus, cpu_online_map, policy->cpus);
	cpus_and(*online_policy_cpus, cpu_online_map, policy->cpus);
#else
#else
	online_policy_cpus = policy->cpus;
	*online_policy_cpus = policy->cpus;
#endif
#endif


	saved_mask = current->cpus_allowed;
	*saved_mask = current->cpus_allowed;
	first_cpu = 1;
	first_cpu = 1;
	cpus_clear(covered_cpus);
	cpus_clear(*covered_cpus);
	for_each_cpu_mask(j, online_policy_cpus) {
	for_each_cpu_mask_nr(j, *online_policy_cpus) {
		/*
		/*
		 * Support for SMP systems.
		 * Support for SMP systems.
		 * Make sure we are running on CPU that wants to change freq
		 * Make sure we are running on CPU that wants to change freq
		 */
		 */
		cpus_clear(set_mask);
		cpus_clear(*set_mask);
		if (policy->shared_type == CPUFREQ_SHARED_TYPE_ANY)
		if (policy->shared_type == CPUFREQ_SHARED_TYPE_ANY)
			cpus_or(set_mask, set_mask, online_policy_cpus);
			cpus_or(*set_mask, *set_mask, *online_policy_cpus);
		else
		else
			cpu_set(j, set_mask);
			cpu_set(j, *set_mask);


		set_cpus_allowed_ptr(current, &set_mask);
		set_cpus_allowed_ptr(current, set_mask);
		preempt_disable();
		preempt_disable();
		if (unlikely(!cpu_isset(smp_processor_id(), set_mask))) {
		if (unlikely(!cpu_isset(smp_processor_id(), *set_mask))) {
			dprintk("couldn't limit to CPUs in this domain\n");
			dprintk("couldn't limit to CPUs in this domain\n");
			retval = -EAGAIN;
			retval = -EAGAIN;
			if (first_cpu) {
			if (first_cpu) {
@@ -500,7 +532,7 @@ static int centrino_target (struct cpufreq_policy *policy,
			break;
			break;
		}
		}


		msr = centrino_model[cpu]->op_points[newstate].index;
		msr = per_cpu(centrino_model, cpu)->op_points[newstate].index;


		if (first_cpu) {
		if (first_cpu) {
			rdmsr(MSR_IA32_PERF_CTL, oldmsr, h);
			rdmsr(MSR_IA32_PERF_CTL, oldmsr, h);
@@ -517,7 +549,7 @@ static int centrino_target (struct cpufreq_policy *policy,
			dprintk("target=%dkHz old=%d new=%d msr=%04x\n",
			dprintk("target=%dkHz old=%d new=%d msr=%04x\n",
				target_freq, freqs.old, freqs.new, msr);
				target_freq, freqs.old, freqs.new, msr);


			for_each_cpu_mask(k, online_policy_cpus) {
			for_each_cpu_mask_nr(k, *online_policy_cpus) {
				freqs.cpu = k;
				freqs.cpu = k;
				cpufreq_notify_transition(&freqs,
				cpufreq_notify_transition(&freqs,
					CPUFREQ_PRECHANGE);
					CPUFREQ_PRECHANGE);
@@ -536,11 +568,11 @@ static int centrino_target (struct cpufreq_policy *policy,
			break;
			break;
		}
		}


		cpu_set(j, covered_cpus);
		cpu_set(j, *covered_cpus);
		preempt_enable();
		preempt_enable();
	}
	}


	for_each_cpu_mask(k, online_policy_cpus) {
	for_each_cpu_mask_nr(k, *online_policy_cpus) {
		freqs.cpu = k;
		freqs.cpu = k;
		cpufreq_notify_transition(&freqs, CPUFREQ_POSTCHANGE);
		cpufreq_notify_transition(&freqs, CPUFREQ_POSTCHANGE);
	}
	}
@@ -553,10 +585,12 @@ static int centrino_target (struct cpufreq_policy *policy,
		 * Best effort undo..
		 * Best effort undo..
		 */
		 */


		if (!cpus_empty(covered_cpus)) {
		if (!cpus_empty(*covered_cpus)) {
			for_each_cpu_mask(j, covered_cpus) {
			cpumask_of_cpu_ptr_declare(new_mask);
				set_cpus_allowed_ptr(current,

						     &cpumask_of_cpu(j));
			for_each_cpu_mask_nr(j, *covered_cpus) {
				cpumask_of_cpu_ptr_next(new_mask, j);
				set_cpus_allowed_ptr(current, new_mask);
				wrmsr(MSR_IA32_PERF_CTL, oldmsr, h);
				wrmsr(MSR_IA32_PERF_CTL, oldmsr, h);
			}
			}
		}
		}
@@ -564,19 +598,22 @@ static int centrino_target (struct cpufreq_policy *policy,
		tmp = freqs.new;
		tmp = freqs.new;
		freqs.new = freqs.old;
		freqs.new = freqs.old;
		freqs.old = tmp;
		freqs.old = tmp;
		for_each_cpu_mask(j, online_policy_cpus) {
		for_each_cpu_mask_nr(j, *online_policy_cpus) {
			freqs.cpu = j;
			freqs.cpu = j;
			cpufreq_notify_transition(&freqs, CPUFREQ_PRECHANGE);
			cpufreq_notify_transition(&freqs, CPUFREQ_PRECHANGE);
			cpufreq_notify_transition(&freqs, CPUFREQ_POSTCHANGE);
			cpufreq_notify_transition(&freqs, CPUFREQ_POSTCHANGE);
		}
		}
	}
	}
	set_cpus_allowed_ptr(current, &saved_mask);
	set_cpus_allowed_ptr(current, saved_mask);
	return 0;
	retval = 0;
	goto out;


migrate_end:
migrate_end:
	preempt_enable();
	preempt_enable();
	set_cpus_allowed_ptr(current, &saved_mask);
	set_cpus_allowed_ptr(current, saved_mask);
	return 0;
out:
	CPUMASK_FREE(allmasks);
	return retval;
}
}


static struct freq_attr* centrino_attr[] = {
static struct freq_attr* centrino_attr[] = {
Loading