]> code.ossystems Code Review - openembedded-core.git/blob
542b69dd52aa36b750e4286658c6ed713355f007
[openembedded-core.git] /
1 commit 69749cf99189a8a78de201ac24990c91ee111469
2 Author: Kristian Høgsberg <krh@redhat.com>
3 Date:   Wed Aug 20 11:20:13 2008 -0400
4
5     i915: Make use of sarea_priv conditional.
6     
7     We fail ioctls that depend on the sarea_priv with EINVAL.
8     
9     Signed-off-by: Kristian Høgsberg <krh@redhat.com>
10     Signed-off-by: Eric Anholt <eric@anholt.net>
11
12 diff --git a/drivers/gpu/drm/i915/i915_dma.c b/drivers/gpu/drm/i915/i915_dma.c
13 index 25f59c1..dbd3f49 100644
14 --- a/drivers/gpu/drm/i915/i915_dma.c
15 +++ b/drivers/gpu/drm/i915/i915_dma.c
16 @@ -55,7 +55,8 @@ int i915_wait_ring(struct drm_device * dev, int n, const char *caller)
17                 if (ring->space >= n)
18                         return 0;
19  
20 -               dev_priv->sarea_priv->perf_boxes |= I915_BOX_WAIT;
21 +               if (dev_priv->sarea_priv)
22 +                       dev_priv->sarea_priv->perf_boxes |= I915_BOX_WAIT;
23  
24                 if (ring->head != last_head)
25                         i = 0;
26 @@ -128,7 +129,7 @@ void i915_kernel_lost_context(struct drm_device * dev)
27         if (ring->space < 0)
28                 ring->space += ring->Size;
29  
30 -       if (ring->head == ring->tail)
31 +       if (ring->head == ring->tail && dev_priv->sarea_priv)
32                 dev_priv->sarea_priv->perf_boxes |= I915_BOX_RING_EMPTY;
33  }
34  
35 @@ -433,10 +434,11 @@ static void i915_emit_breadcrumb(struct drm_device *dev)
36         drm_i915_private_t *dev_priv = dev->dev_private;
37         RING_LOCALS;
38  
39 -       dev_priv->sarea_priv->last_enqueue = ++dev_priv->counter;
40 -
41 +       dev_priv->counter++;
42         if (dev_priv->counter > 0x7FFFFFFFUL)
43 -               dev_priv->sarea_priv->last_enqueue = dev_priv->counter = 1;
44 +               dev_priv->counter = 0;
45 +       if (dev_priv->sarea_priv)
46 +               dev_priv->sarea_priv->last_enqueue = dev_priv->counter;
47  
48         BEGIN_LP_RING(4);
49         OUT_RING(MI_STORE_DWORD_INDEX);
50 @@ -534,6 +536,9 @@ static int i915_dispatch_flip(struct drm_device * dev)
51         drm_i915_private_t *dev_priv = dev->dev_private;
52         RING_LOCALS;
53  
54 +       if (!dev_priv->sarea_priv)
55 +               return -EINVAL;
56 +
57         DRM_DEBUG("%s: page=%d pfCurrentPage=%d\n",
58                   __FUNCTION__,
59                   dev_priv->current_page,
60 @@ -628,7 +633,8 @@ static int i915_batchbuffer(struct drm_device *dev, void *data,
61         ret = i915_dispatch_batchbuffer(dev, batch);
62         mutex_unlock(&dev->struct_mutex);
63  
64 -       sarea_priv->last_dispatch = (int)hw_status[5];
65 +       if (sarea_priv)
66 +               sarea_priv->last_dispatch = (int)hw_status[5];
67         return ret;
68  }
69  
70 @@ -663,7 +669,8 @@ static int i915_cmdbuffer(struct drm_device *dev, void *data,
71                 return ret;
72         }
73  
74 -       sarea_priv->last_dispatch = (int)hw_status[5];
75 +       if (sarea_priv)
76 +               sarea_priv->last_dispatch = (int)hw_status[5];
77         return 0;
78  }
79  
80 diff --git a/drivers/gpu/drm/i915/i915_irq.c b/drivers/gpu/drm/i915/i915_irq.c
81 index d04c526..ef03a59 100644
82 --- a/drivers/gpu/drm/i915/i915_irq.c
83 +++ b/drivers/gpu/drm/i915/i915_irq.c
84 @@ -427,7 +427,9 @@ irqreturn_t i915_driver_irq_handler(DRM_IRQ_ARGS)
85                 I915_WRITE(IMR, dev_priv->irq_mask_reg);
86         (void) I915_READ(IIR); /* Flush posted writes */
87  
88 -       dev_priv->sarea_priv->last_dispatch = READ_BREADCRUMB(dev_priv);
89 +       if (dev_priv->sarea_priv)
90 +               dev_priv->sarea_priv->last_dispatch =
91 +                       READ_BREADCRUMB(dev_priv);
92  
93         if (iir & I915_USER_INTERRUPT) {
94                 dev_priv->mm.irq_gem_seqno = i915_get_gem_seqno(dev);
95 @@ -456,10 +458,11 @@ static int i915_emit_irq(struct drm_device * dev)
96  
97         DRM_DEBUG("\n");
98  
99 -       dev_priv->sarea_priv->last_enqueue = ++dev_priv->counter;
100 -
101 +       dev_priv->counter++;
102         if (dev_priv->counter > 0x7FFFFFFFUL)
103 -               dev_priv->sarea_priv->last_enqueue = dev_priv->counter = 1;
104 +               dev_priv->counter = 1;
105 +       if (dev_priv->sarea_priv)
106 +               dev_priv->sarea_priv->last_enqueue = dev_priv->counter;
107  
108         BEGIN_LP_RING(6);
109         OUT_RING(MI_STORE_DWORD_INDEX);
110 @@ -503,11 +506,15 @@ static int i915_wait_irq(struct drm_device * dev, int irq_nr)
111                   READ_BREADCRUMB(dev_priv));
112  
113         if (READ_BREADCRUMB(dev_priv) >= irq_nr) {
114 -               dev_priv->sarea_priv->last_dispatch = READ_BREADCRUMB(dev_priv);
115 +               if (dev_priv->sarea_priv) {
116 +                       dev_priv->sarea_priv->last_dispatch =
117 +                               READ_BREADCRUMB(dev_priv);
118 +               }
119                 return 0;
120         }
121  
122 -       dev_priv->sarea_priv->perf_boxes |= I915_BOX_WAIT;
123 +       if (dev_priv->sarea_priv)
124 +               dev_priv->sarea_priv->perf_boxes |= I915_BOX_WAIT;
125  
126         i915_user_irq_get(dev);
127         DRM_WAIT_ON(ret, dev_priv->irq_queue, 3 * DRM_HZ,
128 @@ -519,7 +526,9 @@ static int i915_wait_irq(struct drm_device * dev, int irq_nr)
129                           READ_BREADCRUMB(dev_priv), (int)dev_priv->counter);
130         }
131  
132 -       dev_priv->sarea_priv->last_dispatch = READ_BREADCRUMB(dev_priv);
133 +       if (dev_priv->sarea_priv)
134 +               dev_priv->sarea_priv->last_dispatch =
135 +                       READ_BREADCRUMB(dev_priv);
136  
137         return ret;
138  }
139 @@ -682,7 +691,7 @@ int i915_vblank_swap(struct drm_device *dev, void *data,
140         struct list_head *list;
141         int ret;
142  
143 -       if (!dev_priv) {
144 +       if (!dev_priv || !dev_priv->sarea_priv) {
145                 DRM_ERROR("%s called with no initialization\n", __func__);
146                 return -EINVAL;
147         }