From: Tvrtko Ursulin <tvrtko.ursulin@linux.intel.com>
To: Chris Wilson <chris@chris-wilson.co.uk>, intel-gfx@lists.freedesktop.org
Subject: Re: [PATCH 04/23] drm/i915: Push the ring creation flags to the backend
Date: Wed, 24 Jul 2019 12:11:54 +0100 [thread overview]
Message-ID: <af76214d-41e9-f986-61ba-6d5100da9330@linux.intel.com> (raw)
In-Reply-To: <20190723183842.20372-4-chris@chris-wilson.co.uk>
On 23/07/2019 19:38, Chris Wilson wrote:
> Push the ring creation flags from the outer GEM context to the inner
> intel_cotnext to avoid an unsightly back-reference from inside the
> backend.
Sorry I find this quite ugly. Passing in integers in pointers filed and
casting back and forth.
> Signed-off-by: Chris Wilson <chris@chris-wilson.co.uk>
> ---
> drivers/gpu/drm/i915/gem/i915_gem_context.c | 25 +++++++++++++------
> .../gpu/drm/i915/gem/i915_gem_context_types.h | 3 ---
> drivers/gpu/drm/i915/gt/intel_context.c | 1 +
> drivers/gpu/drm/i915/gt/intel_context.h | 5 ++++
> drivers/gpu/drm/i915/gt/intel_lrc.c | 5 ++--
> drivers/gpu/drm/i915/i915_debugfs.c | 23 +++++++++++------
> 6 files changed, 41 insertions(+), 21 deletions(-)
>
> diff --git a/drivers/gpu/drm/i915/gem/i915_gem_context.c b/drivers/gpu/drm/i915/gem/i915_gem_context.c
> index 1b3dc7258ef2..18b226bc5e3a 100644
> --- a/drivers/gpu/drm/i915/gem/i915_gem_context.c
> +++ b/drivers/gpu/drm/i915/gem/i915_gem_context.c
> @@ -296,6 +296,8 @@ static struct i915_gem_engines *default_engines(struct i915_gem_context *ctx)
> return ERR_CAST(ce);
> }
>
> + ce->ring = __intel_context_ring_size(SZ_16K);
> +
> e->engines[id] = ce;
> }
> e->num_engines = id;
> @@ -434,8 +436,6 @@ __create_context(struct drm_i915_private *i915)
> i915_gem_context_set_bannable(ctx);
> i915_gem_context_set_recoverable(ctx);
>
> - ctx->ring_size = 4 * PAGE_SIZE;
> -
> for (i = 0; i < ARRAY_SIZE(ctx->hang_timestamp); i++)
> ctx->hang_timestamp[i] = jiffies - CONTEXT_FAST_HANG_JIFFIES;
>
> @@ -565,8 +565,15 @@ i915_gem_context_create_gvt(struct drm_device *dev)
> i915_gem_context_set_closed(ctx); /* not user accessible */
> i915_gem_context_clear_bannable(ctx);
> i915_gem_context_set_force_single_submission(ctx);
> - if (!USES_GUC_SUBMISSION(to_i915(dev)))
> - ctx->ring_size = 512 * PAGE_SIZE; /* Max ring buffer size */
> + if (!USES_GUC_SUBMISSION(to_i915(dev))) {
> + const unsigned long ring_size = 512 * SZ_4K; /* max */
> + struct i915_gem_engines_iter it;
> + struct intel_context *ce;
> +
> + for_each_gem_engine(ce, i915_gem_context_lock_engines(ctx), it)
> + ce->ring = __intel_context_ring_size(ring_size);
> + i915_gem_context_unlock_engines(ctx);
> + }
>
> GEM_BUG_ON(i915_gem_context_is_kernel(ctx));
> out:
> @@ -605,7 +612,6 @@ i915_gem_context_create_kernel(struct drm_i915_private *i915, int prio)
>
> i915_gem_context_clear_bannable(ctx);
> ctx->sched.priority = I915_USER_PRIORITY(prio);
> - ctx->ring_size = PAGE_SIZE;
>
> GEM_BUG_ON(!i915_gem_context_is_kernel(ctx));
>
> @@ -1589,6 +1595,7 @@ set_engines(struct i915_gem_context *ctx,
> for (n = 0; n < num_engines; n++) {
> struct i915_engine_class_instance ci;
> struct intel_engine_cs *engine;
> + struct intel_context *ce;
>
> if (copy_from_user(&ci, &user->engines[n], sizeof(ci))) {
> __free_engines(set.engines, n);
> @@ -1611,11 +1618,15 @@ set_engines(struct i915_gem_context *ctx,
> return -ENOENT;
> }
>
> - set.engines->engines[n] = intel_context_create(ctx, engine);
> - if (!set.engines->engines[n]) {
> + ce = intel_context_create(ctx, engine);
> + if (!ce) {
> __free_engines(set.engines, n);
> return -ENOMEM;
> }
> +
> + ce->ring = __intel_context_ring_size(SZ_16K);
> +
> + set.engines->engines[n] = ce;
> }
> set.engines->num_engines = num_engines;
>
> diff --git a/drivers/gpu/drm/i915/gem/i915_gem_context_types.h b/drivers/gpu/drm/i915/gem/i915_gem_context_types.h
> index a02d98494078..260d59cc3de8 100644
> --- a/drivers/gpu/drm/i915/gem/i915_gem_context_types.h
> +++ b/drivers/gpu/drm/i915/gem/i915_gem_context_types.h
> @@ -169,9 +169,6 @@ struct i915_gem_context {
>
> struct i915_sched_attr sched;
>
> - /** ring_size: size for allocating the per-engine ring buffer */
> - u32 ring_size;
> -
> /** guilty_count: How many times this context has caused a GPU hang. */
> atomic_t guilty_count;
> /**
> diff --git a/drivers/gpu/drm/i915/gt/intel_context.c b/drivers/gpu/drm/i915/gt/intel_context.c
> index 9e4f51ce52ff..295fa0ddbcac 100644
> --- a/drivers/gpu/drm/i915/gt/intel_context.c
> +++ b/drivers/gpu/drm/i915/gt/intel_context.c
> @@ -196,6 +196,7 @@ intel_context_init(struct intel_context *ce,
> ce->engine = engine;
> ce->ops = engine->cops;
> ce->sseu = engine->sseu;
> + ce->ring = __intel_context_ring_size(SZ_4K);
>
> INIT_LIST_HEAD(&ce->signal_link);
> INIT_LIST_HEAD(&ce->signals);
> diff --git a/drivers/gpu/drm/i915/gt/intel_context.h b/drivers/gpu/drm/i915/gt/intel_context.h
> index 23c7e4c0ce7c..3f54eb3d10ab 100644
> --- a/drivers/gpu/drm/i915/gt/intel_context.h
> +++ b/drivers/gpu/drm/i915/gt/intel_context.h
> @@ -145,4 +145,9 @@ int intel_context_prepare_remote_request(struct intel_context *ce,
>
> struct i915_request *intel_context_create_request(struct intel_context *ce);
>
> +static inline struct intel_ring *__intel_context_ring_size(u64 sz)
> +{
> + return u64_to_ptr(struct intel_ring, sz);
> +}
> +
> #endif /* __INTEL_CONTEXT_H__ */
> diff --git a/drivers/gpu/drm/i915/gt/intel_lrc.c b/drivers/gpu/drm/i915/gt/intel_lrc.c
> index 5fdac40015cf..3f1b20cc50c2 100644
> --- a/drivers/gpu/drm/i915/gt/intel_lrc.c
> +++ b/drivers/gpu/drm/i915/gt/intel_lrc.c
> @@ -3140,9 +3140,8 @@ static int execlists_context_deferred_alloc(struct intel_context *ce,
> goto error_deref_obj;
> }
>
> - ring = intel_engine_create_ring(engine,
> - timeline,
> - ce->gem_context->ring_size);
> + ring = intel_engine_create_ring(engine, timeline,
> + (unsigned long)ce->ring);
> intel_timeline_put(timeline);
> if (IS_ERR(ring)) {
> ret = PTR_ERR(ring);
> diff --git a/drivers/gpu/drm/i915/i915_debugfs.c b/drivers/gpu/drm/i915/i915_debugfs.c
> index 6d3911469801..e237bcecfa1f 100644
> --- a/drivers/gpu/drm/i915/i915_debugfs.c
> +++ b/drivers/gpu/drm/i915/i915_debugfs.c
> @@ -328,10 +328,14 @@ static void print_context_stats(struct seq_file *m,
>
> for_each_gem_engine(ce,
> i915_gem_context_lock_engines(ctx), it) {
> - if (ce->state)
> - per_file_stats(0, ce->state->obj, &kstats);
> - if (ce->ring)
> + intel_context_lock_pinned(ce);
> + if (intel_context_is_pinned(ce)) {
And these hunks do not seem to belong to this patch.
> + if (ce->state)
> + per_file_stats(0,
> + ce->state->obj, &kstats);
> per_file_stats(0, ce->ring->vma->obj, &kstats);
> + }
> + intel_context_unlock_pinned(ce);
> }
> i915_gem_context_unlock_engines(ctx);
>
> @@ -1677,12 +1681,15 @@ static int i915_context_status(struct seq_file *m, void *unused)
>
> for_each_gem_engine(ce,
> i915_gem_context_lock_engines(ctx), it) {
> - seq_printf(m, "%s: ", ce->engine->name);
> - if (ce->state)
> - describe_obj(m, ce->state->obj);
> - if (ce->ring)
> + intel_context_lock_pinned(ce);
> + if (intel_context_is_pinned(ce)) {
> + seq_printf(m, "%s: ", ce->engine->name);
> + if (ce->state)
> + describe_obj(m, ce->state->obj);
> describe_ctx_ring(m, ce->ring);
> - seq_putc(m, '\n');
> + seq_putc(m, '\n');
> + }
> + intel_context_unlock_pinned(ce);
> }
> i915_gem_context_unlock_engines(ctx);
>
>
Regards,
Tvrtko
_______________________________________________
Intel-gfx mailing list
Intel-gfx@lists.freedesktop.org
https://lists.freedesktop.org/mailman/listinfo/intel-gfx
next prev parent reply other threads:[~2019-07-24 11:11 UTC|newest]
Thread overview: 55+ messages / expand[flat|nested] mbox.gz Atom feed top
2019-07-23 18:38 [PATCH 01/23] drm/i915: Move aliasing_ppgtt underneath its i915_ggtt Chris Wilson
2019-07-23 18:38 ` [PATCH 02/23] drm/i915/gt: Provide a local intel_context.vm Chris Wilson
2019-07-23 18:38 ` [PATCH 03/23] drm/i915: Remove lrc default desc from GEM context Chris Wilson
2019-07-24 9:20 ` Tvrtko Ursulin
2019-08-01 8:37 ` Tvrtko Ursulin
2019-08-01 8:41 ` Chris Wilson
2019-08-01 8:53 ` Tvrtko Ursulin
2019-08-01 10:57 ` Chris Wilson
2019-08-01 11:13 ` Chris Wilson
2019-08-01 15:29 ` Tvrtko Ursulin
2019-08-01 15:48 ` Chris Wilson
2019-08-01 16:00 ` Chris Wilson
2019-08-01 16:22 ` Tvrtko Ursulin
2019-08-01 16:36 ` Chris Wilson
2019-07-23 18:38 ` [PATCH 04/23] drm/i915: Push the ring creation flags to the backend Chris Wilson
2019-07-24 11:11 ` Tvrtko Ursulin [this message]
2019-07-26 8:43 ` Chris Wilson
2019-07-29 12:59 ` Tvrtko Ursulin
2019-07-30 9:38 ` Chris Wilson
2019-08-01 8:42 ` Tvrtko Ursulin
2019-08-01 8:45 ` Chris Wilson
2019-08-01 8:46 ` Chris Wilson
2019-07-23 18:38 ` [PATCH 05/23] drm/i915: Flush extra hard after writing relocations through the GTT Chris Wilson
2019-07-23 18:38 ` [PATCH 06/23] drm/i915: Hide unshrinkable context objects from the shrinker Chris Wilson
2019-07-23 18:38 ` [PATCH 07/23] drm/i915/gt: Move the [class][inst] lookup for engines onto the GT Chris Wilson
2019-07-25 21:21 ` Daniele Ceraolo Spurio
2019-07-26 9:22 ` Tvrtko Ursulin
2019-07-26 9:33 ` Chris Wilson
2019-07-26 9:51 ` Tvrtko Ursulin
2019-07-26 9:57 ` Chris Wilson
2019-07-23 18:38 ` [PATCH 08/23] drm/i915: Introduce for_each_user_engine() Chris Wilson
2019-07-23 18:38 ` [PATCH 09/23] drm/i915: Use intel_engine_lookup_user for probing HAS_BSD etc Chris Wilson
2019-07-23 18:38 ` [PATCH 10/23] drm/i915: Isolate i915_getparam_ioctl() Chris Wilson
2019-07-23 18:38 ` [PATCH 11/23] drm/i915: Only include active engines in the capture state Chris Wilson
2019-07-23 18:38 ` [PATCH 12/23] drm/i915: Teach execbuffer to take the engine wakeref not GT Chris Wilson
2019-07-23 18:38 ` [PATCH 13/23] drm/i915/gt: Track timeline activeness in enter/exit Chris Wilson
2019-07-23 18:38 ` [PATCH 14/23] drm/i915/gt: Convert timeline tracking to spinlock Chris Wilson
2019-07-23 18:38 ` [PATCH 15/23] drm/i915/gt: Guard timeline pinning with its own mutex Chris Wilson
2019-07-23 18:38 ` [PATCH 16/23] drm/i915/gt: Add to timeline requires the timeline mutex Chris Wilson
2019-07-23 18:38 ` [PATCH 17/23] drm/i915: Protect request retirement with timeline->mutex Chris Wilson
2019-07-23 18:38 ` [PATCH 18/23] drm/i915: Replace struct_mutex for batch pool serialisation Chris Wilson
2019-07-23 18:38 ` [PATCH 19/23] drm/i915/gt: Mark context->active_count as protected by timeline->mutex Chris Wilson
2019-07-23 18:38 ` [PATCH 20/23] drm/i915: Forgo last_fence active request tracking Chris Wilson
2019-07-23 18:38 ` [PATCH 21/23] drm/i915/overlay: Switch to using i915_active tracking Chris Wilson
2019-07-23 18:38 ` [PATCH 22/23] drm/i915: Extract intel_frontbuffer active tracking Chris Wilson
2019-07-23 18:38 ` [PATCH 23/23] drm/i915: Markup expected timeline locks for i915_active Chris Wilson
2019-07-23 20:16 ` ✗ Fi.CI.CHECKPATCH: warning for series starting with [01/23] drm/i915: Move aliasing_ppgtt underneath its i915_ggtt Patchwork
2019-07-23 20:27 ` ✗ Fi.CI.SPARSE: " Patchwork
2019-07-23 20:38 ` ✓ Fi.CI.BAT: success " Patchwork
2019-07-24 4:13 ` ✗ Fi.CI.IGT: failure " Patchwork
2019-07-24 8:56 ` [PATCH 01/23] " Tvrtko Ursulin
2019-07-24 9:27 ` Chris Wilson
2019-07-24 9:37 ` Chris Wilson
2019-07-24 9:47 ` Chris Wilson
2019-07-24 9:54 ` Tvrtko Ursulin
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=af76214d-41e9-f986-61ba-6d5100da9330@linux.intel.com \
--to=tvrtko.ursulin@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 a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox