[Intel-gfx] [PATCH] Revert "drm/i915: Disallow pin ioctl completely for kms drivers"
Jani Nikula
jani.nikula at linux.intel.com
Thu Nov 27 14:56:38 CET 2014
On Tue, 25 Nov 2014, Chris Wilson <chris at chris-wilson.co.uk> wrote:
> This reverts commit c211a47c2c28562f8a3fff9e027be1a3ed9e154a.
>
> This causes an unwarranteed API break for existing and active userspace.
Ville had an interesting observation regarding the commit being
reverted: https://bugs.freedesktop.org/show_bug.cgi?id=86679#c9
BR,
Jani.
>
> Signed-off-by: Chris Wilson <chris at chris-wilson.co.uk>
> ---
> drivers/gpu/drm/i915/i915_gem.c | 90 +++++++++++++++++++++++++++++++++++++++++
> 1 file changed, 90 insertions(+)
>
> diff --git a/drivers/gpu/drm/i915/i915_gem.c b/drivers/gpu/drm/i915/i915_gem.c
> index 614bc2bc16fe..4a1ca7abd7f9 100644
> --- a/drivers/gpu/drm/i915/i915_gem.c
> +++ b/drivers/gpu/drm/i915/i915_gem.c
> @@ -4252,6 +4252,96 @@ i915_gem_object_unpin_fence(struct drm_i915_gem_object *obj)
> }
>
> int
> +i915_gem_pin_ioctl(struct drm_device *dev, void *data,
> + struct drm_file *file)
> +{
> + struct drm_i915_gem_pin *args = data;
> + struct drm_i915_gem_object *obj;
> + int ret;
> +
> + ret = i915_mutex_lock_interruptible(dev);
> + if (ret)
> + return ret;
> +
> + obj = to_intel_bo(drm_gem_object_lookup(dev, file, args->handle));
> + if (&obj->base == NULL) {
> + ret = -ENOENT;
> + goto unlock;
> + }
> +
> + if (obj->madv != I915_MADV_WILLNEED) {
> + DRM_DEBUG("Attempting to pin a purgeable buffer\n");
> + ret = -EFAULT;
> + goto out;
> + }
> +
> + if (obj->pin_filp != NULL && obj->pin_filp != file) {
> + DRM_DEBUG("Already pinned in i915_gem_pin_ioctl(): %d\n",
> + args->handle);
> + ret = -EINVAL;
> + goto out;
> + }
> +
> + if (obj->user_pin_count == ULONG_MAX) {
> + ret = -EBUSY;
> + goto out;
> + }
> +
> + if (obj->user_pin_count == 0) {
> + ret = i915_gem_obj_ggtt_pin(obj, args->alignment, PIN_MAPPABLE);
> + if (ret)
> + goto out;
> + }
> +
> + obj->user_pin_count++;
> + obj->pin_filp = file;
> +
> + args->offset = i915_gem_obj_ggtt_offset(obj);
> +out:
> + drm_gem_object_unreference(&obj->base);
> +unlock:
> + mutex_unlock(&dev->struct_mutex);
> + return ret;
> +}
> +
> +int
> +i915_gem_unpin_ioctl(struct drm_device *dev, void *data,
> + struct drm_file *file)
> +{
> + struct drm_i915_gem_pin *args = data;
> + struct drm_i915_gem_object *obj;
> + int ret;
> +
> + ret = i915_mutex_lock_interruptible(dev);
> + if (ret)
> + return ret;
> +
> + obj = to_intel_bo(drm_gem_object_lookup(dev, file, args->handle));
> + if (&obj->base == NULL) {
> + ret = -ENOENT;
> + goto unlock;
> + }
> +
> + if (obj->pin_filp != file) {
> + DRM_DEBUG("Not pinned by caller in i915_gem_pin_ioctl(): %d\n",
> + args->handle);
> + ret = -EINVAL;
> + goto out;
> + }
> + obj->user_pin_count--;
> + if (obj->user_pin_count == 0) {
> + obj->pin_filp = NULL;
> + i915_gem_object_ggtt_unpin(obj);
> + }
> +
> +out:
> + drm_gem_object_unreference(&obj->base);
> +unlock:
> + mutex_unlock(&dev->struct_mutex);
> + return ret;
> +}
> +
> +int
> i915_gem_busy_ioctl(struct drm_device *dev, void *data,
> struct drm_file *file)
> {
> --
> 2.1.3
>
> _______________________________________________
> Intel-gfx mailing list
> Intel-gfx at lists.freedesktop.org
> http://lists.freedesktop.org/mailman/listinfo/intel-gfx
--
Jani Nikula, Intel Open Source Technology Center
More information about the Intel-gfx
mailing list