Skip to contentSkip to conversation

drm/i915: allow stolen, pre-allocated objects to avoid GTT allocation

PATCH In review Jesse Barnes 3 participants 3 messages May 8, 2013

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

PATCH 1/1 drm/i915: allow stolen, pre-allocated objects to avoid GTT allocation

In some cases, we may not need GTT address space allocated to a stolen object, so allow passing -1 to the preallocated function to indicate as much.

---
 drivers/gpu/drm/i915/i915_gem_stolen.c |    4 ++++
 drivers/gpu/drm/i915/intel_pm.c        |    2 +-
 2 files changed, 5 insertions(+), 1 deletion(-)
drivers/gpu/drm/i915/i915_gem_stolen.c +4 -0
index 9137fa4c..2e92861 100644
@@ -360,6 +360,10 @@ i915_gem_object_create_stolen_for_preallocated(struct drm_device *dev,
 		return NULL;
 	}
 
+	/* Some objects just need physical mem from stolen space */
+	if (gtt_offset == -1)
+		return obj;
+
 	/* To simplify the initialisation sequence between KMS and GTT,
 	 * we allow construction of the stolen object prior to
 	 * setting up the GTT space. The actual reservation will occur
drivers/gpu/drm/i915/intel_pm.c +1 -1
index e60cd3e..081194d 100644
@@ -2877,7 +2877,7 @@ static void valleyview_setup_pctx(struct drm_device *dev)
 		pcbr_offset = (pcbr & (~4095)) - dev_priv->mm.stolen_base;
 		pctx = i915_gem_object_create_stolen_for_preallocated(dev_priv->dev,
 								      pcbr_offset,
-								      pcbr_offset,
+								      -1,
 								      pctx_size);
 		goto out;
 	}
Signature · 1 line
1.7.10.4
Reviewed-by on v1 1/1
#1 lore raw
Quoted 15 lines · Jesse Barnes

In some cases, we may not need GTT address space allocated to a stolen object, so allow passing -1 to the preallocated function to indicate as much.

---
 drivers/gpu/drm/i915/i915_gem_stolen.c |    4 ++++
 drivers/gpu/drm/i915/intel_pm.c        |    2 +-
 2 files changed, 5 insertions(+), 1 deletion(-)
drivers/gpu/drm/i915/i915_gem_stolen.c +0 -0
index 9137fa4c..2e92861 100644

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

Quoted 5 lines
drivers/gpu/drm/i915/i915_gem_stolen.c +2 -0
@@ -360,6 +360,10 @@ i915_gem_object_create_stolen_for_preallocated(struct drm_device *dev,
 		return NULL;
 	}
 
+	/* Some objects just need physical mem from stolen space */
+	if (gtt_offset == -1)

For complete symmetry, we should do a
list_add(&obj->gtt_list, &dev_priv->mm.unbound_list);
but as these bo are irrelevant for the shrinker there are no immediate consequences. If we wanted to further complicate the code, we could exclude stolen objects from unbound tracking entirely. Not worth it.

So as it stands, for completeness we should do the list_add here. Hmm, actually, _i915_gem_object_create_stolen() should do the list_add(unbound) and we should later do the list_move(bound) after reserving the GTT space. Ok, ignore all of this and

(replacing -1 with a fancy name if some one else bikesheds :) -Chris

Signature · 1 line
Chris Wilson, Intel Open Source Technology Centre
#2 lore raw
In reply to Jesse Barnes
Quoted 15 lines · Jesse Barnes

In some cases, we may not need GTT address space allocated to a stolen object, so allow passing -1 to the preallocated function to indicate as much.

---
 drivers/gpu/drm/i915/i915_gem_stolen.c |    4 ++++
 drivers/gpu/drm/i915/intel_pm.c        |    2 +-
 2 files changed, 5 insertions(+), 1 deletion(-)
drivers/gpu/drm/i915/i915_gem_stolen.c +0 -0
index 9137fa4c..2e92861 100644

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

Quoted 6 lines
drivers/gpu/drm/i915/i915_gem_stolen.c +3 -0
@@ -360,6 +360,10 @@ i915_gem_object_create_stolen_for_preallocated(struct drm_device *dev,
 		return NULL;
 	}
 
+	/* Some objects just need physical mem from stolen space */
+	if (gtt_offset == -1)
+		return obj;

Surely that will explode in the BUG_ON(gtt_offset & 4095), or did that get removed?

Quoted 24 lines
drivers/gpu/drm/i915/i915_gem_stolen.c +1 -0
+
 	/* To simplify the initialisation sequence between KMS and GTT,
 	 * we allow construction of the stolen object prior to
 	 * setting up the GTT space. The actual reservation will occur
drivers/gpu/drm/i915/intel_pm.c +1 -1
index e60cd3e..081194d 100644
@@ -2877,7 +2877,7 @@ static void valleyview_setup_pctx(struct drm_device *dev)
 		pcbr_offset = (pcbr & (~4095)) - dev_priv->mm.stolen_base;
 		pctx = i915_gem_object_create_stolen_for_preallocated(dev_priv->dev,
 								      pcbr_offset,
-								      pcbr_offset,
+								      -1,
 								      pctx_size);
 		goto out;
 	}
Signature · 6 lines
1.7.10.4

_______________________________________________
Intel-gfx mailing list
[email protected]
http://lists.freedesktop.org/mailman/listinfo/intel-gfx
Signature · 2 lines
Ville Syrjälä
Intel OTC