Skip to content

Commit 5bea406

Browse files
committed
drm/i915/guc: Debug print LRC state entries only if the context is pinned
After the context is unpinned the backing memory can also be unpinned, so any accesses via the lrc_reg_state pointer can end up in unmapped memory. To avoid that, make sure to only access that memory if the context is pinned when printing its info. v2: fix newline alignment Fixes: 28ff652 ("drm/i915/guc: Update GuC debugfs to support new GuC") Signed-off-by: Daniele Ceraolo Spurio <daniele.ceraolospurio@intel.com> Cc: John Harrison <John.C.Harrison@Intel.com> Cc: Matthew Brost <matthew.brost@intel.com> Cc: <stable@vger.kernel.org> # v5.15+ Reviewed-by: John Harrison <John.C.Harrison@Intel.com> Link: https://patchwork.freedesktop.org/patch/msgid/20250115001334.3875347-1-daniele.ceraolospurio@intel.com
1 parent 54cb728 commit 5bea406

File tree

1 file changed

+14
-6
lines changed

1 file changed

+14
-6
lines changed

drivers/gpu/drm/i915/gt/uc/intel_guc_submission.c

Lines changed: 14 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -5535,12 +5535,20 @@ static inline void guc_log_context(struct drm_printer *p,
55355535
{
55365536
drm_printf(p, "GuC lrc descriptor %u:\n", ce->guc_id.id);
55375537
drm_printf(p, "\tHW Context Desc: 0x%08x\n", ce->lrc.lrca);
5538-
drm_printf(p, "\t\tLRC Head: Internal %u, Memory %u\n",
5539-
ce->ring->head,
5540-
ce->lrc_reg_state[CTX_RING_HEAD]);
5541-
drm_printf(p, "\t\tLRC Tail: Internal %u, Memory %u\n",
5542-
ce->ring->tail,
5543-
ce->lrc_reg_state[CTX_RING_TAIL]);
5538+
if (intel_context_pin_if_active(ce)) {
5539+
drm_printf(p, "\t\tLRC Head: Internal %u, Memory %u\n",
5540+
ce->ring->head,
5541+
ce->lrc_reg_state[CTX_RING_HEAD]);
5542+
drm_printf(p, "\t\tLRC Tail: Internal %u, Memory %u\n",
5543+
ce->ring->tail,
5544+
ce->lrc_reg_state[CTX_RING_TAIL]);
5545+
intel_context_unpin(ce);
5546+
} else {
5547+
drm_printf(p, "\t\tLRC Head: Internal %u, Memory not pinned\n",
5548+
ce->ring->head);
5549+
drm_printf(p, "\t\tLRC Tail: Internal %u, Memory not pinned\n",
5550+
ce->ring->tail);
5551+
}
55445552
drm_printf(p, "\t\tContext Pin Count: %u\n",
55455553
atomic_read(&ce->pin_count));
55465554
drm_printf(p, "\t\tGuC ID Ref Count: %u\n",

0 commit comments

Comments
 (0)