ia64/xen-unstable

changeset 10841:7ee2c02c6db0

[LINUX] Clean up reboot.c suspend handling.
Signed-off-by: Keir Fraser <keir@xensource.com>
author kfraser@localhost.localdomain
date Fri Jul 28 11:10:08 2006 +0100 (2006-07-28)
parents e5c84586c333
children 4c97599398fe a10d02d20b31
files linux-2.6-xen-sparse/arch/i386/mm/pgtable-xen.c linux-2.6-xen-sparse/drivers/xen/core/reboot.c
line diff
     1.1 --- a/linux-2.6-xen-sparse/arch/i386/mm/pgtable-xen.c	Fri Jul 28 10:51:38 2006 +0100
     1.2 +++ b/linux-2.6-xen-sparse/arch/i386/mm/pgtable-xen.c	Fri Jul 28 11:10:08 2006 +0100
     1.3 @@ -652,8 +652,13 @@ void mm_unpin(struct mm_struct *mm)
     1.4  void mm_pin_all(void)
     1.5  {
     1.6  	struct page *page;
     1.7 +
     1.8 +	/* Only pgds on the pgd_list please: none hidden in the slab cache. */
     1.9 +	kmem_cache_shrink(pgd_cache);
    1.10 +
    1.11  	if (xen_feature(XENFEAT_writable_page_tables))
    1.12  		return;
    1.13 +
    1.14  	for (page = pgd_list; page; page = (struct page *)page->index) {
    1.15  		if (!test_bit(PG_pinned, &page->flags))
    1.16  			__pgd_pin((pgd_t *)page_address(page));
     2.1 --- a/linux-2.6-xen-sparse/drivers/xen/core/reboot.c	Fri Jul 28 10:51:38 2006 +0100
     2.2 +++ b/linux-2.6-xen-sparse/drivers/xen/core/reboot.c	Fri Jul 28 11:10:08 2006 +0100
     2.3 @@ -19,14 +19,6 @@
     2.4  #include <xen/xencons.h>
     2.5  #include <xen/cpu_hotplug.h>
     2.6  
     2.7 -#if defined(__i386__) || defined(__x86_64__)
     2.8 -/*
     2.9 - * Power off function, if any
    2.10 - */
    2.11 -void (*pm_power_off)(void);
    2.12 -EXPORT_SYMBOL(pm_power_off);
    2.13 -#endif
    2.14 -
    2.15  extern void ctrl_alt_del(void);
    2.16  
    2.17  #define SHUTDOWN_INVALID  -1
    2.18 @@ -40,6 +32,13 @@ extern void ctrl_alt_del(void);
    2.19  #define SHUTDOWN_HALT      4
    2.20  
    2.21  #if defined(__i386__) || defined(__x86_64__)
    2.22 +
    2.23 +/*
    2.24 + * Power off function, if any
    2.25 + */
    2.26 +void (*pm_power_off)(void);
    2.27 +EXPORT_SYMBOL(pm_power_off);
    2.28 +
    2.29  void machine_emergency_restart(void)
    2.30  {
    2.31  	/* We really want to get pending console data out before we die. */
    2.32 @@ -70,7 +69,8 @@ int reboot_thru_bios = 0;	/* for dmi_sca
    2.33  EXPORT_SYMBOL(machine_restart);
    2.34  EXPORT_SYMBOL(machine_halt);
    2.35  EXPORT_SYMBOL(machine_power_off);
    2.36 -#endif
    2.37 +
    2.38 +#endif /* defined(__i386__) || defined(__x86_64__) */
    2.39  
    2.40  /******************************************************************************
    2.41   * Stop/pickle callback handling.
    2.42 @@ -82,6 +82,7 @@ static void __shutdown_handler(void *unu
    2.43  static DECLARE_WORK(shutdown_work, __shutdown_handler, NULL);
    2.44  
    2.45  #if defined(__i386__) || defined(__x86_64__)
    2.46 +
    2.47  /* Ensure we run on the idle task page tables so that we will
    2.48     switch page tables before running user space. This is needed
    2.49     on architectures with separate kernel and user page tables
    2.50 @@ -98,17 +99,58 @@ static void switch_idle_mm(void)
    2.51  	current->active_mm = &init_mm;
    2.52  	mmdrop(mm);
    2.53  }
    2.54 +
    2.55 +static void pre_suspend(void)
    2.56 +{
    2.57 +	HYPERVISOR_shared_info = (shared_info_t *)empty_zero_page;
    2.58 +	clear_fixmap(FIX_SHARED_INFO);
    2.59 +
    2.60 +	xen_start_info->store_mfn = mfn_to_pfn(xen_start_info->store_mfn);
    2.61 +	xen_start_info->console_mfn = mfn_to_pfn(xen_start_info->console_mfn);
    2.62 +}
    2.63 +
    2.64 +static void post_suspend(void)
    2.65 +{
    2.66 +	int i, j, k, fpp;
    2.67 +	extern unsigned long max_pfn;
    2.68 +	extern unsigned long *pfn_to_mfn_frame_list_list;
    2.69 +	extern unsigned long *pfn_to_mfn_frame_list[];
    2.70 +
    2.71 +	set_fixmap(FIX_SHARED_INFO, xen_start_info->shared_info);
    2.72 +
    2.73 +	HYPERVISOR_shared_info = (shared_info_t *)fix_to_virt(FIX_SHARED_INFO);
    2.74 +
    2.75 +	memset(empty_zero_page, 0, PAGE_SIZE);
    2.76 +
    2.77 +	HYPERVISOR_shared_info->arch.pfn_to_mfn_frame_list_list =
    2.78 +		virt_to_mfn(pfn_to_mfn_frame_list_list);
    2.79 +
    2.80 +	fpp = PAGE_SIZE/sizeof(unsigned long);
    2.81 +	for (i = 0, j = 0, k = -1; i < max_pfn; i += fpp, j++) {
    2.82 +		if ((j % fpp) == 0) {
    2.83 +			k++;
    2.84 +			pfn_to_mfn_frame_list_list[k] =
    2.85 +				virt_to_mfn(pfn_to_mfn_frame_list[k]);
    2.86 +			j = 0;
    2.87 +		}
    2.88 +		pfn_to_mfn_frame_list[k][j] =
    2.89 +			virt_to_mfn(&phys_to_machine_mapping[i]);
    2.90 +	}
    2.91 +	HYPERVISOR_shared_info->arch.max_pfn = max_pfn;
    2.92 +}
    2.93 +
    2.94 +#else /* !(defined(__i386__) || defined(__x86_64__)) */
    2.95 +
    2.96 +#define switch_idle_mm()	((void)0)
    2.97 +#define mm_pin_all()		((void)0)
    2.98 +#define pre_suspend()		((void)0)
    2.99 +#define post_suspend()		((void)0)
   2.100 +
   2.101  #endif
   2.102  
   2.103  static int __do_suspend(void *ignore)
   2.104  {
   2.105  	int err;
   2.106 -#if defined(__i386__) || defined(__x86_64__)
   2.107 -	int i, j, k, fpp;
   2.108 -	extern unsigned long max_pfn;
   2.109 -	extern unsigned long *pfn_to_mfn_frame_list_list;
   2.110 -	extern unsigned long *pfn_to_mfn_frame_list[];
   2.111 -#endif
   2.112  
   2.113  	extern void time_resume(void);
   2.114  
   2.115 @@ -131,27 +173,13 @@ static int __do_suspend(void *ignore)
   2.116  
   2.117  	preempt_disable();
   2.118  
   2.119 -#ifdef __i386__
   2.120 -	kmem_cache_shrink(pgd_cache);
   2.121 -#endif
   2.122 -#if defined(__i386__) || defined(__x86_64__)
   2.123  	mm_pin_all();
   2.124 -
   2.125 -	__cli();
   2.126 -#elif defined(__ia64__)
   2.127  	local_irq_disable();
   2.128 -#endif
   2.129  	preempt_enable();
   2.130  
   2.131  	gnttab_suspend();
   2.132  
   2.133 -#if defined(__i386__) || defined(__x86_64__)
   2.134 -	HYPERVISOR_shared_info = (shared_info_t *)empty_zero_page;
   2.135 -	clear_fixmap(FIX_SHARED_INFO);
   2.136 -
   2.137 -	xen_start_info->store_mfn = mfn_to_pfn(xen_start_info->store_mfn);
   2.138 -	xen_start_info->console_mfn = mfn_to_pfn(xen_start_info->console_mfn);
   2.139 -#endif
   2.140 +	pre_suspend();
   2.141  
   2.142  	/*
   2.143  	 * We'll stop somewhere inside this hypercall. When it returns,
   2.144 @@ -161,29 +189,7 @@ static int __do_suspend(void *ignore)
   2.145  
   2.146  	shutting_down = SHUTDOWN_INVALID;
   2.147  
   2.148 -#if defined(__i386__) || defined(__x86_64__)
   2.149 -	set_fixmap(FIX_SHARED_INFO, xen_start_info->shared_info);
   2.150 -
   2.151 -	HYPERVISOR_shared_info = (shared_info_t *)fix_to_virt(FIX_SHARED_INFO);
   2.152 -
   2.153 -	memset(empty_zero_page, 0, PAGE_SIZE);
   2.154 -
   2.155 -	HYPERVISOR_shared_info->arch.pfn_to_mfn_frame_list_list =
   2.156 -		virt_to_mfn(pfn_to_mfn_frame_list_list);
   2.157 -
   2.158 -	fpp = PAGE_SIZE/sizeof(unsigned long);
   2.159 -	for (i = 0, j = 0, k = -1; i < max_pfn; i += fpp, j++) {
   2.160 -		if ((j % fpp) == 0) {
   2.161 -			k++;
   2.162 -			pfn_to_mfn_frame_list_list[k] =
   2.163 -				virt_to_mfn(pfn_to_mfn_frame_list[k]);
   2.164 -			j = 0;
   2.165 -		}
   2.166 -		pfn_to_mfn_frame_list[k][j] =
   2.167 -			virt_to_mfn(&phys_to_machine_mapping[i]);
   2.168 -	}
   2.169 -	HYPERVISOR_shared_info->arch.max_pfn = max_pfn;
   2.170 -#endif
   2.171 +	post_suspend();
   2.172  
   2.173  	gnttab_resume();
   2.174  
   2.175 @@ -191,13 +197,9 @@ static int __do_suspend(void *ignore)
   2.176  
   2.177  	time_resume();
   2.178  
   2.179 -#if defined(__i386__) || defined(__x86_64__)
   2.180  	switch_idle_mm();
   2.181  
   2.182 -	__sti();
   2.183 -#elif defined(__ia64__)
   2.184  	local_irq_enable();
   2.185 -#endif
   2.186  
   2.187  	xencons_resume();
   2.188