ia64/linux-2.6.18-xen.hg

changeset 514:0d6c9c975eae

linux/x86: fix powering off certain machines

Dell's Precision490, for example, fails to properly power off without
going through the full sequence of operations in the hypervisor. Hence
acpi_notify_hypervisor_state() must be defined, and used for entry to
S5, regardless of CONFIG_ACPI_PV_SLEEP configuration.

Also fix a compiler warning and the improper use of a hypervisor
return value as ACPI status.

Signed-off-by: Jan Beulich <jbeulich@novell.com>
author Keir Fraser <keir.fraser@citrix.com>
date Fri Apr 04 13:27:48 2008 +0100 (2008-04-04)
parents 51f1b31888b8
children b61443b1bf76
files arch/i386/kernel/acpi/sleep-xen.c arch/x86_64/kernel/acpi/sleep-xen.c drivers/acpi/hardware/hwsleep.c include/asm-i386/acpi.h include/asm-x86_64/acpi.h
line diff
     1.1 --- a/arch/i386/kernel/acpi/sleep-xen.c	Fri Apr 04 13:21:29 2008 +0100
     1.2 +++ b/arch/i386/kernel/acpi/sleep-xen.c	Fri Apr 04 13:27:48 2008 +0100
     1.3 @@ -110,25 +110,4 @@ static int __init acpisleep_dmi_init(voi
     1.4  }
     1.5  
     1.6  core_initcall(acpisleep_dmi_init);
     1.7 -
     1.8 -#else /* CONFIG_ACPI_PV_SLEEP */
     1.9 -#include <asm/hypervisor.h>
    1.10 -#include <xen/interface/platform.h>
    1.11 -int acpi_notify_hypervisor_state(u8 sleep_state,
    1.12 -	u32 pm1a_cnt, u32 pm1b_cnt)
    1.13 -{
    1.14 -	struct xen_platform_op op = {
    1.15 -		.cmd = XENPF_enter_acpi_sleep,
    1.16 -		.interface_version = XENPF_INTERFACE_VERSION,
    1.17 -		.u = {
    1.18 -			.enter_acpi_sleep = {
    1.19 -				.pm1a_cnt_val = (u16)pm1a_cnt,
    1.20 -				.pm1b_cnt_val = (u16)pm1b_cnt,
    1.21 -				.sleep_state = sleep_state,
    1.22 -			},
    1.23 -		},
    1.24 -	};
    1.25 -
    1.26 -	return HYPERVISOR_platform_op(&op);
    1.27 -}
    1.28  #endif /* CONFIG_ACPI_PV_SLEEP */
     2.1 --- a/arch/x86_64/kernel/acpi/sleep-xen.c	Fri Apr 04 13:21:29 2008 +0100
     2.2 +++ b/arch/x86_64/kernel/acpi/sleep-xen.c	Fri Apr 04 13:27:48 2008 +0100
     2.3 @@ -137,29 +137,6 @@ static int __init acpi_sleep_setup(char 
     2.4  }
     2.5  
     2.6  __setup("acpi_sleep=", acpi_sleep_setup);
     2.7 -
     2.8 -#else /* CONFIG_ACPI_PV_SLEEP */
     2.9 -#include <asm/hypervisor.h>
    2.10 -#include <xen/interface/platform.h>
    2.11 -int acpi_notify_hypervisor_state(u8 sleep_state,
    2.12 -	u32 pm1a_cnt, u32 pm1b_cnt)
    2.13 -{
    2.14 -	struct xen_platform_op op = {
    2.15 -		.cmd = XENPF_enter_acpi_sleep,
    2.16 -		.interface_version = XENPF_INTERFACE_VERSION,
    2.17 -		.u = {
    2.18 -			.enter_acpi_sleep = {
    2.19 -				.pm1a_cnt_val = (u16)pm1a_cnt,
    2.20 -				.pm1b_cnt_val = (u16)pm1b_cnt,
    2.21 -				.sleep_state = sleep_state,
    2.22 -			},
    2.23 -		},
    2.24 -	};
    2.25 -
    2.26 -	return HYPERVISOR_platform_op(&op);
    2.27 -}
    2.28 -#endif				/* CONFIG_ACPI_PV_SLEEP */
    2.29 -
    2.30  #endif				/*CONFIG_ACPI_SLEEP */
    2.31  
    2.32  void acpi_pci_link_exit(void)
     3.1 --- a/drivers/acpi/hardware/hwsleep.c	Fri Apr 04 13:21:29 2008 +0100
     3.2 +++ b/drivers/acpi/hardware/hwsleep.c	Fri Apr 04 13:27:48 2008 +0100
     3.3 @@ -227,7 +227,11 @@ acpi_status asmlinkage acpi_enter_sleep_
     3.4  	u32 PM1Bcontrol;
     3.5  	struct acpi_bit_register_info *sleep_type_reg_info;
     3.6  	struct acpi_bit_register_info *sleep_enable_reg_info;
     3.7 +#ifndef CONFIG_XEN
     3.8  	u32 in_value;
     3.9 +#else
    3.10 +	int err;
    3.11 +#endif
    3.12  	acpi_status status;
    3.13  
    3.14  	ACPI_FUNCTION_TRACE(acpi_enter_sleep_state);
    3.15 @@ -327,7 +331,7 @@ acpi_status asmlinkage acpi_enter_sleep_
    3.16  
    3.17  	ACPI_FLUSH_CPU_CACHE();
    3.18  
    3.19 -#ifndef CONFIG_ACPI_PV_SLEEP
    3.20 +#ifndef CONFIG_XEN
    3.21  	status = acpi_hw_register_write(ACPI_MTX_DO_NOT_LOCK,
    3.22  					ACPI_REGISTER_PM1A_CONTROL,
    3.23  					PM1Acontrol);
    3.24 @@ -377,17 +381,18 @@ acpi_status asmlinkage acpi_enter_sleep_
    3.25  		/* Spin until we wake */
    3.26  
    3.27  	} while (!in_value);
    3.28 -
    3.29 -	return_ACPI_STATUS(AE_OK);
    3.30  #else
    3.31  	/* PV ACPI just need check hypercall return value */
    3.32 -	status = acpi_notify_hypervisor_state(sleep_state,
    3.33 +	err = acpi_notify_hypervisor_state(sleep_state,
    3.34  			PM1Acontrol, PM1Bcontrol);
    3.35 -	if (ACPI_FAILURE(status))
    3.36 -		return_ACPI_STATUS(status);
    3.37 -	else
    3.38 -		return_ACPI_STATUS(AE_OK);
    3.39 +	if (err) {
    3.40 +		ACPI_DEBUG_PRINT((ACPI_DB_ERROR,
    3.41 +				  "Hypervisor failure [%d]\n", err));
    3.42 +		return_ACPI_STATUS(AE_ERROR);
    3.43 +	}
    3.44  #endif
    3.45 +
    3.46 +	return_ACPI_STATUS(AE_OK);
    3.47  }
    3.48  
    3.49  ACPI_EXPORT_SYMBOL(acpi_enter_sleep_state)
     4.1 --- a/include/asm-i386/acpi.h	Fri Apr 04 13:21:29 2008 +0100
     4.2 +++ b/include/asm-i386/acpi.h	Fri Apr 04 13:27:48 2008 +0100
     4.3 @@ -31,6 +31,9 @@
     4.4  #include <acpi/pdc_intel.h>
     4.5  
     4.6  #include <asm/system.h>		/* defines cmpxchg */
     4.7 +#ifdef CONFIG_XEN
     4.8 +#include <xen/interface/platform.h>
     4.9 +#endif
    4.10  
    4.11  #define COMPILER_DEPENDENT_INT64   long long
    4.12  #define COMPILER_DEPENDENT_UINT64  unsigned long long
    4.13 @@ -156,6 +159,27 @@ static inline void acpi_disable_pci(void
    4.14  }
    4.15  extern int acpi_irq_balance_set(char *str);
    4.16  
    4.17 +#ifdef CONFIG_XEN
    4.18 +static inline int acpi_notify_hypervisor_state(u8 sleep_state,
    4.19 +					       u32 pm1a_cnt_val,
    4.20 +					       u32 pm1b_cnt_val)
    4.21 +{
    4.22 +	struct xen_platform_op op = {
    4.23 +		.cmd = XENPF_enter_acpi_sleep,
    4.24 +		.interface_version = XENPF_INTERFACE_VERSION,
    4.25 +		.u = {
    4.26 +			.enter_acpi_sleep = {
    4.27 +				.pm1a_cnt_val = pm1a_cnt_val,
    4.28 +				.pm1b_cnt_val = pm1b_cnt_val,
    4.29 +				.sleep_state = sleep_state,
    4.30 +			},
    4.31 +		},
    4.32 +	};
    4.33 +
    4.34 +	return HYPERVISOR_platform_op(&op);
    4.35 +}
    4.36 +#endif /* CONFIG_XEN */
    4.37 +
    4.38  #else	/* !CONFIG_ACPI */
    4.39  
    4.40  #define acpi_lapic 0
    4.41 @@ -177,10 +201,6 @@ extern unsigned long acpi_wakeup_address
    4.42  /* early initialization routine */
    4.43  extern void acpi_reserve_bootmem(void);
    4.44  
    4.45 -#ifdef CONFIG_ACPI_PV_SLEEP
    4.46 -extern int acpi_notify_hypervisor_state(u8 sleep_state,
    4.47 -	u32 pm1a_cnt, u32 pm1b_cnt);
    4.48 -#endif /* CONFIG_ACPI_PV_SLEEP */
    4.49  #endif /*CONFIG_ACPI_SLEEP*/
    4.50  
    4.51  extern u8 x86_acpiid_to_apicid[];
     5.1 --- a/include/asm-x86_64/acpi.h	Fri Apr 04 13:21:29 2008 +0100
     5.2 +++ b/include/asm-x86_64/acpi.h	Fri Apr 04 13:27:48 2008 +0100
     5.3 @@ -28,6 +28,9 @@
     5.4  
     5.5  #ifdef __KERNEL__
     5.6  
     5.7 +#ifdef CONFIG_XEN
     5.8 +#include <xen/interface/platform.h>
     5.9 +#endif
    5.10  #include <acpi/pdc_intel.h>
    5.11  
    5.12  #define COMPILER_DEPENDENT_INT64   long long
    5.13 @@ -129,6 +132,27 @@ static inline void acpi_disable_pci(void
    5.14  }
    5.15  extern int acpi_irq_balance_set(char *str);
    5.16  
    5.17 +#ifdef CONFIG_XEN
    5.18 +static inline int acpi_notify_hypervisor_state(u8 sleep_state,
    5.19 +					       u32 pm1a_cnt_val,
    5.20 +					       u32 pm1b_cnt_val)
    5.21 +{
    5.22 +	struct xen_platform_op op = {
    5.23 +		.cmd = XENPF_enter_acpi_sleep,
    5.24 +		.interface_version = XENPF_INTERFACE_VERSION,
    5.25 +		.u = {
    5.26 +			.enter_acpi_sleep = {
    5.27 +				.pm1a_cnt_val = pm1a_cnt_val,
    5.28 +				.pm1b_cnt_val = pm1b_cnt_val,
    5.29 +				.sleep_state = sleep_state,
    5.30 +			},
    5.31 +		},
    5.32 +	};
    5.33 +
    5.34 +	return HYPERVISOR_platform_op(&op);
    5.35 +}
    5.36 +#endif /* CONFIG_XEN */
    5.37 +
    5.38  #else	/* !CONFIG_ACPI */
    5.39  
    5.40  #define acpi_lapic 0
    5.41 @@ -152,11 +176,6 @@ extern unsigned long acpi_wakeup_address
    5.42  
    5.43  /* early initialization routine */
    5.44  extern void acpi_reserve_bootmem(void);
    5.45 -
    5.46 -#ifdef CONFIG_ACPI_PV_SLEEP
    5.47 -extern int acpi_notify_hypervisor_state(u8 sleep_state,
    5.48 -	u32 pm1a_cnt, u32 pm1b_cnt);
    5.49 -#endif /* CONFIG_ACPI_PV_SLEEP */
    5.50  #endif /*CONFIG_ACPI_SLEEP*/
    5.51  
    5.52  #define boot_cpu_physical_apicid boot_cpu_id