From patchwork Wed Aug 14 18:22:54 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: Chris Wilson X-Patchwork-Id: 11094289 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 81ADD1395 for ; Wed, 14 Aug 2019 18:23:07 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 7213C288AA for ; Wed, 14 Aug 2019 18:23:07 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 66258288A2; Wed, 14 Aug 2019 18:23: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=-5.2 required=2.0 tests=BAYES_00,MAILING_LIST_MULTI, RCVD_IN_DNSWL_MED autolearn=unavailable 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 E4D29288A2 for ; Wed, 14 Aug 2019 18:23:06 +0000 (UTC) Received: from gabe.freedesktop.org (localhost [127.0.0.1]) by gabe.freedesktop.org (Postfix) with ESMTP id 9FCA96E7BD; Wed, 14 Aug 2019 18:23:03 +0000 (UTC) X-Original-To: dri-devel@lists.freedesktop.org Delivered-To: dri-devel@lists.freedesktop.org Received: from fireflyinternet.com (mail.fireflyinternet.com [109.228.58.192]) by gabe.freedesktop.org (Postfix) with ESMTPS id 827B489E5F; Wed, 14 Aug 2019 18:23:01 +0000 (UTC) X-Default-Received-SPF: pass (skip=forwardok (res=PASS)) x-ip-name=78.156.65.138; Received: from haswell.alporthouse.com (unverified [78.156.65.138]) by fireflyinternet.com (Firefly Internet (M1)) with ESMTP id 18112583-1500050 for multiple; Wed, 14 Aug 2019 19:22:55 +0100 From: Chris Wilson To: dri-devel@lists.freedesktop.org Subject: [PATCH] ttm Date: Wed, 14 Aug 2019 19:22:54 +0100 Message-Id: <20190814182254.24955-1-chris@chris-wilson.co.uk> X-Mailer: git-send-email 2.23.0.rc1 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: , Cc: intel-gfx@lists.freedesktop.org Errors-To: dri-devel-bounces@lists.freedesktop.org Sender: "dri-devel" X-Virus-Scanned: ClamAV using ClamSMTP --- drivers/gpu/drm/i915/Makefile | 7 + drivers/gpu/drm/i915/ttm/Makefile | 5 + drivers/gpu/drm/i915/ttm/i915_ttm_drv.c | 4 + drivers/gpu/drm/i915/ttm/i915_ttm_drv.h | 12 ++ drivers/gpu/drm/i915/ttm/i915_ttm_ppgtt.c | 174 ++++++++++++++++++++++ drivers/gpu/drm/i915/ttm/i915_ttm_ppgtt.h | 22 +++ 6 files changed, 224 insertions(+) create mode 100644 drivers/gpu/drm/i915/ttm/Makefile create mode 100644 drivers/gpu/drm/i915/ttm/i915_ttm_drv.c create mode 100644 drivers/gpu/drm/i915/ttm/i915_ttm_drv.h create mode 100644 drivers/gpu/drm/i915/ttm/i915_ttm_ppgtt.c create mode 100644 drivers/gpu/drm/i915/ttm/i915_ttm_ppgtt.h diff --git a/drivers/gpu/drm/i915/Makefile b/drivers/gpu/drm/i915/Makefile index 64db6fe5672b..14936e70ee2b 100644 --- a/drivers/gpu/drm/i915/Makefile +++ b/drivers/gpu/drm/i915/Makefile @@ -98,6 +98,12 @@ gt-y += \ gt/gen8_renderstate.o \ gt/gen9_renderstate.o i915-y += $(gt-y) +# +# TTM (translation table managmeent) code +obj-y += ttm/ +ttm-y += \ + ttm/i915_ttm_drv.o \ + ttm/i915_ttm_ppgtt.o # GEM (Graphics Execution Management) code obj-y += gem/ @@ -126,6 +132,7 @@ gem-y += \ gem/i915_gem_wait.o \ gem/i915_gemfs.o i915-y += \ + $(ttm-y) \ $(gem-y) \ i915_active.o \ i915_buddy.o \ diff --git a/drivers/gpu/drm/i915/ttm/Makefile b/drivers/gpu/drm/i915/ttm/Makefile new file mode 100644 index 000000000000..7e73aa587967 --- /dev/null +++ b/drivers/gpu/drm/i915/ttm/Makefile @@ -0,0 +1,5 @@ +# For building individual subdir files on the command line +subdir-ccflags-y += -I$(srctree)/$(src)/.. + +# Extra header tests +header-test-pattern-$(CONFIG_DRM_I915_WERROR) := *.h diff --git a/drivers/gpu/drm/i915/ttm/i915_ttm_drv.c b/drivers/gpu/drm/i915/ttm/i915_ttm_drv.c new file mode 100644 index 000000000000..863fbdad12eb --- /dev/null +++ b/drivers/gpu/drm/i915/ttm/i915_ttm_drv.c @@ -0,0 +1,4 @@ +/* SPDX-License-Identifier: MIT */ +/* + * Copyright © 2019 Intel Corporation + */ diff --git a/drivers/gpu/drm/i915/ttm/i915_ttm_drv.h b/drivers/gpu/drm/i915/ttm/i915_ttm_drv.h new file mode 100644 index 000000000000..a2ad743ccc12 --- /dev/null +++ b/drivers/gpu/drm/i915/ttm/i915_ttm_drv.h @@ -0,0 +1,12 @@ +/* SPDX-License-Identifier: MIT */ +/* + * Copyright © 2019 Intel Corporation + */ + +#ifndef I915_TTM_DRV_H +#define I915_TTM_DRV_H + +struct i915_ttm_drv { +}; + +#endif /* I915_TTM_DRV_H */ diff --git a/drivers/gpu/drm/i915/ttm/i915_ttm_ppgtt.c b/drivers/gpu/drm/i915/ttm/i915_ttm_ppgtt.c new file mode 100644 index 000000000000..21a5e5e1027e --- /dev/null +++ b/drivers/gpu/drm/i915/ttm/i915_ttm_ppgtt.c @@ -0,0 +1,174 @@ +/* SPDX-License-Identifier: MIT */ +/* + * Copyright © 2019 Intel Corporation + */ + +#include "i915_ttm_ppgtt.h" + +static struct ttm_tt *ppgtt_tt_create(struct ttm_buffer_object *bo, + u32 page_flags) +{ + pr_err("%s\n", __func__); + return NULL; +} + +static int ppgtt_tt_populate(struct ttm_tt *ttm, struct ttm_operation_ctx *ctx) +{ + pr_err("%s\n", __func__); + return 0; +} + +static void ppgtt_tt_unpopulate(struct ttm_tt *ttm) +{ + pr_err("%s\n", __func__); +} + +static int ppgtt_invalidate_caches(struct ttm_bo_device *bdev, u32 flags) +{ + pr_err("%s\n", __func__); + return 0; +} + +static int ppgtt_init_mem_type(struct ttm_bo_device *bdev, u32 type, + struct ttm_mem_type_manager *man) +{ + pr_err("%s\n", __func__); + return 0; +} + +static bool ppgtt_eviction_valuable(struct ttm_buffer_object *bo, + const struct ttm_place *place) +{ + pr_err("%s\n", __func__); + return false; +} + +static void ppgtt_evict_flags(struct ttm_buffer_object *bo, + struct ttm_placement *placement) +{ + pr_err("%s\n", __func__); +} + +static int ppgtt_move(struct ttm_buffer_object *bo, bool evict, + struct ttm_operation_ctx *ctx, + struct ttm_mem_reg *new_mem) +{ + pr_err("%s\n", __func__); + return 0; +} + +static int ppgtt_verify_access(struct ttm_buffer_object *bo, + struct file *filp) +{ + pr_err("%s\n", __func__); + return 0; +} + +static void ppgtt_move_notify(struct ttm_buffer_object *bo, + bool evict, + struct ttm_mem_reg *new_mem) +{ + pr_err("%s\n", __func__); +} + +static int ppgtt_fault_reserve_notify(struct ttm_buffer_object *bo) +{ + pr_err("%s\n", __func__); + return 0; +} + +static void ppgtt_swap_notify(struct ttm_buffer_object *bo) +{ + pr_err("%s\n", __func__); +} + +static int ppgtt_io_mem_reserve(struct ttm_bo_device *bdev, + struct ttm_mem_reg *mem) +{ + pr_err("%s\n", __func__); + return 0; +} + +static void ppgtt_io_mem_free(struct ttm_bo_device *bdev, + struct ttm_mem_reg *mem) +{ + pr_err("%s\n", __func__); +} + +static unsigned long ppgtt_io_mem_pfn(struct ttm_buffer_object *bo, + unsigned long page_offset) +{ + pr_err("%s\n", __func__); + return 0; +} + +static int ppgtt_access_memory(struct ttm_buffer_object *bo, + unsigned long offset, + void *buf, int len, int write) +{ + pr_err("%s\n", __func__); + return 0; +} + +static void ppgtt_del_from_lru_notify(struct ttm_buffer_object *bo) +{ + pr_err("%s\n", __func__); +} + +static void ppgtt_release_notify(struct ttm_buffer_object *bo) +{ + pr_err("%s\n", __func__); +} + +static struct ttm_bo_driver bo_driver = { + .ttm_tt_create = ppgtt_tt_create, + .ttm_tt_populate = ppgtt_tt_populate, + .ttm_tt_unpopulate = ppgtt_tt_unpopulate, + + .invalidate_caches = ppgtt_invalidate_caches, + .init_mem_type = ppgtt_init_mem_type, + .eviction_valuable = ppgtt_eviction_valuable, + .evict_flags = ppgtt_evict_flags, + + .move = ppgtt_move, + .verify_access = ppgtt_verify_access, + .move_notify = ppgtt_move_notify, + .fault_reserve_notify = ppgtt_fault_reserve_notify, + .swap_notify = ppgtt_swap_notify, + + .io_mem_reserve = ppgtt_io_mem_reserve, + .io_mem_free = ppgtt_io_mem_free, + .io_mem_pfn = ppgtt_io_mem_pfn, + + .access_memory = ppgtt_access_memory, + .del_from_lru_notify = ppgtt_del_from_lru_notify, + .release_notify = ppgtt_release_notify, +}; + +struct i915_ttm_ppgtt *i915_ttm_ppgtt_create(struct drm_i915_private *i915) +{ + struct i915_ttm_ppgtt *ppgtt; + int err = 0; + + ppgtt = kzalloc(sizeof(*ppgtt), GFP_KERNEL); + if (!ppgtt) + return NULL; + + address_space_init_once(&ppgtt->mapping); + + err = ttm_bo_device_init(&ppgtt->bdev, &bo_driver, + &ppgtt->mapping, true); + if (err) + goto err_free; + + err = ttm_bo_init_mm(&ppgtt->bdev, TTM_PL_TT, BIT_ULL(48)); + if (err) + goto err_dev; + + return ppgtt; + +err_dev: +err_free: + kfree(ppgtt); + return ERR_PTR(err); +} diff --git a/drivers/gpu/drm/i915/ttm/i915_ttm_ppgtt.h b/drivers/gpu/drm/i915/ttm/i915_ttm_ppgtt.h new file mode 100644 index 000000000000..6c4bd069c65b --- /dev/null +++ b/drivers/gpu/drm/i915/ttm/i915_ttm_ppgtt.h @@ -0,0 +1,22 @@ +/* SPDX-License-Identifier: MIT */ +/* + * Copyright © 2019 Intel Corporation + */ + +#ifndef I915_TTM_PPGTT_H +#define I915_TTM_PPGTT_H + +#include + +#include + +struct drm_i915_private; + +struct i915_ttm_ppgtt { + struct ttm_bo_device bdev; + struct address_space mapping; +}; + +struct i915_ttm_ppgtt *i915_ttm_ppgtt_create(struct drm_i915_private *i915); + +#endif /* I915_TTM_PPGTT_H */