From patchwork Tue Feb 1 18:16:25 2011 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Ben Widawsky X-Patchwork-Id: 523661 Received: from gabe.freedesktop.org (gabe.freedesktop.org [131.252.210.177]) by demeter1.kernel.org (8.14.4/8.14.3) with ESMTP id p11IN9h1003023 for ; Tue, 1 Feb 2011 18:23:29 GMT Received: from gabe.freedesktop.org (localhost [127.0.0.1]) by gabe.freedesktop.org (Postfix) with ESMTP id 5957F9E938 for ; Tue, 1 Feb 2011 10:23:09 -0800 (PST) X-Original-To: intel-gfx@lists.freedesktop.org Delivered-To: intel-gfx@lists.freedesktop.org Received: from mail-gw0-f49.google.com (mail-gw0-f49.google.com [74.125.83.49]) by gabe.freedesktop.org (Postfix) with ESMTP id 5E3F39E8FD for ; Tue, 1 Feb 2011 10:18:06 -0800 (PST) Received: by mail-gw0-f49.google.com with SMTP id 20so2716175gwj.36 for ; Tue, 01 Feb 2011 10:18:06 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=gamma; h=domainkey-signature:from:to:cc:subject:date:message-id:x-mailer :in-reply-to:references; bh=MzGicY20qtYE+WNuC3fZKJl/Z3I3dIVrpCy84yLR6iw=; b=AHq+zRx/W61gJ4fH9m5qs4rBfX+IXpZbW/Vb1Z0Kn4LwrtnBWMe8c/ufP5h+/n4ZGn JQsaZjTJmzRenJE9dOjKFLJlxBAkGLOkq1K1rvBw5qMMeXIIPJS7E9pgwvFMj0kYCT6a t9fzvVD6kAAwvxrmCGl+uhsyF/zMK6EH9IqyM= DomainKey-Signature: a=rsa-sha1; c=nofws; d=gmail.com; s=gamma; h=from:to:cc:subject:date:message-id:x-mailer:in-reply-to:references; b=w1YjCiBRR5mCVK0yNyMvFv/hHHF0uKHrsFlcsfhKGZOzr/yfJctsFnevQ3kpIZNAaM wnsccCUycCAXANTkpiH+N5hQZS/JhoLQCPSyfjdf6rx4A7bzXnXJ5ZAKRfm8Si+TslYG uIX93BApESy0yiGDS9Cby9h8Enl/PFWcBQGJM= Received: by 10.100.164.1 with SMTP id m1mr5110783ane.269.1296584286148; Tue, 01 Feb 2011 10:18:06 -0800 (PST) Received: from localhost.localdomain ([67.208.96.87]) by mx.google.com with ESMTPS id f10sm27543608anh.5.2011.02.01.10.18.04 (version=TLSv1/SSLv3 cipher=RC4-MD5); Tue, 01 Feb 2011 10:18:05 -0800 (PST) From: Ben Widawsky To: intel-gfx@lists.freedesktop.org Date: Tue, 1 Feb 2011 10:16:25 -0800 Message-Id: <1296584186-20446-9-git-send-email-bwidawsk@gmail.com> X-Mailer: git-send-email 1.7.3.4 In-Reply-To: <1296584186-20446-1-git-send-email-bwidawsk@gmail.com> References: <1296584186-20446-1-git-send-email-bwidawsk@gmail.com> Subject: [Intel-gfx] [PATCH 8/9] drm/i915/context: enable calling context_switch X-BeenThere: intel-gfx@lists.freedesktop.org X-Mailman-Version: 2.1.11 Precedence: list List-Id: Intel graphics driver community testing & development List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , MIME-Version: 1.0 Sender: intel-gfx-bounces+patchwork-intel-gfx=patchwork.kernel.org@lists.freedesktop.org Errors-To: intel-gfx-bounces+patchwork-intel-gfx=patchwork.kernel.org@lists.freedesktop.org X-Greylist: IP, sender and recipient auto-whitelisted, not delayed by milter-greylist-4.2.6 (demeter1.kernel.org [140.211.167.41]); Tue, 01 Feb 2011 18:23:56 +0000 (UTC) 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