From patchwork Fri Aug 16 18:59:16 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: "Welty, Brian" X-Patchwork-Id: 11098121 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 C373E18EC for ; Fri, 16 Aug 2019 18:58:29 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id AF5632886A for ; Fri, 16 Aug 2019 18:58:29 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 9E7432899E; Fri, 16 Aug 2019 18:58:29 +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,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 42BC72886A for ; Fri, 16 Aug 2019 18:58:29 +0000 (UTC) Received: from gabe.freedesktop.org (localhost [127.0.0.1]) by gabe.freedesktop.org (Postfix) with ESMTP id D0F246E984; Fri, 16 Aug 2019 18:58:26 +0000 (UTC) X-Original-To: dri-devel@lists.freedesktop.org Delivered-To: dri-devel@lists.freedesktop.org Received: from mga03.intel.com (mga03.intel.com [134.134.136.65]) by gabe.freedesktop.org (Postfix) with ESMTPS id 8D7606E984 for ; Fri, 16 Aug 2019 18:58:25 +0000 (UTC) X-Amp-Result: SKIPPED(no attachment in message) X-Amp-File-Uploaded: False Received: from orsmga006.jf.intel.com ([10.7.209.51]) by orsmga103.jf.intel.com with ESMTP/TLS/DHE-RSA-AES256-GCM-SHA384; 16 Aug 2019 11:58:24 -0700 X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="5.64,394,1559545200"; d="scan'208";a="182252291" Received: from nperf12.hd.intel.com ([10.127.88.161]) by orsmga006.jf.intel.com with ESMTP; 16 Aug 2019 11:58:24 -0700 From: Brian Welty To: =?utf-8?q?Christian_K=C3=B6nig?= , Daniel Vetter , dri-devel@lists.freedesktop.org Subject: [PATCH] drm/ttm: Refactor ttm_bo_pipeline_move Date: Fri, 16 Aug 2019 14:59:16 -0400 Message-Id: <20190816185916.30184-1-brian.welty@intel.com> X-Mailer: git-send-email 2.21.0 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 ttm_bo_pipeline_move needlessly duplicates code. Refactor this to instead call ttm_bo_move_accel_cleanup. Signed-off-by: Brian Welty --- Builds but otherwise currently untested. Came across this duplication and thought would see if others cared to see it cleaned up this way or not. drivers/gpu/drm/ttm/ttm_bo_util.c | 64 +++---------------------------- 1 file changed, 5 insertions(+), 59 deletions(-) diff --git a/drivers/gpu/drm/ttm/ttm_bo_util.c b/drivers/gpu/drm/ttm/ttm_bo_util.c index fe81c565e7ef..086ba2c2f60b 100644 --- a/drivers/gpu/drm/ttm/ttm_bo_util.c +++ b/drivers/gpu/drm/ttm/ttm_bo_util.c @@ -746,49 +746,10 @@ int ttm_bo_pipeline_move(struct ttm_buffer_object *bo, { struct ttm_bo_device *bdev = bo->bdev; struct ttm_mem_reg *old_mem = &bo->mem; - struct ttm_mem_type_manager *from = &bdev->man[old_mem->mem_type]; - struct ttm_mem_type_manager *to = &bdev->man[new_mem->mem_type]; - - int ret; - - dma_resv_add_excl_fence(bo->base.resv, fence); - - if (!evict) { - struct ttm_buffer_object *ghost_obj; - - /** - * This should help pipeline ordinary buffer moves. - * - * Hang old buffer memory on a new buffer object, - * and leave it to be released when the GPU - * operation has completed. - */ - - dma_fence_put(bo->moving); - bo->moving = dma_fence_get(fence); - ret = ttm_buffer_object_transfer(bo, &ghost_obj); - if (ret) - return ret; - - dma_resv_add_excl_fence(ghost_obj->base.resv, fence); - - /** - * If we're not moving to fixed memory, the TTM object - * needs to stay alive. Otherwhise hang it on the ghost - * bo to be unbound and destroyed. - */ - - if (!(to->flags & TTM_MEMTYPE_FLAG_FIXED)) - ghost_obj->ttm = NULL; - else - bo->ttm = NULL; - - ttm_bo_unreserve(ghost_obj); - ttm_bo_put(ghost_obj); - - } else if (from->flags & TTM_MEMTYPE_FLAG_FIXED) { + if (evict && from->flags & TTM_MEMTYPE_FLAG_FIXED) { + dma_resv_add_excl_fence(bo->base.resv, fence); /** * BO doesn't have a TTM we need to bind/unbind. Just remember @@ -807,27 +768,12 @@ int ttm_bo_pipeline_move(struct ttm_buffer_object *bo, dma_fence_put(bo->moving); bo->moving = dma_fence_get(fence); + *old_mem = *new_mem; + new_mem->mm_node = NULL; } else { - /** - * Last resort, wait for the move to be completed. - * - * Should never happen in pratice. - */ - - ret = ttm_bo_wait(bo, false, false); - if (ret) - return ret; - - if (to->flags & TTM_MEMTYPE_FLAG_FIXED) { - ttm_tt_destroy(bo->ttm); - bo->ttm = NULL; - } - ttm_bo_free_old_node(bo); + return ttm_bo_move_accel_cleanup(bo, fence, evict, new_mem); } - *old_mem = *new_mem; - new_mem->mm_node = NULL; - return 0; } EXPORT_SYMBOL(ttm_bo_pipeline_move);