From: "Jan Beulich" Subject: [PATCH] misc adjustments to acpi-cpufreq Date: Tue, 03 Feb 2009 15:55:41 +0000 Message-ID: <4988770D.76E4.0078.0@novell.com> Mime-Version: 1.0 Content-Type: text/plain; charset=US-ASCII Content-Transfer-Encoding: quoted-printable Return-path: Content-Disposition: inline List-Unsubscribe: , List-Post: List-Help: List-Subscribe: , Sender: xen-devel-bounces@lists.xensource.com Errors-To: xen-devel-bounces@lists.xensource.com To: xen-devel@lists.xensource.com List-Id: xen-devel@lists.xenproject.org Avoid the call to check_freq() by default, since that function may spin up to 1ms on certain systems without indicating any kind of severe failure. This matches similar behavior in Linux. Avoid doing a cross processor call in get_cur_val() if the current CPU has its bit set in the mask passed in. Also use the local variable 'cpu' consistently, allowing to remove another local variable. Signed-off-by: Jan Beulich --- 2009-01-30.orig/xen/arch/x86/acpi/cpufreq/cpufreq.c 2009-01-08 = 10:30:05.000000000 +0100 +++ 2009-01-30/xen/arch/x86/acpi/cpufreq/cpufreq.c 2009-02-03 = 16:20:02.000000000 +0100 @@ -58,6 +58,9 @@ static struct acpi_cpufreq_data *drv_dat =20 static struct cpufreq_driver acpi_cpufreq_driver; =20 +static unsigned int __read_mostly acpi_pstate_strict; +integer_param("acpi_pstate_strict", acpi_pstate_strict); + static int check_est_cpu(unsigned int cpuid) { struct cpuinfo_x86 *cpu =3D &cpu_data[cpuid]; @@ -193,28 +196,27 @@ static void drv_write(struct drv_cmd *cm =20 static u32 get_cur_val(cpumask_t mask) { - struct cpufreq_policy *policy; struct processor_performance *perf; struct drv_cmd cmd; - unsigned int cpu; + unsigned int cpu =3D smp_processor_id(); =20 if (unlikely(cpus_empty(mask))) return 0; =20 - cpu =3D first_cpu(mask); - policy =3D cpufreq_cpu_policy[cpu]; + if (!cpu_isset(cpu, mask)) + cpu =3D first_cpu(mask); =20 - if (!policy) + if (cpu >=3D NR_CPUS || !drv_data[cpu]) return 0; =20 =20 - switch (drv_data[policy->cpu]->cpu_feature) { + switch (drv_data[cpu]->cpu_feature) { case SYSTEM_INTEL_MSR_CAPABLE: cmd.type =3D SYSTEM_INTEL_MSR_CAPABLE; cmd.addr.msr.reg =3D MSR_IA32_PERF_STATUS; break; case SYSTEM_IO_CAPABLE: cmd.type =3D SYSTEM_IO_CAPABLE; - perf =3D drv_data[first_cpu(mask)]->acpi_data; + perf =3D drv_data[cpu]->acpi_data; cmd.addr.io.port =3D perf->control_register.address; cmd.addr.io.bit_width =3D perf->control_register.bit_width; break; @@ -393,7 +395,7 @@ static int acpi_cpufreq_target(struct cp =20 drv_write(&cmd); =20 - if (!check_freqs(cmd.mask, freqs.new, data)) { + if (acpi_pstate_strict && !check_freqs(cmd.mask, freqs.new, data)) { printk(KERN_WARNING "Fail transfer to new freq %d\n", freqs.new); return -EAGAIN; }