[Intel-gfx] [RFC] drm/i195: Add flag to enable virtual mappings above 4Gb

Nick Hoath nicholas.hoath at intel.com
Wed Mar 18 09:57:53 PDT 2015


Wa32bitGeneralStateOffset & Wa32bitInstructionBaseOffset hardware
workarounds require that GeneralStateOffset & InstructionBaseOffset
are restricted to a 32 bit address space.

This is a preparatory patch prior to supporting 64bit virtual memory
allocations.

Allow the user space to flag that a mapping can occur beyond
the 32bit limit. This allows backward compatibility and user space
drivers that haven't been enhanced to support these workarounds to
function.

Signed-off-by: Nick Hoath <nicholas.hoath at intel.com>
---
 drivers/gpu/drm/i915/i915_drv.h |  6 ++++++
 drivers/gpu/drm/i915/i915_gem.c | 18 +++++++++++++++---
 include/uapi/drm/i915_drm.h     |  7 ++++++-
 3 files changed, 27 insertions(+), 4 deletions(-)

diff --git a/drivers/gpu/drm/i915/i915_drv.h b/drivers/gpu/drm/i915/i915_drv.h
index 3cc0196..1e6fc1d 100644
--- a/drivers/gpu/drm/i915/i915_drv.h
+++ b/drivers/gpu/drm/i915/i915_drv.h
@@ -2066,6 +2066,12 @@ struct drm_i915_gem_object {
 	unsigned int has_dma_mapping:1;
 
 	unsigned int frontbuffer_bits:INTEL_FRONTBUFFER_BITS;
+
+	/**
+	 * If the object should be mapped in to the bottom 4Gb
+	 * memory space only, then this flag should not be set
+	 */
+	unsigned int hi_mem:1;
 
 	struct sg_table *pages;
 	int pages_pin_count;
diff --git a/drivers/gpu/drm/i915/i915_gem.c b/drivers/gpu/drm/i915/i915_gem.c
index 61134ab..efa782c 100644
--- a/drivers/gpu/drm/i915/i915_gem.c
+++ b/drivers/gpu/drm/i915/i915_gem.c
@@ -395,7 +395,9 @@ static int
 i915_gem_create(struct drm_file *file,
 		struct drm_device *dev,
 		uint64_t size,
-		uint32_t *handle_p)
+		uint32_t *handle_p,
+		uint32_t flags
+		)
 {
 	struct drm_i915_gem_object *obj;
 	int ret;
@@ -410,6 +412,9 @@ i915_gem_create(struct drm_file *file,
 	if (obj == NULL)
 		return -ENOMEM;
 
+	if (flags & I915_CREATE_FLAG_HI_MEM)
+		obj->hi_mem = 1;
+
 	ret = drm_gem_handle_create(file, &obj->base, &handle);
 	/* drop reference from allocate - handle holds it now */
 	drm_gem_object_unreference_unlocked(&obj->base);
@@ -429,7 +434,8 @@ i915_gem_dumb_create(struct drm_file *file,
 	args->pitch = ALIGN(args->width * DIV_ROUND_UP(args->bpp, 8), 64);
 	args->size = args->pitch * args->height;
 	return i915_gem_create(file, dev,
-			       args->size, &args->handle);
+			       args->size, &args->handle,
+			       I915_CREATE_FLAG_HI_MEM);
 }
 
 /**
@@ -440,9 +446,10 @@ i915_gem_create_ioctl(struct drm_device *dev, void *data,
 		      struct drm_file *file)
 {
 	struct drm_i915_gem_create *args = data;
 
 	return i915_gem_create(file, dev,
-			       args->size, &args->handle);
+			       args->size, &args->handle,
+			       args->flags);
 }
 
 static inline int
diff --git a/include/uapi/drm/i915_drm.h b/include/uapi/drm/i915_drm.h
index 6eed16b..eb2e7d9 100644
--- a/include/uapi/drm/i915_drm.h
+++ b/include/uapi/drm/i915_drm.h
@@ -428,6 +428,8 @@ struct drm_i915_gem_init {
 	__u64 gtt_end;
 };
 
+#define I915_CREATE_FLAG_HI_MEM	0x00000001
+
 struct drm_i915_gem_create {
 	/**
 	 * Requested size for the object.
@@ -441,7 +443,10 @@ struct drm_i915_gem_create {
 	 * Object handles are nonzero.
 	 */
 	__u32 handle;
-	__u32 pad;
+	/**
+	 * Object creation flags
+	 */
+	__u32 flags;
 };
 
 struct drm_i915_gem_pread {
-- 
2.1.1



More information about the Intel-gfx mailing list