diff options
author | Benjamin Herrenschmidt <benh@kernel.crashing.org> | 2009-02-02 00:55:46 -0500 |
---|---|---|
committer | Dave Airlie <airlied@redhat.com> | 2009-03-13 00:23:56 -0400 |
commit | f77d390c9779c496aa5b99ec832996fb76bb1d13 (patch) | |
tree | 3e3cccc4ac9416457a944d13b31ef942432717f2 /drivers/gpu/drm/drm_bufs.c | |
parent | d883f7f1b75c8dcafa891f7b9e69c5a2f0ff6d66 (diff) |
drm: Split drm_map and drm_local_map
Once upon a time, the DRM made the distinction between the drm_map
data structure exchanged with user space and the drm_local_map used
in the kernel.
For some reasons, while the BSD port still has that "feature", the
linux part abused drm_map for kernel internal usage as the local
map only existed as a typedef of the struct drm_map.
This patch fixes it by declaring struct drm_local_map separately
(though its content is currently identical to the userspace variant),
and changing the kernel code to only use that, except when it's a
user<->kernel interface (ie. ioctl).
This allows subsequent changes to the in-kernel format
I've also replaced the use of drm_local_map_t with struct drm_local_map
in a couple of places. Mostly by accident but they are the same (the
former is a typedef of the later) and I have some remote plans and
half finished patch to completely kill the drm_local_map_t typedef
so I left those bits in.
Signed-off-by: Benjamin Herrenschmidt <benh@kernel.crashing.org>
Acked-by: Eric Anholt <eric@anholt.net>
Signed-off-by: Dave Airlie <airlied@linux.ie>
Diffstat (limited to 'drivers/gpu/drm/drm_bufs.c')
-rw-r--r-- | drivers/gpu/drm/drm_bufs.c | 46 |
1 files changed, 26 insertions, 20 deletions
diff --git a/drivers/gpu/drm/drm_bufs.c b/drivers/gpu/drm/drm_bufs.c index fab899eec051..1b8dbd5961bc 100644 --- a/drivers/gpu/drm/drm_bufs.c +++ b/drivers/gpu/drm/drm_bufs.c | |||
@@ -50,7 +50,7 @@ resource_size_t drm_get_resource_len(struct drm_device *dev, unsigned int resour | |||
50 | EXPORT_SYMBOL(drm_get_resource_len); | 50 | EXPORT_SYMBOL(drm_get_resource_len); |
51 | 51 | ||
52 | static struct drm_map_list *drm_find_matching_map(struct drm_device *dev, | 52 | static struct drm_map_list *drm_find_matching_map(struct drm_device *dev, |
53 | drm_local_map_t *map) | 53 | struct drm_local_map *map) |
54 | { | 54 | { |
55 | struct drm_map_list *entry; | 55 | struct drm_map_list *entry; |
56 | list_for_each_entry(entry, &dev->maplist, head) { | 56 | list_for_each_entry(entry, &dev->maplist, head) { |
@@ -89,13 +89,8 @@ static int drm_map_handle(struct drm_device *dev, struct drm_hash_item *hash, | |||
89 | } | 89 | } |
90 | 90 | ||
91 | /** | 91 | /** |
92 | * Ioctl to specify a range of memory that is available for mapping by a non-root process. | 92 | * Core function to create a range of memory available for mapping by a |
93 | * | 93 | * non-root process. |
94 | * \param inode device inode. | ||
95 | * \param file_priv DRM file private. | ||
96 | * \param cmd command. | ||
97 | * \param arg pointer to a drm_map structure. | ||
98 | * \return zero on success or a negative value on error. | ||
99 | * | 94 | * |
100 | * Adjusts the memory offset to its absolute value according to the mapping | 95 | * Adjusts the memory offset to its absolute value according to the mapping |
101 | * type. Adds the map to the map list drm_device::maplist. Adds MTRR's where | 96 | * type. Adds the map to the map list drm_device::maplist. Adds MTRR's where |
@@ -106,7 +101,7 @@ static int drm_addmap_core(struct drm_device * dev, unsigned int offset, | |||
106 | enum drm_map_flags flags, | 101 | enum drm_map_flags flags, |
107 | struct drm_map_list ** maplist) | 102 | struct drm_map_list ** maplist) |
108 | { | 103 | { |
109 | struct drm_map *map; | 104 | struct drm_local_map *map; |
110 | struct drm_map_list *list; | 105 | struct drm_map_list *list; |
111 | drm_dma_handle_t *dmah; | 106 | drm_dma_handle_t *dmah; |
112 | unsigned long user_token; | 107 | unsigned long user_token; |
@@ -329,7 +324,7 @@ static int drm_addmap_core(struct drm_device * dev, unsigned int offset, | |||
329 | 324 | ||
330 | int drm_addmap(struct drm_device * dev, unsigned int offset, | 325 | int drm_addmap(struct drm_device * dev, unsigned int offset, |
331 | unsigned int size, enum drm_map_type type, | 326 | unsigned int size, enum drm_map_type type, |
332 | enum drm_map_flags flags, drm_local_map_t ** map_ptr) | 327 | enum drm_map_flags flags, struct drm_local_map ** map_ptr) |
333 | { | 328 | { |
334 | struct drm_map_list *list; | 329 | struct drm_map_list *list; |
335 | int rc; | 330 | int rc; |
@@ -342,6 +337,17 @@ int drm_addmap(struct drm_device * dev, unsigned int offset, | |||
342 | 337 | ||
343 | EXPORT_SYMBOL(drm_addmap); | 338 | EXPORT_SYMBOL(drm_addmap); |
344 | 339 | ||
340 | /** | ||
341 | * Ioctl to specify a range of memory that is available for mapping by a | ||
342 | * non-root process. | ||
343 | * | ||
344 | * \param inode device inode. | ||
345 | * \param file_priv DRM file private. | ||
346 | * \param cmd command. | ||
347 | * \param arg pointer to a drm_map structure. | ||
348 | * \return zero on success or a negative value on error. | ||
349 | * | ||
350 | */ | ||
345 | int drm_addmap_ioctl(struct drm_device *dev, void *data, | 351 | int drm_addmap_ioctl(struct drm_device *dev, void *data, |
346 | struct drm_file *file_priv) | 352 | struct drm_file *file_priv) |
347 | { | 353 | { |
@@ -367,19 +373,13 @@ int drm_addmap_ioctl(struct drm_device *dev, void *data, | |||
367 | * Remove a map private from list and deallocate resources if the mapping | 373 | * Remove a map private from list and deallocate resources if the mapping |
368 | * isn't in use. | 374 | * isn't in use. |
369 | * | 375 | * |
370 | * \param inode device inode. | ||
371 | * \param file_priv DRM file private. | ||
372 | * \param cmd command. | ||
373 | * \param arg pointer to a struct drm_map structure. | ||
374 | * \return zero on success or a negative value on error. | ||
375 | * | ||
376 | * Searches the map on drm_device::maplist, removes it from the list, see if | 376 | * Searches the map on drm_device::maplist, removes it from the list, see if |
377 | * its being used, and free any associate resource (such as MTRR's) if it's not | 377 | * its being used, and free any associate resource (such as MTRR's) if it's not |
378 | * being on use. | 378 | * being on use. |
379 | * | 379 | * |
380 | * \sa drm_addmap | 380 | * \sa drm_addmap |
381 | */ | 381 | */ |
382 | int drm_rmmap_locked(struct drm_device *dev, drm_local_map_t *map) | 382 | int drm_rmmap_locked(struct drm_device *dev, struct drm_local_map *map) |
383 | { | 383 | { |
384 | struct drm_map_list *r_list = NULL, *list_t; | 384 | struct drm_map_list *r_list = NULL, *list_t; |
385 | drm_dma_handle_t dmah; | 385 | drm_dma_handle_t dmah; |
@@ -442,7 +442,7 @@ int drm_rmmap_locked(struct drm_device *dev, drm_local_map_t *map) | |||
442 | } | 442 | } |
443 | EXPORT_SYMBOL(drm_rmmap_locked); | 443 | EXPORT_SYMBOL(drm_rmmap_locked); |
444 | 444 | ||
445 | int drm_rmmap(struct drm_device *dev, drm_local_map_t *map) | 445 | int drm_rmmap(struct drm_device *dev, struct drm_local_map *map) |
446 | { | 446 | { |
447 | int ret; | 447 | int ret; |
448 | 448 | ||
@@ -462,12 +462,18 @@ EXPORT_SYMBOL(drm_rmmap); | |||
462 | * One use case might be after addmap is allowed for normal users for SHM and | 462 | * One use case might be after addmap is allowed for normal users for SHM and |
463 | * gets used by drivers that the server doesn't need to care about. This seems | 463 | * gets used by drivers that the server doesn't need to care about. This seems |
464 | * unlikely. | 464 | * unlikely. |
465 | * | ||
466 | * \param inode device inode. | ||
467 | * \param file_priv DRM file private. | ||
468 | * \param cmd command. | ||
469 | * \param arg pointer to a struct drm_map structure. | ||
470 | * \return zero on success or a negative value on error. | ||
465 | */ | 471 | */ |
466 | int drm_rmmap_ioctl(struct drm_device *dev, void *data, | 472 | int drm_rmmap_ioctl(struct drm_device *dev, void *data, |
467 | struct drm_file *file_priv) | 473 | struct drm_file *file_priv) |
468 | { | 474 | { |
469 | struct drm_map *request = data; | 475 | struct drm_map *request = data; |
470 | drm_local_map_t *map = NULL; | 476 | struct drm_local_map *map = NULL; |
471 | struct drm_map_list *r_list; | 477 | struct drm_map_list *r_list; |
472 | int ret; | 478 | int ret; |
473 | 479 | ||
@@ -1534,7 +1540,7 @@ int drm_mapbufs(struct drm_device *dev, void *data, | |||
1534 | && (dma->flags & _DRM_DMA_USE_SG)) | 1540 | && (dma->flags & _DRM_DMA_USE_SG)) |
1535 | || (drm_core_check_feature(dev, DRIVER_FB_DMA) | 1541 | || (drm_core_check_feature(dev, DRIVER_FB_DMA) |
1536 | && (dma->flags & _DRM_DMA_USE_FB))) { | 1542 | && (dma->flags & _DRM_DMA_USE_FB))) { |
1537 | struct drm_map *map = dev->agp_buffer_map; | 1543 | struct drm_local_map *map = dev->agp_buffer_map; |
1538 | unsigned long token = dev->agp_buffer_token; | 1544 | unsigned long token = dev->agp_buffer_token; |
1539 | 1545 | ||
1540 | if (!map) { | 1546 | if (!map) { |