direct-io.hg

changeset 12271:f56b7ade7068

[BLKTAP] ia64 support
Signed-off-by: Isaku Yamahata <yamahata@valinux.co.jp>
author kfraser@localhost.localdomain
date Tue Nov 07 11:17:39 2006 +0000 (2006-11-07)
parents 3cc7e419b949
children e796d9c2f5e8
files linux-2.6-xen-sparse/drivers/xen/blktap/blktap.c linux-2.6-xen-sparse/include/asm-ia64/hypervisor.h tools/libxc/xenctrl.h
line diff
     1.1 --- a/linux-2.6-xen-sparse/drivers/xen/blktap/blktap.c	Tue Nov 07 11:14:52 2006 +0000
     1.2 +++ b/linux-2.6-xen-sparse/drivers/xen/blktap/blktap.c	Tue Nov 07 11:17:39 2006 +0000
     1.3 @@ -887,6 +887,15 @@ static void fast_flush_area(pending_req_
     1.4  		return;
     1.5  	}
     1.6  
     1.7 +	if (info->vma != NULL &&
     1.8 +	    xen_feature(XENFEAT_auto_translated_physmap)) {
     1.9 +		down_write(&info->vma->vm_mm->mmap_sem);
    1.10 +		zap_page_range(info->vma, 
    1.11 +			       MMAP_VADDR(info->user_vstart, u_idx, 0), 
    1.12 +			       req->nr_pages << PAGE_SHIFT, NULL);
    1.13 +		up_write(&info->vma->vm_mm->mmap_sem);
    1.14 +	}
    1.15 +
    1.16  	mmap_idx = req->mem_idx;
    1.17  
    1.18  	for (i = 0; i < req->nr_pages; i++) {
    1.19 @@ -903,6 +912,7 @@ static void fast_flush_area(pending_req_
    1.20  		}
    1.21  
    1.22  		if (khandle->user != INVALID_GRANT_HANDLE) {
    1.23 +			BUG_ON(xen_feature(XENFEAT_auto_translated_physmap));
    1.24  			if (create_lookup_pte_addr(
    1.25  				info->vma->vm_mm,
    1.26  				MMAP_VADDR(info->user_vstart, u_idx, i),
    1.27 @@ -925,7 +935,7 @@ static void fast_flush_area(pending_req_
    1.28  		GNTTABOP_unmap_grant_ref, unmap, invcount);
    1.29  	BUG_ON(ret);
    1.30  	
    1.31 -	if (info->vma != NULL)
    1.32 +	if (info->vma != NULL && !xen_feature(XENFEAT_auto_translated_physmap))
    1.33  		zap_page_range(info->vma, 
    1.34  			       MMAP_VADDR(info->user_vstart, u_idx, 0), 
    1.35  			       req->nr_pages << PAGE_SHIFT, NULL);
    1.36 @@ -1254,68 +1264,103 @@ static void dispatch_rw_block_io(blkif_t
    1.37  				  req->seg[i].gref, blkif->domid);
    1.38  		op++;
    1.39  
    1.40 -		/* Now map it to user. */
    1.41 -		ret = create_lookup_pte_addr(info->vma->vm_mm, 
    1.42 -					     uvaddr, &ptep);
    1.43 -		if (ret) {
    1.44 -			WPRINTK("Couldn't get a pte addr!\n");
    1.45 -			goto fail_flush;
    1.46 -		}
    1.47 +		if (!xen_feature(XENFEAT_auto_translated_physmap)) {
    1.48 +			/* Now map it to user. */
    1.49 +			ret = create_lookup_pte_addr(info->vma->vm_mm, 
    1.50 +						     uvaddr, &ptep);
    1.51 +			if (ret) {
    1.52 +				WPRINTK("Couldn't get a pte addr!\n");
    1.53 +				goto fail_flush;
    1.54 +			}
    1.55  
    1.56 -		flags = GNTMAP_host_map | GNTMAP_application_map
    1.57 -			| GNTMAP_contains_pte;
    1.58 -		if (operation == WRITE)
    1.59 -			flags |= GNTMAP_readonly;
    1.60 -		gnttab_set_map_op(&map[op], ptep, flags,
    1.61 -				  req->seg[i].gref, blkif->domid);
    1.62 -		op++;
    1.63 +			flags = GNTMAP_host_map | GNTMAP_application_map
    1.64 +				| GNTMAP_contains_pte;
    1.65 +			if (operation == WRITE)
    1.66 +				flags |= GNTMAP_readonly;
    1.67 +			gnttab_set_map_op(&map[op], ptep, flags,
    1.68 +					  req->seg[i].gref, blkif->domid);
    1.69 +			op++;
    1.70 +		}
    1.71  	}
    1.72  
    1.73  	ret = HYPERVISOR_grant_table_op(GNTTABOP_map_grant_ref, map, op);
    1.74  	BUG_ON(ret);
    1.75  
    1.76 -	for (i = 0; i < (nseg*2); i+=2) {
    1.77 -		unsigned long uvaddr;
    1.78 -		unsigned long kvaddr;
    1.79 -		unsigned long offset;
    1.80 -		struct page *pg;
    1.81 +	if (!xen_feature(XENFEAT_auto_translated_physmap)) {
    1.82 +		for (i = 0; i < (nseg*2); i+=2) {
    1.83 +			unsigned long uvaddr;
    1.84 +			unsigned long kvaddr;
    1.85 +			unsigned long offset;
    1.86 +			struct page *pg;
    1.87 +
    1.88 +			uvaddr = MMAP_VADDR(info->user_vstart, usr_idx, i/2);
    1.89 +			kvaddr = idx_to_kaddr(mmap_idx, pending_idx, i/2);
    1.90  
    1.91 -		uvaddr = MMAP_VADDR(info->user_vstart, usr_idx, i/2);
    1.92 -		kvaddr = idx_to_kaddr(mmap_idx, pending_idx, i/2);
    1.93 +			if (unlikely(map[i].status != 0)) {
    1.94 +				WPRINTK("invalid kernel buffer -- "
    1.95 +					"could not remap it\n");
    1.96 +				ret |= 1;
    1.97 +				map[i].handle = INVALID_GRANT_HANDLE;
    1.98 +			}
    1.99  
   1.100 -		if (unlikely(map[i].status != 0)) {
   1.101 -			WPRINTK("invalid kernel buffer -- "
   1.102 -				"could not remap it\n");
   1.103 -			ret |= 1;
   1.104 -			map[i].handle = INVALID_GRANT_HANDLE;
   1.105 -		}
   1.106 +			if (unlikely(map[i+1].status != 0)) {
   1.107 +				WPRINTK("invalid user buffer -- "
   1.108 +					"could not remap it\n");
   1.109 +				ret |= 1;
   1.110 +				map[i+1].handle = INVALID_GRANT_HANDLE;
   1.111 +			}
   1.112 +
   1.113 +			pending_handle(mmap_idx, pending_idx, i/2).kernel 
   1.114 +				= map[i].handle;
   1.115 +			pending_handle(mmap_idx, pending_idx, i/2).user   
   1.116 +				= map[i+1].handle;
   1.117 +
   1.118 +			if (ret)
   1.119 +				continue;
   1.120  
   1.121 -		if (unlikely(map[i+1].status != 0)) {
   1.122 -			WPRINTK("invalid user buffer -- "
   1.123 -				"could not remap it\n");
   1.124 -			ret |= 1;
   1.125 -			map[i+1].handle = INVALID_GRANT_HANDLE;
   1.126 +			set_phys_to_machine(__pa(kvaddr) >> PAGE_SHIFT,
   1.127 +					    FOREIGN_FRAME(map[i].dev_bus_addr
   1.128 +							  >> PAGE_SHIFT));
   1.129 +			offset = (uvaddr - info->vma->vm_start) >> PAGE_SHIFT;
   1.130 +			pg = pfn_to_page(__pa(kvaddr) >> PAGE_SHIFT);
   1.131 +			((struct page **)info->vma->vm_private_data)[offset] =
   1.132 +				pg;
   1.133  		}
   1.134 +	} else {
   1.135 +		for (i = 0; i < nseg; i++) {
   1.136 +			unsigned long uvaddr;
   1.137 +			unsigned long kvaddr;
   1.138 +			unsigned long offset;
   1.139 +			struct page *pg;
   1.140 +
   1.141 +			uvaddr = MMAP_VADDR(info->user_vstart, usr_idx, i);
   1.142 +			kvaddr = idx_to_kaddr(mmap_idx, pending_idx, i);
   1.143  
   1.144 -		pending_handle(mmap_idx, pending_idx, i/2).kernel 
   1.145 -			= map[i].handle;
   1.146 -		pending_handle(mmap_idx, pending_idx, i/2).user   
   1.147 -			= map[i+1].handle;
   1.148 +			if (unlikely(map[i].status != 0)) {
   1.149 +				WPRINTK("invalid kernel buffer -- "
   1.150 +					"could not remap it\n");
   1.151 +				ret |= 1;
   1.152 +				map[i].handle = INVALID_GRANT_HANDLE;
   1.153 +			}
   1.154  
   1.155 -		if (ret)
   1.156 -			continue;
   1.157 +			pending_handle(mmap_idx, pending_idx, i).kernel 
   1.158 +				= map[i].handle;
   1.159 +
   1.160 +			if (ret)
   1.161 +				continue;
   1.162  
   1.163 -		set_phys_to_machine(__pa(kvaddr) >> PAGE_SHIFT,
   1.164 -			FOREIGN_FRAME(map[i].dev_bus_addr >> PAGE_SHIFT));
   1.165 -		offset = (uvaddr - info->vma->vm_start) >> PAGE_SHIFT;
   1.166 -		pg = pfn_to_page(__pa(kvaddr) >> PAGE_SHIFT);
   1.167 -		((struct page **)info->vma->vm_private_data)[offset] =
   1.168 -			pg;
   1.169 +			offset = (uvaddr - info->vma->vm_start) >> PAGE_SHIFT;
   1.170 +			pg = pfn_to_page(__pa(kvaddr) >> PAGE_SHIFT);
   1.171 +			((struct page **)info->vma->vm_private_data)[offset] =
   1.172 +				pg;
   1.173 +		}
   1.174  	}
   1.175  
   1.176  	if (ret)
   1.177  		goto fail_flush;
   1.178  
   1.179 +	if (xen_feature(XENFEAT_auto_translated_physmap))
   1.180 +		down_write(&info->vma->vm_mm->mmap_sem);
   1.181  	/* Mark mapped pages as reserved: */
   1.182  	for (i = 0; i < req->nr_segments; i++) {
   1.183  		unsigned long kvaddr;
   1.184 @@ -1324,7 +1369,18 @@ static void dispatch_rw_block_io(blkif_t
   1.185  		kvaddr = idx_to_kaddr(mmap_idx, pending_idx, i);
   1.186  		pg = pfn_to_page(__pa(kvaddr) >> PAGE_SHIFT);
   1.187  		SetPageReserved(pg);
   1.188 +		if (xen_feature(XENFEAT_auto_translated_physmap)) {
   1.189 +			ret = vm_insert_page(info->vma,
   1.190 +					     MMAP_VADDR(info->user_vstart,
   1.191 +							usr_idx, i), pg);
   1.192 +			if (ret) {
   1.193 +				up_write(&info->vma->vm_mm->mmap_sem);
   1.194 +				goto fail_flush;
   1.195 +			}
   1.196 +		}
   1.197  	}
   1.198 +	if (xen_feature(XENFEAT_auto_translated_physmap))
   1.199 +		up_write(&info->vma->vm_mm->mmap_sem);
   1.200  	
   1.201  	/*record [mmap_idx,pending_idx] to [usr_idx] mapping*/
   1.202  	info->idx_map[usr_idx] = MAKE_ID(mmap_idx, pending_idx);
     2.1 --- a/linux-2.6-xen-sparse/include/asm-ia64/hypervisor.h	Tue Nov 07 11:14:52 2006 +0000
     2.2 +++ b/linux-2.6-xen-sparse/include/asm-ia64/hypervisor.h	Tue Nov 07 11:17:39 2006 +0000
     2.3 @@ -191,6 +191,22 @@ MULTI_grant_table_op(multicall_entry_t *
     2.4  	mcl->args[2] = count;
     2.5  }
     2.6  
     2.7 +/*
     2.8 + * for blktap.c
     2.9 + * int create_lookup_pte_addr(struct mm_struct *mm, 
    2.10 + *                            unsigned long address,
    2.11 + *                            uint64_t *ptep);
    2.12 + */
    2.13 +#define create_lookup_pte_addr(mm, address, ptep)			\
    2.14 +	({								\
    2.15 +		printk(KERN_EMERG					\
    2.16 +		       "%s:%d "						\
    2.17 +		       "create_lookup_pte_addr() isn't supported.\n",	\
    2.18 +		       __func__, __LINE__);				\
    2.19 +		BUG();							\
    2.20 +		(-ENOSYS);						\
    2.21 +	})
    2.22 +
    2.23  // for debug
    2.24  asmlinkage int xprintk(const char *fmt, ...);
    2.25  #define xprintd(fmt, ...)	xprintk("%s:%d " fmt, __func__, __LINE__, \
     3.1 --- a/tools/libxc/xenctrl.h	Tue Nov 07 11:14:52 2006 +0000
     3.2 +++ b/tools/libxc/xenctrl.h	Tue Nov 07 11:17:39 2006 +0000
     3.3 @@ -47,10 +47,9 @@
     3.4  #define rmb() __asm__ __volatile__ ( "lfence" : : : "memory")
     3.5  #define wmb() __asm__ __volatile__ ( "" : : : "memory")
     3.6  #elif defined(__ia64__)
     3.7 -/* FIXME */
     3.8 -#define mb()
     3.9 -#define rmb()
    3.10 -#define wmb()
    3.11 +#define mb()   __asm__ __volatile__ ("mf" ::: "memory")
    3.12 +#define rmb()  __asm__ __volatile__ ("mf" ::: "memory")
    3.13 +#define wmb()  __asm__ __volatile__ ("mf" ::: "memory")
    3.14  #elif defined(__powerpc__)
    3.15  /* XXX loosen these up later */
    3.16  #define mb()   __asm__ __volatile__ ("sync" : : : "memory")