diff options
author | Jonathan Gray <jsg@cvs.openbsd.org> | 2022-07-13 03:37:56 +0000 |
---|---|---|
committer | Jonathan Gray <jsg@cvs.openbsd.org> | 2022-07-13 03:37:56 +0000 |
commit | 673cebbfd1b33ff69536718394f8b66c3bd48490 (patch) | |
tree | ef393fcbc01f705badc702a0968dc9b565c30969 /sys | |
parent | 9efc40856b16c225d199908c9c402c1fd28229a5 (diff) |
drm/i915/gt: Register the migrate contexts with their engines
From Thomas Hellstrom
9cf3a1c1288e43af00d70a8520ea9efbea01615e in linux 5.15.y/5.15.54
3e42cc61275f95fd7f022b6380b95428efe134d3 in mainline linux
Diffstat (limited to 'sys')
-rw-r--r-- | sys/dev/pci/drm/i915/gt/intel_context_types.h | 8 | ||||
-rw-r--r-- | sys/dev/pci/drm/i915/gt/intel_engine_cs.c | 4 | ||||
-rw-r--r-- | sys/dev/pci/drm/i915/gt/intel_engine_pm.c | 23 | ||||
-rw-r--r-- | sys/dev/pci/drm/i915/gt/intel_engine_pm.h | 2 | ||||
-rw-r--r-- | sys/dev/pci/drm/i915/gt/intel_engine_types.h | 7 | ||||
-rw-r--r-- | sys/dev/pci/drm/i915/gt/intel_execlists_submission.c | 2 | ||||
-rw-r--r-- | sys/dev/pci/drm/i915/gt/intel_ring_submission.c | 3 | ||||
-rw-r--r-- | sys/dev/pci/drm/i915/gt/mock_engine.c | 2 | ||||
-rw-r--r-- | sys/dev/pci/drm/i915/gt/uc/intel_guc_submission.c | 12 |
9 files changed, 60 insertions, 3 deletions
diff --git a/sys/dev/pci/drm/i915/gt/intel_context_types.h b/sys/dev/pci/drm/i915/gt/intel_context_types.h index e4a89711b77..bef5b787811 100644 --- a/sys/dev/pci/drm/i915/gt/intel_context_types.h +++ b/sys/dev/pci/drm/i915/gt/intel_context_types.h @@ -152,6 +152,14 @@ struct intel_context { /** sseu: Control eu/slice partitioning */ struct intel_sseu sseu; + /** + * pinned_contexts_link: List link for the engine's pinned contexts. + * This is only used if this is a perma-pinned kernel context and + * the list is assumed to only be manipulated during driver load + * or unload time so no mutex protection currently. + */ + struct list_head pinned_contexts_link; + u8 wa_bb_page; /* if set, page num reserved for context workarounds */ struct { diff --git a/sys/dev/pci/drm/i915/gt/intel_engine_cs.c b/sys/dev/pci/drm/i915/gt/intel_engine_cs.c index 117a541a1e1..bc2c4bbca1f 100644 --- a/sys/dev/pci/drm/i915/gt/intel_engine_cs.c +++ b/sys/dev/pci/drm/i915/gt/intel_engine_cs.c @@ -320,6 +320,7 @@ static int intel_engine_setup(struct intel_gt *gt, enum intel_engine_id id) BUILD_BUG_ON(BITS_PER_TYPE(engine->mask) < I915_NUM_ENGINES); + INIT_LIST_HEAD(&engine->pinned_contexts_list); engine->id = id; engine->legacy_idx = INVALID_ENGINE; engine->mask = BIT(id); @@ -879,6 +880,8 @@ intel_engine_create_pinned_context(struct intel_engine_cs *engine, return ERR_PTR(err); } + list_add_tail(&ce->pinned_contexts_link, &engine->pinned_contexts_list); + /* * Give our perma-pinned kernel timelines a separate lockdep class, * so that we can use them from within the normal user timelines @@ -901,6 +904,7 @@ void intel_engine_destroy_pinned_context(struct intel_context *ce) list_del(&ce->timeline->engine_link); mutex_unlock(&hwsp->vm->mutex); + list_del(&ce->pinned_contexts_link); intel_context_unpin(ce); intel_context_put(ce); } diff --git a/sys/dev/pci/drm/i915/gt/intel_engine_pm.c b/sys/dev/pci/drm/i915/gt/intel_engine_pm.c index 1f07ac4e067..dacd6277373 100644 --- a/sys/dev/pci/drm/i915/gt/intel_engine_pm.c +++ b/sys/dev/pci/drm/i915/gt/intel_engine_pm.c @@ -298,6 +298,29 @@ void intel_engine_init__pm(struct intel_engine_cs *engine) intel_engine_init_heartbeat(engine); } +/** + * intel_engine_reset_pinned_contexts - Reset the pinned contexts of + * an engine. + * @engine: The engine whose pinned contexts we want to reset. + * + * Typically the pinned context LMEM images lose or get their content + * corrupted on suspend. This function resets their images. + */ +void intel_engine_reset_pinned_contexts(struct intel_engine_cs *engine) +{ + struct intel_context *ce; + + list_for_each_entry(ce, &engine->pinned_contexts_list, + pinned_contexts_link) { + /* kernel context gets reset at __engine_unpark() */ + if (ce == engine->kernel_context) + continue; + + dbg_poison_ce(ce); + ce->ops->reset(ce); + } +} + #if IS_ENABLED(CONFIG_DRM_I915_SELFTEST) #include "selftest_engine_pm.c" #endif diff --git a/sys/dev/pci/drm/i915/gt/intel_engine_pm.h b/sys/dev/pci/drm/i915/gt/intel_engine_pm.h index 70ea46d6cfb..8520c595f5e 100644 --- a/sys/dev/pci/drm/i915/gt/intel_engine_pm.h +++ b/sys/dev/pci/drm/i915/gt/intel_engine_pm.h @@ -69,4 +69,6 @@ intel_engine_create_kernel_request(struct intel_engine_cs *engine) void intel_engine_init__pm(struct intel_engine_cs *engine); +void intel_engine_reset_pinned_contexts(struct intel_engine_cs *engine); + #endif /* INTEL_ENGINE_PM_H */ diff --git a/sys/dev/pci/drm/i915/gt/intel_engine_types.h b/sys/dev/pci/drm/i915/gt/intel_engine_types.h index 934e457821e..0ff133f2bf1 100644 --- a/sys/dev/pci/drm/i915/gt/intel_engine_types.h +++ b/sys/dev/pci/drm/i915/gt/intel_engine_types.h @@ -304,6 +304,13 @@ struct intel_engine_cs { struct intel_context *kernel_context; /* pinned */ + /** + * pinned_contexts_list: List of pinned contexts. This list is only + * assumed to be manipulated during driver load- or unload time and + * does therefore not have any additional protection. + */ + struct list_head pinned_contexts_list; + intel_engine_mask_t saturated; /* submitting semaphores too late? */ struct { diff --git a/sys/dev/pci/drm/i915/gt/intel_execlists_submission.c b/sys/dev/pci/drm/i915/gt/intel_execlists_submission.c index 6bdc43b2b95..5bde03d88ee 100644 --- a/sys/dev/pci/drm/i915/gt/intel_execlists_submission.c +++ b/sys/dev/pci/drm/i915/gt/intel_execlists_submission.c @@ -2792,6 +2792,8 @@ static void execlists_sanitize(struct intel_engine_cs *engine) /* And scrub the dirty cachelines for the HWSP */ clflush_cache_range(engine->status_page.addr, PAGE_SIZE); + + intel_engine_reset_pinned_contexts(engine); } static void enable_error_interrupt(struct intel_engine_cs *engine) diff --git a/sys/dev/pci/drm/i915/gt/intel_ring_submission.c b/sys/dev/pci/drm/i915/gt/intel_ring_submission.c index c4b09eee664..09f7b9592fc 100644 --- a/sys/dev/pci/drm/i915/gt/intel_ring_submission.c +++ b/sys/dev/pci/drm/i915/gt/intel_ring_submission.c @@ -17,6 +17,7 @@ #include "intel_ring.h" #include "shmem_utils.h" #include "intel_engine_heartbeat.h" +#include "intel_engine_pm.h" /* Rough estimate of the typical request size, performing a flush, * set-context and then emitting the batch. @@ -292,6 +293,8 @@ static void xcs_sanitize(struct intel_engine_cs *engine) /* And scrub the dirty cachelines for the HWSP */ clflush_cache_range(engine->status_page.addr, PAGE_SIZE); + + intel_engine_reset_pinned_contexts(engine); } static void reset_prepare(struct intel_engine_cs *engine) diff --git a/sys/dev/pci/drm/i915/gt/mock_engine.c b/sys/dev/pci/drm/i915/gt/mock_engine.c index 53cc2f9b413..89ac0511037 100644 --- a/sys/dev/pci/drm/i915/gt/mock_engine.c +++ b/sys/dev/pci/drm/i915/gt/mock_engine.c @@ -376,6 +376,8 @@ int mock_engine_init(struct intel_engine_cs *engine) { struct intel_context *ce; + INIT_LIST_HEAD(&engine->pinned_contexts_list); + engine->sched_engine = i915_sched_engine_create(ENGINE_MOCK); if (!engine->sched_engine) return -ENOMEM; diff --git a/sys/dev/pci/drm/i915/gt/uc/intel_guc_submission.c b/sys/dev/pci/drm/i915/gt/uc/intel_guc_submission.c index 7983409887d..8e1cc0a184b 100644 --- a/sys/dev/pci/drm/i915/gt/uc/intel_guc_submission.c +++ b/sys/dev/pci/drm/i915/gt/uc/intel_guc_submission.c @@ -2347,6 +2347,8 @@ static void guc_sanitize(struct intel_engine_cs *engine) /* And scrub the dirty cachelines for the HWSP */ clflush_cache_range(engine->status_page.addr, PAGE_SIZE); + + intel_engine_reset_pinned_contexts(engine); } static void setup_hwsp(struct intel_engine_cs *engine) @@ -2422,9 +2424,13 @@ static inline void guc_init_lrc_mapping(struct intel_guc *guc) * and even it did this code would be run again. */ - for_each_engine(engine, gt, id) - if (engine->kernel_context) - guc_kernel_context_pin(guc, engine->kernel_context); + for_each_engine(engine, gt, id) { + struct intel_context *ce; + + list_for_each_entry(ce, &engine->pinned_contexts_list, + pinned_contexts_link) + guc_kernel_context_pin(guc, ce); + } } static void guc_release(struct intel_engine_cs *engine) |