From patchwork Wed Nov 8 14:59:34 2017 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: =?utf-8?q?Christian_K=C3=B6nig?= X-Patchwork-Id: 10048629 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 5E46460381 for ; Wed, 8 Nov 2017 14:59:47 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 541EB29348 for ; Wed, 8 Nov 2017 14:59:47 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 4889429368; Wed, 8 Nov 2017 14:59:47 +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_ADSP_CUSTOM_MED, DKIM_SIGNED, FREEMAIL_FROM, 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 E26AD29384 for ; Wed, 8 Nov 2017 14:59:46 +0000 (UTC) Received: from gabe.freedesktop.org (localhost [127.0.0.1]) by gabe.freedesktop.org (Postfix) with ESMTP id B04336E6ED; Wed, 8 Nov 2017 14:59:43 +0000 (UTC) X-Original-To: dri-devel@lists.freedesktop.org Delivered-To: dri-devel@lists.freedesktop.org Received: from mail-wm0-x243.google.com (mail-wm0-x243.google.com [IPv6:2a00:1450:400c:c09::243]) by gabe.freedesktop.org (Postfix) with ESMTPS id 83CB96E25C; Wed, 8 Nov 2017 14:59:42 +0000 (UTC) Received: by mail-wm0-x243.google.com with SMTP id p75so11056408wmg.3; Wed, 08 Nov 2017 06:59:42 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=from:to:subject:date:message-id:in-reply-to:references:mime-version :content-transfer-encoding; bh=RfPGYxHFCuAY8zcYevtg7KYvsfn7/MylXpQwBWaD4Ik=; b=fZE1HAdkSCq2ov6VNMEa1FIu41+tHIlDvWBh+mgnSNiLgbYQCJZlUtjWUZijLqKbyI HjXSrHcDi1xnCYc4iU0E3Q9gssHu3dVjiK3f2CcJF24Um27bYVrUFNF0rm3j1L3nwVX6 tOPdo5uvImzBuISOhEvyW+tgwgqbJ4+DSiJdBKVigKwhKtsjwDJ4z0SvjRhAd5DqoI1w XFpF+5Mf/tochyN8jLSxw/XuL3TO3e81YoGGfiwNigglfTqVMB2roHXej9BFTfEwbfri +vF7fVztqXac7m7KFF2npFpBTOc7Mqman2EY+M2hduVxu4tkGE+QtqupmQiIPxY1Uqdh cXfw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:subject:date:message-id:in-reply-to :references:mime-version:content-transfer-encoding; bh=RfPGYxHFCuAY8zcYevtg7KYvsfn7/MylXpQwBWaD4Ik=; b=G27vthQXt9PRdMqWym+CsAb4EmvV0vx8XlR8fMbHn2o09yiC+6RvSavlgDz+kAJmaW AJu8V6gVKUMFF5ior5jQaoy83SGkanJRq9a70lwiZThyDlhPiD1ZOdwizfKFi9kJX21o hdlVLvLEQGZPN4NcItYxSR2INO5WnJgfAWJ5D/Jopv1FovveKiwegS5bVMHEy0DAYqVm zIEK/yHanZgFstoSmWzkjvYTdkw37URRdth/TyAAdJqJRKwNpZ7xe66EQ1vYYvN8L37E 6J266sv5fsBzCa474QpKKyQRE2Heyix6mOABevdHBoBglgNIWoO4hhYbm2VidOkirndh /tTA== X-Gm-Message-State: AJaThX7H31MBEf33i9MkxC/aClighrZNYsPS4jsVOQvHVqxT24VWyv0i lNvGodeiNX6FvcqhsgZEoMUcmw== X-Google-Smtp-Source: ABhQp+QVx7eOzq7SoG7qITIcdimPMsyyd3k+v3SwWih+PMUDWyeDDrpAnt+ZNuxO7ZpTBH8byhF8cw== X-Received: by 10.28.217.130 with SMTP id q124mr736637wmg.30.1510153181029; Wed, 08 Nov 2017 06:59:41 -0800 (PST) Received: from localhost.localdomain ([2a02:908:1251:7981:c04d:fe7d:a3de:74ad]) by smtp.gmail.com with ESMTPSA id 61sm801346wrl.0.2017.11.08.06.59.40 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Wed, 08 Nov 2017 06:59:40 -0800 (PST) From: "=?UTF-8?q?Christian=20K=C3=B6nig?=" X-Google-Original-From: =?UTF-8?q?Christian=20K=C3=B6nig?= To: Hongbo.He@amd.com, amd-gfx@lists.freedesktop.org, dri-devel@lists.freedesktop.org Subject: [PATCH 2/4] drm/ttm: consistently use reservation_object_unlock Date: Wed, 8 Nov 2017 15:59:34 +0100 Message-Id: <20171108145936.27071-2-christian.koenig@amd.com> X-Mailer: git-send-email 2.11.0 In-Reply-To: <20171108145936.27071-1-christian.koenig@amd.com> References: <20171108145936.27071-1-christian.koenig@amd.com> MIME-Version: 1.0 X-BeenThere: dri-devel@lists.freedesktop.org X-Mailman-Version: 2.1.18 Precedence: list List-Id: Direct Rendering Infrastructure - Development List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: dri-devel-bounces@lists.freedesktop.org Sender: "dri-devel" X-Virus-Scanned: ClamAV using ClamSMTP Instead of having a pointless wrapper or call the underlying ww_mutex function directly. Signed-off-by: Christian König --- drivers/gpu/drm/ttm/ttm_bo.c | 13 +++++++------ drivers/gpu/drm/ttm/ttm_execbuf_util.c | 8 ++++---- include/drm/ttm/ttm_bo_driver.h | 14 +------------- 3 files changed, 12 insertions(+), 23 deletions(-) diff --git a/drivers/gpu/drm/ttm/ttm_bo.c b/drivers/gpu/drm/ttm/ttm_bo.c index 9905cf41cba6..6f55310a9d09 100644 --- a/drivers/gpu/drm/ttm/ttm_bo.c +++ b/drivers/gpu/drm/ttm/ttm_bo.c @@ -471,7 +471,7 @@ static void ttm_bo_cleanup_refs_or_queue(struct ttm_buffer_object *bo) ttm_bo_add_to_lru(bo); } - __ttm_bo_unreserve(bo); + reservation_object_unlock(bo->resv); } if (bo->resv != &bo->ttm_resv) reservation_object_unlock(&bo->ttm_resv); @@ -517,7 +517,8 @@ static int ttm_bo_cleanup_refs_and_unlock(struct ttm_buffer_object *bo, if (ret && !no_wait_gpu) { long lret; - ww_mutex_unlock(&bo->resv->lock); + + reservation_object_unlock(bo->resv); spin_unlock(&glob->lru_lock); lret = reservation_object_wait_timeout_rcu(resv, true, @@ -547,7 +548,7 @@ static int ttm_bo_cleanup_refs_and_unlock(struct ttm_buffer_object *bo, } if (ret || unlikely(list_empty(&bo->ddestroy))) { - __ttm_bo_unreserve(bo); + reservation_object_unlock(bo->resv); spin_unlock(&glob->lru_lock); return ret; } @@ -749,7 +750,7 @@ static int ttm_mem_evict_first(struct ttm_bo_device *bdev, if (place && !bdev->driver->eviction_valuable(bo, place)) { - __ttm_bo_unreserve(bo); + reservation_object_unlock(bo->resv); ret = -EBUSY; continue; } @@ -1788,7 +1789,7 @@ static int ttm_bo_swapout(struct ttm_mem_shrink *shrink) * already swapped buffer. */ - __ttm_bo_unreserve(bo); + reservation_object_unlock(bo->resv); kref_put(&bo->list_kref, ttm_bo_release_list); return ret; } @@ -1825,7 +1826,7 @@ int ttm_bo_wait_unreserved(struct ttm_buffer_object *bo) ret = __ttm_bo_reserve(bo, true, false, NULL); if (unlikely(ret != 0)) goto out_unlock; - __ttm_bo_unreserve(bo); + reservation_object_unlock(bo->resv); out_unlock: mutex_unlock(&bo->wu_mutex); diff --git a/drivers/gpu/drm/ttm/ttm_execbuf_util.c b/drivers/gpu/drm/ttm/ttm_execbuf_util.c index 5e1bcabffef5..373ced0b2fc2 100644 --- a/drivers/gpu/drm/ttm/ttm_execbuf_util.c +++ b/drivers/gpu/drm/ttm/ttm_execbuf_util.c @@ -38,7 +38,7 @@ static void ttm_eu_backoff_reservation_reverse(struct list_head *list, list_for_each_entry_continue_reverse(entry, list, head) { struct ttm_buffer_object *bo = entry->bo; - __ttm_bo_unreserve(bo); + reservation_object_unlock(bo->resv); } } @@ -69,7 +69,7 @@ void ttm_eu_backoff_reservation(struct ww_acquire_ctx *ticket, struct ttm_buffer_object *bo = entry->bo; ttm_bo_add_to_lru(bo); - __ttm_bo_unreserve(bo); + reservation_object_unlock(bo->resv); } spin_unlock(&glob->lru_lock); @@ -112,7 +112,7 @@ int ttm_eu_reserve_buffers(struct ww_acquire_ctx *ticket, ret = __ttm_bo_reserve(bo, intr, (ticket == NULL), ticket); if (!ret && unlikely(atomic_read(&bo->cpu_writers) > 0)) { - __ttm_bo_unreserve(bo); + reservation_object_unlock(bo->resv); ret = -EBUSY; @@ -203,7 +203,7 @@ void ttm_eu_fence_buffer_objects(struct ww_acquire_ctx *ticket, else reservation_object_add_excl_fence(bo->resv, fence); ttm_bo_add_to_lru(bo); - __ttm_bo_unreserve(bo); + reservation_object_unlock(bo->resv); } spin_unlock(&glob->lru_lock); if (ticket) diff --git a/include/drm/ttm/ttm_bo_driver.h b/include/drm/ttm/ttm_bo_driver.h index 5f821a9b3a1f..389359a0006b 100644 --- a/include/drm/ttm/ttm_bo_driver.h +++ b/include/drm/ttm/ttm_bo_driver.h @@ -941,18 +941,6 @@ static inline int ttm_bo_reserve_slowpath(struct ttm_buffer_object *bo, } /** - * __ttm_bo_unreserve - * @bo: A pointer to a struct ttm_buffer_object. - * - * Unreserve a previous reservation of @bo where the buffer object is - * already on lru lists. - */ -static inline void __ttm_bo_unreserve(struct ttm_buffer_object *bo) -{ - ww_mutex_unlock(&bo->resv->lock); -} - -/** * ttm_bo_unreserve * * @bo: A pointer to a struct ttm_buffer_object. @@ -966,7 +954,7 @@ static inline void ttm_bo_unreserve(struct ttm_buffer_object *bo) ttm_bo_add_to_lru(bo); spin_unlock(&bo->glob->lru_lock); } - __ttm_bo_unreserve(bo); + reservation_object_unlock(bo->resv); } /**