From patchwork Fri Apr 30 09:24:56 2021 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: 12232837 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-13.5 required=3.0 tests=BAYES_00, DKIM_ADSP_CUSTOM_MED,DKIM_INVALID,DKIM_SIGNED,FREEMAIL_FORGED_FROMDOMAIN, FREEMAIL_FROM,HEADER_FROM_DIFFERENT_DOMAINS,INCLUDES_CR_TRAILER, INCLUDES_PATCH,MAILING_LIST_MULTI,SPF_HELO_NONE,SPF_PASS,USER_AGENT_GIT autolearn=ham autolearn_force=no version=3.4.0 Received: from mail.kernel.org (mail.kernel.org [198.145.29.99]) by smtp.lore.kernel.org (Postfix) with ESMTP id 99B5BC433B4 for ; Fri, 30 Apr 2021 09:25:13 +0000 (UTC) Received: from gabe.freedesktop.org (gabe.freedesktop.org [131.252.210.177]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mail.kernel.org (Postfix) with ESMTPS id 4C3CD61352 for ; Fri, 30 Apr 2021 09:25:13 +0000 (UTC) DMARC-Filter: OpenDMARC Filter v1.3.2 mail.kernel.org 4C3CD61352 Authentication-Results: mail.kernel.org; dmarc=fail (p=none dis=none) header.from=gmail.com Authentication-Results: mail.kernel.org; spf=none smtp.mailfrom=dri-devel-bounces@lists.freedesktop.org Received: from gabe.freedesktop.org (localhost [127.0.0.1]) by gabe.freedesktop.org (Postfix) with ESMTP id 963F66F503; Fri, 30 Apr 2021 09:25:12 +0000 (UTC) Received: from mail-ej1-x634.google.com (mail-ej1-x634.google.com [IPv6:2a00:1450:4864:20::634]) by gabe.freedesktop.org (Postfix) with ESMTPS id 84E796F503 for ; Fri, 30 Apr 2021 09:25:11 +0000 (UTC) Received: by mail-ej1-x634.google.com with SMTP id f24so5677074ejc.6 for ; Fri, 30 Apr 2021 02:25:11 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=from:to:cc:subject:date:message-id:mime-version :content-transfer-encoding; bh=P4e0Y6+hS4/K3bhBW/GEn8l7kXdxRUpzJe3iWfonmPI=; b=bN+rvQ+EZVIs37ULX/Wxq+iagkQeoveQOYYwYvlMQTWeyOicaz0uXPLdgDCSf5Ss8x JYE7K4zuSPMID/G8hCw1hoJmxX6V8XPTLbdoNh6E6Gyn+xTQsokYlfqg7sQjiZVdc4Nk keEUQSFk2FSnQx+37t6FzeD7BmAwuo1ifZ9zDz84OOKuH+U659DV5OWDQTqK+EeVBCqV g/F7jVY2JKgtky7xYBaavjUSrHPd9aMpZ9yOnroOkVgMOUmCVB9iGT+uGWbo3Zdoz8xK +rZH2bVFrXj7WSHGh11jLKYwjwx2g+qRrQoEjFKjbjHVSPYhVkYUFh5ibGovxwopMpfL Izhw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:cc:subject:date:message-id:mime-version :content-transfer-encoding; bh=P4e0Y6+hS4/K3bhBW/GEn8l7kXdxRUpzJe3iWfonmPI=; b=J55EG6rMvWcEhQgsmKkDyLn4xnLJabq254sDANAFVpBcGFJzsPbuelHK42d+X4sM8M uJv6qxOV0OYGTfBuW6MLwtjAYQIwHm7m2ziXziLuJpsNjaPdqNcbNOyLa15NRqWtMmUp s+RJvyeuNNzsJNE4v3XcMacIFG9ek2Xnk2cW5SXqlQtiz3l6nLbkyG95ZnZvma4TADA4 SFkGeABuHS+37Vpoh1iDQ06pst1+HjfU0lXgjm2GI5gjLZkbzg3p1cKjP0rcO0EdrOUB p/NNRrMCJ6rWqYKRhGE+q1VJmjzhSpoVzkESFe7fufL1JkOhqQm4TawgkCKSoihF95tE jXwA== X-Gm-Message-State: AOAM530RPidIEonJsYsujkWTH4tnzTVK0XWvtxDiw3vgpfzB9pQJVDJr BRMyCCEMJZn0cYpYmbuzUSyduIGSDSo= X-Google-Smtp-Source: ABdhPJxAFlmmVjQA2Zs15vq4kgy4D0lzyX4FeG4hGCxYlGMF/SLah5toxg99niZbwt8Kyf3ayzYabg== X-Received: by 2002:a17:906:7ac9:: with SMTP id k9mr3290062ejo.229.1619774710164; Fri, 30 Apr 2021 02:25:10 -0700 (PDT) Received: from abel.fritz.box ([2a02:908:1252:fb60:d08c:9633:b7a2:37e2]) by smtp.gmail.com with ESMTPSA id h23sm1550959ejx.90.2021.04.30.02.25.09 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 30 Apr 2021 02:25:09 -0700 (PDT) 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 01/13] drm/ttm: add ttm_sys_manager v2 Date: Fri, 30 Apr 2021 11:24:56 +0200 Message-Id: <20210430092508.60710-1-christian.koenig@amd.com> X-Mailer: git-send-email 2.25.1 MIME-Version: 1.0 X-BeenThere: dri-devel@lists.freedesktop.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: Direct Rendering Infrastructure - Development List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: daniel.vetter@ffwll.ch, matthew.william.auld@gmail.com Errors-To: dri-devel-bounces@lists.freedesktop.org Sender: "dri-devel" Add a separate manager for the system domain and make function tables mandatory. v2: debug is still optional Signed-off-by: Christian König Reviewed-by: Matthew Auld --- drivers/gpu/drm/ttm/Makefile | 2 +- drivers/gpu/drm/ttm/ttm_device.c | 17 +----------- drivers/gpu/drm/ttm/ttm_module.h | 3 ++ drivers/gpu/drm/ttm/ttm_resource.c | 11 ++------ drivers/gpu/drm/ttm/ttm_sys_manager.c | 40 +++++++++++++++++++++++++++ 5 files changed, 48 insertions(+), 25 deletions(-) create mode 100644 drivers/gpu/drm/ttm/ttm_sys_manager.c diff --git a/drivers/gpu/drm/ttm/Makefile b/drivers/gpu/drm/ttm/Makefile index 40e5e9da7953..f906b22959cf 100644 --- a/drivers/gpu/drm/ttm/Makefile +++ b/drivers/gpu/drm/ttm/Makefile @@ -4,7 +4,7 @@ ttm-y := ttm_tt.o ttm_bo.o ttm_bo_util.o ttm_bo_vm.o ttm_module.o \ ttm_execbuf_util.o ttm_range_manager.o ttm_resource.o ttm_pool.o \ - ttm_device.o + ttm_device.o ttm_sys_manager.o ttm-$(CONFIG_AGP) += ttm_agp_backend.o obj-$(CONFIG_DRM_TTM) += ttm.o diff --git a/drivers/gpu/drm/ttm/ttm_device.c b/drivers/gpu/drm/ttm/ttm_device.c index b169e9a4f5d4..460953dcad11 100644 --- a/drivers/gpu/drm/ttm/ttm_device.c +++ b/drivers/gpu/drm/ttm/ttm_device.c @@ -165,21 +165,6 @@ int ttm_device_swapout(struct ttm_device *bdev, struct ttm_operation_ctx *ctx, } EXPORT_SYMBOL(ttm_device_swapout); -static void ttm_init_sysman(struct ttm_device *bdev) -{ - struct ttm_resource_manager *man = &bdev->sysman; - - /* - * Initialize the system memory buffer type. - * Other types need to be driver / IOCTL initialized. - */ - man->use_tt = true; - - ttm_resource_manager_init(man, 0); - ttm_set_driver_manager(bdev, TTM_PL_SYSTEM, man); - ttm_resource_manager_set_used(man, true); -} - static void ttm_device_delayed_workqueue(struct work_struct *work) { struct ttm_device *bdev = @@ -222,7 +207,7 @@ int ttm_device_init(struct ttm_device *bdev, struct ttm_device_funcs *funcs, bdev->funcs = funcs; - ttm_init_sysman(bdev); + ttm_sys_man_init(bdev); ttm_pool_init(&bdev->pool, dev, use_dma_alloc, use_dma32); bdev->vma_manager = vma_manager; diff --git a/drivers/gpu/drm/ttm/ttm_module.h b/drivers/gpu/drm/ttm/ttm_module.h index d7cac5d4b835..26564a98958f 100644 --- a/drivers/gpu/drm/ttm/ttm_module.h +++ b/drivers/gpu/drm/ttm/ttm_module.h @@ -34,7 +34,10 @@ #define TTM_PFX "[TTM] " struct dentry; +struct ttm_device; extern struct dentry *ttm_debugfs_root; +int ttm_sys_man_init(struct ttm_device *bdev); + #endif /* _TTM_MODULE_H_ */ diff --git a/drivers/gpu/drm/ttm/ttm_resource.c b/drivers/gpu/drm/ttm/ttm_resource.c index 04f2eef653ab..fc351700d035 100644 --- a/drivers/gpu/drm/ttm/ttm_resource.c +++ b/drivers/gpu/drm/ttm/ttm_resource.c @@ -33,9 +33,6 @@ int ttm_resource_alloc(struct ttm_buffer_object *bo, ttm_manager_type(bo->bdev, res->mem_type); res->mm_node = NULL; - if (!man->func || !man->func->alloc) - return 0; - return man->func->alloc(man, bo, place, res); } @@ -44,9 +41,7 @@ void ttm_resource_free(struct ttm_buffer_object *bo, struct ttm_resource *res) struct ttm_resource_manager *man = ttm_manager_type(bo->bdev, res->mem_type); - if (man->func && man->func->free) - man->func->free(man, res); - + man->func->free(man, res); res->mm_node = NULL; res->mem_type = TTM_PL_SYSTEM; } @@ -139,7 +134,7 @@ void ttm_resource_manager_debug(struct ttm_resource_manager *man, drm_printf(p, " use_type: %d\n", man->use_type); drm_printf(p, " use_tt: %d\n", man->use_tt); drm_printf(p, " size: %llu\n", man->size); - if (man->func && man->func->debug) - (*man->func->debug)(man, p); + if (man->func->debug) + man->func->debug(man, p); } EXPORT_SYMBOL(ttm_resource_manager_debug); diff --git a/drivers/gpu/drm/ttm/ttm_sys_manager.c b/drivers/gpu/drm/ttm/ttm_sys_manager.c new file mode 100644 index 000000000000..ed92615214e3 --- /dev/null +++ b/drivers/gpu/drm/ttm/ttm_sys_manager.c @@ -0,0 +1,40 @@ +/* SPDX-License-Identifier: GPL-2.0 OR MIT */ + +#include +#include +#include + +static int ttm_sys_man_alloc(struct ttm_resource_manager *man, + struct ttm_buffer_object *bo, + const struct ttm_place *place, + struct ttm_resource *mem) +{ + return 0; +} + +static void ttm_sys_man_free(struct ttm_resource_manager *man, + struct ttm_resource *mem) +{ +} + +static const struct ttm_resource_manager_func ttm_sys_manager_func = { + .alloc = ttm_sys_man_alloc, + .free = ttm_sys_man_free, +}; + +int ttm_sys_man_init(struct ttm_device *bdev) +{ + struct ttm_resource_manager *man = &bdev->sysman; + + /* + * Initialize the system memory buffer type. + * Other types need to be driver / IOCTL initialized. + */ + man->use_tt = true; + man->func = &ttm_sys_manager_func; + + ttm_resource_manager_init(man, 0); + ttm_set_driver_manager(bdev, TTM_PL_SYSTEM, man); + ttm_resource_manager_set_used(man, true); + return 0; +}