From patchwork Mon Feb 10 15:09:04 2020 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: 11373521 Return-Path: Received: from mail.kernel.org (pdx-korg-mail-1.web.codeaurora.org [172.30.200.123]) by pdx-korg-patchwork-2.web.codeaurora.org (Postfix) with ESMTP id C9FD8921 for ; Mon, 10 Feb 2020 15:09:26 +0000 (UTC) Received: from gabe.freedesktop.org (gabe.freedesktop.org [131.252.210.177]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mail.kernel.org (Postfix) with ESMTPS id A879D20661 for ; Mon, 10 Feb 2020 15:09:26 +0000 (UTC) Authentication-Results: mail.kernel.org; dkim=fail reason="signature verification failed" (2048-bit key) header.d=gmail.com header.i=@gmail.com header.b="DF8gi3dP" DMARC-Filter: OpenDMARC Filter v1.3.2 mail.kernel.org A879D20661 Authentication-Results: mail.kernel.org; dmarc=fail (p=none dis=none) header.from=gmail.com Authentication-Results: mail.kernel.org; spf=none smtp.mailfrom=dri-devel-bounces@lists.freedesktop.org Received: from gabe.freedesktop.org (localhost [127.0.0.1]) by gabe.freedesktop.org (Postfix) with ESMTP id F2E8D6EC7B; Mon, 10 Feb 2020 15:09:17 +0000 (UTC) X-Original-To: dri-devel@lists.freedesktop.org Delivered-To: dri-devel@lists.freedesktop.org Received: from mail-wm1-x341.google.com (mail-wm1-x341.google.com [IPv6:2a00:1450:4864:20::341]) by gabe.freedesktop.org (Postfix) with ESMTPS id 62B996EC7B; Mon, 10 Feb 2020 15:09:16 +0000 (UTC) Received: by mail-wm1-x341.google.com with SMTP id s144so110512wme.1; Mon, 10 Feb 2020 07:09:16 -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=7NSt6dO/qIhpURlhjYp6e2TctCtwYH9Uut8LFHRiJQ4=; b=DF8gi3dPbM9M/Xt1t3VzJ2F5WHP7VY8kXCaBWczLw+QiR3UPRYx0QgS9jHHSuoIw/d k+OyBk6qD0fnLtA1JMrEqEBEg7jbTVaNIfoZH+DTZj5ti+E6OzHkxCISok5PchL86fqR N3YigSO4Sdc2VPxIvbWBqwq/0LeTxUHZ/EICKVrbSMmmGkU81ri4XEnW6/f6+d2ePIAE R54ZetUG58XGKorR8cuSRA2Z8oFHCokkLexp4+xE3cau4HGoGCssTWjKxIC6Mo96aH9t Bar6JTyRw96BIiWDWUg4FqpyuFyjw4b1eCSTRe4Trsu6dFXIL2bX/ctDjYO0q4qkMy4I bT4w== 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=7NSt6dO/qIhpURlhjYp6e2TctCtwYH9Uut8LFHRiJQ4=; b=s/RBlfLTYMCTxL3BNOL9UakK8a5KHNg/AbkKLVoFD0hGiNaQnzSajOpSKp58yopwk6 5Tj35qoCUduS5WOcRNjnLNx2UsXBHWVeV5QVoZKnVaGswj/XJ7VJH8tmBwb5K6uY2azo VNHWD5OkgjVEpdWfFhVTHmaHDyoC9gH/7uRoOt1zNbYq5U5OJDRVQ+TfUg1t8BSoRGMi fS5QZDqifr/8xCp3W57hQOzPJRxfpz7LBjwUpuz6gaj1h2D0jWtkKv0+VQC3kZP3HzhL 3+2bgUIiOsuiE8bRpxoUzZSTlimaKFPWSsTt618G2V/mXDNNxPR/O8g9jL65p1tFUOwH ofzw== X-Gm-Message-State: APjAAAUk9kLYSKxN4W4B30HW2SD9YZD2YhSxPMb+BLmA1LfTW2XGzoE3 9gvYVKiR04x7b/PeB4k/mzrH9fDw X-Google-Smtp-Source: APXvYqwUvJ7hsGR/wBw4lEgZ/tYu5llOIIuSS2/VrCRWiWww6WRI+mdqbjAHajMOkRyW6r3iQhS+CA== X-Received: by 2002:a05:600c:2944:: with SMTP id n4mr15700211wmd.22.1581347355056; Mon, 10 Feb 2020 07:09:15 -0800 (PST) Received: from abel.fritz.box ([2a02:908:1252:fb60:7d3b:a71c:475c:1e99]) by smtp.gmail.com with ESMTPSA id q10sm1021996wme.16.2020.02.10.07.09.14 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 10 Feb 2020 07:09:14 -0800 (PST) From: " =?utf-8?q?Christian_K=C3=B6nig?= " X-Google-Original-From: =?utf-8?q?Christian_K=C3=B6nig?= To: Xinhui.Pan@amd.com, amd-gfx@lists.freedesktop.org, dri-devel@lists.freedesktop.org Subject: [PATCH 3/6] drm/ttm: use RCU in ttm_bo_flush_all_fences Date: Mon, 10 Feb 2020 16:09:04 +0100 Message-Id: <20200210150907.20616-4-christian.koenig@amd.com> X-Mailer: git-send-email 2.17.1 In-Reply-To: <20200210150907.20616-1-christian.koenig@amd.com> References: <20200210150907.20616-1-christian.koenig@amd.com> MIME-Version: 1.0 X-BeenThere: dri-devel@lists.freedesktop.org X-Mailman-Version: 2.1.29 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" This allows it to call the function without the lock held. Signed-off-by: Christian König --- drivers/gpu/drm/ttm/ttm_bo.c | 10 ++++++---- 1 file changed, 6 insertions(+), 4 deletions(-) diff --git a/drivers/gpu/drm/ttm/ttm_bo.c b/drivers/gpu/drm/ttm/ttm_bo.c index c1104c8857b7..e12fc2c2d165 100644 --- a/drivers/gpu/drm/ttm/ttm_bo.c +++ b/drivers/gpu/drm/ttm/ttm_bo.c @@ -429,22 +429,24 @@ static int ttm_bo_individualize_resv(struct ttm_buffer_object *bo) static void ttm_bo_flush_all_fences(struct ttm_buffer_object *bo) { + struct dma_resv *resv = &bo->base._resv; struct dma_resv_list *fobj; struct dma_fence *fence; int i; - fobj = dma_resv_get_list(&bo->base._resv); - fence = dma_resv_get_excl(&bo->base._resv); + rcu_read_lock(); + fobj = rcu_dereference(resv->fence); + fence = rcu_dereference(resv->fence_excl); if (fence && !fence->ops->signaled) dma_fence_enable_sw_signaling(fence); for (i = 0; fobj && i < fobj->shared_count; ++i) { - fence = rcu_dereference_protected(fobj->shared[i], - dma_resv_held(bo->base.resv)); + fence = rcu_dereference(fobj->shared[i]); if (!fence->ops->signaled) dma_fence_enable_sw_signaling(fence); } + rcu_read_unlock(); } static void ttm_bo_cleanup_refs_or_queue(struct ttm_buffer_object *bo)