diff mbox

drm/i915: Return -ENOENT for unknown contexts

Message ID 1397638689-9352-1-git-send-email-mika.kuoppala@intel.com (mailing list archive)
State New, archived
Headers show

Commit Message

Mika Kuoppala April 16, 2014, 8:58 a.m. UTC
From: Mika Kuoppala <mika.kuoppala@linux.intel.com>

If hw_contexts are disabled, we always return the per file
descriptor default context stats. Make sure that the context
is correctly given and fail accordingly if not.

Testcase: igt/gem_reset_stats/params
Signed-off-by: Mika Kuoppala <mika.kuoppala@intel.com>
---
 drivers/gpu/drm/i915/i915_gem_context.c |    6 +++++-
 1 file changed, 5 insertions(+), 1 deletion(-)

Comments

Chris Wilson April 17, 2014, 7:49 a.m. UTC | #1
On Wed, Apr 16, 2014 at 11:58:09AM +0300, Mika Kuoppala wrote:
> From: Mika Kuoppala <mika.kuoppala@linux.intel.com>
> 
> If hw_contexts are disabled, we always return the per file
> descriptor default context stats. Make sure that the context
> is correctly given and fail accordingly if not.
> 
> Testcase: igt/gem_reset_stats/params
> Signed-off-by: Mika Kuoppala <mika.kuoppala@intel.com>

This code is obsolete, and the bug should be already fixed by

commit 691e6415c891b8b2b082a120b896b443531c4d45
Author: Chris Wilson <chris@chris-wilson.co.uk>
Date:   Wed Apr 9 09:07:36 2014 +0100

    drm/i915: Always use kref tracking for all contexts.

-Chris
Mika Kuoppala April 17, 2014, 10:22 a.m. UTC | #2
Chris Wilson <chris@chris-wilson.co.uk> writes:

> On Wed, Apr 16, 2014 at 11:58:09AM +0300, Mika Kuoppala wrote:
>> From: Mika Kuoppala <mika.kuoppala@linux.intel.com>
>> 
>> If hw_contexts are disabled, we always return the per file
>> descriptor default context stats. Make sure that the context
>> is correctly given and fail accordingly if not.
>> 
>> Testcase: igt/gem_reset_stats/params
>> Signed-off-by: Mika Kuoppala <mika.kuoppala@intel.com>
>
> This code is obsolete, and the bug should be already fixed by
>
> commit 691e6415c891b8b2b082a120b896b443531c4d45
> Author: Chris Wilson <chris@chris-wilson.co.uk>
> Date:   Wed Apr 9 09:07:36 2014 +0100
>
>     drm/i915: Always use kref tracking for all contexts.

Agreed. I should have run it against fixes in addition to dinq.

-Mika

> -Chris
>
> -- 
> Chris Wilson, Intel Open Source Technology Centre
diff mbox

Patch

diff --git a/drivers/gpu/drm/i915/i915_gem_context.c b/drivers/gpu/drm/i915/i915_gem_context.c
index 30b355a..85c890c 100644
--- a/drivers/gpu/drm/i915/i915_gem_context.c
+++ b/drivers/gpu/drm/i915/i915_gem_context.c
@@ -582,8 +582,12 @@  i915_gem_context_get(struct drm_i915_file_private *file_priv, u32 id)
 {
 	struct i915_hw_context *ctx;
 
-	if (!HAS_HW_CONTEXTS(file_priv->dev_priv->dev))
+	if (!HAS_HW_CONTEXTS(file_priv->dev_priv->dev)) {
+		if (id != DEFAULT_CONTEXT_ID)
+			return ERR_PTR(-ENOENT);
+
 		return file_priv->private_default_ctx;
+	}
 
 	ctx = (struct i915_hw_context *)idr_find(&file_priv->context_idr, id);
 	if (!ctx)