[Intel-gfx] [PATCH] ttm

Chris Wilson chris at chris-wilson.co.uk
Wed Aug 14 18:22:54 UTC 2019


---
 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 <linux/fs.h>
+
+#include <drm/ttm/ttm_bo_driver.h>
+
+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 */
-- 
2.23.0.rc1



More information about the Intel-gfx mailing list