From: Jani Nikula <jani.nikula@linux.intel.com>
To: Chris Wilson <chris@chris-wilson.co.uk>, intel-gfx@lists.freedesktop.org
Subject: Re: [PATCH] Revert "drm/i915: Disallow pin ioctl completely for kms drivers"
Date: Thu, 27 Nov 2014 15:56:38 +0200 [thread overview]
Message-ID: <87oars3fxl.fsf@intel.com> (raw)
In-Reply-To: <1416915776-20730-1-git-send-email-chris@chris-wilson.co.uk>
On Tue, 25 Nov 2014, Chris Wilson <chris@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@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@lists.freedesktop.org
> http://lists.freedesktop.org/mailman/listinfo/intel-gfx
--
Jani Nikula, Intel Open Source Technology Center
_______________________________________________
Intel-gfx mailing list
Intel-gfx@lists.freedesktop.org
http://lists.freedesktop.org/mailman/listinfo/intel-gfx
next prev parent reply other threads:[~2014-11-27 13:56 UTC|newest]
Thread overview: 8+ messages / expand[flat|nested] mbox.gz Atom feed top
2014-11-25 11:42 [PATCH] Revert "drm/i915: Disallow pin ioctl completely for kms drivers" Chris Wilson
2014-11-25 12:01 ` Daniel Vetter
2014-11-25 12:06 ` Chris Wilson
2014-11-25 13:34 ` Daniel Vetter
2014-11-25 20:47 ` Chris Wilson
2014-11-26 9:41 ` Daniel Vetter
2014-11-27 13:56 ` Jani Nikula [this message]
2014-11-27 14:13 ` Chris Wilson
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=87oars3fxl.fsf@intel.com \
--to=jani.nikula@linux.intel.com \
--cc=chris@chris-wilson.co.uk \
--cc=intel-gfx@lists.freedesktop.org \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.