diff options
author | Eric Anholt <eric@anholt.net> | 2007-07-19 17:11:11 -0700 |
---|---|---|
committer | Eric Anholt <eric@anholt.net> | 2007-07-20 18:16:42 -0700 |
commit | 5b38e134163cc375e91424c4688cc9328c6e9082 (patch) | |
tree | 3930e659e99aa4c5c319aaca8cffa041e9087e62 /linux-core/drm_fence.c | |
parent | c1119b1b092527fbb6950d0b5e51e076ddb00f29 (diff) |
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 the
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 DRM
is lost.
Diffstat (limited to 'linux-core/drm_fence.c')
-rw-r--r-- | linux-core/drm_fence.c | 151 |
1 files changed, 60 insertions, 91 deletions
diff --git a/linux-core/drm_fence.c b/linux-core/drm_fence.c index 3a3035e1..c4f7da15 100644 --- a/linux-core/drm_fence.c +++ b/linux-core/drm_fence.c @@ -565,12 +565,11 @@ struct drm_fence_object *drm_lookup_fence_object(struct drm_file * priv, uint32_ return fence; } -int drm_fence_create_ioctl(DRM_IOCTL_ARGS) +int drm_fence_create_ioctl(struct drm_device *dev, void *data, struct drm_file *file_priv) { - DRM_DEVICE; int ret; struct drm_fence_manager *fm = &dev->fm; - struct drm_fence_arg arg; + struct drm_fence_arg *arg = data; struct drm_fence_object *fence; unsigned long flags; ret = 0; @@ -580,15 +579,14 @@ int drm_fence_create_ioctl(DRM_IOCTL_ARGS) return -EINVAL; } - DRM_COPY_FROM_USER_IOCTL(arg, (void __user *)data, sizeof(arg)); - if (arg.flags & DRM_FENCE_FLAG_EMIT) + if (arg->flags & DRM_FENCE_FLAG_EMIT) LOCK_TEST_WITH_RETURN(dev, file_priv); - ret = drm_fence_object_create(dev, arg.class, - arg.type, arg.flags, &fence); + ret = drm_fence_object_create(dev, arg->class, + arg->type, arg->flags, &fence); if (ret) return ret; ret = drm_fence_add_user_object(file_priv, fence, - arg.flags & + arg->flags & DRM_FENCE_FLAG_SHAREABLE); if (ret) { drm_fence_usage_deref_unlocked(&fence); @@ -600,25 +598,23 @@ int drm_fence_create_ioctl(DRM_IOCTL_ARGS) */ atomic_inc(&fence->usage); - arg.handle = fence->base.hash.key; + arg->handle = fence->base.hash.key; read_lock_irqsave(&fm->lock, flags); - arg.class = fence->class; - arg.type = fence->type; - arg.signaled = fence->signaled; + arg->class = fence->class; + arg->type = fence->type; + arg->signaled = fence->signaled; read_unlock_irqrestore(&fm->lock, flags); drm_fence_usage_deref_unlocked(&fence); - DRM_COPY_TO_USER_IOCTL((void __user *)data, arg, sizeof(arg)); return ret; } -int drm_fence_destroy_ioctl(DRM_IOCTL_ARGS) +int drm_fence_destroy_ioctl(struct drm_device *dev, void *data, struct drm_file *file_priv) { - DRM_DEVICE; int ret; struct drm_fence_manager *fm = &dev->fm; - struct drm_fence_arg arg; + struct drm_fence_arg *arg = data; struct drm_user_object *uo; ret = 0; @@ -627,10 +623,8 @@ int drm_fence_destroy_ioctl(DRM_IOCTL_ARGS) return -EINVAL; } - DRM_COPY_FROM_USER_IOCTL(arg, (void __user *)data, sizeof(arg)); - mutex_lock(&dev->struct_mutex); - uo = drm_lookup_user_object(file_priv, arg.handle); + uo = drm_lookup_user_object(file_priv, arg->handle); if (!uo || (uo->type != drm_fence_type) || uo->owner != file_priv) { mutex_unlock(&dev->struct_mutex); return -EINVAL; @@ -641,12 +635,11 @@ int drm_fence_destroy_ioctl(DRM_IOCTL_ARGS) } -int drm_fence_reference_ioctl(DRM_IOCTL_ARGS) +int drm_fence_reference_ioctl(struct drm_device *dev, void *data, struct drm_file *file_priv) { - DRM_DEVICE; int ret; struct drm_fence_manager *fm = &dev->fm; - struct drm_fence_arg arg; + struct drm_fence_arg *arg = data; struct drm_fence_object *fence; struct drm_user_object *uo; unsigned long flags; @@ -657,30 +650,27 @@ int drm_fence_reference_ioctl(DRM_IOCTL_ARGS) return -EINVAL; } - DRM_COPY_FROM_USER_IOCTL(arg, (void __user *)data, sizeof(arg)); - ret = drm_user_object_ref(file_priv, arg.handle, drm_fence_type, &uo); + ret = drm_user_object_ref(file_priv, arg->handle, drm_fence_type, &uo); if (ret) return ret; - fence = drm_lookup_fence_object(file_priv, arg.handle); + fence = drm_lookup_fence_object(file_priv, arg->handle); read_lock_irqsave(&fm->lock, flags); - arg.class = fence->class; - arg.type = fence->type; - arg.signaled = fence->signaled; + arg->class = fence->class; + arg->type = fence->type; + arg->signaled = fence->signaled; read_unlock_irqrestore(&fm->lock, flags); drm_fence_usage_deref_unlocked(&fence); - DRM_COPY_TO_USER_IOCTL((void __user *)data, arg, sizeof(arg)); return ret; } -int drm_fence_unreference_ioctl(DRM_IOCTL_ARGS) +int drm_fence_unreference_ioctl(struct drm_device *dev, void *data, struct drm_file *file_priv) { - DRM_DEVICE; int ret; struct drm_fence_manager *fm = &dev->fm; - struct drm_fence_arg arg; + struct drm_fence_arg *arg = data; ret = 0; if (!fm->initialized) { @@ -688,16 +678,14 @@ int drm_fence_unreference_ioctl(DRM_IOCTL_ARGS) return -EINVAL; } - DRM_COPY_FROM_USER_IOCTL(arg, (void __user *)data, sizeof(arg)); - return drm_user_object_unref(file_priv, arg.handle, drm_fence_type); + return drm_user_object_unref(file_priv, arg->handle, drm_fence_type); } -int drm_fence_signaled_ioctl(DRM_IOCTL_ARGS) +int drm_fence_signaled_ioctl(struct drm_device *dev, void *data, struct drm_file *file_priv) { - DRM_DEVICE; int ret; struct drm_fence_manager *fm = &dev->fm; - struct drm_fence_arg arg; + struct drm_fence_arg *arg = data; struct drm_fence_object *fence; unsigned long flags; ret = 0; @@ -707,29 +695,25 @@ int drm_fence_signaled_ioctl(DRM_IOCTL_ARGS) return -EINVAL; } - DRM_COPY_FROM_USER_IOCTL(arg, (void __user *)data, sizeof(arg)); - - fence = drm_lookup_fence_object(file_priv, arg.handle); + fence = drm_lookup_fence_object(file_priv, arg->handle); if (!fence) return -EINVAL; read_lock_irqsave(&fm->lock, flags); - arg.class = fence->class; - arg.type = fence->type; - arg.signaled = fence->signaled; + arg->class = fence->class; + arg->type = fence->type; + arg->signaled = fence->signaled; read_unlock_irqrestore(&fm->lock, flags); drm_fence_usage_deref_unlocked(&fence); - DRM_COPY_TO_USER_IOCTL((void __user *)data, arg, sizeof(arg)); return ret; } -int drm_fence_flush_ioctl(DRM_IOCTL_ARGS) +int drm_fence_flush_ioctl(struct drm_device *dev, void *data, struct drm_file *file_priv) { - DRM_DEVICE; int ret; struct drm_fence_manager *fm = &dev->fm; - struct drm_fence_arg arg; + struct drm_fence_arg *arg = data; struct drm_fence_object *fence; unsigned long flags; ret = 0; @@ -739,31 +723,27 @@ int drm_fence_flush_ioctl(DRM_IOCTL_ARGS) return -EINVAL; } - DRM_COPY_FROM_USER_IOCTL(arg, (void __user *)data, sizeof(arg)); - - fence = drm_lookup_fence_object(file_priv, arg.handle); + fence = drm_lookup_fence_object(file_priv, arg->handle); if (!fence) return -EINVAL; - ret = drm_fence_object_flush(fence, arg.type); + ret = drm_fence_object_flush(fence, arg->type); read_lock_irqsave(&fm->lock, flags); - arg.class = fence->class; - arg.type = fence->type; - arg.signaled = fence->signaled; + arg->class = fence->class; + arg->type = fence->type; + arg->signaled = fence->signaled; read_unlock_irqrestore(&fm->lock, flags); drm_fence_usage_deref_unlocked(&fence); - DRM_COPY_TO_USER_IOCTL((void __user *)data, arg, sizeof(arg)); return ret; } -int drm_fence_wait_ioctl(DRM_IOCTL_ARGS) +int drm_fence_wait_ioctl(struct drm_device *dev, void *data, struct drm_file *file_priv) { - DRM_DEVICE; int ret; struct drm_fence_manager *fm = &dev->fm; - struct drm_fence_arg arg; + struct drm_fence_arg *arg = data; struct drm_fence_object *fence; unsigned long flags; ret = 0; @@ -773,33 +753,29 @@ int drm_fence_wait_ioctl(DRM_IOCTL_ARGS) return -EINVAL; } - DRM_COPY_FROM_USER_IOCTL(arg, (void __user *)data, sizeof(arg)); - - fence = drm_lookup_fence_object(file_priv, arg.handle); + fence = drm_lookup_fence_object(file_priv, arg->handle); if (!fence) return -EINVAL; ret = drm_fence_object_wait(fence, - arg.flags & DRM_FENCE_FLAG_WAIT_LAZY, - 0, arg.type); + arg->flags & DRM_FENCE_FLAG_WAIT_LAZY, + 0, arg->type); read_lock_irqsave(&fm->lock, flags); - arg.class = fence->class; - arg.type = fence->type; - arg.signaled = fence->signaled; + arg->class = fence->class; + arg->type = fence->type; + arg->signaled = fence->signaled; read_unlock_irqrestore(&fm->lock, flags); drm_fence_usage_deref_unlocked(&fence); - DRM_COPY_TO_USER_IOCTL((void __user *)data, arg, sizeof(arg)); return ret; } -int drm_fence_emit_ioctl(DRM_IOCTL_ARGS) +int drm_fence_emit_ioctl(struct drm_device *dev, void *data, struct drm_file *file_priv) { - DRM_DEVICE; int ret; struct drm_fence_manager *fm = &dev->fm; - struct drm_fence_arg arg; + struct drm_fence_arg *arg = data; struct drm_fence_object *fence; unsigned long flags; ret = 0; @@ -809,32 +785,28 @@ int drm_fence_emit_ioctl(DRM_IOCTL_ARGS) return -EINVAL; } - DRM_COPY_FROM_USER_IOCTL(arg, (void __user *)data, sizeof(arg)); - LOCK_TEST_WITH_RETURN(dev, file_priv); - fence = drm_lookup_fence_object(file_priv, arg.handle); + fence = drm_lookup_fence_object(file_priv, arg->handle); if (!fence) return -EINVAL; - ret = drm_fence_object_emit(fence, arg.flags, arg.class, - arg.type); + ret = drm_fence_object_emit(fence, arg->flags, arg->class, + arg->type); read_lock_irqsave(&fm->lock, flags); - arg.class = fence->class; - arg.type = fence->type; - arg.signaled = fence->signaled; + arg->class = fence->class; + arg->type = fence->type; + arg->signaled = fence->signaled; read_unlock_irqrestore(&fm->lock, flags); drm_fence_usage_deref_unlocked(&fence); - DRM_COPY_TO_USER_IOCTL((void __user *)data, arg, sizeof(arg)); return ret; } -int drm_fence_buffers_ioctl(DRM_IOCTL_ARGS) +int drm_fence_buffers_ioctl(struct drm_device *dev, void *data, struct drm_file *file_priv) { - DRM_DEVICE; int ret; struct drm_fence_manager *fm = &dev->fm; - struct drm_fence_arg arg; + struct drm_fence_arg *arg = data; struct drm_fence_object *fence; unsigned long flags; ret = 0; @@ -844,32 +816,29 @@ int drm_fence_buffers_ioctl(DRM_IOCTL_ARGS) return -EINVAL; } - DRM_COPY_FROM_USER_IOCTL(arg, (void __user *)data, sizeof(arg)); - if (!dev->bm.initialized) { DRM_ERROR("Buffer object manager is not initialized\n"); return -EINVAL; } LOCK_TEST_WITH_RETURN(dev, file_priv); - ret = drm_fence_buffer_objects(file_priv, NULL, arg.flags, + ret = drm_fence_buffer_objects(file_priv, NULL, arg->flags, NULL, &fence); if (ret) return ret; ret = drm_fence_add_user_object(file_priv, fence, - arg.flags & + arg->flags & DRM_FENCE_FLAG_SHAREABLE); if (ret) return ret; atomic_inc(&fence->usage); - arg.handle = fence->base.hash.key; + arg->handle = fence->base.hash.key; read_lock_irqsave(&fm->lock, flags); - arg.class = fence->class; - arg.type = fence->type; - arg.signaled = fence->signaled; + arg->class = fence->class; + arg->type = fence->type; + arg->signaled = fence->signaled; read_unlock_irqrestore(&fm->lock, flags); drm_fence_usage_deref_unlocked(&fence); - DRM_COPY_TO_USER_IOCTL((void __user *)data, arg, sizeof(arg)); return ret; } |