diff options
author | Eric Anholt <eric@anholt.net> | 2007-09-02 22:06:45 -0400 |
---|---|---|
committer | Dave Airlie <airlied@optimus.(none)> | 2007-10-14 20:38:20 -0400 |
commit | c153f45f9b7e30289157bba3ff5682291df16caa (patch) | |
tree | 33f21e1ebd83ec548751f3d490afe6230ab99972 /drivers/char/drm/i915_mem.c | |
parent | b589ee5943a9610ebaea6e4e3433f2ae4d812b0b (diff) |
drm: Replace DRM_IOCTL_ARGS with (dev, data, file_priv) and remove DRM_DEVICE.
The data is now in kernel space, copied in/out as appropriate according to t
This results in DRM_COPY_{TO,FROM}_USER going away, and error paths to deal
with those failures. This also means that XFree86 4.2.0 support for i810 DR
is lost.
Signed-off-by: Dave Airlie <airlied@linux.ie>
Diffstat (limited to 'drivers/char/drm/i915_mem.c')
-rw-r--r-- | drivers/char/drm/i915_mem.c | 58 |
1 files changed, 23 insertions, 35 deletions
diff --git a/drivers/char/drm/i915_mem.c b/drivers/char/drm/i915_mem.c index fa279da5be2c..56fb9b30a5d7 100644 --- a/drivers/char/drm/i915_mem.c +++ b/drivers/char/drm/i915_mem.c | |||
@@ -268,11 +268,11 @@ static struct mem_block **get_heap(drm_i915_private_t * dev_priv, int region) | |||
268 | 268 | ||
269 | /* IOCTL HANDLERS */ | 269 | /* IOCTL HANDLERS */ |
270 | 270 | ||
271 | int i915_mem_alloc(DRM_IOCTL_ARGS) | 271 | int i915_mem_alloc(struct drm_device *dev, void *data, |
272 | struct drm_file *file_priv) | ||
272 | { | 273 | { |
273 | DRM_DEVICE; | ||
274 | drm_i915_private_t *dev_priv = dev->dev_private; | 274 | drm_i915_private_t *dev_priv = dev->dev_private; |
275 | drm_i915_mem_alloc_t alloc; | 275 | drm_i915_mem_alloc_t *alloc = data; |
276 | struct mem_block *block, **heap; | 276 | struct mem_block *block, **heap; |
277 | 277 | ||
278 | if (!dev_priv) { | 278 | if (!dev_priv) { |
@@ -280,27 +280,25 @@ int i915_mem_alloc(DRM_IOCTL_ARGS) | |||
280 | return -EINVAL; | 280 | return -EINVAL; |
281 | } | 281 | } |
282 | 282 | ||
283 | DRM_COPY_FROM_USER_IOCTL(alloc, (drm_i915_mem_alloc_t __user *) data, | 283 | heap = get_heap(dev_priv, alloc->region); |
284 | sizeof(alloc)); | ||
285 | |||
286 | heap = get_heap(dev_priv, alloc.region); | ||
287 | if (!heap || !*heap) | 284 | if (!heap || !*heap) |
288 | return -EFAULT; | 285 | return -EFAULT; |
289 | 286 | ||
290 | /* Make things easier on ourselves: all allocations at least | 287 | /* Make things easier on ourselves: all allocations at least |
291 | * 4k aligned. | 288 | * 4k aligned. |
292 | */ | 289 | */ |
293 | if (alloc.alignment < 12) | 290 | if (alloc->alignment < 12) |
294 | alloc.alignment = 12; | 291 | alloc->alignment = 12; |
295 | 292 | ||
296 | block = alloc_block(*heap, alloc.size, alloc.alignment, file_priv); | 293 | block = alloc_block(*heap, alloc->size, alloc->alignment, file_priv); |
297 | 294 | ||
298 | if (!block) | 295 | if (!block) |
299 | return -ENOMEM; | 296 | return -ENOMEM; |
300 | 297 | ||
301 | mark_block(dev, block, 1); | 298 | mark_block(dev, block, 1); |
302 | 299 | ||
303 | if (DRM_COPY_TO_USER(alloc.region_offset, &block->start, sizeof(int))) { | 300 | if (DRM_COPY_TO_USER(alloc->region_offset, &block->start, |
301 | sizeof(int))) { | ||
304 | DRM_ERROR("copy_to_user\n"); | 302 | DRM_ERROR("copy_to_user\n"); |
305 | return -EFAULT; | 303 | return -EFAULT; |
306 | } | 304 | } |
@@ -308,11 +306,11 @@ int i915_mem_alloc(DRM_IOCTL_ARGS) | |||
308 | return 0; | 306 | return 0; |
309 | } | 307 | } |
310 | 308 | ||
311 | int i915_mem_free(DRM_IOCTL_ARGS) | 309 | int i915_mem_free(struct drm_device *dev, void *data, |
310 | struct drm_file *file_priv) | ||
312 | { | 311 | { |
313 | DRM_DEVICE; | ||
314 | drm_i915_private_t *dev_priv = dev->dev_private; | 312 | drm_i915_private_t *dev_priv = dev->dev_private; |
315 | drm_i915_mem_free_t memfree; | 313 | drm_i915_mem_free_t *memfree = data; |
316 | struct mem_block *block, **heap; | 314 | struct mem_block *block, **heap; |
317 | 315 | ||
318 | if (!dev_priv) { | 316 | if (!dev_priv) { |
@@ -320,14 +318,11 @@ int i915_mem_free(DRM_IOCTL_ARGS) | |||
320 | return -EINVAL; | 318 | return -EINVAL; |
321 | } | 319 | } |
322 | 320 | ||
323 | DRM_COPY_FROM_USER_IOCTL(memfree, (drm_i915_mem_free_t __user *) data, | 321 | heap = get_heap(dev_priv, memfree->region); |
324 | sizeof(memfree)); | ||
325 | |||
326 | heap = get_heap(dev_priv, memfree.region); | ||
327 | if (!heap || !*heap) | 322 | if (!heap || !*heap) |
328 | return -EFAULT; | 323 | return -EFAULT; |
329 | 324 | ||
330 | block = find_block(*heap, memfree.region_offset); | 325 | block = find_block(*heap, memfree->region_offset); |
331 | if (!block) | 326 | if (!block) |
332 | return -EFAULT; | 327 | return -EFAULT; |
333 | 328 | ||
@@ -339,11 +334,11 @@ int i915_mem_free(DRM_IOCTL_ARGS) | |||
339 | return 0; | 334 | return 0; |
340 | } | 335 | } |
341 | 336 | ||
342 | int i915_mem_init_heap(DRM_IOCTL_ARGS) | 337 | int i915_mem_init_heap(struct drm_device *dev, void *data, |
338 | struct drm_file *file_priv) | ||
343 | { | 339 | { |
344 | DRM_DEVICE; | ||
345 | drm_i915_private_t *dev_priv = dev->dev_private; | 340 | drm_i915_private_t *dev_priv = dev->dev_private; |
346 | drm_i915_mem_init_heap_t initheap; | 341 | drm_i915_mem_init_heap_t *initheap = data; |
347 | struct mem_block **heap; | 342 | struct mem_block **heap; |
348 | 343 | ||
349 | if (!dev_priv) { | 344 | if (!dev_priv) { |
@@ -351,11 +346,7 @@ int i915_mem_init_heap(DRM_IOCTL_ARGS) | |||
351 | return -EINVAL; | 346 | return -EINVAL; |
352 | } | 347 | } |
353 | 348 | ||
354 | DRM_COPY_FROM_USER_IOCTL(initheap, | 349 | heap = get_heap(dev_priv, initheap->region); |
355 | (drm_i915_mem_init_heap_t __user *) data, | ||
356 | sizeof(initheap)); | ||
357 | |||
358 | heap = get_heap(dev_priv, initheap.region); | ||
359 | if (!heap) | 350 | if (!heap) |
360 | return -EFAULT; | 351 | return -EFAULT; |
361 | 352 | ||
@@ -364,14 +355,14 @@ int i915_mem_init_heap(DRM_IOCTL_ARGS) | |||
364 | return -EFAULT; | 355 | return -EFAULT; |
365 | } | 356 | } |
366 | 357 | ||
367 | return init_heap(heap, initheap.start, initheap.size); | 358 | return init_heap(heap, initheap->start, initheap->size); |
368 | } | 359 | } |
369 | 360 | ||
370 | int i915_mem_destroy_heap( DRM_IOCTL_ARGS ) | 361 | int i915_mem_destroy_heap( struct drm_device *dev, void *data, |
362 | struct drm_file *file_priv ) | ||
371 | { | 363 | { |
372 | DRM_DEVICE; | ||
373 | drm_i915_private_t *dev_priv = dev->dev_private; | 364 | drm_i915_private_t *dev_priv = dev->dev_private; |
374 | drm_i915_mem_destroy_heap_t destroyheap; | 365 | drm_i915_mem_destroy_heap_t *destroyheap = data; |
375 | struct mem_block **heap; | 366 | struct mem_block **heap; |
376 | 367 | ||
377 | if ( !dev_priv ) { | 368 | if ( !dev_priv ) { |
@@ -379,10 +370,7 @@ int i915_mem_destroy_heap( DRM_IOCTL_ARGS ) | |||
379 | return -EINVAL; | 370 | return -EINVAL; |
380 | } | 371 | } |
381 | 372 | ||
382 | DRM_COPY_FROM_USER_IOCTL( destroyheap, (drm_i915_mem_destroy_heap_t *)data, | 373 | heap = get_heap( dev_priv, destroyheap->region ); |
383 | sizeof(destroyheap) ); | ||
384 | |||
385 | heap = get_heap( dev_priv, destroyheap.region ); | ||
386 | if (!heap) { | 374 | if (!heap) { |
387 | DRM_ERROR("get_heap failed"); | 375 | DRM_ERROR("get_heap failed"); |
388 | return -EFAULT; | 376 | return -EFAULT; |