From: Mika Kuoppala <mika.kuoppala@linux.intel.com>
To: Chris Wilson <chris@chris-wilson.co.uk>, intel-gfx@lists.freedesktop.org
Subject: Re: [PATCH v2] drm/i915/vma: Move the bind_count vs pin_count assertion to a helper
Date: Tue, 05 Jun 2018 13:22:17 +0300 [thread overview]
Message-ID: <87muw9pm7a.fsf@gaia.fi.intel.com> (raw)
In-Reply-To: <20180605094107.31367-1-chris@chris-wilson.co.uk>
Chris Wilson <chris@chris-wilson.co.uk> writes:
> To spare ourselves a long line later, refactor the repeated check of
> bind_count vs pin_count to a helper.
>
> v2: Fix up the commentary!
Matches the code now, didn't notice on the first round *blush*
Reviewed-by: Mika Kuoppala <mika.kuoppala@linux.intel.com>
>
> Suggested-by: Joonas Lahtinen <joonas.lahtinen@linux.intel.com>
> Signed-off-by: Chris Wilson <chris@chris-wilson.co.uk>
> Cc: Joonas Lahtinen <joonas.lahtinen@linux.intel.com>
> Cc: Mika Kuoppala <mika.kuoppala@linux.intel.com>
> Cc: Matthew Auld <matthew.william.auld@gmail.com>
> ---
> drivers/gpu/drm/i915/i915_vma.c | 16 ++++++++++++++--
> 1 file changed, 14 insertions(+), 2 deletions(-)
>
> diff --git a/drivers/gpu/drm/i915/i915_vma.c b/drivers/gpu/drm/i915/i915_vma.c
> index 9324d476e0a7..10bf654cd023 100644
> --- a/drivers/gpu/drm/i915/i915_vma.c
> +++ b/drivers/gpu/drm/i915/i915_vma.c
> @@ -459,6 +459,18 @@ bool i915_gem_valid_gtt_space(struct i915_vma *vma, unsigned long cache_level)
> return true;
> }
>
> +static void assert_bind_count(const struct drm_i915_gem_object *obj)
> +{
> + /*
> + * Combine the assertion that the object is bound and that we have
> + * pinned its pages. But we should never have bound the object
> + * more than we have pinned its pages. (For complete accuracy, we
> + * assume that no else is pinning the pages, but as a rough assertion
> + * that we will not run into problems later, this will do!)
> + */
> + GEM_BUG_ON(atomic_read(&obj->mm.pages_pin_count) < obj->bind_count);
> +}
> +
> /**
> * i915_vma_insert - finds a slot for the vma in its address space
> * @vma: the vma
> @@ -595,7 +607,7 @@ i915_vma_insert(struct i915_vma *vma, u64 size, u64 alignment, u64 flags)
> obj->bind_count++;
> spin_unlock(&dev_priv->mm.obj_lock);
>
> - GEM_BUG_ON(atomic_read(&obj->mm.pages_pin_count) < obj->bind_count);
> + assert_bind_count(obj);
>
> return 0;
>
> @@ -633,7 +645,7 @@ i915_vma_remove(struct i915_vma *vma)
> * reaped by the shrinker.
> */
> i915_gem_object_unpin_pages(obj);
> - GEM_BUG_ON(atomic_read(&obj->mm.pages_pin_count) < obj->bind_count);
> + assert_bind_count(obj);
> }
>
> int __i915_vma_do_pin(struct i915_vma *vma,
> --
> 2.17.1
_______________________________________________
Intel-gfx mailing list
Intel-gfx@lists.freedesktop.org
https://lists.freedesktop.org/mailman/listinfo/intel-gfx
next prev parent reply other threads:[~2018-06-05 10:22 UTC|newest]
Thread overview: 7+ messages / expand[flat|nested] mbox.gz Atom feed top
2018-06-05 9:34 [PATCH] drm/i915/vma: Move the bind_count vs pin_count assertion to a helper Chris Wilson
2018-06-05 9:38 ` Mika Kuoppala
2018-06-05 9:40 ` Chris Wilson
2018-06-05 9:41 ` [PATCH v2] " Chris Wilson
2018-06-05 10:22 ` Mika Kuoppala [this message]
2018-06-05 11:37 ` ✓ Fi.CI.BAT: success for drm/i915/vma: Move the bind_count vs pin_count assertion to a helper (rev2) Patchwork
2018-06-05 12:26 ` ✗ Fi.CI.IGT: failure " Patchwork
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=87muw9pm7a.fsf@gaia.fi.intel.com \
--to=mika.kuoppala@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.