aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--drivers/char/agp/intel-gtt.c36
-rw-r--r--drivers/gpu/drm/i915/i915_drv.h3
-rw-r--r--drivers/gpu/drm/i915/i915_gem_gtt.c30
-rw-r--r--drivers/gpu/drm/i915/i915_gem_stolen.c8
-rw-r--r--include/drm/intel-gtt.h10
5 files changed, 33 insertions, 54 deletions
diff --git a/drivers/char/agp/intel-gtt.c b/drivers/char/agp/intel-gtt.c
index ff5f3483e8ea..d8e7e6c9114e 100644
--- a/drivers/char/agp/intel-gtt.c
+++ b/drivers/char/agp/intel-gtt.c
@@ -60,7 +60,6 @@ struct intel_gtt_driver {
60}; 60};
61 61
62static struct _intel_private { 62static struct _intel_private {
63 struct intel_gtt base;
64 const struct intel_gtt_driver *driver; 63 const struct intel_gtt_driver *driver;
65 struct pci_dev *pcidev; /* device one */ 64 struct pci_dev *pcidev; /* device one */
66 struct pci_dev *bridge_dev; 65 struct pci_dev *bridge_dev;
@@ -80,6 +79,13 @@ static struct _intel_private {
80 /* Whether i915 needs to use the dmar apis or not. */ 79 /* Whether i915 needs to use the dmar apis or not. */
81 unsigned int needs_dmar : 1; 80 unsigned int needs_dmar : 1;
82 phys_addr_t gma_bus_addr; 81 phys_addr_t gma_bus_addr;
82 /* Size of memory reserved for graphics by the BIOS */
83 unsigned int stolen_size;
84 /* Total number of gtt entries. */
85 unsigned int gtt_total_entries;
86 /* Part of the gtt that is mappable by the cpu, for those chips where
87 * this is not the full gtt. */
88 unsigned int gtt_mappable_entries;
83} intel_private; 89} intel_private;
84 90
85#define INTEL_GTT_GEN intel_private.driver->gen 91#define INTEL_GTT_GEN intel_private.driver->gen
@@ -510,7 +516,7 @@ static unsigned int intel_gtt_total_entries(void)
510 /* On previous hardware, the GTT size was just what was 516 /* On previous hardware, the GTT size was just what was
511 * required to map the aperture. 517 * required to map the aperture.
512 */ 518 */
513 return intel_private.base.gtt_mappable_entries; 519 return intel_private.gtt_mappable_entries;
514 } 520 }
515} 521}
516 522
@@ -576,8 +582,8 @@ static int intel_gtt_init(void)
576 if (ret != 0) 582 if (ret != 0)
577 return ret; 583 return ret;
578 584
579 intel_private.base.gtt_mappable_entries = intel_gtt_mappable_entries(); 585 intel_private.gtt_mappable_entries = intel_gtt_mappable_entries();
580 intel_private.base.gtt_total_entries = intel_gtt_total_entries(); 586 intel_private.gtt_total_entries = intel_gtt_total_entries();
581 587
582 /* save the PGETBL reg for resume */ 588 /* save the PGETBL reg for resume */
583 intel_private.PGETBL_save = 589 intel_private.PGETBL_save =
@@ -589,10 +595,10 @@ static int intel_gtt_init(void)
589 595
590 dev_info(&intel_private.bridge_dev->dev, 596 dev_info(&intel_private.bridge_dev->dev,
591 "detected gtt size: %dK total, %dK mappable\n", 597 "detected gtt size: %dK total, %dK mappable\n",
592 intel_private.base.gtt_total_entries * 4, 598 intel_private.gtt_total_entries * 4,
593 intel_private.base.gtt_mappable_entries * 4); 599 intel_private.gtt_mappable_entries * 4);
594 600
595 gtt_map_size = intel_private.base.gtt_total_entries * 4; 601 gtt_map_size = intel_private.gtt_total_entries * 4;
596 602
597 intel_private.gtt = NULL; 603 intel_private.gtt = NULL;
598 if (INTEL_GTT_GEN < 6 && INTEL_GTT_GEN > 2) 604 if (INTEL_GTT_GEN < 6 && INTEL_GTT_GEN > 2)
@@ -609,7 +615,7 @@ static int intel_gtt_init(void)
609 615
610 global_cache_flush(); /* FIXME: ? */ 616 global_cache_flush(); /* FIXME: ? */
611 617
612 intel_private.base.stolen_size = intel_gtt_stolen_size(); 618 intel_private.stolen_size = intel_gtt_stolen_size();
613 619
614 intel_private.needs_dmar = USE_PCI_DMA_API && INTEL_GTT_GEN > 2; 620 intel_private.needs_dmar = USE_PCI_DMA_API && INTEL_GTT_GEN > 2;
615 621
@@ -637,8 +643,7 @@ static int intel_fake_agp_fetch_size(void)
637 unsigned int aper_size; 643 unsigned int aper_size;
638 int i; 644 int i;
639 645
640 aper_size = (intel_private.base.gtt_mappable_entries << PAGE_SHIFT) 646 aper_size = (intel_private.gtt_mappable_entries << PAGE_SHIFT) / MB(1);
641 / MB(1);
642 647
643 for (i = 0; i < num_sizes; i++) { 648 for (i = 0; i < num_sizes; i++) {
644 if (aper_size == intel_fake_agp_sizes[i].size) { 649 if (aper_size == intel_fake_agp_sizes[i].size) {
@@ -845,8 +850,8 @@ static int intel_fake_agp_insert_entries(struct agp_memory *mem,
845 int ret = -EINVAL; 850 int ret = -EINVAL;
846 851
847 if (intel_private.clear_fake_agp) { 852 if (intel_private.clear_fake_agp) {
848 int start = intel_private.base.stolen_size / PAGE_SIZE; 853 int start = intel_private.stolen_size / PAGE_SIZE;
849 int end = intel_private.base.gtt_mappable_entries; 854 int end = intel_private.gtt_mappable_entries;
850 intel_gtt_clear_range(start, end - start); 855 intel_gtt_clear_range(start, end - start);
851 intel_private.clear_fake_agp = false; 856 intel_private.clear_fake_agp = false;
852 } 857 }
@@ -857,7 +862,7 @@ static int intel_fake_agp_insert_entries(struct agp_memory *mem,
857 if (mem->page_count == 0) 862 if (mem->page_count == 0)
858 goto out; 863 goto out;
859 864
860 if (pg_start + mem->page_count > intel_private.base.gtt_total_entries) 865 if (pg_start + mem->page_count > intel_private.gtt_total_entries)
861 goto out_err; 866 goto out_err;
862 867
863 if (type != mem->type) 868 if (type != mem->type)
@@ -1366,9 +1371,10 @@ int intel_gmch_probe(struct pci_dev *bridge_pdev, struct pci_dev *gpu_pdev,
1366} 1371}
1367EXPORT_SYMBOL(intel_gmch_probe); 1372EXPORT_SYMBOL(intel_gmch_probe);
1368 1373
1369struct intel_gtt *intel_gtt_get(void) 1374void intel_gtt_get(size_t *gtt_total, size_t *stolen_size)
1370{ 1375{
1371 return &intel_private.base; 1376 *gtt_total = intel_private.gtt_total_entries << PAGE_SHIFT;
1377 *stolen_size = intel_private.stolen_size;
1372} 1378}
1373EXPORT_SYMBOL(intel_gtt_get); 1379EXPORT_SYMBOL(intel_gtt_get);
1374 1380
diff --git a/drivers/gpu/drm/i915/i915_drv.h b/drivers/gpu/drm/i915/i915_drv.h
index dee8d5c7a235..d3274164143d 100644
--- a/drivers/gpu/drm/i915/i915_drv.h
+++ b/drivers/gpu/drm/i915/i915_drv.h
@@ -406,6 +406,7 @@ struct i915_gtt {
406 unsigned int pg_start, 406 unsigned int pg_start,
407 enum i915_cache_level cache_level); 407 enum i915_cache_level cache_level);
408}; 408};
409#define gtt_total_entries(gtt) ((gtt).total >> PAGE_SHIFT)
409 410
410#define I915_PPGTT_PD_ENTRIES 512 411#define I915_PPGTT_PD_ENTRIES 512
411#define I915_PPGTT_PT_ENTRIES 1024 412#define I915_PPGTT_PT_ENTRIES 1024
@@ -696,8 +697,6 @@ struct intel_l3_parity {
696}; 697};
697 698
698struct i915_gem_mm { 699struct i915_gem_mm {
699 /** Bridge to intel-gtt-ko */
700 struct intel_gtt *gtt;
701 /** Memory allocator for GTT stolen memory */ 700 /** Memory allocator for GTT stolen memory */
702 struct drm_mm stolen; 701 struct drm_mm stolen;
703 /** Memory allocator for GTT */ 702 /** Memory allocator for GTT */
diff --git a/drivers/gpu/drm/i915/i915_gem_gtt.c b/drivers/gpu/drm/i915/i915_gem_gtt.c
index 87249e8cd4a0..f7e0018626bd 100644
--- a/drivers/gpu/drm/i915/i915_gem_gtt.c
+++ b/drivers/gpu/drm/i915/i915_gem_gtt.c
@@ -182,7 +182,8 @@ static int gen6_ppgtt_init(struct i915_hw_ppgtt *ppgtt)
182 /* ppgtt PDEs reside in the global gtt pagetable, which has 512*1024 182 /* ppgtt PDEs reside in the global gtt pagetable, which has 512*1024
183 * entries. For aliasing ppgtt support we just steal them at the end for 183 * entries. For aliasing ppgtt support we just steal them at the end for
184 * now. */ 184 * now. */
185 first_pd_entry_in_global_pt = dev_priv->mm.gtt->gtt_total_entries - I915_PPGTT_PD_ENTRIES; 185 first_pd_entry_in_global_pt =
186 gtt_total_entries(dev_priv->gtt) - I915_PPGTT_PD_ENTRIES;
186 187
187 ppgtt->num_pd_entries = I915_PPGTT_PD_ENTRIES; 188 ppgtt->num_pd_entries = I915_PPGTT_PD_ENTRIES;
188 ppgtt->clear_range = gen6_ppgtt_clear_range; 189 ppgtt->clear_range = gen6_ppgtt_clear_range;
@@ -473,7 +474,7 @@ static void gen6_ggtt_clear_range(struct drm_device *dev,
473 struct drm_i915_private *dev_priv = dev->dev_private; 474 struct drm_i915_private *dev_priv = dev->dev_private;
474 gtt_pte_t scratch_pte; 475 gtt_pte_t scratch_pte;
475 gtt_pte_t __iomem *gtt_base = (gtt_pte_t __iomem *) dev_priv->gtt.gsm + first_entry; 476 gtt_pte_t __iomem *gtt_base = (gtt_pte_t __iomem *) dev_priv->gtt.gsm + first_entry;
476 const int max_entries = dev_priv->mm.gtt->gtt_total_entries - first_entry; 477 const int max_entries = gtt_total_entries(dev_priv->gtt) - first_entry;
477 int i; 478 int i;
478 479
479 if (WARN(num_entries > max_entries, 480 if (WARN(num_entries > max_entries,
@@ -634,7 +635,7 @@ void i915_gem_init_global_gtt(struct drm_device *dev)
634 unsigned long gtt_size, mappable_size; 635 unsigned long gtt_size, mappable_size;
635 int ret; 636 int ret;
636 637
637 gtt_size = dev_priv->mm.gtt->gtt_total_entries << PAGE_SHIFT; 638 gtt_size = dev_priv->gtt.total;
638 mappable_size = dev_priv->gtt.mappable_end; 639 mappable_size = dev_priv->gtt.mappable_end;
639 640
640 if (intel_enable_ppgtt(dev) && HAS_ALIASING_PPGTT(dev)) { 641 if (intel_enable_ppgtt(dev) && HAS_ALIASING_PPGTT(dev)) {
@@ -778,7 +779,6 @@ void gen6_gmch_remove(struct drm_device *dev)
778 struct drm_i915_private *dev_priv = dev->dev_private; 779 struct drm_i915_private *dev_priv = dev->dev_private;
779 iounmap(dev_priv->gtt.gsm); 780 iounmap(dev_priv->gtt.gsm);
780 teardown_scratch_page(dev_priv->dev); 781 teardown_scratch_page(dev_priv->dev);
781 kfree(dev_priv->mm.gtt);
782} 782}
783 783
784static int i915_gmch_probe(struct drm_device *dev, 784static int i915_gmch_probe(struct drm_device *dev,
@@ -788,22 +788,13 @@ static int i915_gmch_probe(struct drm_device *dev,
788 struct drm_i915_private *dev_priv = dev->dev_private; 788 struct drm_i915_private *dev_priv = dev->dev_private;
789 int ret; 789 int ret;
790 790
791 /* This is a temporary hack to make the code cleaner in
792 * i915_gem_gtt_init. I promise it will go away very shortly. */
793 kfree(dev_priv->mm.gtt);
794
795 ret = intel_gmch_probe(dev_priv->bridge_dev, dev_priv->dev->pdev, NULL); 791 ret = intel_gmch_probe(dev_priv->bridge_dev, dev_priv->dev->pdev, NULL);
796 if (!ret) { 792 if (!ret) {
797 DRM_ERROR("failed to set up gmch\n"); 793 DRM_ERROR("failed to set up gmch\n");
798 return -EIO; 794 return -EIO;
799 } 795 }
800 796
801 dev_priv->mm.gtt = intel_gtt_get(); 797 intel_gtt_get(gtt_total, stolen);
802 if (!dev_priv->mm.gtt) {
803 DRM_ERROR("Failed to initialize GTT\n");
804 intel_gmch_remove();
805 return -ENODEV;
806 }
807 798
808 dev_priv->gtt.do_idle_maps = needs_idle_maps(dev_priv->dev); 799 dev_priv->gtt.do_idle_maps = needs_idle_maps(dev_priv->dev);
809 dev_priv->gtt.gtt_clear_range = i915_ggtt_clear_range; 800 dev_priv->gtt.gtt_clear_range = i915_ggtt_clear_range;
@@ -824,10 +815,6 @@ int i915_gem_gtt_init(struct drm_device *dev)
824 unsigned long gtt_size; 815 unsigned long gtt_size;
825 int ret; 816 int ret;
826 817
827 dev_priv->mm.gtt = kzalloc(sizeof(*dev_priv->mm.gtt), GFP_KERNEL);
828 if (!dev_priv->mm.gtt)
829 return -ENOMEM;
830
831 gtt->mappable_base = pci_resource_start(dev->pdev, 2); 818 gtt->mappable_base = pci_resource_start(dev->pdev, 2);
832 gtt->mappable_end = pci_resource_len(dev->pdev, 2); 819 gtt->mappable_end = pci_resource_len(dev->pdev, 2);
833 820
@@ -841,13 +828,8 @@ int i915_gem_gtt_init(struct drm_device *dev)
841 828
842 ret = dev_priv->gtt.gtt_probe(dev, &dev_priv->gtt.total, 829 ret = dev_priv->gtt.gtt_probe(dev, &dev_priv->gtt.total,
843 &dev_priv->gtt.stolen_size); 830 &dev_priv->gtt.stolen_size);
844 if (ret) { 831 if (ret)
845 kfree(dev_priv->mm.gtt);
846 return ret; 832 return ret;
847 }
848
849 dev_priv->mm.gtt->gtt_total_entries = dev_priv->gtt.total >> PAGE_SHIFT;
850 dev_priv->mm.gtt->stolen_size = dev_priv->gtt.stolen_size;
851 833
852 gtt_size = (dev_priv->gtt.total >> PAGE_SHIFT) * sizeof(gtt_pte_t); 834 gtt_size = (dev_priv->gtt.total >> PAGE_SHIFT) * sizeof(gtt_pte_t);
853 835
diff --git a/drivers/gpu/drm/i915/i915_gem_stolen.c b/drivers/gpu/drm/i915/i915_gem_stolen.c
index f21ae17e298f..69d97cbac13c 100644
--- a/drivers/gpu/drm/i915/i915_gem_stolen.c
+++ b/drivers/gpu/drm/i915/i915_gem_stolen.c
@@ -187,11 +187,11 @@ int i915_gem_init_stolen(struct drm_device *dev)
187 if (dev_priv->mm.stolen_base == 0) 187 if (dev_priv->mm.stolen_base == 0)
188 return 0; 188 return 0;
189 189
190 DRM_DEBUG_KMS("found %d bytes of stolen memory at %08lx\n", 190 DRM_DEBUG_KMS("found %zd bytes of stolen memory at %08lx\n",
191 dev_priv->mm.gtt->stolen_size, dev_priv->mm.stolen_base); 191 dev_priv->gtt.stolen_size, dev_priv->mm.stolen_base);
192 192
193 /* Basic memrange allocator for stolen space */ 193 /* Basic memrange allocator for stolen space */
194 drm_mm_init(&dev_priv->mm.stolen, 0, dev_priv->mm.gtt->stolen_size); 194 drm_mm_init(&dev_priv->mm.stolen, 0, dev_priv->gtt.stolen_size);
195 195
196 return 0; 196 return 0;
197} 197}
@@ -205,7 +205,7 @@ i915_pages_create_for_stolen(struct drm_device *dev,
205 struct scatterlist *sg; 205 struct scatterlist *sg;
206 206
207 DRM_DEBUG_DRIVER("offset=0x%x, size=%d\n", offset, size); 207 DRM_DEBUG_DRIVER("offset=0x%x, size=%d\n", offset, size);
208 BUG_ON(offset > dev_priv->mm.gtt->stolen_size - size); 208 BUG_ON(offset > dev_priv->gtt.stolen_size - size);
209 209
210 /* We hide that we have no struct page backing our stolen object 210 /* We hide that we have no struct page backing our stolen object
211 * by wrapping the contiguous physical allocation with a fake 211 * by wrapping the contiguous physical allocation with a fake
diff --git a/include/drm/intel-gtt.h b/include/drm/intel-gtt.h
index 769b6c79097e..cf105557fea9 100644
--- a/include/drm/intel-gtt.h
+++ b/include/drm/intel-gtt.h
@@ -3,15 +3,7 @@
3#ifndef _DRM_INTEL_GTT_H 3#ifndef _DRM_INTEL_GTT_H
4#define _DRM_INTEL_GTT_H 4#define _DRM_INTEL_GTT_H
5 5
6struct intel_gtt { 6void intel_gtt_get(size_t *gtt_total, size_t *stolen_size);
7 /* Size of memory reserved for graphics by the BIOS */
8 unsigned int stolen_size;
9 /* Total number of gtt entries. */
10 unsigned int gtt_total_entries;
11 /* Part of the gtt that is mappable by the cpu, for those chips where
12 * this is not the full gtt. */
13 unsigned int gtt_mappable_entries;
14} *intel_gtt_get(void);
15 7
16int intel_gmch_probe(struct pci_dev *bridge_pdev, struct pci_dev *gpu_pdev, 8int intel_gmch_probe(struct pci_dev *bridge_pdev, struct pci_dev *gpu_pdev,
17 struct agp_bridge_data *bridge); 9 struct agp_bridge_data *bridge);