aboutsummaryrefslogtreecommitdiffstats
path: root/drivers/char/drm/i915_dma.c
diff options
context:
space:
mode:
Diffstat (limited to 'drivers/char/drm/i915_dma.c')
-rw-r--r--drivers/char/drm/i915_dma.c42
1 files changed, 30 insertions, 12 deletions
diff --git a/drivers/char/drm/i915_dma.c b/drivers/char/drm/i915_dma.c
index 9140703da1ba..1ff4c7ca0bff 100644
--- a/drivers/char/drm/i915_dma.c
+++ b/drivers/char/drm/i915_dma.c
@@ -344,18 +344,20 @@ static int i915_emit_cmds(drm_device_t * dev, int __user * buffer, int dwords)
344 int i; 344 int i;
345 RING_LOCALS; 345 RING_LOCALS;
346 346
347 if ((dwords+1) * sizeof(int) >= dev_priv->ring.Size - 8)
348 return DRM_ERR(EINVAL);
349
350 BEGIN_LP_RING(((dwords+1)&~1));
351
347 for (i = 0; i < dwords;) { 352 for (i = 0; i < dwords;) {
348 int cmd, sz; 353 int cmd, sz;
349 354
350 if (DRM_COPY_FROM_USER_UNCHECKED(&cmd, &buffer[i], sizeof(cmd))) 355 if (DRM_COPY_FROM_USER_UNCHECKED(&cmd, &buffer[i], sizeof(cmd)))
351 return DRM_ERR(EINVAL); 356 return DRM_ERR(EINVAL);
352 357
353/* printk("%d/%d ", i, dwords); */
354
355 if ((sz = validate_cmd(cmd)) == 0 || i + sz > dwords) 358 if ((sz = validate_cmd(cmd)) == 0 || i + sz > dwords)
356 return DRM_ERR(EINVAL); 359 return DRM_ERR(EINVAL);
357 360
358 BEGIN_LP_RING(sz);
359 OUT_RING(cmd); 361 OUT_RING(cmd);
360 362
361 while (++i, --sz) { 363 while (++i, --sz) {
@@ -365,9 +367,13 @@ static int i915_emit_cmds(drm_device_t * dev, int __user * buffer, int dwords)
365 } 367 }
366 OUT_RING(cmd); 368 OUT_RING(cmd);
367 } 369 }
368 ADVANCE_LP_RING();
369 } 370 }
370 371
372 if (dwords & 1)
373 OUT_RING(0);
374
375 ADVANCE_LP_RING();
376
371 return 0; 377 return 0;
372} 378}
373 379
@@ -401,6 +407,21 @@ static int i915_emit_box(drm_device_t * dev,
401 return 0; 407 return 0;
402} 408}
403 409
410static void i915_emit_breadcrumb(drm_device_t *dev)
411{
412 drm_i915_private_t *dev_priv = dev->dev_private;
413 RING_LOCALS;
414
415 dev_priv->sarea_priv->last_enqueue = dev_priv->counter++;
416
417 BEGIN_LP_RING(4);
418 OUT_RING(CMD_STORE_DWORD_IDX);
419 OUT_RING(20);
420 OUT_RING(dev_priv->counter);
421 OUT_RING(0);
422 ADVANCE_LP_RING();
423}
424
404static int i915_dispatch_cmdbuffer(drm_device_t * dev, 425static int i915_dispatch_cmdbuffer(drm_device_t * dev,
405 drm_i915_cmdbuffer_t * cmd) 426 drm_i915_cmdbuffer_t * cmd)
406{ 427{
@@ -429,6 +450,7 @@ static int i915_dispatch_cmdbuffer(drm_device_t * dev,
429 return ret; 450 return ret;
430 } 451 }
431 452
453 i915_emit_breadcrumb(dev);
432 return 0; 454 return 0;
433} 455}
434 456
@@ -475,12 +497,7 @@ static int i915_dispatch_batchbuffer(drm_device_t * dev,
475 497
476 dev_priv->sarea_priv->last_enqueue = dev_priv->counter++; 498 dev_priv->sarea_priv->last_enqueue = dev_priv->counter++;
477 499
478 BEGIN_LP_RING(4); 500 i915_emit_breadcrumb(dev);
479 OUT_RING(CMD_STORE_DWORD_IDX);
480 OUT_RING(20);
481 OUT_RING(dev_priv->counter);
482 OUT_RING(0);
483 ADVANCE_LP_RING();
484 501
485 return 0; 502 return 0;
486} 503}
@@ -657,7 +674,7 @@ static int i915_getparam(DRM_IOCTL_ARGS)
657 value = READ_BREADCRUMB(dev_priv); 674 value = READ_BREADCRUMB(dev_priv);
658 break; 675 break;
659 default: 676 default:
660 DRM_ERROR("Unkown parameter %d\n", param.param); 677 DRM_ERROR("Unknown parameter %d\n", param.param);
661 return DRM_ERR(EINVAL); 678 return DRM_ERR(EINVAL);
662 } 679 }
663 680
@@ -742,7 +759,8 @@ drm_ioctl_desc_t i915_ioctls[] = {
742 [DRM_IOCTL_NR(DRM_I915_ALLOC)] = {i915_mem_alloc, DRM_AUTH}, 759 [DRM_IOCTL_NR(DRM_I915_ALLOC)] = {i915_mem_alloc, DRM_AUTH},
743 [DRM_IOCTL_NR(DRM_I915_FREE)] = {i915_mem_free, DRM_AUTH}, 760 [DRM_IOCTL_NR(DRM_I915_FREE)] = {i915_mem_free, DRM_AUTH},
744 [DRM_IOCTL_NR(DRM_I915_INIT_HEAP)] = {i915_mem_init_heap, DRM_AUTH|DRM_MASTER|DRM_ROOT_ONLY}, 761 [DRM_IOCTL_NR(DRM_I915_INIT_HEAP)] = {i915_mem_init_heap, DRM_AUTH|DRM_MASTER|DRM_ROOT_ONLY},
745 [DRM_IOCTL_NR(DRM_I915_CMDBUFFER)] = {i915_cmdbuffer, DRM_AUTH} 762 [DRM_IOCTL_NR(DRM_I915_CMDBUFFER)] = {i915_cmdbuffer, DRM_AUTH},
763 [DRM_IOCTL_NR(DRM_I915_DESTROY_HEAP)] = { i915_mem_destroy_heap, DRM_AUTH|DRM_MASTER|DRM_ROOT_ONLY }
746}; 764};
747 765
748int i915_max_ioctl = DRM_ARRAY_SIZE(i915_ioctls); 766int i915_max_ioctl = DRM_ARRAY_SIZE(i915_ioctls);