From patchwork Thu Dec 6 09:57:11 2018 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: 10715537 Return-Path: Received: from mail.wl.linuxfoundation.org (pdx-wl-mail.web.codeaurora.org [172.30.200.125]) by pdx-korg-patchwork-2.web.codeaurora.org (Postfix) with ESMTP id 02D0F109C for ; Thu, 6 Dec 2018 09:57:18 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id E6D942D3F9 for ; Thu, 6 Dec 2018 09:57:17 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id DB1812D66D; Thu, 6 Dec 2018 09:57:17 +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=-5.2 required=2.0 tests=BAYES_00,DKIM_ADSP_CUSTOM_MED, FREEMAIL_FROM,MAILING_LIST_MULTI,RCVD_IN_DNSWL_MED 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 8107E2D564 for ; Thu, 6 Dec 2018 09:57:17 +0000 (UTC) Received: from gabe.freedesktop.org (localhost [127.0.0.1]) by gabe.freedesktop.org (Postfix) with ESMTP id 8AC0D6E56D; Thu, 6 Dec 2018 09:57:16 +0000 (UTC) X-Original-To: dri-devel@lists.freedesktop.org Delivered-To: dri-devel@lists.freedesktop.org Received: from mail-wm1-x344.google.com (mail-wm1-x344.google.com [IPv6:2a00:1450:4864:20::344]) by gabe.freedesktop.org (Postfix) with ESMTPS id DBC676E56D for ; Thu, 6 Dec 2018 09:57:14 +0000 (UTC) Received: by mail-wm1-x344.google.com with SMTP id a18so358582wmj.1 for ; Thu, 06 Dec 2018 01:57:14 -0800 (PST) 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=oC+euazswBjCFB31dSYmVu1QQim/gNdTWQv2RsXhpN0=; b=brV2K4aj9tmzNMmoeSDRYm320y6Jw5m8sdgAACxo8NrmurkZW5zH0hpJJ3JhLTj7sl Rb9IqSAoj/j6Ite/cgAdeNxSzmwCtimCEtLcMYzp3IvqrirMVEXQ6YIg3+0OeBe02Ags tW/aSJ9dmq+8fHxzFvXyz7sV0qClTuezRv0an6ebb5XoLOha937Zo+MTs/HNF4hpQ1Qe 7hvAH49KBU1Zk7xgrpz3tXK0/JdROVlc/v7IRWwFs91aWEW1HTQ/0zOnaps5XOW3CU2s AJErKqDs8My2dgxssx6/gvWXagrqRdkooeJQUsWEvDKWxnToDq5hmcNWE2w3Dpiq4bvs Oaag== X-Gm-Message-State: AA+aEWbDymSznVd9WhacsNXevjG7MJfhuNS1ZThYeqhio1ZiFmvOasyJ kUc+mjtDxelPB5CszsCEQw3ytRfs X-Google-Smtp-Source: AFSGD/VPdK3/l2cxoHAvPu9+3LKTPaiCTmfa2WSpGkcxIc8uayzSIzjpiON6ZGc1Aql4cngP8VPBJQ== X-Received: by 2002:a1c:bd82:: with SMTP id n124mr18434635wmf.105.1544090233263; Thu, 06 Dec 2018 01:57:13 -0800 (PST) Received: from baker.fritz.box ([2a02:908:125b:9a00:b917:e857:eae7:62b0]) by smtp.gmail.com with ESMTPSA id e16sm22180849wrn.72.2018.12.06.01.57.12 for (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Thu, 06 Dec 2018 01:57:12 -0800 (PST) From: " =?utf-8?q?Christian_K=C3=B6nig?= " X-Google-Original-From: =?utf-8?q?Christian_K=C3=B6nig?= To: dri-devel@lists.freedesktop.org Subject: [PATCH] drm/ttm: revert "drop the extra reservation for pipelined BO moves" Date: Thu, 6 Dec 2018 10:57:11 +0100 Message-Id: <20181206095711.24769-1-christian.koenig@amd.com> X-Mailer: git-send-email 2.14.1 MIME-Version: 1.0 X-BeenThere: dri-devel@lists.freedesktop.org X-Mailman-Version: 2.1.23 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 This patch caused trouble because of not handled corner cases during memory pressure. The extra overhead of checking if we have enough space doesn't worth the trouble, so just revert it. This reverts commit 5786b66c9e3b7b18f3c24566e70cae450969cb14 and commit 7d9a7a3bddb537bb05d297423df539bffa1aa501. Signed-off-by: Christian König Reviewed-by: Michel Dänzer Tested-by: Michel Dänzer --- drivers/gpu/drm/ttm/ttm_bo.c | 30 +++++++++++++++++++++--------- 1 file changed, 21 insertions(+), 9 deletions(-) diff --git a/drivers/gpu/drm/ttm/ttm_bo.c b/drivers/gpu/drm/ttm/ttm_bo.c index ffd68b039d23..d87935bf8e30 100644 --- a/drivers/gpu/drm/ttm/ttm_bo.c +++ b/drivers/gpu/drm/ttm/ttm_bo.c @@ -866,11 +866,12 @@ EXPORT_SYMBOL(ttm_bo_mem_put); /** * Add the last move fence to the BO and reserve a new shared slot. */ -static void ttm_bo_add_move_fence(struct ttm_buffer_object *bo, - struct ttm_mem_type_manager *man, - struct ttm_mem_reg *mem) +static int ttm_bo_add_move_fence(struct ttm_buffer_object *bo, + struct ttm_mem_type_manager *man, + struct ttm_mem_reg *mem) { struct dma_fence *fence; + int ret; spin_lock(&man->move_lock); fence = dma_fence_get(man->move); @@ -878,9 +879,16 @@ static void ttm_bo_add_move_fence(struct ttm_buffer_object *bo, if (fence) { reservation_object_add_shared_fence(bo->resv, fence); + + ret = reservation_object_reserve_shared(bo->resv, 1); + if (unlikely(ret)) + return ret; + dma_fence_put(bo->moving); bo->moving = fence; } + + return 0; } /** @@ -908,8 +916,7 @@ static int ttm_bo_mem_force_space(struct ttm_buffer_object *bo, return ret; } while (1); mem->mem_type = mem_type; - ttm_bo_add_move_fence(bo, man, mem); - return 0; + return ttm_bo_add_move_fence(bo, man, mem); } static uint32_t ttm_bo_select_caching(struct ttm_mem_type_manager *man, @@ -978,6 +985,10 @@ int ttm_bo_mem_space(struct ttm_buffer_object *bo, bool has_erestartsys = false; int i, ret; + ret = reservation_object_reserve_shared(bo->resv, 1); + if (unlikely(ret)) + return ret; + mem->mm_node = NULL; for (i = 0; i < placement->num_placement; ++i) { const struct ttm_place *place = &placement->placement[i]; @@ -1013,7 +1024,11 @@ int ttm_bo_mem_space(struct ttm_buffer_object *bo, return ret; if (mem->mm_node) { - ttm_bo_add_move_fence(bo, man, mem); + ret = ttm_bo_add_move_fence(bo, man, mem); + if (unlikely(ret)) { + (*man->func->put_node)(man, mem); + return ret; + } break; } } @@ -1264,9 +1279,6 @@ int ttm_bo_init_reserved(struct ttm_bo_device *bdev, WARN_ON(!locked); } - if (likely(!ret)) - ret = reservation_object_reserve_shared(bo->resv, 1); - if (likely(!ret)) ret = ttm_bo_validate(bo, placement, ctx);