ia64/xen-unstable

changeset 9222:c5286130a96e

Map grant table pages in vmalloc kernel address space instead of fixmap.

Signed-off-by: Christian Limpach <Christian.Limpach@cl.cam.ac.uk>
author cl349@firebug.cl.cam.ac.uk
date Fri Mar 10 13:27:24 2006 +0000 (2006-03-10)
parents cc303cdf8809
children e408a374840c
files linux-2.6-xen-sparse/drivers/xen/core/gnttab.c linux-2.6-xen-sparse/include/asm-i386/mach-xen/asm/fixmap.h linux-2.6-xen-sparse/include/asm-x86_64/mach-xen/asm/fixmap.h
line diff
     1.1 --- a/linux-2.6-xen-sparse/drivers/xen/core/gnttab.c	Fri Mar 10 11:05:59 2006 +0100
     1.2 +++ b/linux-2.6-xen-sparse/drivers/xen/core/gnttab.c	Fri Mar 10 13:27:24 2006 +0000
     1.3 @@ -31,6 +31,8 @@
     1.4  #include <linux/config.h>
     1.5  #include <linux/module.h>
     1.6  #include <linux/sched.h>
     1.7 +#include <linux/mm.h>
     1.8 +#include <linux/vmalloc.h>
     1.9  #include <asm/pgtable.h>
    1.10  #include <xen/interface/xen.h>
    1.11  #include <asm/fixmap.h>
    1.12 @@ -77,7 +79,7 @@ static int gnttab_free_count;
    1.13  static grant_ref_t gnttab_free_head;
    1.14  static spinlock_t gnttab_list_lock = SPIN_LOCK_UNLOCKED;
    1.15  
    1.16 -static grant_entry_t *shared;
    1.17 +static grant_entry_t *shared = NULL;
    1.18  
    1.19  static struct gnttab_free_callback *gnttab_free_callback_list = NULL;
    1.20  
    1.21 @@ -354,12 +356,35 @@ gnttab_request_free_callback(struct gntt
    1.22  	spin_unlock_irqrestore(&gnttab_list_lock, flags);
    1.23  }
    1.24  
    1.25 +#ifndef __ia64__
    1.26 +static int map_pte_fn(pte_t *pte, struct page *pte_page,
    1.27 +		      unsigned long addr, void *data)
    1.28 +{
    1.29 +	unsigned long **frames = (unsigned long **)data;
    1.30 +
    1.31 +	set_pte_at(&init_mm, addr, pte, pfn_pte_ma((*frames)[0], PAGE_KERNEL));
    1.32 +	(*frames)++;
    1.33 +	return 0;
    1.34 +}
    1.35 +
    1.36 +static int unmap_pte_fn(pte_t *pte, struct page *pte_page,
    1.37 +		      unsigned long addr, void *data)
    1.38 +{
    1.39 +
    1.40 +	set_pte_at(&init_mm, addr, pte, __pte(0));
    1.41 +	return 0;
    1.42 +}
    1.43 +#endif
    1.44 +
    1.45  int
    1.46  gnttab_resume(void)
    1.47  {
    1.48  	gnttab_setup_table_t setup;
    1.49 -	unsigned long        frames[NR_GRANT_FRAMES];
    1.50 -	int                  i;
    1.51 +	unsigned long frames[NR_GRANT_FRAMES];
    1.52 +#ifndef __ia64__
    1.53 +	void *pframes = frames;
    1.54 +	struct vm_struct *area;
    1.55 +#endif
    1.56  
    1.57  	setup.dom        = DOMID_SELF;
    1.58  	setup.nr_frames  = NR_GRANT_FRAMES;
    1.59 @@ -368,12 +393,18 @@ gnttab_resume(void)
    1.60  	BUG_ON(HYPERVISOR_grant_table_op(GNTTABOP_setup_table, &setup, 1));
    1.61  	BUG_ON(setup.status != 0);
    1.62  
    1.63 -#ifdef __ia64__
    1.64 +#ifndef __ia64__
    1.65 +	if (shared == NULL) {
    1.66 +		area = get_vm_area(PAGE_SIZE * NR_GRANT_FRAMES, VM_IOREMAP);
    1.67 +		BUG_ON(area == NULL);
    1.68 +		shared = area->addr;
    1.69 +	}
    1.70 +	BUG_ON(generic_page_range(&init_mm, (unsigned long)shared,
    1.71 +				  PAGE_SIZE * NR_GRANT_FRAMES,
    1.72 +				  map_pte_fn, &pframes));
    1.73 +#else
    1.74  	shared = __va(frames[0] << PAGE_SHIFT);
    1.75  	printk("grant table at %p\n", shared);
    1.76 -#else
    1.77 -	for (i = 0; i < NR_GRANT_FRAMES; i++)
    1.78 -		set_fixmap(FIX_GNTTAB_END - i, frames[i] << PAGE_SHIFT);
    1.79  #endif
    1.80  
    1.81  	return 0;
    1.82 @@ -382,10 +413,12 @@ gnttab_resume(void)
    1.83  int
    1.84  gnttab_suspend(void)
    1.85  {
    1.86 -	int i;
    1.87  
    1.88 -	for (i = 0; i < NR_GRANT_FRAMES; i++)
    1.89 -		clear_fixmap(FIX_GNTTAB_END - i);
    1.90 +#ifndef __ia64__
    1.91 +	generic_page_range(&init_mm, (unsigned long)shared,
    1.92 +			   PAGE_SIZE * NR_GRANT_FRAMES,
    1.93 +			   unmap_pte_fn, NULL);
    1.94 +#endif
    1.95  
    1.96  	return 0;
    1.97  }
    1.98 @@ -400,10 +433,6 @@ gnttab_init(void)
    1.99  
   1.100  	BUG_ON(gnttab_resume());
   1.101  
   1.102 -#ifndef __ia64__
   1.103 -	shared = (grant_entry_t *)fix_to_virt(FIX_GNTTAB_END);
   1.104 -#endif
   1.105 -
   1.106  	for (i = NR_RESERVED_ENTRIES; i < NR_GRANT_ENTRIES; i++)
   1.107  		gnttab_list[i] = i + 1;
   1.108  	gnttab_free_count = NR_GRANT_ENTRIES - NR_RESERVED_ENTRIES;
     2.1 --- a/linux-2.6-xen-sparse/include/asm-i386/mach-xen/asm/fixmap.h	Fri Mar 10 11:05:59 2006 +0100
     2.2 +++ b/linux-2.6-xen-sparse/include/asm-i386/mach-xen/asm/fixmap.h	Fri Mar 10 13:27:24 2006 +0000
     2.3 @@ -84,8 +84,6 @@ enum fixed_addresses {
     2.4  	FIX_PCIE_MCFG,
     2.5  #endif
     2.6  	FIX_SHARED_INFO,
     2.7 -	FIX_GNTTAB_BEGIN,
     2.8 -	FIX_GNTTAB_END = FIX_GNTTAB_BEGIN + NR_GRANT_FRAMES - 1,
     2.9  #define NR_FIX_ISAMAPS	256
    2.10  	FIX_ISAMAP_END,
    2.11  	FIX_ISAMAP_BEGIN = FIX_ISAMAP_END + NR_FIX_ISAMAPS - 1,
     3.1 --- a/linux-2.6-xen-sparse/include/asm-x86_64/mach-xen/asm/fixmap.h	Fri Mar 10 11:05:59 2006 +0100
     3.2 +++ b/linux-2.6-xen-sparse/include/asm-x86_64/mach-xen/asm/fixmap.h	Fri Mar 10 13:27:24 2006 +0000
     3.3 @@ -52,8 +52,6 @@ enum fixed_addresses {
     3.4  	FIX_ACPI_END = FIX_ACPI_BEGIN + FIX_ACPI_PAGES - 1,
     3.5  #endif
     3.6  	FIX_SHARED_INFO,
     3.7 -	FIX_GNTTAB_BEGIN,
     3.8 -	FIX_GNTTAB_END = FIX_GNTTAB_BEGIN + NR_GRANT_FRAMES - 1,
     3.9  #define NR_FIX_ISAMAPS	256
    3.10  	FIX_ISAMAP_END,
    3.11  	FIX_ISAMAP_BEGIN = FIX_ISAMAP_END + NR_FIX_ISAMAPS - 1,