ia64/linux-2.6.18-xen.hg

changeset 688:55ec2b18fe7f

IA64: add ia64 cpufreq notify hypercall

This patch adds ia64 notify hypercall to pass cpufreq ACPI information to
hypervisor, and get cpufreq statistic data from hypervisor.

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 Thu Oct 09 15:23:54 2008 +0900 (2008-10-09)
parents 7d2d7b1deda4
children 9010d63470ff
files arch/ia64/kernel/Makefile arch/ia64/kernel/processor_extcntl_xen.c arch/ia64/xen/xcom_hcall.c arch/ia64/xen/xcom_privcmd.c drivers/acpi/Kconfig include/asm-ia64/hypercall.h include/asm-ia64/xen/xcom_hcall.h
line diff
     1.1 --- a/arch/ia64/kernel/Makefile	Fri Oct 03 13:08:44 2008 +0900
     1.2 +++ b/arch/ia64/kernel/Makefile	Thu Oct 09 15:23:54 2008 +0900
     1.3 @@ -16,6 +16,9 @@ obj-$(CONFIG_IA64_HP_ZX1_SWIOTLB) += acp
     1.4  
     1.5  ifneq ($(CONFIG_ACPI_PROCESSOR),)
     1.6  obj-y				+= acpi-processor.o
     1.7 +ifneq ($(CONFIG_PROCESSOR_EXTERNAL_CONTROL),)
     1.8 +obj-$(CONFIG_XEN)		+= processor_extcntl_xen.o
     1.9 +endif
    1.10  endif
    1.11  
    1.12  obj-$(CONFIG_IA64_PALINFO)	+= palinfo.o
     2.1 --- /dev/null	Thu Jan 01 00:00:00 1970 +0000
     2.2 +++ b/arch/ia64/kernel/processor_extcntl_xen.c	Thu Oct 09 15:23:54 2008 +0900
     2.3 @@ -0,0 +1,164 @@
     2.4 +/*
     2.5 + * processor_extcntl_xen.c - interface to notify Xen
     2.6 + *
     2.7 + *  Copyright (C) 2008, Intel corporation
     2.8 + *
     2.9 + * ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
    2.10 + *
    2.11 + *  This program is free software; you can redistribute it and/or modify
    2.12 + *  it under the terms of the GNU General Public License as published by
    2.13 + *  the Free Software Foundation; either version 2 of the License, or (at
    2.14 + *  your option) any later version.
    2.15 + *
    2.16 + *  This program is distributed in the hope that it will be useful, but
    2.17 + *  WITHOUT ANY WARRANTY; without even the implied warranty of
    2.18 + *  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
    2.19 + *  General Public License for more details.
    2.20 + *
    2.21 + *  You should have received a copy of the GNU General Public License along
    2.22 + *  with this program; if not, write to the Free Software Foundation, Inc.,
    2.23 + *  59 Temple Place, Suite 330, Boston, MA 02111-1307 USA.
    2.24 + *
    2.25 + */
    2.26 +
    2.27 +#include <linux/kernel.h>
    2.28 +#include <linux/init.h>
    2.29 +#include <linux/types.h>
    2.30 +#include <linux/acpi.h>
    2.31 +#include <linux/pm.h>
    2.32 +#include <linux/cpu.h>
    2.33 +#include <linux/cpufreq.h>
    2.34 +#include <acpi/processor.h>
    2.35 +#include <asm/hypercall.h>
    2.36 +#include <asm/xen/xencomm.h>
    2.37 +#include <xen/interface/platform.h>
    2.38 +
    2.39 +static int xen_cx_notifier(struct acpi_processor *pr, int action)
    2.40 +{
    2.41 +	printk(KERN_WARNING "Cx is not supported yet\n");
    2.42 +
    2.43 +	return -EINVAL;
    2.44 +}
    2.45 +
    2.46 +static int xen_px_notifier(struct acpi_processor *pr, int action)
    2.47 +{
    2.48 +	int ret = -EINVAL;
    2.49 +	xen_platform_op_t op = {
    2.50 +		.cmd			= XENPF_set_processor_pminfo,
    2.51 +		.interface_version	= XENPF_INTERFACE_VERSION,
    2.52 +		.u.set_pminfo.id	= pr->acpi_id,
    2.53 +		.u.set_pminfo.type	= XEN_PM_PX,
    2.54 +	};
    2.55 +	struct xen_processor_performance *perf;
    2.56 +	struct xen_processor_px *states = NULL;
    2.57 +	struct acpi_processor_performance *px;
    2.58 +	struct acpi_psd_package *pdomain;
    2.59 +	struct xencomm_handle *states_desc;
    2.60 +
    2.61 +	if (!pr || !pr->performance)
    2.62 +		return -EINVAL;
    2.63 +
    2.64 +	perf = &op.u.set_pminfo.perf;
    2.65 +	px = pr->performance;
    2.66 +
    2.67 +	switch(action) {
    2.68 +		case PROCESSOR_PM_CHANGE:
    2.69 +			/* ppc dynamic handle */
    2.70 +			perf->flags = XEN_PX_PPC;
    2.71 +			perf->platform_limit = pr->performance_platform_limit;
    2.72 +
    2.73 +			ret = HYPERVISOR_platform_op(&op);
    2.74 +			break;
    2.75 +
    2.76 +		case PROCESSOR_PM_INIT:
    2.77 +			/* px normal init */
    2.78 +			perf->flags = XEN_PX_PPC |
    2.79 +				XEN_PX_PCT |
    2.80 +				XEN_PX_PSS |
    2.81 +				XEN_PX_PSD;
    2.82 +
    2.83 +			/* ppc */
    2.84 +			perf->platform_limit = pr->performance_platform_limit;
    2.85 +
    2.86 +			/* pct */
    2.87 +			xen_convert_pct_reg(&perf->control_register,
    2.88 +					    &px->control_register);
    2.89 +			xen_convert_pct_reg(&perf->status_register,
    2.90 +					    &px->status_register);
    2.91 +
    2.92 +			/* pss */
    2.93 +			perf->state_count = px->state_count;
    2.94 +			states = kzalloc(
    2.95 +				px->state_count * sizeof(xen_processor_px_t),
    2.96 +				GFP_KERNEL);
    2.97 +			if (!states){
    2.98 +				ret = -ENOMEM;
    2.99 +				break;
   2.100 +			}
   2.101 +			xen_convert_pss_states(states, px->states,
   2.102 +					       px->state_count);
   2.103 +			set_xen_guest_handle(perf->states, states);
   2.104 +			states_desc = xencomm_map_no_alloc(
   2.105 +					xen_guest_handle(perf->states),
   2.106 +					sizeof(*xen_guest_handle(perf->states)));
   2.107 +			set_xen_guest_handle(perf->states,
   2.108 +					     (xen_processor_px_t*)states_desc);
   2.109 +
   2.110 +			/* psd */
   2.111 +			pdomain = &px->domain_info;
   2.112 +			xen_convert_psd_pack(&perf->domain_info, pdomain);
   2.113 +			if (pdomain->coord_type == DOMAIN_COORD_TYPE_SW_ALL)
   2.114 +				perf->shared_type = CPUFREQ_SHARED_TYPE_ALL;
   2.115 +			else if (pdomain->coord_type ==
   2.116 +				 DOMAIN_COORD_TYPE_SW_ANY)
   2.117 +				perf->shared_type = CPUFREQ_SHARED_TYPE_ANY;
   2.118 +			else if (pdomain->coord_type ==
   2.119 +				 DOMAIN_COORD_TYPE_HW_ALL)
   2.120 +				perf->shared_type = CPUFREQ_SHARED_TYPE_HW;
   2.121 +			else {
   2.122 +				ret = -ENODEV;
   2.123 +				kfree(states);
   2.124 +				break;
   2.125 +			}
   2.126 +
   2.127 +			ret = HYPERVISOR_platform_op(&op);
   2.128 +			kfree(states);
   2.129 +			break;
   2.130 +
   2.131 +		default:
   2.132 +			ret = -EINVAL;
   2.133 +	}
   2.134 +
   2.135 +	return ret;
   2.136 +}
   2.137 +
   2.138 +static int xen_tx_notifier(struct acpi_processor *pr, int action)
   2.139 +{
   2.140 +	return -EINVAL;
   2.141 +}
   2.142 +static int xen_hotplug_notifier(struct acpi_processor *pr, int event)
   2.143 +{
   2.144 +	return -EINVAL;
   2.145 +}
   2.146 +
   2.147 +static struct processor_extcntl_ops xen_extcntl_ops = {
   2.148 +	.hotplug		= xen_hotplug_notifier,
   2.149 +};
   2.150 +
   2.151 +void arch_acpi_processor_init_extcntl(const struct processor_extcntl_ops **ops)
   2.152 +{
   2.153 +	unsigned int pmbits = (xen_start_info->flags & SIF_PM_MASK) >> 8;
   2.154 +
   2.155 +	if (!pmbits)
   2.156 +		return;
   2.157 +
   2.158 +	if (pmbits & XEN_PROCESSOR_PM_CX)
   2.159 +		xen_extcntl_ops.pm_ops[PM_TYPE_IDLE] = xen_cx_notifier;
   2.160 +	if (pmbits & XEN_PROCESSOR_PM_PX)
   2.161 +		xen_extcntl_ops.pm_ops[PM_TYPE_PERF] = xen_px_notifier;
   2.162 +	if (pmbits & XEN_PROCESSOR_PM_TX)
   2.163 +		xen_extcntl_ops.pm_ops[PM_TYPE_THR] = xen_tx_notifier;
   2.164 +
   2.165 +	*ops = &xen_extcntl_ops;
   2.166 +}
   2.167 +EXPORT_SYMBOL(arch_acpi_processor_init_extcntl);
     3.1 --- a/arch/ia64/xen/xcom_hcall.c	Fri Oct 03 13:08:44 2008 +0900
     3.2 +++ b/arch/ia64/xen/xcom_hcall.c	Thu Oct 09 15:23:54 2008 +0900
     3.3 @@ -285,6 +285,15 @@ xencomm_hypercall_sched_op(int cmd, void
     3.4  }
     3.5  EXPORT_SYMBOL_GPL(xencomm_hypercall_sched_op);
     3.6  
     3.7 +int xencomm_hypercall_platform_op(struct xen_platform_op *arg)
     3.8 +{
     3.9 +	return xencomm_arch_hypercall_platform_op(
    3.10 +			xencomm_map_no_alloc(arg,
    3.11 +			sizeof(struct xen_platform_op))
    3.12 +			);
    3.13 +}
    3.14 +EXPORT_SYMBOL_GPL(xencomm_hypercall_platform_op);
    3.15 +
    3.16  int
    3.17  xencomm_hypercall_multicall(void *call_list, int nr_calls)
    3.18  {
     4.1 --- a/arch/ia64/xen/xcom_privcmd.c	Fri Oct 03 13:08:44 2008 +0900
     4.2 +++ b/arch/ia64/xen/xcom_privcmd.c	Thu Oct 09 15:23:54 2008 +0900
     4.3 @@ -193,6 +193,31 @@ xencomm_privcmd_sysctl(privcmd_hypercall
     4.4  		set_xen_guest_handle(kern_op.u.physinfo.cpu_to_node,
     4.5  		                     (void *)desc);
     4.6  		break;
     4.7 +
     4.8 +	case XEN_SYSCTL_get_pmstat:
     4.9 +		if (kern_op.u.get_pmstat.type == PMSTAT_get_pxstat) {
    4.10 +			struct pm_px_stat *getpx =
    4.11 +				&kern_op.u.get_pmstat.u.getpx;
    4.12 +			desc = xencomm_map(
    4.13 +				xen_guest_handle(getpx->trans_pt),
    4.14 +				getpx->total * getpx->total *
    4.15 +				sizeof(uint64_t));
    4.16 +			if (xen_guest_handle(getpx->trans_pt) != NULL &&
    4.17 +			    getpx->total > 0 && desc == NULL)
    4.18 +				return -ENOMEM;
    4.19 +
    4.20 +			set_xen_guest_handle(getpx->trans_pt, (void *)desc);
    4.21 +
    4.22 +			desc1 = xencomm_map(xen_guest_handle(getpx->pt),
    4.23 +				getpx->total * sizeof(pm_px_val_t));
    4.24 +			if (xen_guest_handle(getpx->pt) != NULL &&
    4.25 +			    getpx->total > 0 && desc1 == NULL)
    4.26 +				return -ENOMEM;
    4.27 +
    4.28 +			set_xen_guest_handle(getpx->pt, (void *)desc1);
    4.29 +		}
    4.30 +		break;
    4.31 +
    4.32  	default:
    4.33  		printk("%s: unknown sysctl cmd %d\n", __func__, kern_op.cmd);
    4.34  		return -ENOSYS;
     5.1 --- a/drivers/acpi/Kconfig	Fri Oct 03 13:08:44 2008 +0900
     5.2 +++ b/drivers/acpi/Kconfig	Thu Oct 09 15:23:54 2008 +0900
     5.3 @@ -370,7 +370,7 @@ config ACPI_PV_SLEEP
     5.4  
     5.5  config PROCESSOR_EXTERNAL_CONTROL
     5.6  	bool
     5.7 -	depends on X86 && XEN
     5.8 +	depends on (X86 || IA64) && XEN
     5.9  	default y
    5.10  endif	# ACPI
    5.11  
     6.1 --- a/include/asm-ia64/hypercall.h	Fri Oct 03 13:08:44 2008 +0900
     6.2 +++ b/include/asm-ia64/hypercall.h	Thu Oct 09 15:23:54 2008 +0900
     6.3 @@ -444,6 +444,7 @@ xencomm_arch_hypercall_kexec_op(int cmd,
     6.4  
     6.5  /* Use xencomm to do hypercalls.  */
     6.6  #define HYPERVISOR_sched_op xencomm_hypercall_sched_op
     6.7 +#define HYPERVISOR_platform_op xencomm_hypercall_platform_op
     6.8  #define HYPERVISOR_event_channel_op xencomm_hypercall_event_channel_op
     6.9  #define HYPERVISOR_callback_op xencomm_hypercall_callback_op
    6.10  #define HYPERVISOR_multicall xencomm_hypercall_multicall
     7.1 --- a/include/asm-ia64/xen/xcom_hcall.h	Fri Oct 03 13:08:44 2008 +0900
     7.2 +++ b/include/asm-ia64/xen/xcom_hcall.h	Thu Oct 09 15:23:54 2008 +0900
     7.3 @@ -36,6 +36,8 @@ extern int xencomm_hypercall_grant_table
     7.4  
     7.5  extern int xencomm_hypercall_sched_op(int cmd, void *arg);
     7.6  
     7.7 +extern int xencomm_hypercall_platform_op(struct xen_platform_op *arg);
     7.8 +
     7.9  extern int xencomm_hypercall_multicall(void *call_list, int nr_calls);
    7.10  
    7.11  extern int xencomm_hypercall_callback_op(int cmd, void *arg);