public inbox for intel-gfx@lists.freedesktop.org
 help / color / mirror / Atom feed
From: Tvrtko Ursulin <tvrtko.ursulin@linux.intel.com>
To: Chris Wilson <chris@chris-wilson.co.uk>,
	intel-gfx@lists.freedesktop.org,
	Gwenole Beauchesne <gwenole.beauchesne@intel.com>
Subject: Re: [PATCH] drm/i915: Allow userptr backchannel for passing aroung GTT mappings
Date: Mon, 13 Apr 2015 12:01:45 +0100	[thread overview]
Message-ID: <552BA219.1070509@linux.intel.com> (raw)
In-Reply-To: <20150402162714.GH7934@nuc-i3427.alporthouse.com>


On 04/02/2015 05:27 PM, Chris Wilson wrote:
> On Thu, Apr 02, 2015 at 05:11:58PM +0100, Tvrtko Ursulin wrote:
>>> +static struct drm_i915_gem_object *
>>> +find_object_from_vma(struct drm_device *dev,
>>> +		     struct drm_i915_gem_userptr *args)
>>> +{
>>> +	struct drm_i915_gem_object *obj = NULL;
>>> +	struct vm_area_struct *vma;
>>> +
>>> +	down_read(&current->mm->mmap_sem);
>>> +	vma = find_vma(current->mm, args->user_ptr);
>>> +	if (vma == NULL)
>>> +		goto out;
>>> +
>>> +	if (vma->vm_ops != dev->driver->gem_vm_ops)
>>> +		goto out;
>>> +
>>> +	if (vma->vm_start != args->user_ptr ||
>>> +	    vma->vm_end != args->user_ptr + args->user_size) {
>>> +		obj = ERR_PTR(-EINVAL);
>>> +		goto out;
>>> +	}
>>> +
>>> +	obj = to_intel_bo(vma->vm_private_data);
>>> +	drm_gem_object_reference(obj);
>>
>> Hm, can't this race with last unreference in general, and with
>> cleanup worker with userptr objects?
>
> The vma holds a reference to the object and that reference is dropped
> whilst holding down_write(current->mm->mmap_sem), hence I think the
> down_read(current->mm->mmap_sem) is sufficient locking to acquire a
> reference for ourselves.

Yes, I completely forgot about this little detail. :)

>>> +out:		 ret = drm_gem_handle_create(file, &obj->base, &handle);
>>>
>>>   	/* drop reference from allocate - handle holds it now */
>>>   	drm_gem_object_unreference_unlocked(&obj->base);
>>
>> Thing I don't like is how the user of this has no idea what kind of
>> object it "imported". Maybe it doesn't matter, hm. Need to think
>> about it more.
>
> Indeed. But since the userptr is a strict subset of the general bo, if
> they follow the rules for userptr bo then they won't notice a
> difference. read/writes into the memory block are coherent (since the
> pointer is wc) so as far the caller is concerned I think it just ends up
> being slower cpu side, faster gpu side than a system memory snooped
> userptr bo.

Is access to non-userptr bo's interesting to users of this - could we 
reject that and not lose out?

Regards,

Tvrtko
_______________________________________________
Intel-gfx mailing list
Intel-gfx@lists.freedesktop.org
http://lists.freedesktop.org/mailman/listinfo/intel-gfx

  reply	other threads:[~2015-04-13 11:01 UTC|newest]

Thread overview: 7+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2015-04-02 15:04 [PATCH] drm/i915: Allow userptr backchannel for passing aroung GTT mappings Chris Wilson
2015-04-02 16:11 ` Tvrtko Ursulin
2015-04-02 16:27   ` Chris Wilson
2015-04-13 11:01     ` Tvrtko Ursulin [this message]
2015-04-03  1:07 ` shuang.he
2015-04-07  8:53 ` Daniel Vetter
2015-04-07 10:22   ` 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=552BA219.1070509@linux.intel.com \
    --to=tvrtko.ursulin@linux.intel.com \
    --cc=chris@chris-wilson.co.uk \
    --cc=gwenole.beauchesne@intel.com \
    --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 a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox