ia64/linux-2.6.18-xen.hg

changeset 530:3da869d5095b

Add basic interface to allow ACPI processor events revealed to
external control logic like VMM.

Signed-off-by: Tian Kevin <kevin.tian@intel.com>
Signed-off-by: Wei Gang <gang.wei@intel.com>
author Keir Fraser <keir.fraser@citrix.com>
date Thu May 01 10:52:06 2008 +0100 (2008-05-01)
parents 9f9b4214bec8
children 3c564f80f2ef
files drivers/acpi/Kconfig drivers/acpi/Makefile drivers/acpi/processor_extcntl.c include/acpi/processor.h
line diff
     1.1 --- a/drivers/acpi/Kconfig	Thu May 01 10:35:30 2008 +0100
     1.2 +++ b/drivers/acpi/Kconfig	Thu May 01 10:52:06 2008 +0100
     1.3 @@ -367,6 +367,11 @@ config ACPI_PV_SLEEP
     1.4  	bool
     1.5  	depends on X86 && XEN && ACPI_SLEEP
     1.6  	default y
     1.7 +
     1.8 +config PROCESSOR_EXTERNAL_CONTROL
     1.9 +	bool
    1.10 +	depends on X86 && XEN
    1.11 +	default y
    1.12  endif	# ACPI
    1.13  
    1.14  endmenu
     2.1 --- a/drivers/acpi/Makefile	Thu May 01 10:35:30 2008 +0100
     2.2 +++ b/drivers/acpi/Makefile	Thu May 01 10:52:06 2008 +0100
     2.3 @@ -34,6 +34,9 @@ processor-objs	+= processor_core.o proce
     2.4  ifdef CONFIG_CPU_FREQ
     2.5  processor-objs	+= processor_perflib.o			
     2.6  endif
     2.7 +ifdef CONFIG_PROCESSOR_EXTERNAL_CONTROL
     2.8 +processor-objs	+= processor_extcntl.o
     2.9 +endif
    2.10  
    2.11  obj-y				+= sleep/
    2.12  obj-y				+= bus.o glue.o
     3.1 --- /dev/null	Thu Jan 01 00:00:00 1970 +0000
     3.2 +++ b/drivers/acpi/processor_extcntl.c	Thu May 01 10:52:06 2008 +0100
     3.3 @@ -0,0 +1,111 @@
     3.4 +/*
     3.5 + * processor_extcntl.c - channel to external control logic
     3.6 + *
     3.7 + *  Copyright (C) 2008, Intel corporation
     3.8 + *
     3.9 + * ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
    3.10 + *
    3.11 + *  This program is free software; you can redistribute it and/or modify
    3.12 + *  it under the terms of the GNU General Public License as published by
    3.13 + *  the Free Software Foundation; either version 2 of the License, or (at
    3.14 + *  your option) any later version.
    3.15 + *
    3.16 + *  This program is distributed in the hope that it will be useful, but
    3.17 + *  WITHOUT ANY WARRANTY; without even the implied warranty of
    3.18 + *  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
    3.19 + *  General Public License for more details.
    3.20 + *
    3.21 + *  You should have received a copy of the GNU General Public License along
    3.22 + *  with this program; if not, write to the Free Software Foundation, Inc.,
    3.23 + *  59 Temple Place, Suite 330, Boston, MA 02111-1307 USA.
    3.24 + *
    3.25 + */
    3.26 +
    3.27 +#include <linux/kernel.h>
    3.28 +#include <linux/init.h>
    3.29 +#include <linux/types.h>
    3.30 +#include <linux/acpi.h>
    3.31 +#include <linux/pm.h>
    3.32 +#include <linux/cpu.h>
    3.33 +
    3.34 +#include <acpi/processor.h>
    3.35 +
    3.36 +/*
    3.37 + * External processor control logic may register with its own set of
    3.38 + * ops to get ACPI related notification. One example is like VMM.
    3.39 + */
    3.40 +struct processor_extcntl_ops *processor_extcntl_ops;
    3.41 +
    3.42 +int processor_notify_external(struct acpi_processor *pr, int event, int type)
    3.43 +{
    3.44 +	int ret = -EINVAL;
    3.45 +
    3.46 +	if (!processor_cntl_external())
    3.47 +		return -EINVAL;
    3.48 +
    3.49 +	switch (event) {
    3.50 +	case PROCESSOR_PM_INIT:
    3.51 +	case PROCESSOR_PM_CHANGE:
    3.52 +		if ((type >= PM_TYPE_MAX) ||
    3.53 +			!processor_extcntl_ops->pm_ops[type])
    3.54 +			break;
    3.55 +
    3.56 +		ret = processor_extcntl_ops->pm_ops[type](pr, event);
    3.57 +		break;
    3.58 +	case PROCESSOR_HOTPLUG:
    3.59 +		if (processor_extcntl_ops->hotplug)
    3.60 +			ret = processor_extcntl_ops->hotplug(pr, type);
    3.61 +		break;
    3.62 +	default:
    3.63 +		printk(KERN_ERR "Unsupport processor events %d.\n", event);
    3.64 +		break;
    3.65 +	}
    3.66 +
    3.67 +	return ret;
    3.68 +}
    3.69 +
    3.70 +/*
    3.71 + * External control logic can decide to grab full or part of physical
    3.72 + * processor control bits. Take a VMM for example, physical processors
    3.73 + * are owned by VMM and thus existence information like hotplug is
    3.74 + * always required to be notified to VMM. Similar is processor idle
    3.75 + * state which is also necessarily controlled by VMM. But for other
    3.76 + * control bits like performance/throttle states, VMM may choose to
    3.77 + * control or not upon its own policy.
    3.78 + *
    3.79 + * Such ownership is unlikely to be switched in the fly, and thus
    3.80 + * not sure unregister interface is required or not. Being same reason,
    3.81 + * lock is not forced now.
    3.82 + */
    3.83 +int processor_register_extcntl(struct processor_extcntl_ops *ops)
    3.84 +{
    3.85 +	if (!ops)
    3.86 +		return -EINVAL;
    3.87 +
    3.88 +	if (processor_extcntl_ops &&
    3.89 +		(processor_extcntl_ops != ops))
    3.90 +		return -EBUSY;
    3.91 +
    3.92 +	processor_extcntl_ops = ops;
    3.93 +	return 0;
    3.94 +}
    3.95 +
    3.96 +int processor_unregister_extcntl(struct processor_extcntl_ops *ops)
    3.97 +{
    3.98 +	if (processor_extcntl_ops == ops)
    3.99 +		processor_extcntl_ops = NULL;
   3.100 +
   3.101 +	return 0;
   3.102 +}
   3.103 +
   3.104 +/*
   3.105 + * This is called from ACPI processor init, and targeted to hold
   3.106 + * some tricky housekeeping jobs to satisfy external control model.
   3.107 + * For example, we may put dependency parse stub here for idle
   3.108 + * and performance state. Those information may be not available
   3.109 + * if splitting from dom0 control logic like cpufreq driver.
   3.110 + */
   3.111 +int processor_extcntl_init(struct acpi_processor *pr)
   3.112 +{
   3.113 +	return 0;
   3.114 +}
     4.1 --- a/include/acpi/processor.h	Thu May 01 10:35:30 2008 +0100
     4.2 +++ b/include/acpi/processor.h	Thu May 01 10:52:06 2008 +0100
     4.3 @@ -275,4 +275,76 @@ static inline void acpi_thermal_cpufreq_
     4.4  }
     4.5  #endif
     4.6  
     4.7 +/* 
     4.8 + * Following are interfaces geared to external processor PM control
     4.9 + * logic like a VMM
    4.10 + */
    4.11 +/* Events notified to external control logic */
    4.12 +#define PROCESSOR_PM_INIT	1
    4.13 +#define PROCESSOR_PM_CHANGE	2
    4.14 +#define PROCESSOR_HOTPLUG	3
    4.15 +
    4.16 +/* Objects for the PM envents */
    4.17 +#define PM_TYPE_IDLE		0
    4.18 +#define PM_TYPE_PERF		1
    4.19 +#define PM_TYPE_THR		2
    4.20 +#define PM_TYPE_MAX		3
    4.21 +
    4.22 +/* Processor hotplug events */
    4.23 +#define HOTPLUG_TYPE_ADD	0
    4.24 +#define HOTPLUG_TYPE_REMOVE	1
    4.25 +
    4.26 +#ifdef CONFIG_PROCESSOR_EXTERNAL_CONTROL
    4.27 +struct processor_extcntl_ops {
    4.28 +	/* Transfer processor PM events to external control logic */
    4.29 +	int (*pm_ops[PM_TYPE_MAX])(struct acpi_processor *pr, int event);
    4.30 +	/* Notify physical processor status to external control logic */
    4.31 +	int (*hotplug)(struct acpi_processor *pr, int event);
    4.32 +};
    4.33 +extern struct processor_extcntl_ops *processor_extcntl_ops;
    4.34 +
    4.35 +static inline int processor_cntl_external(void)
    4.36 +{
    4.37 +	return (processor_extcntl_ops != NULL);
    4.38 +}
    4.39 +
    4.40 +static inline int processor_pm_external(void)
    4.41 +{
    4.42 +	return processor_cntl_external() &&
    4.43 +		(processor_extcntl_ops->pm_ops[PM_TYPE_IDLE] != NULL);
    4.44 +}
    4.45 +
    4.46 +static inline int processor_pmperf_external(void)
    4.47 +{
    4.48 +	return processor_cntl_external() &&
    4.49 +		(processor_extcntl_ops->pm_ops[PM_TYPE_PERF] != NULL);
    4.50 +}
    4.51 +
    4.52 +static inline int processor_pmthr_external(void)
    4.53 +{
    4.54 +	return processor_cntl_external() &&
    4.55 +		(processor_extcntl_ops->pm_ops[PM_TYPE_THR] != NULL);
    4.56 +}
    4.57 +
    4.58 +extern int processor_notify_external(struct acpi_processor *pr,
    4.59 +			int event, int type);
    4.60 +extern int processor_register_extcntl(struct processor_extcntl_ops *ops);
    4.61 +extern int processor_unregister_extcntl(struct processor_extcntl_ops *ops);
    4.62 +extern int processor_extcntl_init(struct acpi_processor *pr);
    4.63 +#else
    4.64 +static inline int processor_cntl_external(void) {return 0;}
    4.65 +static inline int processor_pm_external(void) {return 0;}
    4.66 +static inline int processor_pmperf_external(void) {return 0;}
    4.67 +static inline int processor_pmthr_external(void) {return 0;}
    4.68 +static inline int processor_notify_external(struct acpi_processor *pr,
    4.69 +			int event, int type)
    4.70 +{
    4.71 +	return -EINVAL;
    4.72 +}
    4.73 +static inline int processor_extcntl_init(struct acpi_processor *pr)
    4.74 +{
    4.75 +	return -EINVAL;
    4.76 +}
    4.77 +#endif /* CONFIG_PROCESSOR_EXTERNAL_CONTROL */
    4.78 +
    4.79  #endif