From patchwork Thu Nov 22 10:51:29 2012 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Mika Kuoppala X-Patchwork-Id: 1783431 Return-Path: X-Original-To: patchwork-intel-gfx@patchwork.kernel.org Delivered-To: patchwork-process-083081@patchwork1.kernel.org Received: from gabe.freedesktop.org (gabe.freedesktop.org [131.252.210.177]) by patchwork1.kernel.org (Postfix) with ESMTP id 677033FC64 for ; Thu, 22 Nov 2012 11:08:03 +0000 (UTC) Received: from gabe.freedesktop.org (localhost [127.0.0.1]) by gabe.freedesktop.org (Postfix) with ESMTP id 5999FE5EA0 for ; Thu, 22 Nov 2012 03:08:03 -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 C2120E5E07 for ; Thu, 22 Nov 2012 02:51:46 -0800 (PST) Received: from orsmga002.jf.intel.com ([10.7.209.21]) by orsmga102.jf.intel.com with ESMTP; 22 Nov 2012 02:51:05 -0800 X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="4.83,299,1352102400"; d="scan'208";a="245762826" Received: from rosetta.fi.intel.com (HELO rosetta) ([10.237.72.62]) by orsmga002.jf.intel.com with ESMTP; 22 Nov 2012 02:51:30 -0800 Received: by rosetta (Postfix, from userid 1000) id 07202644EC3; Thu, 22 Nov 2012 12:51:34 +0200 (EET) From: Mika Kuoppala To: intel-gfx@lists.freedesktop.org Date: Thu, 22 Nov 2012 12:51:29 +0200 Message-Id: <1353581490-5822-5-git-send-email-mika.kuoppala@intel.com> X-Mailer: git-send-email 1.7.9.5 In-Reply-To: <1353581490-5822-1-git-send-email-mika.kuoppala@intel.com> References: <1353581490-5822-1-git-send-email-mika.kuoppala@intel.com> Cc: Mika Kuoppala Subject: [Intel-gfx] [PATCH 4/5] drm/i915: Allocate seqno conditionally in i915_add_request 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 If seqno already exists, add request with that seqno. Otherwise allocate new seqno for this request. Make i915_gem_check_olr use already allocated seqnos in order to avoid nesting into i915_gem_alloc_seqno during i915_gem_idle(). Signed-off-by: Mika Kuoppala --- drivers/gpu/drm/i915/i915_gem.c | 28 ++++++++++++++++----------- drivers/gpu/drm/i915/i915_gem_execbuffer.c | 29 ++++++++++------------------ 2 files changed, 27 insertions(+), 30 deletions(-) diff --git a/drivers/gpu/drm/i915/i915_gem.c b/drivers/gpu/drm/i915/i915_gem.c index a637d5d..858f14f 100644 --- a/drivers/gpu/drm/i915/i915_gem.c +++ b/drivers/gpu/drm/i915/i915_gem.c @@ -981,7 +981,7 @@ i915_gem_check_olr(struct intel_ring_buffer *ring, u32 seqno) ret = 0; if (seqno == ring->outstanding_lazy_request) - ret = i915_add_request(ring, NULL, NULL); + ret = i915_add_request(ring, NULL, &seqno); return ret; } @@ -1942,7 +1942,7 @@ i915_gem_handle_seqno_wrap(struct drm_device *dev) int i; /* The GPU can not handle its semaphore value wrapping, - + * so every billion or so execbuffers, we need to stall + * so every billion or so execbuffers, we need to stall * the GPU in order to reset the counters. */ @@ -1967,10 +1967,6 @@ i915_gem_get_seqno(struct drm_device *dev) drm_i915_private_t *dev_priv = dev->dev_private; u32 seqno = dev_priv->next_seqno; - /* reserve 0 for non-seqno */ - if (++dev_priv->next_seqno == 0) - dev_priv->next_seqno = 1; - return seqno; } @@ -2009,7 +2005,7 @@ i915_gem_alloc_seqno(struct intel_ring_buffer *ring, u32 *seqno) int i915_add_request(struct intel_ring_buffer *ring, struct drm_file *file, - u32 *out_seqno) + u32 *req_seqno) { drm_i915_private_t *dev_priv = ring->dev->dev_private; struct drm_i915_gem_request *request; @@ -2029,12 +2025,21 @@ i915_add_request(struct intel_ring_buffer *ring, if (ret) return ret; + if (req_seqno) + seqno = *req_seqno; + else + seqno = 0; + + if (seqno == 0) { + ret = i915_gem_alloc_seqno(ring, &seqno); + if (ret) + return ret; + } + request = kmalloc(sizeof(*request), GFP_KERNEL); if (request == NULL) return -ENOMEM; - seqno = i915_gem_next_request_seqno(ring); - /* 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 @@ -2083,8 +2088,9 @@ i915_add_request(struct intel_ring_buffer *ring, } } - if (out_seqno) - *out_seqno = seqno; + if (req_seqno) + *req_seqno = seqno; + return 0; } diff --git a/drivers/gpu/drm/i915/i915_gem_execbuffer.c b/drivers/gpu/drm/i915/i915_gem_execbuffer.c index 3eea143..07582f9 100644 --- a/drivers/gpu/drm/i915/i915_gem_execbuffer.c +++ b/drivers/gpu/drm/i915/i915_gem_execbuffer.c @@ -750,13 +750,14 @@ i915_gem_execbuffer_move_to_active(struct list_head *objects, static void i915_gem_execbuffer_retire_commands(struct drm_device *dev, struct drm_file *file, - struct intel_ring_buffer *ring) + struct intel_ring_buffer *ring, + u32 seqno) { /* Unconditionally force add_request to emit a full flush. */ ring->gpu_caches_dirty = true; /* Add a breadcrumb for the completion of the batch buffer */ - (void)i915_add_request(ring, file, NULL); + (void)i915_add_request(ring, file, &seqno); } static int @@ -910,6 +911,12 @@ i915_gem_do_execbuffer(struct drm_device *dev, void *data, if (ret) goto pre_mutex_err; + ret = i915_gem_alloc_seqno(ring, &seqno); + if (ret) { + mutex_unlock(&dev->struct_mutex); + goto pre_mutex_err; + } + if (dev_priv->mm.suspended) { mutex_unlock(&dev->struct_mutex); ret = -EBUSY; @@ -987,22 +994,6 @@ i915_gem_do_execbuffer(struct drm_device *dev, void *data, if (ret) goto err; - seqno = i915_gem_next_request_seqno(ring); - for (i = 0; i < ARRAY_SIZE(ring->sync_seqno); i++) { - if (seqno < ring->sync_seqno[i]) { - /* The GPU can not handle its semaphore value wrapping, - * so every billion or so execbuffers, we need to stall - * the GPU in order to reset the counters. - */ - ret = i915_gpu_idle(dev); - if (ret) - goto err; - i915_gem_retire_requests(dev); - - BUG_ON(ring->sync_seqno[i]); - } - } - ret = i915_switch_context(ring, file, ctx_id); if (ret) goto err; @@ -1051,7 +1042,7 @@ i915_gem_do_execbuffer(struct drm_device *dev, void *data, } i915_gem_execbuffer_move_to_active(&objects, ring, seqno); - i915_gem_execbuffer_retire_commands(dev, file, ring); + i915_gem_execbuffer_retire_commands(dev, file, ring, seqno); err: eb_destroy(eb);