ia64/xen-unstable

changeset 7166:f22fba673196

Dynamically allocate mmu_update array in
direct_remap_pfn_range(). This allows larger batches and
avoids stack overflow.

Signed-off-by: Keir Fraser <keir@xensource.com>
author kaf24@firebug.cl.cam.ac.uk
date Mon Oct 03 10:26:29 2005 +0100 (2005-10-03)
parents bb03b43404bb
children bf6119a58655
files linux-2.6-xen-sparse/arch/xen/i386/mm/ioremap.c
line diff
     1.1 --- a/linux-2.6-xen-sparse/arch/xen/i386/mm/ioremap.c	Sun Oct 02 23:56:13 2005 +0100
     1.2 +++ b/linux-2.6-xen-sparse/arch/xen/i386/mm/ioremap.c	Mon Oct 03 10:26:29 2005 +0100
     1.3 @@ -52,24 +52,30 @@ static int __direct_remap_pfn_range(stru
     1.4  				    pgprot_t prot,
     1.5  				    domid_t  domid)
     1.6  {
     1.7 -	int i;
     1.8 +	int i, rc;
     1.9  	unsigned long start_address;
    1.10 -#define MAX_DIRECTMAP_MMU_QUEUE 130
    1.11 -	mmu_update_t u[MAX_DIRECTMAP_MMU_QUEUE], *v = u, *w = u;
    1.12 +	mmu_update_t *u, *v, *w;
    1.13 +
    1.14 +	u = v = w = (mmu_update_t *)__get_free_page(GFP_KERNEL|__GFP_REPEAT);
    1.15 +	if (u == NULL)
    1.16 +		return -ENOMEM;
    1.17  
    1.18  	start_address = address;
    1.19  
    1.20  	flush_cache_all();
    1.21  
    1.22  	for (i = 0; i < size; i += PAGE_SIZE) {
    1.23 -		if ((v - u) == MAX_DIRECTMAP_MMU_QUEUE) {
    1.24 +		if ((v - u) == (PAGE_SIZE / sizeof(mmu_update_t))) {
    1.25  			/* Fill in the PTE pointers. */
    1.26 -			generic_page_range(mm, start_address, 
    1.27 -					   address - start_address,
    1.28 -					   direct_remap_area_pte_fn, &w);
    1.29 +			rc = generic_page_range(mm, start_address, 
    1.30 +						address - start_address,
    1.31 +						direct_remap_area_pte_fn, &w);
    1.32 +			if (rc)
    1.33 +				goto out;
    1.34  			w = u;
    1.35 +			rc = -EFAULT;
    1.36  			if (HYPERVISOR_mmu_update(u, v - u, NULL, domid) < 0)
    1.37 -				return -EFAULT;
    1.38 +				goto out;
    1.39  			v = u;
    1.40  			start_address = address;
    1.41  		}
    1.42 @@ -89,13 +95,19 @@ static int __direct_remap_pfn_range(stru
    1.43  		/* get the ptep's filled in */
    1.44  		generic_page_range(mm, start_address, address - start_address,
    1.45  				   direct_remap_area_pte_fn, &w);
    1.46 +		rc = -EFAULT;
    1.47  		if (unlikely(HYPERVISOR_mmu_update(u, v - u, NULL, domid) < 0))
    1.48 -			return -EFAULT;
    1.49 +			goto out;
    1.50  	}
    1.51  
    1.52 +	rc = 0;
    1.53 +
    1.54 + out:
    1.55  	flush_tlb_all();
    1.56  
    1.57 -	return 0;
    1.58 +	free_page((unsigned long)u);
    1.59 +
    1.60 +	return rc;
    1.61  }
    1.62  
    1.63  int direct_remap_pfn_range(struct vm_area_struct *vma,