Skip to contentSkip to conversation

drm/i915: Fix retrieval of hangcheck stats

PATCH In review Mika Kuoppala 3 participants 7 messages Jun 25, 2013 – Jul 1, 2013

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

PATCH 1/3 drm/i915: Fix retrieval of hangcheck stats

From: Chris Wilson <[email protected]>

The default context is always supported (as it contains the global hangcheck stats) and the contexts for hangcheck are not limited to any ring.

References: https://bugs.freedesktop.org/show_bug.cgi?id=65845

---
 drivers/gpu/drm/i915/i915_drv.h         |    2 +-
 drivers/gpu/drm/i915/i915_gem_context.c |   23 ++++++++---------------
 2 files changed, 9 insertions(+), 16 deletions(-)
drivers/gpu/drm/i915/i915_drv.h +1 -1
index 491958e..dd55bc0 100644
@@ -1825,7 +1825,7 @@ static inline void i915_gem_context_unreference(struct i915_hw_context *ctx)
 }
 
 struct i915_ctx_hang_stats * __must_check
-i915_gem_context_get_hang_stats(struct intel_ring_buffer *ring,
+i915_gem_context_get_hang_stats(struct drm_device *dev,
 				struct drm_file *file,
 				u32 id);
 int i915_gem_context_create_ioctl(struct drm_device *dev, void *data,
drivers/gpu/drm/i915/i915_gem_context.c +8 -15
index ff47145..ec4cf02 100644
@@ -304,31 +304,24 @@ static int context_idr_cleanup(int id, void *p, void *data)
 }
 
 struct i915_ctx_hang_stats *
-i915_gem_context_get_hang_stats(struct intel_ring_buffer *ring,
+i915_gem_context_get_hang_stats(struct drm_device *dev,
 				struct drm_file *file,
 				u32 id)
 {
-	struct drm_i915_private *dev_priv = ring->dev->dev_private;
+	struct drm_i915_private *dev_priv = dev->dev_private;
 	struct drm_i915_file_private *file_priv = file->driver_priv;
-	struct i915_hw_context *to;
-
-	if (dev_priv->hw_contexts_disabled)
-		return ERR_PTR(-ENOENT);
-
-	if (ring->id != RCS)
-		return ERR_PTR(-EINVAL);
-
-	if (file == NULL)
-		return ERR_PTR(-EINVAL);
+	struct i915_hw_context *ctx;
 
 	if (id == DEFAULT_CONTEXT_ID)
 		return &file_priv->hang_stats;
 
-	to = i915_gem_context_get(file->driver_priv, id);
-	if (to == NULL)
+	ctx = NULL;
+	if (!dev_priv->hw_contexts_disabled)
+		ctx = i915_gem_context_get(file->driver_priv, id);
+	if (ctx == NULL)
 		return ERR_PTR(-ENOENT);
 
-	return &to->hang_stats;
+	return &ctx->hang_stats;
 }
 
 void i915_gem_context_close(struct drm_device *dev, struct drm_file *file)
Signature · 1 line
1.7.9.5
#1 lore raw

PATCH 2/3 drm/i915: Replace open-coding of DEFAULT_CONTEXT_ID

From: Chris Wilson <[email protected]>

The intent of the check is made more clear if we use the proper name for 0 here.

---
 drivers/gpu/drm/i915/i915_gem_execbuffer.c |    6 +++---
 1 file changed, 3 insertions(+), 3 deletions(-)
drivers/gpu/drm/i915/i915_gem_execbuffer.c +3 -3
index 87a3227..b6b47d6 100644
@@ -872,7 +872,7 @@ i915_gem_do_execbuffer(struct drm_device *dev, void *data,
 		break;
 	case I915_EXEC_BSD:
 		ring = &dev_priv->ring[VCS];
-		if (ctx_id != 0) {
+		if (ctx_id != DEFAULT_CONTEXT_ID) {
 			DRM_DEBUG("Ring %s doesn't support contexts\n",
 				  ring->name);
 			return -EPERM;
@@ -880,7 +880,7 @@ i915_gem_do_execbuffer(struct drm_device *dev, void *data,
 		break;
 	case I915_EXEC_BLT:
 		ring = &dev_priv->ring[BCS];
-		if (ctx_id != 0) {
+		if (ctx_id != DEFAULT_CONTEXT_ID) {
 			DRM_DEBUG("Ring %s doesn't support contexts\n",
 				  ring->name);
 			return -EPERM;
@@ -888,7 +888,7 @@ i915_gem_do_execbuffer(struct drm_device *dev, void *data,
 		break;
 	case I915_EXEC_VEBOX:
 		ring = &dev_priv->ring[VECS];
-		if (ctx_id != 0) {
+		if (ctx_id != DEFAULT_CONTEXT_ID) {
 			DRM_DEBUG("Ring %s doesn't support contexts\n",
 				  ring->name);
 			return -EPERM;
Signature · 1 line
1.7.9.5
#3 lore raw

PATCH 3/3 drm/i915: Allow contexts to be specified for unsupported rings

In reply to Mika Kuoppala

From: Chris Wilson <[email protected]>

As our contexts are more general than the logical contexts supported by the hardware, for instance they allow per context hangcheck tracking, it is beneficial to group tasks across rings belonging to the same context. Context switching is already a no-op for unsupported rings, we just suffered from a little too overzealous parameter checking on entry - now we just check that the context is valid.

---
 drivers/gpu/drm/i915/i915_gem_execbuffer.c |   15 ---------------
 1 file changed, 15 deletions(-)
drivers/gpu/drm/i915/i915_gem_execbuffer.c +0 -15
index b6b47d6..5c237f3 100644
@@ -872,27 +872,12 @@ i915_gem_do_execbuffer(struct drm_device *dev, void *data,
 		break;
 	case I915_EXEC_BSD:
 		ring = &dev_priv->ring[VCS];
-		if (ctx_id != DEFAULT_CONTEXT_ID) {
-			DRM_DEBUG("Ring %s doesn't support contexts\n",
-				  ring->name);
-			return -EPERM;
-		}
 		break;
 	case I915_EXEC_BLT:
 		ring = &dev_priv->ring[BCS];
-		if (ctx_id != DEFAULT_CONTEXT_ID) {
-			DRM_DEBUG("Ring %s doesn't support contexts\n",
-				  ring->name);
-			return -EPERM;
-		}
 		break;
 	case I915_EXEC_VEBOX:
 		ring = &dev_priv->ring[VECS];
-		if (ctx_id != DEFAULT_CONTEXT_ID) {
-			DRM_DEBUG("Ring %s doesn't support contexts\n",
-				  ring->name);
-			return -EPERM;
-		}
 		break;
 
 	default:
Signature · 1 line
1.7.9.5
#4 lore raw

Re: [PATCH 3/3] drm/i915: Allow contexts to be specified for unsupported rings

Quoted 8 lines · Mika Kuoppala

From: Chris Wilson <[email protected]>

As our contexts are more general than the logical contexts supported by the hardware, for instance they allow per context hangcheck tracking, it is beneficial to group tasks across rings belonging to the same context. Context switching is already a no-op for unsupported rings, we just suffered from a little too overzealous parameter checking on entry - now we just check that the context is valid.

We have to drop this temporarily as the validation was being provided by i915_gem_context_get_hang_stats(), which is now notably absent. -Chris

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

Re: [PATCH 3/3] drm/i915: Allow contexts to be specified for unsupported rings

Quoted 10 lines · Chris Wilson
Quoted 8 lines · Mika Kuoppala

From: Chris Wilson <[email protected]>

As our contexts are more general than the logical contexts supported by the hardware, for instance they allow per context hangcheck tracking, it is beneficial to group tasks across rings belonging to the same context. Context switching is already a no-op for unsupported rings, we just suffered from a little too overzealous parameter checking on entry - now we just check that the context is valid.

Quoted 6 lines

We have to drop this temporarily as the validation was being provided by i915_gem_context_get_hang_stats(), which is now notably absent. -Chris

Signature · 1 line
Chris Wilson, Intel Open Source Technology Centre

I haven't been actively reading the list recently, but I have this same patch in the PPGTT series. I'll make sure I get it upstream in my series if you guys are okay with dropping it here.

Signature · 1 line
Ben Widawsky, Intel Open Source Technology Center
#6 lore raw
In reply to Mika Kuoppala
Quoted 9 lines · Mika Kuoppala

From: Chris Wilson <[email protected]>

The default context is always supported (as it contains the global hangcheck stats) and the contexts for hangcheck are not limited to any ring.

References: https://bugs.freedesktop.org/show_bug.cgi?id=65845

This patch is also duplicated in my PPGTT series. If you want to drop it here, I'll ameks ure it gets moved forward.

[snip]

Signature · 1 line
Ben Widawsky, Intel Open Source Technology Center