diff options
Diffstat (limited to 'drivers/char/drm/i915_mem.c')
-rw-r--r-- | drivers/char/drm/i915_mem.c | 41 |
1 files changed, 21 insertions, 20 deletions
diff --git a/drivers/char/drm/i915_mem.c b/drivers/char/drm/i915_mem.c index d3ffad61c6b8..fa279da5be2c 100644 --- a/drivers/char/drm/i915_mem.c +++ b/drivers/char/drm/i915_mem.c | |||
@@ -89,7 +89,7 @@ static void mark_block(struct drm_device * dev, struct mem_block *p, int in_use) | |||
89 | */ | 89 | */ |
90 | 90 | ||
91 | static struct mem_block *split_block(struct mem_block *p, int start, int size, | 91 | static struct mem_block *split_block(struct mem_block *p, int start, int size, |
92 | DRMFILE filp) | 92 | struct drm_file *file_priv) |
93 | { | 93 | { |
94 | /* Maybe cut off the start of an existing block */ | 94 | /* Maybe cut off the start of an existing block */ |
95 | if (start > p->start) { | 95 | if (start > p->start) { |
@@ -99,7 +99,7 @@ static struct mem_block *split_block(struct mem_block *p, int start, int size, | |||
99 | goto out; | 99 | goto out; |
100 | newblock->start = start; | 100 | newblock->start = start; |
101 | newblock->size = p->size - (start - p->start); | 101 | newblock->size = p->size - (start - p->start); |
102 | newblock->filp = NULL; | 102 | newblock->file_priv = NULL; |
103 | newblock->next = p->next; | 103 | newblock->next = p->next; |
104 | newblock->prev = p; | 104 | newblock->prev = p; |
105 | p->next->prev = newblock; | 105 | p->next->prev = newblock; |
@@ -116,7 +116,7 @@ static struct mem_block *split_block(struct mem_block *p, int start, int size, | |||
116 | goto out; | 116 | goto out; |
117 | newblock->start = start + size; | 117 | newblock->start = start + size; |
118 | newblock->size = p->size - size; | 118 | newblock->size = p->size - size; |
119 | newblock->filp = NULL; | 119 | newblock->file_priv = NULL; |
120 | newblock->next = p->next; | 120 | newblock->next = p->next; |
121 | newblock->prev = p; | 121 | newblock->prev = p; |
122 | p->next->prev = newblock; | 122 | p->next->prev = newblock; |
@@ -126,20 +126,20 @@ static struct mem_block *split_block(struct mem_block *p, int start, int size, | |||
126 | 126 | ||
127 | out: | 127 | out: |
128 | /* Our block is in the middle */ | 128 | /* Our block is in the middle */ |
129 | p->filp = filp; | 129 | p->file_priv = file_priv; |
130 | return p; | 130 | return p; |
131 | } | 131 | } |
132 | 132 | ||
133 | static struct mem_block *alloc_block(struct mem_block *heap, int size, | 133 | static struct mem_block *alloc_block(struct mem_block *heap, int size, |
134 | int align2, DRMFILE filp) | 134 | int align2, struct drm_file *file_priv) |
135 | { | 135 | { |
136 | struct mem_block *p; | 136 | struct mem_block *p; |
137 | int mask = (1 << align2) - 1; | 137 | int mask = (1 << align2) - 1; |
138 | 138 | ||
139 | for (p = heap->next; p != heap; p = p->next) { | 139 | for (p = heap->next; p != heap; p = p->next) { |
140 | int start = (p->start + mask) & ~mask; | 140 | int start = (p->start + mask) & ~mask; |
141 | if (p->filp == NULL && start + size <= p->start + p->size) | 141 | if (p->file_priv == NULL && start + size <= p->start + p->size) |
142 | return split_block(p, start, size, filp); | 142 | return split_block(p, start, size, file_priv); |
143 | } | 143 | } |
144 | 144 | ||
145 | return NULL; | 145 | return NULL; |
@@ -158,12 +158,12 @@ static struct mem_block *find_block(struct mem_block *heap, int start) | |||
158 | 158 | ||
159 | static void free_block(struct mem_block *p) | 159 | static void free_block(struct mem_block *p) |
160 | { | 160 | { |
161 | p->filp = NULL; | 161 | p->file_priv = NULL; |
162 | 162 | ||
163 | /* Assumes a single contiguous range. Needs a special filp in | 163 | /* Assumes a single contiguous range. Needs a special file_priv in |
164 | * 'heap' to stop it being subsumed. | 164 | * 'heap' to stop it being subsumed. |
165 | */ | 165 | */ |
166 | if (p->next->filp == NULL) { | 166 | if (p->next->file_priv == NULL) { |
167 | struct mem_block *q = p->next; | 167 | struct mem_block *q = p->next; |
168 | p->size += q->size; | 168 | p->size += q->size; |
169 | p->next = q->next; | 169 | p->next = q->next; |
@@ -171,7 +171,7 @@ static void free_block(struct mem_block *p) | |||
171 | drm_free(q, sizeof(*q), DRM_MEM_BUFLISTS); | 171 | drm_free(q, sizeof(*q), DRM_MEM_BUFLISTS); |
172 | } | 172 | } |
173 | 173 | ||
174 | if (p->prev->filp == NULL) { | 174 | if (p->prev->file_priv == NULL) { |
175 | struct mem_block *q = p->prev; | 175 | struct mem_block *q = p->prev; |
176 | q->size += p->size; | 176 | q->size += p->size; |
177 | q->next = p->next; | 177 | q->next = p->next; |
@@ -197,18 +197,19 @@ static int init_heap(struct mem_block **heap, int start, int size) | |||
197 | 197 | ||
198 | blocks->start = start; | 198 | blocks->start = start; |
199 | blocks->size = size; | 199 | blocks->size = size; |
200 | blocks->filp = NULL; | 200 | blocks->file_priv = NULL; |
201 | blocks->next = blocks->prev = *heap; | 201 | blocks->next = blocks->prev = *heap; |
202 | 202 | ||
203 | memset(*heap, 0, sizeof(**heap)); | 203 | memset(*heap, 0, sizeof(**heap)); |
204 | (*heap)->filp = (DRMFILE) - 1; | 204 | (*heap)->file_priv = (struct drm_file *) - 1; |
205 | (*heap)->next = (*heap)->prev = blocks; | 205 | (*heap)->next = (*heap)->prev = blocks; |
206 | return 0; | 206 | return 0; |
207 | } | 207 | } |
208 | 208 | ||
209 | /* Free all blocks associated with the releasing file. | 209 | /* Free all blocks associated with the releasing file. |
210 | */ | 210 | */ |
211 | void i915_mem_release(struct drm_device * dev, DRMFILE filp, struct mem_block *heap) | 211 | void i915_mem_release(struct drm_device * dev, struct drm_file *file_priv, |
212 | struct mem_block *heap) | ||
212 | { | 213 | { |
213 | struct mem_block *p; | 214 | struct mem_block *p; |
214 | 215 | ||
@@ -216,17 +217,17 @@ void i915_mem_release(struct drm_device * dev, DRMFILE filp, struct mem_block *h | |||
216 | return; | 217 | return; |
217 | 218 | ||
218 | for (p = heap->next; p != heap; p = p->next) { | 219 | for (p = heap->next; p != heap; p = p->next) { |
219 | if (p->filp == filp) { | 220 | if (p->file_priv == file_priv) { |
220 | p->filp = NULL; | 221 | p->file_priv = NULL; |
221 | mark_block(dev, p, 0); | 222 | mark_block(dev, p, 0); |
222 | } | 223 | } |
223 | } | 224 | } |
224 | 225 | ||
225 | /* Assumes a single contiguous range. Needs a special filp in | 226 | /* Assumes a single contiguous range. Needs a special file_priv in |
226 | * 'heap' to stop it being subsumed. | 227 | * 'heap' to stop it being subsumed. |
227 | */ | 228 | */ |
228 | for (p = heap->next; p != heap; p = p->next) { | 229 | for (p = heap->next; p != heap; p = p->next) { |
229 | while (p->filp == NULL && p->next->filp == NULL) { | 230 | while (p->file_priv == NULL && p->next->file_priv == NULL) { |
230 | struct mem_block *q = p->next; | 231 | struct mem_block *q = p->next; |
231 | p->size += q->size; | 232 | p->size += q->size; |
232 | p->next = q->next; | 233 | p->next = q->next; |
@@ -292,7 +293,7 @@ int i915_mem_alloc(DRM_IOCTL_ARGS) | |||
292 | if (alloc.alignment < 12) | 293 | if (alloc.alignment < 12) |
293 | alloc.alignment = 12; | 294 | alloc.alignment = 12; |
294 | 295 | ||
295 | block = alloc_block(*heap, alloc.size, alloc.alignment, filp); | 296 | block = alloc_block(*heap, alloc.size, alloc.alignment, file_priv); |
296 | 297 | ||
297 | if (!block) | 298 | if (!block) |
298 | return -ENOMEM; | 299 | return -ENOMEM; |
@@ -330,7 +331,7 @@ int i915_mem_free(DRM_IOCTL_ARGS) | |||
330 | if (!block) | 331 | if (!block) |
331 | return -EFAULT; | 332 | return -EFAULT; |
332 | 333 | ||
333 | if (block->filp != filp) | 334 | if (block->file_priv != file_priv) |
334 | return -EPERM; | 335 | return -EPERM; |
335 | 336 | ||
336 | mark_block(dev, block, 0); | 337 | mark_block(dev, block, 0); |