intel-gfx.lists.freedesktop.org archive mirror
 help / color / mirror / Atom feed
* [PATCH 1/3 v3] drm/i915: Extract reading INSTDONE
@ 2012-08-22 18:32 Ben Widawsky
  2012-08-22 18:32 ` [PATCH 2/3] [REPOST] drm/i915: Add new INSTDONE registers Ben Widawsky
                   ` (2 more replies)
  0 siblings, 3 replies; 7+ messages in thread
From: Ben Widawsky @ 2012-08-22 18:32 UTC (permalink / raw)
  To: intel-gfx; +Cc: Jani Nikula, Ben Widawsky

INSTDONE is used in many places, and it varies from generation to
generation. This provides a good reason for us to extract the logic to
read the relevant information.

The patch has no functional change. It's prep for some new stuff.

v2: move the memset inside of i915_get_extra_instdone (Jani)
v3: bug in the previous memset caught by (Jani)

Cc: Jani Nikula <jani.nikula@intel.com>
Signed-off-by: Ben Widawsky <ben@bwidawsk.net>
---
 drivers/gpu/drm/i915/i915_irq.c | 50 +++++++++++++++++++++++++----------------
 drivers/gpu/drm/i915/i915_reg.h |  1 +
 2 files changed, 32 insertions(+), 19 deletions(-)

diff --git a/drivers/gpu/drm/i915/i915_irq.c b/drivers/gpu/drm/i915/i915_irq.c
index 3633029..de68362 100644
--- a/drivers/gpu/drm/i915/i915_irq.c
+++ b/drivers/gpu/drm/i915/i915_irq.c
@@ -1070,6 +1070,23 @@ i915_error_first_batchbuffer(struct drm_i915_private *dev_priv,
 	return NULL;
 }
 
+/* NB: please notice the memset */
+static void i915_get_extra_instdone(struct drm_device *dev,
+				    uint32_t instdone[I915_NUM_INSTDONE_REG])
+{
+	struct drm_i915_private *dev_priv = dev->dev_private;
+	memset(instdone, 0, sizeof(instdone) * I915_NUM_INSTDONE_REG);
+
+	if (INTEL_INFO(dev)->gen < 4) {
+		instdone[0] = I915_READ(INSTDONE);
+		instdone[1] = 0;
+	} else {
+		instdone[0] = I915_READ(INSTDONE_I965);
+		instdone[1] = I915_READ(INSTDONE1);
+	}
+}
+
+
 static void i915_record_ring_state(struct drm_device *dev,
 				   struct drm_i915_error_state *error,
 				   struct intel_ring_buffer *ring)
@@ -1288,6 +1305,7 @@ void i915_destroy_error_state(struct drm_device *dev)
 static void i915_report_and_clear_eir(struct drm_device *dev)
 {
 	struct drm_i915_private *dev_priv = dev->dev_private;
+	uint32_t instdone[I915_NUM_INSTDONE_REG];
 	u32 eir = I915_READ(EIR);
 	int pipe;
 
@@ -1296,16 +1314,17 @@ static void i915_report_and_clear_eir(struct drm_device *dev)
 
 	pr_err("render error detected, EIR: 0x%08x\n", eir);
 
+	i915_get_extra_instdone(dev, instdone);
+
 	if (IS_G4X(dev)) {
 		if (eir & (GM45_ERROR_MEM_PRIV | GM45_ERROR_CP_PRIV)) {
 			u32 ipeir = I915_READ(IPEIR_I965);
 
 			pr_err("  IPEIR: 0x%08x\n", I915_READ(IPEIR_I965));
 			pr_err("  IPEHR: 0x%08x\n", I915_READ(IPEHR_I965));
-			pr_err("  INSTDONE: 0x%08x\n",
-			       I915_READ(INSTDONE_I965));
+			pr_err("  INSTDONE: 0x%08x\n", instdone[0]);
 			pr_err("  INSTPS: 0x%08x\n", I915_READ(INSTPS));
-			pr_err("  INSTDONE1: 0x%08x\n", I915_READ(INSTDONE1));
+			pr_err("  INSTDONE1: 0x%08x\n", instdone[1]);
 			pr_err("  ACTHD: 0x%08x\n", I915_READ(ACTHD_I965));
 			I915_WRITE(IPEIR_I965, ipeir);
 			POSTING_READ(IPEIR_I965);
@@ -1344,7 +1363,7 @@ static void i915_report_and_clear_eir(struct drm_device *dev)
 
 			pr_err("  IPEIR: 0x%08x\n", I915_READ(IPEIR));
 			pr_err("  IPEHR: 0x%08x\n", I915_READ(IPEHR));
-			pr_err("  INSTDONE: 0x%08x\n", I915_READ(INSTDONE));
+			pr_err("  INSTDONE: 0x%08x\n", instdone[0]);
 			pr_err("  ACTHD: 0x%08x\n", I915_READ(ACTHD));
 			I915_WRITE(IPEIR, ipeir);
 			POSTING_READ(IPEIR);
@@ -1353,10 +1372,9 @@ static void i915_report_and_clear_eir(struct drm_device *dev)
 
 			pr_err("  IPEIR: 0x%08x\n", I915_READ(IPEIR_I965));
 			pr_err("  IPEHR: 0x%08x\n", I915_READ(IPEHR_I965));
-			pr_err("  INSTDONE: 0x%08x\n",
-			       I915_READ(INSTDONE_I965));
+			pr_err("  INSTDONE: 0x%08x\n", instdone[0]);
 			pr_err("  INSTPS: 0x%08x\n", I915_READ(INSTPS));
-			pr_err("  INSTDONE1: 0x%08x\n", I915_READ(INSTDONE1));
+			pr_err("  INSTDONE1: 0x%08x\n", instdone[1]);
 			pr_err("  ACTHD: 0x%08x\n", I915_READ(ACTHD_I965));
 			I915_WRITE(IPEIR_I965, ipeir);
 			POSTING_READ(IPEIR_I965);
@@ -1671,7 +1689,7 @@ void i915_hangcheck_elapsed(unsigned long data)
 {
 	struct drm_device *dev = (struct drm_device *)data;
 	drm_i915_private_t *dev_priv = dev->dev_private;
-	uint32_t acthd[I915_NUM_RINGS], instdone, instdone1;
+	uint32_t acthd[I915_NUM_RINGS], instdone[I915_NUM_INSTDONE_REG];
 	struct intel_ring_buffer *ring;
 	bool err = false, idle;
 	int i;
@@ -1699,25 +1717,19 @@ void i915_hangcheck_elapsed(unsigned long data)
 		return;
 	}
 
-	if (INTEL_INFO(dev)->gen < 4) {
-		instdone = I915_READ(INSTDONE);
-		instdone1 = 0;
-	} else {
-		instdone = I915_READ(INSTDONE_I965);
-		instdone1 = I915_READ(INSTDONE1);
-	}
+	i915_get_extra_instdone(dev, instdone);
 
 	if (memcmp(dev_priv->last_acthd, acthd, sizeof(acthd)) == 0 &&
-	    dev_priv->last_instdone == instdone &&
-	    dev_priv->last_instdone1 == instdone1) {
+	    dev_priv->last_instdone == instdone[0] &&
+	    dev_priv->last_instdone1 == instdone[1]) {
 		if (i915_hangcheck_hung(dev))
 			return;
 	} else {
 		dev_priv->hangcheck_count = 0;
 
 		memcpy(dev_priv->last_acthd, acthd, sizeof(acthd));
-		dev_priv->last_instdone = instdone;
-		dev_priv->last_instdone1 = instdone1;
+		dev_priv->last_instdone = instdone[0];
+		dev_priv->last_instdone1 = instdone[1];
 	}
 
 repeat:
diff --git a/drivers/gpu/drm/i915/i915_reg.h b/drivers/gpu/drm/i915/i915_reg.h
index f27e998..1f97b3f 100644
--- a/drivers/gpu/drm/i915/i915_reg.h
+++ b/drivers/gpu/drm/i915/i915_reg.h
@@ -478,6 +478,7 @@
 #define IPEIR_I965	0x02064
 #define IPEHR_I965	0x02068
 #define INSTDONE_I965	0x0206c
+#define I915_NUM_INSTDONE_REG	2
 #define RING_IPEIR(base)	((base)+0x64)
 #define RING_IPEHR(base)	((base)+0x68)
 #define RING_INSTDONE(base)	((base)+0x6c)
-- 
1.7.11.5

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

* [PATCH 2/3] [REPOST] drm/i915: Add new INSTDONE registers
  2012-08-22 18:32 [PATCH 1/3 v3] drm/i915: Extract reading INSTDONE Ben Widawsky
@ 2012-08-22 18:32 ` Ben Widawsky
  2012-08-22 18:32 ` [PATCH 3/3 v3] drm/i915: Use new INSTDONE registers (Gen7+) Ben Widawsky
  2012-08-23 11:56 ` [PATCH 1/3 v3] drm/i915: Extract reading INSTDONE Jani Nikula
  2 siblings, 0 replies; 7+ messages in thread
From: Ben Widawsky @ 2012-08-22 18:32 UTC (permalink / raw)
  To: intel-gfx; +Cc: Ben Widawsky

Signed-off-by: Ben Widawsky <ben@bwidawsk.net>
---
 drivers/gpu/drm/i915/i915_reg.h | 6 +++++-
 1 file changed, 5 insertions(+), 1 deletion(-)

diff --git a/drivers/gpu/drm/i915/i915_reg.h b/drivers/gpu/drm/i915/i915_reg.h
index 1f97b3f..d0b60f2 100644
--- a/drivers/gpu/drm/i915/i915_reg.h
+++ b/drivers/gpu/drm/i915/i915_reg.h
@@ -478,7 +478,11 @@
 #define IPEIR_I965	0x02064
 #define IPEHR_I965	0x02068
 #define INSTDONE_I965	0x0206c
-#define I915_NUM_INSTDONE_REG	2
+#define GEN7_INSTDONE_1		0x0206c
+#define GEN7_SC_INSTDONE	0x07100
+#define GEN7_SAMPLER_INSTDONE	0x0e160
+#define GEN7_ROW_INSTDONE	0x0e164
+#define I915_NUM_INSTDONE_REG	4
 #define RING_IPEIR(base)	((base)+0x64)
 #define RING_IPEHR(base)	((base)+0x68)
 #define RING_INSTDONE(base)	((base)+0x6c)
-- 
1.7.11.5

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

* [PATCH 3/3 v3] drm/i915: Use new INSTDONE registers (Gen7+)
  2012-08-22 18:32 [PATCH 1/3 v3] drm/i915: Extract reading INSTDONE Ben Widawsky
  2012-08-22 18:32 ` [PATCH 2/3] [REPOST] drm/i915: Add new INSTDONE registers Ben Widawsky
@ 2012-08-22 18:32 ` Ben Widawsky
  2012-08-23 11:56 ` [PATCH 1/3 v3] drm/i915: Extract reading INSTDONE Jani Nikula
  2 siblings, 0 replies; 7+ messages in thread
From: Ben Widawsky @ 2012-08-22 18:32 UTC (permalink / raw)
  To: intel-gfx; +Cc: Jani Nikula, Ben Widawsky

Using the extracted INSTDONE reading, and our new register definitions,
update our hangcheck detection and error collection to use it. This
primarily means changing == to memcmp, and changing = to memcpy.
Hopefully this will give more info on error dump, and provide more
accurate hangcheck detection (both are actually TBD).

Also, remove the reading of instdone1 from the ring error collection
function, and just crap everything in capture_error_state (that could be
split into a separate patch if it wasn't so trivial).

v2: Now assuming i915_get_extra_instdone does the memset we can clean up the
code a bit (Jani)

v3: use ARRAY_SIZE as requested earlier by Jani (didn't change sizeof)
Updated commit msg

Cc: Jani Nikula <jani.nikula@intel.com>
Signed-off-by: Ben Widawsky <ben@bwidawsk.net>
---
 drivers/gpu/drm/i915/i915_debugfs.c |  8 ++++---
 drivers/gpu/drm/i915/i915_drv.h     |  5 ++---
 drivers/gpu/drm/i915/i915_irq.c     | 43 ++++++++++++++++++++++---------------
 3 files changed, 33 insertions(+), 23 deletions(-)

diff --git a/drivers/gpu/drm/i915/i915_debugfs.c b/drivers/gpu/drm/i915/i915_debugfs.c
index d300393..3d886af 100644
--- a/drivers/gpu/drm/i915/i915_debugfs.c
+++ b/drivers/gpu/drm/i915/i915_debugfs.c
@@ -662,10 +662,9 @@ static void i915_ring_error_state(struct seq_file *m,
 	seq_printf(m, "  IPEIR: 0x%08x\n", error->ipeir[ring]);
 	seq_printf(m, "  IPEHR: 0x%08x\n", error->ipehr[ring]);
 	seq_printf(m, "  INSTDONE: 0x%08x\n", error->instdone[ring]);
-	if (ring == RCS && INTEL_INFO(dev)->gen >= 4) {
-		seq_printf(m, "  INSTDONE1: 0x%08x\n", error->instdone1);
+	if (ring == RCS && INTEL_INFO(dev)->gen >= 4)
 		seq_printf(m, "  BBADDR: 0x%08llx\n", error->bbaddr);
-	}
+
 	if (INTEL_INFO(dev)->gen >= 4)
 		seq_printf(m, "  INSTPS: 0x%08x\n", error->instps[ring]);
 	seq_printf(m, "  INSTPM: 0x%08x\n", error->instpm[ring]);
@@ -714,6 +713,9 @@ static int i915_error_state(struct seq_file *m, void *unused)
 	for (i = 0; i < dev_priv->num_fence_regs; i++)
 		seq_printf(m, "  fence[%d] = %08llx\n", i, error->fence[i]);
 
+	for (i = 0; i < ARRAY_SIZE(error->extra_instdone); i++)
+		seq_printf(m, "  INSTDONE_%d: 0x%08x\n", i, error->extra_instdone[i]);
+
 	if (INTEL_INFO(dev)->gen >= 6) {
 		seq_printf(m, "ERROR: 0x%08x\n", error->error);
 		seq_printf(m, "DONE_REG: 0x%08x\n", error->done_reg);
diff --git a/drivers/gpu/drm/i915/i915_drv.h b/drivers/gpu/drm/i915/i915_drv.h
index cbd3cd0..f464c71 100644
--- a/drivers/gpu/drm/i915/i915_drv.h
+++ b/drivers/gpu/drm/i915/i915_drv.h
@@ -199,7 +199,7 @@ struct drm_i915_error_state {
 	u32 err_int; /* gen7 */
 	u32 instpm[I915_NUM_RINGS];
 	u32 instps[I915_NUM_RINGS];
-	u32 instdone1;
+	u32 extra_instdone[I915_NUM_INSTDONE_REG];
 	u32 seqno[I915_NUM_RINGS];
 	u64 bbaddr;
 	u32 fault_reg[I915_NUM_RINGS];
@@ -454,8 +454,7 @@ typedef struct drm_i915_private {
 	struct timer_list hangcheck_timer;
 	int hangcheck_count;
 	uint32_t last_acthd[I915_NUM_RINGS];
-	uint32_t last_instdone;
-	uint32_t last_instdone1;
+	uint32_t prev_instdone[I915_NUM_INSTDONE_REG];
 
 	unsigned int stop_rings;
 
diff --git a/drivers/gpu/drm/i915/i915_irq.c b/drivers/gpu/drm/i915/i915_irq.c
index de68362..b4f01dc 100644
--- a/drivers/gpu/drm/i915/i915_irq.c
+++ b/drivers/gpu/drm/i915/i915_irq.c
@@ -1077,12 +1077,25 @@ static void i915_get_extra_instdone(struct drm_device *dev,
 	struct drm_i915_private *dev_priv = dev->dev_private;
 	memset(instdone, 0, sizeof(instdone) * I915_NUM_INSTDONE_REG);
 
-	if (INTEL_INFO(dev)->gen < 4) {
+	switch(INTEL_INFO(dev)->gen) {
+	case 2:
+	case 3:
 		instdone[0] = I915_READ(INSTDONE);
-		instdone[1] = 0;
-	} else {
+		break;
+	case 4:
+	case 5:
+	case 6:
 		instdone[0] = I915_READ(INSTDONE_I965);
 		instdone[1] = I915_READ(INSTDONE1);
+		break;
+	default:
+		WARN_ONCE(1, "Unsupported platform\n");
+	case 7:
+		instdone[0] = I915_READ(GEN7_INSTDONE_1);
+		instdone[1] = I915_READ(GEN7_SC_INSTDONE);
+		instdone[2] = I915_READ(GEN7_SAMPLER_INSTDONE);
+		instdone[3] = I915_READ(GEN7_ROW_INSTDONE);
+		break;
 	}
 }
 
@@ -1108,10 +1121,8 @@ static void i915_record_ring_state(struct drm_device *dev,
 		error->ipehr[ring->id] = I915_READ(RING_IPEHR(ring->mmio_base));
 		error->instdone[ring->id] = I915_READ(RING_INSTDONE(ring->mmio_base));
 		error->instps[ring->id] = I915_READ(RING_INSTPS(ring->mmio_base));
-		if (ring->id == RCS) {
-			error->instdone1 = I915_READ(INSTDONE1);
+		if (ring->id == RCS)
 			error->bbaddr = I915_READ64(BB_ADDR);
-		}
 	} else {
 		error->faddr[ring->id] = I915_READ(DMA_FADD_I8XX);
 		error->ipeir[ring->id] = I915_READ(IPEIR);
@@ -1230,6 +1241,8 @@ static void i915_capture_error_state(struct drm_device *dev)
 	if (INTEL_INFO(dev)->gen == 7)
 		error->err_int = I915_READ(GEN7_ERR_INT);
 
+	i915_get_extra_instdone(dev, error->extra_instdone);
+
 	i915_gem_record_fences(dev, error);
 	i915_gem_record_rings(dev, error);
 
@@ -1307,7 +1320,7 @@ static void i915_report_and_clear_eir(struct drm_device *dev)
 	struct drm_i915_private *dev_priv = dev->dev_private;
 	uint32_t instdone[I915_NUM_INSTDONE_REG];
 	u32 eir = I915_READ(EIR);
-	int pipe;
+	int pipe, i;
 
 	if (!eir)
 		return;
@@ -1322,9 +1335,9 @@ static void i915_report_and_clear_eir(struct drm_device *dev)
 
 			pr_err("  IPEIR: 0x%08x\n", I915_READ(IPEIR_I965));
 			pr_err("  IPEHR: 0x%08x\n", I915_READ(IPEHR_I965));
-			pr_err("  INSTDONE: 0x%08x\n", instdone[0]);
+			for (i = 0; i < ARRAY_SIZE(instdone); i++)
+				pr_err("  INSTDONE_%d: 0x%08x\n", i, instdone[i]);
 			pr_err("  INSTPS: 0x%08x\n", I915_READ(INSTPS));
-			pr_err("  INSTDONE1: 0x%08x\n", instdone[1]);
 			pr_err("  ACTHD: 0x%08x\n", I915_READ(ACTHD_I965));
 			I915_WRITE(IPEIR_I965, ipeir);
 			POSTING_READ(IPEIR_I965);
@@ -1358,12 +1371,13 @@ static void i915_report_and_clear_eir(struct drm_device *dev)
 	if (eir & I915_ERROR_INSTRUCTION) {
 		pr_err("instruction error\n");
 		pr_err("  INSTPM: 0x%08x\n", I915_READ(INSTPM));
+		for (i = 0; i < ARRAY_SIZE(instdone); i++)
+			pr_err("  INSTDONE_%d: 0x%08x\n", i, instdone[i]);
 		if (INTEL_INFO(dev)->gen < 4) {
 			u32 ipeir = I915_READ(IPEIR);
 
 			pr_err("  IPEIR: 0x%08x\n", I915_READ(IPEIR));
 			pr_err("  IPEHR: 0x%08x\n", I915_READ(IPEHR));
-			pr_err("  INSTDONE: 0x%08x\n", instdone[0]);
 			pr_err("  ACTHD: 0x%08x\n", I915_READ(ACTHD));
 			I915_WRITE(IPEIR, ipeir);
 			POSTING_READ(IPEIR);
@@ -1372,9 +1386,7 @@ static void i915_report_and_clear_eir(struct drm_device *dev)
 
 			pr_err("  IPEIR: 0x%08x\n", I915_READ(IPEIR_I965));
 			pr_err("  IPEHR: 0x%08x\n", I915_READ(IPEHR_I965));
-			pr_err("  INSTDONE: 0x%08x\n", instdone[0]);
 			pr_err("  INSTPS: 0x%08x\n", I915_READ(INSTPS));
-			pr_err("  INSTDONE1: 0x%08x\n", instdone[1]);
 			pr_err("  ACTHD: 0x%08x\n", I915_READ(ACTHD_I965));
 			I915_WRITE(IPEIR_I965, ipeir);
 			POSTING_READ(IPEIR_I965);
@@ -1718,18 +1730,15 @@ void i915_hangcheck_elapsed(unsigned long data)
 	}
 
 	i915_get_extra_instdone(dev, instdone);
-
 	if (memcmp(dev_priv->last_acthd, acthd, sizeof(acthd)) == 0 &&
-	    dev_priv->last_instdone == instdone[0] &&
-	    dev_priv->last_instdone1 == instdone[1]) {
+	    memcmp(dev_priv->prev_instdone, instdone, sizeof(instdone)) == 0) {
 		if (i915_hangcheck_hung(dev))
 			return;
 	} else {
 		dev_priv->hangcheck_count = 0;
 
 		memcpy(dev_priv->last_acthd, acthd, sizeof(acthd));
-		dev_priv->last_instdone = instdone[0];
-		dev_priv->last_instdone1 = instdone[1];
+		memcpy(dev_priv->prev_instdone, instdone, sizeof(instdone));
 	}
 
 repeat:
-- 
1.7.11.5

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

* Re: [PATCH 1/3 v3] drm/i915: Extract reading INSTDONE
  2012-08-22 18:32 [PATCH 1/3 v3] drm/i915: Extract reading INSTDONE Ben Widawsky
  2012-08-22 18:32 ` [PATCH 2/3] [REPOST] drm/i915: Add new INSTDONE registers Ben Widawsky
  2012-08-22 18:32 ` [PATCH 3/3 v3] drm/i915: Use new INSTDONE registers (Gen7+) Ben Widawsky
@ 2012-08-23 11:56 ` Jani Nikula
  2012-08-23 22:18   ` [PATCH 1/3 v4] " Ben Widawsky
  2 siblings, 1 reply; 7+ messages in thread
From: Jani Nikula @ 2012-08-23 11:56 UTC (permalink / raw)
  To: intel-gfx; +Cc: Ben Widawsky

On Wed, 22 Aug 2012, Ben Widawsky <ben@bwidawsk.net> wrote:
> INSTDONE is used in many places, and it varies from generation to
> generation. This provides a good reason for us to extract the logic to
> read the relevant information.
>
> The patch has no functional change. It's prep for some new stuff.
>
> v2: move the memset inside of i915_get_extra_instdone (Jani)
> v3: bug in the previous memset caught by (Jani)
>
> Cc: Jani Nikula <jani.nikula@intel.com>
> Signed-off-by: Ben Widawsky <ben@bwidawsk.net>
> ---
>  drivers/gpu/drm/i915/i915_irq.c | 50 +++++++++++++++++++++++++----------------
>  drivers/gpu/drm/i915/i915_reg.h |  1 +
>  2 files changed, 32 insertions(+), 19 deletions(-)
>
> diff --git a/drivers/gpu/drm/i915/i915_irq.c b/drivers/gpu/drm/i915/i915_irq.c
> index 3633029..de68362 100644
> --- a/drivers/gpu/drm/i915/i915_irq.c
> +++ b/drivers/gpu/drm/i915/i915_irq.c
> @@ -1070,6 +1070,23 @@ i915_error_first_batchbuffer(struct drm_i915_private *dev_priv,
>  	return NULL;
>  }
>  
> +/* NB: please notice the memset */
> +static void i915_get_extra_instdone(struct drm_device *dev,
> +				    uint32_t instdone[I915_NUM_INSTDONE_REG])
> +{
> +	struct drm_i915_private *dev_priv = dev->dev_private;
> +	memset(instdone, 0, sizeof(instdone) * I915_NUM_INSTDONE_REG);

You know what, that's still not right.

Here, sizeof(instdone) == sizeof(uint32_t *). It's an array of uint32_t,
not of (uint32_t *).

Please just make the instdone parameter "uint32_t *instdone" and it'll
be easier for everyone to read.


BR,
Jani.


> +
> +	if (INTEL_INFO(dev)->gen < 4) {
> +		instdone[0] = I915_READ(INSTDONE);
> +		instdone[1] = 0;
> +	} else {
> +		instdone[0] = I915_READ(INSTDONE_I965);
> +		instdone[1] = I915_READ(INSTDONE1);
> +	}
> +}
> +
> +
>  static void i915_record_ring_state(struct drm_device *dev,
>  				   struct drm_i915_error_state *error,
>  				   struct intel_ring_buffer *ring)
> @@ -1288,6 +1305,7 @@ void i915_destroy_error_state(struct drm_device *dev)
>  static void i915_report_and_clear_eir(struct drm_device *dev)
>  {
>  	struct drm_i915_private *dev_priv = dev->dev_private;
> +	uint32_t instdone[I915_NUM_INSTDONE_REG];
>  	u32 eir = I915_READ(EIR);
>  	int pipe;
>  
> @@ -1296,16 +1314,17 @@ static void i915_report_and_clear_eir(struct drm_device *dev)
>  
>  	pr_err("render error detected, EIR: 0x%08x\n", eir);
>  
> +	i915_get_extra_instdone(dev, instdone);
> +
>  	if (IS_G4X(dev)) {
>  		if (eir & (GM45_ERROR_MEM_PRIV | GM45_ERROR_CP_PRIV)) {
>  			u32 ipeir = I915_READ(IPEIR_I965);
>  
>  			pr_err("  IPEIR: 0x%08x\n", I915_READ(IPEIR_I965));
>  			pr_err("  IPEHR: 0x%08x\n", I915_READ(IPEHR_I965));
> -			pr_err("  INSTDONE: 0x%08x\n",
> -			       I915_READ(INSTDONE_I965));
> +			pr_err("  INSTDONE: 0x%08x\n", instdone[0]);
>  			pr_err("  INSTPS: 0x%08x\n", I915_READ(INSTPS));
> -			pr_err("  INSTDONE1: 0x%08x\n", I915_READ(INSTDONE1));
> +			pr_err("  INSTDONE1: 0x%08x\n", instdone[1]);
>  			pr_err("  ACTHD: 0x%08x\n", I915_READ(ACTHD_I965));
>  			I915_WRITE(IPEIR_I965, ipeir);
>  			POSTING_READ(IPEIR_I965);
> @@ -1344,7 +1363,7 @@ static void i915_report_and_clear_eir(struct drm_device *dev)
>  
>  			pr_err("  IPEIR: 0x%08x\n", I915_READ(IPEIR));
>  			pr_err("  IPEHR: 0x%08x\n", I915_READ(IPEHR));
> -			pr_err("  INSTDONE: 0x%08x\n", I915_READ(INSTDONE));
> +			pr_err("  INSTDONE: 0x%08x\n", instdone[0]);
>  			pr_err("  ACTHD: 0x%08x\n", I915_READ(ACTHD));
>  			I915_WRITE(IPEIR, ipeir);
>  			POSTING_READ(IPEIR);
> @@ -1353,10 +1372,9 @@ static void i915_report_and_clear_eir(struct drm_device *dev)
>  
>  			pr_err("  IPEIR: 0x%08x\n", I915_READ(IPEIR_I965));
>  			pr_err("  IPEHR: 0x%08x\n", I915_READ(IPEHR_I965));
> -			pr_err("  INSTDONE: 0x%08x\n",
> -			       I915_READ(INSTDONE_I965));
> +			pr_err("  INSTDONE: 0x%08x\n", instdone[0]);
>  			pr_err("  INSTPS: 0x%08x\n", I915_READ(INSTPS));
> -			pr_err("  INSTDONE1: 0x%08x\n", I915_READ(INSTDONE1));
> +			pr_err("  INSTDONE1: 0x%08x\n", instdone[1]);
>  			pr_err("  ACTHD: 0x%08x\n", I915_READ(ACTHD_I965));
>  			I915_WRITE(IPEIR_I965, ipeir);
>  			POSTING_READ(IPEIR_I965);
> @@ -1671,7 +1689,7 @@ void i915_hangcheck_elapsed(unsigned long data)
>  {
>  	struct drm_device *dev = (struct drm_device *)data;
>  	drm_i915_private_t *dev_priv = dev->dev_private;
> -	uint32_t acthd[I915_NUM_RINGS], instdone, instdone1;
> +	uint32_t acthd[I915_NUM_RINGS], instdone[I915_NUM_INSTDONE_REG];
>  	struct intel_ring_buffer *ring;
>  	bool err = false, idle;
>  	int i;
> @@ -1699,25 +1717,19 @@ void i915_hangcheck_elapsed(unsigned long data)
>  		return;
>  	}
>  
> -	if (INTEL_INFO(dev)->gen < 4) {
> -		instdone = I915_READ(INSTDONE);
> -		instdone1 = 0;
> -	} else {
> -		instdone = I915_READ(INSTDONE_I965);
> -		instdone1 = I915_READ(INSTDONE1);
> -	}
> +	i915_get_extra_instdone(dev, instdone);
>  
>  	if (memcmp(dev_priv->last_acthd, acthd, sizeof(acthd)) == 0 &&
> -	    dev_priv->last_instdone == instdone &&
> -	    dev_priv->last_instdone1 == instdone1) {
> +	    dev_priv->last_instdone == instdone[0] &&
> +	    dev_priv->last_instdone1 == instdone[1]) {
>  		if (i915_hangcheck_hung(dev))
>  			return;
>  	} else {
>  		dev_priv->hangcheck_count = 0;
>  
>  		memcpy(dev_priv->last_acthd, acthd, sizeof(acthd));
> -		dev_priv->last_instdone = instdone;
> -		dev_priv->last_instdone1 = instdone1;
> +		dev_priv->last_instdone = instdone[0];
> +		dev_priv->last_instdone1 = instdone[1];
>  	}
>  
>  repeat:
> diff --git a/drivers/gpu/drm/i915/i915_reg.h b/drivers/gpu/drm/i915/i915_reg.h
> index f27e998..1f97b3f 100644
> --- a/drivers/gpu/drm/i915/i915_reg.h
> +++ b/drivers/gpu/drm/i915/i915_reg.h
> @@ -478,6 +478,7 @@
>  #define IPEIR_I965	0x02064
>  #define IPEHR_I965	0x02068
>  #define INSTDONE_I965	0x0206c
> +#define I915_NUM_INSTDONE_REG	2
>  #define RING_IPEIR(base)	((base)+0x64)
>  #define RING_IPEHR(base)	((base)+0x68)
>  #define RING_INSTDONE(base)	((base)+0x6c)
> -- 
> 1.7.11.5

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

* [PATCH 1/3 v4] drm/i915: Extract reading INSTDONE
  2012-08-23 11:56 ` [PATCH 1/3 v3] drm/i915: Extract reading INSTDONE Jani Nikula
@ 2012-08-23 22:18   ` Ben Widawsky
  2012-08-24  9:26     ` Jani Nikula
  0 siblings, 1 reply; 7+ messages in thread
From: Ben Widawsky @ 2012-08-23 22:18 UTC (permalink / raw)
  To: intel-gfx; +Cc: Jani Nikula, Ben Widawsky

INSTDONE is used in many places, and it varies from generation to
generation. This provides a good reason for us to extract the logic to
read the relevant information.

The patch has no functional change. It's prep for some new stuff.

v2: move the memset inside of i915_get_extra_instdone (Jani)
v3,4: bugs caught by (Jani)

Cc: Jani Nikula <jani.nikula@intel.com>
Signed-off-by: Ben Widawsky <ben@bwidawsk.net>
---
 drivers/gpu/drm/i915/i915_irq.c | 50 +++++++++++++++++++++++++----------------
 drivers/gpu/drm/i915/i915_reg.h |  1 +
 2 files changed, 32 insertions(+), 19 deletions(-)

diff --git a/drivers/gpu/drm/i915/i915_irq.c b/drivers/gpu/drm/i915/i915_irq.c
index 3633029..b7ec34e 100644
--- a/drivers/gpu/drm/i915/i915_irq.c
+++ b/drivers/gpu/drm/i915/i915_irq.c
@@ -1070,6 +1070,23 @@ i915_error_first_batchbuffer(struct drm_i915_private *dev_priv,
 	return NULL;
 }
 
+/* NB: please notice the memset */
+static void i915_get_extra_instdone(struct drm_device *dev,
+				    uint32_t *instdone)
+{
+	struct drm_i915_private *dev_priv = dev->dev_private;
+	memset(instdone, 0, sizeof(*instdone) * I915_NUM_INSTDONE_REG);
+
+	if (INTEL_INFO(dev)->gen < 4) {
+		instdone[0] = I915_READ(INSTDONE);
+		instdone[1] = 0;
+	} else {
+		instdone[0] = I915_READ(INSTDONE_I965);
+		instdone[1] = I915_READ(INSTDONE1);
+	}
+}
+
+
 static void i915_record_ring_state(struct drm_device *dev,
 				   struct drm_i915_error_state *error,
 				   struct intel_ring_buffer *ring)
@@ -1288,6 +1305,7 @@ void i915_destroy_error_state(struct drm_device *dev)
 static void i915_report_and_clear_eir(struct drm_device *dev)
 {
 	struct drm_i915_private *dev_priv = dev->dev_private;
+	uint32_t instdone[I915_NUM_INSTDONE_REG];
 	u32 eir = I915_READ(EIR);
 	int pipe;
 
@@ -1296,16 +1314,17 @@ static void i915_report_and_clear_eir(struct drm_device *dev)
 
 	pr_err("render error detected, EIR: 0x%08x\n", eir);
 
+	i915_get_extra_instdone(dev, instdone);
+
 	if (IS_G4X(dev)) {
 		if (eir & (GM45_ERROR_MEM_PRIV | GM45_ERROR_CP_PRIV)) {
 			u32 ipeir = I915_READ(IPEIR_I965);
 
 			pr_err("  IPEIR: 0x%08x\n", I915_READ(IPEIR_I965));
 			pr_err("  IPEHR: 0x%08x\n", I915_READ(IPEHR_I965));
-			pr_err("  INSTDONE: 0x%08x\n",
-			       I915_READ(INSTDONE_I965));
+			pr_err("  INSTDONE: 0x%08x\n", instdone[0]);
 			pr_err("  INSTPS: 0x%08x\n", I915_READ(INSTPS));
-			pr_err("  INSTDONE1: 0x%08x\n", I915_READ(INSTDONE1));
+			pr_err("  INSTDONE1: 0x%08x\n", instdone[1]);
 			pr_err("  ACTHD: 0x%08x\n", I915_READ(ACTHD_I965));
 			I915_WRITE(IPEIR_I965, ipeir);
 			POSTING_READ(IPEIR_I965);
@@ -1344,7 +1363,7 @@ static void i915_report_and_clear_eir(struct drm_device *dev)
 
 			pr_err("  IPEIR: 0x%08x\n", I915_READ(IPEIR));
 			pr_err("  IPEHR: 0x%08x\n", I915_READ(IPEHR));
-			pr_err("  INSTDONE: 0x%08x\n", I915_READ(INSTDONE));
+			pr_err("  INSTDONE: 0x%08x\n", instdone[0]);
 			pr_err("  ACTHD: 0x%08x\n", I915_READ(ACTHD));
 			I915_WRITE(IPEIR, ipeir);
 			POSTING_READ(IPEIR);
@@ -1353,10 +1372,9 @@ static void i915_report_and_clear_eir(struct drm_device *dev)
 
 			pr_err("  IPEIR: 0x%08x\n", I915_READ(IPEIR_I965));
 			pr_err("  IPEHR: 0x%08x\n", I915_READ(IPEHR_I965));
-			pr_err("  INSTDONE: 0x%08x\n",
-			       I915_READ(INSTDONE_I965));
+			pr_err("  INSTDONE: 0x%08x\n", instdone[0]);
 			pr_err("  INSTPS: 0x%08x\n", I915_READ(INSTPS));
-			pr_err("  INSTDONE1: 0x%08x\n", I915_READ(INSTDONE1));
+			pr_err("  INSTDONE1: 0x%08x\n", instdone[1]);
 			pr_err("  ACTHD: 0x%08x\n", I915_READ(ACTHD_I965));
 			I915_WRITE(IPEIR_I965, ipeir);
 			POSTING_READ(IPEIR_I965);
@@ -1671,7 +1689,7 @@ void i915_hangcheck_elapsed(unsigned long data)
 {
 	struct drm_device *dev = (struct drm_device *)data;
 	drm_i915_private_t *dev_priv = dev->dev_private;
-	uint32_t acthd[I915_NUM_RINGS], instdone, instdone1;
+	uint32_t acthd[I915_NUM_RINGS], instdone[I915_NUM_INSTDONE_REG];
 	struct intel_ring_buffer *ring;
 	bool err = false, idle;
 	int i;
@@ -1699,25 +1717,19 @@ void i915_hangcheck_elapsed(unsigned long data)
 		return;
 	}
 
-	if (INTEL_INFO(dev)->gen < 4) {
-		instdone = I915_READ(INSTDONE);
-		instdone1 = 0;
-	} else {
-		instdone = I915_READ(INSTDONE_I965);
-		instdone1 = I915_READ(INSTDONE1);
-	}
+	i915_get_extra_instdone(dev, instdone);
 
 	if (memcmp(dev_priv->last_acthd, acthd, sizeof(acthd)) == 0 &&
-	    dev_priv->last_instdone == instdone &&
-	    dev_priv->last_instdone1 == instdone1) {
+	    dev_priv->last_instdone == instdone[0] &&
+	    dev_priv->last_instdone1 == instdone[1]) {
 		if (i915_hangcheck_hung(dev))
 			return;
 	} else {
 		dev_priv->hangcheck_count = 0;
 
 		memcpy(dev_priv->last_acthd, acthd, sizeof(acthd));
-		dev_priv->last_instdone = instdone;
-		dev_priv->last_instdone1 = instdone1;
+		dev_priv->last_instdone = instdone[0];
+		dev_priv->last_instdone1 = instdone[1];
 	}
 
 repeat:
diff --git a/drivers/gpu/drm/i915/i915_reg.h b/drivers/gpu/drm/i915/i915_reg.h
index f27e998..1f97b3f 100644
--- a/drivers/gpu/drm/i915/i915_reg.h
+++ b/drivers/gpu/drm/i915/i915_reg.h
@@ -478,6 +478,7 @@
 #define IPEIR_I965	0x02064
 #define IPEHR_I965	0x02068
 #define INSTDONE_I965	0x0206c
+#define I915_NUM_INSTDONE_REG	2
 #define RING_IPEIR(base)	((base)+0x64)
 #define RING_IPEHR(base)	((base)+0x68)
 #define RING_INSTDONE(base)	((base)+0x6c)
-- 
1.7.12

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

* Re: [PATCH 1/3 v4] drm/i915: Extract reading INSTDONE
  2012-08-23 22:18   ` [PATCH 1/3 v4] " Ben Widawsky
@ 2012-08-24  9:26     ` Jani Nikula
  2012-08-24 14:59       ` Daniel Vetter
  0 siblings, 1 reply; 7+ messages in thread
From: Jani Nikula @ 2012-08-24  9:26 UTC (permalink / raw)
  To: intel-gfx; +Cc: Ben Widawsky

On Fri, 24 Aug 2012, Ben Widawsky <ben@bwidawsk.net> wrote:
> INSTDONE is used in many places, and it varies from generation to
> generation. This provides a good reason for us to extract the logic to
> read the relevant information.
>
> The patch has no functional change. It's prep for some new stuff.
>
> v2: move the memset inside of i915_get_extra_instdone (Jani)
> v3,4: bugs caught by (Jani)

On the series,

Reviewed-by: Jani Nikula <jani.nikula@intel.com>

>
> Cc: Jani Nikula <jani.nikula@intel.com>
> Signed-off-by: Ben Widawsky <ben@bwidawsk.net>
> ---
>  drivers/gpu/drm/i915/i915_irq.c | 50 +++++++++++++++++++++++++----------------
>  drivers/gpu/drm/i915/i915_reg.h |  1 +
>  2 files changed, 32 insertions(+), 19 deletions(-)
>
> diff --git a/drivers/gpu/drm/i915/i915_irq.c b/drivers/gpu/drm/i915/i915_irq.c
> index 3633029..b7ec34e 100644
> --- a/drivers/gpu/drm/i915/i915_irq.c
> +++ b/drivers/gpu/drm/i915/i915_irq.c
> @@ -1070,6 +1070,23 @@ i915_error_first_batchbuffer(struct drm_i915_private *dev_priv,
>  	return NULL;
>  }
>  
> +/* NB: please notice the memset */
> +static void i915_get_extra_instdone(struct drm_device *dev,
> +				    uint32_t *instdone)
> +{
> +	struct drm_i915_private *dev_priv = dev->dev_private;
> +	memset(instdone, 0, sizeof(*instdone) * I915_NUM_INSTDONE_REG);
> +
> +	if (INTEL_INFO(dev)->gen < 4) {
> +		instdone[0] = I915_READ(INSTDONE);
> +		instdone[1] = 0;
> +	} else {
> +		instdone[0] = I915_READ(INSTDONE_I965);
> +		instdone[1] = I915_READ(INSTDONE1);
> +	}
> +}
> +
> +
>  static void i915_record_ring_state(struct drm_device *dev,
>  				   struct drm_i915_error_state *error,
>  				   struct intel_ring_buffer *ring)
> @@ -1288,6 +1305,7 @@ void i915_destroy_error_state(struct drm_device *dev)
>  static void i915_report_and_clear_eir(struct drm_device *dev)
>  {
>  	struct drm_i915_private *dev_priv = dev->dev_private;
> +	uint32_t instdone[I915_NUM_INSTDONE_REG];
>  	u32 eir = I915_READ(EIR);
>  	int pipe;
>  
> @@ -1296,16 +1314,17 @@ static void i915_report_and_clear_eir(struct drm_device *dev)
>  
>  	pr_err("render error detected, EIR: 0x%08x\n", eir);
>  
> +	i915_get_extra_instdone(dev, instdone);
> +
>  	if (IS_G4X(dev)) {
>  		if (eir & (GM45_ERROR_MEM_PRIV | GM45_ERROR_CP_PRIV)) {
>  			u32 ipeir = I915_READ(IPEIR_I965);
>  
>  			pr_err("  IPEIR: 0x%08x\n", I915_READ(IPEIR_I965));
>  			pr_err("  IPEHR: 0x%08x\n", I915_READ(IPEHR_I965));
> -			pr_err("  INSTDONE: 0x%08x\n",
> -			       I915_READ(INSTDONE_I965));
> +			pr_err("  INSTDONE: 0x%08x\n", instdone[0]);
>  			pr_err("  INSTPS: 0x%08x\n", I915_READ(INSTPS));
> -			pr_err("  INSTDONE1: 0x%08x\n", I915_READ(INSTDONE1));
> +			pr_err("  INSTDONE1: 0x%08x\n", instdone[1]);
>  			pr_err("  ACTHD: 0x%08x\n", I915_READ(ACTHD_I965));
>  			I915_WRITE(IPEIR_I965, ipeir);
>  			POSTING_READ(IPEIR_I965);
> @@ -1344,7 +1363,7 @@ static void i915_report_and_clear_eir(struct drm_device *dev)
>  
>  			pr_err("  IPEIR: 0x%08x\n", I915_READ(IPEIR));
>  			pr_err("  IPEHR: 0x%08x\n", I915_READ(IPEHR));
> -			pr_err("  INSTDONE: 0x%08x\n", I915_READ(INSTDONE));
> +			pr_err("  INSTDONE: 0x%08x\n", instdone[0]);
>  			pr_err("  ACTHD: 0x%08x\n", I915_READ(ACTHD));
>  			I915_WRITE(IPEIR, ipeir);
>  			POSTING_READ(IPEIR);
> @@ -1353,10 +1372,9 @@ static void i915_report_and_clear_eir(struct drm_device *dev)
>  
>  			pr_err("  IPEIR: 0x%08x\n", I915_READ(IPEIR_I965));
>  			pr_err("  IPEHR: 0x%08x\n", I915_READ(IPEHR_I965));
> -			pr_err("  INSTDONE: 0x%08x\n",
> -			       I915_READ(INSTDONE_I965));
> +			pr_err("  INSTDONE: 0x%08x\n", instdone[0]);
>  			pr_err("  INSTPS: 0x%08x\n", I915_READ(INSTPS));
> -			pr_err("  INSTDONE1: 0x%08x\n", I915_READ(INSTDONE1));
> +			pr_err("  INSTDONE1: 0x%08x\n", instdone[1]);
>  			pr_err("  ACTHD: 0x%08x\n", I915_READ(ACTHD_I965));
>  			I915_WRITE(IPEIR_I965, ipeir);
>  			POSTING_READ(IPEIR_I965);
> @@ -1671,7 +1689,7 @@ void i915_hangcheck_elapsed(unsigned long data)
>  {
>  	struct drm_device *dev = (struct drm_device *)data;
>  	drm_i915_private_t *dev_priv = dev->dev_private;
> -	uint32_t acthd[I915_NUM_RINGS], instdone, instdone1;
> +	uint32_t acthd[I915_NUM_RINGS], instdone[I915_NUM_INSTDONE_REG];
>  	struct intel_ring_buffer *ring;
>  	bool err = false, idle;
>  	int i;
> @@ -1699,25 +1717,19 @@ void i915_hangcheck_elapsed(unsigned long data)
>  		return;
>  	}
>  
> -	if (INTEL_INFO(dev)->gen < 4) {
> -		instdone = I915_READ(INSTDONE);
> -		instdone1 = 0;
> -	} else {
> -		instdone = I915_READ(INSTDONE_I965);
> -		instdone1 = I915_READ(INSTDONE1);
> -	}
> +	i915_get_extra_instdone(dev, instdone);
>  
>  	if (memcmp(dev_priv->last_acthd, acthd, sizeof(acthd)) == 0 &&
> -	    dev_priv->last_instdone == instdone &&
> -	    dev_priv->last_instdone1 == instdone1) {
> +	    dev_priv->last_instdone == instdone[0] &&
> +	    dev_priv->last_instdone1 == instdone[1]) {
>  		if (i915_hangcheck_hung(dev))
>  			return;
>  	} else {
>  		dev_priv->hangcheck_count = 0;
>  
>  		memcpy(dev_priv->last_acthd, acthd, sizeof(acthd));
> -		dev_priv->last_instdone = instdone;
> -		dev_priv->last_instdone1 = instdone1;
> +		dev_priv->last_instdone = instdone[0];
> +		dev_priv->last_instdone1 = instdone[1];
>  	}
>  
>  repeat:
> diff --git a/drivers/gpu/drm/i915/i915_reg.h b/drivers/gpu/drm/i915/i915_reg.h
> index f27e998..1f97b3f 100644
> --- a/drivers/gpu/drm/i915/i915_reg.h
> +++ b/drivers/gpu/drm/i915/i915_reg.h
> @@ -478,6 +478,7 @@
>  #define IPEIR_I965	0x02064
>  #define IPEHR_I965	0x02068
>  #define INSTDONE_I965	0x0206c
> +#define I915_NUM_INSTDONE_REG	2
>  #define RING_IPEIR(base)	((base)+0x64)
>  #define RING_IPEHR(base)	((base)+0x68)
>  #define RING_INSTDONE(base)	((base)+0x6c)
> -- 
> 1.7.12

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

* Re: [PATCH 1/3 v4] drm/i915: Extract reading INSTDONE
  2012-08-24  9:26     ` Jani Nikula
@ 2012-08-24 14:59       ` Daniel Vetter
  0 siblings, 0 replies; 7+ messages in thread
From: Daniel Vetter @ 2012-08-24 14:59 UTC (permalink / raw)
  To: Jani Nikula; +Cc: Ben Widawsky, intel-gfx

On Fri, Aug 24, 2012 at 12:26:05PM +0300, Jani Nikula wrote:
> On Fri, 24 Aug 2012, Ben Widawsky <ben@bwidawsk.net> wrote:
> > INSTDONE is used in many places, and it varies from generation to
> > generation. This provides a good reason for us to extract the logic to
> > read the relevant information.
> >
> > The patch has no functional change. It's prep for some new stuff.
> >
> > v2: move the memset inside of i915_get_extra_instdone (Jani)
> > v3,4: bugs caught by (Jani)
> 
> On the series,
> 
> Reviewed-by: Jani Nikula <jani.nikula@intel.com>
All 3 queued for -next, thanks for the patches and review.
-Daniel
> 
> >
> > Cc: Jani Nikula <jani.nikula@intel.com>
> > Signed-off-by: Ben Widawsky <ben@bwidawsk.net>
> > ---
> >  drivers/gpu/drm/i915/i915_irq.c | 50 +++++++++++++++++++++++++----------------
> >  drivers/gpu/drm/i915/i915_reg.h |  1 +
> >  2 files changed, 32 insertions(+), 19 deletions(-)
> >
> > diff --git a/drivers/gpu/drm/i915/i915_irq.c b/drivers/gpu/drm/i915/i915_irq.c
> > index 3633029..b7ec34e 100644
> > --- a/drivers/gpu/drm/i915/i915_irq.c
> > +++ b/drivers/gpu/drm/i915/i915_irq.c
> > @@ -1070,6 +1070,23 @@ i915_error_first_batchbuffer(struct drm_i915_private *dev_priv,
> >  	return NULL;
> >  }
> >  
> > +/* NB: please notice the memset */
> > +static void i915_get_extra_instdone(struct drm_device *dev,
> > +				    uint32_t *instdone)
> > +{
> > +	struct drm_i915_private *dev_priv = dev->dev_private;
> > +	memset(instdone, 0, sizeof(*instdone) * I915_NUM_INSTDONE_REG);
> > +
> > +	if (INTEL_INFO(dev)->gen < 4) {
> > +		instdone[0] = I915_READ(INSTDONE);
> > +		instdone[1] = 0;
> > +	} else {
> > +		instdone[0] = I915_READ(INSTDONE_I965);
> > +		instdone[1] = I915_READ(INSTDONE1);
> > +	}
> > +}
> > +
> > +
> >  static void i915_record_ring_state(struct drm_device *dev,
> >  				   struct drm_i915_error_state *error,
> >  				   struct intel_ring_buffer *ring)
> > @@ -1288,6 +1305,7 @@ void i915_destroy_error_state(struct drm_device *dev)
> >  static void i915_report_and_clear_eir(struct drm_device *dev)
> >  {
> >  	struct drm_i915_private *dev_priv = dev->dev_private;
> > +	uint32_t instdone[I915_NUM_INSTDONE_REG];
> >  	u32 eir = I915_READ(EIR);
> >  	int pipe;
> >  
> > @@ -1296,16 +1314,17 @@ static void i915_report_and_clear_eir(struct drm_device *dev)
> >  
> >  	pr_err("render error detected, EIR: 0x%08x\n", eir);
> >  
> > +	i915_get_extra_instdone(dev, instdone);
> > +
> >  	if (IS_G4X(dev)) {
> >  		if (eir & (GM45_ERROR_MEM_PRIV | GM45_ERROR_CP_PRIV)) {
> >  			u32 ipeir = I915_READ(IPEIR_I965);
> >  
> >  			pr_err("  IPEIR: 0x%08x\n", I915_READ(IPEIR_I965));
> >  			pr_err("  IPEHR: 0x%08x\n", I915_READ(IPEHR_I965));
> > -			pr_err("  INSTDONE: 0x%08x\n",
> > -			       I915_READ(INSTDONE_I965));
> > +			pr_err("  INSTDONE: 0x%08x\n", instdone[0]);
> >  			pr_err("  INSTPS: 0x%08x\n", I915_READ(INSTPS));
> > -			pr_err("  INSTDONE1: 0x%08x\n", I915_READ(INSTDONE1));
> > +			pr_err("  INSTDONE1: 0x%08x\n", instdone[1]);
> >  			pr_err("  ACTHD: 0x%08x\n", I915_READ(ACTHD_I965));
> >  			I915_WRITE(IPEIR_I965, ipeir);
> >  			POSTING_READ(IPEIR_I965);
> > @@ -1344,7 +1363,7 @@ static void i915_report_and_clear_eir(struct drm_device *dev)
> >  
> >  			pr_err("  IPEIR: 0x%08x\n", I915_READ(IPEIR));
> >  			pr_err("  IPEHR: 0x%08x\n", I915_READ(IPEHR));
> > -			pr_err("  INSTDONE: 0x%08x\n", I915_READ(INSTDONE));
> > +			pr_err("  INSTDONE: 0x%08x\n", instdone[0]);
> >  			pr_err("  ACTHD: 0x%08x\n", I915_READ(ACTHD));
> >  			I915_WRITE(IPEIR, ipeir);
> >  			POSTING_READ(IPEIR);
> > @@ -1353,10 +1372,9 @@ static void i915_report_and_clear_eir(struct drm_device *dev)
> >  
> >  			pr_err("  IPEIR: 0x%08x\n", I915_READ(IPEIR_I965));
> >  			pr_err("  IPEHR: 0x%08x\n", I915_READ(IPEHR_I965));
> > -			pr_err("  INSTDONE: 0x%08x\n",
> > -			       I915_READ(INSTDONE_I965));
> > +			pr_err("  INSTDONE: 0x%08x\n", instdone[0]);
> >  			pr_err("  INSTPS: 0x%08x\n", I915_READ(INSTPS));
> > -			pr_err("  INSTDONE1: 0x%08x\n", I915_READ(INSTDONE1));
> > +			pr_err("  INSTDONE1: 0x%08x\n", instdone[1]);
> >  			pr_err("  ACTHD: 0x%08x\n", I915_READ(ACTHD_I965));
> >  			I915_WRITE(IPEIR_I965, ipeir);
> >  			POSTING_READ(IPEIR_I965);
> > @@ -1671,7 +1689,7 @@ void i915_hangcheck_elapsed(unsigned long data)
> >  {
> >  	struct drm_device *dev = (struct drm_device *)data;
> >  	drm_i915_private_t *dev_priv = dev->dev_private;
> > -	uint32_t acthd[I915_NUM_RINGS], instdone, instdone1;
> > +	uint32_t acthd[I915_NUM_RINGS], instdone[I915_NUM_INSTDONE_REG];
> >  	struct intel_ring_buffer *ring;
> >  	bool err = false, idle;
> >  	int i;
> > @@ -1699,25 +1717,19 @@ void i915_hangcheck_elapsed(unsigned long data)
> >  		return;
> >  	}
> >  
> > -	if (INTEL_INFO(dev)->gen < 4) {
> > -		instdone = I915_READ(INSTDONE);
> > -		instdone1 = 0;
> > -	} else {
> > -		instdone = I915_READ(INSTDONE_I965);
> > -		instdone1 = I915_READ(INSTDONE1);
> > -	}
> > +	i915_get_extra_instdone(dev, instdone);
> >  
> >  	if (memcmp(dev_priv->last_acthd, acthd, sizeof(acthd)) == 0 &&
> > -	    dev_priv->last_instdone == instdone &&
> > -	    dev_priv->last_instdone1 == instdone1) {
> > +	    dev_priv->last_instdone == instdone[0] &&
> > +	    dev_priv->last_instdone1 == instdone[1]) {
> >  		if (i915_hangcheck_hung(dev))
> >  			return;
> >  	} else {
> >  		dev_priv->hangcheck_count = 0;
> >  
> >  		memcpy(dev_priv->last_acthd, acthd, sizeof(acthd));
> > -		dev_priv->last_instdone = instdone;
> > -		dev_priv->last_instdone1 = instdone1;
> > +		dev_priv->last_instdone = instdone[0];
> > +		dev_priv->last_instdone1 = instdone[1];
> >  	}
> >  
> >  repeat:
> > diff --git a/drivers/gpu/drm/i915/i915_reg.h b/drivers/gpu/drm/i915/i915_reg.h
> > index f27e998..1f97b3f 100644
> > --- a/drivers/gpu/drm/i915/i915_reg.h
> > +++ b/drivers/gpu/drm/i915/i915_reg.h
> > @@ -478,6 +478,7 @@
> >  #define IPEIR_I965	0x02064
> >  #define IPEHR_I965	0x02068
> >  #define INSTDONE_I965	0x0206c
> > +#define I915_NUM_INSTDONE_REG	2
> >  #define RING_IPEIR(base)	((base)+0x64)
> >  #define RING_IPEHR(base)	((base)+0x68)
> >  #define RING_INSTDONE(base)	((base)+0x6c)
> > -- 
> > 1.7.12
> _______________________________________________
> Intel-gfx mailing list
> Intel-gfx@lists.freedesktop.org
> http://lists.freedesktop.org/mailman/listinfo/intel-gfx

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

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

end of thread, other threads:[~2012-08-24 14:59 UTC | newest]

Thread overview: 7+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2012-08-22 18:32 [PATCH 1/3 v3] drm/i915: Extract reading INSTDONE Ben Widawsky
2012-08-22 18:32 ` [PATCH 2/3] [REPOST] drm/i915: Add new INSTDONE registers Ben Widawsky
2012-08-22 18:32 ` [PATCH 3/3 v3] drm/i915: Use new INSTDONE registers (Gen7+) Ben Widawsky
2012-08-23 11:56 ` [PATCH 1/3 v3] drm/i915: Extract reading INSTDONE Jani Nikula
2012-08-23 22:18   ` [PATCH 1/3 v4] " Ben Widawsky
2012-08-24  9:26     ` Jani Nikula
2012-08-24 14:59       ` Daniel Vetter

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).