From mboxrd@z Thu Jan 1 00:00:00 1970 From: Ben Widawsky Subject: [PATCH 01/48] drm/i915: Fix bad refcounting on execbuf failures Date: Fri, 6 Dec 2013 14:10:46 -0800 Message-ID: <1386367941-7131-1-git-send-email-benjamin.widawsky@intel.com> References: <20131206215521.GA6922@bwidawsk.net> Mime-Version: 1.0 Content-Type: text/plain; charset="us-ascii" Content-Transfer-Encoding: 7bit Return-path: Received: from mail.bwidawsk.net (bwidawsk.net [166.78.191.112]) by gabe.freedesktop.org (Postfix) with ESMTP id 0B666FA682 for ; Fri, 6 Dec 2013 14:12:35 -0800 (PST) In-Reply-To: <20131206215521.GA6922@bwidawsk.net> List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Sender: intel-gfx-bounces@lists.freedesktop.org Errors-To: intel-gfx-bounces@lists.freedesktop.org To: Intel GFX Cc: Ben Widawsky , stable@vger.kernel.org, Ben Widawsky List-Id: intel-gfx@lists.freedesktop.org eb_destroy currently cleans up the refcounts for all the VMAs done at lookup. Currently eb_lookup_vmas cleans up all the *objects* we've looked up. There exists a period of time when we under severe memory pressure, the VMA creation will fail, and fall into our exit path. When the above event occurs, the object list, and eb->vma list are not equal, the latter being a subset of the former. As we attempt to clean up the refcounts on the error path we have the potential to decrement the refcount by one extra here. commit 27173f1f95db5e74ceb35fe9a2f2f348ea11bac9 Author: Ben Widawsky Date: Wed Aug 14 11:38:36 2013 +0200 drm/i915: Convert execbuf code to use vmas NOTE: A patch purporting the same results exists from Chris written to address a quibble he had with something or other in this patch. I have not tested that patch, but if it does the same thing I don't care which is used. Cc: stable@vger.kernel.org Cc: Chris Wilson Signed-off-by: Ben Widawsky --- drivers/gpu/drm/i915/i915_gem_execbuffer.c | 7 +++++++ 1 file changed, 7 insertions(+) diff --git a/drivers/gpu/drm/i915/i915_gem_execbuffer.c b/drivers/gpu/drm/i915/i915_gem_execbuffer.c index f0c590e..cdab6e4 100644 --- a/drivers/gpu/drm/i915/i915_gem_execbuffer.c +++ b/drivers/gpu/drm/i915/i915_gem_execbuffer.c @@ -157,6 +157,13 @@ eb_lookup_vmas(struct eb_vmas *eb, out: + /* eb_vmas are cleaned up by destroy. Others are not */ + if (ret) { + struct i915_vma *vma; + list_for_each_entry(vma, &eb->vmas, exec_list) + list_del(&vma->obj->obj_exec_link); + } + while (!list_empty(&objects)) { obj = list_first_entry(&objects, struct drm_i915_gem_object, -- 1.8.4.2