ia64/xen-unstable

changeset 18582:903a901ab372

[IA64] implement ia64 cpufreq notify hypercall

This patch implement the ia64 cpufreq hypercall to get dom0 cpufreq ACPI info.

Signed-off-by: Yu Ke <ke.yu@intel.com>
Signed-off-by: Liu Jinsong <jinsong.liu@intel.com>
author Isaku Yamahata <yamahata@valinux.co.jp>
date Fri Oct 10 11:17:24 2008 +0900 (2008-10-10)
parents a311996570f4
children faf07ca43a28
files xen/arch/ia64/linux-xen/acpi.c xen/arch/ia64/linux-xen/entry.S xen/arch/ia64/xen/Makefile xen/arch/ia64/xen/cpufreq/cpufreq.c xen/arch/ia64/xen/domain.c xen/arch/ia64/xen/platform_hypercall.c
line diff
     1.1 --- a/xen/arch/ia64/linux-xen/acpi.c	Fri Oct 10 11:17:24 2008 +0900
     1.2 +++ b/xen/arch/ia64/linux-xen/acpi.c	Fri Oct 10 11:17:24 2008 +0900
     1.3 @@ -219,6 +219,32 @@ acpi_parse_lapic_addr_ovr(struct acpi_su
     1.4  	return 0;
     1.5  }
     1.6  
     1.7 +#ifdef XEN
     1.8 +
     1.9 +#define MAX_LOCAL_SAPIC 255
    1.10 +static u16 ia64_acpiid_to_sapicid[ MAX_LOCAL_SAPIC ] =
    1.11 +		{[0 ... MAX_LOCAL_SAPIC - 1] = 0xffff };
    1.12 +
    1.13 +/* acpi id to cpu id */
    1.14 +int get_cpu_id(u8 acpi_id)
    1.15 +{
    1.16 +	int i;
    1.17 +	u16 apic_id;
    1.18 +
    1.19 +	apic_id = ia64_acpiid_to_sapicid[acpi_id];
    1.20 +	if ( apic_id == 0xffff )
    1.21 +		return -EINVAL;
    1.22 +
    1.23 +	for ( i = 0; i < NR_CPUS; i++ )
    1.24 +	{
    1.25 +		if ( apic_id == ia64_cpu_to_sapicid[i] )
    1.26 +			return i;
    1.27 +	}
    1.28 +
    1.29 +	return -1;
    1.30 +}
    1.31 +#endif
    1.32 +
    1.33  static int __init
    1.34  acpi_parse_lsapic(struct acpi_subtable_header * header, const unsigned long end)
    1.35  {
    1.36 @@ -233,6 +259,10 @@ acpi_parse_lsapic(struct acpi_subtable_h
    1.37  		smp_boot_data.cpu_phys_id[available_cpus] =
    1.38  		    (lsapic->id << 8) | lsapic->eid;
    1.39  #endif
    1.40 +#ifdef XEN
    1.41 +        ia64_acpiid_to_sapicid[lsapic->processor_id] =
    1.42 +            (lsapic->id << 8) | lsapic->eid;
    1.43 +#endif
    1.44  		++available_cpus;
    1.45  	}
    1.46  
     2.1 --- a/xen/arch/ia64/linux-xen/entry.S	Fri Oct 10 11:17:24 2008 +0900
     2.2 +++ b/xen/arch/ia64/linux-xen/entry.S	Fri Oct 10 11:17:24 2008 +0900
     2.3 @@ -1524,7 +1524,7 @@ ia64_hypercall_table:
     2.4  	data8 do_ni_hypercall		/* do_set_callbacks */
     2.5  	data8 do_ni_hypercall		/* do_fpu_taskswitch *//*  5 */
     2.6  	data8 do_sched_op_compat
     2.7 -	data8 do_ni_hypercall
     2.8 +	data8 do_platform_op
     2.9  	data8 do_ni_hypercall		/* do_set_debugreg */
    2.10  	data8 do_ni_hypercall		/* do_get_debugreg */
    2.11  	data8 do_ni_hypercall		/* do_update_descriptor * 10 */
     3.1 --- a/xen/arch/ia64/xen/Makefile	Fri Oct 10 11:17:24 2008 +0900
     3.2 +++ b/xen/arch/ia64/xen/Makefile	Fri Oct 10 11:17:24 2008 +0900
     3.3 @@ -15,6 +15,7 @@ obj-y += dom_fw_sn2.o
     3.4  obj-y += fw_emul.o
     3.5  obj-y += hpsimserial.o
     3.6  obj-y += hypercall.o
     3.7 +obj-y += platform_hypercall.o
     3.8  obj-y += hyperprivop.o
     3.9  obj-y += idle0_task.o
    3.10  obj-y += irq.o
     4.1 --- a/xen/arch/ia64/xen/cpufreq/cpufreq.c	Fri Oct 10 11:17:24 2008 +0900
     4.2 +++ b/xen/arch/ia64/xen/cpufreq/cpufreq.c	Fri Oct 10 11:17:24 2008 +0900
     4.3 @@ -305,20 +305,10 @@ static int __init cpufreq_driver_init(vo
     4.4  
     4.5  	return ret;
     4.6  }
     4.7 +
     4.8  __initcall(cpufreq_driver_init);
     4.9  
    4.10 -int get_cpu_id(u8 acpi_id)
    4.11 -{
    4.12 -    return -1;
    4.13 -}
    4.14 -
    4.15 -int xenpf_copy_px_states(struct processor_performance *pxpt,
    4.16 -                         struct xen_processor_performance *dom0_px_info)
    4.17 -{
    4.18 -    return -ENOSYS;
    4.19 -}
    4.20 -
    4.21  int cpufreq_cpu_init(unsigned int cpuid)
    4.22  {
    4.23 -    return -ENOSYS;
    4.24 +	return cpufreq_add_cpu(cpuid);
    4.25  }
     5.1 --- a/xen/arch/ia64/xen/domain.c	Fri Oct 10 11:17:24 2008 +0900
     5.2 +++ b/xen/arch/ia64/xen/domain.c	Fri Oct 10 11:17:24 2008 +0900
     5.3 @@ -2160,6 +2160,7 @@ int __init construct_dom0(struct domain 
     5.4  	snprintf(si->magic, sizeof(si->magic), "xen-3.0-ia64");
     5.5  	si->nr_pages     = max_pages;
     5.6  	si->flags = SIF_INITDOMAIN|SIF_PRIVILEGED;
     5.7 +	si->flags |= (xen_processor_pmbits << 8) & SIF_PM_MASK;
     5.8  
     5.9  	printk("Dom0: 0x%lx\n", (u64)dom0);
    5.10  
     6.1 --- /dev/null	Thu Jan 01 00:00:00 1970 +0000
     6.2 +++ b/xen/arch/ia64/xen/platform_hypercall.c	Fri Oct 10 11:17:24 2008 +0900
     6.3 @@ -0,0 +1,87 @@
     6.4 +/******************************************************************************
     6.5 + * platform_hypercall.c
     6.6 + * 
     6.7 + * Hardware platform operations. Intended for use by domain-0 kernel.
     6.8 + * 
     6.9 + * Copyright (c) 2002-2006, K Fraser
    6.10 + */
    6.11 +
    6.12 +#include <xen/config.h>
    6.13 +#include <xen/types.h>
    6.14 +#include <xen/lib.h>
    6.15 +#include <xen/sched.h>
    6.16 +#include <xen/guest_access.h>
    6.17 +#include <xen/acpi.h>
    6.18 +#include <public/platform.h>
    6.19 +#include <acpi/cpufreq/processor_perf.h>
    6.20 +
    6.21 +DEFINE_SPINLOCK(xenpf_lock);
    6.22 +
    6.23 +extern int set_px_pminfo(uint32_t cpu, struct xen_processor_performance *perf);
    6.24 +extern long set_cx_pminfo(uint32_t cpu, struct xen_processor_power *power);
    6.25 +
    6.26 +int xenpf_copy_px_states(struct processor_performance *pxpt,
    6.27 +        struct xen_processor_performance *dom0_px_info)
    6.28 +{
    6.29 +    if (!pxpt || !dom0_px_info)
    6.30 +        return -EINVAL;
    6.31 +    return  copy_from_guest(pxpt->states, dom0_px_info->states,
    6.32 +                    dom0_px_info->state_count);
    6.33 +}
    6.34 +
    6.35 +long do_platform_op(XEN_GUEST_HANDLE(xen_platform_op_t) u_xenpf_op)
    6.36 +{
    6.37 +    long ret = 0;
    6.38 +    struct xen_platform_op curop, *op = &curop;
    6.39 +
    6.40 +    if ( !IS_PRIV(current->domain) )
    6.41 +        return -EPERM;
    6.42 +
    6.43 +    if ( copy_from_guest(op, u_xenpf_op, 1) )
    6.44 +        return -EFAULT;
    6.45 +
    6.46 +    if ( op->interface_version != XENPF_INTERFACE_VERSION )
    6.47 +        return -EACCES;
    6.48 +
    6.49 +    switch ( op->cmd )
    6.50 +    {
    6.51 +    case XENPF_set_processor_pminfo:
    6.52 +        spin_lock(&xenpf_lock);
    6.53 +        switch ( op->u.set_pminfo.type )
    6.54 +        {
    6.55 +        case XEN_PM_PX:
    6.56 +            ret = set_px_pminfo(op->u.set_pminfo.id,
    6.57 +                    &op->u.set_pminfo.perf);
    6.58 +            break;
    6.59 +
    6.60 +        case XEN_PM_CX:
    6.61 +            /* Place holder for Cx */
    6.62 +            ret = -ENOSYS;
    6.63 +            break;
    6.64 +
    6.65 +        default:
    6.66 +            ret = -EINVAL;
    6.67 +            break;
    6.68 +        }
    6.69 +        spin_unlock(&xenpf_lock);
    6.70 +        break;
    6.71 +
    6.72 +    default:
    6.73 +        printk("Unknown platform hypercall op 0x%x\n", op->cmd);
    6.74 +        ret = -ENOSYS;
    6.75 +        break;
    6.76 +    }
    6.77 +
    6.78 +    return ret;
    6.79 +}
    6.80 +
    6.81 +/*
    6.82 + * Local variables:
    6.83 + * mode: C
    6.84 + * c-set-style: "BSD"
    6.85 + * c-basic-offset: 4
    6.86 + * tab-width: 4
    6.87 + * indent-tabs-mode: nil
    6.88 + * End:
    6.89 + */
    6.90 +