aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorBen Widawsky <ben@bwidawsk.net>2013-01-17 15:45:17 -0500
committerDaniel Vetter <daniel.vetter@ffwll.ch>2013-01-20 07:09:20 -0500
commit93d187993b783c68383a884091a600d9ad499ea6 (patch)
treec3677acfc75ea5b39ce337257ad600979d5b1b29
parentdabb7a91ae6442d642a52e0de22d781a8ad2af12 (diff)
drm/i915: Remove use of gtt_mappable_entries
Mappable_end, ie. size is almost always what you want as opposed to the number of entries. Since we already have that information, we can scrap the number of entries and only calculate it when needed. If gtt_start is !0, this will have slightly different behavior. This difference can only occur in DRI1, and exists when we try to kick out the firmware fb. The new code seems like a bugfix to me. The other case where we've changed the behavior is during init we check the mappable region against our current known upper and lower limits (64MB, and 512MB). This now matches the comment, and makes things more convenient after removing gtt_mappable_entries. Also worth noting is the setting of mappable_end is taken out of setup because we do it earlier now in the DRI2 case and therefore need to add that tiny hunk to support the DRI1 IOCTL. v2: Move up mappable end to before legacy AGP init v3: Add the dev_priv inclusion here from previous rebase error in patch 5 Reviewed-by: Rodrigo Vivi <rodrigo.vivi@gmail.com> (v2) Signed-off-by: Ben Widawsky <ben@bwidawsk.net> [danvet: squash in fix for a printk format flag mismatch warning.] Signed-off-by: Daniel Vetter <daniel.vetter@ffwll.ch>
-rw-r--r--drivers/gpu/drm/i915/i915_debugfs.c2
-rw-r--r--drivers/gpu/drm/i915/i915_dma.c8
-rw-r--r--drivers/gpu/drm/i915/i915_gem.c2
-rw-r--r--drivers/gpu/drm/i915/i915_gem_gtt.c15
-rw-r--r--drivers/gpu/drm/i915/intel_fb.c3
5 files changed, 15 insertions, 15 deletions
diff --git a/drivers/gpu/drm/i915/i915_debugfs.c b/drivers/gpu/drm/i915/i915_debugfs.c
index 773b23ecc83b..90a6fc506dd5 100644
--- a/drivers/gpu/drm/i915/i915_debugfs.c
+++ b/drivers/gpu/drm/i915/i915_debugfs.c
@@ -258,7 +258,7 @@ static int i915_gem_object_info(struct seq_file *m, void* data)
258 seq_printf(m, "%u fault mappable objects, %zu bytes\n", 258 seq_printf(m, "%u fault mappable objects, %zu bytes\n",
259 count, size); 259 count, size);
260 260
261 seq_printf(m, "%zu [%zu] gtt total\n", 261 seq_printf(m, "%zu [%lu] gtt total\n",
262 dev_priv->gtt.total, 262 dev_priv->gtt.total,
263 dev_priv->gtt.mappable_end - dev_priv->gtt.start); 263 dev_priv->gtt.mappable_end - dev_priv->gtt.start);
264 264
diff --git a/drivers/gpu/drm/i915/i915_dma.c b/drivers/gpu/drm/i915/i915_dma.c
index 468d2a0fc378..3f70178c63ca 100644
--- a/drivers/gpu/drm/i915/i915_dma.c
+++ b/drivers/gpu/drm/i915/i915_dma.c
@@ -1427,8 +1427,8 @@ static void i915_kick_out_firmware_fb(struct drm_i915_private *dev_priv)
1427 return; 1427 return;
1428 1428
1429 ap->ranges[0].base = dev_priv->gtt.mappable_base; 1429 ap->ranges[0].base = dev_priv->gtt.mappable_base;
1430 ap->ranges[0].size = 1430 ap->ranges[0].size = dev_priv->gtt.mappable_end - dev_priv->gtt.start;
1431 dev_priv->mm.gtt->gtt_mappable_entries << PAGE_SHIFT; 1431
1432 primary = 1432 primary =
1433 pdev->resource[PCI_ROM_RESOURCE].flags & IORESOURCE_ROM_SHADOW; 1433 pdev->resource[PCI_ROM_RESOURCE].flags & IORESOURCE_ROM_SHADOW;
1434 1434
@@ -1542,7 +1542,7 @@ int i915_driver_load(struct drm_device *dev, unsigned long flags)
1542 goto put_gmch; 1542 goto put_gmch;
1543 } 1543 }
1544 1544
1545 aperture_size = dev_priv->mm.gtt->gtt_mappable_entries << PAGE_SHIFT; 1545 aperture_size = dev_priv->gtt.mappable_end;
1546 1546
1547 dev_priv->gtt.mappable = 1547 dev_priv->gtt.mappable =
1548 io_mapping_create_wc(dev_priv->gtt.mappable_base, 1548 io_mapping_create_wc(dev_priv->gtt.mappable_base,
@@ -1699,7 +1699,7 @@ int i915_driver_unload(struct drm_device *dev)
1699 if (dev_priv->mm.gtt_mtrr >= 0) { 1699 if (dev_priv->mm.gtt_mtrr >= 0) {
1700 mtrr_del(dev_priv->mm.gtt_mtrr, 1700 mtrr_del(dev_priv->mm.gtt_mtrr,
1701 dev_priv->gtt.mappable_base, 1701 dev_priv->gtt.mappable_base,
1702 dev_priv->mm.gtt->gtt_mappable_entries * PAGE_SIZE); 1702 dev_priv->gtt.mappable_end);
1703 dev_priv->mm.gtt_mtrr = -1; 1703 dev_priv->mm.gtt_mtrr = -1;
1704 } 1704 }
1705 1705
diff --git a/drivers/gpu/drm/i915/i915_gem.c b/drivers/gpu/drm/i915/i915_gem.c
index 51fdf16181a7..e4132ffb7609 100644
--- a/drivers/gpu/drm/i915/i915_gem.c
+++ b/drivers/gpu/drm/i915/i915_gem.c
@@ -149,6 +149,7 @@ int
149i915_gem_init_ioctl(struct drm_device *dev, void *data, 149i915_gem_init_ioctl(struct drm_device *dev, void *data,
150 struct drm_file *file) 150 struct drm_file *file)
151{ 151{
152 struct drm_i915_private *dev_priv = dev->dev_private;
152 struct drm_i915_gem_init *args = data; 153 struct drm_i915_gem_init *args = data;
153 154
154 if (drm_core_check_feature(dev, DRIVER_MODESET)) 155 if (drm_core_check_feature(dev, DRIVER_MODESET))
@@ -165,6 +166,7 @@ i915_gem_init_ioctl(struct drm_device *dev, void *data,
165 mutex_lock(&dev->struct_mutex); 166 mutex_lock(&dev->struct_mutex);
166 i915_gem_setup_global_gtt(dev, args->gtt_start, args->gtt_end, 167 i915_gem_setup_global_gtt(dev, args->gtt_start, args->gtt_end,
167 args->gtt_end); 168 args->gtt_end);
169 dev_priv->gtt.mappable_end = args->gtt_end;
168 mutex_unlock(&dev->struct_mutex); 170 mutex_unlock(&dev->struct_mutex);
169 171
170 return 0; 172 return 0;
diff --git a/drivers/gpu/drm/i915/i915_gem_gtt.c b/drivers/gpu/drm/i915/i915_gem_gtt.c
index 0b8930577953..0f0db02c1e56 100644
--- a/drivers/gpu/drm/i915/i915_gem_gtt.c
+++ b/drivers/gpu/drm/i915/i915_gem_gtt.c
@@ -557,7 +557,6 @@ void i915_gem_setup_global_gtt(struct drm_device *dev,
557 } 557 }
558 558
559 dev_priv->gtt.start = start; 559 dev_priv->gtt.start = start;
560 dev_priv->gtt.mappable_end = mappable_end;
561 dev_priv->gtt.total = end - start; 560 dev_priv->gtt.total = end - start;
562 561
563 /* Clear any non-preallocated blocks */ 562 /* Clear any non-preallocated blocks */
@@ -596,7 +595,7 @@ void i915_gem_init_global_gtt(struct drm_device *dev)
596 int ret; 595 int ret;
597 596
598 gtt_size = dev_priv->mm.gtt->gtt_total_entries << PAGE_SHIFT; 597 gtt_size = dev_priv->mm.gtt->gtt_total_entries << PAGE_SHIFT;
599 mappable_size = dev_priv->mm.gtt->gtt_mappable_entries << PAGE_SHIFT; 598 mappable_size = dev_priv->gtt.mappable_end;
600 599
601 if (intel_enable_ppgtt(dev) && HAS_ALIASING_PPGTT(dev)) { 600 if (intel_enable_ppgtt(dev) && HAS_ALIASING_PPGTT(dev)) {
602 /* PPGTT pdes are stolen from global gtt ptes, so shrink the 601 /* PPGTT pdes are stolen from global gtt ptes, so shrink the
@@ -692,6 +691,7 @@ int i915_gem_gtt_init(struct drm_device *dev)
692 int ret; 691 int ret;
693 692
694 dev_priv->gtt.mappable_base = pci_resource_start(dev->pdev, 2); 693 dev_priv->gtt.mappable_base = pci_resource_start(dev->pdev, 2);
694 dev_priv->gtt.mappable_end = pci_resource_len(dev->pdev, 2);
695 695
696 /* On modern platforms we need not worry ourself with the legacy 696 /* On modern platforms we need not worry ourself with the legacy
697 * hostbridge query stuff. Skip it entirely 697 * hostbridge query stuff. Skip it entirely
@@ -735,14 +735,13 @@ int i915_gem_gtt_init(struct drm_device *dev)
735 else 735 else
736 dev_priv->mm.gtt->stolen_size = gen7_get_stolen_size(snb_gmch_ctl); 736 dev_priv->mm.gtt->stolen_size = gen7_get_stolen_size(snb_gmch_ctl);
737 737
738 dev_priv->mm.gtt->gtt_mappable_entries = pci_resource_len(dev->pdev, 2) >> PAGE_SHIFT;
739 /* 64/512MB is the current min/max we actually know of, but this is just a 738 /* 64/512MB is the current min/max we actually know of, but this is just a
740 * coarse sanity check. 739 * coarse sanity check.
741 */ 740 */
742 if ((dev_priv->mm.gtt->gtt_mappable_entries >> 8) < 64 || 741 if ((dev_priv->gtt.mappable_end < (64<<20) ||
743 dev_priv->mm.gtt->gtt_mappable_entries > dev_priv->mm.gtt->gtt_total_entries) { 742 (dev_priv->gtt.mappable_end > (512<<20)))) {
744 DRM_ERROR("Unknown GMADR entries (%d)\n", 743 DRM_ERROR("Unknown GMADR size (%lx)\n",
745 dev_priv->mm.gtt->gtt_mappable_entries); 744 dev_priv->gtt.mappable_end);
746 ret = -ENXIO; 745 ret = -ENXIO;
747 goto err_out; 746 goto err_out;
748 } 747 }
@@ -764,7 +763,7 @@ int i915_gem_gtt_init(struct drm_device *dev)
764 763
765 /* GMADR is the PCI aperture used by SW to access tiled GFX surfaces in a linear fashion. */ 764 /* GMADR is the PCI aperture used by SW to access tiled GFX surfaces in a linear fashion. */
766 DRM_INFO("Memory usable by graphics device = %dM\n", dev_priv->mm.gtt->gtt_total_entries >> 8); 765 DRM_INFO("Memory usable by graphics device = %dM\n", dev_priv->mm.gtt->gtt_total_entries >> 8);
767 DRM_DEBUG_DRIVER("GMADR size = %dM\n", dev_priv->mm.gtt->gtt_mappable_entries >> 8); 766 DRM_DEBUG_DRIVER("GMADR size = %ldM\n", dev_priv->gtt.mappable_end >> 20);
768 DRM_DEBUG_DRIVER("GTT stolen size = %dM\n", dev_priv->mm.gtt->stolen_size >> 20); 767 DRM_DEBUG_DRIVER("GTT stolen size = %dM\n", dev_priv->mm.gtt->stolen_size >> 20);
769 768
770 return 0; 769 return 0;
diff --git a/drivers/gpu/drm/i915/intel_fb.c b/drivers/gpu/drm/i915/intel_fb.c
index ce02af8ca96e..ce5f54498426 100644
--- a/drivers/gpu/drm/i915/intel_fb.c
+++ b/drivers/gpu/drm/i915/intel_fb.c
@@ -135,8 +135,7 @@ static int intelfb_create(struct intel_fbdev *ifbdev,
135 goto out_unpin; 135 goto out_unpin;
136 } 136 }
137 info->apertures->ranges[0].base = dev->mode_config.fb_base; 137 info->apertures->ranges[0].base = dev->mode_config.fb_base;
138 info->apertures->ranges[0].size = 138 info->apertures->ranges[0].size = dev_priv->gtt.mappable_end;
139 dev_priv->mm.gtt->gtt_mappable_entries << PAGE_SHIFT;
140 139
141 info->fix.smem_start = dev->mode_config.fb_base + obj->gtt_offset; 140 info->fix.smem_start = dev->mode_config.fb_base + obj->gtt_offset;
142 info->fix.smem_len = size; 141 info->fix.smem_len = size;