From patchwork Thu Mar 14 00:21:08 2013 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Ben Widawsky X-Patchwork-Id: 2267061 Return-Path: X-Original-To: patchwork-intel-gfx@patchwork.kernel.org Delivered-To: patchwork-process-083081@patchwork2.kernel.org Received: from gabe.freedesktop.org (gabe.freedesktop.org [131.252.210.177]) by patchwork2.kernel.org (Postfix) with ESMTP id EBD72DF215 for ; Thu, 14 Mar 2013 00:20:50 +0000 (UTC) Received: from gabe.freedesktop.org (localhost [127.0.0.1]) by gabe.freedesktop.org (Postfix) with ESMTP id D9760E5C6D for ; Wed, 13 Mar 2013 17:20:50 -0700 (PDT) X-Original-To: intel-gfx@lists.freedesktop.org Delivered-To: intel-gfx@lists.freedesktop.org Received: from shiva.localdomain (209-20-75-48.static.cloud-ips.com [209.20.75.48]) by gabe.freedesktop.org (Postfix) with ESMTP id A1571E5CE8 for ; Wed, 13 Mar 2013 17:19:18 -0700 (PDT) Received: by shiva.localdomain (Postfix, from userid 1005) id 3D27F8C06E; Thu, 14 Mar 2013 00:19:18 +0000 (UTC) X-Spam-Checker-Version: SpamAssassin 3.3.2 (2011-06-06) on shiva.chad-versace.us X-Spam-Level: X-Spam-Status: No, score=-2.9 required=5.0 tests=ALL_TRUSTED,BAYES_00, URIBL_BLOCKED autolearn=ham version=3.3.2 Received: from localhost.localdomain (unknown [67.232.160.146]) by shiva.localdomain (Postfix) with ESMTPSA id 690998C050; Thu, 14 Mar 2013 00:19:17 +0000 (UTC) From: Ben Widawsky To: intel-gfx@lists.freedesktop.org Date: Wed, 13 Mar 2013 17:21:08 -0700 Message-Id: <1363220468-1718-4-git-send-email-ben@bwidawsk.net> X-Mailer: git-send-email 1.8.1.5 In-Reply-To: <1363220468-1718-1-git-send-email-ben@bwidawsk.net> References: <1363220468-1718-1-git-send-email-ben@bwidawsk.net> Cc: Ben Widawsky Subject: [Intel-gfx] [PATCH 4/4] drm/i915: Extract object reserver/reloc/bind X-BeenThere: intel-gfx@lists.freedesktop.org X-Mailman-Version: 2.1.13 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 These operations are all quite similar and moving them to a separate function provides a clean split if we want to do something other than immediately binding the work into the ring. Signed-off-by: Ben Widawsky --- drivers/gpu/drm/i915/i915_gem_execbuffer.c | 77 ++++++++++++++++-------------- 1 file changed, 42 insertions(+), 35 deletions(-) diff --git a/drivers/gpu/drm/i915/i915_gem_execbuffer.c b/drivers/gpu/drm/i915/i915_gem_execbuffer.c index 99ebb36..35f6bf3 100644 --- a/drivers/gpu/drm/i915/i915_gem_execbuffer.c +++ b/drivers/gpu/drm/i915/i915_gem_execbuffer.c @@ -827,6 +827,47 @@ i915_reset_gen7_sol_offsets(struct drm_device *dev, return 0; } +/* Move the objects en-masse into the GTT, evicting if necessary. */ +static bool +prepare_objects(struct eb_objects *eb, struct drm_i915_gem_object *batch_obj, + u32 flags) +{ + bool need_relocs = (eb->args->flags & I915_EXEC_NO_RELOC) == 0; + int ret; + + ret = i915_gem_execbuffer_reserve(eb->ring, &eb->objects, &need_relocs); + if (ret) + return ret; + + /* The objects are in their final locations, apply the relocations. */ + if (need_relocs) + ret = i915_gem_execbuffer_relocate(eb); + if (ret) { + if (ret == -EFAULT) { + ret = i915_gem_execbuffer_relocate_slow(eb); + BUG_ON(!mutex_is_locked(&eb->ring->dev->struct_mutex)); + } + if (ret) + return ret; + } + + /* Set the pending read domains for the batch buffer to COMMAND */ + if (batch_obj->base.pending_write_domain) { + DRM_DEBUG("Attempting to use self-modifying batch buffer\n"); + return -EINVAL; + } + batch_obj->base.pending_read_domains |= I915_GEM_DOMAIN_COMMAND; + + /* snb/ivb/vlv conflate the "batch in ppgtt" bit with the "non-secure + * batch" bit. Hence we need to pin secure batches into the global gtt. + * hsw should have this fixed, but let's be paranoid and do it + * unconditionally for now. */ + if (flags & I915_DISPATCH_SECURE && !batch_obj->has_global_gtt_mapping) + i915_gem_gtt_bind_object(batch_obj, batch_obj->cache_level); + + return i915_gem_execbuffer_move_to_gpu(eb->ring, &eb->objects); +} + static int i915_gem_do_execbuffer(struct drm_device *dev, void *data, struct drm_file *file, @@ -842,7 +883,6 @@ i915_gem_do_execbuffer(struct drm_device *dev, void *data, u32 exec_start, exec_len; u32 mask, flags; int ret, mode, i; - bool need_relocs; if (!i915_gem_check_execbuffer(args)) return -EINVAL; @@ -987,40 +1027,7 @@ i915_gem_do_execbuffer(struct drm_device *dev, void *data, struct drm_i915_gem_object, exec_list); - /* Move the objects en-masse into the GTT, evicting if necessary. */ - need_relocs = (args->flags & I915_EXEC_NO_RELOC) == 0; - ret = i915_gem_execbuffer_reserve(ring, &eb->objects, &need_relocs); - if (ret) - goto err; - - /* The objects are in their final locations, apply the relocations. */ - if (need_relocs) - ret = i915_gem_execbuffer_relocate(eb); - if (ret) { - if (ret == -EFAULT) { - ret = i915_gem_execbuffer_relocate_slow(eb); - BUG_ON(!mutex_is_locked(&dev->struct_mutex)); - } - if (ret) - goto err; - } - - /* Set the pending read domains for the batch buffer to COMMAND */ - if (batch_obj->base.pending_write_domain) { - DRM_DEBUG("Attempting to use self-modifying batch buffer\n"); - ret = -EINVAL; - goto err; - } - batch_obj->base.pending_read_domains |= I915_GEM_DOMAIN_COMMAND; - - /* snb/ivb/vlv conflate the "batch in ppgtt" bit with the "non-secure - * batch" bit. Hence we need to pin secure batches into the global gtt. - * hsw should have this fixed, but let's be paranoid and do it - * unconditionally for now. */ - if (flags & I915_DISPATCH_SECURE && !batch_obj->has_global_gtt_mapping) - i915_gem_gtt_bind_object(batch_obj, batch_obj->cache_level); - - ret = i915_gem_execbuffer_move_to_gpu(ring, &eb->objects); + ret = prepare_objects(eb, batch_obj, flags); if (ret) goto err;