diff mbox

[1/3] drm/i915/tdr: Initialize hangcheck struct for each engine

Message ID 1458331676-567-2-git-send-email-arun.siluvery@linux.intel.com (mailing list archive)
State New, archived
Headers show

Commit Message

arun.siluvery@linux.intel.com March 18, 2016, 8:07 p.m. UTC
From: Tomas Elf <tomas.elf@intel.com>

Initialize hangcheck struct during driver load. Since we do the same after
recovering from a reset, this is extracted into a helper function.

Cc: Mika Kuoppala <mika.kuoppala@intel.com>
Signed-off-by: Tomas Elf <tomas.elf@intel.com>
Signed-off-by: Arun Siluvery <arun.siluvery@linux.intel.com>
---
 drivers/gpu/drm/i915/i915_dma.c         | 12 ++++++++++++
 drivers/gpu/drm/i915/i915_drv.h         |  1 +
 drivers/gpu/drm/i915/intel_lrc.c        |  2 +-
 drivers/gpu/drm/i915/intel_ringbuffer.c |  7 ++++++-
 4 files changed, 20 insertions(+), 2 deletions(-)

Comments

Chris Wilson March 18, 2016, 8:48 p.m. UTC | #1
On Fri, Mar 18, 2016 at 08:07:54PM +0000, Arun Siluvery wrote:
> From: Tomas Elf <tomas.elf@intel.com>
> 
> Initialize hangcheck struct during driver load. Since we do the same after
> recovering from a reset, this is extracted into a helper function.
> 
> Cc: Mika Kuoppala <mika.kuoppala@intel.com>
> Signed-off-by: Tomas Elf <tomas.elf@intel.com>
> Signed-off-by: Arun Siluvery <arun.siluvery@linux.intel.com>
> ---
>  drivers/gpu/drm/i915/i915_dma.c         | 12 ++++++++++++
>  drivers/gpu/drm/i915/i915_drv.h         |  1 +
>  drivers/gpu/drm/i915/intel_lrc.c        |  2 +-
>  drivers/gpu/drm/i915/intel_ringbuffer.c |  7 ++++++-
>  4 files changed, 20 insertions(+), 2 deletions(-)
> 
> diff --git a/drivers/gpu/drm/i915/i915_dma.c b/drivers/gpu/drm/i915/i915_dma.c
> index 3f439a0..c5d1673 100644
> --- a/drivers/gpu/drm/i915/i915_dma.c
> +++ b/drivers/gpu/drm/i915/i915_dma.c
> @@ -945,6 +945,16 @@ static void intel_init_dpio(struct drm_i915_private *dev_priv)
>  	}
>  }
>  
> +static void i915_hangcheck_init(struct drm_device *dev)
> +{
> +	int i;
> +	struct intel_engine_cs *engine;
> +	struct drm_i915_private *dev_priv = dev->dev_private;
> +
> +	for_each_engine(engine, dev_priv, i)
> +		intel_engine_init_hangcheck(engine);
> +}
> +
>  static int i915_workqueues_init(struct drm_i915_private *dev_priv)
>  {
>  	/*
> @@ -1233,6 +1243,8 @@ static int i915_driver_init_hw(struct drm_i915_private *dev_priv)
>  
>  	i915_gem_load_init_fences(dev_priv);
>  
> +	i915_hangcheck_init(dev);

This is tautological. If we are clearing the per-engine hangcheck in
ring->init_hw() then we will do later anyway. So why now?
-Chris
arun.siluvery@linux.intel.com March 18, 2016, 9:22 p.m. UTC | #2
On 18/03/2016 20:48, Chris Wilson wrote:
> On Fri, Mar 18, 2016 at 08:07:54PM +0000, Arun Siluvery wrote:
>> From: Tomas Elf <tomas.elf@intel.com>
>>
>> Initialize hangcheck struct during driver load. Since we do the same after
>> recovering from a reset, this is extracted into a helper function.
>>
>> Cc: Mika Kuoppala <mika.kuoppala@intel.com>
>> Signed-off-by: Tomas Elf <tomas.elf@intel.com>
>> Signed-off-by: Arun Siluvery <arun.siluvery@linux.intel.com>
>> ---
>>   drivers/gpu/drm/i915/i915_dma.c         | 12 ++++++++++++
>>   drivers/gpu/drm/i915/i915_drv.h         |  1 +
>>   drivers/gpu/drm/i915/intel_lrc.c        |  2 +-
>>   drivers/gpu/drm/i915/intel_ringbuffer.c |  7 ++++++-
>>   4 files changed, 20 insertions(+), 2 deletions(-)
>>
>> diff --git a/drivers/gpu/drm/i915/i915_dma.c b/drivers/gpu/drm/i915/i915_dma.c
>> index 3f439a0..c5d1673 100644
>> --- a/drivers/gpu/drm/i915/i915_dma.c
>> +++ b/drivers/gpu/drm/i915/i915_dma.c
>> @@ -945,6 +945,16 @@ static void intel_init_dpio(struct drm_i915_private *dev_priv)
>>   	}
>>   }
>>
>> +static void i915_hangcheck_init(struct drm_device *dev)
>> +{
>> +	int i;
>> +	struct intel_engine_cs *engine;
>> +	struct drm_i915_private *dev_priv = dev->dev_private;
>> +
>> +	for_each_engine(engine, dev_priv, i)
>> +		intel_engine_init_hangcheck(engine);
>> +}
>> +
>>   static int i915_workqueues_init(struct drm_i915_private *dev_priv)
>>   {
>>   	/*
>> @@ -1233,6 +1243,8 @@ static int i915_driver_init_hw(struct drm_i915_private *dev_priv)
>>
>>   	i915_gem_load_init_fences(dev_priv);
>>
>> +	i915_hangcheck_init(dev);
>
> This is tautological. If we are clearing the per-engine hangcheck in
> ring->init_hw() then we will do later anyway. So why now?

It was doing slightly more earlier but now it is not required. The 
helper function intel_engine_init_hangcheck() also doesn't add much 
value so this patch can be ignored.

regards
Arun


> -Chris
>
Chris Wilson March 18, 2016, 9:34 p.m. UTC | #3
On Fri, Mar 18, 2016 at 09:22:55PM +0000, Arun Siluvery wrote:
> On 18/03/2016 20:48, Chris Wilson wrote:
> >On Fri, Mar 18, 2016 at 08:07:54PM +0000, Arun Siluvery wrote:
> >>From: Tomas Elf <tomas.elf@intel.com>
> >>
> >>Initialize hangcheck struct during driver load. Since we do the same after
> >>recovering from a reset, this is extracted into a helper function.
> >>
> >>Cc: Mika Kuoppala <mika.kuoppala@intel.com>
> >>Signed-off-by: Tomas Elf <tomas.elf@intel.com>
> >>Signed-off-by: Arun Siluvery <arun.siluvery@linux.intel.com>
> >>---
> >>  drivers/gpu/drm/i915/i915_dma.c         | 12 ++++++++++++
> >>  drivers/gpu/drm/i915/i915_drv.h         |  1 +
> >>  drivers/gpu/drm/i915/intel_lrc.c        |  2 +-
> >>  drivers/gpu/drm/i915/intel_ringbuffer.c |  7 ++++++-
> >>  4 files changed, 20 insertions(+), 2 deletions(-)
> >>
> >>diff --git a/drivers/gpu/drm/i915/i915_dma.c b/drivers/gpu/drm/i915/i915_dma.c
> >>index 3f439a0..c5d1673 100644
> >>--- a/drivers/gpu/drm/i915/i915_dma.c
> >>+++ b/drivers/gpu/drm/i915/i915_dma.c
> >>@@ -945,6 +945,16 @@ static void intel_init_dpio(struct drm_i915_private *dev_priv)
> >>  	}
> >>  }
> >>
> >>+static void i915_hangcheck_init(struct drm_device *dev)
> >>+{
> >>+	int i;
> >>+	struct intel_engine_cs *engine;
> >>+	struct drm_i915_private *dev_priv = dev->dev_private;
> >>+
> >>+	for_each_engine(engine, dev_priv, i)
> >>+		intel_engine_init_hangcheck(engine);
> >>+}
> >>+
> >>  static int i915_workqueues_init(struct drm_i915_private *dev_priv)
> >>  {
> >>  	/*
> >>@@ -1233,6 +1243,8 @@ static int i915_driver_init_hw(struct drm_i915_private *dev_priv)
> >>
> >>  	i915_gem_load_init_fences(dev_priv);
> >>
> >>+	i915_hangcheck_init(dev);
> >
> >This is tautological. If we are clearing the per-engine hangcheck in
> >ring->init_hw() then we will do later anyway. So why now?
> 
> It was doing slightly more earlier but now it is not required. The
> helper function intel_engine_init_hangcheck() also doesn't add much
> value so this patch can be ignored.

The helper function is ok, it adds a little bit of documentation which
is far more meaningful than memset(). I was just wondering if there was
an actual requirement I missed for i915_driver_init_hw() to do so, or if
there will be.
-Chris
Chris Wilson March 21, 2016, 5:15 p.m. UTC | #4
On Mon, Mar 21, 2016 at 04:26:59PM +0000, Arun Siluvery wrote:
> From: Tomas Elf <tomas.elf@intel.com>
> 
> Initialize hangcheck struct during driver load. Since we do the same after
> recovering from a reset, this is extracted into a helper function.
> 
> v2: remove redundant hangcheck init during load as this is done when
> engines are initialized (Chris)
> 
> Cc: Mika Kuoppala <mika.kuoppala@intel.com>
> Signed-off-by: Tomas Elf <tomas.elf@intel.com>
> Signed-off-by: Arun Siluvery <arun.siluvery@linux.intel.com>
Reviewed-by: Chris Wilson <chris@chris-wilson.co.uk>
-Chris
diff mbox

Patch

diff --git a/drivers/gpu/drm/i915/i915_dma.c b/drivers/gpu/drm/i915/i915_dma.c
index 3f439a0..c5d1673 100644
--- a/drivers/gpu/drm/i915/i915_dma.c
+++ b/drivers/gpu/drm/i915/i915_dma.c
@@ -945,6 +945,16 @@  static void intel_init_dpio(struct drm_i915_private *dev_priv)
 	}
 }
 
+static void i915_hangcheck_init(struct drm_device *dev)
+{
+	int i;
+	struct intel_engine_cs *engine;
+	struct drm_i915_private *dev_priv = dev->dev_private;
+
+	for_each_engine(engine, dev_priv, i)
+		intel_engine_init_hangcheck(engine);
+}
+
 static int i915_workqueues_init(struct drm_i915_private *dev_priv)
 {
 	/*
@@ -1233,6 +1243,8 @@  static int i915_driver_init_hw(struct drm_i915_private *dev_priv)
 
 	i915_gem_load_init_fences(dev_priv);
 
+	i915_hangcheck_init(dev);
+
 	/* On the 945G/GM, the chipset reports the MSI capability on the
 	 * integrated graphics even though the support isn't actually there
 	 * according to the published specs.  It doesn't appear to function
diff --git a/drivers/gpu/drm/i915/i915_drv.h b/drivers/gpu/drm/i915/i915_drv.h
index f330a53..549a232 100644
--- a/drivers/gpu/drm/i915/i915_drv.h
+++ b/drivers/gpu/drm/i915/i915_drv.h
@@ -2718,6 +2718,7 @@  extern long i915_compat_ioctl(struct file *filp, unsigned int cmd,
 extern int intel_gpu_reset(struct drm_device *dev, u32 engine_mask);
 extern bool intel_has_gpu_reset(struct drm_device *dev);
 extern int i915_reset(struct drm_device *dev);
+extern void intel_engine_init_hangcheck(struct intel_engine_cs *engine);
 extern unsigned long i915_chipset_val(struct drm_i915_private *dev_priv);
 extern unsigned long i915_mch_val(struct drm_i915_private *dev_priv);
 extern unsigned long i915_gfx_val(struct drm_i915_private *dev_priv);
diff --git a/drivers/gpu/drm/i915/intel_lrc.c b/drivers/gpu/drm/i915/intel_lrc.c
index 3a23b95..40ef4ea 100644
--- a/drivers/gpu/drm/i915/intel_lrc.c
+++ b/drivers/gpu/drm/i915/intel_lrc.c
@@ -1606,7 +1606,7 @@  static int gen8_init_common_ring(struct intel_engine_cs *engine)
 	engine->next_context_status_buffer = next_context_status_buffer_hw;
 	DRM_DEBUG_DRIVER("Execlists enabled for %s\n", engine->name);
 
-	memset(&engine->hangcheck, 0, sizeof(engine->hangcheck));
+	intel_engine_init_hangcheck(engine);
 
 	return 0;
 }
diff --git a/drivers/gpu/drm/i915/intel_ringbuffer.c b/drivers/gpu/drm/i915/intel_ringbuffer.c
index df0ef5b..ce59850 100644
--- a/drivers/gpu/drm/i915/intel_ringbuffer.c
+++ b/drivers/gpu/drm/i915/intel_ringbuffer.c
@@ -555,6 +555,11 @@  static bool stop_ring(struct intel_engine_cs *engine)
 	return (I915_READ_HEAD(engine) & HEAD_ADDR) == 0;
 }
 
+void intel_engine_init_hangcheck(struct intel_engine_cs *engine)
+{
+	memset(&engine->hangcheck, 0, sizeof(engine->hangcheck));
+}
+
 static int init_ring_common(struct intel_engine_cs *engine)
 {
 	struct drm_device *dev = engine->dev;
@@ -634,7 +639,7 @@  static int init_ring_common(struct intel_engine_cs *engine)
 	ringbuf->tail = I915_READ_TAIL(engine) & TAIL_ADDR;
 	intel_ring_update_space(ringbuf);
 
-	memset(&engine->hangcheck, 0, sizeof(engine->hangcheck));
+	intel_engine_init_hangcheck(engine);
 
 out:
 	intel_uncore_forcewake_put(dev_priv, FORCEWAKE_ALL);