From patchwork Fri Jan 15 12:24:15 2010 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Daniel Vetter X-Patchwork-Id: 73155 Received: from gabe.freedesktop.org (gabe.freedesktop.org [131.252.210.177]) by demeter.kernel.org (8.14.3/8.14.2) with ESMTP id o0FCORpi003288 for ; Fri, 15 Jan 2010 12:24:27 GMT Received: from gabe.freedesktop.org (localhost [127.0.0.1]) by gabe.freedesktop.org (Postfix) with ESMTP id 329A79F3BD; Fri, 15 Jan 2010 04:24:27 -0800 (PST) X-Original-To: intel-gfx@lists.freedesktop.org Delivered-To: intel-gfx@lists.freedesktop.org Received: from mail.ffwll.ch (cable-static-49-187.intergga.ch [157.161.49.187]) by gabe.freedesktop.org (Postfix) with ESMTP id 36EB39F4DB for ; Fri, 15 Jan 2010 04:24:21 -0800 (PST) Received: by mail.ffwll.ch (Postfix, from userid 1000) id 67F3520C230; Fri, 15 Jan 2010 13:24:20 +0100 (CET) X-Spam-ASN: X-Spam-Checker-Version: SpamAssassin 3.2.5 (2008-06-10) on orange.ffwll.ch X-Spam-Level: X-Spam-Hammy: 0.000-+--struct, 0.000-+--signed-off-by, 0.000-+--signedoffby X-Spam-Status: No, score=-1.2 required=6.0 tests=ALL_TRUSTED,BAYES_00, FH_DATE_PAST_20XX autolearn=no version=3.2.5 X-Spam-Spammy: 0.967-+--H*m:ffwll, 0.964-+--H*Ad:U*daniel.vetter, 0.953-+--H*r:mail.ffwll.ch Received: from biene (unknown [192.168.23.129]) by mail.ffwll.ch (Postfix) with ESMTP id D1AA620C223; Fri, 15 Jan 2010 13:23:55 +0100 (CET) Received: from daniel by biene with local (Exim 4.71) (envelope-from ) id 1NVlE3-0003hS-0F; Fri, 15 Jan 2010 13:24:27 +0100 From: Daniel Vetter To: intel-gfx@lists.freedesktop.org Date: Fri, 15 Jan 2010 13:24:15 +0100 Message-Id: <218f84ba918f387762e080160db19fbf90b63462.1263558064.git.daniel.vetter@ffwll.ch> X-Mailer: git-send-email 1.6.6 In-Reply-To: References: <74471ded981086a7e563554dd9d0ea490fb31a88.1263558064.git.daniel.vetter@ffwll.ch> <102f9fb63e13a34928c5fd4c1c42f2c578357d65.1263558064.git.daniel.vetter@ffwll.ch> <696000111f936935bff77e578594e1adbadd4811.1263558064.git.daniel.vetter@ffwll.ch> <4b6704aae352dc67313813a3aff309a51c84d8e8.1263558064.git.daniel.vetter@ffwll.ch> In-Reply-To: References: Cc: Daniel Vetter Subject: [Intel-gfx] [PATCH 08/11] drm/i915: fixup i915_gem_evict_everything to actually evict everything X-BeenThere: intel-gfx@lists.freedesktop.org X-Mailman-Version: 2.1.9 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@lists.freedesktop.org Errors-To: intel-gfx-bounces@lists.freedesktop.org diff --git a/drivers/gpu/drm/i915/i915_gem.c b/drivers/gpu/drm/i915/i915_gem.c index d8812ce..6bf4481 100644 --- a/drivers/gpu/drm/i915/i915_gem.c +++ b/drivers/gpu/drm/i915/i915_gem.c @@ -2103,32 +2103,61 @@ i915_gem_find_inactive_object(struct drm_device *dev, int min_size) } static int -i915_gem_evict_everything(struct drm_device *dev) +i915_gpu_idle(struct drm_device *dev) { drm_i915_private_t *dev_priv = dev->dev_private; + bool lists_empty; uint32_t seqno; int ret; - bool lists_empty; spin_lock(&dev_priv->mm.active_list_lock); - lists_empty = (list_empty(&dev_priv->mm.inactive_list) && - list_empty(&dev_priv->mm.flushing_list) && - list_empty(&dev_priv->mm.active_list)); + lists_empty = list_empty(&dev_priv->mm.flushing_list) && + list_empty(&dev_priv->mm.active_list); spin_unlock(&dev_priv->mm.active_list_lock); if (lists_empty) - return -ENOSPC; + return 0; - /* Flush everything (on to the inactive lists) and evict */ - i915_gem_flush(dev, I915_GEM_GPU_DOMAINS, I915_GEM_GPU_DOMAINS); + /* Wait for any outstanding rendering to complete ... */ seqno = i915_add_request(dev, NULL, I915_GEM_GPU_DOMAINS); if (seqno == 0) return -ENOMEM; ret = i915_wait_request(dev, seqno); + if (ret != 0) + return ret; + + /* ... and flush everything onto the inactive list. */ + i915_gem_flush(dev, I915_GEM_GPU_DOMAINS, I915_GEM_GPU_DOMAINS); + seqno = i915_add_request(dev, NULL, I915_GEM_GPU_DOMAINS); + if (seqno == 0) + return -ENOMEM; + + return i915_wait_request(dev, seqno); +} + +static int +i915_gem_evict_everything(struct drm_device *dev) +{ + drm_i915_private_t *dev_priv = dev->dev_private; + int ret; + bool lists_empty; + + spin_lock(&dev_priv->mm.active_list_lock); + lists_empty = (list_empty(&dev_priv->mm.inactive_list) && + list_empty(&dev_priv->mm.flushing_list) && + list_empty(&dev_priv->mm.active_list)); + spin_unlock(&dev_priv->mm.active_list_lock); + + if (lists_empty) + return -ENOSPC; + + ret = i915_gpu_idle(dev); if (ret) return ret; + BUG_ON(!list_empty(&dev_priv->mm.flushing_list)); + ret = i915_gem_evict_from_inactive_list(dev); if (ret) return ret; @@ -4455,30 +4484,6 @@ i915_gem_evict_from_inactive_list(struct drm_device *dev) return 0; } -static int -i915_gpu_idle(struct drm_device *dev) -{ - drm_i915_private_t *dev_priv = dev->dev_private; - bool lists_empty; - uint32_t seqno; - - spin_lock(&dev_priv->mm.active_list_lock); - lists_empty = list_empty(&dev_priv->mm.flushing_list) && - list_empty(&dev_priv->mm.active_list); - spin_unlock(&dev_priv->mm.active_list_lock); - - if (lists_empty) - return 0; - - /* Flush everything onto the inactive list. */ - i915_gem_flush(dev, I915_GEM_GPU_DOMAINS, I915_GEM_GPU_DOMAINS); - seqno = i915_add_request(dev, NULL, I915_GEM_GPU_DOMAINS); - if (seqno == 0) - return -ENOMEM; - - return i915_wait_request(dev, seqno); -} - int i915_gem_idle(struct drm_device *dev) {