aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--drivers/gpu/drm/nouveau/nouveau_drv.h1
-rw-r--r--drivers/gpu/drm/nouveau/nouveau_gem.c64
-rw-r--r--include/drm/nouveau_drm.h1
3 files changed, 4 insertions, 62 deletions
diff --git a/drivers/gpu/drm/nouveau/nouveau_drv.h b/drivers/gpu/drm/nouveau/nouveau_drv.h
index c3f102125083..b78663fc334c 100644
--- a/drivers/gpu/drm/nouveau/nouveau_drv.h
+++ b/drivers/gpu/drm/nouveau/nouveau_drv.h
@@ -96,7 +96,6 @@ struct nouveau_bo {
96 struct nouveau_tile_reg *tile; 96 struct nouveau_tile_reg *tile;
97 97
98 struct drm_gem_object *gem; 98 struct drm_gem_object *gem;
99 struct drm_file *cpu_filp;
100 int pin_refcnt; 99 int pin_refcnt;
101}; 100};
102 101
diff --git a/drivers/gpu/drm/nouveau/nouveau_gem.c b/drivers/gpu/drm/nouveau/nouveau_gem.c
index 454d5ceb28f1..e14d10e38870 100644
--- a/drivers/gpu/drm/nouveau/nouveau_gem.c
+++ b/drivers/gpu/drm/nouveau/nouveau_gem.c
@@ -48,9 +48,6 @@ nouveau_gem_object_del(struct drm_gem_object *gem)
48 return; 48 return;
49 nvbo->gem = NULL; 49 nvbo->gem = NULL;
50 50
51 if (unlikely(nvbo->cpu_filp))
52 ttm_bo_synccpu_write_release(bo);
53
54 if (unlikely(nvbo->pin_refcnt)) { 51 if (unlikely(nvbo->pin_refcnt)) {
55 nvbo->pin_refcnt = 1; 52 nvbo->pin_refcnt = 1;
56 nouveau_bo_unpin(nvbo); 53 nouveau_bo_unpin(nvbo);
@@ -334,23 +331,6 @@ retry:
334 validate_fini(op, NULL); 331 validate_fini(op, NULL);
335 return -EINVAL; 332 return -EINVAL;
336 } 333 }
337
338 if (unlikely(atomic_read(&nvbo->bo.cpu_writers) > 0)) {
339 validate_fini(op, NULL);
340
341 if (nvbo->cpu_filp == file_priv) {
342 NV_ERROR(dev, "bo %p mapped by process trying "
343 "to validate it!\n", nvbo);
344 return -EINVAL;
345 }
346
347 ret = ttm_bo_wait_cpu(&nvbo->bo, false);
348 if (ret) {
349 NV_ERROR(dev, "fail wait_cpu\n");
350 return ret;
351 }
352 goto retry;
353 }
354 } 334 }
355 335
356 return 0; 336 return 0;
@@ -791,26 +771,9 @@ nouveau_gem_ioctl_cpu_prep(struct drm_device *dev, void *data,
791 return -ENOENT; 771 return -ENOENT;
792 nvbo = nouveau_gem_object(gem); 772 nvbo = nouveau_gem_object(gem);
793 773
794 if (nvbo->cpu_filp) { 774 spin_lock(&nvbo->bo.bdev->fence_lock);
795 if (nvbo->cpu_filp == file_priv) 775 ret = ttm_bo_wait(&nvbo->bo, true, true, no_wait);
796 goto out; 776 spin_unlock(&nvbo->bo.bdev->fence_lock);
797
798 ret = ttm_bo_wait_cpu(&nvbo->bo, no_wait);
799 if (ret)
800 goto out;
801 }
802
803 if (req->flags & NOUVEAU_GEM_CPU_PREP_NOBLOCK) {
804 spin_lock(&nvbo->bo.bdev->fence_lock);
805 ret = ttm_bo_wait(&nvbo->bo, false, false, no_wait);
806 spin_unlock(&nvbo->bo.bdev->fence_lock);
807 } else {
808 ret = ttm_bo_synccpu_write_grab(&nvbo->bo, no_wait);
809 if (ret == 0)
810 nvbo->cpu_filp = file_priv;
811 }
812
813out:
814 drm_gem_object_unreference_unlocked(gem); 777 drm_gem_object_unreference_unlocked(gem);
815 return ret; 778 return ret;
816} 779}
@@ -819,26 +782,7 @@ int
819nouveau_gem_ioctl_cpu_fini(struct drm_device *dev, void *data, 782nouveau_gem_ioctl_cpu_fini(struct drm_device *dev, void *data,
820 struct drm_file *file_priv) 783 struct drm_file *file_priv)
821{ 784{
822 struct drm_nouveau_gem_cpu_prep *req = data; 785 return 0;
823 struct drm_gem_object *gem;
824 struct nouveau_bo *nvbo;
825 int ret = -EINVAL;
826
827 gem = drm_gem_object_lookup(dev, file_priv, req->handle);
828 if (!gem)
829 return -ENOENT;
830 nvbo = nouveau_gem_object(gem);
831
832 if (nvbo->cpu_filp != file_priv)
833 goto out;
834 nvbo->cpu_filp = NULL;
835
836 ttm_bo_synccpu_write_release(&nvbo->bo);
837 ret = 0;
838
839out:
840 drm_gem_object_unreference_unlocked(gem);
841 return ret;
842} 786}
843 787
844int 788int
diff --git a/include/drm/nouveau_drm.h b/include/drm/nouveau_drm.h
index bc5590b1a1ac..60a7b3e9c2e9 100644
--- a/include/drm/nouveau_drm.h
+++ b/include/drm/nouveau_drm.h
@@ -171,7 +171,6 @@ struct drm_nouveau_gem_pushbuf {
171}; 171};
172 172
173#define NOUVEAU_GEM_CPU_PREP_NOWAIT 0x00000001 173#define NOUVEAU_GEM_CPU_PREP_NOWAIT 0x00000001
174#define NOUVEAU_GEM_CPU_PREP_NOBLOCK 0x00000002
175#define NOUVEAU_GEM_CPU_PREP_WRITE 0x00000004 174#define NOUVEAU_GEM_CPU_PREP_WRITE 0x00000004
176struct drm_nouveau_gem_cpu_prep { 175struct drm_nouveau_gem_cpu_prep {
177 uint32_t handle; 176 uint32_t handle;