Re: [PATCH 3/3] drm/i915: Ignore duplicate VMA stored within the per-object handle LUT

Joonas Lahtinen
2017-08-23T10:05:35Z

On Tue, 2017-08-22 at 12:05 +0100, Chris Wilson wrote:
> By using drm_gem_flink/drm_gem_open on an object using the same fd, it
> is possible for a client to create multiple handles pointing to the same
> object (tied to the same contexts and VMA), as exemplified by
> igt::gem_handle_to_libdrm_bo(). Since this duplication has been possible
> since forever, we cannot assume that the handle:(fpriv, object) is
> unique and so must handle the multiple users of a single VMA.
>
> Testcase: igt/gem_close
> Bugzilla: https://bugs.freedesktop.org/show_bug.cgi?id=102355
> Fixes: d1b48c1e7184 ("drm/i915: Replace execbuf vma ht with an idr")
> Signed-off-by: Chris Wilson <chris@chris-wilson.co.uk>
> Cc: Tvrtko Ursulin <tvrtko.ursulin@intel.com>
> Cc: Joonas Lahtinen <joonas.lahtinen@linux.intel.com>

<SNIP>

> +++ b/drivers/gpu/drm/i915/i915_gem_execbuffer.c
> @@ -720,6 +720,7 @@ static int eb_lookup_vmas(struct i915_execbuffer *eb)
> goto err_obj;
> }
>
> + vma->open_count++;
> list_add(&lut->obj_link, &obj->lut_list);

This code maybe should be in i915_gem.c as "i915_gem_object_add_lut" or
something.

> +++ b/drivers/gpu/drm/i915/i915_vma.h
> @@ -59,6 +59,7 @@ struct i915_vma {
> u32 fence_size;
> u32 fence_alignment;
>
> + unsigned int open_count;
> unsigned int flags;

Kerneldocs.

Regards, Joonas
--
Joonas Lahtinen
Open Source Technology Center
Intel Corporation