Skip to contentSkip to conversation

drm/i915: Don't use a special stolen reserve offset

PATCH In review Ben Widawsky 2 participants 5 messages Jul 4, 2013 – Jul 5, 2013

Subsystems (2)
lore
Share & tools
lore
#0 lore raw

PATCH 1/1 drm/i915: Don't use a special stolen reserve offset

Setting the node directly is good enough. We don't need a special value to store the gtt_offset, and we no longer have the pointer to tuck things away neatly.

This is temporarily broken since:
commit 7dedae28b41000539b6c18bcf72107c97e4937e4

Author: Ben Widawsky <[email protected]>
Date:   Wed Jul 3 14:45:24 2013 -0700
    drm/i915: Use gtt_space->start for stolen reservation

However with no userspace currently, the bisection problem shouldn't be a concern.

---
 drivers/gpu/drm/i915/i915_drv.h        | 1 -
 drivers/gpu/drm/i915/i915_gem_gtt.c    | 1 -
 drivers/gpu/drm/i915/i915_gem_stolen.c | 8 ++++++--
 3 files changed, 6 insertions(+), 4 deletions(-)
drivers/gpu/drm/i915/i915_drv.h +0 -1
index ea86ad6..b9e8ba1 100644
@@ -1201,7 +1201,6 @@ enum hdmi_force_audio {
 	HDMI_AUDIO_ON,			/* force turn on HDMI audio */
 };
 
-#define I915_GTT_RESERVED (ULONG_MAX)
 #define I915_GTT_OFFSET_NONE ((u32)-1)
 
 struct drm_i915_gem_object_ops {
drivers/gpu/drm/i915/i915_gem_gtt.c +0 -1
index f075831..c0ca103 100644
@@ -632,7 +632,6 @@ void i915_gem_setup_global_gtt(struct drm_device *dev,
 		DRM_DEBUG_KMS("reserving preallocated space: %lx + %zx\n",
 			      i915_gem_obj_ggtt_offset(obj), obj->base.size);
 
-		BUG_ON(obj->gtt_space->start != I915_GTT_RESERVED);
 		obj->gtt_space = drm_mm_create_block(&dev_priv->mm.gtt_space,
 						     i915_gem_obj_ggtt_offset(obj),
 						     obj->base.size,
drivers/gpu/drm/i915/i915_gem_stolen.c +6 -2
index c6b70312..289d511d 100644
@@ -397,8 +397,12 @@ i915_gem_object_create_stolen_for_preallocated(struct drm_device *dev,
 			drm_gem_object_unreference(&obj->base);
 			return NULL;
 		}
-	} else
-		obj->gtt_space->start = I915_GTT_RESERVED;
+	} else {
+		/* Generally it isn't safe to directly set attributes of the
+		 * drm_mm_node, however this is a special case where we'll
+		 * promise to handle everything properly later. */
+		obj->gtt_space->start = gtt_offset;
+	}
 
 	obj->has_global_gtt_mapping = 1;
 
Signature · 1 line
1.8.3.2
#1 lore raw
Quoted 40 lines · Ben Widawsky

Setting the node directly is good enough. We don't need a special value to store the gtt_offset, and we no longer have the pointer to tuck things away neatly.

This is temporarily broken since:
commit 7dedae28b41000539b6c18bcf72107c97e4937e4

Author: Ben Widawsky <[email protected]>
Date:   Wed Jul 3 14:45:24 2013 -0700
    drm/i915: Use gtt_space->start for stolen reservation

However with no userspace currently, the bisection problem shouldn't be a concern.

---
 drivers/gpu/drm/i915/i915_drv.h        | 1 -
 drivers/gpu/drm/i915/i915_gem_gtt.c    | 1 -
 drivers/gpu/drm/i915/i915_gem_stolen.c | 8 ++++++--
 3 files changed, 6 insertions(+), 4 deletions(-)
drivers/gpu/drm/i915/i915_drv.h +0 -1
index ea86ad6..b9e8ba1 100644
@@ -1201,7 +1201,6 @@ enum hdmi_force_audio {
 	HDMI_AUDIO_ON,			/* force turn on HDMI audio */
 };
 
-#define I915_GTT_RESERVED (ULONG_MAX)
 #define I915_GTT_OFFSET_NONE ((u32)-1)
 
 struct drm_i915_gem_object_ops {
drivers/gpu/drm/i915/i915_gem_gtt.c +0 -0
index f075831..c0ca103 100644

drivers/gpu/drm/i915/i915_gem_gtt.c void i915_gem_setup_global_gtt(struct drm_device *dev, · line 635

Quoted 4 lines
drivers/gpu/drm/i915/i915_gem_gtt.c +0 -1
@@ -632,7 +632,6 @@ void i915_gem_setup_global_gtt(struct drm_device *dev,
 		DRM_DEBUG_KMS("reserving preallocated space: %lx + %zx\n",
 			      i915_gem_obj_ggtt_offset(obj), obj->base.size);
 
-		BUG_ON(obj->gtt_space->start != I915_GTT_RESERVED);

I've thought we've agreed on a WARN_ON(!drm_mm_node_allocated); here? -Daniel

Quoted 29 lines
drivers/gpu/drm/i915/i915_gem_gtt.c +0 -0
 		obj->gtt_space = drm_mm_create_block(&dev_priv->mm.gtt_space,
 						     i915_gem_obj_ggtt_offset(obj),
 						     obj->base.size,
drivers/gpu/drm/i915/i915_gem_stolen.c +6 -2
index c6b70312..289d511d 100644
@@ -397,8 +397,12 @@ i915_gem_object_create_stolen_for_preallocated(struct drm_device *dev,
 			drm_gem_object_unreference(&obj->base);
 			return NULL;
 		}
-	} else
-		obj->gtt_space->start = I915_GTT_RESERVED;
+	} else {
+		/* Generally it isn't safe to directly set attributes of the
+		 * drm_mm_node, however this is a special case where we'll
+		 * promise to handle everything properly later. */
+		obj->gtt_space->start = gtt_offset;
+	}
 
 	obj->has_global_gtt_mapping = 1;
 
Signature · 6 lines
1.8.3.2

_______________________________________________
Intel-gfx mailing list
[email protected]
http://lists.freedesktop.org/mailman/listinfo/intel-gfx
Signature · 3 lines
Daniel Vetter
Software Engineer, Intel Corporation
+41 (0) 79 365 57 48 - http://blog.ffwll.ch
#2 lore raw
Quoted 44 lines · Daniel Vetter
Quoted 43 lines · Ben Widawsky

Setting the node directly is good enough. We don't need a special value to store the gtt_offset, and we no longer have the pointer to tuck things away neatly.

This is temporarily broken since:
commit 7dedae28b41000539b6c18bcf72107c97e4937e4

Author: Ben Widawsky <[email protected]>
Date:   Wed Jul 3 14:45:24 2013 -0700
    drm/i915: Use gtt_space->start for stolen reservation

However with no userspace currently, the bisection problem shouldn't be a concern.

---
 drivers/gpu/drm/i915/i915_drv.h        | 1 -
 drivers/gpu/drm/i915/i915_gem_gtt.c    | 1 -
 drivers/gpu/drm/i915/i915_gem_stolen.c | 8 ++++++--
 3 files changed, 6 insertions(+), 4 deletions(-)
drivers/gpu/drm/i915/i915_drv.h +0 -1
index ea86ad6..b9e8ba1 100644
@@ -1201,7 +1201,6 @@ enum hdmi_force_audio {
 	HDMI_AUDIO_ON,			/* force turn on HDMI audio */
 };
 
-#define I915_GTT_RESERVED (ULONG_MAX)
 #define I915_GTT_OFFSET_NONE ((u32)-1)
 
 struct drm_i915_gem_object_ops {
drivers/gpu/drm/i915/i915_gem_gtt.c +0 -0
index f075831..c0ca103 100644
@@ -632,7 +632,6 @@ void i915_gem_setup_global_gtt(struct drm_device *dev,
 		DRM_DEBUG_KMS("reserving preallocated space: %lx + %zx\n",
 			      i915_gem_obj_ggtt_offset(obj), obj->base.size);
 
Quoted 3 lines

drivers/gpu/drm/i915/i915_gem_gtt.c void i915_gem_setup_global_gtt(struct drm_device *dev, · line 635

Quoted 1 line
drivers/gpu/drm/i915/i915_gem_gtt.c +0 -1
-		BUG_ON(obj->gtt_space->start != I915_GTT_RESERVED);

I've thought we've agreed on a WARN_ON(!drm_mm_node_allocated); here?

WARN_ON(drm_mm_node_allocated); to be precise ;-)
-Daniel

Signature · 3 lines
Daniel Vetter
Software Engineer, Intel Corporation
+41 (0) 79 365 57 48 - http://blog.ffwll.ch
#3 lore raw
Quoted 45 lines · Daniel Vetter
Quoted 44 lines · Daniel Vetter
Quoted 43 lines · Ben Widawsky

Setting the node directly is good enough. We don't need a special value to store the gtt_offset, and we no longer have the pointer to tuck things away neatly.

This is temporarily broken since:
commit 7dedae28b41000539b6c18bcf72107c97e4937e4

Author: Ben Widawsky <[email protected]>
Date:   Wed Jul 3 14:45:24 2013 -0700
    drm/i915: Use gtt_space->start for stolen reservation

However with no userspace currently, the bisection problem shouldn't be a concern.

---
 drivers/gpu/drm/i915/i915_drv.h        | 1 -
 drivers/gpu/drm/i915/i915_gem_gtt.c    | 1 -
 drivers/gpu/drm/i915/i915_gem_stolen.c | 8 ++++++--
 3 files changed, 6 insertions(+), 4 deletions(-)
drivers/gpu/drm/i915/i915_drv.h +0 -1
index ea86ad6..b9e8ba1 100644
@@ -1201,7 +1201,6 @@ enum hdmi_force_audio {
 	HDMI_AUDIO_ON,			/* force turn on HDMI audio */
 };
 
-#define I915_GTT_RESERVED (ULONG_MAX)
 #define I915_GTT_OFFSET_NONE ((u32)-1)
 
 struct drm_i915_gem_object_ops {
drivers/gpu/drm/i915/i915_gem_gtt.c +0 -0
index f075831..c0ca103 100644
@@ -632,7 +632,6 @@ void i915_gem_setup_global_gtt(struct drm_device *dev,
 		DRM_DEBUG_KMS("reserving preallocated space: %lx + %zx\n",
 			      i915_gem_obj_ggtt_offset(obj), obj->base.size);
 
Quoted 6 lines
Quoted 3 lines

drivers/gpu/drm/i915/i915_gem_gtt.c void i915_gem_setup_global_gtt(struct drm_device *dev, · line 635

Quoted 1 line
drivers/gpu/drm/i915/i915_gem_gtt.c +0 -1
-		BUG_ON(obj->gtt_space->start != I915_GTT_RESERVED);

I've thought we've agreed on a WARN_ON(!drm_mm_node_allocated); here?

WARN_ON(drm_mm_node_allocated); to be precise ;-)
-Daniel

To be honest, I forgot - but the original plan was to do it after the node embedding. I think for the same paranoia, we also want to check that obj->gtt_space != NULL.

Would you mind adding it on merge?

Signature · 1 line
Ben Widawsky, Intel Open Source Technology Center
#4 lore raw
In reply to Ben Widawsky
Quoted 52 lines · Ben Widawsky

Setting the node directly is good enough. We don't need a special value to store the gtt_offset, and we no longer have the pointer to tuck things away neatly.

This is temporarily broken since:
commit 7dedae28b41000539b6c18bcf72107c97e4937e4

Author: Ben Widawsky <[email protected]>
Date:   Wed Jul 3 14:45:24 2013 -0700
    drm/i915: Use gtt_space->start for stolen reservation

However with no userspace currently, the bisection problem shouldn't be a concern.

---
 drivers/gpu/drm/i915/i915_drv.h        | 1 -
 drivers/gpu/drm/i915/i915_gem_gtt.c    | 1 -
 drivers/gpu/drm/i915/i915_gem_stolen.c | 8 ++++++--
 3 files changed, 6 insertions(+), 4 deletions(-)
drivers/gpu/drm/i915/i915_drv.h +0 -1
index ea86ad6..b9e8ba1 100644
@@ -1201,7 +1201,6 @@ enum hdmi_force_audio {
 	HDMI_AUDIO_ON,			/* force turn on HDMI audio */
 };
 
-#define I915_GTT_RESERVED (ULONG_MAX)
 #define I915_GTT_OFFSET_NONE ((u32)-1)
 
 struct drm_i915_gem_object_ops {
drivers/gpu/drm/i915/i915_gem_gtt.c +0 -1
index f075831..c0ca103 100644
@@ -632,7 +632,6 @@ void i915_gem_setup_global_gtt(struct drm_device *dev,
 		DRM_DEBUG_KMS("reserving preallocated space: %lx + %zx\n",
 			      i915_gem_obj_ggtt_offset(obj), obj->base.size);
 
-		BUG_ON(obj->gtt_space->start != I915_GTT_RESERVED);
 		obj->gtt_space = drm_mm_create_block(&dev_priv->mm.gtt_space,
 						     i915_gem_obj_ggtt_offset(obj),
 						     obj->base.size,
drivers/gpu/drm/i915/i915_gem_stolen.c +0 -0
index c6b70312..289d511d 100644

drivers/gpu/drm/i915/i915_gem_stolen.c i915_gem_object_create_stolen_for_preallocated(struct drm_device *dev, · line 404

Quoted 10 lines
drivers/gpu/drm/i915/i915_gem_stolen.c +5 -2
@@ -397,8 +397,12 @@ i915_gem_object_create_stolen_for_preallocated(struct drm_device *dev,
 			drm_gem_object_unreference(&obj->base);
 			return NULL;
 		}
-	} else
-		obj->gtt_space->start = I915_GTT_RESERVED;
+	} else {
+		/* Generally it isn't safe to directly set attributes of the
+		 * drm_mm_node, however this is a special case where we'll
+		 * promise to handle everything properly later. */
+		obj->gtt_space->start = gtt_offset;

Since obj->gtt_space isn't embedded yet this will blow up. I think we need to do the embedding first, then fix this up.
-Daniel

Quoted 11 lines
drivers/gpu/drm/i915/i915_gem_stolen.c +1 -0
+	}
 
 	obj->has_global_gtt_mapping = 1;
 
Signature · 6 lines
1.8.3.2

_______________________________________________
Intel-gfx mailing list
[email protected]
http://lists.freedesktop.org/mailman/listinfo/intel-gfx
Signature · 3 lines
Daniel Vetter
Software Engineer, Intel Corporation
+41 (0) 79 365 57 48 - http://blog.ffwll.ch