From: Mika Kuoppala <mika.kuoppala@linux.intel.com>
To: Chris Wilson <chris@chris-wilson.co.uk>, intel-gfx@lists.freedesktop.org
Cc: Chris Wilson <chris@chris-wilson.co.uk>
Subject: Re: [Intel-gfx] [PATCH 15/69] drm/i915/gt: Track all timelines created using the HWSP
Date: Tue, 15 Dec 2020 19:09:39 +0200 [thread overview]
Message-ID: <87h7onm1ws.fsf@gaia.fi.intel.com> (raw)
In-Reply-To: <20201214100949.11387-15-chris@chris-wilson.co.uk>
Chris Wilson <chris@chris-wilson.co.uk> writes:
> We assume that the contents of the HWSP are lost across suspend, and so
> upon resume we must restore critical values such as the timeline seqno.
> Keep track of every timeline allocated that uses the HWSP as its storage
> and so we can then reset all seqno values by walking that list.
>
> Signed-off-by: Chris Wilson <chris@chris-wilson.co.uk>
> ---
> drivers/gpu/drm/i915/gt/intel_engine_cs.c | 9 ++++-
> drivers/gpu/drm/i915/gt/intel_engine_pm.c | 6 ++++
> drivers/gpu/drm/i915/gt/intel_engine_types.h | 1 +
> .../drm/i915/gt/intel_execlists_submission.c | 11 ++++--
> .../gpu/drm/i915/gt/intel_ring_submission.c | 35 +++++++++++++++++++
> drivers/gpu/drm/i915/gt/intel_timeline.h | 13 +++++--
> .../gpu/drm/i915/gt/intel_timeline_types.h | 2 ++
> 7 files changed, 71 insertions(+), 6 deletions(-)
>
> diff --git a/drivers/gpu/drm/i915/gt/intel_engine_cs.c b/drivers/gpu/drm/i915/gt/intel_engine_cs.c
> index 71bd052628f4..6c08e74edcae 100644
> --- a/drivers/gpu/drm/i915/gt/intel_engine_cs.c
> +++ b/drivers/gpu/drm/i915/gt/intel_engine_cs.c
> @@ -648,6 +648,8 @@ static int init_status_page(struct intel_engine_cs *engine)
> void *vaddr;
> int ret;
>
> + INIT_LIST_HEAD(&engine->status_page.timelines);
> +
> /*
> * Though the HWS register does support 36bit addresses, historically
> * we have had hangs and corruption reported due to wild writes if
> @@ -936,6 +938,7 @@ void intel_engine_cleanup_common(struct intel_engine_cs *engine)
> fput(engine->default_state);
>
> if (engine->kernel_context) {
> + list_del(&engine->kernel_context->timeline->engine_link);
> intel_context_unpin(engine->kernel_context);
> intel_context_put(engine->kernel_context);
> }
> @@ -1281,8 +1284,12 @@ void intel_engines_reset_default_submission(struct intel_gt *gt)
> struct intel_engine_cs *engine;
> enum intel_engine_id id;
>
> - for_each_engine(engine, gt, id)
> + for_each_engine(engine, gt, id) {
> + if (engine->sanitize)
> + engine->sanitize(engine);
> +
> engine->set_default_submission(engine);
> + }
> }
>
> bool intel_engine_can_store_dword(struct intel_engine_cs *engine)
> diff --git a/drivers/gpu/drm/i915/gt/intel_engine_pm.c b/drivers/gpu/drm/i915/gt/intel_engine_pm.c
> index 99574378047f..1e5bad0b9a82 100644
> --- a/drivers/gpu/drm/i915/gt/intel_engine_pm.c
> +++ b/drivers/gpu/drm/i915/gt/intel_engine_pm.c
> @@ -60,6 +60,12 @@ static int __engine_unpark(struct intel_wakeref *wf)
>
> /* Scrub the context image after our loss of control */
> ce->ops->reset(ce);
> +
> + CE_TRACE(ce, "reset { seqno:%x, *hwsp:%x, ring:%x }\n",
> + ce->timeline->seqno,
> + READ_ONCE(*ce->timeline->hwsp_seqno),
> + ce->ring->emit);
> + GEM_BUG_ON(ce->timeline->seqno != *ce->timeline->hwsp_seqno);
Compiler should be satified but could still have been READ_ONCE,
for the reader and for the fine bug on which might get delivered to console.
But main thing is that now coherency is enforced from the get go.
> }
>
> if (engine->unpark)
> diff --git a/drivers/gpu/drm/i915/gt/intel_engine_types.h b/drivers/gpu/drm/i915/gt/intel_engine_types.h
> index e71eef157231..c28f4e190fe6 100644
> --- a/drivers/gpu/drm/i915/gt/intel_engine_types.h
> +++ b/drivers/gpu/drm/i915/gt/intel_engine_types.h
> @@ -68,6 +68,7 @@ typedef u8 intel_engine_mask_t;
> #define ALL_ENGINES ((intel_engine_mask_t)~0ul)
>
> struct intel_hw_status_page {
> + struct list_head timelines;
> struct i915_vma *vma;
> u32 *addr;
> };
> diff --git a/drivers/gpu/drm/i915/gt/intel_execlists_submission.c b/drivers/gpu/drm/i915/gt/intel_execlists_submission.c
> index 9f5efff08785..c5b013cc10b3 100644
> --- a/drivers/gpu/drm/i915/gt/intel_execlists_submission.c
> +++ b/drivers/gpu/drm/i915/gt/intel_execlists_submission.c
> @@ -3508,7 +3508,6 @@ static int execlists_context_alloc(struct intel_context *ce)
>
> static void execlists_context_reset(struct intel_context *ce)
> {
> - CE_TRACE(ce, "reset\n");
> GEM_BUG_ON(!intel_context_is_pinned(ce));
>
> intel_ring_reset(ce->ring, ce->ring->emit);
> @@ -3985,6 +3984,14 @@ static void reset_csb_pointers(struct intel_engine_cs *engine)
> GEM_BUG_ON(READ_ONCE(*execlists->csb_write) != reset_value);
> }
>
> +static void sanitize_hwsp(struct intel_engine_cs *engine)
> +{
> + struct intel_timeline *tl;
> +
> + list_for_each_entry(tl, &engine->status_page.timelines, engine_link)
> + intel_timeline_reset_seqno(tl);
> +}
> +
> static void execlists_sanitize(struct intel_engine_cs *engine)
> {
> GEM_BUG_ON(execlists_active(&engine->execlists));
> @@ -4008,7 +4015,7 @@ static void execlists_sanitize(struct intel_engine_cs *engine)
> * that may be lost on resume/initialisation, and so we need to
> * reset the value in the HWSP.
> */
> - intel_timeline_reset_seqno(engine->kernel_context->timeline);
> + sanitize_hwsp(engine);
>
> /* And scrub the dirty cachelines for the HWSP */
> clflush_cache_range(engine->status_page.addr, PAGE_SIZE);
> diff --git a/drivers/gpu/drm/i915/gt/intel_ring_submission.c b/drivers/gpu/drm/i915/gt/intel_ring_submission.c
> index 5105e19514ee..4ea741f488a8 100644
> --- a/drivers/gpu/drm/i915/gt/intel_ring_submission.c
> +++ b/drivers/gpu/drm/i915/gt/intel_ring_submission.c
> @@ -321,6 +321,39 @@ static int xcs_resume(struct intel_engine_cs *engine)
> return ret;
> }
>
> +static void sanitize_hwsp(struct intel_engine_cs *engine)
> +{
> + struct intel_timeline *tl;
> +
> + list_for_each_entry(tl, &engine->status_page.timelines, engine_link)
> + intel_timeline_reset_seqno(tl);
> +}
> +
> +static void xcs_sanitize(struct intel_engine_cs *engine)
> +{
> + /*
> + * Poison residual state on resume, in case the suspend didn't!
> + *
> + * We have to assume that across suspend/resume (or other loss
> + * of control) that the contents of our pinned buffers has been
> + * lost, replaced by garbage. Since this doesn't always happen,
> + * let's poison such state so that we more quickly spot when
> + * we falsely assume it has been preserved.
> + */
> + if (IS_ENABLED(CONFIG_DRM_I915_DEBUG_GEM))
> + memset(engine->status_page.addr, POISON_INUSE, PAGE_SIZE);
> +
> + /*
> + * The kernel_context HWSP is stored in the status_page. As above,
> + * that may be lost on resume/initialisation, and so we need to
> + * reset the value in the HWSP.
> + */
> + sanitize_hwsp(engine);
> +
> + /* And scrub the dirty cachelines for the HWSP */
> + clflush_cache_range(engine->status_page.addr, PAGE_SIZE);
The flush could be part of the actual writing of the seqno with
that range. But then you would need to track the debug so. Better
to make sure to transfer everything to be visible.
Reviewed-by: Mika Kuoppala <mika.kuoppala@linux.intel.com>
> +}
> +
> static void reset_prepare(struct intel_engine_cs *engine)
> {
> struct intel_uncore *uncore = engine->uncore;
> @@ -1070,6 +1103,8 @@ static void setup_common(struct intel_engine_cs *engine)
> setup_irq(engine);
>
> engine->resume = xcs_resume;
> + engine->sanitize = xcs_sanitize;
> +
> engine->reset.prepare = reset_prepare;
> engine->reset.rewind = reset_rewind;
> engine->reset.cancel = reset_cancel;
> diff --git a/drivers/gpu/drm/i915/gt/intel_timeline.h b/drivers/gpu/drm/i915/gt/intel_timeline.h
> index 634acebd0c4b..1ee680d31801 100644
> --- a/drivers/gpu/drm/i915/gt/intel_timeline.h
> +++ b/drivers/gpu/drm/i915/gt/intel_timeline.h
> @@ -48,9 +48,16 @@ static inline struct intel_timeline *
> intel_timeline_create_from_engine(struct intel_engine_cs *engine,
> unsigned int offset)
> {
> - return __intel_timeline_create(engine->gt,
> - engine->status_page.vma,
> - offset);
> + struct intel_timeline *tl;
> +
> + tl = __intel_timeline_create(engine->gt,
> + engine->status_page.vma,
> + offset);
> + if (IS_ERR(tl))
> + return tl;
> +
> + list_add_tail(&tl->engine_link, &engine->status_page.timelines);
> + return tl;
> }
>
> static inline struct intel_timeline *
> diff --git a/drivers/gpu/drm/i915/gt/intel_timeline_types.h b/drivers/gpu/drm/i915/gt/intel_timeline_types.h
> index 4474f487f589..e360f50706bf 100644
> --- a/drivers/gpu/drm/i915/gt/intel_timeline_types.h
> +++ b/drivers/gpu/drm/i915/gt/intel_timeline_types.h
> @@ -84,6 +84,8 @@ struct intel_timeline {
> struct list_head link;
> struct intel_gt *gt;
>
> + struct list_head engine_link;
> +
> struct kref kref;
> struct rcu_head rcu;
> };
> --
> 2.20.1
>
> _______________________________________________
> Intel-gfx mailing list
> Intel-gfx@lists.freedesktop.org
> https://lists.freedesktop.org/mailman/listinfo/intel-gfx
_______________________________________________
Intel-gfx mailing list
Intel-gfx@lists.freedesktop.org
https://lists.freedesktop.org/mailman/listinfo/intel-gfx
next prev parent reply other threads:[~2020-12-15 17:12 UTC|newest]
Thread overview: 82+ messages / expand[flat|nested] mbox.gz Atom feed top
2020-12-14 10:08 [Intel-gfx] [PATCH 01/69] drm/i915: Use cmpxchg64 for 32b compatilibity Chris Wilson
2020-12-14 10:08 ` [Intel-gfx] [PATCH 02/69] drm/i915/uc: Squelch load failure error message Chris Wilson
2020-12-23 10:12 ` Matthew Auld
2020-12-14 10:08 ` [Intel-gfx] [PATCH 03/69] drm/i915: Encode fence specific waitqueue behaviour into the wait.flags Chris Wilson
2020-12-14 10:08 ` [Intel-gfx] [PATCH 04/69] drm/i915/gt: Replace direct submit with direct call to tasklet Chris Wilson
2020-12-14 10:08 ` [Intel-gfx] [PATCH 05/69] drm/i915/gt: Use virtual_engine during execlists_dequeue Chris Wilson
2020-12-14 10:08 ` [Intel-gfx] [PATCH 06/69] drm/i915/gt: Decouple inflight virtual engines Chris Wilson
2020-12-14 10:08 ` [Intel-gfx] [PATCH 07/69] drm/i915/gt: Defer schedule_out until after the next dequeue Chris Wilson
2020-12-14 10:08 ` [Intel-gfx] [PATCH 08/69] drm/i915/gt: Remove virtual breadcrumb before transfer Chris Wilson
2020-12-14 10:08 ` [Intel-gfx] [PATCH 09/69] drm/i915/gt: Shrink the critical section for irq signaling Chris Wilson
2020-12-14 10:08 ` [Intel-gfx] [PATCH 10/69] drm/i915/gt: Resubmit the virtual engine on schedule-out Chris Wilson
2020-12-14 10:08 ` [Intel-gfx] [PATCH 11/69] drm/i915/gt: Simplify virtual engine handling for execlists_hold() Chris Wilson
2020-12-14 10:08 ` [Intel-gfx] [PATCH 12/69] drm/i915/gt: ce->inflight updates are now serialised Chris Wilson
2020-12-14 10:08 ` [Intel-gfx] [PATCH 13/69] drm/i915/gem: Drop free_work for GEM contexts Chris Wilson
2020-12-14 10:08 ` [Intel-gfx] [PATCH 14/69] drm/i915/gt: Track the overall awake/busy time Chris Wilson
2020-12-15 13:49 ` Tvrtko Ursulin
2020-12-14 10:08 ` [Intel-gfx] [PATCH 15/69] drm/i915/gt: Track all timelines created using the HWSP Chris Wilson
2020-12-15 17:09 ` Mika Kuoppala [this message]
2020-12-15 17:16 ` Chris Wilson
2020-12-14 10:08 ` [Intel-gfx] [PATCH 16/69] drm/i915/gt: Wrap intel_timeline.has_initial_breadcrumb Chris Wilson
2020-12-14 10:08 ` [Intel-gfx] [PATCH 17/69] drm/i915/gt: Track timeline GGTT offset separately from subpage offset Chris Wilson
2020-12-14 10:08 ` [Intel-gfx] [PATCH 18/69] drm/i915/gt: Add timeline "mode" Chris Wilson
2020-12-14 10:08 ` [Intel-gfx] [PATCH 19/69] drm/i915/gt: Use indices for writing into relative timelines Chris Wilson
2020-12-14 10:09 ` [Intel-gfx] [PATCH 20/69] drm/i915/selftests: Exercise relative timeline modes Chris Wilson
2020-12-14 10:09 ` [Intel-gfx] [PATCH 21/69] drm/i915/gt: Use ppHWSP for unshared non-semaphore related timelines Chris Wilson
2020-12-14 10:09 ` [Intel-gfx] [PATCH 22/69] drm/i915/selftests: Confirm RING_TIMESTAMP / CTX_TIMESTAMP share a clock Chris Wilson
2020-12-14 10:09 ` [Intel-gfx] [PATCH 23/69] drm/i915/gt: Consolidate the CS timestamp clocks Chris Wilson
2020-12-14 10:09 ` [Intel-gfx] [PATCH 24/69] drm/i915/gt: Prefer recycling an idle fence Chris Wilson
2020-12-14 10:09 ` [Intel-gfx] [PATCH 25/69] drm/i915/gem: Optimistically prune dma-resv from the shrinker Chris Wilson
2020-12-14 10:09 ` [Intel-gfx] [PATCH 26/69] drm/i915: Drop i915_request.lock serialisation around await_start Chris Wilson
2020-12-14 10:09 ` [Intel-gfx] [PATCH 27/69] drm/i915: Drop i915_request.lock requirement for intel_rps_boost() Chris Wilson
2020-12-14 10:09 ` [Intel-gfx] [PATCH 28/69] drm/i915/gem: Reduce ctx->engine_mutex for reading the clone source Chris Wilson
2020-12-14 10:09 ` [Intel-gfx] [PATCH 29/69] drm/i915/gem: Reduce ctx->engines_mutex for get_engines() Chris Wilson
2020-12-14 10:09 ` [Intel-gfx] [PATCH 30/69] drm/i915: Reduce test_and_set_bit to set_bit in i915_request_submit() Chris Wilson
2020-12-14 10:09 ` [Intel-gfx] [PATCH 31/69] drm/i915/gt: Drop atomic for engine->fw_active tracking Chris Wilson
2020-12-14 10:09 ` [Intel-gfx] [PATCH 32/69] drm/i915/gt: Extract busy-stats for ring-scheduler Chris Wilson
2020-12-14 10:09 ` [Intel-gfx] [PATCH 33/69] drm/i915/gt: Convert stats.active to plain unsigned int Chris Wilson
2020-12-14 10:09 ` [Intel-gfx] [PATCH 34/69] drm/i915/gt: Refactor heartbeat request construction and submission Chris Wilson
2020-12-14 10:09 ` [Intel-gfx] [PATCH 35/69] drm/i915: Strip out internal priorities Chris Wilson
2020-12-14 10:09 ` [Intel-gfx] [PATCH 36/69] drm/i915: Remove I915_USER_PRIORITY_SHIFT Chris Wilson
2020-12-14 10:09 ` [Intel-gfx] [PATCH 37/69] drm/i915/gt: Defer the kmem_cache_free() until after the HW submit Chris Wilson
2020-12-14 10:09 ` [Intel-gfx] [PATCH 38/69] drm/i915: Prune empty priolists Chris Wilson
2020-12-14 10:09 ` [Intel-gfx] [PATCH 39/69] drm/i915: Replace engine->schedule() with a known request operation Chris Wilson
2020-12-14 10:09 ` [Intel-gfx] [PATCH 40/69] drm/i915/gt: Do not suspend bonded requests if one hangs Chris Wilson
2020-12-14 10:09 ` [Intel-gfx] [PATCH 41/69] drm/i915: Teach the i915_dependency to use a double-lock Chris Wilson
2020-12-14 10:09 ` [Intel-gfx] [PATCH 42/69] drm/i915: Restructure priority inheritance Chris Wilson
2020-12-14 10:09 ` [Intel-gfx] [PATCH 43/69] drm/i915/selftests: Measure set-priority duration Chris Wilson
2020-12-14 10:09 ` [Intel-gfx] [PATCH 44/69] drm/i915/selftests: Exercise priority inheritance around an engine loop Chris Wilson
2020-12-14 10:09 ` [Intel-gfx] [PATCH 45/69] drm/i915: Improve DFS for priority inheritance Chris Wilson
2020-12-14 10:09 ` [Intel-gfx] [PATCH 46/69] drm/i915/gt: Remove timeslice suppression Chris Wilson
2020-12-14 10:09 ` [Intel-gfx] [PATCH 47/69] drm/i915: Extract request submission from execlists Chris Wilson
2020-12-14 10:09 ` [Intel-gfx] [PATCH 48/69] drm/i915: Extract request suspension from the execlists backend Chris Wilson
2020-12-14 10:09 ` [Intel-gfx] [PATCH 49/69] drm/i915: Extract the ability to defer and rerun a request later Chris Wilson
2020-12-14 10:09 ` [Intel-gfx] [PATCH 50/69] drm/i915: Fix the iterative dfs for defering requests Chris Wilson
2020-12-14 10:09 ` [Intel-gfx] [PATCH 51/69] drm/i915: Wrap cmpxchg64 with try_cmpxchg64() helper Chris Wilson
2020-12-14 10:09 ` [Intel-gfx] [PATCH 52/69] drm/i915: Fair low-latency scheduling Chris Wilson
2020-12-14 10:09 ` [Intel-gfx] [PATCH 53/69] drm/i915/gt: Specify a deadline for the heartbeat Chris Wilson
2020-12-14 10:09 ` [Intel-gfx] [PATCH 54/69] drm/i915: Extend the priority boosting for the display with a deadline Chris Wilson
2020-12-14 10:09 ` [Intel-gfx] [PATCH 55/69] drm/i915: Move common active lists from engine to i915_scheduler Chris Wilson
2020-12-14 10:09 ` [Intel-gfx] [PATCH 56/69] drm/i915: Move scheduler queue Chris Wilson
2020-12-14 10:09 ` [Intel-gfx] [PATCH 57/69] drm/i915: Move tasklet from execlists to sched Chris Wilson
2020-12-14 10:09 ` [Intel-gfx] [PATCH 58/69] drm/i915/gt: Another tweak for flushing the tasklets Chris Wilson
2020-12-14 10:09 ` [Intel-gfx] [PATCH 59/69] Restore "drm/i915: drop engine_pin/unpin_breadcrumbs_irq" Chris Wilson
2020-12-14 10:09 ` [Intel-gfx] [PATCH 60/69] drm/i915/gt: Couple tasklet scheduling for all CS interrupts Chris Wilson
2020-12-14 10:09 ` [Intel-gfx] [PATCH 61/69] drm/i915/gt: Support creation of 'internal' rings Chris Wilson
2020-12-14 10:09 ` [Intel-gfx] [PATCH 62/69] drm/i915/gt: Use client timeline address for seqno writes Chris Wilson
2020-12-14 10:09 ` [Intel-gfx] [PATCH 63/69] drm/i915/gt: Infrastructure for ring scheduling Chris Wilson
2020-12-14 13:29 ` kernel test robot
2020-12-14 13:29 ` kernel test robot
2020-12-14 10:09 ` [Intel-gfx] [PATCH 64/69] drm/i915/gt: Enable busy-stats for ring-scheduler Chris Wilson
2020-12-14 10:09 ` [Intel-gfx] [PATCH 65/69] drm/i915/gt: Implement ring scheduler for gen6/7 Chris Wilson
2020-12-14 10:09 ` [Intel-gfx] [PATCH 66/69] drm/i915/gt: Enable ring scheduling " Chris Wilson
2020-12-14 10:09 ` [Intel-gfx] [PATCH 67/69] drm/i915: Move saturated workload detection back to the context Chris Wilson
2020-12-14 10:09 ` [Intel-gfx] [PATCH 68/69] drm/i915/gt: Skip over completed active execlists, again Chris Wilson
2020-12-14 10:09 ` [Intel-gfx] [PATCH 69/69] drm/i915/gt: Support virtual engine queues Chris Wilson
2020-12-14 12:33 ` kernel test robot
2020-12-14 12:33 ` kernel test robot
2020-12-14 12:37 ` [Intel-gfx] ✗ Fi.CI.CHECKPATCH: warning for series starting with [01/69] drm/i915: Use cmpxchg64 for 32b compatilibity Patchwork
2020-12-14 12:38 ` [Intel-gfx] ✗ Fi.CI.SPARSE: " Patchwork
2020-12-14 12:42 ` [Intel-gfx] ✗ Fi.CI.DOCS: " Patchwork
2020-12-14 13:04 ` [Intel-gfx] ✓ Fi.CI.BAT: success " Patchwork
2020-12-14 15:58 ` [Intel-gfx] ✗ 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=87h7onm1ws.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.