direct-io.hg

changeset 15107:8b9637467068

[IA64] Make p2m exposure compatible with suspend/resume and fix one bug.

Signed-off-by: Isaku Yamahata <yamahata@valinux.co.jp>
author Alex Williamson <alex.williamson@hp.com>
date Tue May 08 10:39:51 2007 -0600 (2007-05-08)
parents d7303c4a9dab
children 3ecf1cea58b1
files linux-2.6-xen-sparse/arch/ia64/xen/hypervisor.c linux-2.6-xen-sparse/include/asm-ia64/hypervisor.h
line diff
     1.1 --- a/linux-2.6-xen-sparse/arch/ia64/xen/hypervisor.c	Tue May 08 09:09:17 2007 -0600
     1.2 +++ b/linux-2.6-xen-sparse/arch/ia64/xen/hypervisor.c	Tue May 08 10:39:51 2007 -0600
     1.3 @@ -48,6 +48,7 @@ EXPORT_SYMBOL(running_on_xen);
     1.4  static int p2m_expose_init(void);
     1.5  #else
     1.6  #define p2m_expose_init() (-ENOSYS)
     1.7 +#define p2m_expose_resume() ((void)0)
     1.8  #endif
     1.9  
    1.10  EXPORT_SYMBOL(__hypercall);
    1.11 @@ -882,6 +883,8 @@ static struct resource p2m_resource = {
    1.12  };
    1.13  static unsigned long p2m_assign_start_pfn __read_mostly;
    1.14  static unsigned long p2m_assign_end_pfn __read_mostly;
    1.15 +static unsigned long p2m_expose_size;	// this is referenced only when resume.
    1.16 +					// so __read_mostly doesn't make sense.
    1.17  volatile const pte_t* p2m_pte __read_mostly;
    1.18  
    1.19  #define GRNULE_PFN	PTRS_PER_PTE
    1.20 @@ -942,8 +945,15 @@ p2m_expose_dtr_call(struct notifier_bloc
    1.21  	unsigned int cpu = (unsigned int)(long)ptr;
    1.22  	if (event != CPU_ONLINE)
    1.23  		return 0;
    1.24 -	if (!(p2m_initialized && xen_ia64_p2m_expose_use_dtr))
    1.25 -		smp_call_function_single(cpu, &p2m_itr, &p2m_itr_arg, 1, 1);
    1.26 +	if (p2m_initialized && xen_ia64_p2m_expose_use_dtr) {
    1.27 +		unsigned int me = get_cpu();
    1.28 +		if (cpu == me)
    1.29 +			p2m_itr(&p2m_itr_arg);
    1.30 +		else
    1.31 +			smp_call_function_single(cpu, &p2m_itr, &p2m_itr_arg,
    1.32 +						 1, 1);
    1.33 +		put_cpu();
    1.34 +	}
    1.35  	return 0;
    1.36  }
    1.37  
    1.38 @@ -958,7 +968,6 @@ static int
    1.39  p2m_expose_init(void)
    1.40  {
    1.41  	unsigned long num_pfn;
    1.42 -	unsigned long size = 0;
    1.43  	unsigned long p2m_size = 0;
    1.44  	unsigned long align = ~0UL;
    1.45  	int error = 0;
    1.46 @@ -1010,7 +1019,7 @@ p2m_expose_init(void)
    1.47  			p2m_convert_max_pfn = ROUNDUP(p2m_max_low_pfn,
    1.48  			                              granule_pfn);
    1.49  			num_pfn = p2m_convert_max_pfn - p2m_convert_min_pfn;
    1.50 -			size = num_pfn << PAGE_SHIFT;
    1.51 +			p2m_expose_size = num_pfn << PAGE_SHIFT;
    1.52  			p2m_size = num_pfn / PTRS_PER_PTE;
    1.53  			p2m_size = ROUNDUP(p2m_size, granule_pfn << PAGE_SHIFT);
    1.54  			if (p2m_size == page_size)
    1.55 @@ -1030,7 +1039,7 @@ p2m_expose_init(void)
    1.56  		                                p2m_granule_pfn);
    1.57  		p2m_convert_max_pfn = ROUNDUP(p2m_max_low_pfn, p2m_granule_pfn);
    1.58  		num_pfn = p2m_convert_max_pfn - p2m_convert_min_pfn;
    1.59 -		size = num_pfn << PAGE_SHIFT;
    1.60 +		p2m_expose_size = num_pfn << PAGE_SHIFT;
    1.61  		p2m_size = num_pfn / PTRS_PER_PTE;
    1.62  		p2m_size = ROUNDUP(p2m_size, p2m_granule_pfn << PAGE_SHIFT);
    1.63  		align = max(privcmd_resource_align,
    1.64 @@ -1054,14 +1063,14 @@ p2m_expose_init(void)
    1.65  	
    1.66  	error = HYPERVISOR_expose_p2m(p2m_convert_min_pfn,
    1.67  	                              p2m_assign_start_pfn,
    1.68 -	                              size, p2m_granule_pfn);
    1.69 +	                              p2m_expose_size, p2m_granule_pfn);
    1.70  	if (error) {
    1.71  		printk(KERN_ERR P2M_PREFIX "failed expose p2m hypercall %d\n",
    1.72  		       error);
    1.73  		printk(KERN_ERR P2M_PREFIX "conv 0x%016lx assign 0x%016lx "
    1.74 -		       "size 0x%016lx granule 0x%016lx\n",
    1.75 +		       "expose_size 0x%016lx granule 0x%016lx\n",
    1.76  		       p2m_convert_min_pfn, p2m_assign_start_pfn,
    1.77 -		       size, p2m_granule_pfn);;
    1.78 +		       p2m_expose_size, p2m_granule_pfn);;
    1.79  		release_resource(&p2m_resource);
    1.80  		goto out;
    1.81  	}
    1.82 @@ -1104,6 +1113,49 @@ p2m_expose_cleanup(void)
    1.83  }
    1.84  #endif
    1.85  
    1.86 +static void
    1.87 +p2m_expose_resume(void)
    1.88 +{
    1.89 +	int error;
    1.90 +
    1.91 +	if (!xen_ia64_p2m_expose || !p2m_initialized)
    1.92 +		return;
    1.93 +
    1.94 +	/*
    1.95 +	 * We can't call {lock, unlock}_cpu_hotplug() because
    1.96 +	 * they require process context.
    1.97 +	 * We don't need them because we're the only one cpu and
    1.98 +	 * interrupts are masked when resume.
    1.99 +	 */
   1.100 +	error = HYPERVISOR_expose_p2m(p2m_convert_min_pfn,
   1.101 +	                              p2m_assign_start_pfn,
   1.102 +	                              p2m_expose_size, p2m_granule_pfn);
   1.103 +	if (error) {
   1.104 +		printk(KERN_ERR P2M_PREFIX "failed expose p2m hypercall %d\n",
   1.105 +		       error);
   1.106 +		printk(KERN_ERR P2M_PREFIX "conv 0x%016lx assign 0x%016lx "
   1.107 +		       "expose_size 0x%016lx granule 0x%016lx\n",
   1.108 +		       p2m_convert_min_pfn, p2m_assign_start_pfn,
   1.109 +		       p2m_expose_size, p2m_granule_pfn);;
   1.110 +		p2m_initialized = 0;
   1.111 +		smp_mb();
   1.112 +		ia64_ptr(0x2, p2m_itr_arg.vaddr, p2m_itr_arg.log_page_size);
   1.113 +		
   1.114 +		/*
   1.115 +		 * We can't call those clean up functions because they
   1.116 +		 * require process context.
   1.117 +		 */
   1.118 +#if 0
   1.119 +#ifdef CONFIG_XEN_IA64_EXPOSE_P2M_USE_DTR
   1.120 +		if (xen_ia64_p2m_expose_use_dtr)
   1.121 +			unregister_cpu_notifier(
   1.122 +				&p2m_expose_dtr_hotplug_notifier);
   1.123 +#endif
   1.124 +		release_resource(&p2m_resource);
   1.125 +#endif
   1.126 +	}
   1.127 +}
   1.128 +
   1.129  //XXX inlinize?
   1.130  unsigned long
   1.131  p2m_phystomach(unsigned long gpfn)
   1.132 @@ -1187,3 +1239,15 @@ xen_ia64_unmap_resource(struct resource*
   1.133  	xen_ia64_release_resource(res);
   1.134  }
   1.135  EXPORT_SYMBOL_GPL(xen_ia64_unmap_resource);
   1.136 +
   1.137 +///////////////////////////////////////////////////////////////////////////
   1.138 +// suspend/resume
   1.139 +void
   1.140 +xen_post_suspend(int suspend_cancelled)
   1.141 +{
   1.142 +	if (suspend_cancelled)
   1.143 +		return;
   1.144 +	
   1.145 +	p2m_expose_resume();
   1.146 +	/* add more if necessary */
   1.147 +}
     2.1 --- a/linux-2.6-xen-sparse/include/asm-ia64/hypervisor.h	Tue May 08 09:09:17 2007 -0600
     2.2 +++ b/linux-2.6-xen-sparse/include/asm-ia64/hypervisor.h	Tue May 08 10:39:51 2007 -0600
     2.3 @@ -168,6 +168,9 @@ xen_destroy_contiguous_region(unsigned l
     2.4  		__xen_destroy_contiguous_region(vstart, order);
     2.5  }
     2.6  
     2.7 +/* For drivers/xen/core/machine_reboot.c */
     2.8 +#define HAVE_XEN_POST_SUSPEND
     2.9 +void xen_post_suspend(int suspend_cancelled);
    2.10  #endif /* !CONFIG_VMX_GUEST */
    2.11  
    2.12  // for netfront.c, netback.c