@@ -73,9 +73,6 @@ module_param(limit, uint, 0644);
7373MODULE_PARM_DESC (limit ,
7474 "Maximum number of grants that may be mapped by one mapping request" );
7575
76- /* True in PV mode, false otherwise */
77- static int use_ptemod ;
78-
7976static void unmap_grant_pages (struct gntdev_grant_map * map ,
8077 int offset , int pages );
8178
@@ -163,7 +160,7 @@ struct gntdev_grant_map *gntdev_alloc_map(struct gntdev_priv *priv, int count,
163160 NULL == add -> pages ||
164161 NULL == add -> being_removed )
165162 goto err ;
166- if (use_ptemod ) {
163+ if (xen_pv_domain () ) {
167164 add -> kmap_ops = kvmalloc_array (count , sizeof (add -> kmap_ops [0 ]),
168165 GFP_KERNEL );
169166 add -> kunmap_ops = kvmalloc_array (count , sizeof (add -> kunmap_ops [0 ]),
@@ -211,7 +208,7 @@ struct gntdev_grant_map *gntdev_alloc_map(struct gntdev_priv *priv, int count,
211208 add -> grants [i ].ref = INVALID_GRANT_REF ;
212209 add -> map_ops [i ].handle = INVALID_GRANT_HANDLE ;
213210 add -> unmap_ops [i ].handle = INVALID_GRANT_HANDLE ;
214- if (use_ptemod ) {
211+ if (xen_pv_domain () ) {
215212 add -> kmap_ops [i ].handle = INVALID_GRANT_HANDLE ;
216213 add -> kunmap_ops [i ].handle = INVALID_GRANT_HANDLE ;
217214 }
@@ -268,7 +265,7 @@ void gntdev_put_map(struct gntdev_priv *priv, struct gntdev_grant_map *map)
268265 if (!refcount_dec_and_test (& map -> users ))
269266 return ;
270267
271- if (map -> pages && !use_ptemod ) {
268+ if (map -> pages && !xen_pv_domain () ) {
272269 /*
273270 * Increment the reference count. This ensures that the
274271 * subsequent call to unmap_grant_pages() will not wind up
@@ -298,7 +295,7 @@ void gntdev_put_map(struct gntdev_priv *priv, struct gntdev_grant_map *map)
298295 */
299296 }
300297
301- if (use_ptemod && map -> notifier_init )
298+ if (xen_pv_domain () && map -> notifier_init )
302299 mmu_interval_notifier_remove (& map -> notifier );
303300
304301 if (map -> notify .flags & UNMAP_NOTIFY_SEND_EVENT ) {
@@ -334,7 +331,7 @@ int gntdev_map_grant_pages(struct gntdev_grant_map *map)
334331 size_t alloced = 0 ;
335332 int i , err = 0 ;
336333
337- if (!use_ptemod ) {
334+ if (!xen_pv_domain () ) {
338335 /* Note: it could already be mapped */
339336 if (map -> map_ops [0 ].handle != INVALID_GRANT_HANDLE )
340337 return 0 ;
@@ -389,7 +386,7 @@ int gntdev_map_grant_pages(struct gntdev_grant_map *map)
389386 if (map -> flags & GNTMAP_device_map )
390387 map -> unmap_ops [i ].dev_bus_addr = map -> map_ops [i ].dev_bus_addr ;
391388
392- if (use_ptemod ) {
389+ if (xen_pv_domain () ) {
393390 if (map -> kmap_ops [i ].status == GNTST_okay ) {
394391 alloced ++ ;
395392 map -> kunmap_ops [i ].handle = map -> kmap_ops [i ].handle ;
@@ -421,7 +418,7 @@ static void __unmap_grant_pages_done(int result,
421418 map -> unmap_ops [offset + i ].handle ,
422419 map -> unmap_ops [offset + i ].status );
423420 map -> unmap_ops [offset + i ].handle = INVALID_GRANT_HANDLE ;
424- if (use_ptemod ) {
421+ if (xen_pv_domain () ) {
425422 if (map -> kunmap_ops [offset + i ].status == GNTST_okay &&
426423 map -> kunmap_ops [offset + i ].handle != INVALID_GRANT_HANDLE )
427424 successful_unmaps ++ ;
@@ -464,7 +461,7 @@ static void __unmap_grant_pages(struct gntdev_grant_map *map, int offset,
464461 }
465462
466463 map -> unmap_data .unmap_ops = map -> unmap_ops + offset ;
467- map -> unmap_data .kunmap_ops = use_ptemod ? map -> kunmap_ops + offset : NULL ;
464+ map -> unmap_data .kunmap_ops = xen_pv_domain () ? map -> kunmap_ops + offset : NULL ;
468465 map -> unmap_data .pages = map -> pages + offset ;
469466 map -> unmap_data .count = pages ;
470467 map -> unmap_data .done = __unmap_grant_pages_done ;
@@ -1039,7 +1036,7 @@ static long gntdev_ioctl(struct file *flip,
10391036
10401037#ifdef CONFIG_XEN_GNTDEV_DMABUF
10411038 case IOCTL_GNTDEV_DMABUF_EXP_FROM_REFS :
1042- return gntdev_ioctl_dmabuf_exp_from_refs (priv , use_ptemod , ptr );
1039+ return gntdev_ioctl_dmabuf_exp_from_refs (priv , ptr );
10431040
10441041 case IOCTL_GNTDEV_DMABUF_EXP_WAIT_RELEASED :
10451042 return gntdev_ioctl_dmabuf_exp_wait_released (priv , ptr );
@@ -1086,7 +1083,7 @@ static int gntdev_mmap(struct file *flip, struct vm_area_struct *vma)
10861083
10871084 vm_flags_set (vma , VM_DONTEXPAND | VM_DONTDUMP | VM_MIXEDMAP );
10881085
1089- if (use_ptemod )
1086+ if (xen_pv_domain () )
10901087 vm_flags_set (vma , VM_DONTCOPY );
10911088
10921089 vma -> vm_private_data = map ;
@@ -1102,7 +1099,7 @@ static int gntdev_mmap(struct file *flip, struct vm_area_struct *vma)
11021099
11031100 map -> pages_vm_start = vma -> vm_start ;
11041101
1105- if (use_ptemod ) {
1102+ if (xen_pv_domain () ) {
11061103 err = mmu_interval_notifier_insert_locked (
11071104 & map -> notifier , vma -> vm_mm , vma -> vm_start ,
11081105 vma -> vm_end - vma -> vm_start , & gntdev_mmu_ops );
@@ -1113,7 +1110,7 @@ static int gntdev_mmap(struct file *flip, struct vm_area_struct *vma)
11131110 }
11141111 mutex_unlock (& priv -> lock );
11151112
1116- if (use_ptemod ) {
1113+ if (xen_pv_domain () ) {
11171114 /*
11181115 * gntdev takes the address of the PTE in find_grant_ptes() and
11191116 * passes it to the hypervisor in gntdev_map_grant_pages(). The
@@ -1139,7 +1136,7 @@ static int gntdev_mmap(struct file *flip, struct vm_area_struct *vma)
11391136 if (err )
11401137 goto out_put_map ;
11411138
1142- if (!use_ptemod ) {
1139+ if (!xen_pv_domain () ) {
11431140 err = vm_map_pages_zero (vma , map -> pages , map -> count );
11441141 if (err )
11451142 goto out_put_map ;
@@ -1154,7 +1151,7 @@ static int gntdev_mmap(struct file *flip, struct vm_area_struct *vma)
11541151out_unlock_put :
11551152 mutex_unlock (& priv -> lock );
11561153out_put_map :
1157- if (use_ptemod )
1154+ if (xen_pv_domain () )
11581155 unmap_grant_pages (map , 0 , map -> count );
11591156 gntdev_put_map (priv , map );
11601157 return err ;
@@ -1183,8 +1180,6 @@ static int __init gntdev_init(void)
11831180 if (!xen_domain ())
11841181 return - ENODEV ;
11851182
1186- use_ptemod = xen_pv_domain ();
1187-
11881183 err = misc_register (& gntdev_miscdev );
11891184 if (err != 0 ) {
11901185 pr_err ("Could not register gntdev device\n" );
0 commit comments