ia64/linux-2.6.18-xen.hg

changeset 536:e39cf97647af

Isolate Xen PM related code in dom0 with #ifdef CONFIG_XEN to avoid
breaking native.

Signed-off-by: Wei Gang <gang.wei@intel.com>
author Keir Fraser <keir.fraser@citrix.com>
date Mon May 05 10:17:41 2008 +0100 (2008-05-05)
parents 26c60aa94b9f
children 63b51bcb6bf6
files arch/i386/kernel/acpi/processor.c arch/i386/kernel/cpu/cpufreq/acpi-cpufreq.c drivers/acpi/processor_core.c drivers/acpi/processor_idle.c drivers/acpi/processor_perflib.c include/acpi/processor.h
line diff
     1.1 --- a/arch/i386/kernel/acpi/processor.c	Mon May 05 10:14:25 2008 +0100
     1.2 +++ b/arch/i386/kernel/acpi/processor.c	Mon May 05 10:17:41 2008 +0100
     1.3 @@ -59,16 +59,21 @@ static void init_intel_pdc(struct acpi_p
     1.4  	return;
     1.5  }
     1.6  
     1.7 -/* 
     1.8 - * Initialize _PDC data based on the CPU vendor. As a work-around, just
     1.9 - * use cpu0's cpuinfo for all processors. Further work is required 
    1.10 - * to expose xen hypervisor interface of getting physical cpuinfo to dom0
    1.11 - * kerneland then arch_acpi_processor_init_pdc can set _PDC parameters 
    1.12 - * according to Xen's phys information.
    1.13 - */
    1.14 +/* Initialize _PDC data based on the CPU vendor */
    1.15  void arch_acpi_processor_init_pdc(struct acpi_processor *pr)
    1.16  {
    1.17 +#ifdef CONFIG_XEN
    1.18 +	/* 
    1.19 +	 * As a work-around, just use cpu0's cpuinfo for all processors.
    1.20 +	 * Further work is required to expose xen hypervisor interface of
    1.21 +	 * getting physical cpuinfo to dom0 kernel and then
    1.22 +	 * arch_acpi_processor_init_pdc can set _PDC parameters according
    1.23 +	 * to Xen's phys information.
    1.24 +	 */
    1.25  	unsigned int cpu = 0;
    1.26 +#else
    1.27 +	unsigned int cpu = pr->id;
    1.28 +#endif /* CONFIG_XEN */
    1.29  	struct cpuinfo_x86 *c = cpu_data + cpu;
    1.30  
    1.31  	pr->pdc = NULL;
     2.1 --- a/arch/i386/kernel/cpu/cpufreq/acpi-cpufreq.c	Mon May 05 10:14:25 2008 +0100
     2.2 +++ b/arch/i386/kernel/cpu/cpufreq/acpi-cpufreq.c	Mon May 05 10:17:41 2008 +0100
     2.3 @@ -568,6 +568,7 @@ acpi_cpufreq_init (void)
     2.4  {
     2.5  	dprintk("acpi_cpufreq_init\n");
     2.6  
     2.7 +#ifdef CONFIG_XEN
     2.8  	/*
     2.9  	 * This effectively blocks in-kernel cpufreq driver to interfere
    2.10  	 * external control logic
    2.11 @@ -576,6 +577,7 @@ acpi_cpufreq_init (void)
    2.12  		printk("CPUFREQ is controllerd externally...exit then!\n");
    2.13  		return -1;
    2.14  	}
    2.15 +#endif /* CONFIG_XEN */
    2.16  
    2.17  	acpi_cpufreq_early_init_acpi();
    2.18  
     3.1 --- a/drivers/acpi/processor_core.c	Mon May 05 10:14:25 2008 +0100
     3.2 +++ b/drivers/acpi/processor_core.c	Mon May 05 10:17:41 2008 +0100
     3.3 @@ -474,9 +474,14 @@ static int acpi_processor_get_info(struc
     3.4  	 *  they are physically not present.
     3.5  	 */
     3.6  	if (cpu_index == -1) {
     3.7 +#ifdef CONFIG_XEN
     3.8  		if (ACPI_FAILURE
     3.9  		    (acpi_processor_hotadd_init(pr->handle, &pr->id)) &&
    3.10  		    !processor_cntl_external()) {
    3.11 +#else
    3.12 +		if (ACPI_FAILURE
    3.13 +		    (acpi_processor_hotadd_init(pr->handle, &pr->id))) {
    3.14 +#endif /* CONFIG_XEN */
    3.15  			printk(KERN_ERR PREFIX
    3.16  				    "Getting cpuindex for acpiid 0x%x\n",
    3.17  				    pr->acpi_id);
    3.18 @@ -518,7 +523,11 @@ static int acpi_processor_get_info(struc
    3.19  	return 0;
    3.20  }
    3.21  
    3.22 +#ifdef CONFIG_XEN
    3.23  static void *processor_device_array[NR_ACPI_CPUS];
    3.24 +#else
    3.25 +static void *processor_device_array[NR_CPUS];
    3.26 +#endif /* CONFIG_XEN */
    3.27  
    3.28  static int acpi_processor_start(struct acpi_device *device)
    3.29  {
    3.30 @@ -530,29 +539,48 @@ static int acpi_processor_start(struct a
    3.31  	pr = acpi_driver_data(device);
    3.32  
    3.33  	result = acpi_processor_get_info(pr);
    3.34 +#ifdef CONFIG_XEN
    3.35  	if (result || 
    3.36  	    ((pr->id == -1) && !processor_cntl_external())) {
    3.37 +#else
    3.38 +	if (result) {
    3.39 +#endif /* CONFIG_XEN */
    3.40  		/* Processor is physically not present */
    3.41  		return 0;
    3.42  	}
    3.43  
    3.44 +#ifdef CONFIG_XEN
    3.45  	BUG_ON(!processor_cntl_external() &&
    3.46  	       ((pr->id >= NR_CPUS) || (pr->id < 0)));
    3.47 +#else
    3.48 +	BUG_ON((pr->id >= NR_CPUS) || (pr->id < 0));
    3.49 +#endif /* CONFIG_XEN */
    3.50  
    3.51  	/*
    3.52  	 * Buggy BIOS check
    3.53  	 * ACPI id of processors can be reported wrongly by the BIOS.
    3.54  	 * Don't trust it blindly
    3.55  	 */
    3.56 +#ifdef CONFIG_XEN
    3.57  	if (processor_device_array[pr->acpi_id] != NULL &&
    3.58  	    processor_device_array[pr->acpi_id] != (void *)device) {
    3.59 +#else
    3.60 +	if (processor_device_array[pr->id] != NULL &&
    3.61 +	    processor_device_array[pr->id] != (void *)device) {
    3.62 +#endif /* CONFIG_XEN */
    3.63  		printk(KERN_WARNING "BIOS reported wrong ACPI id"
    3.64  			"for the processor\n");
    3.65  		return -ENODEV;
    3.66  	}
    3.67 +#ifdef CONFIG_XEN
    3.68  	processor_device_array[pr->acpi_id] = (void *)device;
    3.69  	if (pr->id != -1)
    3.70  		processors[pr->id] = pr;
    3.71 +#else
    3.72 +	processor_device_array[pr->id] = (void *)device;
    3.73 +
    3.74 +	processors[pr->id] = pr;
    3.75 +#endif /* CONFIG_XEN */
    3.76  
    3.77  	result = acpi_processor_add_fs(device);
    3.78  	if (result)
    3.79 @@ -663,8 +691,13 @@ static int acpi_processor_remove(struct 
    3.80  
    3.81  	acpi_processor_remove_fs(device);
    3.82  
    3.83 +#ifdef CONFIG_XEN
    3.84  	if (pr->id != -1)
    3.85  		processors[pr->id] = NULL;
    3.86 +#else
    3.87 +	processors[pr->id] = NULL;
    3.88 +#endif /* CONFIG_XEN */
    3.89 +
    3.90  
    3.91  	kfree(pr);
    3.92  
    3.93 @@ -718,9 +751,11 @@ int acpi_processor_device_add(acpi_handl
    3.94  	if (!pr)
    3.95  		return -ENODEV;
    3.96  
    3.97 +#ifdef CONFIG_XEN
    3.98  	if (processor_cntl_external())
    3.99  		processor_notify_external(pr,
   3.100  			PROCESSOR_HOTPLUG, HOTPLUG_TYPE_ADD);
   3.101 +#endif /* CONFIG_XEN */
   3.102  
   3.103  	if ((pr->id >= 0) && (pr->id < NR_CPUS)) {
   3.104  		kobject_uevent(&(*device)->kobj, KOBJ_ONLINE);
   3.105 @@ -760,9 +795,11 @@ acpi_processor_hotplug_notify(acpi_handl
   3.106  			break;
   3.107  		}
   3.108  
   3.109 +#ifdef CONFIG_XEN
   3.110  		if (processor_cntl_external())
   3.111  			processor_notify_external(pr,
   3.112  					PROCESSOR_HOTPLUG, HOTPLUG_TYPE_ADD);
   3.113 +#endif /* CONFIG_XEN */
   3.114  
   3.115  		if (pr->id >= 0 && (pr->id < NR_CPUS)) {
   3.116  			kobject_uevent(&device->kobj, KOBJ_OFFLINE);
   3.117 @@ -793,13 +830,19 @@ acpi_processor_hotplug_notify(acpi_handl
   3.118  			return;
   3.119  		}
   3.120  
   3.121 +#ifdef CONFIG_XEN
   3.122  		if ((pr->id >= 0) && (pr->id < NR_CPUS)
   3.123  		    && (cpu_present(pr->id)))
   3.124 +#else
   3.125 +		if ((pr->id < NR_CPUS) && (cpu_present(pr->id)))
   3.126 +#endif /* CONFIG_XEN */
   3.127  			kobject_uevent(&device->kobj, KOBJ_OFFLINE);
   3.128  
   3.129 +#ifdef CONFIG_XEN
   3.130  		if (processor_cntl_external())
   3.131  			processor_notify_external(pr, PROCESSOR_HOTPLUG,
   3.132  							HOTPLUG_TYPE_REMOVE);
   3.133 +#endif /* CONFIG_XEN */
   3.134  
   3.135  		break;
   3.136  	default:
   3.137 @@ -865,8 +908,10 @@ static acpi_status acpi_processor_hotadd
   3.138  
   3.139  static int acpi_processor_handle_eject(struct acpi_processor *pr)
   3.140  {
   3.141 +#ifdef CONFIG_XEN
   3.142  	if (pr->id == -1)
   3.143  		return (0);
   3.144 +#endif /* CONFIG_XEN */
   3.145  
   3.146  	if (cpu_online(pr->id)) {
   3.147  		return (-EINVAL);
     4.1 --- a/drivers/acpi/processor_idle.c	Mon May 05 10:14:25 2008 +0100
     4.2 +++ b/drivers/acpi/processor_idle.c	Mon May 05 10:17:41 2008 +0100
     4.3 @@ -714,12 +714,17 @@ static int acpi_processor_get_power_info
     4.4  		    (reg->space_id != ACPI_ADR_SPACE_FIXED_HARDWARE))
     4.5  			continue;
     4.6  
     4.7 +#ifdef CONFIG_XEN
     4.8  		if (!processor_pm_external())
     4.9  			cx.address = (reg->space_id ==
    4.10  				      ACPI_ADR_SPACE_FIXED_HARDWARE) ?
    4.11  		    		      0 : reg->address;
    4.12  		else
    4.13  			cx.address = reg->address;
    4.14 +#else
    4.15 +		cx.address = (reg->space_id == ACPI_ADR_SPACE_FIXED_HARDWARE) ?
    4.16 +		    0 : reg->address;
    4.17 +#endif /* CONFIG_XEN */
    4.18  
    4.19  		/* There should be an easy way to extract an integer... */
    4.20  		obj = (union acpi_object *)&(element->package.elements[1]);
    4.21 @@ -728,11 +733,17 @@ static int acpi_processor_get_power_info
    4.22  
    4.23  		cx.type = obj->integer.value;
    4.24  
    4.25 +#ifdef CONFIG_XEN
    4.26  		/* Following check doesn't apply to external control case */
    4.27  		if (!processor_pm_external())
    4.28  			if ((cx.type != ACPI_STATE_C1) &&
    4.29  			    (reg->space_id != ACPI_ADR_SPACE_SYSTEM_IO))
    4.30  				continue;
    4.31 +#else
    4.32 +		if ((cx.type != ACPI_STATE_C1) &&
    4.33 +		    (reg->space_id != ACPI_ADR_SPACE_SYSTEM_IO))
    4.34 +			continue;
    4.35 +#endif /* CONFIG_XEN */
    4.36  
    4.37  		if ((cx.type < ACPI_STATE_C2) || (cx.type > ACPI_STATE_C3))
    4.38  			continue;
    4.39 @@ -997,16 +1008,24 @@ int acpi_processor_cst_has_changed(struc
    4.40  		return -ENODEV;
    4.41  
    4.42  	/* Fall back to the default idle loop */
    4.43 +#ifdef CONFIG_XEN
    4.44  	if (!processor_pm_external())
    4.45  		pm_idle = pm_idle_save;
    4.46 +#else
    4.47 +	pm_idle = pm_idle_save;
    4.48 +#endif /* CONFIG_XEN */
    4.49  	synchronize_sched();	/* Relies on interrupts forcing exit from idle. */
    4.50  
    4.51  	pr->flags.power = 0;
    4.52  	result = acpi_processor_get_power_info(pr);
    4.53 +#ifdef CONFIG_XEN
    4.54  	if (processor_pm_external())
    4.55  		processor_notify_external(pr,
    4.56  			PROCESSOR_PM_CHANGE, PM_TYPE_IDLE);
    4.57  	else if ((pr->flags.power == 1) && (pr->flags.power_setup_done))
    4.58 +#else
    4.59 +	if ((pr->flags.power == 1) && (pr->flags.power_setup_done))
    4.60 +#endif /* CONFIG_XEN */
    4.61  		pm_idle = acpi_processor_idle;
    4.62  
    4.63  	return result;
    4.64 @@ -1138,7 +1157,11 @@ int acpi_processor_power_init(struct acp
    4.65  				       pr->power.states[i].type);
    4.66  		printk(")\n");
    4.67  
    4.68 +#ifdef CONFIG_XEN
    4.69  		if (!processor_pm_external() && (pr->id == 0)) {
    4.70 +#else
    4.71 +		if (pr->id == 0) {
    4.72 +#endif /* CONFIG_XEN */
    4.73  			pm_idle_save = pm_idle;
    4.74  			pm_idle = acpi_processor_idle;
    4.75  		}
    4.76 @@ -1157,9 +1180,11 @@ int acpi_processor_power_init(struct acp
    4.77  
    4.78  	pr->flags.power_setup_done = 1;
    4.79  
    4.80 +#ifdef CONFIG_XEN
    4.81  	if (processor_pm_external())
    4.82  		processor_notify_external(pr,
    4.83  			PROCESSOR_PM_INIT, PM_TYPE_IDLE);
    4.84 +#endif /* CONFIG_XEN */
    4.85  	return 0;
    4.86  }
    4.87  
     5.1 --- a/drivers/acpi/processor_perflib.c	Mon May 05 10:14:25 2008 +0100
     5.2 +++ b/drivers/acpi/processor_perflib.c	Mon May 05 10:17:41 2008 +0100
     5.3 @@ -136,11 +136,13 @@ int acpi_processor_ppc_has_changed(struc
     5.4  	int ret = acpi_processor_get_platform_limit(pr);
     5.5  	if (ret < 0)
     5.6  		return (ret);
     5.7 -	else if (!processor_pmperf_external())
     5.8 -		return cpufreq_update_policy(pr->id);
     5.9 -	else
    5.10 +#ifdef CONFIG_XEN
    5.11 +	else if (processor_pmperf_external())
    5.12  		return processor_notify_external(pr,
    5.13  				PROCESSOR_PM_CHANGE, PM_TYPE_PERF);
    5.14 +#endif /* CONFIG_XEN */
    5.15 +	else
    5.16 +		return cpufreq_update_policy(pr->id);
    5.17  }
    5.18  
    5.19  void acpi_processor_ppc_init(void)
     6.1 --- a/include/acpi/processor.h	Mon May 05 10:14:25 2008 +0100
     6.2 +++ b/include/acpi/processor.h	Mon May 05 10:17:41 2008 +0100
     6.3 @@ -21,7 +21,9 @@
     6.4  #define ACPI_PSD_REV0_REVISION		0 /* Support for _PSD as in ACPI 3.0 */
     6.5  #define ACPI_PSD_REV0_ENTRIES		5
     6.6  
     6.7 +#ifdef CONFIG_XEN
     6.8  #define NR_ACPI_CPUS			256
     6.9 +#endif /* CONFIG_XEN */
    6.10  
    6.11  /*
    6.12   * Types of coordination defined in ACPI 3.0. Same macros can be used across
    6.13 @@ -294,6 +296,7 @@ static inline void acpi_thermal_cpufreq_
    6.14  }
    6.15  #endif
    6.16  
    6.17 +#ifdef CONFIG_XEN
    6.18  /* 
    6.19   * Following are interfaces geared to external processor PM control
    6.20   * logic like a VMM
    6.21 @@ -365,5 +368,6 @@ static inline int processor_extcntl_init
    6.22  	return -EINVAL;
    6.23  }
    6.24  #endif /* CONFIG_PROCESSOR_EXTERNAL_CONTROL */
    6.25 +#endif /* CONFIG_XEN */
    6.26  
    6.27  #endif