aboutsummaryrefslogtreecommitdiffstats
path: root/xen/arch/x86/platform_hypercall.c
diff options
context:
space:
mode:
authorKeir Fraser <keir.fraser@citrix.com>2008-09-26 14:05:41 +0100
committerKeir Fraser <keir.fraser@citrix.com>2008-09-26 14:05:41 +0100
commit452119c09420458bc60b4824658ca6be15bc4a10 (patch)
tree2214deafa281713f84954274059c39186a753c38 /xen/arch/x86/platform_hypercall.c
parentc06a7db0c547b6c5280327f0856019aeb52a7c70 (diff)
downloadxen-452119c09420458bc60b4824658ca6be15bc4a10.tar.gz
xen-452119c09420458bc60b4824658ca6be15bc4a10.tar.bz2
xen-452119c09420458bc60b4824658ca6be15bc4a10.zip
x86 and ia64: move cpufreq notify code to commone place
This patch move the cpufreq notify code from x86 specfic place to common place, since it can be used by both x86 and ia64 cpufreq driver. Signed-off-by: Liu Jinsong <jinsong.liu@intel.com> Signed-off-by: Yu Ke <ke.yu@intel.com>
Diffstat (limited to 'xen/arch/x86/platform_hypercall.c')
-rw-r--r--xen/arch/x86/platform_hypercall.c104
1 files changed, 12 insertions, 92 deletions
diff --git a/xen/arch/x86/platform_hypercall.c b/xen/arch/x86/platform_hypercall.c
index 72c6648deb..99060a0d56 100644
--- a/xen/arch/x86/platform_hypercall.c
+++ b/xen/arch/x86/platform_hypercall.c
@@ -45,6 +45,7 @@ extern spinlock_t xenpf_lock;
static DEFINE_PER_CPU(uint64_t, freq);
+extern int set_px_pminfo(uint32_t cpu, struct xen_processor_performance *perf);
extern long set_cx_pminfo(uint32_t cpu, struct xen_processor_power *power);
static long cpu_frequency_change_helper(void *data)
@@ -52,6 +53,15 @@ static long cpu_frequency_change_helper(void *data)
return cpu_frequency_change(this_cpu(freq));
}
+int xenpf_copy_px_states(struct processor_performance *pxpt,
+ struct xen_processor_performance *dom0_px_info)
+{
+ if (!pxpt || !dom0_px_info)
+ return -EINVAL;
+ return copy_from_compat(pxpt->states, dom0_px_info->states,
+ dom0_px_info->state_count);
+}
+
ret_t do_platform_op(XEN_GUEST_HANDLE(xen_platform_op_t) u_xenpf_op)
{
ret_t ret = 0;
@@ -363,99 +373,9 @@ ret_t do_platform_op(XEN_GUEST_HANDLE(xen_platform_op_t) u_xenpf_op)
{
case XEN_PM_PX:
{
- static int cpu_count = 0;
- struct xenpf_set_processor_pminfo *xenpmpt = &op->u.set_pminfo;
- struct xen_processor_performance *xenpxpt = &op->u.set_pminfo.perf;
- int cpuid = get_cpu_id(xenpmpt->id);
- struct processor_pminfo *pmpt;
- struct processor_performance *pxpt;
-
- if ( !(xen_processor_pmbits & XEN_PROCESSOR_PM_PX) )
- {
- ret = -ENOSYS;
- break;
- }
- if ( cpuid < 0 )
- {
- ret = -EINVAL;
- break;
- }
- pmpt = processor_pminfo[cpuid];
- if ( !pmpt )
- {
- pmpt = xmalloc(struct processor_pminfo);
- if ( !pmpt )
- {
- ret = -ENOMEM;
- break;
- }
- memset(pmpt, 0, sizeof(*pmpt));
- processor_pminfo[cpuid] = pmpt;
- }
- pxpt = &pmpt->perf;
- pmpt->acpi_id = xenpmpt->id;
- pmpt->id = cpuid;
-
- if ( xenpxpt->flags & XEN_PX_PCT )
- {
- memcpy ((void *)&pxpt->control_register,
- (void *)&xenpxpt->control_register,
- sizeof(struct xen_pct_register));
- memcpy ((void *)&pxpt->status_register,
- (void *)&xenpxpt->status_register,
- sizeof(struct xen_pct_register));
- }
- if ( xenpxpt->flags & XEN_PX_PSS )
- {
- if ( !(pxpt->states = xmalloc_array(struct xen_processor_px,
- xenpxpt->state_count)) )
- {
- ret = -ENOMEM;
- break;
- }
- if ( copy_from_compat(pxpt->states, xenpxpt->states,
- xenpxpt->state_count) )
- {
- xfree(pxpt->states);
- ret = -EFAULT;
- break;
- }
- pxpt->state_count = xenpxpt->state_count;
- }
- if ( xenpxpt->flags & XEN_PX_PSD )
- {
- pxpt->shared_type = xenpxpt->shared_type;
- memcpy ((void *)&pxpt->domain_info,
- (void *)&xenpxpt->domain_info,
- sizeof(struct xen_psd_package));
- }
- if ( xenpxpt->flags & XEN_PX_PPC )
- {
- pxpt->platform_limit = xenpxpt->platform_limit;
-
- if ( pxpt->init == XEN_PX_INIT )
- {
- ret = cpufreq_limit_change(cpuid);
- break;
- }
- }
-
- if ( xenpxpt->flags == ( XEN_PX_PCT | XEN_PX_PSS |
- XEN_PX_PSD | XEN_PX_PPC ) )
- {
- pxpt->init = XEN_PX_INIT;
- cpu_count++;
-
- /* Currently we only handle Intel and AMD processor */
- if ( boot_cpu_data.x86_vendor == X86_VENDOR_INTEL )
- ret = cpufreq_add_cpu(cpuid);
- else if ( (boot_cpu_data.x86_vendor == X86_VENDOR_AMD) &&
- (cpu_count == num_online_cpus()) )
- ret = powernow_cpufreq_init();
- else
- break;
- }
+ ret = set_px_pminfo(op->u.set_pminfo.id,
+ &op->u.set_pminfo.perf);
break;
}