aboutsummaryrefslogtreecommitdiffstats
path: root/drivers/char/agp/intel-gtt.c
diff options
context:
space:
mode:
authorDaniel Vetter <daniel.vetter@ffwll.ch>2010-08-27 11:12:41 -0400
committerChris Wilson <chris@chris-wilson.co.uk>2010-09-08 16:20:12 -0400
commitfbe407836b5c8d82c68195962240a392d0ce64ea (patch)
tree243c746f61fae6ecff3f1459408be5909c4e161d /drivers/char/agp/intel-gtt.c
parent77ad498ecaeb9a614d2a7bbfaab58a35c0cc577d (diff)
intel-gtt: adjust overhead entries in intel_gtt_stolen_entries
agp/intel_gtt.c and drm/i915/i915_dma.c don't calculate this the same way: The intel-gtt code seems to use the actual gtt size, the drm module just the mappable. Go with the logic from the drm module because that's the more conservative choice. But conserve the original code in intel_gtt_total_size for later use. 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.c141
1 files changed, 78 insertions, 63 deletions
diff --git a/drivers/char/agp/intel-gtt.c b/drivers/char/agp/intel-gtt.c
index a620296c0810..04e052e3f3da 100644
--- a/drivers/char/agp/intel-gtt.c
+++ b/drivers/char/agp/intel-gtt.c
@@ -537,76 +537,19 @@ static unsigned int intel_gtt_stolen_entries(void)
537 u8 rdct; 537 u8 rdct;
538 int local = 0; 538 int local = 0;
539 static const int ddt[4] = { 0, 16, 32, 64 }; 539 static const int ddt[4] = { 0, 16, 32, 64 };
540 int size; /* reserved space (in kb) at the top of stolen memory */
541 unsigned int overhead_entries, stolen_entries; 540 unsigned int overhead_entries, stolen_entries;
542 unsigned int stolen_size = 0; 541 unsigned int stolen_size = 0;
543 542
544 pci_read_config_word(intel_private.bridge_dev, 543 pci_read_config_word(intel_private.bridge_dev,
545 I830_GMCH_CTRL, &gmch_ctrl); 544 I830_GMCH_CTRL, &gmch_ctrl);
546 545
547 if (IS_I965) { 546 if (IS_G4X || IS_PINEVIEW)
548 u32 pgetbl_ctl; 547 overhead_entries = 0;
549 pgetbl_ctl = readl(intel_private.registers+I810_PGETBL_CTL); 548 else
550 549 overhead_entries = intel_private.base.gtt_mappable_entries
551 /* The 965 has a field telling us the size of the GTT, 550 / 1024;
552 * which may be larger than what is necessary to map the
553 * aperture.
554 */
555 switch (pgetbl_ctl & I965_PGETBL_SIZE_MASK) {
556 case I965_PGETBL_SIZE_128KB:
557 size = 128;
558 break;
559 case I965_PGETBL_SIZE_256KB:
560 size = 256;
561 break;
562 case I965_PGETBL_SIZE_512KB:
563 size = 512;
564 break;
565 case I965_PGETBL_SIZE_1MB:
566 size = 1024;
567 break;
568 case I965_PGETBL_SIZE_2MB:
569 size = 2048;
570 break;
571 case I965_PGETBL_SIZE_1_5MB:
572 size = 1024 + 512;
573 break;
574 default:
575 dev_info(&intel_private.pcidev->dev,
576 "unknown page table size, assuming 512KB\n");
577 size = 512;
578 }
579 size += 4; /* add in BIOS popup space */
580 } else if (IS_G33 && !IS_PINEVIEW) {
581 /* G33's GTT size defined in gmch_ctrl */
582 switch (gmch_ctrl & G33_PGETBL_SIZE_MASK) {
583 case G33_PGETBL_SIZE_1M:
584 size = 1024;
585 break;
586 case G33_PGETBL_SIZE_2M:
587 size = 2048;
588 break;
589 default:
590 dev_info(&intel_private.bridge_dev->dev,
591 "unknown page table size 0x%x, assuming 512KB\n",
592 (gmch_ctrl & G33_PGETBL_SIZE_MASK));
593 size = 512;
594 }
595 size += 4;
596 } else if (IS_G4X || IS_PINEVIEW) {
597 /* On 4 series hardware, GTT stolen is separate from graphics
598 * stolen, ignore it in stolen gtt entries counting. However,
599 * 4KB of the stolen memory doesn't get mapped to the GTT.
600 */
601 size = 4;
602 } else {
603 /* On previous hardware, the GTT size was just what was
604 * required to map the aperture.
605 */
606 size = agp_bridge->driver->fetch_size() + 4;
607 }
608 551
609 overhead_entries = size/4; 552 overhead_entries += 1; /* BIOS popup */
610 553
611 if (intel_private.bridge_dev->device == PCI_DEVICE_ID_INTEL_82830_HB || 554 if (intel_private.bridge_dev->device == PCI_DEVICE_ID_INTEL_82830_HB ||
612 intel_private.bridge_dev->device == PCI_DEVICE_ID_INTEL_82845G_HB) { 555 intel_private.bridge_dev->device == PCI_DEVICE_ID_INTEL_82845G_HB) {
@@ -752,6 +695,78 @@ static unsigned int intel_gtt_stolen_entries(void)
752 return stolen_entries; 695 return stolen_entries;
753} 696}
754 697
698#if 0 /* extracted code in bad shape, needs some cleaning before use */
699static unsigned int intel_gtt_total_entries(void)
700{
701 int size;
702 u16 gmch_ctrl;
703
704 if (IS_I965) {
705 u32 pgetbl_ctl;
706 pgetbl_ctl = readl(intel_private.registers+I810_PGETBL_CTL);
707
708 /* The 965 has a field telling us the size of the GTT,
709 * which may be larger than what is necessary to map the
710 * aperture.
711 */
712 switch (pgetbl_ctl & I965_PGETBL_SIZE_MASK) {
713 case I965_PGETBL_SIZE_128KB:
714 size = 128;
715 break;
716 case I965_PGETBL_SIZE_256KB:
717 size = 256;
718 break;
719 case I965_PGETBL_SIZE_512KB:
720 size = 512;
721 break;
722 case I965_PGETBL_SIZE_1MB:
723 size = 1024;
724 break;
725 case I965_PGETBL_SIZE_2MB:
726 size = 2048;
727 break;
728 case I965_PGETBL_SIZE_1_5MB:
729 size = 1024 + 512;
730 break;
731 default:
732 dev_info(&intel_private.pcidev->dev,
733 "unknown page table size, assuming 512KB\n");
734 size = 512;
735 }
736 size += 4; /* add in BIOS popup space */
737 } else if (IS_G33 && !IS_PINEVIEW) {
738 /* G33's GTT size defined in gmch_ctrl */
739 switch (gmch_ctrl & G33_PGETBL_SIZE_MASK) {
740 case G33_PGETBL_SIZE_1M:
741 size = 1024;
742 break;
743 case G33_PGETBL_SIZE_2M:
744 size = 2048;
745 break;
746 default:
747 dev_info(&intel_private.bridge_dev->dev,
748 "unknown page table size 0x%x, assuming 512KB\n",
749 (gmch_ctrl & G33_PGETBL_SIZE_MASK));
750 size = 512;
751 }
752 size += 4;
753 } else if (IS_G4X || IS_PINEVIEW) {
754 /* On 4 series hardware, GTT stolen is separate from graphics
755 * stolen, ignore it in stolen gtt entries counting. However,
756 * 4KB of the stolen memory doesn't get mapped to the GTT.
757 */
758 size = 4;
759 } else {
760 /* On previous hardware, the GTT size was just what was
761 * required to map the aperture.
762 */
763 size = agp_bridge->driver->fetch_size() + 4;
764 }
765
766 return size/KB(4);
767}
768#endif
769
755static unsigned int intel_gtt_mappable_entries(void) 770static unsigned int intel_gtt_mappable_entries(void)
756{ 771{
757 unsigned int aperture_size; 772 unsigned int aperture_size;