From mboxrd@z Thu Jan 1 00:00:00 1970 From: Thomas Hellstrom Subject: Re: [PATCH 03/10] drm/ttm: do not check if list is empty in ttm_bo_force_list_clean Date: Mon, 19 Nov 2012 14:33:34 +0100 Message-ID: <50AA352E.9010703@vmware.com> References: <1352728811-21860-1-git-send-email-maarten.lankhorst@canonical.com> <1352728811-21860-3-git-send-email-maarten.lankhorst@canonical.com> Mime-Version: 1.0 Content-Type: text/plain; charset="us-ascii"; Format="flowed" Content-Transfer-Encoding: 7bit Return-path: Received: from smtp-outbound-1.vmware.com (smtp-outbound-1.vmware.com [208.91.2.12]) by gabe.freedesktop.org (Postfix) with ESMTP id DC363E6119 for ; Mon, 19 Nov 2012 05:33:38 -0800 (PST) In-Reply-To: <1352728811-21860-3-git-send-email-maarten.lankhorst@canonical.com> List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Sender: dri-devel-bounces+sf-dri-devel=m.gmane.org@lists.freedesktop.org Errors-To: dri-devel-bounces+sf-dri-devel=m.gmane.org@lists.freedesktop.org To: Maarten Lankhorst Cc: dri-devel@lists.freedesktop.org List-Id: dri-devel@lists.freedesktop.org On 11/12/2012 03:00 PM, Maarten Lankhorst wrote: > Just use the return error from ttm_mem_evict_first instead. Here driver need to be able to evict a memory type completely, because they might shut down the memory type or clear it for some legacy usage, suspending or whatever, so returning 0 on -EBUSY isn't sufficient, we need at least a list empty check, and a shared reservation at this point is illegal. This is a point where the mechanism to exclude other reservers is needed, as we discussed previously. vmwgfx is using the ttm lock, but will of course adapt if a new mechanism is emerging. Thanks, /Thomas > > Signed-off-by: Maarten Lankhorst > --- > drivers/gpu/drm/ttm/ttm_bo.c | 27 ++++++++------------------- > 1 file changed, 8 insertions(+), 19 deletions(-) > > diff --git a/drivers/gpu/drm/ttm/ttm_bo.c b/drivers/gpu/drm/ttm/ttm_bo.c > index 74d6e7c..a3383a7 100644 > --- a/drivers/gpu/drm/ttm/ttm_bo.c > +++ b/drivers/gpu/drm/ttm/ttm_bo.c > @@ -1302,29 +1302,18 @@ EXPORT_SYMBOL(ttm_bo_create); > static int ttm_bo_force_list_clean(struct ttm_bo_device *bdev, > unsigned mem_type, bool allow_errors) > { > - struct ttm_mem_type_manager *man = &bdev->man[mem_type]; > - struct ttm_bo_global *glob = bdev->glob; > - int ret; > - > - /* > - * Can't use standard list traversal since we're unlocking. > - */ > + int ret = 0; > > - spin_lock(&glob->lru_lock); > - while (!list_empty(&man->lru)) { > - spin_unlock(&glob->lru_lock); > + while (!ret) { > ret = ttm_mem_evict_first(bdev, mem_type, false, false, false); > - if (ret) { > - if (allow_errors) { > - return ret; > - } else { > - pr_err("Cleanup eviction failed\n"); > - } > + if (ret == -EBUSY) > + return 0; > + else if (ret && !allow_errors) { > + pr_err("Cleanup eviction failed\n"); > + ret = 0; > } > - spin_lock(&glob->lru_lock); > } > - spin_unlock(&glob->lru_lock); > - return 0; > + return ret; > } > > int ttm_bo_clean_mm(struct ttm_bo_device *bdev, unsigned mem_type)