From patchwork Thu Nov 9 08:59:06 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: 10050517 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 D3F6B60381 for ; Thu, 9 Nov 2017 08:59:24 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id C3DE82ABF3 for ; Thu, 9 Nov 2017 08:59:24 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id B8DFE2ABF6; Thu, 9 Nov 2017 08:59:24 +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 6B70F2ABF3 for ; Thu, 9 Nov 2017 08:59:24 +0000 (UTC) Received: from gabe.freedesktop.org (localhost [127.0.0.1]) by gabe.freedesktop.org (Postfix) with ESMTP id 1D38D6E881; Thu, 9 Nov 2017 08:59:20 +0000 (UTC) X-Original-To: dri-devel@lists.freedesktop.org Delivered-To: dri-devel@lists.freedesktop.org Received: from mail-wr0-x241.google.com (mail-wr0-x241.google.com [IPv6:2a00:1450:400c:c0c::241]) by gabe.freedesktop.org (Postfix) with ESMTPS id D79D96E876; Thu, 9 Nov 2017 08:59:18 +0000 (UTC) Received: by mail-wr0-x241.google.com with SMTP id k61so4877305wrc.4; Thu, 09 Nov 2017 00:59:18 -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=OY0cf0rG0ZGB+Q4Ej4TI0rnEhOcwA+JlD5rHodCMdvQ=; b=G+Hyl55FkmgmkKWUMMSM4OCW0JhIaTErXe4ESkPyBNGMLhLyg1jlJJ3m6UhwjPWUqY 5gPFi03Tux+Ot1VaW3Piw+paZ/2EZ7UVkZwjuvDmo+nb+UDUmzenuf3gZqNOLVQ9N80/ +xBPWzFazUVGG2vzPHQKZzdMQx7eVvPlJMH8Y23JNCn9DoOc8yY/Aa1Y0P44ft689p7z /ebxUq2KWDb1l8LxhQRzvvY349ZIm1mavqanCh2zCvJLZSsAae7BJhPNjO6wsjDAMKfm G0TcmMMEzx9b88Dd46JlBwY0JjHf52bYxdGP+lan0QZ2+GM7qTwJ3atfVB6GqWccMkuN znHQ== 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=OY0cf0rG0ZGB+Q4Ej4TI0rnEhOcwA+JlD5rHodCMdvQ=; b=kkibgPBUK+y7wyHLkmoRGhZLvUvzqCET+1YHgVhsKHFUcm5DehSVT+lTRX9xYMlUn8 j3HdG0ArnG2c3UubmPd0zAaiJYE8xStMBhY/snVvqR7ANeUxXbhYB6pARAzmslN7MFzs z7sOCPl8W50SWTUrbNJr/HLz4TfL9E+jjq1vKF8WN1WjePs36GoKenq2LnBQrTkVLLt6 kGM50N1wNItw5R54x81NQVDs+k/rqpeVJP/QiQlZSEihS1W2jm8oElwN3v1SAdkumV2O 4TmifDpP9ibIXqh8DLJ0XdNPWtirYWCwpu6NFyWj7ztukxEG7Ijkklmb7mkBnL9tYNDq 0xQg== X-Gm-Message-State: AJaThX5U1R3Bp7pPSovyBAOydRn6upGtZKYow17vgLsWL5EwGLCyPgoZ FxBB3Zp53KHbgJVA0c/WNoNQuw== X-Google-Smtp-Source: ABhQp+TObrPUjc8/20nqTlFvQVL6xOalLFtOICi+mC2wXZ1L2SMRwRXVFuQK3nskBgrB/wIvgoXgug== X-Received: by 10.223.163.215 with SMTP id m23mr2390078wrb.220.1510217957134; Thu, 09 Nov 2017 00:59:17 -0800 (PST) Received: from localhost.localdomain ([2a02:908:1251:7981:61f0:1658:ce3b:16a3]) by smtp.gmail.com with ESMTPSA id 69sm8893723wmp.37.2017.11.09.00.59.16 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Thu, 09 Nov 2017 00:59:16 -0800 (PST) From: "=?UTF-8?q?Christian=20K=C3=B6nig?=" X-Google-Original-From: =?UTF-8?q?Christian=20K=C3=B6nig?= To: dri-devel@lists.freedesktop.org, amd-gfx@lists.freedesktop.org, Hongbo.He@amd.com, michel@daenzer.net Subject: [PATCH 4/7] drm/ttm: user reservation object wrappers Date: Thu, 9 Nov 2017 09:59:06 +0100 Message-Id: <20171109085909.1653-4-christian.koenig@amd.com> X-Mailer: git-send-email 2.11.0 In-Reply-To: <20171109085909.1653-1-christian.koenig@amd.com> References: <20171109085909.1653-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 Consistently use the reservation object wrappers instead of accessing the ww_mutex directly. Additional to that use the reservation object wrappers directly instead of calling __ttm_bo_reserve with fixed parameters. Signed-off-by: Christian König --- drivers/gpu/drm/ttm/ttm_bo.c | 16 +++++++++------- include/drm/ttm/ttm_bo_driver.h | 6 +++--- 2 files changed, 12 insertions(+), 10 deletions(-) diff --git a/drivers/gpu/drm/ttm/ttm_bo.c b/drivers/gpu/drm/ttm/ttm_bo.c index 6f55310a9d09..6f5d18366e6e 100644 --- a/drivers/gpu/drm/ttm/ttm_bo.c +++ b/drivers/gpu/drm/ttm/ttm_bo.c @@ -446,7 +446,7 @@ static void ttm_bo_cleanup_refs_or_queue(struct ttm_buffer_object *bo) } spin_lock(&glob->lru_lock); - ret = __ttm_bo_reserve(bo, false, true, NULL); + ret = reservation_object_trylock(bo->resv) ? 0 : -EBUSY; if (!ret) { if (reservation_object_test_signaled_rcu(&bo->ttm_resv, true)) { ttm_bo_del_from_lru(bo); @@ -531,7 +531,7 @@ static int ttm_bo_cleanup_refs_and_unlock(struct ttm_buffer_object *bo, return -EBUSY; spin_lock(&glob->lru_lock); - ret = __ttm_bo_reserve(bo, false, true, NULL); + ret = reservation_object_trylock(bo->resv) ? 0 : -EBUSY; /* * We raced, and lost, someone else holds the reservation now, @@ -592,10 +592,10 @@ static int ttm_bo_delayed_delete(struct ttm_bo_device *bdev, bool remove_all) kref_get(&nentry->list_kref); } - ret = __ttm_bo_reserve(entry, false, true, NULL); + ret = reservation_object_trylock(entry->resv) ? 0 : -EBUSY; if (remove_all && ret) { spin_unlock(&glob->lru_lock); - ret = __ttm_bo_reserve(entry, false, false, NULL); + ret = reservation_object_lock(entry->resv, NULL); spin_lock(&glob->lru_lock); } @@ -744,7 +744,7 @@ static int ttm_mem_evict_first(struct ttm_bo_device *bdev, spin_lock(&glob->lru_lock); for (i = 0; i < TTM_MAX_BO_PRIORITY; ++i) { list_for_each_entry(bo, &man->lru[i], lru) { - ret = __ttm_bo_reserve(bo, false, true, NULL); + ret = reservation_object_trylock(bo->resv) ? 0 : -EBUSY; if (ret) continue; @@ -1719,7 +1719,7 @@ static int ttm_bo_swapout(struct ttm_mem_shrink *shrink) spin_lock(&glob->lru_lock); for (i = 0; i < TTM_MAX_BO_PRIORITY; ++i) { list_for_each_entry(bo, &glob->swap_lru[i], swap) { - ret = __ttm_bo_reserve(bo, false, true, NULL); + ret = reservation_object_trylock(bo->resv) ? 0 : -EBUSY; if (!ret) break; } @@ -1823,7 +1823,9 @@ int ttm_bo_wait_unreserved(struct ttm_buffer_object *bo) return -ERESTARTSYS; if (!ww_mutex_is_locked(&bo->resv->lock)) goto out_unlock; - ret = __ttm_bo_reserve(bo, true, false, NULL); + ret = reservation_object_lock_interruptible(bo->resv, NULL); + if (ret = -EINTR) + ret = -ERESTARTSYS; if (unlikely(ret != 0)) goto out_unlock; reservation_object_unlock(bo->resv); diff --git a/include/drm/ttm/ttm_bo_driver.h b/include/drm/ttm/ttm_bo_driver.h index 389359a0006b..3659cf6150d2 100644 --- a/include/drm/ttm/ttm_bo_driver.h +++ b/include/drm/ttm/ttm_bo_driver.h @@ -836,14 +836,14 @@ static inline int __ttm_bo_reserve(struct ttm_buffer_object *bo, if (WARN_ON(ticket)) return -EBUSY; - success = ww_mutex_trylock(&bo->resv->lock); + success = reservation_object_trylock(bo->resv); return success ? 0 : -EBUSY; } if (interruptible) - ret = ww_mutex_lock_interruptible(&bo->resv->lock, ticket); + ret = reservation_object_lock_interruptible(bo->resv, ticket); else - ret = ww_mutex_lock(&bo->resv->lock, ticket); + ret = reservation_object_lock(bo->resv, ticket); if (ret == -EINTR) return -ERESTARTSYS; return ret;