From: Mika Kuoppala <mika.kuoppala@linux.intel.com>
To: Chris Wilson <chris@chris-wilson.co.uk>, intel-gfx@lists.freedesktop.org
Cc: igt-dev@lists.freedesktop.org
Subject: Re: [Intel-gfx] [igt-dev] [PATCH i-g-t] i915/gem_ctx_shared: Prefer explicit domain control
Date: Fri, 14 Jun 2019 16:18:03 +0300 [thread overview]
Message-ID: <87sgsc8fw4.fsf@gaia.fi.intel.com> (raw)
In-Reply-To: <20190611081719.16367-1-chris@chris-wilson.co.uk>
Chris Wilson <chris@chris-wilson.co.uk> writes:
> Since we are fiddling behind the scenes, we are writing to objects that
> are not part of the execbuffer, do not rely on implicit domain
> management being able to track the appropriate CPU cache status.
>
> Bugzilla: https://bugs.freedesktop.org/show_bug.cgi?id=110890
> Signed-off-by: Chris Wilson <chris@chris-wilson.co.uk>
Reviewed-by: Mika Kuoppala <mika.kuoppala@linux.intel.com>
> ---
> tests/i915/gem_ctx_shared.c | 32 ++++++++++++++++++++++----------
> 1 file changed, 22 insertions(+), 10 deletions(-)
>
> diff --git a/tests/i915/gem_ctx_shared.c b/tests/i915/gem_ctx_shared.c
> index 069964546..ed43e8903 100644
> --- a/tests/i915/gem_ctx_shared.c
> +++ b/tests/i915/gem_ctx_shared.c
> @@ -184,27 +184,30 @@ static void exhaust_shared_gtt(int i915, unsigned int flags)
> static void exec_shared_gtt(int i915, unsigned int ring)
> {
> const int gen = intel_gen(intel_get_drm_devid(i915));
> - const uint32_t bbe = MI_BATCH_BUFFER_END;
> - struct drm_i915_gem_exec_object2 obj = {
> - .handle = gem_create(i915, 4096)
> - };
> + struct drm_i915_gem_exec_object2 obj = {};
> struct drm_i915_gem_execbuffer2 execbuf = {
> .buffers_ptr = to_user_pointer(&obj),
> .buffer_count = 1,
> .flags = ring,
> };
> - uint32_t scratch = obj.handle;
> + uint32_t scratch, *s;
> uint32_t batch[16];
> int i;
>
> gem_require_ring(i915, ring);
> igt_require(gem_can_store_dword(i915, ring));
>
> + scratch = gem_create(i915, 4096);
> + s = gem_mmap__cpu(i915, scratch, 0, 4096, PROT_WRITE);
> +
> + gem_set_domain(i915, scratch, I915_GEM_DOMAIN_CPU, I915_GEM_DOMAIN_CPU);
> + *s = MI_BATCH_BUFFER_END;
> +
> /* Load object into place in the GTT */
> - gem_write(i915, obj.handle, 0, &bbe, sizeof(bbe));
> + obj.handle = scratch;
> gem_execbuf(i915, &execbuf);
>
> - /* Presume nothing causes an eviction in the meantime */
> + /* Presume nothing causes an eviction in the meantime! */
>
> obj.handle = gem_create(i915, 4096);
>
> @@ -235,10 +238,19 @@ static void exec_shared_gtt(int i915, unsigned int ring)
> gem_sync(i915, obj.handle); /* write hazard lies */
> gem_close(i915, obj.handle);
>
> - gem_read(i915, scratch, 0, batch, sizeof(uint32_t));
> - gem_close(i915, scratch);
> + /*
> + * If we created the new context with the old GTT, the write
> + * into the stale location of scratch will have landed in the right
> + * object. Otherwise, it should read the previous value of
> + * MI_BATCH_BUFFER_END.
> + *
> + * Setting .write = CPU to paper over our write hazard lies above.
> + */
> + gem_set_domain(i915, scratch, I915_GEM_DOMAIN_CPU, I915_GEM_DOMAIN_CPU);
> + igt_assert_eq_u32(*s, 0xc0ffee);
>
> - igt_assert_eq_u32(*batch, 0xc0ffee);
> + munmap(s, 4096);
> + gem_close(i915, scratch);
> }
>
> static int nop_sync(int i915, uint32_t ctx, unsigned int ring, int64_t timeout)
> --
> 2.20.1
>
> _______________________________________________
> igt-dev mailing list
> igt-dev@lists.freedesktop.org
> https://lists.freedesktop.org/mailman/listinfo/igt-dev
_______________________________________________
Intel-gfx mailing list
Intel-gfx@lists.freedesktop.org
https://lists.freedesktop.org/mailman/listinfo/intel-gfx
prev parent reply other threads:[~2019-06-14 13:18 UTC|newest]
Thread overview: 4+ messages / expand[flat|nested] mbox.gz Atom feed top
2019-06-11 8:17 [Intel-gfx] [PATCH i-g-t] i915/gem_ctx_shared: Prefer explicit domain control Chris Wilson
2019-06-11 8:50 ` [igt-dev] ✓ Fi.CI.BAT: success for " Patchwork
2019-06-12 10:35 ` [igt-dev] ✓ Fi.CI.IGT: " Patchwork
2019-06-14 13:18 ` Mika Kuoppala [this message]
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=87sgsc8fw4.fsf@gaia.fi.intel.com \
--to=mika.kuoppala@linux.intel.com \
--cc=chris@chris-wilson.co.uk \
--cc=igt-dev@lists.freedesktop.org \
--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