ia64/linux-2.6.18-xen.hg

changeset 106:22c388bfd719

Refactor grant table allocation into arch-specific code.
Signed-off-by: Hollis Blanchard <hollisb@us.ibm.com>
author kfraser@localhost.localdomain
date Fri Jul 06 17:33:03 2007 +0100 (2007-07-06)
parents 4a08141e62ca
children e5f633c33025
files arch/ia64/xen/hypervisor.c drivers/xen/core/gnttab.c include/xen/gnttab.h
line diff
     1.1 --- a/arch/ia64/xen/hypervisor.c	Fri Jul 06 14:32:59 2007 +0100
     1.2 +++ b/arch/ia64/xen/hypervisor.c	Fri Jul 06 17:33:03 2007 +0100
     1.3 @@ -409,6 +409,11 @@ void
     1.4  #include <xen/interface/xen.h>
     1.5  #include <xen/gnttab.h>
     1.6  
     1.7 +void *arch_gnttab_alloc_shared(unsigned long *frames)
     1.8 +{
     1.9 +	return __va(frames[0] << PAGE_SHIFT);
    1.10 +}
    1.11 +
    1.12  static void
    1.13  gnttab_map_grant_ref_pre(struct gnttab_map_grant_ref *uop)
    1.14  {
     2.1 --- a/drivers/xen/core/gnttab.c	Fri Jul 06 14:32:59 2007 +0100
     2.2 +++ b/drivers/xen/core/gnttab.c	Fri Jul 06 17:33:03 2007 +0100
     2.3 @@ -430,7 +430,7 @@ static inline unsigned int max_nr_grant_
     2.4  
     2.5  #ifdef CONFIG_XEN
     2.6  
     2.7 -#ifndef __ia64__
     2.8 +#ifdef CONFIG_X86
     2.9  static int map_pte_fn(pte_t *pte, struct page *pmd_page,
    2.10  		      unsigned long addr, void *data)
    2.11  {
    2.12 @@ -448,7 +448,15 @@ static int unmap_pte_fn(pte_t *pte, stru
    2.13  	set_pte_at(&init_mm, addr, pte, __pte(0));
    2.14  	return 0;
    2.15  }
    2.16 -#endif
    2.17 +
    2.18 +void *arch_gnttab_alloc_shared(unsigned long *frames)
    2.19 +{
    2.20 +	struct vm_struct *area;
    2.21 +	area = alloc_vm_area(PAGE_SIZE * max_nr_grant_frames());
    2.22 +	BUG_ON(area == NULL);
    2.23 +	return area->addr;
    2.24 +}
    2.25 +#endif /* CONFIG_X86 */
    2.26  
    2.27  static int gnttab_map(unsigned int start_idx, unsigned int end_idx)
    2.28  {
    2.29 @@ -473,21 +481,16 @@ static int gnttab_map(unsigned int start
    2.30  
    2.31  	BUG_ON(rc || setup.status);
    2.32  
    2.33 -#ifndef __ia64__
    2.34 -	if (shared == NULL) {
    2.35 -		struct vm_struct *area;
    2.36 -		area = alloc_vm_area(PAGE_SIZE * max_nr_grant_frames());
    2.37 -		BUG_ON(area == NULL);
    2.38 -		shared = area->addr;
    2.39 -	}
    2.40 +	if (shared == NULL)
    2.41 +		shared = arch_gnttab_alloc_shared(frames);
    2.42 +
    2.43 +#ifdef CONFIG_X86
    2.44  	rc = apply_to_page_range(&init_mm, (unsigned long)shared,
    2.45  				 PAGE_SIZE * nr_gframes,
    2.46  				 map_pte_fn, &frames);
    2.47  	BUG_ON(rc);
    2.48 -        frames -= nr_gframes; /* adjust after map_pte_fn() */
    2.49 -#else
    2.50 -	shared = __va(frames[0] << PAGE_SHIFT);
    2.51 -#endif
    2.52 +	frames -= nr_gframes; /* adjust after map_pte_fn() */
    2.53 +#endif /* CONFIG_X86 */
    2.54  
    2.55  	kfree(frames);
    2.56  
    2.57 @@ -623,7 +626,7 @@ int gnttab_resume(void)
    2.58  
    2.59  int gnttab_suspend(void)
    2.60  {
    2.61 -#ifndef __ia64__
    2.62 +#ifdef CONFIG_X86
    2.63  	apply_to_page_range(&init_mm, (unsigned long)shared,
    2.64  			    PAGE_SIZE * nr_grant_frames,
    2.65  			    unmap_pte_fn, NULL);
     3.1 --- a/include/xen/gnttab.h	Fri Jul 06 14:32:59 2007 +0100
     3.2 +++ b/include/xen/gnttab.h	Fri Jul 06 17:33:03 2007 +0100
     3.3 @@ -117,6 +117,8 @@ static inline void gnttab_reset_grant_pa
     3.4  int gnttab_suspend(void);
     3.5  int gnttab_resume(void);
     3.6  
     3.7 +void *arch_gnttab_alloc_shared(unsigned long *frames);
     3.8 +
     3.9  static inline void
    3.10  gnttab_set_map_op(struct gnttab_map_grant_ref *map, maddr_t addr,
    3.11  		  uint32_t flags, grant_ref_t ref, domid_t domid)