From patchwork Tue Mar 6 14:43:43 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: 10261963 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 EFA91602C8 for ; Tue, 6 Mar 2018 14:44:07 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id E0D9F2900D for ; Tue, 6 Mar 2018 14:44:07 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id D559C29012; Tue, 6 Mar 2018 14:44:07 +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 B60282900F for ; Tue, 6 Mar 2018 14:44:06 +0000 (UTC) Received: from gabe.freedesktop.org (localhost [127.0.0.1]) by gabe.freedesktop.org (Postfix) with ESMTP id E3A966E1BC; Tue, 6 Mar 2018 14:43:58 +0000 (UTC) X-Original-To: dri-devel@lists.freedesktop.org Delivered-To: dri-devel@lists.freedesktop.org Received: from mail-wm0-x243.google.com (mail-wm0-x243.google.com [IPv6:2a00:1450:400c:c09::243]) by gabe.freedesktop.org (Postfix) with ESMTPS id A06A76E074; Tue, 6 Mar 2018 14:43:51 +0000 (UTC) Received: by mail-wm0-x243.google.com with SMTP id t6so22763185wmt.5; Tue, 06 Mar 2018 06:43: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:in-reply-to:references:mime-version :content-transfer-encoding; bh=YEtjBCSg26ud8DyX1sdeHf1SFLPj1y5snLEhUmucPCI=; b=OB/pb3dpcbopcN0Sy8PZmSQRRU4ysYioOuG0wthHUP1644pi5qvWud4isZJRet0OCx gP911zdhnCpyqi+mUAoWWuyDaEyWoxkl8EK/mgDZLszKW84SiuAOfmBzlv5V1ofnGh84 av7fCQL3nRdVc/VEPlz/tqPMnGN7plaQpG9BR9HNDHdjlT2W1vvs7QlhkKtzHds5lM+P PPumutaw/6/Q81uTrqe4vuzfdIEqghaeDSXsQo20IRsKLBDVvFEIqh3Ycfxry03WUCWB 79fpXBkIHORzlCiF232Wi4DGLYKFjhCAE5b1+TmiDg6rAt4gCcmexwxeoCwJB8Q3V4y+ nvqw== 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=YEtjBCSg26ud8DyX1sdeHf1SFLPj1y5snLEhUmucPCI=; b=M3OBn9gxPi4FFLleLyFhgykdUsEBQRds9ghuiiHuxqhWYICPxwHWD0qkGvVEoirk9s phbHpGYNxLVotpXzC1tl0olohL0EOI+VYcYZPDBTNYlBhJKc6v4GSpJddvwFiXY6AnvJ wLbBaGqM2vCw8OXg5XOfbtEAnQ0EDsFfSLjwRyWmjiCgLvj1QQxe3TTlqsb+VZr/xnKk kNj2NLQbm+DA+zOmNn5698XHXzEPrAOqMSl6nIyhPl6t6OHV0qT52y0RI7za3bmJFJo4 UTfvSeq2Am7M75eNhegcxivmJCqfa0JIGwiWcyP5vpzx7rMjMAyuPFy8M2Jh3yLTtCuU +sig== X-Gm-Message-State: AElRT7HPoPDLRtMRABDOxC8EFWtElfBmbxhoURB4diwa52LrJtUg/2WV itPtnNOPaqpAns+FgsCeFDwX0A== X-Google-Smtp-Source: AG47ELt2LgIIQ09Fu+4SCv/Mj84uQ8mWO64jhNHoXvLMv1XyvL4ppjwIGQekDTP0gxjTNgBR0nWQiA== X-Received: by 10.28.118.20 with SMTP id r20mr2306059wmc.145.1520347429693; Tue, 06 Mar 2018 06:43:49 -0800 (PST) Received: from baker.fritz.box ([2a02:908:1251:8fc0:44ab:16c7:7c4f:90f9]) by smtp.gmail.com with ESMTPSA id s21sm13419206wra.45.2018.03.06.06.43.48 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Tue, 06 Mar 2018 06:43: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 2/6] drm/ttm: add bo as parameter to the ttm_tt_create callback Date: Tue, 6 Mar 2018 15:43:43 +0100 Message-Id: <20180306144347.1702-2-christian.koenig@amd.com> X-Mailer: git-send-email 2.14.1 In-Reply-To: <20180306144347.1702-1-christian.koenig@amd.com> References: <20180306144347.1702-1-christian.koenig@amd.com> 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 Instead of calculating the size in bytes just to recalculate the number of pages from it pass the BO directly to the function. Signed-off-by: Christian König --- drivers/gpu/drm/amd/amdgpu/amdgpu_ttm.c | 8 ++++---- drivers/gpu/drm/ast/ast_ttm.c | 6 +++--- drivers/gpu/drm/bochs/bochs_mm.c | 5 ++--- drivers/gpu/drm/cirrus/cirrus_ttm.c | 6 +++--- drivers/gpu/drm/hisilicon/hibmc/hibmc_ttm.c | 5 ++--- drivers/gpu/drm/mgag200/mgag200_ttm.c | 6 +++--- drivers/gpu/drm/nouveau/nouveau_bo.c | 10 ++++------ drivers/gpu/drm/nouveau/nouveau_sgdma.c | 7 +++---- drivers/gpu/drm/nouveau/nouveau_ttm.h | 4 ++-- drivers/gpu/drm/qxl/qxl_ttm.c | 8 ++++---- drivers/gpu/drm/radeon/radeon_ttm.c | 12 ++++++------ drivers/gpu/drm/ttm/ttm_agp_backend.c | 6 +++--- drivers/gpu/drm/ttm/ttm_tt.c | 29 ++++++++++++++--------------- drivers/gpu/drm/virtio/virtgpu_ttm.c | 7 +++---- drivers/gpu/drm/vmwgfx/vmwgfx_buffer.c | 10 +++++----- drivers/staging/vboxvideo/vbox_ttm.c | 5 ++--- include/drm/ttm/ttm_bo_driver.h | 6 ++---- include/drm/ttm/ttm_tt.h | 22 ++++++++++------------ 18 files changed, 75 insertions(+), 87 deletions(-) diff --git a/drivers/gpu/drm/amd/amdgpu/amdgpu_ttm.c b/drivers/gpu/drm/amd/amdgpu/amdgpu_ttm.c index 628cbc3ab46f..44ae2c60c9d4 100644 --- a/drivers/gpu/drm/amd/amdgpu/amdgpu_ttm.c +++ b/drivers/gpu/drm/amd/amdgpu/amdgpu_ttm.c @@ -974,20 +974,20 @@ static struct ttm_backend_func amdgpu_backend_func = { .destroy = &amdgpu_ttm_backend_destroy, }; -static struct ttm_tt *amdgpu_ttm_tt_create(struct ttm_bo_device *bdev, - unsigned long size, uint32_t page_flags) +static struct ttm_tt *amdgpu_ttm_tt_create(struct ttm_buffer_object *bo, + uint32_t page_flags) { struct amdgpu_device *adev; struct amdgpu_ttm_tt *gtt; - adev = amdgpu_ttm_adev(bdev); + adev = amdgpu_ttm_adev(bo->bdev); gtt = kzalloc(sizeof(struct amdgpu_ttm_tt), GFP_KERNEL); if (gtt == NULL) { return NULL; } gtt->ttm.ttm.func = &amdgpu_backend_func; - if (ttm_sg_tt_init(>t->ttm, bdev, size, page_flags)) { + if (ttm_sg_tt_init(>t->ttm, bo, page_flags)) { kfree(gtt); return NULL; } diff --git a/drivers/gpu/drm/ast/ast_ttm.c b/drivers/gpu/drm/ast/ast_ttm.c index 211224f6bdd3..fe354ebf374d 100644 --- a/drivers/gpu/drm/ast/ast_ttm.c +++ b/drivers/gpu/drm/ast/ast_ttm.c @@ -199,8 +199,8 @@ static struct ttm_backend_func ast_tt_backend_func = { }; -static struct ttm_tt *ast_ttm_tt_create(struct ttm_bo_device *bdev, - unsigned long size, uint32_t page_flags) +static struct ttm_tt *ast_ttm_tt_create(struct ttm_buffer_object *bo, + uint32_t page_flags) { struct ttm_tt *tt; @@ -208,7 +208,7 @@ static struct ttm_tt *ast_ttm_tt_create(struct ttm_bo_device *bdev, if (tt == NULL) return NULL; tt->func = &ast_tt_backend_func; - if (ttm_tt_init(tt, bdev, size, page_flags)) { + if (ttm_tt_init(tt, bo, page_flags)) { kfree(tt); return NULL; } diff --git a/drivers/gpu/drm/bochs/bochs_mm.c b/drivers/gpu/drm/bochs/bochs_mm.c index 73722484e12b..50c52b45448f 100644 --- a/drivers/gpu/drm/bochs/bochs_mm.c +++ b/drivers/gpu/drm/bochs/bochs_mm.c @@ -176,8 +176,7 @@ static struct ttm_backend_func bochs_tt_backend_func = { .destroy = &bochs_ttm_backend_destroy, }; -static struct ttm_tt *bochs_ttm_tt_create(struct ttm_bo_device *bdev, - unsigned long size, +static struct ttm_tt *bochs_ttm_tt_create(struct ttm_buffer_object *bo, uint32_t page_flags) { struct ttm_tt *tt; @@ -186,7 +185,7 @@ static struct ttm_tt *bochs_ttm_tt_create(struct ttm_bo_device *bdev, if (tt == NULL) return NULL; tt->func = &bochs_tt_backend_func; - if (ttm_tt_init(tt, bdev, size, page_flags)) { + if (ttm_tt_init(tt, bo, page_flags)) { kfree(tt); return NULL; } diff --git a/drivers/gpu/drm/cirrus/cirrus_ttm.c b/drivers/gpu/drm/cirrus/cirrus_ttm.c index 6cd0233b3bf8..f21953243790 100644 --- a/drivers/gpu/drm/cirrus/cirrus_ttm.c +++ b/drivers/gpu/drm/cirrus/cirrus_ttm.c @@ -199,8 +199,8 @@ static struct ttm_backend_func cirrus_tt_backend_func = { }; -static struct ttm_tt *cirrus_ttm_tt_create(struct ttm_bo_device *bdev, - unsigned long size, uint32_t page_flags) +static struct ttm_tt *cirrus_ttm_tt_create(struct ttm_buffer_object *bo, + uint32_t page_flags) { struct ttm_tt *tt; @@ -208,7 +208,7 @@ static struct ttm_tt *cirrus_ttm_tt_create(struct ttm_bo_device *bdev, if (tt == NULL) return NULL; tt->func = &cirrus_tt_backend_func; - if (ttm_tt_init(tt, bdev, size, page_flags)) { + if (ttm_tt_init(tt, bo, page_flags)) { kfree(tt); return NULL; } diff --git a/drivers/gpu/drm/hisilicon/hibmc/hibmc_ttm.c b/drivers/gpu/drm/hisilicon/hibmc/hibmc_ttm.c index 8dfffdbb6b07..4871025f7573 100644 --- a/drivers/gpu/drm/hisilicon/hibmc/hibmc_ttm.c +++ b/drivers/gpu/drm/hisilicon/hibmc/hibmc_ttm.c @@ -200,8 +200,7 @@ static struct ttm_backend_func hibmc_tt_backend_func = { .destroy = &hibmc_ttm_backend_destroy, }; -static struct ttm_tt *hibmc_ttm_tt_create(struct ttm_bo_device *bdev, - unsigned long size, +static struct ttm_tt *hibmc_ttm_tt_create(struct ttm_buffer_object *bo, u32 page_flags) { struct ttm_tt *tt; @@ -213,7 +212,7 @@ static struct ttm_tt *hibmc_ttm_tt_create(struct ttm_bo_device *bdev, return NULL; } tt->func = &hibmc_tt_backend_func; - ret = ttm_tt_init(tt, bdev, size, page_flags); + ret = ttm_tt_init(tt, bo, page_flags); if (ret) { DRM_ERROR("failed to initialize ttm_tt: %d\n", ret); kfree(tt); diff --git a/drivers/gpu/drm/mgag200/mgag200_ttm.c b/drivers/gpu/drm/mgag200/mgag200_ttm.c index 69beb2046008..05570f0de4d7 100644 --- a/drivers/gpu/drm/mgag200/mgag200_ttm.c +++ b/drivers/gpu/drm/mgag200/mgag200_ttm.c @@ -199,8 +199,8 @@ static struct ttm_backend_func mgag200_tt_backend_func = { }; -static struct ttm_tt *mgag200_ttm_tt_create(struct ttm_bo_device *bdev, - unsigned long size, uint32_t page_flags) +static struct ttm_tt *mgag200_ttm_tt_create(struct ttm_buffer_object *bo, + uint32_t page_flags) { struct ttm_tt *tt; @@ -208,7 +208,7 @@ static struct ttm_tt *mgag200_ttm_tt_create(struct ttm_bo_device *bdev, if (tt == NULL) return NULL; tt->func = &mgag200_tt_backend_func; - if (ttm_tt_init(tt, bdev, size, page_flags)) { + if (ttm_tt_init(tt, bo, page_flags)) { kfree(tt); return NULL; } diff --git a/drivers/gpu/drm/nouveau/nouveau_bo.c b/drivers/gpu/drm/nouveau/nouveau_bo.c index 49cc8dfcb141..6f402c4f2bdd 100644 --- a/drivers/gpu/drm/nouveau/nouveau_bo.c +++ b/drivers/gpu/drm/nouveau/nouveau_bo.c @@ -604,19 +604,17 @@ nouveau_bo_wr32(struct nouveau_bo *nvbo, unsigned index, u32 val) } static struct ttm_tt * -nouveau_ttm_tt_create(struct ttm_bo_device *bdev, unsigned long size, - uint32_t page_flags) +nouveau_ttm_tt_create(struct ttm_buffer_object *bo, uint32_t page_flags) { #if IS_ENABLED(CONFIG_AGP) - struct nouveau_drm *drm = nouveau_bdev(bdev); + struct nouveau_drm *drm = nouveau_bdev(bo->bdev); if (drm->agp.bridge) { - return ttm_agp_tt_create(bdev, drm->agp.bridge, size, - page_flags); + return ttm_agp_tt_create(bo, drm->agp.bridge, page_flags); } #endif - return nouveau_sgdma_create_ttm(bdev, size, page_flags); + return nouveau_sgdma_create_ttm(bo, page_flags); } static int diff --git a/drivers/gpu/drm/nouveau/nouveau_sgdma.c b/drivers/gpu/drm/nouveau/nouveau_sgdma.c index 87b030437f4d..8ebdc74cc0ad 100644 --- a/drivers/gpu/drm/nouveau/nouveau_sgdma.c +++ b/drivers/gpu/drm/nouveau/nouveau_sgdma.c @@ -82,10 +82,9 @@ static struct ttm_backend_func nv50_sgdma_backend = { }; struct ttm_tt * -nouveau_sgdma_create_ttm(struct ttm_bo_device *bdev, - unsigned long size, uint32_t page_flags) +nouveau_sgdma_create_ttm(struct ttm_buffer_object *bo, uint32_t page_flags) { - struct nouveau_drm *drm = nouveau_bdev(bdev); + struct nouveau_drm *drm = nouveau_bdev(bo->bdev); struct nouveau_sgdma_be *nvbe; nvbe = kzalloc(sizeof(*nvbe), GFP_KERNEL); @@ -97,7 +96,7 @@ nouveau_sgdma_create_ttm(struct ttm_bo_device *bdev, else nvbe->ttm.ttm.func = &nv50_sgdma_backend; - if (ttm_dma_tt_init(&nvbe->ttm, bdev, size, page_flags)) + if (ttm_dma_tt_init(&nvbe->ttm, bo, page_flags)) /* * A failing ttm_dma_tt_init() will call ttm_tt_destroy() * and thus our nouveau_sgdma_destroy() hook, so we don't need diff --git a/drivers/gpu/drm/nouveau/nouveau_ttm.h b/drivers/gpu/drm/nouveau/nouveau_ttm.h index 64e484ee5ef1..89929ad8c7cd 100644 --- a/drivers/gpu/drm/nouveau/nouveau_ttm.h +++ b/drivers/gpu/drm/nouveau/nouveau_ttm.h @@ -12,8 +12,8 @@ extern const struct ttm_mem_type_manager_func nouveau_vram_manager; extern const struct ttm_mem_type_manager_func nouveau_gart_manager; extern const struct ttm_mem_type_manager_func nv04_gart_manager; -struct ttm_tt *nouveau_sgdma_create_ttm(struct ttm_bo_device *, - unsigned long size, u32 page_flags); +struct ttm_tt *nouveau_sgdma_create_ttm(struct ttm_buffer_object *bo, + u32 page_flags); int nouveau_ttm_init(struct nouveau_drm *drm); void nouveau_ttm_fini(struct nouveau_drm *drm); diff --git a/drivers/gpu/drm/qxl/qxl_ttm.c b/drivers/gpu/drm/qxl/qxl_ttm.c index 2ad70eb96207..ee2340e31f06 100644 --- a/drivers/gpu/drm/qxl/qxl_ttm.c +++ b/drivers/gpu/drm/qxl/qxl_ttm.c @@ -291,19 +291,19 @@ static struct ttm_backend_func qxl_backend_func = { .destroy = &qxl_ttm_backend_destroy, }; -static struct ttm_tt *qxl_ttm_tt_create(struct ttm_bo_device *bdev, - unsigned long size, uint32_t page_flags) +static struct ttm_tt *qxl_ttm_tt_create(struct ttm_buffer_object *bo, + uint32_t page_flags) { struct qxl_device *qdev; struct qxl_ttm_tt *gtt; - qdev = qxl_get_qdev(bdev); + qdev = qxl_get_qdev(bo->bdev); gtt = kzalloc(sizeof(struct qxl_ttm_tt), GFP_KERNEL); if (gtt == NULL) return NULL; gtt->ttm.ttm.func = &qxl_backend_func; gtt->qdev = qdev; - if (ttm_dma_tt_init(>t->ttm, bdev, size, page_flags)) { + if (ttm_dma_tt_init(>t->ttm, bo, page_flags)) { kfree(gtt); return NULL; } diff --git a/drivers/gpu/drm/radeon/radeon_ttm.c b/drivers/gpu/drm/radeon/radeon_ttm.c index 009f55a2bbf9..8689fcca051c 100644 --- a/drivers/gpu/drm/radeon/radeon_ttm.c +++ b/drivers/gpu/drm/radeon/radeon_ttm.c @@ -686,17 +686,17 @@ static struct ttm_backend_func radeon_backend_func = { .destroy = &radeon_ttm_backend_destroy, }; -static struct ttm_tt *radeon_ttm_tt_create(struct ttm_bo_device *bdev, - unsigned long size, uint32_t page_flags) +static struct ttm_tt *radeon_ttm_tt_create(struct ttm_buffer_object *bo, + uint32_t page_flags) { struct radeon_device *rdev; struct radeon_ttm_tt *gtt; - rdev = radeon_get_rdev(bdev); + rdev = radeon_get_rdev(bo->bdev); #if IS_ENABLED(CONFIG_AGP) if (rdev->flags & RADEON_IS_AGP) { - return ttm_agp_tt_create(bdev, rdev->ddev->agp->bridge, - size, page_flags); + return ttm_agp_tt_create(bo, rdev->ddev->agp->bridge, + page_flags); } #endif @@ -706,7 +706,7 @@ static struct ttm_tt *radeon_ttm_tt_create(struct ttm_bo_device *bdev, } gtt->ttm.ttm.func = &radeon_backend_func; gtt->rdev = rdev; - if (ttm_dma_tt_init(>t->ttm, bdev, size, page_flags)) { + if (ttm_dma_tt_init(>t->ttm, bo, page_flags)) { kfree(gtt); return NULL; } diff --git a/drivers/gpu/drm/ttm/ttm_agp_backend.c b/drivers/gpu/drm/ttm/ttm_agp_backend.c index f7c2aefbec7c..7c2485fe88d8 100644 --- a/drivers/gpu/drm/ttm/ttm_agp_backend.c +++ b/drivers/gpu/drm/ttm/ttm_agp_backend.c @@ -110,9 +110,9 @@ static struct ttm_backend_func ttm_agp_func = { .destroy = ttm_agp_destroy, }; -struct ttm_tt *ttm_agp_tt_create(struct ttm_bo_device *bdev, +struct ttm_tt *ttm_agp_tt_create(struct ttm_buffer_object *bo, struct agp_bridge_data *bridge, - unsigned long size, uint32_t page_flags) + uint32_t page_flags) { struct ttm_agp_backend *agp_be; @@ -124,7 +124,7 @@ struct ttm_tt *ttm_agp_tt_create(struct ttm_bo_device *bdev, agp_be->bridge = bridge; agp_be->ttm.func = &ttm_agp_func; - if (ttm_tt_init(&agp_be->ttm, bdev, size, page_flags)) { + if (ttm_tt_init(&agp_be->ttm, bo, page_flags)) { kfree(agp_be); return NULL; } diff --git a/drivers/gpu/drm/ttm/ttm_tt.c b/drivers/gpu/drm/ttm/ttm_tt.c index 971133106ec2..65976238d24b 100644 --- a/drivers/gpu/drm/ttm/ttm_tt.c +++ b/drivers/gpu/drm/ttm/ttm_tt.c @@ -73,8 +73,7 @@ int ttm_tt_create(struct ttm_buffer_object *bo, bool zero_alloc) return -EINVAL; } - bo->ttm = bdev->driver->ttm_tt_create(bdev, bo->num_pages << PAGE_SHIFT, - page_flags); + bo->ttm = bdev->driver->ttm_tt_create(bo, page_flags); if (unlikely(bo->ttm == NULL)) return -ENOMEM; @@ -237,21 +236,21 @@ void ttm_tt_destroy(struct ttm_tt *ttm) ttm->func->destroy(ttm); } -void ttm_tt_init_fields(struct ttm_tt *ttm, struct ttm_bo_device *bdev, - unsigned long size, uint32_t page_flags) +void ttm_tt_init_fields(struct ttm_tt *ttm, struct ttm_buffer_object *bo, + uint32_t page_flags) { - ttm->bdev = bdev; - ttm->num_pages = (size + PAGE_SIZE - 1) >> PAGE_SHIFT; + ttm->bdev = bo->bdev; + ttm->num_pages = bo->num_pages; ttm->caching_state = tt_cached; ttm->page_flags = page_flags; ttm->state = tt_unpopulated; ttm->swap_storage = NULL; } -int ttm_tt_init(struct ttm_tt *ttm, struct ttm_bo_device *bdev, - unsigned long size, uint32_t page_flags) +int ttm_tt_init(struct ttm_tt *ttm, struct ttm_buffer_object *bo, + uint32_t page_flags) { - ttm_tt_init_fields(ttm, bdev, size, page_flags); + ttm_tt_init_fields(ttm, bo, page_flags); if (ttm_tt_alloc_page_directory(ttm)) { ttm_tt_destroy(ttm); @@ -269,12 +268,12 @@ void ttm_tt_fini(struct ttm_tt *ttm) } EXPORT_SYMBOL(ttm_tt_fini); -int ttm_dma_tt_init(struct ttm_dma_tt *ttm_dma, struct ttm_bo_device *bdev, - unsigned long size, uint32_t page_flags) +int ttm_dma_tt_init(struct ttm_dma_tt *ttm_dma, struct ttm_buffer_object *bo, + uint32_t page_flags) { struct ttm_tt *ttm = &ttm_dma->ttm; - ttm_tt_init_fields(ttm, bdev, size, page_flags); + ttm_tt_init_fields(ttm, bo, page_flags); INIT_LIST_HEAD(&ttm_dma->pages_list); if (ttm_dma_tt_alloc_page_directory(ttm_dma)) { @@ -286,13 +285,13 @@ int ttm_dma_tt_init(struct ttm_dma_tt *ttm_dma, struct ttm_bo_device *bdev, } EXPORT_SYMBOL(ttm_dma_tt_init); -int ttm_sg_tt_init(struct ttm_dma_tt *ttm_dma, struct ttm_bo_device *bdev, - unsigned long size, uint32_t page_flags) +int ttm_sg_tt_init(struct ttm_dma_tt *ttm_dma, struct ttm_buffer_object *bo, + uint32_t page_flags) { struct ttm_tt *ttm = &ttm_dma->ttm; int ret; - ttm_tt_init_fields(ttm, bdev, size, page_flags); + ttm_tt_init_fields(ttm, bo, page_flags); INIT_LIST_HEAD(&ttm_dma->pages_list); if (page_flags & TTM_PAGE_FLAG_SG) diff --git a/drivers/gpu/drm/virtio/virtgpu_ttm.c b/drivers/gpu/drm/virtio/virtgpu_ttm.c index ee9839fbae66..01618afc6bce 100644 --- a/drivers/gpu/drm/virtio/virtgpu_ttm.c +++ b/drivers/gpu/drm/virtio/virtgpu_ttm.c @@ -324,20 +324,19 @@ static struct ttm_backend_func virtio_gpu_backend_func = { .destroy = &virtio_gpu_ttm_backend_destroy, }; -static struct ttm_tt *virtio_gpu_ttm_tt_create(struct ttm_bo_device *bdev, - unsigned long size, +static struct ttm_tt *virtio_gpu_ttm_tt_create(struct ttm_buffer_object *bo, uint32_t page_flags) { struct virtio_gpu_device *vgdev; struct virtio_gpu_ttm_tt *gtt; - vgdev = virtio_gpu_get_vgdev(bdev); + vgdev = virtio_gpu_get_vgdev(bo->bdev); gtt = kzalloc(sizeof(struct virtio_gpu_ttm_tt), GFP_KERNEL); if (gtt == NULL) return NULL; gtt->ttm.ttm.func = &virtio_gpu_backend_func; gtt->vgdev = vgdev; - if (ttm_dma_tt_init(>t->ttm, bdev, size, page_flags)) { + if (ttm_dma_tt_init(>t->ttm, bo, page_flags)) { kfree(gtt); return NULL; } diff --git a/drivers/gpu/drm/vmwgfx/vmwgfx_buffer.c b/drivers/gpu/drm/vmwgfx/vmwgfx_buffer.c index fead3f2dbb46..7177eecb8c9f 100644 --- a/drivers/gpu/drm/vmwgfx/vmwgfx_buffer.c +++ b/drivers/gpu/drm/vmwgfx/vmwgfx_buffer.c @@ -693,8 +693,8 @@ static struct ttm_backend_func vmw_ttm_func = { .destroy = vmw_ttm_destroy, }; -static struct ttm_tt *vmw_ttm_tt_create(struct ttm_bo_device *bdev, - unsigned long size, uint32_t page_flags) +static struct ttm_tt *vmw_ttm_tt_create(struct ttm_buffer_object *bo, + uint32_t page_flags) { struct vmw_ttm_tt *vmw_be; int ret; @@ -704,13 +704,13 @@ static struct ttm_tt *vmw_ttm_tt_create(struct ttm_bo_device *bdev, return NULL; vmw_be->dma_ttm.ttm.func = &vmw_ttm_func; - vmw_be->dev_priv = container_of(bdev, struct vmw_private, bdev); + vmw_be->dev_priv = container_of(bo->bdev, struct vmw_private, bdev); vmw_be->mob = NULL; if (vmw_be->dev_priv->map_mode == vmw_dma_alloc_coherent) - ret = ttm_dma_tt_init(&vmw_be->dma_ttm, bdev, size, page_flags); + ret = ttm_dma_tt_init(&vmw_be->dma_ttm, bo, page_flags); else - ret = ttm_tt_init(&vmw_be->dma_ttm.ttm, bdev, size, page_flags); + ret = ttm_tt_init(&vmw_be->dma_ttm.ttm, bo, page_flags); if (unlikely(ret != 0)) goto out_no_init; diff --git a/drivers/staging/vboxvideo/vbox_ttm.c b/drivers/staging/vboxvideo/vbox_ttm.c index 2c7daa3d0f24..548edb7c494b 100644 --- a/drivers/staging/vboxvideo/vbox_ttm.c +++ b/drivers/staging/vboxvideo/vbox_ttm.c @@ -193,8 +193,7 @@ static struct ttm_backend_func vbox_tt_backend_func = { .destroy = &vbox_ttm_backend_destroy, }; -static struct ttm_tt *vbox_ttm_tt_create(struct ttm_bo_device *bdev, - unsigned long size, +static struct ttm_tt *vbox_ttm_tt_create(struct ttm_buffer_object *bo, u32 page_flags) { struct ttm_tt *tt; @@ -204,7 +203,7 @@ static struct ttm_tt *vbox_ttm_tt_create(struct ttm_bo_device *bdev, return NULL; tt->func = &vbox_tt_backend_func; - if (ttm_tt_init(tt, bdev, size, page_flags)) { + if (ttm_tt_init(tt, bo, page_flags)) { kfree(tt); return NULL; } diff --git a/include/drm/ttm/ttm_bo_driver.h b/include/drm/ttm/ttm_bo_driver.h index 39cd6b086d3a..3234cc322e70 100644 --- a/include/drm/ttm/ttm_bo_driver.h +++ b/include/drm/ttm/ttm_bo_driver.h @@ -225,8 +225,7 @@ struct ttm_bo_driver { /** * ttm_tt_create * - * @bdev: pointer to a struct ttm_bo_device: - * @size: Size of the data needed backing. + * @bo: The buffer object to create the ttm for. * @page_flags: Page flags as identified by TTM_PAGE_FLAG_XX flags. * * Create a struct ttm_tt to back data with system memory pages. @@ -234,8 +233,7 @@ struct ttm_bo_driver { * Returns: * NULL: Out of memory. */ - struct ttm_tt *(*ttm_tt_create)(struct ttm_bo_device *bdev, - unsigned long size, + struct ttm_tt *(*ttm_tt_create)(struct ttm_buffer_object *bo, uint32_t page_flags); /** diff --git a/include/drm/ttm/ttm_tt.h b/include/drm/ttm/ttm_tt.h index 1cf316a4257c..c0e928abf592 100644 --- a/include/drm/ttm/ttm_tt.h +++ b/include/drm/ttm/ttm_tt.h @@ -150,8 +150,7 @@ int ttm_tt_create(struct ttm_buffer_object *bo, bool zero_alloc); * ttm_tt_init * * @ttm: The struct ttm_tt. - * @bdev: pointer to a struct ttm_bo_device: - * @size: Size of the data needed backing. + * @bo: The buffer object we create the ttm for. * @page_flags: Page flags as identified by TTM_PAGE_FLAG_XX flags. * * Create a struct ttm_tt to back data with system memory pages. @@ -159,12 +158,12 @@ int ttm_tt_create(struct ttm_buffer_object *bo, bool zero_alloc); * Returns: * NULL: Out of memory. */ -int ttm_tt_init(struct ttm_tt *ttm, struct ttm_bo_device *bdev, - unsigned long size, uint32_t page_flags); -int ttm_dma_tt_init(struct ttm_dma_tt *ttm_dma, struct ttm_bo_device *bdev, - unsigned long size, uint32_t page_flags); -int ttm_sg_tt_init(struct ttm_dma_tt *ttm_dma, struct ttm_bo_device *bdev, - unsigned long size, uint32_t page_flags); +int ttm_tt_init(struct ttm_tt *ttm, struct ttm_buffer_object *bo, + uint32_t page_flags); +int ttm_dma_tt_init(struct ttm_dma_tt *ttm_dma, struct ttm_buffer_object *bo, + uint32_t page_flags); +int ttm_sg_tt_init(struct ttm_dma_tt *ttm_dma, struct ttm_buffer_object *bo, + uint32_t page_flags); /** * ttm_tt_fini @@ -254,9 +253,8 @@ void ttm_tt_unpopulate(struct ttm_tt *ttm); /** * ttm_agp_tt_create * - * @bdev: Pointer to a struct ttm_bo_device. + * @bo: Buffer object we allocate the ttm for. * @bridge: The agp bridge this device is sitting on. - * @size: Size of the data needed backing. * @page_flags: Page flags as identified by TTM_PAGE_FLAG_XX flags. * * @@ -264,9 +262,9 @@ void ttm_tt_unpopulate(struct ttm_tt *ttm); * for TT memory. This function uses the linux agpgart interface to * bind and unbind memory backing a ttm_tt. */ -struct ttm_tt *ttm_agp_tt_create(struct ttm_bo_device *bdev, +struct ttm_tt *ttm_agp_tt_create(struct ttm_buffer_object *bo, struct agp_bridge_data *bridge, - unsigned long size, uint32_t page_flags); + uint32_t page_flags); int ttm_agp_tt_populate(struct ttm_tt *ttm, struct ttm_operation_ctx *ctx); void ttm_agp_tt_unpopulate(struct ttm_tt *ttm); #endif