From patchwork Fri Dec 15 18:31:42 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: 10115837 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 2802E6019C for ; Fri, 15 Dec 2017 18:31:52 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 21C2F2A0EA for ; Fri, 15 Dec 2017 18:31:52 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 16ADB2A0EE; Fri, 15 Dec 2017 18:31:52 +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 A51B92A0EA for ; Fri, 15 Dec 2017 18:31:51 +0000 (UTC) Received: from gabe.freedesktop.org (localhost [127.0.0.1]) by gabe.freedesktop.org (Postfix) with ESMTP id 306816E889; Fri, 15 Dec 2017 18:31:50 +0000 (UTC) X-Original-To: dri-devel@lists.freedesktop.org Delivered-To: dri-devel@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 7CD0F6E883 for ; Fri, 15 Dec 2017 18:31:49 +0000 (UTC) Received: by mail-wm0-x241.google.com with SMTP id t8so19159209wmc.3 for ; Fri, 15 Dec 2017 10:31:49 -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=ETQ0yYttrVYdIEyKOP+gdp9poTIJEL8X+66Z4DwYc1I=; b=rLcPPoyU2lUrOrgrJkGz4KVt+nvWPiKKVQD9SP654Qf7w67YQl0Z1yS5jBtZz4mF68 kLJTZKNAoB0q3+rjFBr0x0vi8B4O1J2oI3OpGTGHtc2NWY9oOU3yNx4byBq8sm36vri9 uDw30d6u396AKCUuiFf/0RPjzFStguCIZfcILc8SZkGYDoMmEbsh7WMsp9+67F2brk3W qPRraG8Dow/v4bNgRpj4VZhPSHigX6/nFkoMX12oTEP/Wnyxx+rpn7ng01zqF/jqYYnO m1OrfPo6m4WZKPV28mmhvaUH9J2WDmiEqp8sSBWzfRz9MJ53NrQByq9Frq61BNUiAxNg 8acA== 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=ETQ0yYttrVYdIEyKOP+gdp9poTIJEL8X+66Z4DwYc1I=; b=DeRseF5JVLhGc1lt/LefxYmuIktueYQKTEn8KXLhMWOKYbFt5tzMK4OyXNmog7ww53 A12DyJTRLaM6gb8vQqro2IAqPvUb2mRgXj+/oR9i41hmh1W4b0YWEsjGqhncCkZ8tAuM aotXbN5Kj4mLXu3Fj21QTQ/bI2BtK42IdWvNaZrz+UUaFUWF1iTn+TuAyrkmZ7CeFjJt QLmpVSwQzOyrt2G1KvJn2zkS8l2GkveQ5u3lgL/agveLBTzykLW7hKxqxYbjt2aDZ+4w rZrCAsBJZXg3ozc0pZBd/V7+ba71SC9uGpmyBz9MwOpXmKL1EwZor/uR+XoP0wFlVJGb 0YHg== X-Gm-Message-State: AKGB3mLMsqt6G7RoRVdwwjjoEhnV5dB+BqE3zciEQLpkLBoCa1RyN6i2 ssv1QdVpdssFWK8POr+r0aRK7A== X-Google-Smtp-Source: ACJfBosfXhiheQxlBtrahQGoDwi7yE2k0G02p7h/p8HTf2XXMGyIN7xCcrWSwdkx0CxT8n141sPaXA== X-Received: by 10.28.190.12 with SMTP id o12mr5898069wmf.148.1513362707755; Fri, 15 Dec 2017 10:31:47 -0800 (PST) Received: from localhost.localdomain ([2a02:908:1251:7981:52e:5a82:dbe5:f509]) by smtp.gmail.com with ESMTPSA id a203sm4542911wmh.45.2017.12.15.10.31.46 for (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Fri, 15 Dec 2017 10:31:47 -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 Subject: [PATCH 1/3] drm/ttm: use try_lock in ttm_bo_delayed_delete again Date: Fri, 15 Dec 2017 19:31:42 +0100 Message-Id: <20171215183144.16520-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 We only need to wait for the contended lock when the reservation object is shared or when we want to remove everything. A trylock should be sufficient in all other cases. Signed-off-by: Christian König Reviewed-by: Thomas Hellstrom --- drivers/gpu/drm/ttm/ttm_bo.c | 13 +++++++++---- 1 file changed, 9 insertions(+), 4 deletions(-) diff --git a/drivers/gpu/drm/ttm/ttm_bo.c b/drivers/gpu/drm/ttm/ttm_bo.c index ba5b48617bba..122a964cac40 100644 --- a/drivers/gpu/drm/ttm/ttm_bo.c +++ b/drivers/gpu/drm/ttm/ttm_bo.c @@ -586,12 +586,17 @@ static bool ttm_bo_delayed_delete(struct ttm_bo_device *bdev, bool remove_all) ddestroy); kref_get(&bo->list_kref); list_move_tail(&bo->ddestroy, &removed); - spin_unlock(&glob->lru_lock); - reservation_object_lock(bo->resv, NULL); + if (remove_all || bo->resv != &bo->ttm_resv) { + spin_unlock(&glob->lru_lock); + reservation_object_lock(bo->resv, NULL); - spin_lock(&glob->lru_lock); - ttm_bo_cleanup_refs(bo, false, !remove_all, true); + spin_lock(&glob->lru_lock); + ttm_bo_cleanup_refs(bo, false, !remove_all, true); + + } else if (reservation_object_trylock(bo->resv)) { + ttm_bo_cleanup_refs(bo, false, !remove_all, true); + } kref_put(&bo->list_kref, ttm_bo_release_list); spin_lock(&glob->lru_lock);