Skip to contentSkip to conversation

Apply BDW workarounds using LRIs in render init fn

PATCH In review Arun Siluvery 2 participants 7 messages Aug 26, 2014

Subsystems (2)
lore
Share & tools
lore
#0 lore raw

cover Apply BDW workarounds using LRIs in render init fn

Workarounds for BDW are applied using LRIs during render ring initialization. Only those WA registers that are part of register state are initialized in this fn, remaining are still in its current place init_clock_gating() which are not affected by a gpu reset. I can send another patch where they can be moved to render ring init function but during testing I found their state doesn't change after reset.

Arun Siluvery (2):
drm/i915/bdw: Apply workarounds in render ring init function drm/i915/bdw: Export workaround data to debugfs

 drivers/gpu/drm/i915/i915_debugfs.c     |  40 +++++++++++++
 drivers/gpu/drm/i915/i915_drv.h         |  14 +++++
 drivers/gpu/drm/i915/i915_gem_context.c |   6 ++
 drivers/gpu/drm/i915/intel_pm.c         |  48 ---------------
 drivers/gpu/drm/i915/intel_ringbuffer.c | 101 ++++++++++++++++++++++++++++++++
 drivers/gpu/drm/i915/intel_ringbuffer.h |   1 +
 6 files changed, 162 insertions(+), 48 deletions(-)
Signature · 1 line
2.0.4
#1 lore raw

PATCH 1/2 drm/i915/bdw: Apply workarounds in render ring init function

For BDW workarounds are currently initialized in init_clock_gating() but they are lost during reset, suspend/resume etc; this patch moves the WAs that are part of register state context to render ring init fn otherwise default context ends up with incorrect values as they don't get initialized until init_clock_gating fn.

v2: Add workarounds to golden render state
This method has its own issues, first of all this is different for each gen and it is generated using a tool so adding new workaround and mainitaining them across gens is not a straightforward process.

v3: Use LRIs to emit these workarounds (Ville) Instead of modifying the golden render state the same LRIs are emitted from within the driver.

For: VIZ-4092

---
 drivers/gpu/drm/i915/i915_gem_context.c |  6 +++
 drivers/gpu/drm/i915/intel_pm.c         | 48 --------------------
 drivers/gpu/drm/i915/intel_ringbuffer.c | 78 +++++++++++++++++++++++++++++++++
 drivers/gpu/drm/i915/intel_ringbuffer.h |  1 +
 4 files changed, 85 insertions(+), 48 deletions(-)
drivers/gpu/drm/i915/i915_gem_context.c +6 -0
index 9683e62..2debce4 100644
@@ -631,20 +631,26 @@ static int do_switch(struct intel_engine_cs *ring,
 	}
 
 	uninitialized = !to->legacy_hw_ctx.initialized && from == NULL;
 	to->legacy_hw_ctx.initialized = true;
 
 done:
 	i915_gem_context_reference(to);
 	ring->last_context = to;
 
 	if (uninitialized) {
+		if (IS_BROADWELL(ring->dev)) {
+			ret = bdw_init_workarounds(ring);
+			if (ret)
+				DRM_ERROR("init workarounds: %d\n", ret);
+		}
+
 		ret = i915_gem_render_state_init(ring);
 		if (ret)
 			DRM_ERROR("init render state: %d\n", ret);
 	}
 
 	return 0;
 
 unpin_out:
 	if (ring->id == RCS)
 		i915_gem_object_ggtt_unpin(to->legacy_hw_ctx.rcs_state);
drivers/gpu/drm/i915/intel_pm.c +0 -48

101 lines not on this page · raw message

drivers/gpu/drm/i915/intel_ringbuffer.c +78 -0

98 lines not on this page · raw message

drivers/gpu/drm/i915/intel_ringbuffer.h +1 -0
index 9cbf7b0..9da4107 100644
@@ -411,20 +411,21 @@ int intel_ring_flush_all_caches(struct intel_engine_cs *ring);
 int intel_ring_invalidate_all_caches(struct intel_engine_cs *ring);
 
 void intel_fini_pipe_control(struct intel_engine_cs *ring);
 int intel_init_pipe_control(struct intel_engine_cs *ring);
 
 int intel_init_render_ring_buffer(struct drm_device *dev);
 int intel_init_bsd_ring_buffer(struct drm_device *dev);
 int intel_init_bsd2_ring_buffer(struct drm_device *dev);
 int intel_init_blt_ring_buffer(struct drm_device *dev);
 int intel_init_vebox_ring_buffer(struct drm_device *dev);
+int bdw_init_workarounds(struct intel_engine_cs *ring);
 
 u64 intel_ring_get_active_head(struct intel_engine_cs *ring);
 void intel_ring_setup_status_page(struct intel_engine_cs *ring);
 
 static inline u32 intel_ring_get_tail(struct intel_ringbuffer *ringbuf)
 {
 	return ringbuf->tail;
 }
 
 static inline u32 intel_ring_get_seqno(struct intel_engine_cs *ring)
Signature · 1 line
2.0.4
#6 lore raw

PATCH 2/2 drm/i915/bdw: Export workaround data to debugfs

In reply to Arun Siluvery

The workarounds that are applied are exported to a debugfs file; this is used to verify their state after the test case (reset or suspend/resume etc). This patch is only required to support i-g-t.

---
 drivers/gpu/drm/i915/i915_debugfs.c     | 40 +++++++++++++++++++++++++++++++++
 drivers/gpu/drm/i915/i915_drv.h         | 14 ++++++++++++
 drivers/gpu/drm/i915/intel_ringbuffer.c | 23 +++++++++++++++++++
 3 files changed, 77 insertions(+)
drivers/gpu/drm/i915/i915_debugfs.c +40 -0
index d42db6b..f0d63f6 100644
@@ -2451,20 +2451,59 @@ static int i915_shared_dplls_info(struct seq_file *m, void *unused)
 		seq_printf(m, " dpll_md: 0x%08x\n", pll->hw_state.dpll_md);
 		seq_printf(m, " fp0:     0x%08x\n", pll->hw_state.fp0);
 		seq_printf(m, " fp1:     0x%08x\n", pll->hw_state.fp1);
 		seq_printf(m, " wrpll:   0x%08x\n", pll->hw_state.wrpll);
 	}
 	drm_modeset_unlock_all(dev);
 
 	return 0;
 }
 
+static int intel_wa_registers(struct seq_file *m, void *unused)
+{
+	int i;
+	int ret;
+	struct drm_info_node *node = (struct drm_info_node *) m->private;
+	struct drm_device *dev = node->minor->dev;
+	struct drm_i915_private *dev_priv = dev->dev_private;
+
+	if (!IS_BROADWELL(dev)) {
+		DRM_DEBUG_DRIVER("Workaround table not available !!\n");
+		return -EINVAL;
+	}
+
+	ret = mutex_lock_interruptible(&dev->struct_mutex);
+	if (ret)
+		return ret;
+
+	intel_runtime_pm_get(dev_priv);
+
+	seq_printf(m, "Workarounds applied: %d\n", dev_priv->num_wa_regs);
+	for (i = 0; i < dev_priv->num_wa_regs; ++i) {
+		u32 addr, mask;
+
+		addr = dev_priv->intel_wa_regs[i].addr;
+		mask = dev_priv->intel_wa_regs[i].mask;
+		dev_priv->intel_wa_regs[i].value = I915_READ(addr) | mask;
+		if (dev_priv->intel_wa_regs[i].addr)
+			seq_printf(m, "0x%X: 0x%08X, mask: 0x%08X\n",
+				   dev_priv->intel_wa_regs[i].addr,
+				   dev_priv->intel_wa_regs[i].value,
+				   dev_priv->intel_wa_regs[i].mask);
+	}
+
+	intel_runtime_pm_put(dev_priv);
+	mutex_unlock(&dev->struct_mutex);
+
+	return 0;
+}
+
 struct pipe_crc_info {
 	const char *name;
 	struct drm_device *dev;
 	enum pipe pipe;
 };
 
 static int i915_dp_mst_info(struct seq_file *m, void *unused)
 {
 	struct drm_info_node *node = (struct drm_info_node *) m->private;
 	struct drm_device *dev = node->minor->dev;
@@ -3980,20 +4019,21 @@ static const struct drm_info_list i915_debugfs_list[] = {
 	{"i915_llc", i915_llc, 0},
 	{"i915_edp_psr_status", i915_edp_psr_status, 0},
 	{"i915_sink_crc_eDP1", i915_sink_crc, 0},
 	{"i915_energy_uJ", i915_energy_uJ, 0},
 	{"i915_pc8_status", i915_pc8_status, 0},
 	{"i915_power_domain_info", i915_power_domain_info, 0},
 	{"i915_display_info", i915_display_info, 0},
 	{"i915_semaphore_status", i915_semaphore_status, 0},
 	{"i915_shared_dplls_info", i915_shared_dplls_info, 0},
 	{"i915_dp_mst_info", i915_dp_mst_info, 0},
+	{"intel_wa_registers", intel_wa_registers, 0}
 };
 #define I915_DEBUGFS_ENTRIES ARRAY_SIZE(i915_debugfs_list)
 
 static const struct i915_debugfs_files {
 	const char *name;
 	const struct file_operations *fops;
 } i915_debugfs_files[] = {
 	{"i915_wedged", &i915_wedged_fops},
 	{"i915_max_freq", &i915_max_freq_fops},
 	{"i915_min_freq", &i915_min_freq_fops},
drivers/gpu/drm/i915/i915_drv.h +14 -0
index bcf79f0..49b7be7 100644
@@ -1546,20 +1546,34 @@ struct drm_i915_private {
 	wait_queue_head_t pending_flip_queue;
 
 #ifdef CONFIG_DEBUG_FS
 	struct intel_pipe_crc pipe_crc[I915_MAX_PIPES];
 #endif
 
 	int num_shared_dpll;
 	struct intel_shared_dpll shared_dplls[I915_NUM_PLLS];
 	int dpio_phy_iosf_port[I915_NUM_PHYS_VLV];
 
+	/*
+	 * workarounds are currently applied at different places and
+	 * changes are being done to consolidate them so exact count is
+	 * not clear at this point, use a max value for now.
+	 */
+#define I915_MAX_WA_REGS  16
+	struct {
+		u32 addr;
+		u32 value;
+		/* bitmask representing WA bits */
+		u32 mask;
+	} intel_wa_regs[I915_MAX_WA_REGS];
+	u32 num_wa_regs;
+
 	/* Reclocking support */
 	bool render_reclock_avail;
 	bool lvds_downclock_avail;
 	/* indicates the reduced downclock for LVDS*/
 	int lvds_downclock;
 
 	struct i915_frontbuffer_tracking fb_tracking;
 
 	u16 orig_clock;
 
drivers/gpu/drm/i915/intel_ringbuffer.c +23 -0
index c1e7da6..0e496d2 100644
@@ -646,34 +646,54 @@ err_unpin:
 	i915_gem_object_ggtt_unpin(ring->scratch.obj);
 err_unref:
 	drm_gem_object_unreference(&ring->scratch.obj->base);
 err:
 	return ret;
 }
 
 static inline void intel_ring_emit_wa(struct intel_engine_cs *ring,
 				       u32 addr, u32 value)
 {
+	struct drm_device *dev = ring->dev;
+	struct drm_i915_private *dev_priv = dev->dev_private;
+
+	if (dev_priv->num_wa_regs > I915_MAX_WA_REGS)
+		return;
+
 	intel_ring_emit(ring, MI_LOAD_REGISTER_IMM(1));
 	intel_ring_emit(ring, addr);
 	intel_ring_emit(ring, value);
+
+	dev_priv->intel_wa_regs[dev_priv->num_wa_regs].addr = addr;
+	dev_priv->intel_wa_regs[dev_priv->num_wa_regs].mask = (value) & 0xFFFF;
+	/* value is updated with the status of remaining bits of this
+	 * register when it is read from debugfs file
+	 */
+	dev_priv->intel_wa_regs[dev_priv->num_wa_regs].value = value;
+	dev_priv->num_wa_regs++;
+
+	return;
 }
 
 int bdw_init_workarounds(struct intel_engine_cs *ring)
 {
 	int ret;
+	struct drm_device *dev = ring->dev;
+	struct drm_i915_private *dev_priv = dev->dev_private;
 
 	/*
 	 * workarounds applied in this fn are part of register state context,
 	 * they need to be re-initialized followed by gpu reset, suspend/resume,
 	 * module reload.
 	 */
+	dev_priv->num_wa_regs = 0;
+	memset(dev_priv->intel_wa_regs, 0, sizeof(dev_priv->intel_wa_regs));
 
 	/*
 	 * update the number of dwords required based on the
 	 * actual number of workarounds applied
 	 */
 	ret = intel_ring_begin(ring, 24);
 	if (ret)
 		return ret;
 
 	/* WaDisablePartialInstShootdown:bdw */
@@ -718,20 +738,23 @@ int bdw_init_workarounds(struct intel_engine_cs *ring)
 	 *
 	 * Note that PS/WM thread counts depend on the WIZ hashing
 	 * disable bit, which we don't touch here, but it's good
 	 * to keep in mind (see 3DSTATE_PS and 3DSTATE_WM).
 	 */
 	intel_ring_emit_wa(ring, GEN7_GT_MODE,
 			   GEN6_WIZ_HASHING_MASK | GEN6_WIZ_HASHING_16x4);
 
 	intel_ring_advance(ring);
 
+	DRM_DEBUG_DRIVER("Number of Workarounds applied: %d\n",
+			 dev_priv->num_wa_regs);
+
 	return 0;
 }
 
 static int init_render_ring(struct intel_engine_cs *ring)
 {
 	struct drm_device *dev = ring->dev;
 	struct drm_i915_private *dev_priv = dev->dev_private;
 	int ret = init_ring_common(ring);
 	if (ret)
 		return ret;
Signature · 1 line
2.0.4
#2 lore raw

Re: [PATCH 1/2] drm/i915/bdw: Apply workarounds in render ring init function

In reply to Arun Siluvery
Quoted 33 lines · Arun Siluvery

For BDW workarounds are currently initialized in init_clock_gating() but they are lost during reset, suspend/resume etc; this patch moves the WAs that are part of register state context to render ring init fn otherwise default context ends up with incorrect values as they don't get initialized until init_clock_gating fn.

v2: Add workarounds to golden render state
This method has its own issues, first of all this is different for each gen and it is generated using a tool so adding new workaround and mainitaining them across gens is not a straightforward process.

v3: Use LRIs to emit these workarounds (Ville) Instead of modifying the golden render state the same LRIs are emitted from within the driver.

For: VIZ-4092

---
 drivers/gpu/drm/i915/i915_gem_context.c |  6 +++
 drivers/gpu/drm/i915/intel_pm.c         | 48 --------------------
 drivers/gpu/drm/i915/intel_ringbuffer.c | 78 +++++++++++++++++++++++++++++++++
 drivers/gpu/drm/i915/intel_ringbuffer.h |  1 +
 4 files changed, 85 insertions(+), 48 deletions(-)
drivers/gpu/drm/i915/i915_gem_context.c +0 -0
index 9683e62..2debce4 100644
@@ -631,20 +631,26 @@ static int do_switch(struct intel_engine_cs *ring,
 	}
 
 	uninitialized = !to->legacy_hw_ctx.initialized && from == NULL;
 	to->legacy_hw_ctx.initialized = true;

drivers/gpu/drm/i915/i915_gem_context.c static int do_switch(struct intel_engine_cs *ring, · line 644

Quoted 10 lines
drivers/gpu/drm/i915/i915_gem_context.c +4 -0
 
 done:
 	i915_gem_context_reference(to);
 	ring->last_context = to;
 
 	if (uninitialized) {
+		if (IS_BROADWELL(ring->dev)) {
+			ret = bdw_init_workarounds(ring);
+			if (ret)
+				DRM_ERROR("init workarounds: %d\n", ret);

A good rule of thumb is that if you are exporting gen specific routines, the layering and abstraction is fishy.
-Chris

Signature · 1 line
Chris Wilson, Intel Open Source Technology Centre
#3 lore raw

Re: [PATCH 1/2] drm/i915/bdw: Apply workarounds in render ring init function

Quoted 39 lines · Chris Wilson
Quoted 38 lines · Arun Siluvery

For BDW workarounds are currently initialized in init_clock_gating() but they are lost during reset, suspend/resume etc; this patch moves the WAs that are part of register state context to render ring init fn otherwise default context ends up with incorrect values as they don't get initialized until init_clock_gating fn.

v2: Add workarounds to golden render state
This method has its own issues, first of all this is different for each gen and it is generated using a tool so adding new workaround and mainitaining them across gens is not a straightforward process.

v3: Use LRIs to emit these workarounds (Ville) Instead of modifying the golden render state the same LRIs are emitted from within the driver.

For: VIZ-4092

---
  drivers/gpu/drm/i915/i915_gem_context.c |  6 +++
  drivers/gpu/drm/i915/intel_pm.c         | 48 --------------------
  drivers/gpu/drm/i915/intel_ringbuffer.c | 78 +++++++++++++++++++++++++++++++++
  drivers/gpu/drm/i915/intel_ringbuffer.h |  1 +
  4 files changed, 85 insertions(+), 48 deletions(-)
drivers/gpu/drm/i915/i915_gem_context.c +0 -0
index 9683e62..2debce4 100644
@@ -631,20 +631,26 @@ static int do_switch(struct intel_engine_cs *ring,
  	}
 
  	uninitialized = !to->legacy_hw_ctx.initialized && from == NULL;
  	to->legacy_hw_ctx.initialized = true;
 
  done:
  	i915_gem_context_reference(to);
  	ring->last_context = to;
 
Quoted 10 lines

drivers/gpu/drm/i915/i915_gem_context.c static int do_switch(struct intel_engine_cs *ring, · line 644

Quoted 5 lines
drivers/gpu/drm/i915/i915_gem_context.c +4 -0
  	if (uninitialized) {
+		if (IS_BROADWELL(ring->dev)) {
+			ret = bdw_init_workarounds(ring);
+			if (ret)
+				DRM_ERROR("init workarounds: %d\n", ret);

A good rule of thumb is that if you are exporting gen specific routines, the layering and abstraction is fishy.
-Chris

ok, so something like i915_init_workarounds() is ok? with a check for bdw/gen8 done inside that function.

regards
Arun

#4 lore raw

Re: [PATCH 1/2] drm/i915/bdw: Apply workarounds in render ring init function

Quoted 50 lines · Arun
Quoted 39 lines · Chris Wilson
Quoted 38 lines · Arun Siluvery

For BDW workarounds are currently initialized in init_clock_gating() but they are lost during reset, suspend/resume etc; this patch moves the WAs that are part of register state context to render ring init fn otherwise default context ends up with incorrect values as they don't get initialized until init_clock_gating fn.

v2: Add workarounds to golden render state
This method has its own issues, first of all this is different for each gen and it is generated using a tool so adding new workaround and mainitaining them across gens is not a straightforward process.

v3: Use LRIs to emit these workarounds (Ville) Instead of modifying the golden render state the same LRIs are emitted from within the driver.

For: VIZ-4092

---
 drivers/gpu/drm/i915/i915_gem_context.c |  6 +++
 drivers/gpu/drm/i915/intel_pm.c         | 48 --------------------
 drivers/gpu/drm/i915/intel_ringbuffer.c | 78 +++++++++++++++++++++++++++++++++
 drivers/gpu/drm/i915/intel_ringbuffer.h |  1 +
 4 files changed, 85 insertions(+), 48 deletions(-)
drivers/gpu/drm/i915/i915_gem_context.c +0 -0
index 9683e62..2debce4 100644
@@ -631,20 +631,26 @@ static int do_switch(struct intel_engine_cs *ring,
 	}
 
 	uninitialized = !to->legacy_hw_ctx.initialized && from == NULL;
 	to->legacy_hw_ctx.initialized = true;
 
 done:
 	i915_gem_context_reference(to);
 	ring->last_context = to;
 
Quoted 10 lines

drivers/gpu/drm/i915/i915_gem_context.c static int do_switch(struct intel_engine_cs *ring, · line 644

Quoted 5 lines
drivers/gpu/drm/i915/i915_gem_context.c +4 -0
 	if (uninitialized) {
+		if (IS_BROADWELL(ring->dev)) {
+			ret = bdw_init_workarounds(ring);
+			if (ret)
+				DRM_ERROR("init workarounds: %d\n", ret);

A good rule of thumb is that if you are exporting gen specific routines, the layering and abstraction is fishy.
-Chris

Quoted 2 lines

ok, so something like i915_init_workarounds() is ok? with a check for bdw/gen8 done inside that function.

Except for init_workarounds is quite useless as a function name and we already have a structure that is already customised per-engine and per-gen that you could hook into. engine->ring_init_context() ?
-Chris

Signature · 1 line
Chris Wilson, Intel Open Source Technology Centre
#5 lore raw

Re: [PATCH 1/2] drm/i915/bdw: Apply workarounds in render ring init function

Quoted 51 lines · Chris Wilson
Quoted 50 lines · Arun
Quoted 49 lines · Chris Wilson
Quoted 33 lines · Arun Siluvery

For BDW workarounds are currently initialized in init_clock_gating() but they are lost during reset, suspend/resume etc; this patch moves the WAs that are part of register state context to render ring init fn otherwise default context ends up with incorrect values as they don't get initialized until init_clock_gating fn.

v2: Add workarounds to golden render state
This method has its own issues, first of all this is different for each gen and it is generated using a tool so adding new workaround and mainitaining them across gens is not a straightforward process.

v3: Use LRIs to emit these workarounds (Ville) Instead of modifying the golden render state the same LRIs are emitted from within the driver.

For: VIZ-4092

---
  drivers/gpu/drm/i915/i915_gem_context.c |  6 +++
  drivers/gpu/drm/i915/intel_pm.c         | 48 --------------------
  drivers/gpu/drm/i915/intel_ringbuffer.c | 78 +++++++++++++++++++++++++++++++++
  drivers/gpu/drm/i915/intel_ringbuffer.h |  1 +
  4 files changed, 85 insertions(+), 48 deletions(-)
drivers/gpu/drm/i915/i915_gem_context.c +0 -0
index 9683e62..2debce4 100644
@@ -631,20 +631,26 @@ static int do_switch(struct intel_engine_cs *ring,
  	}
 
  	uninitialized = !to->legacy_hw_ctx.initialized && from == NULL;
  	to->legacy_hw_ctx.initialized = true;

drivers/gpu/drm/i915/i915_gem_context.c static int do_switch(struct intel_engine_cs *ring, · line 644

Quoted 10 lines
drivers/gpu/drm/i915/i915_gem_context.c +4 -0
 
  done:
  	i915_gem_context_reference(to);
  	ring->last_context = to;
 
  	if (uninitialized) {
+		if (IS_BROADWELL(ring->dev)) {
+			ret = bdw_init_workarounds(ring);
+			if (ret)
+				DRM_ERROR("init workarounds: %d\n", ret);

A good rule of thumb is that if you are exporting gen specific routines, the layering and abstraction is fishy.
-Chris

Quoted 9 lines
Quoted 2 lines

ok, so something like i915_init_workarounds() is ok? with a check for bdw/gen8 done inside that function.

Except for init_workarounds is quite useless as a function name and we already have a structure that is already customised per-engine and per-gen that you could hook into. engine->ring_init_context() ?
-Chris

Ok thanks, I can create a new fn ring_init_context().

regards
Arun