[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index] [Xen-devel] [PATCH v2] x86, cpufreq: Change powernow's CPB status immediately
# HG changeset patch # User Boris Ostrovsky <boris.ostrovsky@xxxxxxx> # Date 1339592992 -7200 # Node ID 08cf5548d5ccc2995661fb25047906094a6b3deb # Parent 32034d1914a607d7b6f1f060352b4cac973600f8 x86, cpufreq: Change powernow's CPB status immediately When command to modify turbo mode (CPB on AMD processors) comes in the actual change happens later, when P-state transition is requested. There is no time limit on when this transition will occur and therefore change in CPB state may take long time from the moment when command to toggle it is issued. This patch makes CPB mode change happen immediately when request is made. Signed-off-by: Boris Ostrovsky <boris.ostrovsky@xxxxxxx> diff -r 32034d1914a6 -r 08cf5548d5cc xen/arch/x86/acpi/cpufreq/powernow.c --- a/xen/arch/x86/acpi/cpufreq/powernow.c Thu Jun 07 19:46:57 2012 +0100 +++ b/xen/arch/x86/acpi/cpufreq/powernow.c Wed Jun 13 15:09:52 2012 +0200 @@ -68,16 +68,37 @@ static void transition_pstate(void *drvc struct drv_cmd *cmd; cmd = (struct drv_cmd *) drvcmd; - if (cmd->turbo != CPUFREQ_TURBO_UNSUPPORTED) { + + wrmsrl(MSR_PSTATE_CTRL, cmd->val); +} + +static void update_cpb(void *data) +{ + struct cpufreq_policy *policy = (struct cpufreq_policy *)data; + + if (policy->turbo != CPUFREQ_TURBO_UNSUPPORTED) { uint64_t msr_content; + rdmsrl(MSR_K8_HWCR, msr_content); - if (cmd->turbo == CPUFREQ_TURBO_ENABLED) + + if (policy->turbo == CPUFREQ_TURBO_ENABLED) msr_content &= ~MSR_HWCR_CPBDIS_MASK; else msr_content |= MSR_HWCR_CPBDIS_MASK; + wrmsrl(MSR_K8_HWCR, msr_content); } - wrmsrl(MSR_PSTATE_CTRL, cmd->val); +} + +static int powernow_cpufreq_update (int cpuid, + struct cpufreq_policy *policy) +{ + if (!cpumask_test_cpu(cpuid, &cpu_online_map)) + return -EINVAL; + + on_selected_cpus(cpumask_of(cpuid), update_cpb, policy, 1); + + return 0; } static int powernow_cpufreq_target(struct cpufreq_policy *policy, @@ -300,7 +321,8 @@ static struct cpufreq_driver powernow_cp .verify = powernow_cpufreq_verify, .target = powernow_cpufreq_target, .init = powernow_cpufreq_cpu_init, - .exit = powernow_cpufreq_cpu_exit + .exit = powernow_cpufreq_cpu_exit, + .update = powernow_cpufreq_update }; unsigned int __init powernow_register_driver() diff -r 32034d1914a6 -r 08cf5548d5cc xen/drivers/acpi/pmstat.c --- a/xen/drivers/acpi/pmstat.c Thu Jun 07 19:46:57 2012 +0100 +++ b/xen/drivers/acpi/pmstat.c Wed Jun 13 15:09:52 2012 +0200 @@ -494,13 +494,13 @@ int do_pm_op(struct xen_sysctl_pm_op *op case XEN_SYSCTL_pm_op_enable_turbo: { - cpufreq_enable_turbo(op->cpuid); + ret = cpufreq_update_turbo(op->cpuid, CPUFREQ_TURBO_ENABLED); break; } case XEN_SYSCTL_pm_op_disable_turbo: { - cpufreq_disable_turbo(op->cpuid); + ret = cpufreq_update_turbo(op->cpuid, CPUFREQ_TURBO_DISABLED); break; } diff -r 32034d1914a6 -r 08cf5548d5cc xen/drivers/cpufreq/utility.c --- a/xen/drivers/cpufreq/utility.c Thu Jun 07 19:46:57 2012 +0100 +++ b/xen/drivers/cpufreq/utility.c Wed Jun 13 15:09:52 2012 +0200 @@ -390,23 +390,38 @@ int cpufreq_driver_getavg(unsigned int c return policy->cur; } -void cpufreq_enable_turbo(int cpuid) +int cpufreq_update_turbo(int cpuid, int new_state) { struct cpufreq_policy *policy; + int curr_state; + int ret = 0; + + if (new_state != CPUFREQ_TURBO_ENABLED && + new_state != CPUFREQ_TURBO_DISABLED) + return -EINVAL; policy = per_cpu(cpufreq_cpu_policy, cpuid); - if (policy && policy->turbo != CPUFREQ_TURBO_UNSUPPORTED) - policy->turbo = CPUFREQ_TURBO_ENABLED; + if (!policy) + return -EACCES; + + if (policy->turbo == CPUFREQ_TURBO_UNSUPPORTED) + return -EOPNOTSUPP; + + curr_state = policy->turbo; + if (curr_state == new_state) + return 0; + + policy->turbo = new_state; + if (cpufreq_driver->update) + { + ret = cpufreq_driver->update(cpuid, policy); + if (ret) + policy->turbo = curr_state; + } + + return ret; } -void cpufreq_disable_turbo(int cpuid) -{ - struct cpufreq_policy *policy; - - policy = per_cpu(cpufreq_cpu_policy, cpuid); - if (policy && policy->turbo != CPUFREQ_TURBO_UNSUPPORTED) - policy->turbo = CPUFREQ_TURBO_DISABLED; -} int cpufreq_get_turbo_status(int cpuid) { diff -r 32034d1914a6 -r 08cf5548d5cc xen/include/acpi/cpufreq/cpufreq.h --- a/xen/include/acpi/cpufreq/cpufreq.h Thu Jun 07 19:46:57 2012 +0100 +++ b/xen/include/acpi/cpufreq/cpufreq.h Wed Jun 13 15:09:52 2012 +0200 @@ -124,8 +124,7 @@ extern int cpufreq_driver_getavg(unsigne #define CPUFREQ_TURBO_UNSUPPORTED 0 #define CPUFREQ_TURBO_ENABLED 1 -extern void cpufreq_enable_turbo(int cpuid); -extern void cpufreq_disable_turbo(int cpuid); +extern int cpufreq_update_turbo(int cpuid, int new_state); extern int cpufreq_get_turbo_status(int cpuid); static __inline__ int @@ -146,6 +145,7 @@ struct cpufreq_driver { char name[CPUFREQ_NAME_LEN]; int (*init)(struct cpufreq_policy *policy); int (*verify)(struct cpufreq_policy *policy); + int (*update)(int cpuid, struct cpufreq_policy *policy); int (*target)(struct cpufreq_policy *policy, unsigned int target_freq, unsigned int relation); _______________________________________________ Xen-devel mailing list Xen-devel@xxxxxxxxxxxxx http://lists.xen.org/xen-devel
|
Lists.xenproject.org is hosted with RackSpace, monitoring our |