[RFC PATCH 1/2] drm/i915: Add vmap and vunmap callback

Jouni Högander jouni.hogander at intel.com
Wed Feb 2 15:36:03 UTC 2022


Generic fbdev emulation is doing cpu copy into allocated dumb buffer.
This requires mapping / unammping framebuffer.

This patch is adding vmap and vunmap callbacks to i915_gem_object_funcs.

Signed-off-by: Jouni Högander <jouni.hogander at intel.com>
---
 drivers/gpu/drm/i915/gem/i915_gem_object.c | 28 ++++++++++++++++++++++
 1 file changed, 28 insertions(+)

diff --git a/drivers/gpu/drm/i915/gem/i915_gem_object.c b/drivers/gpu/drm/i915/gem/i915_gem_object.c
index e03e362d320b..354292508a48 100644
--- a/drivers/gpu/drm/i915/gem/i915_gem_object.c
+++ b/drivers/gpu/drm/i915/gem/i915_gem_object.c
@@ -26,6 +26,7 @@
 
 #include "display/intel_frontbuffer.h"
 #include "pxp/intel_pxp.h"
+#include <drm/drm_gem_ttm_helper.h>
 #include "i915_drv.h"
 #include "i915_gem_clflush.h"
 #include "i915_gem_context.h"
@@ -739,10 +740,37 @@ int __init i915_objects_module_init(void)
 	return 0;
 }
 
+static int i915_gem_vmap(struct drm_gem_object *gem,
+		     struct dma_buf_map *map)
+{
+	struct drm_i915_gem_object *obj = to_intel_bo(gem);
+	enum i915_map_type type;
+	void *vaddr;
+
+	type = i915_coherent_map_type(to_i915(obj->base.dev), obj, true);
+	vaddr = i915_gem_object_pin_map_unlocked(obj, type);
+	if (IS_ERR(vaddr))
+		return PTR_ERR(vaddr);
+
+	dma_buf_map_set_vaddr(map, vaddr);
+
+	return 0;
+}
+
+static void i915_gem_vunmap(struct drm_gem_object *gem,
+			struct dma_buf_map *map)
+{
+	struct drm_i915_gem_object *obj = to_intel_bo(gem);
+
+	i915_gem_object_unpin_map(obj);
+}
+
 static const struct drm_gem_object_funcs i915_gem_object_funcs = {
 	.free = i915_gem_free_object,
 	.close = i915_gem_close_object,
 	.export = i915_gem_prime_export,
+	.vmap = i915_gem_vmap,
+	.vunmap = i915_gem_vunmap,
 };
 
 /**
-- 
2.25.1



More information about the Intel-gfx-trybot mailing list