From: Daniel Vetter <daniel@ffwll.ch>
To: Ben Widawsky <ben@bwidawsk.net>
Cc: Intel GFX <intel-gfx@lists.freedesktop.org>
Subject: Re: [PATCH 24/29] drm/i915: create vmas at execbuf
Date: Wed, 7 Aug 2013 22:52:35 +0200 [thread overview]
Message-ID: <20130807205235.GD22035@phenom.ffwll.local> (raw)
In-Reply-To: <1375315222-4785-25-git-send-email-ben@bwidawsk.net>
On Wed, Jul 31, 2013 at 05:00:17PM -0700, Ben Widawsky wrote:
> In order to transition more of our code over to using a VMA instead of
> an <OBJ, VM> pair - we must have the vma accessible at execbuf time. Up
> until now, we've only had a VMA when actually binding an object.
>
> The previous patch helped handle the distinction on bound vs. unbound.
> This patch will help us catch leaks, and other issues before we actually
> shuffle a bunch of stuff around.
>
> The subsequent patch to fix up the rest of execbuf should be mostly just
> moving code around, and this is the major functional change.
>
> v2: Release table_lock earlier so vma allocation needn't be atomic.
> (Chris)
>
> Signed-off-by: Ben Widawsky <ben@bwidawsk.net>
Merged up to this patch to dinq, thanks.
-Daniel
> ---
> drivers/gpu/drm/i915/i915_drv.h | 3 +++
> drivers/gpu/drm/i915/i915_gem.c | 25 ++++++++++++++++++-------
> drivers/gpu/drm/i915/i915_gem_execbuffer.c | 18 +++++++++++++-----
> 3 files changed, 34 insertions(+), 12 deletions(-)
>
> diff --git a/drivers/gpu/drm/i915/i915_drv.h b/drivers/gpu/drm/i915/i915_drv.h
> index f6c2812..c0eb7fd 100644
> --- a/drivers/gpu/drm/i915/i915_drv.h
> +++ b/drivers/gpu/drm/i915/i915_drv.h
> @@ -1857,6 +1857,9 @@ unsigned long i915_gem_obj_size(struct drm_i915_gem_object *o,
> struct i915_address_space *vm);
> struct i915_vma *i915_gem_obj_to_vma(struct drm_i915_gem_object *obj,
> struct i915_address_space *vm);
> +struct i915_vma *
> +i915_gem_obj_lookup_or_create_vma(struct drm_i915_gem_object *obj,
> + struct i915_address_space *vm);
> /* Some GGTT VM helpers */
> #define obj_to_ggtt(obj) \
> (&((struct drm_i915_private *)(obj)->base.dev->dev_private)->gtt.base)
> diff --git a/drivers/gpu/drm/i915/i915_gem.c b/drivers/gpu/drm/i915/i915_gem.c
> index 21331d8..72bd53c 100644
> --- a/drivers/gpu/drm/i915/i915_gem.c
> +++ b/drivers/gpu/drm/i915/i915_gem.c
> @@ -3101,8 +3101,7 @@ i915_gem_object_bind_to_vm(struct drm_i915_gem_object *obj,
> struct i915_vma *vma;
> int ret;
>
> - if (WARN_ON(!list_empty(&obj->vma_list)))
> - return -EBUSY;
> + BUG_ON(!i915_is_ggtt(vm));
>
> fence_size = i915_gem_get_gtt_size(dev,
> obj->base.size,
> @@ -3142,16 +3141,15 @@ i915_gem_object_bind_to_vm(struct drm_i915_gem_object *obj,
>
> i915_gem_object_pin_pages(obj);
>
> - /* FIXME: For now we only ever use 1 VMA per object */
> - BUG_ON(!i915_is_ggtt(vm));
> - WARN_ON(!list_empty(&obj->vma_list));
> -
> - vma = i915_gem_vma_create(obj, vm);
> + vma = i915_gem_obj_lookup_or_create_vma(obj, vm);
> if (IS_ERR(vma)) {
> i915_gem_object_unpin_pages(obj);
> return PTR_ERR(vma);
> }
>
> + /* For now we only ever use 1 vma per object */
> + WARN_ON(!list_is_singular(&obj->vma_list));
> +
> search_free:
> ret = drm_mm_insert_node_in_range_generic(&vm->mm, &vma->node,
> size, alignment,
> @@ -4800,3 +4798,16 @@ struct i915_vma *i915_gem_obj_to_vma(struct drm_i915_gem_object *obj,
>
> return NULL;
> }
> +
> +struct i915_vma *
> +i915_gem_obj_lookup_or_create_vma(struct drm_i915_gem_object *obj,
> + struct i915_address_space *vm)
> +{
> + struct i915_vma *vma;
> +
> + vma = i915_gem_obj_to_vma(obj, vm);
> + if (!vma)
> + vma = i915_gem_vma_create(obj, vm);
> +
> + return vma;
> +}
> diff --git a/drivers/gpu/drm/i915/i915_gem_execbuffer.c b/drivers/gpu/drm/i915/i915_gem_execbuffer.c
> index 0f21702..3f17a55 100644
> --- a/drivers/gpu/drm/i915/i915_gem_execbuffer.c
> +++ b/drivers/gpu/drm/i915/i915_gem_execbuffer.c
> @@ -85,14 +85,14 @@ static int
> eb_lookup_objects(struct eb_objects *eb,
> struct drm_i915_gem_exec_object2 *exec,
> const struct drm_i915_gem_execbuffer2 *args,
> + struct i915_address_space *vm,
> struct drm_file *file)
> {
> + struct drm_i915_gem_object *obj;
> int i;
>
> spin_lock(&file->table_lock);
> for (i = 0; i < args->buffer_count; i++) {
> - struct drm_i915_gem_object *obj;
> -
> obj = to_intel_bo(idr_find(&file->object_idr, exec[i].handle));
> if (obj == NULL) {
> spin_unlock(&file->table_lock);
> @@ -110,6 +110,15 @@ eb_lookup_objects(struct eb_objects *eb,
>
> drm_gem_object_reference(&obj->base);
> list_add_tail(&obj->exec_list, &eb->objects);
> + }
> + spin_unlock(&file->table_lock);
> +
> + list_for_each_entry(obj, &eb->objects, exec_list) {
> + struct i915_vma *vma;
> +
> + vma = i915_gem_obj_lookup_or_create_vma(obj, vm);
> + if (IS_ERR(vma))
> + return PTR_ERR(vma);
>
> obj->exec_entry = &exec[i];
> if (eb->and < 0) {
> @@ -121,7 +130,6 @@ eb_lookup_objects(struct eb_objects *eb,
> &eb->buckets[handle & eb->and]);
> }
> }
> - spin_unlock(&file->table_lock);
>
> return 0;
> }
> @@ -672,7 +680,7 @@ i915_gem_execbuffer_relocate_slow(struct drm_device *dev,
>
> /* reacquire the objects */
> eb_reset(eb);
> - ret = eb_lookup_objects(eb, exec, args, file);
> + ret = eb_lookup_objects(eb, exec, args, vm, file);
> if (ret)
> goto err;
>
> @@ -1009,7 +1017,7 @@ i915_gem_do_execbuffer(struct drm_device *dev, void *data,
> }
>
> /* Look up object handles */
> - ret = eb_lookup_objects(eb, exec, args, file);
> + ret = eb_lookup_objects(eb, exec, args, vm, file);
> if (ret)
> goto err;
>
> --
> 1.8.3.4
>
> _______________________________________________
> 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
next prev parent reply other threads:[~2013-08-07 20:52 UTC|newest]
Thread overview: 70+ messages / expand[flat|nested] mbox.gz Atom feed top
2013-07-31 23:59 [PATCH 00/29] Completion of i915 VMAs v2 Ben Widawsky
2013-07-31 23:59 ` [PATCH 01/29] drm/i915: Create an init vm Ben Widawsky
2013-07-31 23:59 ` [PATCH 02/29] drm/i915: Rework drop caches for checkpatch Ben Widawsky
2013-08-03 11:32 ` Chris Wilson
2013-08-03 22:10 ` Ben Widawsky
2013-07-31 23:59 ` [PATCH 03/29] drm/i915: Make proper functions for VMs Ben Widawsky
2013-07-31 23:59 ` [PATCH 04/29] drm/i915: Use bound list for inactive shrink Ben Widawsky
2013-07-31 23:59 ` [PATCH 05/29] drm/i915: Add VM to pin Ben Widawsky
2013-07-31 23:59 ` [PATCH 06/29] drm/i915: Use ggtt_vm to save some typing Ben Widawsky
2013-08-01 0:00 ` [PATCH 07/29] drm/i915: Update describe_obj Ben Widawsky
2013-08-01 0:00 ` [PATCH 08/29] drm/i915: Rework __i915_gem_shrink Ben Widawsky
2013-08-05 8:59 ` Daniel Vetter
2013-08-01 0:00 ` [PATCH 09/29] drm/i915: thread address space through execbuf Ben Widawsky
2013-08-05 9:39 ` Daniel Vetter
2013-08-01 0:00 ` [PATCH 10/29] drm/i915: make caching operate on all address spaces Ben Widawsky
2013-08-05 9:41 ` Daniel Vetter
2013-08-01 0:00 ` [PATCH 11/29] drm/i915: BUG_ON put_pages later Ben Widawsky
2013-08-05 9:42 ` Daniel Vetter
2013-08-01 0:00 ` [PATCH 12/29] drm/i915: make reset&hangcheck code VM aware Ben Widawsky
2013-08-01 0:00 ` [PATCH 13/29] drm/i915: clear domains for all objects on reset Ben Widawsky
2013-08-03 10:59 ` Chris Wilson
2013-08-03 22:24 ` Ben Widawsky
2013-08-05 9:52 ` Daniel Vetter
2013-08-05 16:46 ` [PATCH 13/29] drm/i915: eliminate dead domain clearing " Ben Widawsky
2013-08-05 17:13 ` Daniel Vetter
2013-08-01 0:00 ` [PATCH 14/29] drm/i915: Restore PDEs on gtt restore Ben Widawsky
2013-08-06 18:14 ` Daniel Vetter
2013-08-01 0:00 ` [PATCH 15/29] drm/i915: Improve VMA comments Ben Widawsky
2013-08-01 0:00 ` [PATCH 16/29] drm/i915: Cleanup more of VMA in destroy Ben Widawsky
2013-08-01 0:00 ` [PATCH 17/29] drm/i915: plumb VM into bind/unbind code Ben Widawsky
2013-08-06 18:29 ` Daniel Vetter
2013-08-06 18:54 ` Daniel Vetter
2013-08-01 0:00 ` [PATCH 18/29] drm/i915: Use new bind/unbind in eviction code Ben Widawsky
2013-08-06 18:39 ` Daniel Vetter
2013-08-06 21:27 ` Ben Widawsky
2013-08-06 21:29 ` Daniel Vetter
2013-08-06 22:57 ` Ben Widawsky
2013-08-06 22:59 ` Daniel Vetter
2013-08-06 23:25 ` Ben Widawsky
2013-08-06 23:44 ` Daniel Vetter
2013-08-07 18:24 ` Ben Widawsky
2013-08-01 0:00 ` [PATCH 19/29] drm/i915: turn bound_ggtt checks to bound_any Ben Widawsky
2013-08-03 11:03 ` Chris Wilson
2013-08-03 22:26 ` Ben Widawsky
2013-08-06 18:43 ` Daniel Vetter
2013-08-06 21:29 ` Ben Widawsky
2013-08-01 0:00 ` [PATCH 20/29] drm/i915: Fix up map and fenceable for VMA Ben Widawsky
2013-08-06 19:11 ` Daniel Vetter
2013-08-07 18:37 ` Ben Widawsky
2013-08-07 20:32 ` Daniel Vetter
2013-08-01 0:00 ` [PATCH 21/29] drm/i915: mm_list is per VMA Ben Widawsky
2013-08-06 19:38 ` Daniel Vetter
2013-08-07 0:28 ` Ben Widawsky
2013-08-07 20:52 ` Daniel Vetter
2013-08-08 4:32 ` Ben Widawsky
2013-08-08 6:46 ` Daniel Vetter
2013-08-08 18:10 ` Ben Widawsky
2013-08-01 0:00 ` [PATCH 22/29] drm/i915: Update error capture for VMs Ben Widawsky
2013-08-01 0:00 ` [PATCH 23/29] drm/i915: Add vma to list at creation Ben Widawsky
2013-08-01 0:00 ` [PATCH 24/29] drm/i915: create vmas at execbuf Ben Widawsky
2013-08-07 20:52 ` Daniel Vetter [this message]
2013-08-01 0:00 ` [PATCH 25/29] drm/i915: Convert execbuf code to use vmas Ben Widawsky
2013-08-06 20:43 ` Daniel Vetter
2013-08-06 20:45 ` Daniel Vetter
2013-08-01 0:00 ` [PATCH 26/29] drm/i915: Convert active API to VMA Ben Widawsky
2013-08-06 20:47 ` Daniel Vetter
2013-08-01 0:00 ` [PATCH 27/29] drm/i915: Add bind/unbind object functions to VM Ben Widawsky
2013-08-01 0:00 ` [PATCH 28/29] drm/i915: Use the new vm [un]bind functions Ben Widawsky
2013-08-06 20:58 ` Daniel Vetter
2013-08-01 0:00 ` [PATCH 29/29] drm/i915: eliminate vm->insert_entries() Ben Widawsky
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=20130807205235.GD22035@phenom.ffwll.local \
--to=daniel@ffwll.ch \
--cc=ben@bwidawsk.net \
--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