drm/i915/execlists: Track inflight CCID
authorChris Wilson <chris@chris-wilson.co.uk>
Tue, 28 Apr 2020 18:47:50 +0000 (19:47 +0100)
committerChris Wilson <chris@chris-wilson.co.uk>
Tue, 28 Apr 2020 21:17:36 +0000 (22:17 +0100)
commit5c4a53e3b1cbc38d0906e382f1037290658759bb
tree0639281ac4195dac184b629c272624a457c33b45
parent2632f174a2e1a5fd40a70404fa8ccfd0b1f79ebd
drm/i915/execlists: Track inflight CCID

The presumption is that by using a circular counter that is twice as
large as the maximum ELSP submission, we would never reuse the same CCID
for two inflight contexts.

However, if we continually preempt an active context such that it always
remains inflight, it can be resubmitted with an arbitrary number of
paired contexts. As each of its paired contexts will use a new CCID,
eventually it will wrap and submit two ELSP with the same CCID.

Rather than use a simple circular counter, switch over to a small bitmap
of inflight ids so we can avoid reusing one that is still potentially
active.

Closes: https://gitlab.freedesktop.org/drm/intel/-/issues/1796
Fixes: 2935ed5339c4 ("drm/i915: Remove logical HW ID")
Signed-off-by: Chris Wilson <chris@chris-wilson.co.uk>
Cc: Mika Kuoppala <mika.kuoppala@linux.intel.com>
Cc: <stable@vger.kernel.org> # v5.5+
Reviewed-by: Mika Kuoppala <mika.kuoppala@linux.intel.com>
Link: https://patchwork.freedesktop.org/patch/msgid/20200428184751.11257-2-chris@chris-wilson.co.uk
drivers/gpu/drm/i915/gt/intel_engine_types.h
drivers/gpu/drm/i915/gt/intel_lrc.c
drivers/gpu/drm/i915/i915_perf.c
drivers/gpu/drm/i915/selftests/i915_vma.c