direct-io.hg

changeset 11392:6f41473da163

[LINUX] Remove vm_map_xen_pages(), clean up __direct_remap_page_range.
Signed-off-by: Keir Fraser <keir@xensource.com>
author kaf24@firebug.cl.cam.ac.uk
date Thu Aug 31 18:23:28 2006 +0100 (2006-08-31)
parents 2017f6e92bf8
children fd6c2b5e041f
files linux-2.6-xen-sparse/arch/i386/mm/ioremap-xen.c linux-2.6-xen-sparse/arch/i386/oprofile/xenoprof.c
line diff
     1.1 --- a/linux-2.6-xen-sparse/arch/i386/mm/ioremap-xen.c	Thu Aug 31 14:46:28 2006 +0100
     1.2 +++ b/linux-2.6-xen-sparse/arch/i386/mm/ioremap-xen.c	Thu Aug 31 18:23:28 2006 +0100
     1.3 @@ -22,15 +22,6 @@
     1.4  #define ISA_START_ADDRESS	0x0
     1.5  #define ISA_END_ADDRESS		0x100000
     1.6  
     1.7 -#if 0 /* not PAE safe */
     1.8 -/* These hacky macros avoid phys->machine translations. */
     1.9 -#define __direct_pte(x) ((pte_t) { (x) } )
    1.10 -#define __direct_mk_pte(page_nr,pgprot) \
    1.11 -  __direct_pte(((page_nr) << PAGE_SHIFT) | pgprot_val(pgprot))
    1.12 -#define direct_mk_pte_phys(physpage, pgprot) \
    1.13 -  __direct_mk_pte((physpage) >> PAGE_SHIFT, pgprot)
    1.14 -#endif
    1.15 -
    1.16  static int direct_remap_area_pte_fn(pte_t *pte, 
    1.17  				    struct page *pmd_page,
    1.18  				    unsigned long address, 
    1.19 @@ -66,17 +57,16 @@ static int __direct_remap_pfn_range(stru
    1.20  
    1.21  	for (i = 0; i < size; i += PAGE_SIZE) {
    1.22  		if ((v - u) == (PAGE_SIZE / sizeof(mmu_update_t))) {
    1.23 -			/* Fill in the PTE pointers. */
    1.24 +			/* Flush a full batch after filling in the PTE ptrs. */
    1.25  			rc = apply_to_page_range(mm, start_address, 
    1.26  						 address - start_address,
    1.27  						 direct_remap_area_pte_fn, &w);
    1.28  			if (rc)
    1.29  				goto out;
    1.30 -			w = u;
    1.31  			rc = -EFAULT;
    1.32  			if (HYPERVISOR_mmu_update(u, v - u, NULL, domid) < 0)
    1.33  				goto out;
    1.34 -			v = u;
    1.35 +			v = w = u;
    1.36  			start_address = address;
    1.37  		}
    1.38  
    1.39 @@ -92,7 +82,7 @@ static int __direct_remap_pfn_range(stru
    1.40  	}
    1.41  
    1.42  	if (v != u) {
    1.43 -		/* get the ptep's filled in */
    1.44 +		/* Final batch. */
    1.45  		rc = apply_to_page_range(mm, start_address,
    1.46  					 address - start_address,
    1.47  					 direct_remap_area_pte_fn, &w);
    1.48 @@ -179,32 +169,6 @@ int touch_pte_range(struct mm_struct *mm
    1.49  
    1.50  EXPORT_SYMBOL(touch_pte_range);
    1.51  
    1.52 -void *vm_map_xen_pages (unsigned long maddr, int vm_size, pgprot_t prot)
    1.53 -{
    1.54 -	int error;
    1.55 -       
    1.56 -	struct vm_struct *vma;
    1.57 -	vma = get_vm_area (vm_size, VM_IOREMAP);
    1.58 -      
    1.59 -	if (vma == NULL) {
    1.60 -		printk ("ioremap.c,vm_map_xen_pages(): "
    1.61 -			"Failed to get VMA area\n");
    1.62 -		return NULL;
    1.63 -	}
    1.64 -
    1.65 -	error = direct_kernel_remap_pfn_range((unsigned long) vma->addr,
    1.66 -					      maddr >> PAGE_SHIFT, vm_size,
    1.67 -					      prot, DOMID_SELF );
    1.68 -	if (error == 0) {
    1.69 -		return vma->addr;
    1.70 -	} else {
    1.71 -		printk ("ioremap.c,vm_map_xen_pages(): "
    1.72 -			"Failed to map xen shared pages into kernel space\n");
    1.73 -		return NULL;
    1.74 -	}
    1.75 -}
    1.76 -EXPORT_SYMBOL(vm_map_xen_pages);
    1.77 -
    1.78  /*
    1.79   * Does @address reside within a non-highmem page that is local to this virtual
    1.80   * machine (i.e., not an I/O page, nor a memory page belonging to another VM).
     2.1 --- a/linux-2.6-xen-sparse/arch/i386/oprofile/xenoprof.c	Thu Aug 31 14:46:28 2006 +0100
     2.2 +++ b/linux-2.6-xen-sparse/arch/i386/oprofile/xenoprof.c	Thu Aug 31 18:23:28 2006 +0100
     2.3 @@ -34,8 +34,6 @@
     2.4  static int xenoprof_start(void);
     2.5  static void xenoprof_stop(void);
     2.6  
     2.7 -void * vm_map_xen_pages(unsigned long maddr, int vm_size, pgprot_t prot);
     2.8 -
     2.9  static int xenoprof_enabled = 0;
    2.10  static unsigned int num_events = 0;
    2.11  static int is_primary = 0;
    2.12 @@ -373,9 +371,9 @@ static int xenoprof_set_passive(int * p_
    2.13  {
    2.14  	int ret;
    2.15  	int i, j;
    2.16 -	int vm_size;
    2.17  	int npages;
    2.18  	struct xenoprof_buf *buf;
    2.19 +	struct vm_struct *area;
    2.20  	pgprot_t prot = __pgprot(_KERNPG_TABLE);
    2.21  
    2.22  	if (!is_primary)
    2.23 @@ -391,20 +389,30 @@ static int xenoprof_set_passive(int * p_
    2.24  	for (i = 0; i < pdoms; i++) {
    2.25  		passive_domains[i].domain_id = p_domains[i];
    2.26  		passive_domains[i].max_samples = 2048;
    2.27 -		ret = HYPERVISOR_xenoprof_op(XENOPROF_set_passive, &passive_domains[i]);
    2.28 +		ret = HYPERVISOR_xenoprof_op(XENOPROF_set_passive,
    2.29 +					     &passive_domains[i]);
    2.30  		if (ret)
    2.31 -			return ret;
    2.32 +			goto out;
    2.33  
    2.34  		npages = (passive_domains[i].bufsize * passive_domains[i].nbuf - 1) / PAGE_SIZE + 1;
    2.35 -		vm_size = npages * PAGE_SIZE;
    2.36  
    2.37 -		p_shared_buffer[i] = (char *)vm_map_xen_pages(passive_domains[i].buf_maddr,
    2.38 -							      vm_size, prot);
    2.39 -		if (!p_shared_buffer[i]) {
    2.40 +		area = get_vm_area(npages * PAGE_SIZE, VM_IOREMAP);
    2.41 +		if (area == NULL) {
    2.42  			ret = -ENOMEM;
    2.43  			goto out;
    2.44  		}
    2.45  
    2.46 +		ret = direct_kernel_remap_pfn_range(
    2.47 +			(unsigned long)area->addr,
    2.48 +			passive_domains[i].buf_maddr >> PAGE_SHIFT,
    2.49 +			npages * PAGE_SIZE, prot, DOMID_SELF);
    2.50 +		if (ret) {
    2.51 +			vunmap(area->addr);
    2.52 +			goto out;
    2.53 +		}
    2.54 +
    2.55 +		p_shared_buffer[i] = area->addr;
    2.56 +
    2.57  		for (j = 0; j < passive_domains[i].nbuf; j++) {
    2.58  			buf = (struct xenoprof_buf *)
    2.59  				&p_shared_buffer[i][j * passive_domains[i].bufsize];
    2.60 @@ -473,11 +481,9 @@ static int using_xenoprof;
    2.61  int __init oprofile_arch_init(struct oprofile_operations * ops)
    2.62  {
    2.63  	struct xenoprof_init init;
    2.64 -	struct xenoprof_buf * buf;
    2.65 -	int vm_size;
    2.66 -	int npages;
    2.67 -	int ret;
    2.68 -	int i;
    2.69 +	struct xenoprof_buf *buf;
    2.70 +	int npages, ret, i;
    2.71 +	struct vm_struct *area;
    2.72  
    2.73  	init.max_samples = 16;
    2.74  	ret = HYPERVISOR_xenoprof_op(XENOPROF_init, &init);
    2.75 @@ -495,15 +501,24 @@ int __init oprofile_arch_init(struct opr
    2.76  			num_events = OP_MAX_COUNTER;
    2.77  
    2.78  		npages = (init.bufsize * nbuf - 1) / PAGE_SIZE + 1;
    2.79 -		vm_size = npages * PAGE_SIZE;
    2.80  
    2.81 -		shared_buffer = (char *)vm_map_xen_pages(init.buf_maddr,
    2.82 -							 vm_size, prot);
    2.83 -		if (!shared_buffer) {
    2.84 +		area = get_vm_area(npages * PAGE_SIZE, VM_IOREMAP);
    2.85 +		if (area == NULL) {
    2.86  			ret = -ENOMEM;
    2.87  			goto out;
    2.88  		}
    2.89  
    2.90 +		ret = direct_kernel_remap_pfn_range(
    2.91 +			(unsigned long)area->addr,
    2.92 +			init.buf_maddr >> PAGE_SHIFT,
    2.93 +			npages * PAGE_SIZE, prot, DOMID_SELF);
    2.94 +		if (ret) {
    2.95 +			vunmap(area->addr);
    2.96 +			goto out;
    2.97 +		}
    2.98 +
    2.99 +		shared_buffer = area->addr;
   2.100 +
   2.101  		for (i=0; i< nbuf; i++) {
   2.102  			buf = (struct xenoprof_buf*) 
   2.103  				&shared_buffer[i * init.bufsize];