From patchwork Tue Jul 5 12:30:03 2016 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: 9214175 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 3E97D60752 for ; Tue, 5 Jul 2016 12:30:14 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 2FF442892A for ; Tue, 5 Jul 2016 12:30:14 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 24A6A28A30; Tue, 5 Jul 2016 12:30:14 +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_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]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 0B3AE2892A for ; Tue, 5 Jul 2016 12:30:12 +0000 (UTC) Received: from gabe.freedesktop.org (localhost [127.0.0.1]) by gabe.freedesktop.org (Postfix) with ESMTP id A5B786E0BB; Tue, 5 Jul 2016 12:30:09 +0000 (UTC) X-Original-To: dri-devel@lists.freedesktop.org Delivered-To: dri-devel@lists.freedesktop.org Received: from pegasos-out.vodafone.de (pegasos-out.vodafone.de [80.84.1.38]) by gabe.freedesktop.org (Postfix) with ESMTP id 7A9C86E299 for ; Tue, 5 Jul 2016 12:30:08 +0000 (UTC) Received: from localhost (localhost.localdomain [127.0.0.1]) by pegasos-out.vodafone.de (Rohrpostix2 Daemon) with ESMTP id 62EF05E0DB1; Tue, 5 Jul 2016 14:30:07 +0200 (CEST) X-Virus-Scanned: amavisd-new at vodafone.de Authentication-Results: rohrpostix2.prod.vfnet.de (amavisd-new); dkim=pass header.i=@vodafone.de Received: from pegasos-out.vodafone.de ([127.0.0.1]) by localhost (rohrpostix2.prod.vfnet.de [127.0.0.1]) (amavisd-new, port 10024) with ESMTP id 10-nNYYvu1ND; Tue, 5 Jul 2016 14:30:05 +0200 (CEST) Received: from smtp-05.vodafone.de (xsmail-dmz2.prod.vfnet.de [10.215.254.33]) by pegasos-out.vodafone.de (Rohrpostix2 Daemon) with ESMTP id 66DEC5E0D7A; Tue, 5 Jul 2016 14:30:05 +0200 (CEST) X-DKIM: OpenDKIM Filter v2.6.8 pegasos-out.vodafone.de 66DEC5E0D7A DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=vodafone.de; s=mail; t=1467721805; bh=irjYTZjYlqHOftHC2cbZwuRVTUjA8QBT46QpCgygT+A=; h=From:To:Cc:Subject:Date:In-Reply-To:References; b=dOU/xvLGpbWWLPr0VRWsfPgj+PdkHq6TPT2dTnXCHj6A7fo5JrJzkd3Ijdo3eRSAb bOnoDK8rBZdZpZuAl0zVp3m3eCllOi80t3FghAndESPyRWHfUQk9DjQtzGWZoH8Ue0 hfFUFkSsOUrhByDmIInzniRUCezE/SSpfPjdkuWE= X-Virus-Scanned: amavisd-new at vodafone.de Received: from smtp-05.vodafone.de ([127.0.0.1]) by localhost (xsmail-dmz2.prod.vfnet.de [127.0.0.1]) (amavisd-new, port 10024) with ESMTP id ox4Q2UgsFQph; Tue, 5 Jul 2016 14:30:04 +0200 (CEST) From: =?UTF-8?q?Christian=20K=C3=B6nig?= To: thomas@shipmail.org Subject: [PATCH 2/2] drm/ttm: use RCU to pipeline evictions Date: Tue, 5 Jul 2016 14:30:03 +0200 Message-Id: <1467721803-2138-2-git-send-email-deathsimple@vodafone.de> X-Mailer: git-send-email 2.5.0 In-Reply-To: <1467721803-2138-1-git-send-email-deathsimple@vodafone.de> References: <1467721803-2138-1-git-send-email-deathsimple@vodafone.de> MIME-Version: 1.0 Cc: dri-devel@lists.freedesktop.org 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 From: Christian König Could be faster on the read path. Signed-off-by: Christian König Reviewed-by: Alex Deucher --- drivers/gpu/drm/ttm/ttm_bo.c | 16 ++++++++++------ drivers/gpu/drm/ttm/ttm_bo_util.c | 8 +++++--- 2 files changed, 15 insertions(+), 9 deletions(-) diff --git a/drivers/gpu/drm/ttm/ttm_bo.c b/drivers/gpu/drm/ttm/ttm_bo.c index 66c50ad..7e30f3b 100644 --- a/drivers/gpu/drm/ttm/ttm_bo.c +++ b/drivers/gpu/drm/ttm/ttm_bo.c @@ -797,9 +797,11 @@ static int ttm_bo_add_move_fence(struct ttm_buffer_object *bo, struct fence *fence; int ret; - spin_lock(&man->move_lock); - fence = fence_get(man->move); - spin_unlock(&man->move_lock); + rcu_read_lock(); + do + fence = rcu_dereference(man->move); + while (unlikely(fence && !fence_get_rcu(fence))); + rcu_read_unlock(); if (fence) { reservation_object_add_shared_fence(bo->resv, fence); @@ -1304,9 +1306,11 @@ static int ttm_bo_force_list_clean(struct ttm_bo_device *bdev, } spin_unlock(&glob->lru_lock); - spin_lock(&man->move_lock); - fence = fence_get(man->move); - spin_unlock(&man->move_lock); + rcu_read_lock(); + do + fence = rcu_dereference(man->move); + while (unlikely(fence && !fence_get_rcu(fence))); + rcu_read_unlock(); if (fence) { ret = fence_wait(fence, false); diff --git a/drivers/gpu/drm/ttm/ttm_bo_util.c b/drivers/gpu/drm/ttm/ttm_bo_util.c index 4da0e78..fcd2431 100644 --- a/drivers/gpu/drm/ttm/ttm_bo_util.c +++ b/drivers/gpu/drm/ttm/ttm_bo_util.c @@ -746,6 +746,7 @@ int ttm_bo_pipeline_move(struct ttm_buffer_object *bo, ttm_bo_unref(&ghost_obj); } else if (from->flags & TTM_MEMTYPE_FLAG_FIXED) { + struct fence *old; /** * BO doesn't have a TTM we need to bind/unbind. Just remember @@ -753,9 +754,10 @@ int ttm_bo_pipeline_move(struct ttm_buffer_object *bo, */ spin_lock(&from->move_lock); - if (!from->move || fence_is_later(fence, from->move)) { - fence_put(from->move); - from->move = fence_get(fence); + old = rcu_dereference_protected(from->move, 1); + if (!old || fence_is_later(fence, old)) { + rcu_assign_pointer(from->move, fence_get(fence)); + fence_put(old); } spin_unlock(&from->move_lock);