aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorDave Airlie <airlied@redhat.com>2015-12-22 01:19:37 -0500
committerDave Airlie <airlied@redhat.com>2015-12-22 01:19:37 -0500
commit0239c75978a9b9bdadfe07cdc60d40bdedb93a07 (patch)
tree263ae0b69bfd53de3e5a6dd0983cc9eb31ccd1d2
parentaa72044a1d229ad8ad6fd53a2f2dd3da12430216 (diff)
parent5645e785cea2f33acdc5e5cee62b3ce8a00f1169 (diff)
Merge tag 'drm-vc4-next-2015-12-21' of http://github.com/anholt/linux into drm-next
I've decided to just send this fixes-for-next pull request now, even if we don't have a patch for the CONFIG_PM_SLEEP build failure reviewed. If you like my patch for that, I'd be happy to see it applied directly. This pull request brings in little fixes from Dan Carpenter for the 3D support added in this -next cycle. * tag 'drm-vc4-next-2015-12-21' of http://github.com/anholt/linux: drm/vc4: fix an error code drm/vc4: allocate enough memory in vc4_save_hang_state() drm/vc4: copy_to_user() returns the number of bytes remaining
-rw-r--r--drivers/gpu/drm/vc4/vc4_gem.c41
1 files changed, 20 insertions, 21 deletions
diff --git a/drivers/gpu/drm/vc4/vc4_gem.c b/drivers/gpu/drm/vc4/vc4_gem.c
index 39f29e759334..48ce30a6f4b5 100644
--- a/drivers/gpu/drm/vc4/vc4_gem.c
+++ b/drivers/gpu/drm/vc4/vc4_gem.c
@@ -71,7 +71,7 @@ vc4_get_hang_state_ioctl(struct drm_device *dev, void *data,
71 struct vc4_dev *vc4 = to_vc4_dev(dev); 71 struct vc4_dev *vc4 = to_vc4_dev(dev);
72 unsigned long irqflags; 72 unsigned long irqflags;
73 u32 i; 73 u32 i;
74 int ret; 74 int ret = 0;
75 75
76 spin_lock_irqsave(&vc4->job_lock, irqflags); 76 spin_lock_irqsave(&vc4->job_lock, irqflags);
77 kernel_state = vc4->hang_state; 77 kernel_state = vc4->hang_state;
@@ -119,9 +119,11 @@ vc4_get_hang_state_ioctl(struct drm_device *dev, void *data,
119 bo_state[i].size = vc4_bo->base.base.size; 119 bo_state[i].size = vc4_bo->base.base.size;
120 } 120 }
121 121
122 ret = copy_to_user((void __user *)(uintptr_t)get_state->bo, 122 if (copy_to_user((void __user *)(uintptr_t)get_state->bo,
123 bo_state, 123 bo_state,
124 state->bo_count * sizeof(*bo_state)); 124 state->bo_count * sizeof(*bo_state)))
125 ret = -EFAULT;
126
125 kfree(bo_state); 127 kfree(bo_state);
126 128
127err_free: 129err_free:
@@ -143,7 +145,7 @@ vc4_save_hang_state(struct drm_device *dev)
143 unsigned long irqflags; 145 unsigned long irqflags;
144 unsigned int i, unref_list_count; 146 unsigned int i, unref_list_count;
145 147
146 kernel_state = kcalloc(1, sizeof(*state), GFP_KERNEL); 148 kernel_state = kcalloc(1, sizeof(*kernel_state), GFP_KERNEL);
147 if (!kernel_state) 149 if (!kernel_state)
148 return; 150 return;
149 151
@@ -554,34 +556,31 @@ vc4_get_bcl(struct drm_device *dev, struct vc4_exec_info *exec)
554 exec->shader_state = temp + exec_size; 556 exec->shader_state = temp + exec_size;
555 exec->shader_state_size = args->shader_rec_count; 557 exec->shader_state_size = args->shader_rec_count;
556 558
557 ret = copy_from_user(bin, 559 if (copy_from_user(bin,
558 (void __user *)(uintptr_t)args->bin_cl, 560 (void __user *)(uintptr_t)args->bin_cl,
559 args->bin_cl_size); 561 args->bin_cl_size)) {
560 if (ret) { 562 ret = -EFAULT;
561 DRM_ERROR("Failed to copy in bin cl\n");
562 goto fail; 563 goto fail;
563 } 564 }
564 565
565 ret = copy_from_user(exec->shader_rec_u, 566 if (copy_from_user(exec->shader_rec_u,
566 (void __user *)(uintptr_t)args->shader_rec, 567 (void __user *)(uintptr_t)args->shader_rec,
567 args->shader_rec_size); 568 args->shader_rec_size)) {
568 if (ret) { 569 ret = -EFAULT;
569 DRM_ERROR("Failed to copy in shader recs\n");
570 goto fail; 570 goto fail;
571 } 571 }
572 572
573 ret = copy_from_user(exec->uniforms_u, 573 if (copy_from_user(exec->uniforms_u,
574 (void __user *)(uintptr_t)args->uniforms, 574 (void __user *)(uintptr_t)args->uniforms,
575 args->uniforms_size); 575 args->uniforms_size)) {
576 if (ret) { 576 ret = -EFAULT;
577 DRM_ERROR("Failed to copy in uniforms cl\n");
578 goto fail; 577 goto fail;
579 } 578 }
580 579
581 bo = vc4_bo_create(dev, exec_size, true); 580 bo = vc4_bo_create(dev, exec_size, true);
582 if (!bo) { 581 if (!bo) {
583 DRM_ERROR("Couldn't allocate BO for binning\n"); 582 DRM_ERROR("Couldn't allocate BO for binning\n");
584 ret = PTR_ERR(exec->exec_bo); 583 ret = -ENOMEM;
585 goto fail; 584 goto fail;
586 } 585 }
587 exec->exec_bo = &bo->base; 586 exec->exec_bo = &bo->base;