From: Daniel Vetter <daniel@ffwll.ch>
To: Chris Wilson <chris@chris-wilson.co.uk>
Cc: intel-gfx@lists.freedesktop.org
Subject: Re: [PATCH] Revert "drm/i915: Disallow pin ioctl completely for kms drivers"
Date: Tue, 25 Nov 2014 13:01:39 +0100 [thread overview]
Message-ID: <20141125120139.GA25711@phenom.ffwll.local> (raw)
In-Reply-To: <1416915776-20730-1-git-send-email-chris@chris-wilson.co.uk>
On Tue, Nov 25, 2014 at 11:42:56AM +0000, Chris Wilson wrote:
> This reverts commit c211a47c2c28562f8a3fff9e027be1a3ed9e154a.
>
> This causes an unwarranteed API break for existing and active userspace.
>
> Signed-off-by: Chris Wilson <chris@chris-wilson.co.uk>
Hm, SNA still seems to be able to cope with this and I really don't see
the point of keeping this interface going and patching it up. With GEM the
kernel should be in control of shared resources, letting userspace in to
the game just leads to tears. And we have them now. Keeping pinning around
just because we've forgotten to properly disable it was ok with me, but
fixing it up when it starts to fall apart really isn't.
-Daniel
> ---
> 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
--
Daniel Vetter
Software Engineer, Intel Corporation
+41 (0) 79 365 57 48 - http://blog.ffwll.ch
_______________________________________________
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-25 12:01 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 [this message]
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
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=20141125120139.GA25711@phenom.ffwll.local \
--to=daniel@ffwll.ch \
--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.