[Intel-gfx] [PATCH 12/17] drm/i915: Always use the scatterlists if available for GTT insertion

Chris Wilson chris at chris-wilson.co.uk
Sat Apr 21 18:35:56 CEST 2012


If we have created a scatterlist for the physical mapping of the object,
simply use it. This facilitates the later insertion of stolen objects
into the GATT which are not backed by struct page.

Signed-off-by: Chris Wilson <chris at chris-wilson.co.uk>
---
 drivers/gpu/drm/i915/i915_gem_gtt.c |   19 ++++++++-----------
 1 file changed, 8 insertions(+), 11 deletions(-)

diff --git a/drivers/gpu/drm/i915/i915_gem_gtt.c b/drivers/gpu/drm/i915/i915_gem_gtt.c
index b0c20a5..7afd631 100644
--- a/drivers/gpu/drm/i915/i915_gem_gtt.c
+++ b/drivers/gpu/drm/i915/i915_gem_gtt.c
@@ -249,8 +249,6 @@ void i915_ppgtt_bind_object(struct i915_hw_ppgtt *ppgtt,
 			    struct drm_i915_gem_object *obj,
 			    enum i915_cache_level cache_level)
 {
-	struct drm_device *dev = obj->base.dev;
-	struct drm_i915_private *dev_priv = dev->dev_private;
 	uint32_t pte_flags = GEN6_PTE_VALID;
 
 	switch (cache_level) {
@@ -267,20 +265,20 @@ void i915_ppgtt_bind_object(struct i915_hw_ppgtt *ppgtt,
 		BUG();
 	}
 
-	if (dev_priv->mm.gtt->needs_dmar) {
-		BUG_ON(!obj->sg_list);
-
+	if (obj->sg_list) {
 		i915_ppgtt_insert_sg_entries(ppgtt,
 					     obj->sg_list,
 					     obj->num_sg,
 					     obj->gtt_space->start >> PAGE_SHIFT,
 					     pte_flags);
-	} else
+	} else {
+		BUG_ON(!obj->pages);
 		i915_ppgtt_insert_pages(ppgtt,
 					obj->gtt_space->start >> PAGE_SHIFT,
 					obj->base.size >> PAGE_SHIFT,
 					obj->pages,
 					pte_flags);
+	}
 }
 
 void i915_ppgtt_unbind_object(struct i915_hw_ppgtt *ppgtt,
@@ -368,21 +366,20 @@ void i915_gem_gtt_bind_object(struct drm_i915_gem_object *obj,
 			      enum i915_cache_level cache_level)
 {
 	struct drm_device *dev = obj->base.dev;
-	struct drm_i915_private *dev_priv = dev->dev_private;
 	unsigned int agp_type = cache_level_to_agp_type(dev, cache_level);
 
-	if (dev_priv->mm.gtt->needs_dmar) {
-		BUG_ON(!obj->sg_list);
-
+	if (obj->sg_list) {
 		intel_gtt_insert_sg_entries(obj->sg_list,
 					    obj->num_sg,
 					    obj->gtt_space->start >> PAGE_SHIFT,
 					    agp_type);
-	} else
+	} else {
+		BUG_ON(!obj->pages);
 		intel_gtt_insert_pages(obj->gtt_space->start >> PAGE_SHIFT,
 				       obj->base.size >> PAGE_SHIFT,
 				       obj->pages,
 				       agp_type);
+	}
 
 	obj->has_global_gtt_mapping = 1;
 }
-- 
1.7.10




More information about the Intel-gfx mailing list