[Intel-gfx] [PATCH] drm/i915/gem: Allow importing of shmemfs objects into any device

Chris Wilson chris at chris-wilson.co.uk
Wed Jan 20 15:40:19 UTC 2021


If we import a shmemfs object between devices, for example from
Tigerlake to DG1, we can simply reuse the native object and its backing
store.

Suggested-by: Imre Deak <imre.deak at intel.com>
Signed-off-by: Chris Wilson <chris at chris-wilson.co.uk>
Cc: Matthew Auld <matthew.auld at intel.com>
Cc: Imre Deak <imre.deak at intel.com>
---
 drivers/gpu/drm/i915/gem/i915_gem_dmabuf.c | 7 +++++++
 1 file changed, 7 insertions(+)

diff --git a/drivers/gpu/drm/i915/gem/i915_gem_dmabuf.c b/drivers/gpu/drm/i915/gem/i915_gem_dmabuf.c
index 04e9c04545ad..4816f08c4009 100644
--- a/drivers/gpu/drm/i915/gem/i915_gem_dmabuf.c
+++ b/drivers/gpu/drm/i915/gem/i915_gem_dmabuf.c
@@ -242,6 +242,13 @@ struct drm_gem_object *i915_gem_prime_import(struct drm_device *dev,
 			 */
 			return &i915_gem_object_get(obj)->base;
 		}
+
+		/*
+		 * If the object is in plain system memory, we can reuse the
+		 * same backing store in any device.
+		 */
+		if (i915_gem_object_is_shmem(obj))
+			return &i915_gem_object_get(obj)->base;
 	}
 
 	/* need to attach */
-- 
2.20.1



More information about the Intel-gfx mailing list