aboutsummaryrefslogtreecommitdiffstats
path: root/drivers
diff options
context:
space:
mode:
authorChris Wilson <chris@chris-wilson.co.uk>2010-11-23 09:24:24 -0500
committerChris Wilson <chris@chris-wilson.co.uk>2010-11-23 10:43:18 -0500
commitc64f7ba5f1006d8c20eacafecf98d4d00a6902a0 (patch)
tree0309e263e05be06e718d6a07169802ac026aef68 /drivers
parent1b6064d79b9a1c5e5aa6fcc6855f3da5e639ff73 (diff)
agp/intel: Remove confusion of stolen entries not stolen memory
Signed-off-by: Chris Wilson <chris@chris-wilson.co.uk>
Diffstat (limited to 'drivers')
-rw-r--r--drivers/char/agp/intel-gtt.c40
-rw-r--r--drivers/gpu/drm/i915/i915_dma.c4
-rw-r--r--drivers/gpu/drm/i915/i915_drv.h2
3 files changed, 10 insertions, 36 deletions
diff --git a/drivers/char/agp/intel-gtt.c b/drivers/char/agp/intel-gtt.c
index 19919ef9d66..d2733e526a6 100644
--- a/drivers/char/agp/intel-gtt.c
+++ b/drivers/char/agp/intel-gtt.c
@@ -477,26 +477,17 @@ static const struct aper_size_info_fixed const intel_fake_agp_sizes[] = {
477 {512, 131072, 7}, 477 {512, 131072, 7},
478}; 478};
479 479
480static unsigned int intel_gtt_stolen_entries(void) 480static unsigned int intel_gtt_stolen_size(void)
481{ 481{
482 u16 gmch_ctrl; 482 u16 gmch_ctrl;
483 u8 rdct; 483 u8 rdct;
484 int local = 0; 484 int local = 0;
485 static const int ddt[4] = { 0, 16, 32, 64 }; 485 static const int ddt[4] = { 0, 16, 32, 64 };
486 unsigned int overhead_entries;
487 unsigned int stolen_size = 0; 486 unsigned int stolen_size = 0;
488 487
489 pci_read_config_word(intel_private.bridge_dev, 488 pci_read_config_word(intel_private.bridge_dev,
490 I830_GMCH_CTRL, &gmch_ctrl); 489 I830_GMCH_CTRL, &gmch_ctrl);
491 490
492 if (INTEL_GTT_GEN > 4 || IS_PINEVIEW)
493 overhead_entries = 0;
494 else
495 overhead_entries = intel_private.base.gtt_mappable_entries
496 / 1024;
497
498 overhead_entries += 1; /* BIOS popup */
499
500 if (intel_private.bridge_dev->device == PCI_DEVICE_ID_INTEL_82830_HB || 491 if (intel_private.bridge_dev->device == PCI_DEVICE_ID_INTEL_82830_HB ||
501 intel_private.bridge_dev->device == PCI_DEVICE_ID_INTEL_82845G_HB) { 492 intel_private.bridge_dev->device == PCI_DEVICE_ID_INTEL_82845G_HB) {
502 switch (gmch_ctrl & I830_GMCH_GMS_MASK) { 493 switch (gmch_ctrl & I830_GMCH_GMS_MASK) {
@@ -631,7 +622,7 @@ static unsigned int intel_gtt_stolen_entries(void)
631 stolen_size = 0; 622 stolen_size = 0;
632 } 623 }
633 624
634 return stolen_size/KB(4) - overhead_entries; 625 return stolen_size;
635} 626}
636 627
637static void i965_adjust_pgetbl_size(unsigned int size_flag) 628static void i965_adjust_pgetbl_size(unsigned int size_flag)
@@ -817,8 +808,8 @@ static int intel_gtt_init(void)
817 global_cache_flush(); /* FIXME: ? */ 808 global_cache_flush(); /* FIXME: ? */
818 809
819 /* we have to call this as early as possible after the MMIO base address is known */ 810 /* we have to call this as early as possible after the MMIO base address is known */
820 intel_private.base.gtt_stolen_entries = intel_gtt_stolen_entries(); 811 intel_private.base.stolen_size = intel_gtt_stolen_size();
821 if (intel_private.base.gtt_stolen_entries == 0) { 812 if (intel_private.base.stolen_size == 0) {
822 intel_private.driver->cleanup(); 813 intel_private.driver->cleanup();
823 iounmap(intel_private.registers); 814 iounmap(intel_private.registers);
824 iounmap(intel_private.gtt); 815 iounmap(intel_private.gtt);
@@ -1006,8 +997,7 @@ static int intel_fake_agp_configure(void)
1006 997
1007 agp_bridge->gart_bus_addr = intel_private.gma_bus_addr; 998 agp_bridge->gart_bus_addr = intel_private.gma_bus_addr;
1008 999
1009 for (i = intel_private.base.gtt_stolen_entries; 1000 for (i = 0; i < intel_private.base.gtt_total_entries; i++) {
1010 i < intel_private.base.gtt_total_entries; i++) {
1011 intel_private.driver->write_entry(intel_private.scratch_page_dma, 1001 intel_private.driver->write_entry(intel_private.scratch_page_dma,
1012 i, 0); 1002 i, 0);
1013 } 1003 }
@@ -1065,17 +1055,7 @@ static int intel_fake_agp_insert_entries(struct agp_memory *mem,
1065 if (mem->page_count == 0) 1055 if (mem->page_count == 0)
1066 goto out; 1056 goto out;
1067 1057
1068 if (pg_start < intel_private.base.gtt_stolen_entries) { 1058 if (pg_start + mem->page_count > intel_private.base.gtt_total_entries)
1069 dev_printk(KERN_DEBUG, &intel_private.pcidev->dev,
1070 "pg_start == 0x%.8lx, gtt_stolen_entries == 0x%.8x\n",
1071 pg_start, intel_private.base.gtt_stolen_entries);
1072
1073 dev_info(&intel_private.pcidev->dev,
1074 "trying to insert into local/stolen memory\n");
1075 goto out_err;
1076 }
1077
1078 if ((pg_start + mem->page_count) > intel_private.base.gtt_total_entries)
1079 goto out_err; 1059 goto out_err;
1080 1060
1081 if (type != mem->type) 1061 if (type != mem->type)
@@ -1118,12 +1098,6 @@ static int intel_fake_agp_remove_entries(struct agp_memory *mem,
1118 if (mem->page_count == 0) 1098 if (mem->page_count == 0)
1119 return 0; 1099 return 0;
1120 1100
1121 if (pg_start < intel_private.base.gtt_stolen_entries) {
1122 dev_info(&intel_private.pcidev->dev,
1123 "trying to disable local/stolen memory\n");
1124 return -EINVAL;
1125 }
1126
1127 if (USE_PCI_DMA_API && INTEL_GTT_GEN > 2) 1101 if (USE_PCI_DMA_API && INTEL_GTT_GEN > 2)
1128 intel_agp_unmap_memory(mem); 1102 intel_agp_unmap_memory(mem);
1129 1103
@@ -1629,7 +1603,7 @@ int intel_gmch_probe(struct pci_dev *pdev,
1629} 1603}
1630EXPORT_SYMBOL(intel_gmch_probe); 1604EXPORT_SYMBOL(intel_gmch_probe);
1631 1605
1632struct intel_gtt *intel_gtt_get(void) 1606const struct intel_gtt *intel_gtt_get(void)
1633{ 1607{
1634 return &intel_private.base; 1608 return &intel_private.base;
1635} 1609}
diff --git a/drivers/gpu/drm/i915/i915_dma.c b/drivers/gpu/drm/i915/i915_dma.c
index 3df271215ab..86b0e8052ec 100644
--- a/drivers/gpu/drm/i915/i915_dma.c
+++ b/drivers/gpu/drm/i915/i915_dma.c
@@ -1044,7 +1044,7 @@ static unsigned long i915_stolen_to_phys(struct drm_device *dev, u32 offset)
1044 pci_read_config_byte(pdev, 0x9c, &val); 1044 pci_read_config_byte(pdev, 0x9c, &val);
1045 base = val >> 3 << 27; 1045 base = val >> 3 << 27;
1046 } 1046 }
1047 base -= dev_priv->mm.gtt->gtt_stolen_entries << PAGE_SHIFT; 1047 base -= dev_priv->mm.gtt->stolen_size;
1048#endif 1048#endif
1049 1049
1050 return base + offset; 1050 return base + offset;
@@ -1168,7 +1168,7 @@ static int i915_load_modeset_init(struct drm_device *dev)
1168 unsigned long prealloc_size, gtt_size, mappable_size; 1168 unsigned long prealloc_size, gtt_size, mappable_size;
1169 int ret = 0; 1169 int ret = 0;
1170 1170
1171 prealloc_size = dev_priv->mm.gtt->gtt_stolen_entries << PAGE_SHIFT; 1171 prealloc_size = dev_priv->mm.gtt->stolen_size;
1172 gtt_size = dev_priv->mm.gtt->gtt_total_entries << PAGE_SHIFT; 1172 gtt_size = dev_priv->mm.gtt->gtt_total_entries << PAGE_SHIFT;
1173 mappable_size = dev_priv->mm.gtt->gtt_mappable_entries << PAGE_SHIFT; 1173 mappable_size = dev_priv->mm.gtt->gtt_mappable_entries << PAGE_SHIFT;
1174 1174
diff --git a/drivers/gpu/drm/i915/i915_drv.h b/drivers/gpu/drm/i915/i915_drv.h
index 745e46b0673..b62ff5d6fa7 100644
--- a/drivers/gpu/drm/i915/i915_drv.h
+++ b/drivers/gpu/drm/i915/i915_drv.h
@@ -542,7 +542,7 @@ typedef struct drm_i915_private {
542 542
543 struct { 543 struct {
544 /** Bridge to intel-gtt-ko */ 544 /** Bridge to intel-gtt-ko */
545 struct intel_gtt *gtt; 545 const struct intel_gtt *gtt;
546 /** Memory allocator for GTT stolen memory */ 546 /** Memory allocator for GTT stolen memory */
547 struct drm_mm stolen; 547 struct drm_mm stolen;
548 /** Memory allocator for GTT */ 548 /** Memory allocator for GTT */