All of lore.kernel.org
 help / color / mirror / Atom feed
* [PATCH] drm/i915: hold forcewake around ring hw init
@ 2012-06-04  8:40 Daniel Vetter
  2012-06-04  9:04 ` Jani Nikula
  0 siblings, 1 reply; 8+ messages in thread
From: Daniel Vetter @ 2012-06-04  8:40 UTC (permalink / raw)
  To: Intel Graphics Development; +Cc: Daniel Vetter, stable

Empirical evidence suggests that we need to: On at least one ivb
machine when running the hangman i-g-t test, the rings don't properly
initialize properly - the RING_START registers seems to be stuck at
all zeros.

Holding forcewake around this register init sequences makes chip reset
reliable again. Note that this is not the first such issue:

commit f01db988ef6f6c70a6cc36ee71e4a98a68901229
Author: Sean Paul <seanpaul@chromium.org>
Date:   Fri Mar 16 12:43:22 2012 -0400

    drm/i915: Add wait_for in init_ring_common

added delay loops to make RING_START and RING_CTL initialization
reliable on the blt ring at boot-up. So I guess it won't hurt if we do
this unconditionally for all force_wake needing gpus.

To avoid copy&pasting of the HAS_FORCE_WAKE check I've added a new
intel_info bit for that.

Cc: stable@vger.kernel.org
Reported-by: Yang Guang <guang.a.yang@intel.com>
Bugzilla: https://bugs.freedesktop.org/show_bug.cgi?id=50522
Signed-Off-by: Daniel Vetter <daniel.vetter@ffwll.ch>
---
 drivers/gpu/drm/i915/i915_drv.c         |   13 +++++++++----
 drivers/gpu/drm/i915/i915_drv.h         |    3 +++
 drivers/gpu/drm/i915/intel_ringbuffer.c |    9 ++++++++-
 3 files changed, 20 insertions(+), 5 deletions(-)

diff --git a/drivers/gpu/drm/i915/i915_drv.c b/drivers/gpu/drm/i915/i915_drv.c
index 238a521..a0c76aa 100644
--- a/drivers/gpu/drm/i915/i915_drv.c
+++ b/drivers/gpu/drm/i915/i915_drv.c
@@ -233,6 +233,7 @@ static const struct intel_device_info intel_sandybridge_d_info = {
 	.has_blt_ring = 1,
 	.has_llc = 1,
 	.has_pch_split = 1,
+	.has_force_wake = 1
 };
 
 static const struct intel_device_info intel_sandybridge_m_info = {
@@ -243,6 +244,7 @@ static const struct intel_device_info intel_sandybridge_m_info = {
 	.has_blt_ring = 1,
 	.has_llc = 1,
 	.has_pch_split = 1,
+	.has_force_wake = 1
 };
 
 static const struct intel_device_info intel_ivybridge_d_info = {
@@ -252,6 +254,7 @@ static const struct intel_device_info intel_ivybridge_d_info = {
 	.has_blt_ring = 1,
 	.has_llc = 1,
 	.has_pch_split = 1,
+	.has_force_wake = 1
 };
 
 static const struct intel_device_info intel_ivybridge_m_info = {
@@ -262,6 +265,7 @@ static const struct intel_device_info intel_ivybridge_m_info = {
 	.has_blt_ring = 1,
 	.has_llc = 1,
 	.has_pch_split = 1,
+	.has_force_wake = 1
 };
 
 static const struct intel_device_info intel_valleyview_m_info = {
@@ -289,6 +293,7 @@ static const struct intel_device_info intel_haswell_d_info = {
 	.has_blt_ring = 1,
 	.has_llc = 1,
 	.has_pch_split = 1,
+	.has_force_wake = 1
 };
 
 static const struct intel_device_info intel_haswell_m_info = {
@@ -298,6 +303,7 @@ static const struct intel_device_info intel_haswell_m_info = {
 	.has_blt_ring = 1,
 	.has_llc = 1,
 	.has_pch_split = 1,
+	.has_force_wake = 1
 };
 
 static const struct pci_device_id pciidlist[] = {		/* aka */
@@ -1139,10 +1145,9 @@ MODULE_LICENSE("GPL and additional rights");
 
 /* We give fast paths for the really cool registers */
 #define NEEDS_FORCE_WAKE(dev_priv, reg) \
-       (((dev_priv)->info->gen >= 6) && \
-        ((reg) < 0x40000) &&            \
-        ((reg) != FORCEWAKE)) && \
-       (!IS_VALLEYVIEW((dev_priv)->dev))
+	((HAS_FORCE_WAKE((dev_priv)->dev)) && \
+	 ((reg) < 0x40000) &&            \
+	 ((reg) != FORCEWAKE))
 
 #define __i915_read(x, y) \
 u##x i915_read##x(struct drm_i915_private *dev_priv, u32 reg) { \
diff --git a/drivers/gpu/drm/i915/i915_drv.h b/drivers/gpu/drm/i915/i915_drv.h
index ccabadd..7cc36db 100644
--- a/drivers/gpu/drm/i915/i915_drv.h
+++ b/drivers/gpu/drm/i915/i915_drv.h
@@ -285,6 +285,7 @@ struct intel_device_info {
 	u8 is_ivybridge:1;
 	u8 is_valleyview:1;
 	u8 has_pch_split:1;
+	u8 has_force_wake:1;
 	u8 is_haswell:1;
 	u8 has_fbc:1;
 	u8 has_pipe_cxsr:1;
@@ -1105,6 +1106,8 @@ struct drm_i915_file_private {
 #define HAS_PCH_CPT(dev) (INTEL_PCH_TYPE(dev) == PCH_CPT)
 #define HAS_PCH_IBX(dev) (INTEL_PCH_TYPE(dev) == PCH_IBX)
 
+#define HAS_FORCE_WAKE(dev) (INTEL_INFO(dev)->has_force_wake)
+
 #include "i915_trace.h"
 
 /**
diff --git a/drivers/gpu/drm/i915/intel_ringbuffer.c b/drivers/gpu/drm/i915/intel_ringbuffer.c
index 89a5e7f..bdb37f2 100644
--- a/drivers/gpu/drm/i915/intel_ringbuffer.c
+++ b/drivers/gpu/drm/i915/intel_ringbuffer.c
@@ -266,10 +266,14 @@ u32 intel_ring_get_active_head(struct intel_ring_buffer *ring)
 
 static int init_ring_common(struct intel_ring_buffer *ring)
 {
-	drm_i915_private_t *dev_priv = ring->dev->dev_private;
+	struct drm_device *dev = ring->dev;
+	drm_i915_private_t *dev_priv = dev->dev_private;
 	struct drm_i915_gem_object *obj = ring->obj;
 	u32 head;
 
+	if (HAS_FORCE_WAKE(dev))
+		gen6_gt_force_wake_get(dev_priv);
+
 	/* Stop the ring if it's running. */
 	I915_WRITE_CTL(ring, 0);
 	I915_WRITE_HEAD(ring, 0);
@@ -328,6 +332,9 @@ static int init_ring_common(struct intel_ring_buffer *ring)
 		ring->space = ring_space(ring);
 	}
 
+	if (HAS_FORCE_WAKE(dev))
+		gen6_gt_force_wake_put(dev_priv);
+
 	return 0;
 }
 
-- 
1.7.10

^ permalink raw reply related	[flat|nested] 8+ messages in thread

* Re: [PATCH] drm/i915: hold forcewake around ring hw init
  2012-06-04  8:40 [PATCH] drm/i915: hold forcewake around ring hw init Daniel Vetter
@ 2012-06-04  9:04 ` Jani Nikula
  2012-06-04  9:16   ` Daniel Vetter
  2012-06-04  9:18   ` Daniel Vetter
  0 siblings, 2 replies; 8+ messages in thread
From: Jani Nikula @ 2012-06-04  9:04 UTC (permalink / raw)
  To: Intel Graphics Development; +Cc: Daniel Vetter, stable


Hi Daniel, please find a couple of comments inline.

BR,
Jani.

On Mon, 04 Jun 2012, Daniel Vetter <daniel.vetter@ffwll.ch> wrote:
> diff --git a/drivers/gpu/drm/i915/i915_drv.c b/drivers/gpu/drm/i915/i915_drv.c
> index 238a521..a0c76aa 100644
> --- a/drivers/gpu/drm/i915/i915_drv.c
> +++ b/drivers/gpu/drm/i915/i915_drv.c
> @@ -233,6 +233,7 @@ static const struct intel_device_info intel_sandybridge_d_info = {
>  	.has_blt_ring = 1,
>  	.has_llc = 1,
>  	.has_pch_split = 1,
> +	.has_force_wake = 1
>  };

Don't know if you care, but sticking a comma at the would avoid touching
the line the next time you need to add a field. Ditto below.

>  
>  static const struct intel_device_info intel_sandybridge_m_info = {
> @@ -243,6 +244,7 @@ static const struct intel_device_info intel_sandybridge_m_info = {
>  	.has_blt_ring = 1,
>  	.has_llc = 1,
>  	.has_pch_split = 1,
> +	.has_force_wake = 1
>  };
>  
>  static const struct intel_device_info intel_ivybridge_d_info = {
> @@ -252,6 +254,7 @@ static const struct intel_device_info intel_ivybridge_d_info = {
>  	.has_blt_ring = 1,
>  	.has_llc = 1,
>  	.has_pch_split = 1,
> +	.has_force_wake = 1
>  };
>  
>  static const struct intel_device_info intel_ivybridge_m_info = {
> @@ -262,6 +265,7 @@ static const struct intel_device_info intel_ivybridge_m_info = {
>  	.has_blt_ring = 1,
>  	.has_llc = 1,
>  	.has_pch_split = 1,
> +	.has_force_wake = 1
>  };
>  
>  static const struct intel_device_info intel_valleyview_m_info = {
> @@ -289,6 +293,7 @@ static const struct intel_device_info intel_haswell_d_info = {
>  	.has_blt_ring = 1,
>  	.has_llc = 1,
>  	.has_pch_split = 1,
> +	.has_force_wake = 1
>  };
>  
>  static const struct intel_device_info intel_haswell_m_info = {
> @@ -298,6 +303,7 @@ static const struct intel_device_info intel_haswell_m_info = {
>  	.has_blt_ring = 1,
>  	.has_llc = 1,
>  	.has_pch_split = 1,
> +	.has_force_wake = 1
>  };
>  

[snip]

> diff --git a/drivers/gpu/drm/i915/intel_ringbuffer.c b/drivers/gpu/drm/i915/intel_ringbuffer.c
> index 89a5e7f..bdb37f2 100644
> --- a/drivers/gpu/drm/i915/intel_ringbuffer.c
> +++ b/drivers/gpu/drm/i915/intel_ringbuffer.c
> @@ -266,10 +266,14 @@ u32 intel_ring_get_active_head(struct intel_ring_buffer *ring)
>  
>  static int init_ring_common(struct intel_ring_buffer *ring)
>  {
> -	drm_i915_private_t *dev_priv = ring->dev->dev_private;
> +	struct drm_device *dev = ring->dev;
> +	drm_i915_private_t *dev_priv = dev->dev_private;
>  	struct drm_i915_gem_object *obj = ring->obj;
>  	u32 head;
>  
> +	if (HAS_FORCE_WAKE(dev))
> +		gen6_gt_force_wake_get(dev_priv);
> +
>  	/* Stop the ring if it's running. */
>  	I915_WRITE_CTL(ring, 0);
>  	I915_WRITE_HEAD(ring, 0);
> @@ -328,6 +332,9 @@ static int init_ring_common(struct intel_ring_buffer *ring)
>  		ring->space = ring_space(ring);
>  	}
>  

Above, outside of patch context, there's an error code path with return
-EIO, which I think would leak dev_priv->forcewake_count.

> +	if (HAS_FORCE_WAKE(dev))
> +		gen6_gt_force_wake_put(dev_priv);
> +
>  	return 0;
>  }

^ permalink raw reply	[flat|nested] 8+ messages in thread

* Re: [PATCH] drm/i915: hold forcewake around ring hw init
  2012-06-04  9:04 ` Jani Nikula
@ 2012-06-04  9:16   ` Daniel Vetter
  2012-06-04  9:21     ` Chris Wilson
  2012-06-04  9:18   ` Daniel Vetter
  1 sibling, 1 reply; 8+ messages in thread
From: Daniel Vetter @ 2012-06-04  9:16 UTC (permalink / raw)
  To: Jani Nikula; +Cc: Daniel Vetter, Intel Graphics Development, stable

On Mon, Jun 04, 2012 at 12:04:41PM +0300, Jani Nikula wrote:
> 
> Hi Daniel, please find a couple of comments inline.

Oops, a clear case of -ENOTENOUGHCOFFEE. Thanks for catching these, I'll
follow up with a v2 shortly.
-Daniel
-- 
Daniel Vetter
Mail: daniel@ffwll.ch
Mobile: +41 (0)79 365 57 48

^ permalink raw reply	[flat|nested] 8+ messages in thread

* [PATCH] drm/i915: hold forcewake around ring hw init
  2012-06-04  9:04 ` Jani Nikula
  2012-06-04  9:16   ` Daniel Vetter
@ 2012-06-04  9:18   ` Daniel Vetter
  2012-06-04  9:39     ` Daniel Vetter
  2012-06-04 12:47     ` Eugeni Dodonov
  1 sibling, 2 replies; 8+ messages in thread
From: Daniel Vetter @ 2012-06-04  9:18 UTC (permalink / raw)
  To: Intel Graphics Development; +Cc: Daniel Vetter, stable

Empirical evidence suggests that we need to: On at least one ivb
machine when running the hangman i-g-t test, the rings don't properly
initialize properly - the RING_START registers seems to be stuck at
all zeros.

Holding forcewake around this register init sequences makes chip reset
reliable again. Note that this is not the first such issue:

commit f01db988ef6f6c70a6cc36ee71e4a98a68901229
Author: Sean Paul <seanpaul@chromium.org>
Date:   Fri Mar 16 12:43:22 2012 -0400

    drm/i915: Add wait_for in init_ring_common

added delay loops to make RING_START and RING_CTL initialization
reliable on the blt ring at boot-up. So I guess it won't hurt if we do
this unconditionally for all force_wake needing gpus.

To avoid copy&pasting of the HAS_FORCE_WAKE check I've added a new
intel_info bit for that.

v2: Fixup missing commas in static struct and properly handling the
error case in init_ring_common, both noticed by Jani Nikula.

Cc: stable@vger.kernel.org
Reported-by: Yang Guang <guang.a.yang@intel.com>
Bugzilla: https://bugs.freedesktop.org/show_bug.cgi?id=50522
Signed-Off-by: Daniel Vetter <daniel.vetter@ffwll.ch>
---
 drivers/gpu/drm/i915/i915_drv.c         |   13 +++++++++----
 drivers/gpu/drm/i915/i915_drv.h         |    3 +++
 drivers/gpu/drm/i915/intel_ringbuffer.c |   16 +++++++++++++---
 3 files changed, 25 insertions(+), 7 deletions(-)

diff --git a/drivers/gpu/drm/i915/i915_drv.c b/drivers/gpu/drm/i915/i915_drv.c
index 238a521..9fe9ebe 100644
--- a/drivers/gpu/drm/i915/i915_drv.c
+++ b/drivers/gpu/drm/i915/i915_drv.c
@@ -233,6 +233,7 @@ static const struct intel_device_info intel_sandybridge_d_info = {
 	.has_blt_ring = 1,
 	.has_llc = 1,
 	.has_pch_split = 1,
+	.has_force_wake = 1,
 };
 
 static const struct intel_device_info intel_sandybridge_m_info = {
@@ -243,6 +244,7 @@ static const struct intel_device_info intel_sandybridge_m_info = {
 	.has_blt_ring = 1,
 	.has_llc = 1,
 	.has_pch_split = 1,
+	.has_force_wake = 1,
 };
 
 static const struct intel_device_info intel_ivybridge_d_info = {
@@ -252,6 +254,7 @@ static const struct intel_device_info intel_ivybridge_d_info = {
 	.has_blt_ring = 1,
 	.has_llc = 1,
 	.has_pch_split = 1,
+	.has_force_wake = 1,
 };
 
 static const struct intel_device_info intel_ivybridge_m_info = {
@@ -262,6 +265,7 @@ static const struct intel_device_info intel_ivybridge_m_info = {
 	.has_blt_ring = 1,
 	.has_llc = 1,
 	.has_pch_split = 1,
+	.has_force_wake = 1,
 };
 
 static const struct intel_device_info intel_valleyview_m_info = {
@@ -289,6 +293,7 @@ static const struct intel_device_info intel_haswell_d_info = {
 	.has_blt_ring = 1,
 	.has_llc = 1,
 	.has_pch_split = 1,
+	.has_force_wake = 1,
 };
 
 static const struct intel_device_info intel_haswell_m_info = {
@@ -298,6 +303,7 @@ static const struct intel_device_info intel_haswell_m_info = {
 	.has_blt_ring = 1,
 	.has_llc = 1,
 	.has_pch_split = 1,
+	.has_force_wake = 1,
 };
 
 static const struct pci_device_id pciidlist[] = {		/* aka */
@@ -1139,10 +1145,9 @@ MODULE_LICENSE("GPL and additional rights");
 
 /* We give fast paths for the really cool registers */
 #define NEEDS_FORCE_WAKE(dev_priv, reg) \
-       (((dev_priv)->info->gen >= 6) && \
-        ((reg) < 0x40000) &&            \
-        ((reg) != FORCEWAKE)) && \
-       (!IS_VALLEYVIEW((dev_priv)->dev))
+	((HAS_FORCE_WAKE((dev_priv)->dev)) && \
+	 ((reg) < 0x40000) &&            \
+	 ((reg) != FORCEWAKE))
 
 #define __i915_read(x, y) \
 u##x i915_read##x(struct drm_i915_private *dev_priv, u32 reg) { \
diff --git a/drivers/gpu/drm/i915/i915_drv.h b/drivers/gpu/drm/i915/i915_drv.h
index ccabadd..7cc36db 100644
--- a/drivers/gpu/drm/i915/i915_drv.h
+++ b/drivers/gpu/drm/i915/i915_drv.h
@@ -285,6 +285,7 @@ struct intel_device_info {
 	u8 is_ivybridge:1;
 	u8 is_valleyview:1;
 	u8 has_pch_split:1;
+	u8 has_force_wake:1;
 	u8 is_haswell:1;
 	u8 has_fbc:1;
 	u8 has_pipe_cxsr:1;
@@ -1105,6 +1106,8 @@ struct drm_i915_file_private {
 #define HAS_PCH_CPT(dev) (INTEL_PCH_TYPE(dev) == PCH_CPT)
 #define HAS_PCH_IBX(dev) (INTEL_PCH_TYPE(dev) == PCH_IBX)
 
+#define HAS_FORCE_WAKE(dev) (INTEL_INFO(dev)->has_force_wake)
+
 #include "i915_trace.h"
 
 /**
diff --git a/drivers/gpu/drm/i915/intel_ringbuffer.c b/drivers/gpu/drm/i915/intel_ringbuffer.c
index 89a5e7f..0b172ee 100644
--- a/drivers/gpu/drm/i915/intel_ringbuffer.c
+++ b/drivers/gpu/drm/i915/intel_ringbuffer.c
@@ -266,10 +266,15 @@ u32 intel_ring_get_active_head(struct intel_ring_buffer *ring)
 
 static int init_ring_common(struct intel_ring_buffer *ring)
 {
-	drm_i915_private_t *dev_priv = ring->dev->dev_private;
+	struct drm_device *dev = ring->dev;
+	drm_i915_private_t *dev_priv = dev->dev_private;
 	struct drm_i915_gem_object *obj = ring->obj;
+	int ret = 0;
 	u32 head;
 
+	if (HAS_FORCE_WAKE(dev))
+		gen6_gt_force_wake_get(dev_priv);
+
 	/* Stop the ring if it's running. */
 	I915_WRITE_CTL(ring, 0);
 	I915_WRITE_HEAD(ring, 0);
@@ -317,7 +322,8 @@ static int init_ring_common(struct intel_ring_buffer *ring)
 				I915_READ_HEAD(ring),
 				I915_READ_TAIL(ring),
 				I915_READ_START(ring));
-		return -EIO;
+		ret = -EIO;
+		goto out;
 	}
 
 	if (!drm_core_check_feature(ring->dev, DRIVER_MODESET))
@@ -328,7 +334,11 @@ static int init_ring_common(struct intel_ring_buffer *ring)
 		ring->space = ring_space(ring);
 	}
 
-	return 0;
+out:
+	if (HAS_FORCE_WAKE(dev))
+		gen6_gt_force_wake_put(dev_priv);
+
+	return ret;
 }
 
 static int
-- 
1.7.10

^ permalink raw reply related	[flat|nested] 8+ messages in thread

* Re: [PATCH] drm/i915: hold forcewake around ring hw init
  2012-06-04  9:16   ` Daniel Vetter
@ 2012-06-04  9:21     ` Chris Wilson
  0 siblings, 0 replies; 8+ messages in thread
From: Chris Wilson @ 2012-06-04  9:21 UTC (permalink / raw)
  To: Daniel Vetter, Jani Nikula
  Cc: Daniel Vetter, Intel Graphics Development, stable

On Mon, 4 Jun 2012 11:16:04 +0200, Daniel Vetter <daniel@ffwll.ch> wrote:
> On Mon, Jun 04, 2012 at 12:04:41PM +0300, Jani Nikula wrote:
> > 
> > Hi Daniel, please find a couple of comments inline.
> 
> Oops, a clear case of -ENOTENOUGHCOFFEE. Thanks for catching these, I'll
> follow up with a v2 shortly.

Fwiw, the w/a looks harmless and is indeed advisable in cases where we
do a lot of writes (which does not really seem to apply here!)
Acked-by: Chris Wilson <chris@chris-wilson.co.uk>
-Chris

-- 
Chris Wilson, Intel Open Source Technology Centre

^ permalink raw reply	[flat|nested] 8+ messages in thread

* Re: [PATCH] drm/i915: hold forcewake around ring hw init
  2012-06-04  9:18   ` Daniel Vetter
@ 2012-06-04  9:39     ` Daniel Vetter
  2012-06-04 12:47     ` Eugeni Dodonov
  1 sibling, 0 replies; 8+ messages in thread
From: Daniel Vetter @ 2012-06-04  9:39 UTC (permalink / raw)
  To: Intel Graphics Development; +Cc: Daniel Vetter, stable

On Mon, Jun 04, 2012 at 11:18:15AM +0200, Daniel Vetter wrote:
> Empirical evidence suggests that we need to: On at least one ivb
> machine when running the hangman i-g-t test, the rings don't properly
> initialize properly - the RING_START registers seems to be stuck at
> all zeros.
> 
> Holding forcewake around this register init sequences makes chip reset
> reliable again. Note that this is not the first such issue:
> 
> commit f01db988ef6f6c70a6cc36ee71e4a98a68901229
> Author: Sean Paul <seanpaul@chromium.org>
> Date:   Fri Mar 16 12:43:22 2012 -0400
> 
>     drm/i915: Add wait_for in init_ring_common
> 
> added delay loops to make RING_START and RING_CTL initialization
> reliable on the blt ring at boot-up. So I guess it won't hurt if we do
> this unconditionally for all force_wake needing gpus.
> 
> To avoid copy&pasting of the HAS_FORCE_WAKE check I've added a new
> intel_info bit for that.
> 
> v2: Fixup missing commas in static struct and properly handling the
> error case in init_ring_common, both noticed by Jani Nikula.
> 
> Cc: stable@vger.kernel.org
> Reported-by: Yang Guang <guang.a.yang@intel.com>

Now also tested-by, Yang confirmed that the new patch still works.
-Daniel

> Bugzilla: https://bugs.freedesktop.org/show_bug.cgi?id=50522
> Signed-Off-by: Daniel Vetter <daniel.vetter@ffwll.ch>
> ---
>  drivers/gpu/drm/i915/i915_drv.c         |   13 +++++++++----
>  drivers/gpu/drm/i915/i915_drv.h         |    3 +++
>  drivers/gpu/drm/i915/intel_ringbuffer.c |   16 +++++++++++++---
>  3 files changed, 25 insertions(+), 7 deletions(-)
> 
> diff --git a/drivers/gpu/drm/i915/i915_drv.c b/drivers/gpu/drm/i915/i915_drv.c
> index 238a521..9fe9ebe 100644
> --- a/drivers/gpu/drm/i915/i915_drv.c
> +++ b/drivers/gpu/drm/i915/i915_drv.c
> @@ -233,6 +233,7 @@ static const struct intel_device_info intel_sandybridge_d_info = {
>  	.has_blt_ring = 1,
>  	.has_llc = 1,
>  	.has_pch_split = 1,
> +	.has_force_wake = 1,
>  };
>  
>  static const struct intel_device_info intel_sandybridge_m_info = {
> @@ -243,6 +244,7 @@ static const struct intel_device_info intel_sandybridge_m_info = {
>  	.has_blt_ring = 1,
>  	.has_llc = 1,
>  	.has_pch_split = 1,
> +	.has_force_wake = 1,
>  };
>  
>  static const struct intel_device_info intel_ivybridge_d_info = {
> @@ -252,6 +254,7 @@ static const struct intel_device_info intel_ivybridge_d_info = {
>  	.has_blt_ring = 1,
>  	.has_llc = 1,
>  	.has_pch_split = 1,
> +	.has_force_wake = 1,
>  };
>  
>  static const struct intel_device_info intel_ivybridge_m_info = {
> @@ -262,6 +265,7 @@ static const struct intel_device_info intel_ivybridge_m_info = {
>  	.has_blt_ring = 1,
>  	.has_llc = 1,
>  	.has_pch_split = 1,
> +	.has_force_wake = 1,
>  };
>  
>  static const struct intel_device_info intel_valleyview_m_info = {
> @@ -289,6 +293,7 @@ static const struct intel_device_info intel_haswell_d_info = {
>  	.has_blt_ring = 1,
>  	.has_llc = 1,
>  	.has_pch_split = 1,
> +	.has_force_wake = 1,
>  };
>  
>  static const struct intel_device_info intel_haswell_m_info = {
> @@ -298,6 +303,7 @@ static const struct intel_device_info intel_haswell_m_info = {
>  	.has_blt_ring = 1,
>  	.has_llc = 1,
>  	.has_pch_split = 1,
> +	.has_force_wake = 1,
>  };
>  
>  static const struct pci_device_id pciidlist[] = {		/* aka */
> @@ -1139,10 +1145,9 @@ MODULE_LICENSE("GPL and additional rights");
>  
>  /* We give fast paths for the really cool registers */
>  #define NEEDS_FORCE_WAKE(dev_priv, reg) \
> -       (((dev_priv)->info->gen >= 6) && \
> -        ((reg) < 0x40000) &&            \
> -        ((reg) != FORCEWAKE)) && \
> -       (!IS_VALLEYVIEW((dev_priv)->dev))
> +	((HAS_FORCE_WAKE((dev_priv)->dev)) && \
> +	 ((reg) < 0x40000) &&            \
> +	 ((reg) != FORCEWAKE))
>  
>  #define __i915_read(x, y) \
>  u##x i915_read##x(struct drm_i915_private *dev_priv, u32 reg) { \
> diff --git a/drivers/gpu/drm/i915/i915_drv.h b/drivers/gpu/drm/i915/i915_drv.h
> index ccabadd..7cc36db 100644
> --- a/drivers/gpu/drm/i915/i915_drv.h
> +++ b/drivers/gpu/drm/i915/i915_drv.h
> @@ -285,6 +285,7 @@ struct intel_device_info {
>  	u8 is_ivybridge:1;
>  	u8 is_valleyview:1;
>  	u8 has_pch_split:1;
> +	u8 has_force_wake:1;
>  	u8 is_haswell:1;
>  	u8 has_fbc:1;
>  	u8 has_pipe_cxsr:1;
> @@ -1105,6 +1106,8 @@ struct drm_i915_file_private {
>  #define HAS_PCH_CPT(dev) (INTEL_PCH_TYPE(dev) == PCH_CPT)
>  #define HAS_PCH_IBX(dev) (INTEL_PCH_TYPE(dev) == PCH_IBX)
>  
> +#define HAS_FORCE_WAKE(dev) (INTEL_INFO(dev)->has_force_wake)
> +
>  #include "i915_trace.h"
>  
>  /**
> diff --git a/drivers/gpu/drm/i915/intel_ringbuffer.c b/drivers/gpu/drm/i915/intel_ringbuffer.c
> index 89a5e7f..0b172ee 100644
> --- a/drivers/gpu/drm/i915/intel_ringbuffer.c
> +++ b/drivers/gpu/drm/i915/intel_ringbuffer.c
> @@ -266,10 +266,15 @@ u32 intel_ring_get_active_head(struct intel_ring_buffer *ring)
>  
>  static int init_ring_common(struct intel_ring_buffer *ring)
>  {
> -	drm_i915_private_t *dev_priv = ring->dev->dev_private;
> +	struct drm_device *dev = ring->dev;
> +	drm_i915_private_t *dev_priv = dev->dev_private;
>  	struct drm_i915_gem_object *obj = ring->obj;
> +	int ret = 0;
>  	u32 head;
>  
> +	if (HAS_FORCE_WAKE(dev))
> +		gen6_gt_force_wake_get(dev_priv);
> +
>  	/* Stop the ring if it's running. */
>  	I915_WRITE_CTL(ring, 0);
>  	I915_WRITE_HEAD(ring, 0);
> @@ -317,7 +322,8 @@ static int init_ring_common(struct intel_ring_buffer *ring)
>  				I915_READ_HEAD(ring),
>  				I915_READ_TAIL(ring),
>  				I915_READ_START(ring));
> -		return -EIO;
> +		ret = -EIO;
> +		goto out;
>  	}
>  
>  	if (!drm_core_check_feature(ring->dev, DRIVER_MODESET))
> @@ -328,7 +334,11 @@ static int init_ring_common(struct intel_ring_buffer *ring)
>  		ring->space = ring_space(ring);
>  	}
>  
> -	return 0;
> +out:
> +	if (HAS_FORCE_WAKE(dev))
> +		gen6_gt_force_wake_put(dev_priv);
> +
> +	return ret;
>  }
>  
>  static int
> -- 
> 1.7.10
> 

-- 
Daniel Vetter
Mail: daniel@ffwll.ch
Mobile: +41 (0)79 365 57 48

^ permalink raw reply	[flat|nested] 8+ messages in thread

* Re: [PATCH] drm/i915: hold forcewake around ring hw init
  2012-06-04  9:18   ` Daniel Vetter
  2012-06-04  9:39     ` Daniel Vetter
@ 2012-06-04 12:47     ` Eugeni Dodonov
  2012-06-04 18:26       ` Daniel Vetter
  1 sibling, 1 reply; 8+ messages in thread
From: Eugeni Dodonov @ 2012-06-04 12:47 UTC (permalink / raw)
  To: Daniel Vetter; +Cc: Intel Graphics Development, stable

On 06/04/2012 06:18 AM, Daniel Vetter wrote:
> Empirical evidence suggests that we need to: On at least one ivb
> machine when running the hangman i-g-t test, the rings don't properly
> initialize properly - the RING_START registers seems to be stuck at
> all zeros.
>
> Holding forcewake around this register init sequences makes chip reset
> reliable again. Note that this is not the first such issue:
>
> commit f01db988ef6f6c70a6cc36ee71e4a98a68901229
> Author: Sean Paul<seanpaul@chromium.org>
> Date:   Fri Mar 16 12:43:22 2012 -0400
>
>      drm/i915: Add wait_for in init_ring_common
>
> added delay loops to make RING_START and RING_CTL initialization
> reliable on the blt ring at boot-up. So I guess it won't hurt if we do
> this unconditionally for all force_wake needing gpus.
>
> To avoid copy&pasting of the HAS_FORCE_WAKE check I've added a new
> intel_info bit for that.
>
> v2: Fixup missing commas in static struct and properly handling the
> error case in init_ring_common, both noticed by Jani Nikula.
>
> Cc: stable@vger.kernel.org
> Reported-by: Yang Guang<guang.a.yang@intel.com>
> Bugzilla: https://bugs.freedesktop.org/show_bug.cgi?id=50522
> Signed-Off-by: Daniel Vetter<daniel.vetter@ffwll.ch>

The new .has_forcewake looks nice! Just one very tiny bikeshed below :).

Reviewed-by: Eugeni Dodonov <eugeni.dodonov@intel.com>

> @@ -285,6 +285,7 @@ struct intel_device_info {
>   	u8 is_ivybridge:1;
>   	u8 is_valleyview:1;
>   	u8 has_pch_split:1;
> +	u8 has_force_wake:1;
>   	u8 is_haswell:1;
>   	u8 has_fbc:1;
>   	u8 has_pipe_cxsr:1;

While you are on it, maybe it would make sense to move is_haswell up, so 
all the 'is_*' and 'has_*' flags would stay together?

It is partly may fault though, due to the has_pch_split which ended up 
in wrong place, but as you are touching those fields anyway, perhaps we 
could rectify it for the future? :)

Eugeni

^ permalink raw reply	[flat|nested] 8+ messages in thread

* Re: [PATCH] drm/i915: hold forcewake around ring hw init
  2012-06-04 12:47     ` Eugeni Dodonov
@ 2012-06-04 18:26       ` Daniel Vetter
  0 siblings, 0 replies; 8+ messages in thread
From: Daniel Vetter @ 2012-06-04 18:26 UTC (permalink / raw)
  To: eugeni.dodonov; +Cc: Daniel Vetter, Intel Graphics Development, stable

On Mon, Jun 04, 2012 at 09:47:54AM -0300, Eugeni Dodonov wrote:
> On 06/04/2012 06:18 AM, Daniel Vetter wrote:
> >Empirical evidence suggests that we need to: On at least one ivb
> >machine when running the hangman i-g-t test, the rings don't properly
> >initialize properly - the RING_START registers seems to be stuck at
> >all zeros.
> >
> >Holding forcewake around this register init sequences makes chip reset
> >reliable again. Note that this is not the first such issue:
> >
> >commit f01db988ef6f6c70a6cc36ee71e4a98a68901229
> >Author: Sean Paul<seanpaul@chromium.org>
> >Date:   Fri Mar 16 12:43:22 2012 -0400
> >
> >     drm/i915: Add wait_for in init_ring_common
> >
> >added delay loops to make RING_START and RING_CTL initialization
> >reliable on the blt ring at boot-up. So I guess it won't hurt if we do
> >this unconditionally for all force_wake needing gpus.
> >
> >To avoid copy&pasting of the HAS_FORCE_WAKE check I've added a new
> >intel_info bit for that.
> >
> >v2: Fixup missing commas in static struct and properly handling the
> >error case in init_ring_common, both noticed by Jani Nikula.
> >
> >Cc: stable@vger.kernel.org
> >Reported-by: Yang Guang<guang.a.yang@intel.com>
> >Bugzilla: https://bugs.freedesktop.org/show_bug.cgi?id=50522
> >Signed-Off-by: Daniel Vetter<daniel.vetter@ffwll.ch>
> 
> The new .has_forcewake looks nice! Just one very tiny bikeshed below :).
> 
> Reviewed-by: Eugeni Dodonov <eugeni.dodonov@intel.com>
Picked up for -fixes, thanks for the review.
-Daniel
-- 
Daniel Vetter
Mail: daniel@ffwll.ch
Mobile: +41 (0)79 365 57 48

^ permalink raw reply	[flat|nested] 8+ messages in thread

end of thread, other threads:[~2012-06-04 18:24 UTC | newest]

Thread overview: 8+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2012-06-04  8:40 [PATCH] drm/i915: hold forcewake around ring hw init Daniel Vetter
2012-06-04  9:04 ` Jani Nikula
2012-06-04  9:16   ` Daniel Vetter
2012-06-04  9:21     ` Chris Wilson
2012-06-04  9:18   ` Daniel Vetter
2012-06-04  9:39     ` Daniel Vetter
2012-06-04 12:47     ` Eugeni Dodonov
2012-06-04 18:26       ` Daniel Vetter

This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.