aboutsummaryrefslogtreecommitdiffstats
path: root/drivers
diff options
context:
space:
mode:
Diffstat (limited to 'drivers')
-rw-r--r--drivers/gpu/drm/vmwgfx/vmwgfx_context.c5
-rw-r--r--drivers/gpu/drm/vmwgfx/vmwgfx_dmabuf.c15
-rw-r--r--drivers/gpu/drm/vmwgfx/vmwgfx_drv.c6
-rw-r--r--drivers/gpu/drm/vmwgfx/vmwgfx_drv.h5
-rw-r--r--drivers/gpu/drm/vmwgfx/vmwgfx_execbuf.c5
-rw-r--r--drivers/gpu/drm/vmwgfx/vmwgfx_fb.c9
-rw-r--r--drivers/gpu/drm/vmwgfx/vmwgfx_ioctl.c10
-rw-r--r--drivers/gpu/drm/vmwgfx/vmwgfx_kms.c15
-rw-r--r--drivers/gpu/drm/vmwgfx/vmwgfx_resource.c15
-rw-r--r--drivers/gpu/drm/vmwgfx/vmwgfx_shader.c5
-rw-r--r--drivers/gpu/drm/vmwgfx/vmwgfx_surface.c14
11 files changed, 46 insertions, 58 deletions
diff --git a/drivers/gpu/drm/vmwgfx/vmwgfx_context.c b/drivers/gpu/drm/vmwgfx/vmwgfx_context.c
index 1e80152674b5..701d5207def6 100644
--- a/drivers/gpu/drm/vmwgfx/vmwgfx_context.c
+++ b/drivers/gpu/drm/vmwgfx/vmwgfx_context.c
@@ -462,7 +462,6 @@ int vmw_context_define_ioctl(struct drm_device *dev, void *data,
462 struct vmw_resource *tmp; 462 struct vmw_resource *tmp;
463 struct drm_vmw_context_arg *arg = (struct drm_vmw_context_arg *)data; 463 struct drm_vmw_context_arg *arg = (struct drm_vmw_context_arg *)data;
464 struct ttm_object_file *tfile = vmw_fpriv(file_priv)->tfile; 464 struct ttm_object_file *tfile = vmw_fpriv(file_priv)->tfile;
465 struct vmw_master *vmaster = vmw_master(file_priv->master);
466 int ret; 465 int ret;
467 466
468 467
@@ -474,7 +473,7 @@ int vmw_context_define_ioctl(struct drm_device *dev, void *data,
474 if (unlikely(vmw_user_context_size == 0)) 473 if (unlikely(vmw_user_context_size == 0))
475 vmw_user_context_size = ttm_round_pot(sizeof(*ctx)) + 128; 474 vmw_user_context_size = ttm_round_pot(sizeof(*ctx)) + 128;
476 475
477 ret = ttm_read_lock(&vmaster->lock, true); 476 ret = ttm_read_lock(&dev_priv->reservation_sem, true);
478 if (unlikely(ret != 0)) 477 if (unlikely(ret != 0))
479 return ret; 478 return ret;
480 479
@@ -521,7 +520,7 @@ int vmw_context_define_ioctl(struct drm_device *dev, void *data,
521out_err: 520out_err:
522 vmw_resource_unreference(&res); 521 vmw_resource_unreference(&res);
523out_unlock: 522out_unlock:
524 ttm_read_unlock(&vmaster->lock); 523 ttm_read_unlock(&dev_priv->reservation_sem);
525 return ret; 524 return ret;
526 525
527} 526}
diff --git a/drivers/gpu/drm/vmwgfx/vmwgfx_dmabuf.c b/drivers/gpu/drm/vmwgfx/vmwgfx_dmabuf.c
index a75840211b3c..70ddce8358b0 100644
--- a/drivers/gpu/drm/vmwgfx/vmwgfx_dmabuf.c
+++ b/drivers/gpu/drm/vmwgfx/vmwgfx_dmabuf.c
@@ -52,11 +52,10 @@ int vmw_dmabuf_to_placement(struct vmw_private *dev_priv,
52 struct ttm_placement *placement, 52 struct ttm_placement *placement,
53 bool interruptible) 53 bool interruptible)
54{ 54{
55 struct vmw_master *vmaster = dev_priv->active_master;
56 struct ttm_buffer_object *bo = &buf->base; 55 struct ttm_buffer_object *bo = &buf->base;
57 int ret; 56 int ret;
58 57
59 ret = ttm_write_lock(&vmaster->lock, interruptible); 58 ret = ttm_write_lock(&dev_priv->reservation_sem, interruptible);
60 if (unlikely(ret != 0)) 59 if (unlikely(ret != 0))
61 return ret; 60 return ret;
62 61
@@ -71,7 +70,7 @@ int vmw_dmabuf_to_placement(struct vmw_private *dev_priv,
71 ttm_bo_unreserve(bo); 70 ttm_bo_unreserve(bo);
72 71
73err: 72err:
74 ttm_write_unlock(&vmaster->lock); 73 ttm_write_unlock(&dev_priv->reservation_sem);
75 return ret; 74 return ret;
76} 75}
77 76
@@ -95,12 +94,11 @@ int vmw_dmabuf_to_vram_or_gmr(struct vmw_private *dev_priv,
95 struct vmw_dma_buffer *buf, 94 struct vmw_dma_buffer *buf,
96 bool pin, bool interruptible) 95 bool pin, bool interruptible)
97{ 96{
98 struct vmw_master *vmaster = dev_priv->active_master;
99 struct ttm_buffer_object *bo = &buf->base; 97 struct ttm_buffer_object *bo = &buf->base;
100 struct ttm_placement *placement; 98 struct ttm_placement *placement;
101 int ret; 99 int ret;
102 100
103 ret = ttm_write_lock(&vmaster->lock, interruptible); 101 ret = ttm_write_lock(&dev_priv->reservation_sem, interruptible);
104 if (unlikely(ret != 0)) 102 if (unlikely(ret != 0))
105 return ret; 103 return ret;
106 104
@@ -143,7 +141,7 @@ int vmw_dmabuf_to_vram_or_gmr(struct vmw_private *dev_priv,
143err_unreserve: 141err_unreserve:
144 ttm_bo_unreserve(bo); 142 ttm_bo_unreserve(bo);
145err: 143err:
146 ttm_write_unlock(&vmaster->lock); 144 ttm_write_unlock(&dev_priv->reservation_sem);
147 return ret; 145 return ret;
148} 146}
149 147
@@ -198,7 +196,6 @@ int vmw_dmabuf_to_start_of_vram(struct vmw_private *dev_priv,
198 struct vmw_dma_buffer *buf, 196 struct vmw_dma_buffer *buf,
199 bool pin, bool interruptible) 197 bool pin, bool interruptible)
200{ 198{
201 struct vmw_master *vmaster = dev_priv->active_master;
202 struct ttm_buffer_object *bo = &buf->base; 199 struct ttm_buffer_object *bo = &buf->base;
203 struct ttm_placement placement; 200 struct ttm_placement placement;
204 int ret = 0; 201 int ret = 0;
@@ -209,7 +206,7 @@ int vmw_dmabuf_to_start_of_vram(struct vmw_private *dev_priv,
209 placement = vmw_vram_placement; 206 placement = vmw_vram_placement;
210 placement.lpfn = bo->num_pages; 207 placement.lpfn = bo->num_pages;
211 208
212 ret = ttm_write_lock(&vmaster->lock, interruptible); 209 ret = ttm_write_lock(&dev_priv->reservation_sem, interruptible);
213 if (unlikely(ret != 0)) 210 if (unlikely(ret != 0))
214 return ret; 211 return ret;
215 212
@@ -232,7 +229,7 @@ int vmw_dmabuf_to_start_of_vram(struct vmw_private *dev_priv,
232 229
233 ttm_bo_unreserve(bo); 230 ttm_bo_unreserve(bo);
234err_unlock: 231err_unlock:
235 ttm_write_unlock(&vmaster->lock); 232 ttm_write_unlock(&dev_priv->reservation_sem);
236 233
237 return ret; 234 return ret;
238} 235}
diff --git a/drivers/gpu/drm/vmwgfx/vmwgfx_drv.c b/drivers/gpu/drm/vmwgfx/vmwgfx_drv.c
index c35715f26f40..54cfeb6fc3b1 100644
--- a/drivers/gpu/drm/vmwgfx/vmwgfx_drv.c
+++ b/drivers/gpu/drm/vmwgfx/vmwgfx_drv.c
@@ -606,6 +606,7 @@ static int vmw_driver_load(struct drm_device *dev, unsigned long chipset)
606 mutex_init(&dev_priv->release_mutex); 606 mutex_init(&dev_priv->release_mutex);
607 mutex_init(&dev_priv->binding_mutex); 607 mutex_init(&dev_priv->binding_mutex);
608 rwlock_init(&dev_priv->resource_lock); 608 rwlock_init(&dev_priv->resource_lock);
609 ttm_lock_init(&dev_priv->reservation_sem);
609 610
610 for (i = vmw_res_context; i < vmw_res_max; ++i) { 611 for (i = vmw_res_context; i < vmw_res_max; ++i) {
611 idr_init(&dev_priv->res_idr[i]); 612 idr_init(&dev_priv->res_idr[i]);
@@ -1175,12 +1176,11 @@ static int vmwgfx_pm_notifier(struct notifier_block *nb, unsigned long val,
1175{ 1176{
1176 struct vmw_private *dev_priv = 1177 struct vmw_private *dev_priv =
1177 container_of(nb, struct vmw_private, pm_nb); 1178 container_of(nb, struct vmw_private, pm_nb);
1178 struct vmw_master *vmaster = dev_priv->active_master;
1179 1179
1180 switch (val) { 1180 switch (val) {
1181 case PM_HIBERNATION_PREPARE: 1181 case PM_HIBERNATION_PREPARE:
1182 case PM_SUSPEND_PREPARE: 1182 case PM_SUSPEND_PREPARE:
1183 ttm_suspend_lock(&vmaster->lock); 1183 ttm_suspend_lock(&dev_priv->reservation_sem);
1184 1184
1185 /** 1185 /**
1186 * This empties VRAM and unbinds all GMR bindings. 1186 * This empties VRAM and unbinds all GMR bindings.
@@ -1194,7 +1194,7 @@ static int vmwgfx_pm_notifier(struct notifier_block *nb, unsigned long val,
1194 case PM_POST_HIBERNATION: 1194 case PM_POST_HIBERNATION:
1195 case PM_POST_SUSPEND: 1195 case PM_POST_SUSPEND:
1196 case PM_POST_RESTORE: 1196 case PM_POST_RESTORE:
1197 ttm_suspend_unlock(&vmaster->lock); 1197 ttm_suspend_unlock(&dev_priv->reservation_sem);
1198 1198
1199 break; 1199 break;
1200 case PM_RESTORE_PREPARE: 1200 case PM_RESTORE_PREPARE:
diff --git a/drivers/gpu/drm/vmwgfx/vmwgfx_drv.h b/drivers/gpu/drm/vmwgfx/vmwgfx_drv.h
index 07831554dad7..8c6b71f6cac9 100644
--- a/drivers/gpu/drm/vmwgfx/vmwgfx_drv.h
+++ b/drivers/gpu/drm/vmwgfx/vmwgfx_drv.h
@@ -487,6 +487,11 @@ struct vmw_private {
487 uint32_t num_3d_resources; 487 uint32_t num_3d_resources;
488 488
489 /* 489 /*
490 * Replace this with an rwsem as soon as we have down_xx_interruptible()
491 */
492 struct ttm_lock reservation_sem;
493
494 /*
490 * Query processing. These members 495 * Query processing. These members
491 * are protected by the cmdbuf mutex. 496 * are protected by the cmdbuf mutex.
492 */ 497 */
diff --git a/drivers/gpu/drm/vmwgfx/vmwgfx_execbuf.c b/drivers/gpu/drm/vmwgfx/vmwgfx_execbuf.c
index efb575a7996c..931490b9cfed 100644
--- a/drivers/gpu/drm/vmwgfx/vmwgfx_execbuf.c
+++ b/drivers/gpu/drm/vmwgfx/vmwgfx_execbuf.c
@@ -2712,7 +2712,6 @@ int vmw_execbuf_ioctl(struct drm_device *dev, void *data,
2712{ 2712{
2713 struct vmw_private *dev_priv = vmw_priv(dev); 2713 struct vmw_private *dev_priv = vmw_priv(dev);
2714 struct drm_vmw_execbuf_arg *arg = (struct drm_vmw_execbuf_arg *)data; 2714 struct drm_vmw_execbuf_arg *arg = (struct drm_vmw_execbuf_arg *)data;
2715 struct vmw_master *vmaster = vmw_master(file_priv->master);
2716 int ret; 2715 int ret;
2717 2716
2718 /* 2717 /*
@@ -2729,7 +2728,7 @@ int vmw_execbuf_ioctl(struct drm_device *dev, void *data,
2729 return -EINVAL; 2728 return -EINVAL;
2730 } 2729 }
2731 2730
2732 ret = ttm_read_lock(&vmaster->lock, true); 2731 ret = ttm_read_lock(&dev_priv->reservation_sem, true);
2733 if (unlikely(ret != 0)) 2732 if (unlikely(ret != 0))
2734 return ret; 2733 return ret;
2735 2734
@@ -2745,6 +2744,6 @@ int vmw_execbuf_ioctl(struct drm_device *dev, void *data,
2745 vmw_kms_cursor_post_execbuf(dev_priv); 2744 vmw_kms_cursor_post_execbuf(dev_priv);
2746 2745
2747out_unlock: 2746out_unlock:
2748 ttm_read_unlock(&vmaster->lock); 2747 ttm_read_unlock(&dev_priv->reservation_sem);
2749 return ret; 2748 return ret;
2750} 2749}
diff --git a/drivers/gpu/drm/vmwgfx/vmwgfx_fb.c b/drivers/gpu/drm/vmwgfx/vmwgfx_fb.c
index ed5ce2a41bbf..9699bd174ae4 100644
--- a/drivers/gpu/drm/vmwgfx/vmwgfx_fb.c
+++ b/drivers/gpu/drm/vmwgfx/vmwgfx_fb.c
@@ -377,14 +377,13 @@ static int vmw_fb_create_bo(struct vmw_private *vmw_priv,
377 377
378 ne_placement.lpfn = (size + PAGE_SIZE - 1) >> PAGE_SHIFT; 378 ne_placement.lpfn = (size + PAGE_SIZE - 1) >> PAGE_SHIFT;
379 379
380 /* interuptable? */ 380 (void) ttm_write_lock(&vmw_priv->reservation_sem, false);
381 ret = ttm_write_lock(&vmw_priv->fbdev_master.lock, false);
382 if (unlikely(ret != 0))
383 return ret;
384 381
385 vmw_bo = kmalloc(sizeof(*vmw_bo), GFP_KERNEL); 382 vmw_bo = kmalloc(sizeof(*vmw_bo), GFP_KERNEL);
386 if (!vmw_bo) 383 if (!vmw_bo) {
384 ret = -ENOMEM;
387 goto err_unlock; 385 goto err_unlock;
386 }
388 387
389 ret = vmw_dmabuf_init(vmw_priv, vmw_bo, size, 388 ret = vmw_dmabuf_init(vmw_priv, vmw_bo, size,
390 &ne_placement, 389 &ne_placement,
diff --git a/drivers/gpu/drm/vmwgfx/vmwgfx_ioctl.c b/drivers/gpu/drm/vmwgfx/vmwgfx_ioctl.c
index 47b70949bf3a..37881ecf5d7a 100644
--- a/drivers/gpu/drm/vmwgfx/vmwgfx_ioctl.c
+++ b/drivers/gpu/drm/vmwgfx/vmwgfx_ioctl.c
@@ -226,7 +226,6 @@ int vmw_present_ioctl(struct drm_device *dev, void *data,
226 struct drm_vmw_present_arg *arg = 226 struct drm_vmw_present_arg *arg =
227 (struct drm_vmw_present_arg *)data; 227 (struct drm_vmw_present_arg *)data;
228 struct vmw_surface *surface; 228 struct vmw_surface *surface;
229 struct vmw_master *vmaster = vmw_master(file_priv->master);
230 struct drm_vmw_rect __user *clips_ptr; 229 struct drm_vmw_rect __user *clips_ptr;
231 struct drm_vmw_rect *clips = NULL; 230 struct drm_vmw_rect *clips = NULL;
232 struct drm_framebuffer *fb; 231 struct drm_framebuffer *fb;
@@ -271,7 +270,7 @@ int vmw_present_ioctl(struct drm_device *dev, void *data,
271 } 270 }
272 vfb = vmw_framebuffer_to_vfb(fb); 271 vfb = vmw_framebuffer_to_vfb(fb);
273 272
274 ret = ttm_read_lock(&vmaster->lock, true); 273 ret = ttm_read_lock(&dev_priv->reservation_sem, true);
275 if (unlikely(ret != 0)) 274 if (unlikely(ret != 0))
276 goto out_no_ttm_lock; 275 goto out_no_ttm_lock;
277 276
@@ -291,7 +290,7 @@ int vmw_present_ioctl(struct drm_device *dev, void *data,
291 vmw_surface_unreference(&surface); 290 vmw_surface_unreference(&surface);
292 291
293out_no_surface: 292out_no_surface:
294 ttm_read_unlock(&vmaster->lock); 293 ttm_read_unlock(&dev_priv->reservation_sem);
295out_no_ttm_lock: 294out_no_ttm_lock:
296 drm_framebuffer_unreference(fb); 295 drm_framebuffer_unreference(fb);
297out_no_fb: 296out_no_fb:
@@ -311,7 +310,6 @@ int vmw_present_readback_ioctl(struct drm_device *dev, void *data,
311 struct drm_vmw_fence_rep __user *user_fence_rep = 310 struct drm_vmw_fence_rep __user *user_fence_rep =
312 (struct drm_vmw_fence_rep __user *) 311 (struct drm_vmw_fence_rep __user *)
313 (unsigned long)arg->fence_rep; 312 (unsigned long)arg->fence_rep;
314 struct vmw_master *vmaster = vmw_master(file_priv->master);
315 struct drm_vmw_rect __user *clips_ptr; 313 struct drm_vmw_rect __user *clips_ptr;
316 struct drm_vmw_rect *clips = NULL; 314 struct drm_vmw_rect *clips = NULL;
317 struct drm_framebuffer *fb; 315 struct drm_framebuffer *fb;
@@ -361,7 +359,7 @@ int vmw_present_readback_ioctl(struct drm_device *dev, void *data,
361 goto out_no_ttm_lock; 359 goto out_no_ttm_lock;
362 } 360 }
363 361
364 ret = ttm_read_lock(&vmaster->lock, true); 362 ret = ttm_read_lock(&dev_priv->reservation_sem, true);
365 if (unlikely(ret != 0)) 363 if (unlikely(ret != 0))
366 goto out_no_ttm_lock; 364 goto out_no_ttm_lock;
367 365
@@ -369,7 +367,7 @@ int vmw_present_readback_ioctl(struct drm_device *dev, void *data,
369 vfb, user_fence_rep, 367 vfb, user_fence_rep,
370 clips, num_clips); 368 clips, num_clips);
371 369
372 ttm_read_unlock(&vmaster->lock); 370 ttm_read_unlock(&dev_priv->reservation_sem);
373out_no_ttm_lock: 371out_no_ttm_lock:
374 drm_framebuffer_unreference(fb); 372 drm_framebuffer_unreference(fb);
375out_no_fb: 373out_no_fb:
diff --git a/drivers/gpu/drm/vmwgfx/vmwgfx_kms.c b/drivers/gpu/drm/vmwgfx/vmwgfx_kms.c
index 8a650413dea5..159af7ee111f 100644
--- a/drivers/gpu/drm/vmwgfx/vmwgfx_kms.c
+++ b/drivers/gpu/drm/vmwgfx/vmwgfx_kms.c
@@ -596,7 +596,6 @@ static int vmw_framebuffer_surface_dirty(struct drm_framebuffer *framebuffer,
596 unsigned num_clips) 596 unsigned num_clips)
597{ 597{
598 struct vmw_private *dev_priv = vmw_priv(framebuffer->dev); 598 struct vmw_private *dev_priv = vmw_priv(framebuffer->dev);
599 struct vmw_master *vmaster = vmw_master(file_priv->master);
600 struct vmw_framebuffer_surface *vfbs = 599 struct vmw_framebuffer_surface *vfbs =
601 vmw_framebuffer_to_vfbs(framebuffer); 600 vmw_framebuffer_to_vfbs(framebuffer);
602 struct drm_clip_rect norect; 601 struct drm_clip_rect norect;
@@ -611,7 +610,7 @@ static int vmw_framebuffer_surface_dirty(struct drm_framebuffer *framebuffer,
611 610
612 drm_modeset_lock_all(dev_priv->dev); 611 drm_modeset_lock_all(dev_priv->dev);
613 612
614 ret = ttm_read_lock(&vmaster->lock, true); 613 ret = ttm_read_lock(&dev_priv->reservation_sem, true);
615 if (unlikely(ret != 0)) { 614 if (unlikely(ret != 0)) {
616 drm_modeset_unlock_all(dev_priv->dev); 615 drm_modeset_unlock_all(dev_priv->dev);
617 return ret; 616 return ret;
@@ -632,7 +631,7 @@ static int vmw_framebuffer_surface_dirty(struct drm_framebuffer *framebuffer,
632 flags, color, 631 flags, color,
633 clips, num_clips, inc, NULL); 632 clips, num_clips, inc, NULL);
634 633
635 ttm_read_unlock(&vmaster->lock); 634 ttm_read_unlock(&dev_priv->reservation_sem);
636 635
637 drm_modeset_unlock_all(dev_priv->dev); 636 drm_modeset_unlock_all(dev_priv->dev);
638 637
@@ -954,7 +953,6 @@ static int vmw_framebuffer_dmabuf_dirty(struct drm_framebuffer *framebuffer,
954 unsigned num_clips) 953 unsigned num_clips)
955{ 954{
956 struct vmw_private *dev_priv = vmw_priv(framebuffer->dev); 955 struct vmw_private *dev_priv = vmw_priv(framebuffer->dev);
957 struct vmw_master *vmaster = vmw_master(file_priv->master);
958 struct vmw_framebuffer_dmabuf *vfbd = 956 struct vmw_framebuffer_dmabuf *vfbd =
959 vmw_framebuffer_to_vfbd(framebuffer); 957 vmw_framebuffer_to_vfbd(framebuffer);
960 struct drm_clip_rect norect; 958 struct drm_clip_rect norect;
@@ -962,7 +960,7 @@ static int vmw_framebuffer_dmabuf_dirty(struct drm_framebuffer *framebuffer,
962 960
963 drm_modeset_lock_all(dev_priv->dev); 961 drm_modeset_lock_all(dev_priv->dev);
964 962
965 ret = ttm_read_lock(&vmaster->lock, true); 963 ret = ttm_read_lock(&dev_priv->reservation_sem, true);
966 if (unlikely(ret != 0)) { 964 if (unlikely(ret != 0)) {
967 drm_modeset_unlock_all(dev_priv->dev); 965 drm_modeset_unlock_all(dev_priv->dev);
968 return ret; 966 return ret;
@@ -989,7 +987,7 @@ static int vmw_framebuffer_dmabuf_dirty(struct drm_framebuffer *framebuffer,
989 clips, num_clips, increment, NULL); 987 clips, num_clips, increment, NULL);
990 } 988 }
991 989
992 ttm_read_unlock(&vmaster->lock); 990 ttm_read_unlock(&dev_priv->reservation_sem);
993 991
994 drm_modeset_unlock_all(dev_priv->dev); 992 drm_modeset_unlock_all(dev_priv->dev);
995 993
@@ -2022,7 +2020,6 @@ int vmw_kms_update_layout_ioctl(struct drm_device *dev, void *data,
2022 struct vmw_private *dev_priv = vmw_priv(dev); 2020 struct vmw_private *dev_priv = vmw_priv(dev);
2023 struct drm_vmw_update_layout_arg *arg = 2021 struct drm_vmw_update_layout_arg *arg =
2024 (struct drm_vmw_update_layout_arg *)data; 2022 (struct drm_vmw_update_layout_arg *)data;
2025 struct vmw_master *vmaster = vmw_master(file_priv->master);
2026 void __user *user_rects; 2023 void __user *user_rects;
2027 struct drm_vmw_rect *rects; 2024 struct drm_vmw_rect *rects;
2028 unsigned rects_size; 2025 unsigned rects_size;
@@ -2030,7 +2027,7 @@ int vmw_kms_update_layout_ioctl(struct drm_device *dev, void *data,
2030 int i; 2027 int i;
2031 struct drm_mode_config *mode_config = &dev->mode_config; 2028 struct drm_mode_config *mode_config = &dev->mode_config;
2032 2029
2033 ret = ttm_read_lock(&vmaster->lock, true); 2030 ret = ttm_read_lock(&dev_priv->reservation_sem, true);
2034 if (unlikely(ret != 0)) 2031 if (unlikely(ret != 0))
2035 return ret; 2032 return ret;
2036 2033
@@ -2072,6 +2069,6 @@ int vmw_kms_update_layout_ioctl(struct drm_device *dev, void *data,
2072out_free: 2069out_free:
2073 kfree(rects); 2070 kfree(rects);
2074out_unlock: 2071out_unlock:
2075 ttm_read_unlock(&vmaster->lock); 2072 ttm_read_unlock(&dev_priv->reservation_sem);
2076 return ret; 2073 return ret;
2077} 2074}
diff --git a/drivers/gpu/drm/vmwgfx/vmwgfx_resource.c b/drivers/gpu/drm/vmwgfx/vmwgfx_resource.c
index 9757b57f8388..30439cbeac2b 100644
--- a/drivers/gpu/drm/vmwgfx/vmwgfx_resource.c
+++ b/drivers/gpu/drm/vmwgfx/vmwgfx_resource.c
@@ -676,10 +676,9 @@ int vmw_dmabuf_alloc_ioctl(struct drm_device *dev, void *data,
676 struct drm_vmw_dmabuf_rep *rep = &arg->rep; 676 struct drm_vmw_dmabuf_rep *rep = &arg->rep;
677 struct vmw_dma_buffer *dma_buf; 677 struct vmw_dma_buffer *dma_buf;
678 uint32_t handle; 678 uint32_t handle;
679 struct vmw_master *vmaster = vmw_master(file_priv->master);
680 int ret; 679 int ret;
681 680
682 ret = ttm_read_lock(&vmaster->lock, true); 681 ret = ttm_read_lock(&dev_priv->reservation_sem, true);
683 if (unlikely(ret != 0)) 682 if (unlikely(ret != 0))
684 return ret; 683 return ret;
685 684
@@ -696,7 +695,7 @@ int vmw_dmabuf_alloc_ioctl(struct drm_device *dev, void *data,
696 vmw_dmabuf_unreference(&dma_buf); 695 vmw_dmabuf_unreference(&dma_buf);
697 696
698out_no_dmabuf: 697out_no_dmabuf:
699 ttm_read_unlock(&vmaster->lock); 698 ttm_read_unlock(&dev_priv->reservation_sem);
700 699
701 return ret; 700 return ret;
702} 701}
@@ -873,7 +872,6 @@ int vmw_stream_claim_ioctl(struct drm_device *dev, void *data,
873 struct vmw_resource *tmp; 872 struct vmw_resource *tmp;
874 struct drm_vmw_stream_arg *arg = (struct drm_vmw_stream_arg *)data; 873 struct drm_vmw_stream_arg *arg = (struct drm_vmw_stream_arg *)data;
875 struct ttm_object_file *tfile = vmw_fpriv(file_priv)->tfile; 874 struct ttm_object_file *tfile = vmw_fpriv(file_priv)->tfile;
876 struct vmw_master *vmaster = vmw_master(file_priv->master);
877 int ret; 875 int ret;
878 876
879 /* 877 /*
@@ -884,7 +882,7 @@ int vmw_stream_claim_ioctl(struct drm_device *dev, void *data,
884 if (unlikely(vmw_user_stream_size == 0)) 882 if (unlikely(vmw_user_stream_size == 0))
885 vmw_user_stream_size = ttm_round_pot(sizeof(*stream)) + 128; 883 vmw_user_stream_size = ttm_round_pot(sizeof(*stream)) + 128;
886 884
887 ret = ttm_read_lock(&vmaster->lock, true); 885 ret = ttm_read_lock(&dev_priv->reservation_sem, true);
888 if (unlikely(ret != 0)) 886 if (unlikely(ret != 0))
889 return ret; 887 return ret;
890 888
@@ -932,7 +930,7 @@ int vmw_stream_claim_ioctl(struct drm_device *dev, void *data,
932out_err: 930out_err:
933 vmw_resource_unreference(&res); 931 vmw_resource_unreference(&res);
934out_unlock: 932out_unlock:
935 ttm_read_unlock(&vmaster->lock); 933 ttm_read_unlock(&dev_priv->reservation_sem);
936 return ret; 934 return ret;
937} 935}
938 936
@@ -985,14 +983,13 @@ int vmw_dumb_create(struct drm_file *file_priv,
985 struct drm_mode_create_dumb *args) 983 struct drm_mode_create_dumb *args)
986{ 984{
987 struct vmw_private *dev_priv = vmw_priv(dev); 985 struct vmw_private *dev_priv = vmw_priv(dev);
988 struct vmw_master *vmaster = vmw_master(file_priv->master);
989 struct vmw_dma_buffer *dma_buf; 986 struct vmw_dma_buffer *dma_buf;
990 int ret; 987 int ret;
991 988
992 args->pitch = args->width * ((args->bpp + 7) / 8); 989 args->pitch = args->width * ((args->bpp + 7) / 8);
993 args->size = args->pitch * args->height; 990 args->size = args->pitch * args->height;
994 991
995 ret = ttm_read_lock(&vmaster->lock, true); 992 ret = ttm_read_lock(&dev_priv->reservation_sem, true);
996 if (unlikely(ret != 0)) 993 if (unlikely(ret != 0))
997 return ret; 994 return ret;
998 995
@@ -1004,7 +1001,7 @@ int vmw_dumb_create(struct drm_file *file_priv,
1004 1001
1005 vmw_dmabuf_unreference(&dma_buf); 1002 vmw_dmabuf_unreference(&dma_buf);
1006out_no_dmabuf: 1003out_no_dmabuf:
1007 ttm_read_unlock(&vmaster->lock); 1004 ttm_read_unlock(&dev_priv->reservation_sem);
1008 return ret; 1005 return ret;
1009} 1006}
1010 1007
diff --git a/drivers/gpu/drm/vmwgfx/vmwgfx_shader.c b/drivers/gpu/drm/vmwgfx/vmwgfx_shader.c
index ee3856578a12..c1559eeaffe9 100644
--- a/drivers/gpu/drm/vmwgfx/vmwgfx_shader.c
+++ b/drivers/gpu/drm/vmwgfx/vmwgfx_shader.c
@@ -449,7 +449,6 @@ int vmw_shader_define_ioctl(struct drm_device *dev, void *data,
449 struct drm_vmw_shader_create_arg *arg = 449 struct drm_vmw_shader_create_arg *arg =
450 (struct drm_vmw_shader_create_arg *)data; 450 (struct drm_vmw_shader_create_arg *)data;
451 struct ttm_object_file *tfile = vmw_fpriv(file_priv)->tfile; 451 struct ttm_object_file *tfile = vmw_fpriv(file_priv)->tfile;
452 struct vmw_master *vmaster = vmw_master(file_priv->master);
453 struct vmw_dma_buffer *buffer = NULL; 452 struct vmw_dma_buffer *buffer = NULL;
454 SVGA3dShaderType shader_type; 453 SVGA3dShaderType shader_type;
455 int ret; 454 int ret;
@@ -487,14 +486,14 @@ int vmw_shader_define_ioctl(struct drm_device *dev, void *data,
487 goto out_bad_arg; 486 goto out_bad_arg;
488 } 487 }
489 488
490 ret = ttm_read_lock(&vmaster->lock, true); 489 ret = ttm_read_lock(&dev_priv->reservation_sem, true);
491 if (unlikely(ret != 0)) 490 if (unlikely(ret != 0))
492 goto out_bad_arg; 491 goto out_bad_arg;
493 492
494 ret = vmw_shader_alloc(dev_priv, buffer, arg->size, arg->offset, 493 ret = vmw_shader_alloc(dev_priv, buffer, arg->size, arg->offset,
495 shader_type, tfile, &arg->shader_handle); 494 shader_type, tfile, &arg->shader_handle);
496 495
497 ttm_read_unlock(&vmaster->lock); 496 ttm_read_unlock(&dev_priv->reservation_sem);
498out_bad_arg: 497out_bad_arg:
499 vmw_dmabuf_unreference(&buffer); 498 vmw_dmabuf_unreference(&buffer);
500 return ret; 499 return ret;
diff --git a/drivers/gpu/drm/vmwgfx/vmwgfx_surface.c b/drivers/gpu/drm/vmwgfx/vmwgfx_surface.c
index e7af580ab977..aac243b9ec30 100644
--- a/drivers/gpu/drm/vmwgfx/vmwgfx_surface.c
+++ b/drivers/gpu/drm/vmwgfx/vmwgfx_surface.c
@@ -697,7 +697,6 @@ int vmw_surface_define_ioctl(struct drm_device *dev, void *data,
697 struct vmw_surface_offset *cur_offset; 697 struct vmw_surface_offset *cur_offset;
698 uint32_t num_sizes; 698 uint32_t num_sizes;
699 uint32_t size; 699 uint32_t size;
700 struct vmw_master *vmaster = vmw_master(file_priv->master);
701 const struct svga3d_surface_desc *desc; 700 const struct svga3d_surface_desc *desc;
702 701
703 if (unlikely(vmw_user_surface_size == 0)) 702 if (unlikely(vmw_user_surface_size == 0))
@@ -723,7 +722,7 @@ int vmw_surface_define_ioctl(struct drm_device *dev, void *data,
723 return -EINVAL; 722 return -EINVAL;
724 } 723 }
725 724
726 ret = ttm_read_lock(&vmaster->lock, true); 725 ret = ttm_read_lock(&dev_priv->reservation_sem, true);
727 if (unlikely(ret != 0)) 726 if (unlikely(ret != 0))
728 return ret; 727 return ret;
729 728
@@ -862,7 +861,7 @@ int vmw_surface_define_ioctl(struct drm_device *dev, void *data,
862 rep->sid = user_srf->prime.base.hash.key; 861 rep->sid = user_srf->prime.base.hash.key;
863 vmw_resource_unreference(&res); 862 vmw_resource_unreference(&res);
864 863
865 ttm_read_unlock(&vmaster->lock); 864 ttm_read_unlock(&dev_priv->reservation_sem);
866 return 0; 865 return 0;
867out_no_copy: 866out_no_copy:
868 kfree(srf->offsets); 867 kfree(srf->offsets);
@@ -873,7 +872,7 @@ out_no_sizes:
873out_no_user_srf: 872out_no_user_srf:
874 ttm_mem_global_free(vmw_mem_glob(dev_priv), size); 873 ttm_mem_global_free(vmw_mem_glob(dev_priv), size);
875out_unlock: 874out_unlock:
876 ttm_read_unlock(&vmaster->lock); 875 ttm_read_unlock(&dev_priv->reservation_sem);
877 return ret; 876 return ret;
878} 877}
879 878
@@ -1173,7 +1172,6 @@ int vmw_gb_surface_define_ioctl(struct drm_device *dev, void *data,
1173 struct ttm_object_file *tfile = vmw_fpriv(file_priv)->tfile; 1172 struct ttm_object_file *tfile = vmw_fpriv(file_priv)->tfile;
1174 int ret; 1173 int ret;
1175 uint32_t size; 1174 uint32_t size;
1176 struct vmw_master *vmaster = vmw_master(file_priv->master);
1177 const struct svga3d_surface_desc *desc; 1175 const struct svga3d_surface_desc *desc;
1178 uint32_t backup_handle; 1176 uint32_t backup_handle;
1179 1177
@@ -1189,7 +1187,7 @@ int vmw_gb_surface_define_ioctl(struct drm_device *dev, void *data,
1189 return -EINVAL; 1187 return -EINVAL;
1190 } 1188 }
1191 1189
1192 ret = ttm_read_lock(&vmaster->lock, true); 1190 ret = ttm_read_lock(&dev_priv->reservation_sem, true);
1193 if (unlikely(ret != 0)) 1191 if (unlikely(ret != 0))
1194 return ret; 1192 return ret;
1195 1193
@@ -1283,12 +1281,12 @@ int vmw_gb_surface_define_ioctl(struct drm_device *dev, void *data,
1283 1281
1284 vmw_resource_unreference(&res); 1282 vmw_resource_unreference(&res);
1285 1283
1286 ttm_read_unlock(&vmaster->lock); 1284 ttm_read_unlock(&dev_priv->reservation_sem);
1287 return 0; 1285 return 0;
1288out_no_user_srf: 1286out_no_user_srf:
1289 ttm_mem_global_free(vmw_mem_glob(dev_priv), size); 1287 ttm_mem_global_free(vmw_mem_glob(dev_priv), size);
1290out_unlock: 1288out_unlock:
1291 ttm_read_unlock(&vmaster->lock); 1289 ttm_read_unlock(&dev_priv->reservation_sem);
1292 return ret; 1290 return ret;
1293} 1291}
1294 1292