From patchwork Thu Feb 19 16:18:54 2015 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Mika Kuoppala X-Patchwork-Id: 5852481 Return-Path: X-Original-To: patchwork-intel-gfx@patchwork.kernel.org Delivered-To: patchwork-parsemail@patchwork2.web.kernel.org Received: from mail.kernel.org (mail.kernel.org [198.145.29.136]) by patchwork2.web.kernel.org (Postfix) with ESMTP id E459EBF440 for ; Thu, 19 Feb 2015 16:19:20 +0000 (UTC) Received: from mail.kernel.org (localhost [127.0.0.1]) by mail.kernel.org (Postfix) with ESMTP id F3FB520272 for ; Thu, 19 Feb 2015 16:19:19 +0000 (UTC) Received: from gabe.freedesktop.org (gabe.freedesktop.org [131.252.210.177]) by mail.kernel.org (Postfix) with ESMTP id DC3A72025A for ; Thu, 19 Feb 2015 16:19:18 +0000 (UTC) Received: from gabe.freedesktop.org (localhost [127.0.0.1]) by gabe.freedesktop.org (Postfix) with ESMTP id 3578B6E5E2; Thu, 19 Feb 2015 08:19:18 -0800 (PST) X-Original-To: intel-gfx@lists.freedesktop.org Delivered-To: intel-gfx@lists.freedesktop.org Received: from mga09.intel.com (mga09.intel.com [134.134.136.24]) by gabe.freedesktop.org (Postfix) with ESMTP id 099416E5E2 for ; Thu, 19 Feb 2015 08:19:16 -0800 (PST) Received: from orsmga002.jf.intel.com ([10.7.209.21]) by orsmga102.jf.intel.com with ESMTP; 19 Feb 2015 08:14:52 -0800 X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="5.09,609,1418112000"; d="scan'208";a="687962365" Received: from rosetta.fi.intel.com (HELO rosetta) ([10.237.72.54]) by orsmga002.jf.intel.com with ESMTP; 19 Feb 2015 08:18:57 -0800 Received: by rosetta (Postfix, from userid 1000) id 1401180052; Thu, 19 Feb 2015 18:18:56 +0200 (EET) From: Mika Kuoppala To: intel-gfx@lists.freedesktop.org Date: Thu, 19 Feb 2015 18:18:54 +0200 Message-Id: <1424362735-10569-1-git-send-email-mika.kuoppala@intel.com> X-Mailer: git-send-email 1.9.1 Cc: miku@iki.fi Subject: [Intel-gfx] [PATCH 1/2] drm/i915: Split adding request to smaller functions X-BeenThere: intel-gfx@lists.freedesktop.org X-Mailman-Version: 2.1.18 Precedence: list List-Id: Intel graphics driver community testing & development List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , MIME-Version: 1.0 Errors-To: intel-gfx-bounces@lists.freedesktop.org Sender: "Intel-gfx" X-Spam-Status: No, score=-4.2 required=5.0 tests=BAYES_00, RCVD_IN_DNSWL_MED, T_RP_MATCHES_RCVD, UNPARSEABLE_RELAY autolearn=unavailable version=3.3.1 X-Spam-Checker-Version: SpamAssassin 3.3.1 (2010-03-16) on mail.kernel.org X-Virus-Scanned: ClamAV using ClamSMTP Clean __i915_add_request by splitting request submission to preparation, actual submission and adding to client. While doing this we can remove the request->start which was not used. Cc: Chris Wilson Signed-off-by: Mika Kuoppala --- drivers/gpu/drm/i915/i915_gem.c | 116 +++++++++++++++++++++++++++------------- 1 file changed, 78 insertions(+), 38 deletions(-) diff --git a/drivers/gpu/drm/i915/i915_gem.c b/drivers/gpu/drm/i915/i915_gem.c index 61134ab..06265e7 100644 --- a/drivers/gpu/drm/i915/i915_gem.c +++ b/drivers/gpu/drm/i915/i915_gem.c @@ -2407,26 +2407,34 @@ i915_gem_get_seqno(struct drm_device *dev, u32 *seqno) return 0; } -int __i915_add_request(struct intel_engine_cs *ring, - struct drm_file *file, - struct drm_i915_gem_object *obj) +static struct intel_ringbuffer * +__request_to_ringbuf(struct drm_i915_gem_request *request) +{ + if (i915.enable_execlists) + return request->ctx->engine[request->ring->id].ringbuf; + + return request->ring->buffer; +} + +static struct drm_i915_gem_request * +i915_gem_request_prepare(struct intel_engine_cs *ring, struct drm_file *file) { - struct drm_i915_private *dev_priv = ring->dev->dev_private; struct drm_i915_gem_request *request; struct intel_ringbuffer *ringbuf; - u32 request_start; int ret; request = ring->outstanding_lazy_request; if (WARN_ON(request == NULL)) - return -ENOMEM; + return ERR_PTR(-ENOMEM); - if (i915.enable_execlists) { - ringbuf = request->ctx->engine[ring->id].ringbuf; - } else - ringbuf = ring->buffer; + /* execlist submission has this already set */ + if (!request->ctx) + request->ctx = ring->last_context; + + ringbuf = __request_to_ringbuf(request); + if (WARN_ON(ringbuf == NULL)) + return ERR_PTR(-EIO); - request_start = intel_ring_get_tail(ringbuf); /* * Emit any outstanding flushes - execbuf can fail to emit the flush * after having emitted the batchbuffer command. Hence we need to fix @@ -2434,21 +2442,30 @@ int __i915_add_request(struct intel_engine_cs *ring, * is that the flush _must_ happen before the next request, no matter * what. */ - if (i915.enable_execlists) { + if (i915.enable_execlists) ret = logical_ring_flush_all_caches(ringbuf, request->ctx); - if (ret) - return ret; - } else { + else ret = intel_ring_flush_all_caches(ring); - if (ret) - return ret; - } + + if (ret) + return ERR_PTR(ret); + + return request; +} + +static int i915_gem_request_submit(struct drm_i915_gem_request *request, + struct drm_i915_gem_object *batch) +{ + struct intel_ringbuffer *ringbuf = __request_to_ringbuf(request); + struct intel_engine_cs *ring = request->ring; + int ret; /* Record the position of the start of the request so that * should we detect the updated seqno part-way through the * GPU processing the request, we never over-estimate the * position of the head. */ + request->batch_obj = batch; request->postfix = intel_ring_get_tail(ringbuf); if (i915.enable_execlists) { @@ -2461,7 +2478,6 @@ int __i915_add_request(struct intel_engine_cs *ring, return ret; } - request->head = request_start; request->tail = intel_ring_get_tail(ringbuf); /* Whilst this request exists, batch_obj will be on the @@ -2470,35 +2486,59 @@ int __i915_add_request(struct intel_engine_cs *ring, * inactive_list and lose its active reference. Hence we do not need * to explicitly hold another reference here. */ - request->batch_obj = obj; - if (!i915.enable_execlists) { - /* Hold a reference to the current context so that we can inspect - * it later in case a hangcheck error event fires. + if (!i915.enable_execlists && request->ctx) { + /* Hold a reference to the current context so that we can + * inspect it later in case a hangcheck error event fires. */ - request->ctx = ring->last_context; - if (request->ctx) - i915_gem_context_reference(request->ctx); + i915_gem_context_reference(request->ctx); } request->emitted_jiffies = jiffies; + list_add_tail(&request->list, &ring->request_list); - request->file_priv = NULL; + ring->outstanding_lazy_request = NULL; - if (file) { - struct drm_i915_file_private *file_priv = file->driver_priv; + trace_i915_gem_request_add(request); - spin_lock(&file_priv->mm.lock); - request->file_priv = file_priv; - list_add_tail(&request->client_list, - &file_priv->mm.request_list); - spin_unlock(&file_priv->mm.lock); + return 0; +} - request->pid = get_pid(task_pid(current)); - } +static void i915_gem_request_add_to_client(struct drm_i915_gem_request *request) +{ + struct drm_i915_file_private *file_priv; - trace_i915_gem_request_add(request); - ring->outstanding_lazy_request = NULL; + if (!request->file_priv) + return; + + file_priv = request->file_priv; + + spin_lock(&file_priv->mm.lock); + request->file_priv = file_priv; + list_add_tail(&request->client_list, + &file_priv->mm.request_list); + spin_unlock(&file_priv->mm.lock); + + request->pid = get_pid(task_pid(current)); +} + +int __i915_add_request(struct intel_engine_cs *ring, + struct drm_file *file, + struct drm_i915_gem_object *batch) +{ + struct drm_i915_private *dev_priv = ring->dev->dev_private; + struct drm_i915_gem_request *request; + int ret; + + request = i915_gem_request_prepare(ring, file); + if (IS_ERR(request)) + return PTR_ERR(request); + + ret = i915_gem_request_submit(request, batch); + if (ret) + return ret; + + i915_gem_request_add_to_client(request); i915_queue_hangcheck(ring->dev);