aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorKristian Høgsberg <krh@redhat.com>2008-08-20 11:20:13 -0400
committerDave Airlie <airlied@linux.ie>2008-10-17 17:10:51 -0400
commitc99b058f132388a666544d293392d52d1def6b12 (patch)
treed9417f12dfa2957af7c0fa86f47be29691c0cd97
parent546b0974c39657017407c86fe79811100b60700d (diff)
i915: Make use of sarea_priv conditional.
We fail ioctls that depend on the sarea_priv with EINVAL. Signed-off-by: Kristian Høgsberg <krh@redhat.com> Signed-off-by: Eric Anholt <eric@anholt.net> Signed-off-by: Dave Airlie <airlied@redhat.com>
-rw-r--r--drivers/gpu/drm/i915/i915_dma.c21
-rw-r--r--drivers/gpu/drm/i915/i915_irq.c25
2 files changed, 31 insertions, 15 deletions
diff --git a/drivers/gpu/drm/i915/i915_dma.c b/drivers/gpu/drm/i915/i915_dma.c
index d71c89f8802e..048da791ca66 100644
--- a/drivers/gpu/drm/i915/i915_dma.c
+++ b/drivers/gpu/drm/i915/i915_dma.c
@@ -55,7 +55,8 @@ int i915_wait_ring(struct drm_device * dev, int n, const char *caller)
55 if (ring->space >= n) 55 if (ring->space >= n)
56 return 0; 56 return 0;
57 57
58 dev_priv->sarea_priv->perf_boxes |= I915_BOX_WAIT; 58 if (dev_priv->sarea_priv)
59 dev_priv->sarea_priv->perf_boxes |= I915_BOX_WAIT;
59 60
60 if (ring->head != last_head) 61 if (ring->head != last_head)
61 i = 0; 62 i = 0;
@@ -128,7 +129,7 @@ void i915_kernel_lost_context(struct drm_device * dev)
128 if (ring->space < 0) 129 if (ring->space < 0)
129 ring->space += ring->Size; 130 ring->space += ring->Size;
130 131
131 if (ring->head == ring->tail) 132 if (ring->head == ring->tail && dev_priv->sarea_priv)
132 dev_priv->sarea_priv->perf_boxes |= I915_BOX_RING_EMPTY; 133 dev_priv->sarea_priv->perf_boxes |= I915_BOX_RING_EMPTY;
133} 134}
134 135
@@ -433,10 +434,11 @@ static void i915_emit_breadcrumb(struct drm_device *dev)
433 drm_i915_private_t *dev_priv = dev->dev_private; 434 drm_i915_private_t *dev_priv = dev->dev_private;
434 RING_LOCALS; 435 RING_LOCALS;
435 436
436 dev_priv->sarea_priv->last_enqueue = ++dev_priv->counter; 437 dev_priv->counter++;
437
438 if (dev_priv->counter > 0x7FFFFFFFUL) 438 if (dev_priv->counter > 0x7FFFFFFFUL)
439 dev_priv->sarea_priv->last_enqueue = dev_priv->counter = 1; 439 dev_priv->counter = 0;
440 if (dev_priv->sarea_priv)
441 dev_priv->sarea_priv->last_enqueue = dev_priv->counter;
440 442
441 BEGIN_LP_RING(4); 443 BEGIN_LP_RING(4);
442 OUT_RING(MI_STORE_DWORD_INDEX); 444 OUT_RING(MI_STORE_DWORD_INDEX);
@@ -534,6 +536,9 @@ static int i915_dispatch_flip(struct drm_device * dev)
534 drm_i915_private_t *dev_priv = dev->dev_private; 536 drm_i915_private_t *dev_priv = dev->dev_private;
535 RING_LOCALS; 537 RING_LOCALS;
536 538
539 if (!dev_priv->sarea_priv)
540 return -EINVAL;
541
537 DRM_DEBUG("%s: page=%d pfCurrentPage=%d\n", 542 DRM_DEBUG("%s: page=%d pfCurrentPage=%d\n",
538 __func__, 543 __func__,
539 dev_priv->current_page, 544 dev_priv->current_page,
@@ -628,7 +633,8 @@ static int i915_batchbuffer(struct drm_device *dev, void *data,
628 ret = i915_dispatch_batchbuffer(dev, batch); 633 ret = i915_dispatch_batchbuffer(dev, batch);
629 mutex_unlock(&dev->struct_mutex); 634 mutex_unlock(&dev->struct_mutex);
630 635
631 sarea_priv->last_dispatch = (int)hw_status[5]; 636 if (sarea_priv)
637 sarea_priv->last_dispatch = (int)hw_status[5];
632 return ret; 638 return ret;
633} 639}
634 640
@@ -663,7 +669,8 @@ static int i915_cmdbuffer(struct drm_device *dev, void *data,
663 return ret; 669 return ret;
664 } 670 }
665 671
666 sarea_priv->last_dispatch = (int)hw_status[5]; 672 if (sarea_priv)
673 sarea_priv->last_dispatch = (int)hw_status[5];
667 return 0; 674 return 0;
668} 675}
669 676
diff --git a/drivers/gpu/drm/i915/i915_irq.c b/drivers/gpu/drm/i915/i915_irq.c
index d04c526410a9..ef03a59c1df8 100644
--- a/drivers/gpu/drm/i915/i915_irq.c
+++ b/drivers/gpu/drm/i915/i915_irq.c
@@ -427,7 +427,9 @@ irqreturn_t i915_driver_irq_handler(DRM_IRQ_ARGS)
427 I915_WRITE(IMR, dev_priv->irq_mask_reg); 427 I915_WRITE(IMR, dev_priv->irq_mask_reg);
428 (void) I915_READ(IIR); /* Flush posted writes */ 428 (void) I915_READ(IIR); /* Flush posted writes */
429 429
430 dev_priv->sarea_priv->last_dispatch = READ_BREADCRUMB(dev_priv); 430 if (dev_priv->sarea_priv)
431 dev_priv->sarea_priv->last_dispatch =
432 READ_BREADCRUMB(dev_priv);
431 433
432 if (iir & I915_USER_INTERRUPT) { 434 if (iir & I915_USER_INTERRUPT) {
433 dev_priv->mm.irq_gem_seqno = i915_get_gem_seqno(dev); 435 dev_priv->mm.irq_gem_seqno = i915_get_gem_seqno(dev);
@@ -456,10 +458,11 @@ static int i915_emit_irq(struct drm_device * dev)
456 458
457 DRM_DEBUG("\n"); 459 DRM_DEBUG("\n");
458 460
459 dev_priv->sarea_priv->last_enqueue = ++dev_priv->counter; 461 dev_priv->counter++;
460
461 if (dev_priv->counter > 0x7FFFFFFFUL) 462 if (dev_priv->counter > 0x7FFFFFFFUL)
462 dev_priv->sarea_priv->last_enqueue = dev_priv->counter = 1; 463 dev_priv->counter = 1;
464 if (dev_priv->sarea_priv)
465 dev_priv->sarea_priv->last_enqueue = dev_priv->counter;
463 466
464 BEGIN_LP_RING(6); 467 BEGIN_LP_RING(6);
465 OUT_RING(MI_STORE_DWORD_INDEX); 468 OUT_RING(MI_STORE_DWORD_INDEX);
@@ -503,11 +506,15 @@ static int i915_wait_irq(struct drm_device * dev, int irq_nr)
503 READ_BREADCRUMB(dev_priv)); 506 READ_BREADCRUMB(dev_priv));
504 507
505 if (READ_BREADCRUMB(dev_priv) >= irq_nr) { 508 if (READ_BREADCRUMB(dev_priv) >= irq_nr) {
506 dev_priv->sarea_priv->last_dispatch = READ_BREADCRUMB(dev_priv); 509 if (dev_priv->sarea_priv) {
510 dev_priv->sarea_priv->last_dispatch =
511 READ_BREADCRUMB(dev_priv);
512 }
507 return 0; 513 return 0;
508 } 514 }
509 515
510 dev_priv->sarea_priv->perf_boxes |= I915_BOX_WAIT; 516 if (dev_priv->sarea_priv)
517 dev_priv->sarea_priv->perf_boxes |= I915_BOX_WAIT;
511 518
512 i915_user_irq_get(dev); 519 i915_user_irq_get(dev);
513 DRM_WAIT_ON(ret, dev_priv->irq_queue, 3 * DRM_HZ, 520 DRM_WAIT_ON(ret, dev_priv->irq_queue, 3 * DRM_HZ,
@@ -519,7 +526,9 @@ static int i915_wait_irq(struct drm_device * dev, int irq_nr)
519 READ_BREADCRUMB(dev_priv), (int)dev_priv->counter); 526 READ_BREADCRUMB(dev_priv), (int)dev_priv->counter);
520 } 527 }
521 528
522 dev_priv->sarea_priv->last_dispatch = READ_BREADCRUMB(dev_priv); 529 if (dev_priv->sarea_priv)
530 dev_priv->sarea_priv->last_dispatch =
531 READ_BREADCRUMB(dev_priv);
523 532
524 return ret; 533 return ret;
525} 534}
@@ -682,7 +691,7 @@ int i915_vblank_swap(struct drm_device *dev, void *data,
682 struct list_head *list; 691 struct list_head *list;
683 int ret; 692 int ret;
684 693
685 if (!dev_priv) { 694 if (!dev_priv || !dev_priv->sarea_priv) {
686 DRM_ERROR("%s called with no initialization\n", __func__); 695 DRM_ERROR("%s called with no initialization\n", __func__);
687 return -EINVAL; 696 return -EINVAL;
688 } 697 }