From patchwork Sun Aug 14 17:44:41 2016 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Chris Wilson X-Patchwork-Id: 9279519 Return-Path: Received: from mail.wl.linuxfoundation.org (pdx-wl-mail.web.codeaurora.org [172.30.200.125]) by pdx-korg-patchwork.web.codeaurora.org (Postfix) with ESMTP id 3C8F660231 for ; Sun, 14 Aug 2016 17:44:55 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 3007328A33 for ; Sun, 14 Aug 2016 17:44:55 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 24B5E28A58; Sun, 14 Aug 2016 17:44:55 +0000 (UTC) X-Spam-Checker-Version: SpamAssassin 3.3.1 (2010-03-16) on pdx-wl-mail.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-4.1 required=2.0 tests=BAYES_00,DKIM_SIGNED, RCVD_IN_DNSWL_MED,T_DKIM_INVALID autolearn=ham version=3.3.1 Received: from gabe.freedesktop.org (gabe.freedesktop.org [131.252.210.177]) (using TLSv1.2 with cipher DHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mail.wl.linuxfoundation.org (Postfix) with ESMTPS id DB8BF28A33 for ; Sun, 14 Aug 2016 17:44:54 +0000 (UTC) Received: from gabe.freedesktop.org (localhost [127.0.0.1]) by gabe.freedesktop.org (Postfix) with ESMTP id 309546E134; Sun, 14 Aug 2016 17:44:54 +0000 (UTC) X-Original-To: intel-gfx@lists.freedesktop.org Delivered-To: intel-gfx@lists.freedesktop.org Received: from mail-wm0-x241.google.com (mail-wm0-x241.google.com [IPv6:2a00:1450:400c:c09::241]) by gabe.freedesktop.org (Postfix) with ESMTPS id 159496E134 for ; Sun, 14 Aug 2016 17:44:51 +0000 (UTC) Received: by mail-wm0-x241.google.com with SMTP id i5so7332186wmg.2 for ; Sun, 14 Aug 2016 10:44:51 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20120113; h=sender:from:to:cc:subject:date:message-id:in-reply-to:references; bh=DiDjd4vxjpefnLm7bHdv9UsP59vC5xgg2CxKwEEWt9M=; b=kgNtQB4pi35ivpYp9vr3S7ERrDR69f2eL8hlPc9NGBzLUn0wXln6xsX0qSoV1C9Cax YqcnZheq66DQrim439yI2xdcOmdDmqCcyUYOpoKY3qbIqsV1VaB1SK2swpuSnukygIke NwxYEiUvYIND8Lf208B5Lxg5xYkVlFXcfF5TxaewXO8rZmbkqR/63iggAmThYNReVF1X YWBjTx7ZNuAtUGTJAgjIxmSxFXhUoMh/+LKmyxgMZ1DDpT9I8+Hj4gtvHA40yoMFnfon 5Kt6FuJVNDWY41wIn52dmO2i6UoTGEwhc2p14Pdoool/VSh4UZXGJHvcUAYS5+1SrL+f 83Kg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20130820; h=x-gm-message-state:sender:from:to:cc:subject:date:message-id :in-reply-to:references; bh=DiDjd4vxjpefnLm7bHdv9UsP59vC5xgg2CxKwEEWt9M=; b=SzI5wSyz/UgNF0N+NCQnn286tEK1kIjBckW7sVcTwnujIJI9j7pG1aAvwi7OXwtXbU tSncj3Ufqljozar82d+L61dIi345upWKnZqmm/dHxZPKWDuRwnke7+hjWauidWt0T2us eNf48ZQka3EI3dwT+0ZZmkjXgxvZADz66g+6GVXQKl+VOohGj2JvqSoulODimsccuJgV pGSvUhOXqM0xtYD5VQkED1a89RCu2F8bJNWSOmYKTTHAlBIxFz7pgpSPTblsXwxM2SBt Pq4/TxoQhml5neE7HV55kW8jxut8os3w/9GSl2Y7qVdm7TWYQER0GSocrd3DnKCtXERI eIJA== X-Gm-Message-State: AEkoouu3YFAEv7NJJ6Egwk8x8FoHl2XkFS6EOjE0WgEMZu3nQ9RbfLizCkfXyddUPG2nLw== X-Received: by 10.28.238.154 with SMTP id j26mr10923545wmi.94.1471196689704; Sun, 14 Aug 2016 10:44:49 -0700 (PDT) Received: from haswell.alporthouse.com ([78.156.65.138]) by smtp.gmail.com with ESMTPSA id d80sm12619266wmd.14.2016.08.14.10.44.48 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Sun, 14 Aug 2016 10:44:48 -0700 (PDT) From: Chris Wilson To: intel-gfx@lists.freedesktop.org Date: Sun, 14 Aug 2016 18:44:41 +0100 Message-Id: <1471196681-30043-2-git-send-email-chris@chris-wilson.co.uk> X-Mailer: git-send-email 2.8.1 In-Reply-To: <1471196681-30043-1-git-send-email-chris@chris-wilson.co.uk> References: <1471196681-30043-1-git-send-email-chris@chris-wilson.co.uk> Cc: Matthew Auld Subject: [Intel-gfx] [PATCH 2/2] drm/i915: Unbind closed vma for i915_gem_object_unbind() 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-Virus-Scanned: ClamAV using ClamSMTP Closed vma are removed from the obj->vma_list so that they cannot be found by userspace. However, this means that when forcibly unbinding an object, we have to wait upon all rendering to that object first in order for the closed, but active, vma to be reaped and their bindings removed. Reported-by: Matthew Auld References: https://bugs.freedesktop.org/show_bug.cgi?id=97343 Fixes: aa653a685d81 ("drm/i915: Be more careful when unbinding vma") Signed-off-by: Chris Wilson Cc: Matthew Auld Reviewed-by: Matthew Auld Tested-by: Matthew Auld --- drivers/gpu/drm/i915/i915_gem.c | 14 +++++++++++--- 1 file changed, 11 insertions(+), 3 deletions(-) diff --git a/drivers/gpu/drm/i915/i915_gem.c b/drivers/gpu/drm/i915/i915_gem.c index 53942d760bdc..c3ae0258a26b 100644 --- a/drivers/gpu/drm/i915/i915_gem.c +++ b/drivers/gpu/drm/i915/i915_gem.c @@ -283,11 +283,19 @@ int i915_gem_object_unbind(struct drm_i915_gem_object *obj) { struct i915_vma *vma; LIST_HEAD(still_in_list); - int ret = 0; + int ret; - /* The vma will only be freed if it is marked as closed, and if we wait - * upon rendering to the vma, we may unbind anything in the list. + /* Closed vma are removed from the obj->vma_list - but they may + * still have an active binding on the object. To remove those we + * must wait for all rendering to complete to the object (as unbinding + * must anyway), and retire the requests. */ + ret = i915_gem_object_wait_rendering(obj, false); + if (ret) + return ret; + + i915_gem_retire_requests(to_i915(obj->base.dev)); + while ((vma = list_first_entry_or_null(&obj->vma_list, struct i915_vma, obj_link))) {