aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorDaniel Vetter <daniel.vetter@ffwll.ch>2010-09-08 15:01:04 -0400
committerChris Wilson <chris@chris-wilson.co.uk>2010-09-08 16:20:09 -0400
commit1784a5fb4f7a41b9a5ea066f7782418bfe170c04 (patch)
treeb295e950380bf16dbe54893bd84df56c2b1eca86
parentbfde067bebe72293b1f909a8b35ee8d82811f8f5 (diff)
intel-gtt: new function intel_gtt_mappable_entries
This implementation is stolen from drm/i915, but is equivalent to the code sprinkled over intel-gtt.c in the various fetch_size functions. It's not yet used anywhere, though. Also introduce intel_gtt_init which only calls intel_gtt_stolen_entries. Over the course of the next patches, this will grow untill it contains the complete init sequence starting from the call to gtt_mappable_entries. Signed-off-by: Daniel Vetter <daniel.vetter@ffwll.ch> Signed-off-by: Chris Wilson <chris@chris-wilson.co.uk>
-rw-r--r--drivers/char/agp/intel-gtt.c78
1 files changed, 59 insertions, 19 deletions
diff --git a/drivers/char/agp/intel-gtt.c b/drivers/char/agp/intel-gtt.c
index 9edeb060efb2..932ede81e726 100644
--- a/drivers/char/agp/intel-gtt.c
+++ b/drivers/char/agp/intel-gtt.c
@@ -755,6 +755,7 @@ static unsigned int intel_gtt_stolen_entries(void)
755 break; 755 break;
756 } 756 }
757 } 757 }
758
758 if (!local && gtt_entries > intel_max_stolen) { 759 if (!local && gtt_entries > intel_max_stolen) {
759 dev_info(&intel_private.bridge_dev->dev, 760 dev_info(&intel_private.bridge_dev->dev,
760 "detected %dK stolen memory, trimming to %dK\n", 761 "detected %dK stolen memory, trimming to %dK\n",
@@ -773,6 +774,47 @@ static unsigned int intel_gtt_stolen_entries(void)
773 return gtt_entries; 774 return gtt_entries;
774} 775}
775 776
777static unsigned int intel_gtt_mappable_entries(void)
778{
779 unsigned int aperture_size;
780 u16 gmch_ctrl;
781
782 aperture_size = 1024 * 1024;
783
784 pci_read_config_word(intel_private.bridge_dev,
785 I830_GMCH_CTRL, &gmch_ctrl);
786
787 switch (intel_private.pcidev->device) {
788 case PCI_DEVICE_ID_INTEL_82830_CGC:
789 case PCI_DEVICE_ID_INTEL_82845G_IG:
790 case PCI_DEVICE_ID_INTEL_82855GM_IG:
791 case PCI_DEVICE_ID_INTEL_82865_IG:
792 if ((gmch_ctrl & I830_GMCH_MEM_MASK) == I830_GMCH_MEM_64M)
793 aperture_size *= 64;
794 else
795 aperture_size *= 128;
796 break;
797 default:
798 /* 9xx supports large sizes, just look at the length */
799 aperture_size = pci_resource_len(intel_private.pcidev, 2);
800 break;
801 }
802
803 return aperture_size >> PAGE_SHIFT;
804}
805
806static int intel_gtt_init(void)
807{
808 /* we have to call this as early as possible after the MMIO base address is known */
809 intel_private.base.gtt_stolen_entries = intel_gtt_stolen_entries();
810 if (intel_private.base.gtt_stolen_entries == 0) {
811 iounmap(intel_private.registers);
812 return -ENOMEM;
813 }
814
815 return 0;
816}
817
776static void intel_i830_fini_flush(void) 818static void intel_i830_fini_flush(void)
777{ 819{
778 kunmap(intel_private.i8xx_page); 820 kunmap(intel_private.i8xx_page);
@@ -825,7 +867,7 @@ static void intel_i830_chipset_flush(struct agp_bridge_data *bridge)
825 */ 867 */
826static int intel_i830_create_gatt_table(struct agp_bridge_data *bridge) 868static int intel_i830_create_gatt_table(struct agp_bridge_data *bridge)
827{ 869{
828 int page_order; 870 int page_order, ret;
829 struct aper_size_info_fixed *size; 871 struct aper_size_info_fixed *size;
830 int num_entries; 872 int num_entries;
831 u32 temp; 873 u32 temp;
@@ -845,12 +887,9 @@ static int intel_i830_create_gatt_table(struct agp_bridge_data *bridge)
845 temp = readl(intel_private.registers+I810_PGETBL_CTL) & 0xfffff000; 887 temp = readl(intel_private.registers+I810_PGETBL_CTL) & 0xfffff000;
846 global_cache_flush(); /* FIXME: ?? */ 888 global_cache_flush(); /* FIXME: ?? */
847 889
848 /* we have to call this as early as possible after the MMIO base address is known */ 890 ret = intel_gtt_init();
849 intel_private.base.gtt_stolen_entries = intel_gtt_stolen_entries(); 891 if (ret != 0)
850 if (intel_private.base.gtt_stolen_entries == 0) { 892 return ret;
851 iounmap(intel_private.registers);
852 return -ENOMEM;
853 }
854 893
855 agp_bridge->gatt_table = NULL; 894 agp_bridge->gatt_table = NULL;
856 895
@@ -1302,7 +1341,7 @@ static int intel_i915_get_gtt_size(void)
1302 */ 1341 */
1303static int intel_i915_create_gatt_table(struct agp_bridge_data *bridge) 1342static int intel_i915_create_gatt_table(struct agp_bridge_data *bridge)
1304{ 1343{
1305 int page_order; 1344 int page_order, ret;
1306 struct aper_size_info_fixed *size; 1345 struct aper_size_info_fixed *size;
1307 int num_entries; 1346 int num_entries;
1308 u32 temp, temp2; 1347 u32 temp, temp2;
@@ -1335,12 +1374,10 @@ static int intel_i915_create_gatt_table(struct agp_bridge_data *bridge)
1335 temp = readl(intel_private.registers+I810_PGETBL_CTL) & 0xfffff000; 1374 temp = readl(intel_private.registers+I810_PGETBL_CTL) & 0xfffff000;
1336 global_cache_flush(); /* FIXME: ? */ 1375 global_cache_flush(); /* FIXME: ? */
1337 1376
1338 /* we have to call this as early as possible after the MMIO base address is known */ 1377 ret = intel_gtt_init();
1339 intel_private.base.gtt_stolen_entries = intel_gtt_stolen_entries(); 1378 if (ret != 0) {
1340 if (intel_private.base.gtt_stolen_entries == 0) {
1341 iounmap(intel_private.gtt); 1379 iounmap(intel_private.gtt);
1342 iounmap(intel_private.registers); 1380 return ret;
1343 return -ENOMEM;
1344 } 1381 }
1345 1382
1346 agp_bridge->gatt_table = NULL; 1383 agp_bridge->gatt_table = NULL;
@@ -1426,7 +1463,7 @@ static void intel_i965_get_gtt_range(int *gtt_offset, int *gtt_size)
1426 */ 1463 */
1427static int intel_i965_create_gatt_table(struct agp_bridge_data *bridge) 1464static int intel_i965_create_gatt_table(struct agp_bridge_data *bridge)
1428{ 1465{
1429 int page_order; 1466 int page_order, ret;
1430 struct aper_size_info_fixed *size; 1467 struct aper_size_info_fixed *size;
1431 int num_entries; 1468 int num_entries;
1432 u32 temp; 1469 u32 temp;
@@ -1459,12 +1496,10 @@ static int intel_i965_create_gatt_table(struct agp_bridge_data *bridge)
1459 temp = readl(intel_private.registers+I810_PGETBL_CTL) & 0xfffff000; 1496 temp = readl(intel_private.registers+I810_PGETBL_CTL) & 0xfffff000;
1460 global_cache_flush(); /* FIXME: ? */ 1497 global_cache_flush(); /* FIXME: ? */
1461 1498
1462 /* we have to call this as early as possible after the MMIO base address is known */ 1499 ret = intel_gtt_init();
1463 intel_private.base.gtt_stolen_entries = intel_gtt_stolen_entries(); 1500 if (ret != 0) {
1464 if (intel_private.base.gtt_stolen_entries == 0) {
1465 iounmap(intel_private.gtt); 1501 iounmap(intel_private.gtt);
1466 iounmap(intel_private.registers); 1502 return ret;
1467 return -ENOMEM;
1468 } 1503 }
1469 1504
1470 agp_bridge->gatt_table = NULL; 1505 agp_bridge->gatt_table = NULL;
@@ -1776,6 +1811,11 @@ int intel_gmch_probe(struct pci_dev *pdev,
1776 pci_set_consistent_dma_mask(intel_private.pcidev, 1811 pci_set_consistent_dma_mask(intel_private.pcidev,
1777 DMA_BIT_MASK(mask)); 1812 DMA_BIT_MASK(mask));
1778 1813
1814 if (bridge->driver == &intel_810_driver)
1815 return 1;
1816
1817 intel_private.base.gtt_mappable_entries = intel_gtt_mappable_entries();
1818
1779 return 1; 1819 return 1;
1780} 1820}
1781EXPORT_SYMBOL(intel_gmch_probe); 1821EXPORT_SYMBOL(intel_gmch_probe);