From patchwork Fri Feb 2 19:09:44 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: 10198023 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 39E3C60388 for ; Fri, 2 Feb 2018 19:09:54 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 2A00228F53 for ; Fri, 2 Feb 2018 19:09:54 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 1C6FA28F56; Fri, 2 Feb 2018 19:09:54 +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 4511B28F53 for ; Fri, 2 Feb 2018 19:09:53 +0000 (UTC) Received: from gabe.freedesktop.org (localhost [127.0.0.1]) by gabe.freedesktop.org (Postfix) with ESMTP id 4FADE6EFB7; Fri, 2 Feb 2018 19:09:52 +0000 (UTC) X-Original-To: dri-devel@lists.freedesktop.org Delivered-To: dri-devel@lists.freedesktop.org Received: from mail-wm0-x244.google.com (mail-wm0-x244.google.com [IPv6:2a00:1450:400c:c09::244]) by gabe.freedesktop.org (Postfix) with ESMTPS id 5AD416EE0A; Fri, 2 Feb 2018 19:09:51 +0000 (UTC) Received: by mail-wm0-x244.google.com with SMTP id v71so14434696wmv.2; Fri, 02 Feb 2018 11:09:51 -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=FafWsYURDlnLoSkI3pILYlBet3/hDm1bdlUIUMGxWq4=; b=oUEx1wUxPkAq2yBD9XmvDxy/PNT8zvE5FfHNuvGJXsL2eMIxSZ7AcaYopmpzqMzgs1 sMW7pnmUodOW7WpZgld76+QbtUvu2ZiUqHiKrD/WUy7srm8x8iXXHhV9z7qwai5r+TQL Yp2NkWv446FG0qgd5jnBDp9Pu5WpXhwQ2A1ghUMUCeJF2JaslpDM3Yc1Z5xeTqAHzP9h NyzhvWPnS3tcLuaVfElPkmBnxGsjmyFTkKFeJqIPqp7YBheCcPSl+DhxBZmEEE/tLmfp Tl2/uq8JfMbQlnjPCaOVQBt/Te8li6gl9CLx4e5wWU/fn1HjddXicmeIxL5tHdrxagyf eRMw== 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=FafWsYURDlnLoSkI3pILYlBet3/hDm1bdlUIUMGxWq4=; b=iBvqhynyoHBqemJjj5wK/Yvk7dCLPf9v7uwOJfROFt0OySegikkByHyWWyjc4VeM7t QzTk1mwgTb3+4MqTblGdAVFpNBrcywpx8JP9ZnUoZfiT25DjM5HAc+sF5+qFoRfwTGIu fObN/4cWd42uiC/2IflFSHyfe9siCtM2iX89eUkUKKQDZgGOteMVytT2zA6/bsQ37YVN 1a7p7w/2/Q+Cawml38jt3/MJGdsbC0zlji6VOb4h7CsVwHBtOTlG2lDlMi0XdiZXpsRK a4pHf+j+y0fvt1FvxrW3tQtsqrsYil16iTKY6ieQF3zyMvVfJcMewrauxsw4VF8RV58u Cnqw== X-Gm-Message-State: AKwxytdGa06wsZFTV0JgpbBv3HO+7KSp4Dydoa+UVO+D/oj5jbaDlpEl 5F5oum2tcrab+c8SkaKsjopfPg== X-Google-Smtp-Source: AH8x227fgljRft+s+1FE5wb65H/bL/IwvtxjMJJBF2g6qMfC09COBd5GgXC6dZEDNqHH4QWsj35l+g== X-Received: by 10.28.54.221 with SMTP id y90mr28599757wmh.156.1517598589729; Fri, 02 Feb 2018 11:09:49 -0800 (PST) Received: from baker.fritz.box ([2a02:908:1251:8fc0:ad10:3711:be7c:8502]) by smtp.gmail.com with ESMTPSA id j132sm3917316wmd.38.2018.02.02.11.09.48 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Fri, 02 Feb 2018 11:09:49 -0800 (PST) From: "=?UTF-8?q?Christian=20K=C3=B6nig?=" X-Google-Original-From: =?UTF-8?q?Christian=20K=C3=B6nig?= To: amd-gfx@lists.freedesktop.org, dri-devel@lists.freedesktop.org Subject: [PATCH 1/5] drm/ttm: add ttm_tt_populate wrapper Date: Fri, 2 Feb 2018 20:09:44 +0100 Message-Id: <20180202190948.2654-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 Stop calling the driver callback directly. Signed-off-by: Christian König --- drivers/gpu/drm/ttm/ttm_bo_util.c | 12 +++++------- drivers/gpu/drm/ttm/ttm_bo_vm.c | 2 +- drivers/gpu/drm/ttm/ttm_tt.c | 10 +++++++++- include/drm/ttm/ttm_bo_driver.h | 9 +++++++++ 4 files changed, 24 insertions(+), 9 deletions(-) diff --git a/drivers/gpu/drm/ttm/ttm_bo_util.c b/drivers/gpu/drm/ttm/ttm_bo_util.c index 33ffe286f3a5..38da6903cae9 100644 --- a/drivers/gpu/drm/ttm/ttm_bo_util.c +++ b/drivers/gpu/drm/ttm/ttm_bo_util.c @@ -375,8 +375,8 @@ int ttm_bo_move_memcpy(struct ttm_buffer_object *bo, /* * TTM might be null for moves within the same region. */ - if (ttm && ttm->state == tt_unpopulated) { - ret = ttm->bdev->driver->ttm_tt_populate(ttm, ctx); + if (ttm) { + ret = ttm_tt_populate(ttm, ctx); if (ret) goto out1; } @@ -557,11 +557,9 @@ static int ttm_bo_kmap_ttm(struct ttm_buffer_object *bo, BUG_ON(!ttm); - if (ttm->state == tt_unpopulated) { - ret = ttm->bdev->driver->ttm_tt_populate(ttm, &ctx); - if (ret) - return ret; - } + ret = ttm_tt_populate(ttm, &ctx); + if (ret) + return ret; if (num_pages == 1 && (mem->placement & TTM_PL_FLAG_CACHED)) { /* diff --git a/drivers/gpu/drm/ttm/ttm_bo_vm.c b/drivers/gpu/drm/ttm/ttm_bo_vm.c index 716e724ac710..610d6714042a 100644 --- a/drivers/gpu/drm/ttm/ttm_bo_vm.c +++ b/drivers/gpu/drm/ttm/ttm_bo_vm.c @@ -234,7 +234,7 @@ static int ttm_bo_vm_fault(struct vm_fault *vmf) cvma.vm_page_prot); /* Allocate all page at once, most common usage */ - if (ttm->bdev->driver->ttm_tt_populate(ttm, &ctx)) { + if (ttm_tt_populate(ttm, &ctx)) { ret = VM_FAULT_OOM; goto out_io_unlock; } diff --git a/drivers/gpu/drm/ttm/ttm_tt.c b/drivers/gpu/drm/ttm/ttm_tt.c index 95a77dab8cc9..39c44e301c72 100644 --- a/drivers/gpu/drm/ttm/ttm_tt.c +++ b/drivers/gpu/drm/ttm/ttm_tt.c @@ -276,7 +276,7 @@ int ttm_tt_bind(struct ttm_tt *ttm, struct ttm_mem_reg *bo_mem, if (ttm->state == tt_bound) return 0; - ret = ttm->bdev->driver->ttm_tt_populate(ttm, ctx); + ret = ttm_tt_populate(ttm, ctx); if (ret) return ret; @@ -392,6 +392,14 @@ int ttm_tt_swapout(struct ttm_tt *ttm, struct file *persistent_swap_storage) return ret; } +int ttm_tt_populate(struct ttm_tt *ttm, struct ttm_operation_ctx *ctx) +{ + if (ttm->state != tt_unpopulated) + return 0; + + return ttm->bdev->driver->ttm_tt_populate(ttm, ctx); +} + static void ttm_tt_clear_mapping(struct ttm_tt *ttm) { pgoff_t i; diff --git a/include/drm/ttm/ttm_bo_driver.h b/include/drm/ttm/ttm_bo_driver.h index 9b417eb2df20..2bac25a6cf90 100644 --- a/include/drm/ttm/ttm_bo_driver.h +++ b/include/drm/ttm/ttm_bo_driver.h @@ -700,6 +700,15 @@ int ttm_tt_swapin(struct ttm_tt *ttm); int ttm_tt_set_placement_caching(struct ttm_tt *ttm, uint32_t placement); int ttm_tt_swapout(struct ttm_tt *ttm, struct file *persistent_swap_storage); +/** + * ttm_tt_populate - allocate pages for a ttm + * + * @ttm: Pointer to the ttm_tt structure + * + * Calls the driver method to allocate pages for a ttm + */ +int ttm_tt_populate(struct ttm_tt *ttm, struct ttm_operation_ctx *ctx); + /** * ttm_tt_unpopulate - free pages from a ttm *