From: Ben Widawsky <bwidawsk@gmail.com>
To: intel-gfx@lists.freedesktop.org
Subject: [PATCH 8/9] drm/i915/context: enable calling context_switch
Date: Tue, 1 Feb 2011 10:16:25 -0800 [thread overview]
Message-ID: <1296584186-20446-9-git-send-email-bwidawsk@gmail.com> (raw)
In-Reply-To: <1296584186-20446-1-git-send-email-bwidawsk@gmail.com>
Changed context_validation code to return a pointer to the context which
was validated. This saved us a context id lookup later when we want to
actually context switch. The downside is we can't differentiate a
lost context (buffer moved) from a never-existed context. This seems
okay to me for now.
Added a call from do_execbuffer to actually context_switch for the
ringbuffer. Although context_switch is not yet implemented, this can
hopefully prove we don't break the existing code.
---
drivers/gpu/drm/i915/i915_context.c | 14 ++++++++------
drivers/gpu/drm/i915/i915_drv.h | 9 +++++----
drivers/gpu/drm/i915/i915_gem_execbuffer.c | 13 ++++++++-----
drivers/gpu/drm/i915/intel_ringbuffer.h | 2 +-
4 files changed, 22 insertions(+), 16 deletions(-)
diff --git a/drivers/gpu/drm/i915/i915_context.c b/drivers/gpu/drm/i915/i915_context.c
index cba0452..4f255fb 100644
--- a/drivers/gpu/drm/i915/i915_context.c
+++ b/drivers/gpu/drm/i915/i915_context.c
@@ -73,7 +73,8 @@ static void i915_context_del_id(struct drm_device *dev,
idr_remove(&dev_priv->i915_ctx_idr, ctx->ctx_id);
}
-int i915_context_validate(struct drm_device *dev, struct drm_file *file,
+struct drm_i915_gem_context *
+i915_context_validate(struct drm_device *dev, struct drm_file *file,
uint32_t ctx_id,
struct drm_i915_context_flag *ctx_flag, int count)
{
@@ -85,7 +86,7 @@ int i915_context_validate(struct drm_device *dev, struct drm_file *file,
ctx = i915_context_lookup_id(dev, ctx_id);
if (ctx == NULL) {
DRM_ERROR("Couldn't find context\n");
- return -ENXIO;
+ return ctx;
}
if ((!count || !ctx_flag))
@@ -117,7 +118,7 @@ int i915_context_validate(struct drm_device *dev, struct drm_file *file,
}
obj_priv = to_intel_bo(obj);
if (flag->offset && HAS_PPGTT(dev)) {
- /*
+ /*
* No need to check for overlaps because this is
* in their local GTT so they can only screw up
* themselves. But do check serious violations
@@ -163,13 +164,14 @@ out:
DRM_DEBUG_DRIVER("Context associated buffer has moved"
" %p->%p\n",
ppgtt_offset, obj_priv->gtt_offset);
- ret = -EIO;
- break;
+ mutex_unlock(&ctx->slot_mtx);
+ ctx = NULL;
+ return ctx;
}
}
mutex_unlock(&ctx->slot_mtx);
- return ret;
+ return ctx;
}
void i915_context_handle_binding(struct drm_i915_gem_object *obj)
diff --git a/drivers/gpu/drm/i915/i915_drv.h b/drivers/gpu/drm/i915/i915_drv.h
index 3105fd6..110e495 100644
--- a/drivers/gpu/drm/i915/i915_drv.h
+++ b/drivers/gpu/drm/i915/i915_drv.h
@@ -1326,10 +1326,11 @@ extern void i915_context_init(struct drm_device *dev);
extern void i915_context_deinit(struct drm_device *dev);
extern void i915_context_close(struct drm_device *dev, struct drm_file *file);
struct drm_i915_context_flag;
-extern int i915_context_validate(struct drm_device *dev,
- struct drm_file *file, uint32_t ctx_id,
- struct drm_i915_context_flag *ctx_flag,
- int count);
+extern struct drm_i915_gem_context *
+i915_context_validate(struct drm_device *dev,
+ struct drm_file *file, uint32_t ctx_id,
+ struct drm_i915_context_flag *ctx_flag,
+ int count);
extern void i915_context_handle_binding(struct drm_i915_gem_object *obj);
#define LP_RING(d) (&((struct drm_i915_private *)(d))->ring[RCS])
diff --git a/drivers/gpu/drm/i915/i915_gem_execbuffer.c b/drivers/gpu/drm/i915/i915_gem_execbuffer.c
index 1051b1e..9d022fb 100644
--- a/drivers/gpu/drm/i915/i915_gem_execbuffer.c
+++ b/drivers/gpu/drm/i915/i915_gem_execbuffer.c
@@ -990,6 +990,7 @@ i915_gem_do_execbuffer(struct drm_device *dev, void *data,
struct drm_i915_gem_object *batch_obj;
struct drm_clip_rect *cliprects = NULL;
struct intel_ring_buffer *ring;
+ struct drm_i915_gem_context *ctx;
u32 exec_start, exec_len;
u32 seqno;
u32 ctx_id;
@@ -1006,12 +1007,11 @@ i915_gem_do_execbuffer(struct drm_device *dev, void *data,
ctx_id = EXECBUFFER2_CTX_ID(args);
if (ctx_id) {
- ret = i915_context_validate(dev, file, ctx_id,
+ ctx = i915_context_validate(dev, file, ctx_id,
ctx_flags, flag_count);
- if (ret) {
- if (ret == -EIO)
- DRM_DEBUG_DRIVER("Context resubmission required\n");
- return ret;
+ if (!ctx) {
+ DRM_DEBUG_DRIVER("Context resubmission required\n");
+ return -EIO;
}
}
#if WATCH_EXEC
@@ -1203,6 +1203,9 @@ i915_gem_do_execbuffer(struct drm_device *dev, void *data,
}
}
+ if (!dev_priv->ctx_disable)
+ ring->context_switch(ring, ctx, I915_CONTEXT_NORMAL_SWITCH);
+
exec_start = batch_obj->gtt_offset + args->batch_start_offset;
exec_len = args->batch_len;
if (cliprects) {
diff --git a/drivers/gpu/drm/i915/intel_ringbuffer.h b/drivers/gpu/drm/i915/intel_ringbuffer.h
index 68ebecf..61525ba 100644
--- a/drivers/gpu/drm/i915/intel_ringbuffer.h
+++ b/drivers/gpu/drm/i915/intel_ringbuffer.h
@@ -82,7 +82,7 @@ struct intel_ring_buffer {
struct drm_i915_gem_context *last_context;
void (*context_switch)(struct intel_ring_buffer *ring,
struct drm_i915_gem_context *ctx,
- uint32_t flags);
+ u32 flags);
/**
* List of objects currently involved in rendering from the
--
1.7.3.4
next prev parent reply other threads:[~2011-02-01 18:18 UTC|newest]
Thread overview: 12+ messages / expand[flat|nested] mbox.gz Atom feed top
2011-02-01 18:16 [PATCH 0/9] drm/1915/context (i915HW Context support, early) Ben Widawsky
2011-02-01 18:16 ` [PATCH 1/9] drm/i915/context: context switch, and PPGTT params Ben Widawsky
2011-02-01 18:31 ` Jesse Barnes
2011-02-01 18:16 ` [PATCH 2/9] drm/i915/context: basic implementation context ioctls Ben Widawsky
2011-02-01 18:45 ` Chris Wilson
2011-02-01 18:16 ` [PATCH 3/9] drm/i915/context: context initialization/destruction Ben Widawsky
2011-02-01 18:16 ` [PATCH 4/9] drm/i915/context: whitespace cleanup, and warning cleanup Ben Widawsky
2011-02-01 18:16 ` [PATCH 5/9] drm/i915/context: switch context support query to variable Ben Widawsky
2011-02-01 18:16 ` [PATCH 6/9] drm/i915/context: minimal support for contexts in execbuffer2 Ben Widawsky
2011-02-01 18:16 ` [PATCH 7/9] drm/i915/context: context validation for execbuffer2 Ben Widawsky
2011-02-01 18:16 ` Ben Widawsky [this message]
2011-02-01 18:16 ` [PATCH 9/9] drm/i915/context: Insert MI_SET_CONTEXT in ringbuffer context switch Ben Widawsky
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=1296584186-20446-9-git-send-email-bwidawsk@gmail.com \
--to=bwidawsk@gmail.com \
--cc=intel-gfx@lists.freedesktop.org \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox