Skip to content

Commit 7c17d37

Browse files
icklemikuint
authored andcommitted
drm/i915: Use ordered seqno write interrupt generation on gen8+ execlists
Broadwell and later currently use the same unordered command sequence to update the seqno in the HWS status page and then assert the user interrupt. We should apply the w/a from legacy (where we do an mmio read to delay the seqno read after the interrupt), but this is not enough to enforce coherent seqno visibilty on Skylake. Rather than search for the proper post-interrupt seqno barrier, use a strongly ordered command sequence to write the seqno, then assert the user interrupt from the ring. v2: Move around the wa tail dwords to avoid adding duplicate code. v3: Add references, comments on workarounds and bit5 check. References: https://bugs.freedesktop.org/show_bug.cgi?id=93693 Testcase: igt/gem_ring_sync_loop #skl Signed-off-by: Chris Wilson <chris@chris-wilson.co.uk> Cc: Mika Kuoppala <mika.kuoppala@intel.com> Reviewed-by: Mika Kuoppala <mika.kuoppala@intel.com> Link: http://patchwork.freedesktop.org/patch/msgid/1453297415-17793-1-git-send-email-mika.kuoppala@intel.com
1 parent c81eeea commit 7c17d37

2 files changed

Lines changed: 62 additions & 28 deletions

File tree

‎drivers/gpu/drm/i915/intel_lrc.c‎

Lines changed: 61 additions & 28 deletions
Original file line numberDiff line numberDiff line change
@@ -760,23 +760,34 @@ static int logical_ring_wait_for_space(struct drm_i915_gem_request *req,
760760
* on a queue waiting for the ELSP to be ready to accept a new context submission. At that
761761
* point, the tail *inside* the context is updated and the ELSP written to.
762762
*/
763-
static void
763+
static int
764764
intel_logical_ring_advance_and_submit(struct drm_i915_gem_request *request)
765765
{
766-
struct intel_engine_cs *ring = request->ring;
766+
struct intel_ringbuffer *ringbuf = request->ringbuf;
767767
struct drm_i915_private *dev_priv = request->i915;
768768

769-
intel_logical_ring_advance(request->ringbuf);
769+
intel_logical_ring_advance(ringbuf);
770+
request->tail = ringbuf->tail;
770771

771-
request->tail = request->ringbuf->tail;
772+
/*
773+
* Here we add two extra NOOPs as padding to avoid
774+
* lite restore of a context with HEAD==TAIL.
775+
*
776+
* Caller must reserve WA_TAIL_DWORDS for us!
777+
*/
778+
intel_logical_ring_emit(ringbuf, MI_NOOP);
779+
intel_logical_ring_emit(ringbuf, MI_NOOP);
780+
intel_logical_ring_advance(ringbuf);
772781

773-
if (intel_ring_stopped(ring))
774-
return;
782+
if (intel_ring_stopped(request->ring))
783+
return 0;
775784

776785
if (dev_priv->guc.execbuf_client)
777786
i915_guc_submit(dev_priv->guc.execbuf_client, request);
778787
else
779788
execlists_context_queue(request);
789+
790+
return 0;
780791
}
781792

782793
static void __wrap_ring_buffer(struct intel_ringbuffer *ringbuf)
@@ -1845,44 +1856,65 @@ static void bxt_a_set_seqno(struct intel_engine_cs *ring, u32 seqno)
18451856
intel_flush_status_page(ring, I915_GEM_HWS_INDEX);
18461857
}
18471858

1859+
/*
1860+
* Reserve space for 2 NOOPs at the end of each request to be
1861+
* used as a workaround for not being allowed to do lite
1862+
* restore with HEAD==TAIL (WaIdleLiteRestore).
1863+
*/
1864+
#define WA_TAIL_DWORDS 2
1865+
1866+
static inline u32 hws_seqno_address(struct intel_engine_cs *engine)
1867+
{
1868+
return engine->status_page.gfx_addr + I915_GEM_HWS_INDEX_ADDR;
1869+
}
1870+
18481871
static int gen8_emit_request(struct drm_i915_gem_request *request)
18491872
{
18501873
struct intel_ringbuffer *ringbuf = request->ringbuf;
1851-
struct intel_engine_cs *ring = ringbuf->ring;
1852-
u32 cmd;
18531874
int ret;
18541875

1855-
/*
1856-
* Reserve space for 2 NOOPs at the end of each request to be
1857-
* used as a workaround for not being allowed to do lite
1858-
* restore with HEAD==TAIL (WaIdleLiteRestore).
1859-
*/
1860-
ret = intel_logical_ring_begin(request, 8);
1876+
ret = intel_logical_ring_begin(request, 6 + WA_TAIL_DWORDS);
18611877
if (ret)
18621878
return ret;
18631879

1864-
cmd = MI_STORE_DWORD_IMM_GEN4;
1865-
cmd |= MI_GLOBAL_GTT;
1880+
/* w/a: bit 5 needs to be zero for MI_FLUSH_DW address. */
1881+
BUILD_BUG_ON(I915_GEM_HWS_INDEX_ADDR & (1 << 5));
18661882

1867-
intel_logical_ring_emit(ringbuf, cmd);
18681883
intel_logical_ring_emit(ringbuf,
1869-
(ring->status_page.gfx_addr +
1870-
(I915_GEM_HWS_INDEX << MI_STORE_DWORD_INDEX_SHIFT)));
1884+
(MI_FLUSH_DW + 1) | MI_FLUSH_DW_OP_STOREDW);
1885+
intel_logical_ring_emit(ringbuf,
1886+
hws_seqno_address(request->ring) |
1887+
MI_FLUSH_DW_USE_GTT);
18711888
intel_logical_ring_emit(ringbuf, 0);
18721889
intel_logical_ring_emit(ringbuf, i915_gem_request_get_seqno(request));
18731890
intel_logical_ring_emit(ringbuf, MI_USER_INTERRUPT);
18741891
intel_logical_ring_emit(ringbuf, MI_NOOP);
1875-
intel_logical_ring_advance_and_submit(request);
1892+
return intel_logical_ring_advance_and_submit(request);
1893+
}
18761894

1877-
/*
1878-
* Here we add two extra NOOPs as padding to avoid
1879-
* lite restore of a context with HEAD==TAIL.
1880-
*/
1881-
intel_logical_ring_emit(ringbuf, MI_NOOP);
1882-
intel_logical_ring_emit(ringbuf, MI_NOOP);
1883-
intel_logical_ring_advance(ringbuf);
1895+
static int gen8_emit_request_render(struct drm_i915_gem_request *request)
1896+
{
1897+
struct intel_ringbuffer *ringbuf = request->ringbuf;
1898+
int ret;
18841899

1885-
return 0;
1900+
ret = intel_logical_ring_begin(request, 6 + WA_TAIL_DWORDS);
1901+
if (ret)
1902+
return ret;
1903+
1904+
/* w/a for post sync ops following a GPGPU operation we
1905+
* need a prior CS_STALL, which is emitted by the flush
1906+
* following the batch.
1907+
*/
1908+
intel_logical_ring_emit(ringbuf, GFX_OP_PIPE_CONTROL(5));
1909+
intel_logical_ring_emit(ringbuf,
1910+
(PIPE_CONTROL_GLOBAL_GTT_IVB |
1911+
PIPE_CONTROL_CS_STALL |
1912+
PIPE_CONTROL_QW_WRITE));
1913+
intel_logical_ring_emit(ringbuf, hws_seqno_address(request->ring));
1914+
intel_logical_ring_emit(ringbuf, 0);
1915+
intel_logical_ring_emit(ringbuf, i915_gem_request_get_seqno(request));
1916+
intel_logical_ring_emit(ringbuf, MI_USER_INTERRUPT);
1917+
return intel_logical_ring_advance_and_submit(request);
18861918
}
18871919

18881920
static int intel_lr_context_render_state_init(struct drm_i915_gem_request *req)
@@ -2069,6 +2101,7 @@ static int logical_render_ring_init(struct drm_device *dev)
20692101
ring->init_context = gen8_init_rcs_context;
20702102
ring->cleanup = intel_fini_pipe_control;
20712103
ring->emit_flush = gen8_emit_flush_render;
2104+
ring->emit_request = gen8_emit_request_render;
20722105

20732106
ring->dev = dev;
20742107

‎drivers/gpu/drm/i915/intel_ringbuffer.h‎

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -426,6 +426,7 @@ intel_write_status_page(struct intel_engine_cs *ring,
426426
* The area from dword 0x30 to 0x3ff is available for driver usage.
427427
*/
428428
#define I915_GEM_HWS_INDEX 0x30
429+
#define I915_GEM_HWS_INDEX_ADDR (I915_GEM_HWS_INDEX << MI_STORE_DWORD_INDEX_SHIFT)
429430
#define I915_GEM_HWS_SCRATCH_INDEX 0x40
430431
#define I915_GEM_HWS_SCRATCH_ADDR (I915_GEM_HWS_SCRATCH_INDEX << MI_STORE_DWORD_INDEX_SHIFT)
431432

0 commit comments

Comments
 (0)