From patchwork Wed Feb 2 23:00:18 2011 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Ben Widawsky X-Patchwork-Id: 528021 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 p12N5JCZ007278 for ; Wed, 2 Feb 2011 23:05:39 GMT Received: from gabe.freedesktop.org (localhost [127.0.0.1]) by gabe.freedesktop.org (Postfix) with ESMTP id 9073F9E9E1 for ; Wed, 2 Feb 2011 15:05:19 -0800 (PST) X-Original-To: intel-gfx@lists.freedesktop.org Delivered-To: intel-gfx@lists.freedesktop.org Received: from mail-yw0-f49.google.com (mail-yw0-f49.google.com [209.85.213.49]) by gabe.freedesktop.org (Postfix) with ESMTP id B2DD49E9CA for ; Wed, 2 Feb 2011 15:00:52 -0800 (PST) Received: by ywf7 with SMTP id 7so239314ywf.36 for ; Wed, 02 Feb 2011 15:00:52 -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=GgyXyJSRyQZvDzt/E+8V+faJhOOpeVH8NX0KuPF1lnw=; b=aeUgdZrG/Pv0PjIfx0GzqQ2l2TdJ8FoGgESOaFbFoCXsvpn6Obg/0emp3Fgz5j5/8T EHP9iBDJhw0VyF/7b2jakHYTTG2a6Euh0q8GBcTq9Hoct33MfR70Pm/bgRBiDDGs3iyT KMTe+17KW+sUFPbT5o/pu/PnuR+UTAus9jpo4= 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=qtNEENB9rPvZoUjHmwPNEql45lLhUozJ7wPXfR1he1hmr81HtI7qEYSCeAXid7gkVE PEciGemIQwAEtuxfMFHcCPPiC9aDIy6+BCGemTtBf0+LKBFOn7cfr0rpRaHb7XqZLUIq bV8LPs+02meAEGF4yWkZCJqzA7QciAU4zd8XE= Received: by 10.151.12.2 with SMTP id p2mr12103638ybi.256.1296687652122; Wed, 02 Feb 2011 15:00:52 -0800 (PST) Received: from localhost.localdomain ([134.134.139.76]) by mx.google.com with ESMTPS id i10sm79654yhd.10.2011.02.02.15.00.50 (version=TLSv1/SSLv3 cipher=RC4-MD5); Wed, 02 Feb 2011 15:00:51 -0800 (PST) From: Ben Widawsky To: intel-gfx@lists.freedesktop.org Date: Wed, 2 Feb 2011 15:00:18 -0800 Message-Id: <1296687620-27019-7-git-send-email-bwidawsk@gmail.com> X-Mailer: git-send-email 1.7.3.4 In-Reply-To: <1296687620-27019-1-git-send-email-bwidawsk@gmail.com> References: <1296687620-27019-1-git-send-email-bwidawsk@gmail.com> Subject: [Intel-gfx] [PATCH 6/8] 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]); Wed, 02 Feb 2011 23:06:05 +0000 (UTC) diff --git a/drivers/gpu/drm/i915/i915_context.c b/drivers/gpu/drm/i915/i915_context.c index 4795caf..1085797 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_bind_ppgtt(struct drm_i915_gem_object *obj) diff --git a/drivers/gpu/drm/i915/i915_gem_execbuffer.c b/drivers/gpu/drm/i915/i915_gem_execbuffer.c index 356388a..b2313f0 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