Skip to content

Commit

Permalink
drm: Replace DRM_IOCTL_ARGS with (dev, data, file_priv) and remove DR…
Browse files Browse the repository at this point in the history
…M_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>
  • Loading branch information
Eric Anholt authored and Dave Airlie committed Oct 15, 2007
1 parent b589ee5 commit c153f45
Show file tree
Hide file tree
Showing 45 changed files with 1,489 additions and 2,146 deletions.
219 changes: 114 additions & 105 deletions drivers/char/drm/drmP.h

Large diffs are not rendered by default.

107 changes: 33 additions & 74 deletions drivers/char/drm/drm_agpsupport.c
Original file line number Diff line number Diff line change
Expand Up @@ -71,19 +71,16 @@ int drm_agp_info(struct drm_device *dev, struct drm_agp_info *info)

EXPORT_SYMBOL(drm_agp_info);

int drm_agp_info_ioctl(struct inode *inode, struct drm_file *file_priv,
unsigned int cmd, unsigned long arg)
int drm_agp_info_ioctl(struct drm_device *dev, void *data,
struct drm_file *file_priv)
{
struct drm_device *dev = file_priv->head->dev;
struct drm_agp_info info;
struct drm_agp_info *info = data;
int err;

err = drm_agp_info(dev, &info);
err = drm_agp_info(dev, info);
if (err)
return err;

if (copy_to_user((struct drm_agp_info __user *) arg, &info, sizeof(info)))
return -EFAULT;
return 0;
}

Expand Down Expand Up @@ -122,8 +119,8 @@ EXPORT_SYMBOL(drm_agp_acquire);
* Verifies the AGP device hasn't been acquired before and calls
* \c agp_backend_acquire.
*/
int drm_agp_acquire_ioctl(struct inode *inode, struct drm_file *file_priv,
unsigned int cmd, unsigned long arg)
int drm_agp_acquire_ioctl(struct drm_device *dev, void *data,
struct drm_file *file_priv)
{
return drm_agp_acquire((struct drm_device *) file_priv->head->dev);
}
Expand All @@ -146,11 +143,9 @@ int drm_agp_release(struct drm_device * dev)
}
EXPORT_SYMBOL(drm_agp_release);

int drm_agp_release_ioctl(struct inode *inode, struct drm_file *file_priv,
unsigned int cmd, unsigned long arg)
int drm_agp_release_ioctl(struct drm_device *dev, void *data,
struct drm_file *file_priv)
{
struct drm_device *dev = file_priv->head->dev;

return drm_agp_release(dev);
}

Expand Down Expand Up @@ -178,16 +173,12 @@ int drm_agp_enable(struct drm_device * dev, struct drm_agp_mode mode)

EXPORT_SYMBOL(drm_agp_enable);

int drm_agp_enable_ioctl(struct inode *inode, struct drm_file *file_priv,
unsigned int cmd, unsigned long arg)
int drm_agp_enable_ioctl(struct drm_device *dev, void *data,
struct drm_file *file_priv)
{
struct drm_device *dev = file_priv->head->dev;
struct drm_agp_mode mode;

if (copy_from_user(&mode, (struct drm_agp_mode __user *) arg, sizeof(mode)))
return -EFAULT;
struct drm_agp_mode *mode = data;

return drm_agp_enable(dev, mode);
return drm_agp_enable(dev, *mode);
}

/**
Expand Down Expand Up @@ -236,34 +227,13 @@ int drm_agp_alloc(struct drm_device *dev, struct drm_agp_buffer *request)
}
EXPORT_SYMBOL(drm_agp_alloc);

int drm_agp_alloc_ioctl(struct inode *inode, struct drm_file *file_priv,
unsigned int cmd, unsigned long arg)
{
struct drm_device *dev = file_priv->head->dev;
struct drm_agp_buffer request;
struct drm_agp_buffer __user *argp = (void __user *)arg;
int err;

if (copy_from_user(&request, argp, sizeof(request)))
return -EFAULT;

err = drm_agp_alloc(dev, &request);
if (err)
return err;

if (copy_to_user(argp, &request, sizeof(request))) {
struct drm_agp_mem *entry;
list_for_each_entry(entry, &dev->agp->memory, head) {
if (entry->handle == request.handle)
break;
}
list_del(&entry->head);
drm_free_agp(entry->memory, entry->pages);
drm_free(entry, sizeof(*entry), DRM_MEM_AGPLISTS);
return -EFAULT;
}
int drm_agp_alloc_ioctl(struct drm_device *dev, void *data,
struct drm_file *file_priv)
{
struct drm_agp_buffer *request = data;

return 0;
return drm_agp_alloc(dev, request);
}

/**
Expand Down Expand Up @@ -317,17 +287,13 @@ int drm_agp_unbind(struct drm_device *dev, struct drm_agp_binding *request)
}
EXPORT_SYMBOL(drm_agp_unbind);

int drm_agp_unbind_ioctl(struct inode *inode, struct drm_file *file_priv,
unsigned int cmd, unsigned long arg)
{
struct drm_device *dev = file_priv->head->dev;
struct drm_agp_binding request;

if (copy_from_user
(&request, (struct drm_agp_binding __user *) arg, sizeof(request)))
return -EFAULT;
int drm_agp_unbind_ioctl(struct drm_device *dev, void *data,
struct drm_file *file_priv)
{
struct drm_agp_binding *request = data;

return drm_agp_unbind(dev, &request);
return drm_agp_unbind(dev, request);
}

/**
Expand Down Expand Up @@ -365,17 +331,13 @@ int drm_agp_bind(struct drm_device *dev, struct drm_agp_binding *request)
}
EXPORT_SYMBOL(drm_agp_bind);

int drm_agp_bind_ioctl(struct inode *inode, struct drm_file *file_priv,
unsigned int cmd, unsigned long arg)
{
struct drm_device *dev = file_priv->head->dev;
struct drm_agp_binding request;

if (copy_from_user
(&request, (struct drm_agp_binding __user *) arg, sizeof(request)))
return -EFAULT;
int drm_agp_bind_ioctl(struct drm_device *dev, void *data,
struct drm_file *file_priv)
{
struct drm_agp_binding *request = data;

return drm_agp_bind(dev, &request);
return drm_agp_bind(dev, request);
}

/**
Expand Down Expand Up @@ -411,17 +373,14 @@ int drm_agp_free(struct drm_device *dev, struct drm_agp_buffer *request)
}
EXPORT_SYMBOL(drm_agp_free);

int drm_agp_free_ioctl(struct inode *inode, struct drm_file *file_priv,
unsigned int cmd, unsigned long arg)
{
struct drm_device *dev = file_priv->head->dev;
struct drm_agp_buffer request;

if (copy_from_user
(&request, (struct drm_agp_buffer __user *) arg, sizeof(request)))
return -EFAULT;

return drm_agp_free(dev, &request);
int drm_agp_free_ioctl(struct drm_device *dev, void *data,
struct drm_file *file_priv)
{
struct drm_agp_buffer *request = data;

return drm_agp_free(dev, request);
}

/**
Expand Down
36 changes: 15 additions & 21 deletions drivers/char/drm/drm_auth.c
Original file line number Diff line number Diff line change
Expand Up @@ -137,32 +137,29 @@ static int drm_remove_magic(struct drm_device * dev, drm_magic_t magic)
* searches an unique non-zero magic number and add it associating it with \p
* file_priv.
*/
int drm_getmagic(struct inode *inode, struct drm_file *file_priv,
unsigned int cmd, unsigned long arg)
int drm_getmagic(struct drm_device *dev, void *data, struct drm_file *file_priv)
{
static drm_magic_t sequence = 0;
static DEFINE_SPINLOCK(lock);
struct drm_device *dev = file_priv->head->dev;
struct drm_auth auth;
struct drm_auth *auth = data;

/* Find unique magic */
if (file_priv->magic) {
auth.magic = file_priv->magic;
auth->magic = file_priv->magic;
} else {
do {
spin_lock(&lock);
if (!sequence)
++sequence; /* reserve 0 */
auth.magic = sequence++;
auth->magic = sequence++;
spin_unlock(&lock);
} while (drm_find_file(dev, auth.magic));
file_priv->magic = auth.magic;
drm_add_magic(dev, file_priv, auth.magic);
} while (drm_find_file(dev, auth->magic));
file_priv->magic = auth->magic;
drm_add_magic(dev, file_priv, auth->magic);
}

DRM_DEBUG("%u\n", auth.magic);
if (copy_to_user((struct drm_auth __user *) arg, &auth, sizeof(auth)))
return -EFAULT;
DRM_DEBUG("%u\n", auth->magic);

return 0;
}

Expand All @@ -177,19 +174,16 @@ int drm_getmagic(struct inode *inode, struct drm_file *file_priv,
*
* Checks if \p file_priv is associated with the magic number passed in \arg.
*/
int drm_authmagic(struct inode *inode, struct drm_file *file_priv,
unsigned int cmd, unsigned long arg)
int drm_authmagic(struct drm_device *dev, void *data,
struct drm_file *file_priv)
{
struct drm_device *dev = file_priv->head->dev;
struct drm_auth auth;
struct drm_auth *auth = data;
struct drm_file *file;

if (copy_from_user(&auth, (struct drm_auth __user *) arg, sizeof(auth)))
return -EFAULT;
DRM_DEBUG("%u\n", auth.magic);
if ((file = drm_find_file(dev, auth.magic))) {
DRM_DEBUG("%u\n", auth->magic);
if ((file = drm_find_file(dev, auth->magic))) {
file->authenticated = 1;
drm_remove_magic(dev, auth.magic);
drm_remove_magic(dev, auth->magic);
return 0;
}
return -EINVAL;
Expand Down
Loading

0 comments on commit c153f45

Please sign in to comment.