From patchwork Tue Nov 7 13:44:31 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: 10046699 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 56A746031B for ; Tue, 7 Nov 2017 13:44:40 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 4D1C628CEC for ; Tue, 7 Nov 2017 13:44:40 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 41AA828D6C; Tue, 7 Nov 2017 13:44:40 +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 91F0528CEC for ; Tue, 7 Nov 2017 13:44:39 +0000 (UTC) Received: from gabe.freedesktop.org (localhost [127.0.0.1]) by gabe.freedesktop.org (Postfix) with ESMTP id 701AA6E325; Tue, 7 Nov 2017 13:44:37 +0000 (UTC) X-Original-To: dri-devel@lists.freedesktop.org Delivered-To: dri-devel@lists.freedesktop.org Received: from mail-wm0-x244.google.com (mail-wm0-x244.google.com [IPv6:2a00:1450:400c:c09::244]) by gabe.freedesktop.org (Postfix) with ESMTPS id 8A63E6E325; Tue, 7 Nov 2017 13:44:36 +0000 (UTC) Received: by mail-wm0-x244.google.com with SMTP id b9so4006907wmh.0; Tue, 07 Nov 2017 05:44:36 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=from:to:subject:date:message-id:mime-version :content-transfer-encoding; bh=tGQg2I03u/5rHBlMUW29QN6jWeX/WUga6iwrYMbIMiI=; b=UO1ckWubVBbHt57Z3gO6cSu0OJRqh74l++r1DO5DSQg2GkDqUosNClt0IdyORr450B PjsrGns2/1+JMBVZBsXf6ysEYIvYXWqCUYF9L/Wr+ttDZgnypemvtNrofFHOwxRg9lJE QzZw40dgB2WaZYGniy6hGjahqG9OGPSIxwLYEH5Hd6NC08uVJl3gJO9+WeqnwGyjSubK 50Yh1F29rRx4kOJn6yJj31aayTTtY8rpjp5kq41aM003TU/AlJhuzamQ6KbxE/JbyJAb Gki11fifih0Uqb6kxdwx2IAPOTJGKmZbx8YeCnUL8+vBQsxpdNIf31uHsdEp/U7oMbCs DrDg== 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:mime-version :content-transfer-encoding; bh=tGQg2I03u/5rHBlMUW29QN6jWeX/WUga6iwrYMbIMiI=; b=V9Q7xYrbS93SnjG+WEfIYQxs26w6HZkUljjH4U2ksD+7g29v+3u51A3ucMh+E7wYil NU/Ff1I9wMcpIrwriEU/TC/4XdDqHOzDHS2RvZyoypChTa/lDxECC+Z6T76GEa6E9I4u 2aluVG1WJvoolNwXvElKHFytFiGbNCbo5xIWHYAwGMOQNasQuMUWdKGzFAjhRqYJVcFE hfZy7YbFzral7p/w1pNzWtRndjY0LaqzIK+qvagszFjuTJuPJpn0+GlXp/Kni14exJHz mLBV+sIeslF+eFfiIB+GhSpgOiwsGsJENbav9oI0XPMbOxpqJFTVi7FiqkVUKXrV8UUQ FVag== X-Gm-Message-State: AJaThX5NNU37XaQbuiXW99MCZ4g/rXz2vnVZ85bX5ObUzLMqi/erKGOn mgj5gHidTQUcpCx4+cXpGpcCrA== X-Google-Smtp-Source: ABhQp+RmKS3197DL0Wfr4RXfTm+s5Kd5h0kuFro2oNJrzXxaieWV7wH125T8jCry1+8O5EkxMbxfFQ== X-Received: by 10.28.23.129 with SMTP id 123mr1426582wmx.54.1510062274841; Tue, 07 Nov 2017 05:44:34 -0800 (PST) Received: from localhost.localdomain ([2a02:908:1251:7981:5d34:9fbe:ecf2:d33f]) by smtp.gmail.com with ESMTPSA id m198sm3563611wmg.20.2017.11.07.05.44.33 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Tue, 07 Nov 2017 05:44:34 -0800 (PST) From: "=?UTF-8?q?Christian=20K=C3=B6nig?=" X-Google-Original-From: =?UTF-8?q?Christian=20K=C3=B6nig?= To: amd-gfx@lists.freedesktop.org, dri-devel@lists.freedesktop.org Subject: [PATCH] drm/ttm: set bo->resv point to tbo->ttm_resv after individualize_resv Date: Tue, 7 Nov 2017 14:44:31 +0100 Message-Id: <20171107134431.11209-1-christian.koenig@amd.com> X-Mailer: git-send-email 2.11.0 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 Set bo->resv to ttm_resv during BO cleanup. This way freed BOs can be better reaped during eviction. Signed-off-by: Roger He Signed-off-by: Christian König --- drivers/gpu/drm/ttm/ttm_bo.c | 23 ++++++++--------------- 1 file changed, 8 insertions(+), 15 deletions(-) diff --git a/drivers/gpu/drm/ttm/ttm_bo.c b/drivers/gpu/drm/ttm/ttm_bo.c index c088703777e2..cc33eb2174f6 100644 --- a/drivers/gpu/drm/ttm/ttm_bo.c +++ b/drivers/gpu/drm/ttm/ttm_bo.c @@ -444,18 +444,19 @@ static void ttm_bo_cleanup_refs_or_queue(struct ttm_buffer_object *bo) reservation_object_wait_timeout_rcu(bo->resv, true, false, 30 * HZ); spin_lock(&glob->lru_lock); + bo->resv = &bo->ttm_resv; goto error; } spin_lock(&glob->lru_lock); - ret = __ttm_bo_reserve(bo, false, true, NULL); + if (bo->resv != &bo->ttm_resv) + bo->resv = &bo->ttm_resv; + else + ret = __ttm_bo_reserve(bo, false, true, NULL); if (!ret) { - if (reservation_object_test_signaled_rcu(&bo->ttm_resv, true)) { + if (reservation_object_test_signaled_rcu(bo->resv, true)) { ttm_bo_del_from_lru(bo); spin_unlock(&glob->lru_lock); - if (bo->resv != &bo->ttm_resv) - reservation_object_unlock(&bo->ttm_resv); - ttm_bo_cleanup_memtype_use(bo); return; } @@ -474,8 +475,6 @@ static void ttm_bo_cleanup_refs_or_queue(struct ttm_buffer_object *bo) __ttm_bo_unreserve(bo); } - if (bo->resv != &bo->ttm_resv) - reservation_object_unlock(&bo->ttm_resv); error: kref_get(&bo->list_kref); @@ -503,15 +502,9 @@ static int ttm_bo_cleanup_refs_and_unlock(struct ttm_buffer_object *bo, bool no_wait_gpu) { struct ttm_bo_global *glob = bo->glob; - struct reservation_object *resv; int ret; - if (unlikely(list_empty(&bo->ddestroy))) - resv = bo->resv; - else - resv = &bo->ttm_resv; - - if (reservation_object_test_signaled_rcu(resv, true)) + if (reservation_object_test_signaled_rcu(bo->resv, true)) ret = 0; else ret = -EBUSY; @@ -521,7 +514,7 @@ static int ttm_bo_cleanup_refs_and_unlock(struct ttm_buffer_object *bo, ww_mutex_unlock(&bo->resv->lock); spin_unlock(&glob->lru_lock); - lret = reservation_object_wait_timeout_rcu(resv, true, + lret = reservation_object_wait_timeout_rcu(bo->resv, true, interruptible, 30 * HZ);