aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorLinus Torvalds <torvalds@g5.osdl.org>2005-09-07 20:29:07 -0400
committerLinus Torvalds <torvalds@g5.osdl.org>2005-09-07 20:29:07 -0400
commitdb400b3c4ee89d384d9163836a55577abdae772d (patch)
tree95d2d031089bcc7d26a7e4b3616c90e821a9c904
parent0dd7f883a9e21c5f2ff5e8f1cbb0e78cdc044d8a (diff)
parent908f9c485042e516bb3749f4361129a94772fe26 (diff)
Merge branch 'drm-fixes' of master.kernel.org:/pub/scm/linux/kernel/git/airlied/drm-2.6
-rw-r--r--drivers/char/drm/drm_bufs.c66
-rw-r--r--drivers/char/drm/drm_context.c2
-rw-r--r--drivers/char/drm/drm_sysfs.c1
-rw-r--r--drivers/char/drm/mga_dma.c14
4 files changed, 46 insertions, 37 deletions
diff --git a/drivers/char/drm/drm_bufs.c b/drivers/char/drm/drm_bufs.c
index e0743ebbe4bd..f28e70ae6606 100644
--- a/drivers/char/drm/drm_bufs.c
+++ b/drivers/char/drm/drm_bufs.c
@@ -48,8 +48,8 @@ unsigned long drm_get_resource_len(drm_device_t *dev, unsigned int resource)
48} 48}
49EXPORT_SYMBOL(drm_get_resource_len); 49EXPORT_SYMBOL(drm_get_resource_len);
50 50
51static drm_local_map_t *drm_find_matching_map(drm_device_t *dev, 51static drm_map_list_t *drm_find_matching_map(drm_device_t *dev,
52 drm_local_map_t *map) 52 drm_local_map_t *map)
53{ 53{
54 struct list_head *list; 54 struct list_head *list;
55 55
@@ -57,7 +57,7 @@ static drm_local_map_t *drm_find_matching_map(drm_device_t *dev,
57 drm_map_list_t *entry = list_entry(list, drm_map_list_t, head); 57 drm_map_list_t *entry = list_entry(list, drm_map_list_t, head);
58 if (entry->map && map->type == entry->map->type && 58 if (entry->map && map->type == entry->map->type &&
59 entry->map->offset == map->offset) { 59 entry->map->offset == map->offset) {
60 return entry->map; 60 return entry;
61 } 61 }
62 } 62 }
63 63
@@ -114,14 +114,13 @@ static __inline__ unsigned int HandleID(unsigned long lhandle, drm_device_t *dev
114 * type. Adds the map to the map list drm_device::maplist. Adds MTRR's where 114 * type. Adds the map to the map list drm_device::maplist. Adds MTRR's where
115 * applicable and if supported by the kernel. 115 * applicable and if supported by the kernel.
116 */ 116 */
117int drm_addmap(drm_device_t * dev, unsigned int offset, 117int drm_addmap_core(drm_device_t * dev, unsigned int offset,
118 unsigned int size, drm_map_type_t type, 118 unsigned int size, drm_map_type_t type,
119 drm_map_flags_t flags, drm_local_map_t ** map_ptr) 119 drm_map_flags_t flags, drm_map_list_t **maplist)
120{ 120{
121 drm_map_t *map; 121 drm_map_t *map;
122 drm_map_list_t *list; 122 drm_map_list_t *list;
123 drm_dma_handle_t *dmah; 123 drm_dma_handle_t *dmah;
124 drm_local_map_t *found_map;
125 124
126 map = drm_alloc( sizeof(*map), DRM_MEM_MAPS ); 125 map = drm_alloc( sizeof(*map), DRM_MEM_MAPS );
127 if ( !map ) 126 if ( !map )
@@ -166,17 +165,17 @@ int drm_addmap(drm_device_t * dev, unsigned int offset,
166 * needing to be aware of it. Therefore, we just return success 165 * needing to be aware of it. Therefore, we just return success
167 * when the server tries to create a duplicate map. 166 * when the server tries to create a duplicate map.
168 */ 167 */
169 found_map = drm_find_matching_map(dev, map); 168 list = drm_find_matching_map(dev, map);
170 if (found_map != NULL) { 169 if (list != NULL) {
171 if (found_map->size != map->size) { 170 if (list->map->size != map->size) {
172 DRM_DEBUG("Matching maps of type %d with " 171 DRM_DEBUG("Matching maps of type %d with "
173 "mismatched sizes, (%ld vs %ld)\n", 172 "mismatched sizes, (%ld vs %ld)\n",
174 map->type, map->size, found_map->size); 173 map->type, map->size, list->map->size);
175 found_map->size = map->size; 174 list->map->size = map->size;
176 } 175 }
177 176
178 drm_free(map, sizeof(*map), DRM_MEM_MAPS); 177 drm_free(map, sizeof(*map), DRM_MEM_MAPS);
179 *map_ptr = found_map; 178 *maplist = list;
180 return 0; 179 return 0;
181 } 180 }
182 181
@@ -264,9 +263,22 @@ int drm_addmap(drm_device_t * dev, unsigned int offset,
264 : map->offset, dev); 263 : map->offset, dev);
265 up(&dev->struct_sem); 264 up(&dev->struct_sem);
266 265
267 *map_ptr = map; 266 *maplist = list;
268 return 0; 267 return 0;
269} 268}
269
270int drm_addmap(drm_device_t *dev, unsigned int offset,
271 unsigned int size, drm_map_type_t type,
272 drm_map_flags_t flags, drm_local_map_t **map_ptr)
273{
274 drm_map_list_t *list;
275 int rc;
276
277 rc = drm_addmap_core(dev, offset, size, type, flags, &list);
278 if (!rc)
279 *map_ptr = list->map;
280 return rc;
281}
270EXPORT_SYMBOL(drm_addmap); 282EXPORT_SYMBOL(drm_addmap);
271 283
272int drm_addmap_ioctl(struct inode *inode, struct file *filp, 284int drm_addmap_ioctl(struct inode *inode, struct file *filp,
@@ -275,10 +287,9 @@ int drm_addmap_ioctl(struct inode *inode, struct file *filp,
275 drm_file_t *priv = filp->private_data; 287 drm_file_t *priv = filp->private_data;
276 drm_device_t *dev = priv->head->dev; 288 drm_device_t *dev = priv->head->dev;
277 drm_map_t map; 289 drm_map_t map;
278 drm_map_t *map_ptr; 290 drm_map_list_t *maplist;
279 drm_map_t __user *argp = (void __user *)arg; 291 drm_map_t __user *argp = (void __user *)arg;
280 int err; 292 int err;
281 unsigned long handle = 0;
282 293
283 if (!(filp->f_mode & 3)) 294 if (!(filp->f_mode & 3))
284 return -EACCES; /* Require read/write */ 295 return -EACCES; /* Require read/write */
@@ -287,26 +298,15 @@ int drm_addmap_ioctl(struct inode *inode, struct file *filp,
287 return -EFAULT; 298 return -EFAULT;
288 } 299 }
289 300
290 err = drm_addmap(dev, map.offset, map.size, map.type, map.flags, 301 err = drm_addmap_core(dev, map.offset, map.size, map.type, map.flags,
291 &map_ptr); 302 &maplist);
292 303
293 if (err) { 304 if (err)
294 return err; 305 return err;
295 }
296
297 {
298 drm_map_list_t *_entry;
299 list_for_each_entry(_entry, &dev->maplist->head, head) {
300 if (_entry->map == map_ptr)
301 handle = _entry->user_token;
302 }
303 if (!handle)
304 return -EFAULT;
305 }
306 306
307 if (copy_to_user(argp, map_ptr, sizeof(*map_ptr))) 307 if (copy_to_user(argp, maplist->map, sizeof(drm_map_t)))
308 return -EFAULT; 308 return -EFAULT;
309 if (put_user(handle, &argp->handle)) 309 if (put_user(maplist->user_token, &argp->handle))
310 return -EFAULT; 310 return -EFAULT;
311 return 0; 311 return 0;
312} 312}
@@ -1041,7 +1041,7 @@ static int drm_addbufs_sg(drm_device_t *dev, drm_buf_desc_t *request)
1041 return 0; 1041 return 0;
1042} 1042}
1043 1043
1044int drm_addbufs_fb(drm_device_t *dev, drm_buf_desc_t *request) 1044static int drm_addbufs_fb(drm_device_t *dev, drm_buf_desc_t *request)
1045{ 1045{
1046 drm_device_dma_t *dma = dev->dma; 1046 drm_device_dma_t *dma = dev->dma;
1047 drm_buf_entry_t *entry; 1047 drm_buf_entry_t *entry;
diff --git a/drivers/char/drm/drm_context.c b/drivers/char/drm/drm_context.c
index f515567e5b6f..502892794c16 100644
--- a/drivers/char/drm/drm_context.c
+++ b/drivers/char/drm/drm_context.c
@@ -308,7 +308,7 @@ found:
308 * 308 *
309 * Attempt to set drm_device::context_flag. 309 * Attempt to set drm_device::context_flag.
310 */ 310 */
311int drm_context_switch( drm_device_t *dev, int old, int new ) 311static int drm_context_switch( drm_device_t *dev, int old, int new )
312{ 312{
313 if ( test_and_set_bit( 0, &dev->context_flag ) ) { 313 if ( test_and_set_bit( 0, &dev->context_flag ) ) {
314 DRM_ERROR( "Reentering -- FIXME\n" ); 314 DRM_ERROR( "Reentering -- FIXME\n" );
diff --git a/drivers/char/drm/drm_sysfs.c b/drivers/char/drm/drm_sysfs.c
index 2fc10c4bbcdf..475cc5e555e1 100644
--- a/drivers/char/drm/drm_sysfs.c
+++ b/drivers/char/drm/drm_sysfs.c
@@ -17,6 +17,7 @@
17#include <linux/err.h> 17#include <linux/err.h>
18 18
19#include "drm_core.h" 19#include "drm_core.h"
20#include "drmP.h"
20 21
21struct drm_sysfs_class { 22struct drm_sysfs_class {
22 struct class_device_attribute attr; 23 struct class_device_attribute attr;
diff --git a/drivers/char/drm/mga_dma.c b/drivers/char/drm/mga_dma.c
index 567b425b784f..fc7d4a594bca 100644
--- a/drivers/char/drm/mga_dma.c
+++ b/drivers/char/drm/mga_dma.c
@@ -417,6 +417,7 @@ int mga_driver_preinit(drm_device_t *dev, unsigned long flags)
417 return 0; 417 return 0;
418} 418}
419 419
420#if __OS_HAS_AGP
420/** 421/**
421 * Bootstrap the driver for AGP DMA. 422 * Bootstrap the driver for AGP DMA.
422 * 423 *
@@ -560,6 +561,13 @@ static int mga_do_agp_dma_bootstrap(drm_device_t * dev,
560 DRM_INFO("Initialized card for AGP DMA.\n"); 561 DRM_INFO("Initialized card for AGP DMA.\n");
561 return 0; 562 return 0;
562} 563}
564#else
565static int mga_do_agp_dma_bootstrap(drm_device_t * dev,
566 drm_mga_dma_bootstrap_t * dma_bs)
567{
568 return -EINVAL;
569}
570#endif
563 571
564/** 572/**
565 * Bootstrap the driver for PCI DMA. 573 * Bootstrap the driver for PCI DMA.
@@ -697,7 +705,6 @@ static int mga_do_dma_bootstrap(drm_device_t * dev,
697 * carve off portions of it for internal uses. The remaining memory 705 * carve off portions of it for internal uses. The remaining memory
698 * is returned to user-mode to be used for AGP textures. 706 * is returned to user-mode to be used for AGP textures.
699 */ 707 */
700
701 if (is_agp) { 708 if (is_agp) {
702 err = mga_do_agp_dma_bootstrap(dev, dma_bs); 709 err = mga_do_agp_dma_bootstrap(dev, dma_bs);
703 } 710 }
@@ -932,6 +939,7 @@ static int mga_do_cleanup_dma( drm_device_t *dev )
932 drm_core_ioremapfree(dev->agp_buffer_map, dev); 939 drm_core_ioremapfree(dev->agp_buffer_map, dev);
933 940
934 if (dev_priv->used_new_dma_init) { 941 if (dev_priv->used_new_dma_init) {
942#if __OS_HAS_AGP
935 if (dev_priv->agp_mem != NULL) { 943 if (dev_priv->agp_mem != NULL) {
936 dev_priv->agp_textures = NULL; 944 dev_priv->agp_textures = NULL;
937 drm_unbind_agp(dev_priv->agp_mem); 945 drm_unbind_agp(dev_priv->agp_mem);
@@ -944,7 +952,7 @@ static int mga_do_cleanup_dma( drm_device_t *dev )
944 if ((dev->agp != NULL) && dev->agp->acquired) { 952 if ((dev->agp != NULL) && dev->agp->acquired) {
945 err = drm_agp_release(dev); 953 err = drm_agp_release(dev);
946 } 954 }
947 955#endif
948 dev_priv->used_new_dma_init = 0; 956 dev_priv->used_new_dma_init = 0;
949 } 957 }
950 958
@@ -965,7 +973,7 @@ static int mga_do_cleanup_dma( drm_device_t *dev )
965 } 973 }
966 } 974 }
967 975
968 return 0; 976 return err;
969} 977}
970 978
971int mga_dma_init( DRM_IOCTL_ARGS ) 979int mga_dma_init( DRM_IOCTL_ARGS )