aboutsummaryrefslogtreecommitdiffstats
path: root/drivers/char/agp/intel-gtt.c
diff options
context:
space:
mode:
authorDaniel Vetter <daniel.vetter@ffwll.ch>2010-08-28 10:14:32 -0400
committerChris Wilson <chris@chris-wilson.co.uk>2010-09-08 16:20:15 -0400
commit210b23c2f7b9721afb0a57459b7dbac3b094862e (patch)
tree1294b7eff22f03bc10c2a8ffa64333fe56895b7a /drivers/char/agp/intel-gtt.c
parentccc4e67be5ac1bd38c4bfd61aca38366597e8afb (diff)
intel-gtt: i965: use detected gtt size for mapping
Also move the Sandybdridge size detection into gtt_total_entries, like the rest. Signed-off-by: Daniel Vetter <daniel.vetter@ffwll.ch> Signed-off-by: Chris Wilson <chris@chris-wilson.co.uk>
Diffstat (limited to 'drivers/char/agp/intel-gtt.c')
-rw-r--r--drivers/char/agp/intel-gtt.c76
1 files changed, 34 insertions, 42 deletions
diff --git a/drivers/char/agp/intel-gtt.c b/drivers/char/agp/intel-gtt.c
index 3d93cd0acc01..cd0fd1479e5d 100644
--- a/drivers/char/agp/intel-gtt.c
+++ b/drivers/char/agp/intel-gtt.c
@@ -712,7 +712,7 @@ static unsigned int intel_gtt_total_entries(void)
712{ 712{
713 int size; 713 int size;
714 714
715 if (IS_G33 || INTEL_GTT_GEN >= 4) { 715 if (IS_G33 || INTEL_GTT_GEN == 4 || INTEL_GTT_GEN == 5) {
716 u32 pgetbl_ctl; 716 u32 pgetbl_ctl;
717 pgetbl_ctl = readl(intel_private.registers+I810_PGETBL_CTL); 717 pgetbl_ctl = readl(intel_private.registers+I810_PGETBL_CTL);
718 718
@@ -742,6 +742,24 @@ static unsigned int intel_gtt_total_entries(void)
742 } 742 }
743 743
744 return size/4; 744 return size/4;
745 } else if (INTEL_GTT_GEN == 6) {
746 u16 snb_gmch_ctl;
747
748 pci_read_config_word(intel_private.pcidev, SNB_GMCH_CTRL, &snb_gmch_ctl);
749 switch (snb_gmch_ctl & SNB_GTT_SIZE_MASK) {
750 default:
751 case SNB_GTT_SIZE_0M:
752 printk(KERN_ERR "Bad GTT size mask: 0x%04x.\n", snb_gmch_ctl);
753 size = MB(0);
754 break;
755 case SNB_GTT_SIZE_1M:
756 size = MB(1);
757 break;
758 case SNB_GTT_SIZE_2M:
759 size = MB(2);
760 break;
761 }
762 return size/4;
745 } else { 763 } else {
746 /* On previous hardware, the GTT size was just what was 764 /* On previous hardware, the GTT size was just what was
747 * required to map the aperture. 765 * required to map the aperture.
@@ -1327,44 +1345,18 @@ static unsigned long intel_gen6_mask_memory(struct agp_bridge_data *bridge,
1327 1345
1328static void intel_i965_get_gtt_range(int *gtt_offset, int *gtt_size) 1346static void intel_i965_get_gtt_range(int *gtt_offset, int *gtt_size)
1329{ 1347{
1330 u16 snb_gmch_ctl; 1348 switch (INTEL_GTT_GEN) {
1331 1349 case 5:
1332 switch (intel_private.bridge_dev->device) { 1350 case 6:
1333 case PCI_DEVICE_ID_INTEL_GM45_HB:
1334 case PCI_DEVICE_ID_INTEL_EAGLELAKE_HB:
1335 case PCI_DEVICE_ID_INTEL_Q45_HB:
1336 case PCI_DEVICE_ID_INTEL_G45_HB:
1337 case PCI_DEVICE_ID_INTEL_G41_HB:
1338 case PCI_DEVICE_ID_INTEL_B43_HB:
1339 case PCI_DEVICE_ID_INTEL_IRONLAKE_D_HB:
1340 case PCI_DEVICE_ID_INTEL_IRONLAKE_M_HB:
1341 case PCI_DEVICE_ID_INTEL_IRONLAKE_MA_HB:
1342 case PCI_DEVICE_ID_INTEL_IRONLAKE_MC2_HB:
1343 *gtt_offset = *gtt_size = MB(2);
1344 break;
1345 case PCI_DEVICE_ID_INTEL_SANDYBRIDGE_HB:
1346 case PCI_DEVICE_ID_INTEL_SANDYBRIDGE_M_HB:
1347 case PCI_DEVICE_ID_INTEL_SANDYBRIDGE_S_HB:
1348 *gtt_offset = MB(2); 1351 *gtt_offset = MB(2);
1349
1350 pci_read_config_word(intel_private.pcidev, SNB_GMCH_CTRL, &snb_gmch_ctl);
1351 switch (snb_gmch_ctl & SNB_GTT_SIZE_MASK) {
1352 default:
1353 case SNB_GTT_SIZE_0M:
1354 printk(KERN_ERR "Bad GTT size mask: 0x%04x.\n", snb_gmch_ctl);
1355 *gtt_size = MB(0);
1356 break;
1357 case SNB_GTT_SIZE_1M:
1358 *gtt_size = MB(1);
1359 break;
1360 case SNB_GTT_SIZE_2M:
1361 *gtt_size = MB(2);
1362 break;
1363 }
1364 break; 1352 break;
1353 case 4:
1365 default: 1354 default:
1366 *gtt_offset = *gtt_size = KB(512); 1355 *gtt_offset = KB(512);
1356 break;
1367 } 1357 }
1358
1359 *gtt_size = intel_private.base.gtt_total_entries * 4;
1368} 1360}
1369 1361
1370/* The intel i965 automatically initializes the agp aperture during POST. 1362/* The intel i965 automatically initializes the agp aperture during POST.
@@ -1387,17 +1379,17 @@ static int intel_i965_create_gatt_table(struct agp_bridge_data *bridge)
1387 1379
1388 temp &= 0xfff00000; 1380 temp &= 0xfff00000;
1389 1381
1390 intel_i965_get_gtt_range(&gtt_offset, &gtt_size); 1382 intel_private.registers = ioremap(temp, 128 * 4096);
1383 if (!intel_private.registers)
1384 return -ENOMEM;
1391 1385
1392 intel_private.gtt = ioremap((temp + gtt_offset) , gtt_size); 1386 intel_private.base.gtt_total_entries = intel_gtt_total_entries();
1393 1387
1394 if (!intel_private.gtt) 1388 intel_i965_get_gtt_range(&gtt_offset, &gtt_size);
1395 return -ENOMEM;
1396 1389
1397 intel_private.base.gtt_total_entries = gtt_size / 4; 1390 intel_private.gtt = ioremap((temp + gtt_offset) , gtt_size);
1398 1391
1399 intel_private.registers = ioremap(temp, 128 * 4096); 1392 if (!intel_private.gtt) {
1400 if (!intel_private.registers) {
1401 iounmap(intel_private.gtt); 1393 iounmap(intel_private.gtt);
1402 return -ENOMEM; 1394 return -ENOMEM;
1403 } 1395 }