[Intel-gfx] [PATCH 7/8] drm/i915: Keep track if we have local memory

ville.syrjala at linux.intel.com ville.syrjala at linux.intel.com
Thu Nov 28 16:15:09 CET 2013


From: Ville Syrjälä <ville.syrjala at linux.intel.com>

intel-gtt will tell us if we have local memory as opposed to stolen
memory. Make a note of that in dev_priv->gtt.has_local_memory.

Local memory starts at offset 0 from the GPU's point of view, so we
need to add a small exception to consider stolen_base==0 as valid
when local memory is present.

The other part of the story is encoding the PTEs correctly. To make
that happen set the cache_level to I915_CACHE_LOCAL for all
stolen objects when local memory is present.

Signed-off-by: Ville Syrjälä <ville.syrjala at linux.intel.com>
---
 drivers/gpu/drm/i915/i915_drv.h        |  6 ++++--
 drivers/gpu/drm/i915/i915_gem_gtt.c    | 17 +++++++++++------
 drivers/gpu/drm/i915/i915_gem_stolen.c | 15 +++++++++++----
 3 files changed, 26 insertions(+), 12 deletions(-)

diff --git a/drivers/gpu/drm/i915/i915_drv.h b/drivers/gpu/drm/i915/i915_drv.h
index 9ee725f..2d9a1b3 100644
--- a/drivers/gpu/drm/i915/i915_drv.h
+++ b/drivers/gpu/drm/i915/i915_drv.h
@@ -589,13 +589,15 @@ struct i915_gtt {
 	void __iomem *gsm;
 
 	bool do_idle_maps;
+	bool has_local_memory;
 
 	int mtrr;
 
 	/* global gtt ops */
 	int (*gtt_probe)(struct drm_device *dev, size_t *gtt_total,
-			  size_t *stolen, phys_addr_t *mappable_base,
-			  unsigned long *mappable_end);
+			 size_t *stolen, phys_addr_t *mappable_base,
+			 unsigned long *mappable_end,
+			 bool *has_local_memory);
 };
 #define gtt_total_entries(gtt) ((gtt).base.total >> PAGE_SHIFT)
 
diff --git a/drivers/gpu/drm/i915/i915_gem_gtt.c b/drivers/gpu/drm/i915/i915_gem_gtt.c
index 0eb6203..c154d80 100644
--- a/drivers/gpu/drm/i915/i915_gem_gtt.c
+++ b/drivers/gpu/drm/i915/i915_gem_gtt.c
@@ -1348,7 +1348,8 @@ static int gen8_gmch_probe(struct drm_device *dev,
 			   size_t *gtt_total,
 			   size_t *stolen,
 			   phys_addr_t *mappable_base,
-			   unsigned long *mappable_end)
+			   unsigned long *mappable_end,
+			   bool *has_local_memory)
 {
 	struct drm_i915_private *dev_priv = dev->dev_private;
 	unsigned int gtt_size;
@@ -1358,6 +1359,7 @@ static int gen8_gmch_probe(struct drm_device *dev,
 	/* TODO: We're not aware of mappable constraints on gen8 yet */
 	*mappable_base = pci_resource_start(dev->pdev, 2);
 	*mappable_end = pci_resource_len(dev->pdev, 2);
+	*has_local_memory = false;
 
 	if (!pci_set_dma_mask(dev->pdev, DMA_BIT_MASK(39)))
 		pci_set_consistent_dma_mask(dev->pdev, DMA_BIT_MASK(39));
@@ -1383,7 +1385,8 @@ static int gen6_gmch_probe(struct drm_device *dev,
 			   size_t *gtt_total,
 			   size_t *stolen,
 			   phys_addr_t *mappable_base,
-			   unsigned long *mappable_end)
+			   unsigned long *mappable_end,
+			   bool *has_local_memory)
 {
 	struct drm_i915_private *dev_priv = dev->dev_private;
 	unsigned int gtt_size;
@@ -1392,6 +1395,7 @@ static int gen6_gmch_probe(struct drm_device *dev,
 
 	*mappable_base = pci_resource_start(dev->pdev, 2);
 	*mappable_end = pci_resource_len(dev->pdev, 2);
+	*has_local_memory = false;
 
 	/* 64/512MB is the current min/max we actually know of, but this is just
 	 * a coarse sanity check.
@@ -1433,10 +1437,10 @@ static int i915_gmch_probe(struct drm_device *dev,
 			   size_t *gtt_total,
 			   size_t *stolen,
 			   phys_addr_t *mappable_base,
-			   unsigned long *mappable_end)
+			   unsigned long *mappable_end,
+			   bool *has_local_memory)
 {
 	struct drm_i915_private *dev_priv = dev->dev_private;
-	bool has_local_memory;
 	int ret;
 
 	ret = intel_gmch_probe(dev_priv->bridge_dev, dev_priv->dev->pdev, NULL);
@@ -1445,7 +1449,7 @@ static int i915_gmch_probe(struct drm_device *dev,
 		return -EIO;
 	}
 
-	intel_gtt_get(gtt_total, stolen, mappable_base, mappable_end, &has_local_memory);
+	intel_gtt_get(gtt_total, stolen, mappable_base, mappable_end, has_local_memory);
 
 	dev_priv->gtt.do_idle_maps = needs_idle_maps(dev_priv->dev);
 	dev_priv->gtt.base.clear_range = i915_ggtt_clear_range;
@@ -1487,7 +1491,8 @@ int i915_gem_gtt_init(struct drm_device *dev)
 	}
 
 	ret = gtt->gtt_probe(dev, &gtt->base.total, &gtt->stolen_size,
-			     &gtt->mappable_base, &gtt->mappable_end);
+			     &gtt->mappable_base, &gtt->mappable_end,
+			     &gtt->has_local_memory);
 	if (ret)
 		return ret;
 
diff --git a/drivers/gpu/drm/i915/i915_gem_stolen.c b/drivers/gpu/drm/i915/i915_gem_stolen.c
index d284d89..39e6404 100644
--- a/drivers/gpu/drm/i915/i915_gem_stolen.c
+++ b/drivers/gpu/drm/i915/i915_gem_stolen.c
@@ -205,11 +205,14 @@ int i915_gem_init_stolen(struct drm_device *dev)
 		return 0;
 
 	dev_priv->mm.stolen_base = i915_stolen_to_physical(dev);
-	if (dev_priv->mm.stolen_base == 0)
+	if (!dev_priv->gtt.has_local_memory &&
+	    dev_priv->mm.stolen_base == 0)
 		return 0;
 
-	DRM_DEBUG_KMS("found %zd bytes of stolen memory at %08lx\n",
-		      dev_priv->gtt.stolen_size, dev_priv->mm.stolen_base);
+	DRM_DEBUG_KMS("found %zd bytes of %s memory at %08lx\n",
+		      dev_priv->gtt.stolen_size,
+		      dev_priv->gtt.has_local_memory ? "local" : "stolen",
+		      dev_priv->mm.stolen_base);
 
 	if (IS_VALLEYVIEW(dev))
 		bios_reserved = 1024*1024; /* top 1M on VLV/BYT */
@@ -281,6 +284,7 @@ static struct drm_i915_gem_object *
 _i915_gem_object_create_stolen(struct drm_device *dev,
 			       struct drm_mm_node *stolen)
 {
+	struct drm_i915_private *dev_priv = dev->dev_private;
 	struct drm_i915_gem_object *obj;
 
 	obj = i915_gem_object_alloc(dev);
@@ -300,7 +304,10 @@ _i915_gem_object_create_stolen(struct drm_device *dev,
 	obj->stolen = stolen;
 
 	obj->base.read_domains = I915_GEM_DOMAIN_CPU | I915_GEM_DOMAIN_GTT;
-	obj->cache_level = HAS_LLC(dev) ? I915_CACHE_LLC : I915_CACHE_NONE;
+	if (dev_priv->gtt.has_local_memory)
+		obj->cache_level = I915_CACHE_LOCAL;
+	else
+		obj->cache_level = HAS_LLC(dev) ? I915_CACHE_LLC : I915_CACHE_NONE;
 
 	return obj;
 
-- 
1.8.3.2




More information about the Intel-gfx mailing list