Skip to content

Commit

Permalink
Merge branch 'drm-fixes' of master.kernel.org:/pub/scm/linux/kernel/g…
Browse files Browse the repository at this point in the history
…it/airlied/drm-2.6
  • Loading branch information
Linus Torvalds committed Sep 8, 2005
2 parents 0dd7f88 + 908f9c4 commit db400b3
Show file tree
Hide file tree
Showing 4 changed files with 46 additions and 37 deletions.
66 changes: 33 additions & 33 deletions drivers/char/drm/drm_bufs.c
Original file line number Diff line number Diff line change
Expand Up @@ -48,16 +48,16 @@ unsigned long drm_get_resource_len(drm_device_t *dev, unsigned int resource)
}
EXPORT_SYMBOL(drm_get_resource_len);

static drm_local_map_t *drm_find_matching_map(drm_device_t *dev,
drm_local_map_t *map)
static drm_map_list_t *drm_find_matching_map(drm_device_t *dev,
drm_local_map_t *map)
{
struct list_head *list;

list_for_each(list, &dev->maplist->head) {
drm_map_list_t *entry = list_entry(list, drm_map_list_t, head);
if (entry->map && map->type == entry->map->type &&
entry->map->offset == map->offset) {
return entry->map;
return entry;
}
}

Expand Down Expand Up @@ -114,14 +114,13 @@ static __inline__ unsigned int HandleID(unsigned long lhandle, drm_device_t *dev
* type. Adds the map to the map list drm_device::maplist. Adds MTRR's where
* applicable and if supported by the kernel.
*/
int drm_addmap(drm_device_t * dev, unsigned int offset,
unsigned int size, drm_map_type_t type,
drm_map_flags_t flags, drm_local_map_t ** map_ptr)
int drm_addmap_core(drm_device_t * dev, unsigned int offset,
unsigned int size, drm_map_type_t type,
drm_map_flags_t flags, drm_map_list_t **maplist)
{
drm_map_t *map;
drm_map_list_t *list;
drm_dma_handle_t *dmah;
drm_local_map_t *found_map;

map = drm_alloc( sizeof(*map), DRM_MEM_MAPS );
if ( !map )
Expand Down Expand Up @@ -166,17 +165,17 @@ int drm_addmap(drm_device_t * dev, unsigned int offset,
* needing to be aware of it. Therefore, we just return success
* when the server tries to create a duplicate map.
*/
found_map = drm_find_matching_map(dev, map);
if (found_map != NULL) {
if (found_map->size != map->size) {
list = drm_find_matching_map(dev, map);
if (list != NULL) {
if (list->map->size != map->size) {
DRM_DEBUG("Matching maps of type %d with "
"mismatched sizes, (%ld vs %ld)\n",
map->type, map->size, found_map->size);
found_map->size = map->size;
map->type, map->size, list->map->size);
list->map->size = map->size;
}

drm_free(map, sizeof(*map), DRM_MEM_MAPS);
*map_ptr = found_map;
*maplist = list;
return 0;
}

Expand Down Expand Up @@ -264,9 +263,22 @@ int drm_addmap(drm_device_t * dev, unsigned int offset,
: map->offset, dev);
up(&dev->struct_sem);

*map_ptr = map;
*maplist = list;
return 0;
}

int drm_addmap(drm_device_t *dev, unsigned int offset,
unsigned int size, drm_map_type_t type,
drm_map_flags_t flags, drm_local_map_t **map_ptr)
{
drm_map_list_t *list;
int rc;

rc = drm_addmap_core(dev, offset, size, type, flags, &list);
if (!rc)
*map_ptr = list->map;
return rc;
}
EXPORT_SYMBOL(drm_addmap);

int drm_addmap_ioctl(struct inode *inode, struct file *filp,
Expand All @@ -275,10 +287,9 @@ int drm_addmap_ioctl(struct inode *inode, struct file *filp,
drm_file_t *priv = filp->private_data;
drm_device_t *dev = priv->head->dev;
drm_map_t map;
drm_map_t *map_ptr;
drm_map_list_t *maplist;
drm_map_t __user *argp = (void __user *)arg;
int err;
unsigned long handle = 0;

if (!(filp->f_mode & 3))
return -EACCES; /* Require read/write */
Expand All @@ -287,26 +298,15 @@ int drm_addmap_ioctl(struct inode *inode, struct file *filp,
return -EFAULT;
}

err = drm_addmap(dev, map.offset, map.size, map.type, map.flags,
&map_ptr);
err = drm_addmap_core(dev, map.offset, map.size, map.type, map.flags,
&maplist);

if (err) {
if (err)
return err;
}

{
drm_map_list_t *_entry;
list_for_each_entry(_entry, &dev->maplist->head, head) {
if (_entry->map == map_ptr)
handle = _entry->user_token;
}
if (!handle)
return -EFAULT;
}

if (copy_to_user(argp, map_ptr, sizeof(*map_ptr)))
if (copy_to_user(argp, maplist->map, sizeof(drm_map_t)))
return -EFAULT;
if (put_user(handle, &argp->handle))
if (put_user(maplist->user_token, &argp->handle))
return -EFAULT;
return 0;
}
Expand Down Expand Up @@ -1041,7 +1041,7 @@ static int drm_addbufs_sg(drm_device_t *dev, drm_buf_desc_t *request)
return 0;
}

int drm_addbufs_fb(drm_device_t *dev, drm_buf_desc_t *request)
static int drm_addbufs_fb(drm_device_t *dev, drm_buf_desc_t *request)
{
drm_device_dma_t *dma = dev->dma;
drm_buf_entry_t *entry;
Expand Down
2 changes: 1 addition & 1 deletion drivers/char/drm/drm_context.c
Original file line number Diff line number Diff line change
Expand Up @@ -308,7 +308,7 @@ int drm_setsareactx(struct inode *inode, struct file *filp,
*
* Attempt to set drm_device::context_flag.
*/
int drm_context_switch( drm_device_t *dev, int old, int new )
static int drm_context_switch( drm_device_t *dev, int old, int new )
{
if ( test_and_set_bit( 0, &dev->context_flag ) ) {
DRM_ERROR( "Reentering -- FIXME\n" );
Expand Down
1 change: 1 addition & 0 deletions drivers/char/drm/drm_sysfs.c
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,7 @@
#include <linux/err.h>

#include "drm_core.h"
#include "drmP.h"

struct drm_sysfs_class {
struct class_device_attribute attr;
Expand Down
14 changes: 11 additions & 3 deletions drivers/char/drm/mga_dma.c
Original file line number Diff line number Diff line change
Expand Up @@ -417,6 +417,7 @@ int mga_driver_preinit(drm_device_t *dev, unsigned long flags)
return 0;
}

#if __OS_HAS_AGP
/**
* Bootstrap the driver for AGP DMA.
*
Expand Down Expand Up @@ -560,6 +561,13 @@ static int mga_do_agp_dma_bootstrap(drm_device_t * dev,
DRM_INFO("Initialized card for AGP DMA.\n");
return 0;
}
#else
static int mga_do_agp_dma_bootstrap(drm_device_t * dev,
drm_mga_dma_bootstrap_t * dma_bs)
{
return -EINVAL;
}
#endif

/**
* Bootstrap the driver for PCI DMA.
Expand Down Expand Up @@ -697,7 +705,6 @@ static int mga_do_dma_bootstrap(drm_device_t * dev,
* carve off portions of it for internal uses. The remaining memory
* is returned to user-mode to be used for AGP textures.
*/

if (is_agp) {
err = mga_do_agp_dma_bootstrap(dev, dma_bs);
}
Expand Down Expand Up @@ -932,6 +939,7 @@ static int mga_do_cleanup_dma( drm_device_t *dev )
drm_core_ioremapfree(dev->agp_buffer_map, dev);

if (dev_priv->used_new_dma_init) {
#if __OS_HAS_AGP
if (dev_priv->agp_mem != NULL) {
dev_priv->agp_textures = NULL;
drm_unbind_agp(dev_priv->agp_mem);
Expand All @@ -944,7 +952,7 @@ static int mga_do_cleanup_dma( drm_device_t *dev )
if ((dev->agp != NULL) && dev->agp->acquired) {
err = drm_agp_release(dev);
}

#endif
dev_priv->used_new_dma_init = 0;
}

Expand All @@ -965,7 +973,7 @@ static int mga_do_cleanup_dma( drm_device_t *dev )
}
}

return 0;
return err;
}

int mga_dma_init( DRM_IOCTL_ARGS )
Expand Down

0 comments on commit db400b3

Please sign in to comment.