ia64/linux-2.6.18-xen.hg

changeset 621:f4b11ef0c6eb

linux/acpi: adjust extcntl's changes to (mostly) common code, mostly for readability

While I realize that it may have been upon my request that all these
#ifdef-s were introduced, I think this went too far here: With the
abstraction in include/acpi/processor.h in place, the code still
guarantees even without all these #ifdef-s that in native kernels
built from the same source the logic will not change.

The one thing that appears a little weak still is the NR_ACPI_CPUS
construct - nothing guarantees that the ACPI IDs are constrained to 8
bits, and hence using an array here doesn't seem either safe or
scalable looking forward. To make the issue explict, the patch adds a
respective BUG_ON().

Also remove a stray export.

Signed-off-by: Jan Beulich <jbeulich@novell.com>
author Keir Fraser <keir.fraser@citrix.com>
date Wed Jul 23 14:20:56 2008 +0100 (2008-07-23)
parents 72234a8ee99c
children 2b60a0b5432e
files arch/i386/kernel/acpi/processor_extcntl_xen.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_extcntl_xen.c	Wed Jul 23 13:37:30 2008 +0100
     1.2 +++ b/arch/i386/kernel/acpi/processor_extcntl_xen.c	Wed Jul 23 14:20:56 2008 +0100
     1.3 @@ -40,7 +40,6 @@ static int __init set_xen_processor_pmbi
     1.4  	return 1;
     1.5  }
     1.6  __setup("xen_processor_pmbits=", set_xen_processor_pmbits);
     1.7 -EXPORT_SYMBOL(xen_processor_pmbits);
     1.8  
     1.9  static int xen_cx_notifier(struct acpi_processor *pr, int action)
    1.10  {
     2.1 --- a/drivers/acpi/processor_core.c	Wed Jul 23 13:37:30 2008 +0100
     2.2 +++ b/drivers/acpi/processor_core.c	Wed Jul 23 14:20:56 2008 +0100
     2.3 @@ -474,14 +474,9 @@ static int acpi_processor_get_info(struc
     2.4  	 *  they are physically not present.
     2.5  	 */
     2.6  	if (cpu_index == -1) {
     2.7 -#ifdef CONFIG_XEN
     2.8  		if (ACPI_FAILURE
     2.9  		    (acpi_processor_hotadd_init(pr->handle, &pr->id)) &&
    2.10  		    !processor_cntl_external()) {
    2.11 -#else
    2.12 -		if (ACPI_FAILURE
    2.13 -		    (acpi_processor_hotadd_init(pr->handle, &pr->id))) {
    2.14 -#endif /* CONFIG_XEN */
    2.15  			printk(KERN_ERR PREFIX
    2.16  				    "Getting cpuindex for acpiid 0x%x\n",
    2.17  				    pr->acpi_id);
    2.18 @@ -523,11 +518,7 @@ static int acpi_processor_get_info(struc
    2.19  	return 0;
    2.20  }
    2.21  
    2.22 -#ifdef CONFIG_XEN
    2.23  static void *processor_device_array[NR_ACPI_CPUS];
    2.24 -#else
    2.25 -static void *processor_device_array[NR_CPUS];
    2.26 -#endif /* CONFIG_XEN */
    2.27  
    2.28  static int acpi_processor_start(struct acpi_device *device)
    2.29  {
    2.30 @@ -539,22 +530,14 @@ static int acpi_processor_start(struct a
    2.31  	pr = acpi_driver_data(device);
    2.32  
    2.33  	result = acpi_processor_get_info(pr);
    2.34 -#ifdef CONFIG_XEN
    2.35  	if (result || 
    2.36  	    ((pr->id == -1) && !processor_cntl_external())) {
    2.37 -#else
    2.38 -	if (result) {
    2.39 -#endif /* CONFIG_XEN */
    2.40  		/* Processor is physically not present */
    2.41  		return 0;
    2.42  	}
    2.43  
    2.44 -#ifdef CONFIG_XEN
    2.45  	BUG_ON(!processor_cntl_external() &&
    2.46  	       ((pr->id >= NR_CPUS) || (pr->id < 0)));
    2.47 -#else
    2.48 -	BUG_ON((pr->id >= NR_CPUS) || (pr->id < 0));
    2.49 -#endif /* CONFIG_XEN */
    2.50  
    2.51  	/*
    2.52  	 * Buggy BIOS check
    2.53 @@ -562,6 +545,7 @@ static int acpi_processor_start(struct a
    2.54  	 * Don't trust it blindly
    2.55  	 */
    2.56  #ifdef CONFIG_XEN
    2.57 +	BUG_ON(pr->acpi_id >= NR_ACPI_CPUS);
    2.58  	if (processor_device_array[pr->acpi_id] != NULL &&
    2.59  	    processor_device_array[pr->acpi_id] != (void *)device) {
    2.60  #else
    2.61 @@ -595,9 +579,9 @@ static int acpi_processor_start(struct a
    2.62  
    2.63  	acpi_processor_power_init(pr, device);
    2.64  
    2.65 -#ifdef CONFIG_PROCESSOR_EXTERNAL_CONTROL
    2.66 -	processor_extcntl_init(pr);
    2.67 -#endif
    2.68 +	result = processor_extcntl_init(pr);
    2.69 +	if (result)
    2.70 +		goto end;
    2.71  
    2.72  	if (pr->flags.throttling) {
    2.73  		printk(KERN_INFO PREFIX "%s [%s] (supports",
    2.74 @@ -751,11 +735,9 @@ int acpi_processor_device_add(acpi_handl
    2.75  	if (!pr)
    2.76  		return -ENODEV;
    2.77  
    2.78 -#ifdef CONFIG_XEN
    2.79  	if (processor_cntl_external())
    2.80  		processor_notify_external(pr,
    2.81  			PROCESSOR_HOTPLUG, HOTPLUG_TYPE_ADD);
    2.82 -#endif /* CONFIG_XEN */
    2.83  
    2.84  	if ((pr->id >= 0) && (pr->id < NR_CPUS)) {
    2.85  		kobject_uevent(&(*device)->kobj, KOBJ_ONLINE);
    2.86 @@ -795,11 +777,9 @@ acpi_processor_hotplug_notify(acpi_handl
    2.87  			break;
    2.88  		}
    2.89  
    2.90 -#ifdef CONFIG_XEN
    2.91  		if (processor_cntl_external())
    2.92  			processor_notify_external(pr,
    2.93  					PROCESSOR_HOTPLUG, HOTPLUG_TYPE_ADD);
    2.94 -#endif /* CONFIG_XEN */
    2.95  
    2.96  		if (pr->id >= 0 && (pr->id < NR_CPUS)) {
    2.97  			kobject_uevent(&device->kobj, KOBJ_OFFLINE);
    2.98 @@ -838,11 +818,9 @@ acpi_processor_hotplug_notify(acpi_handl
    2.99  #endif /* CONFIG_XEN */
   2.100  			kobject_uevent(&device->kobj, KOBJ_OFFLINE);
   2.101  
   2.102 -#ifdef CONFIG_XEN
   2.103  		if (processor_cntl_external())
   2.104  			processor_notify_external(pr, PROCESSOR_HOTPLUG,
   2.105  							HOTPLUG_TYPE_REMOVE);
   2.106 -#endif /* CONFIG_XEN */
   2.107  
   2.108  		break;
   2.109  	default:
     3.1 --- a/drivers/acpi/processor_idle.c	Wed Jul 23 13:37:30 2008 +0100
     3.2 +++ b/drivers/acpi/processor_idle.c	Wed Jul 23 14:20:56 2008 +0100
     3.3 @@ -714,17 +714,12 @@ static int acpi_processor_get_power_info
     3.4  		    (reg->space_id != ACPI_ADR_SPACE_FIXED_HARDWARE))
     3.5  			continue;
     3.6  
     3.7 -#ifdef CONFIG_XEN
     3.8  		if (!processor_pm_external())
     3.9  			cx.address = (reg->space_id ==
    3.10  				      ACPI_ADR_SPACE_FIXED_HARDWARE) ?
    3.11  		    		      0 : reg->address;
    3.12  		else
    3.13  			cx.address = reg->address;
    3.14 -#else
    3.15 -		cx.address = (reg->space_id == ACPI_ADR_SPACE_FIXED_HARDWARE) ?
    3.16 -		    0 : reg->address;
    3.17 -#endif /* CONFIG_XEN */
    3.18  
    3.19  		/* There should be an easy way to extract an integer... */
    3.20  		obj = (union acpi_object *)&(element->package.elements[1]);
    3.21 @@ -733,17 +728,11 @@ static int acpi_processor_get_power_info
    3.22  
    3.23  		cx.type = obj->integer.value;
    3.24  
    3.25 -#ifdef CONFIG_XEN
    3.26  		/* Following check doesn't apply to external control case */
    3.27 -		if (!processor_pm_external())
    3.28 -			if ((cx.type != ACPI_STATE_C1) &&
    3.29 -			    (reg->space_id != ACPI_ADR_SPACE_SYSTEM_IO))
    3.30 -				continue;
    3.31 -#else
    3.32 -		if ((cx.type != ACPI_STATE_C1) &&
    3.33 +		if (!processor_pm_external() &&
    3.34 +		    (cx.type != ACPI_STATE_C1) &&
    3.35  		    (reg->space_id != ACPI_ADR_SPACE_SYSTEM_IO))
    3.36  			continue;
    3.37 -#endif /* CONFIG_XEN */
    3.38  
    3.39  		if ((cx.type < ACPI_STATE_C2) || (cx.type > ACPI_STATE_C3))
    3.40  			continue;
    3.41 @@ -1008,24 +997,16 @@ int acpi_processor_cst_has_changed(struc
    3.42  		return -ENODEV;
    3.43  
    3.44  	/* Fall back to the default idle loop */
    3.45 -#ifdef CONFIG_XEN
    3.46  	if (!processor_pm_external())
    3.47  		pm_idle = pm_idle_save;
    3.48 -#else
    3.49 -	pm_idle = pm_idle_save;
    3.50 -#endif /* CONFIG_XEN */
    3.51  	synchronize_sched();	/* Relies on interrupts forcing exit from idle. */
    3.52  
    3.53  	pr->flags.power = 0;
    3.54  	result = acpi_processor_get_power_info(pr);
    3.55 -#ifdef CONFIG_XEN
    3.56  	if (processor_pm_external())
    3.57  		processor_notify_external(pr,
    3.58  			PROCESSOR_PM_CHANGE, PM_TYPE_IDLE);
    3.59  	else if ((pr->flags.power == 1) && (pr->flags.power_setup_done))
    3.60 -#else
    3.61 -	if ((pr->flags.power == 1) && (pr->flags.power_setup_done))
    3.62 -#endif /* CONFIG_XEN */
    3.63  		pm_idle = acpi_processor_idle;
    3.64  
    3.65  	return result;
    3.66 @@ -1157,11 +1138,7 @@ int acpi_processor_power_init(struct acp
    3.67  				       pr->power.states[i].type);
    3.68  		printk(")\n");
    3.69  
    3.70 -#ifdef CONFIG_XEN
    3.71  		if (!processor_pm_external() && (pr->id == 0)) {
    3.72 -#else
    3.73 -		if (pr->id == 0) {
    3.74 -#endif /* CONFIG_XEN */
    3.75  			pm_idle_save = pm_idle;
    3.76  			pm_idle = acpi_processor_idle;
    3.77  		}
    3.78 @@ -1180,11 +1157,9 @@ int acpi_processor_power_init(struct acp
    3.79  
    3.80  	pr->flags.power_setup_done = 1;
    3.81  
    3.82 -#ifdef CONFIG_XEN
    3.83  	if (processor_pm_external())
    3.84  		processor_notify_external(pr,
    3.85  			PROCESSOR_PM_INIT, PM_TYPE_IDLE);
    3.86 -#endif /* CONFIG_XEN */
    3.87  	return 0;
    3.88  }
    3.89  
     4.1 --- a/drivers/acpi/processor_perflib.c	Wed Jul 23 13:37:30 2008 +0100
     4.2 +++ b/drivers/acpi/processor_perflib.c	Wed Jul 23 14:20:56 2008 +0100
     4.3 @@ -136,11 +136,9 @@ int acpi_processor_ppc_has_changed(struc
     4.4  	int ret = acpi_processor_get_platform_limit(pr);
     4.5  	if (ret < 0)
     4.6  		return (ret);
     4.7 -#ifdef CONFIG_XEN
     4.8  	else if (processor_pmperf_external())
     4.9  		return processor_notify_external(pr,
    4.10  				PROCESSOR_PM_CHANGE, PM_TYPE_PERF);
    4.11 -#endif /* CONFIG_XEN */
    4.12  	else
    4.13  		return cpufreq_update_policy(pr->id);
    4.14  }
    4.15 @@ -305,10 +303,9 @@ static int acpi_processor_get_performanc
    4.16  }
    4.17  
    4.18  #ifndef CONFIG_PROCESSOR_EXTERNAL_CONTROL
    4.19 -static int acpi_processor_get_performance_info(struct acpi_processor *pr)
    4.20 -#else
    4.21 +static
    4.22 +#endif
    4.23  int acpi_processor_get_performance_info(struct acpi_processor *pr)
    4.24 -#endif
    4.25  {
    4.26  	int result = 0;
    4.27  	acpi_status status = AE_OK;
    4.28 @@ -548,10 +545,9 @@ static void acpi_cpufreq_remove_file(str
    4.29  #endif				/* CONFIG_X86_ACPI_CPUFREQ_PROC_INTF */
    4.30  
    4.31  #ifndef CONFIG_PROCESSOR_EXTERNAL_CONTROL
    4.32 -static int acpi_processor_get_psd(struct acpi_processor	*pr)
    4.33 -#else
    4.34 +static
    4.35 +#endif
    4.36  int acpi_processor_get_psd(struct acpi_processor *pr)
    4.37 -#endif
    4.38  {
    4.39  	int result = 0;
    4.40  	acpi_status status = AE_OK;
     5.1 --- a/include/acpi/processor.h	Wed Jul 23 13:37:30 2008 +0100
     5.2 +++ b/include/acpi/processor.h	Wed Jul 23 14:20:56 2008 +0100
     5.3 @@ -22,7 +22,9 @@
     5.4  #define ACPI_PSD_REV0_ENTRIES		5
     5.5  
     5.6  #ifdef CONFIG_XEN
     5.7 -#define NR_ACPI_CPUS			256
     5.8 +#define NR_ACPI_CPUS			(NR_CPUS < 256 ? 256 : NR_CPUS)
     5.9 +#else
    5.10 +#define NR_ACPI_CPUS			NR_CPUS
    5.11  #endif /* CONFIG_XEN */
    5.12  
    5.13  /*
    5.14 @@ -296,7 +298,6 @@ static inline void acpi_thermal_cpufreq_
    5.15  }
    5.16  #endif
    5.17  
    5.18 -#ifdef CONFIG_XEN
    5.19  /* 
    5.20   * Following are interfaces geared to external processor PM control
    5.21   * logic like a VMM
    5.22 @@ -306,7 +307,7 @@ static inline void acpi_thermal_cpufreq_
    5.23  #define PROCESSOR_PM_CHANGE	2
    5.24  #define PROCESSOR_HOTPLUG	3
    5.25  
    5.26 -/* Objects for the PM envents */
    5.27 +/* Objects for the PM events */
    5.28  #define PM_TYPE_IDLE		0
    5.29  #define PM_TYPE_PERF		1
    5.30  #define PM_TYPE_THR		2
    5.31 @@ -362,13 +363,12 @@ static inline int processor_pmthr_extern
    5.32  static inline int processor_notify_external(struct acpi_processor *pr,
    5.33  			int event, int type)
    5.34  {
    5.35 -	return -EINVAL;
    5.36 +	return 0;
    5.37  }
    5.38  static inline int processor_extcntl_init(struct acpi_processor *pr)
    5.39  {
    5.40 -	return -EINVAL;
    5.41 +	return 0;
    5.42  }
    5.43  #endif /* CONFIG_PROCESSOR_EXTERNAL_CONTROL */
    5.44 -#endif /* CONFIG_XEN */
    5.45  
    5.46  #endif