diff options
-rw-r--r-- | drivers/char/agp/intel-agp.h | 14 | ||||
-rw-r--r-- | drivers/char/agp/intel-gtt.c | 96 |
2 files changed, 81 insertions, 29 deletions
diff --git a/drivers/char/agp/intel-agp.h b/drivers/char/agp/intel-agp.h index 90539df02504..010e3defd6c3 100644 --- a/drivers/char/agp/intel-agp.h +++ b/drivers/char/agp/intel-agp.h | |||
@@ -75,6 +75,8 @@ | |||
75 | #define I810_GMS_DISABLE 0x00000000 | 75 | #define I810_GMS_DISABLE 0x00000000 |
76 | #define I810_PGETBL_CTL 0x2020 | 76 | #define I810_PGETBL_CTL 0x2020 |
77 | #define I810_PGETBL_ENABLED 0x00000001 | 77 | #define I810_PGETBL_ENABLED 0x00000001 |
78 | /* Note: PGETBL_CTL2 has a different offset on G33. */ | ||
79 | #define I965_PGETBL_CTL2 0x20c4 | ||
78 | #define I965_PGETBL_SIZE_MASK 0x0000000e | 80 | #define I965_PGETBL_SIZE_MASK 0x0000000e |
79 | #define I965_PGETBL_SIZE_512KB (0 << 1) | 81 | #define I965_PGETBL_SIZE_512KB (0 << 1) |
80 | #define I965_PGETBL_SIZE_256KB (1 << 1) | 82 | #define I965_PGETBL_SIZE_256KB (1 << 1) |
@@ -82,9 +84,15 @@ | |||
82 | #define I965_PGETBL_SIZE_1MB (3 << 1) | 84 | #define I965_PGETBL_SIZE_1MB (3 << 1) |
83 | #define I965_PGETBL_SIZE_2MB (4 << 1) | 85 | #define I965_PGETBL_SIZE_2MB (4 << 1) |
84 | #define I965_PGETBL_SIZE_1_5MB (5 << 1) | 86 | #define I965_PGETBL_SIZE_1_5MB (5 << 1) |
85 | #define G33_PGETBL_SIZE_MASK (3 << 8) | 87 | #define G33_GMCH_SIZE_MASK (3 << 8) |
86 | #define G33_PGETBL_SIZE_1M (1 << 8) | 88 | #define G33_GMCH_SIZE_1M (1 << 8) |
87 | #define G33_PGETBL_SIZE_2M (2 << 8) | 89 | #define G33_GMCH_SIZE_2M (2 << 8) |
90 | #define G4x_GMCH_SIZE_MASK (0xf << 8) | ||
91 | #define G4x_GMCH_SIZE_1M (0x1 << 8) | ||
92 | #define G4x_GMCH_SIZE_2M (0x3 << 8) | ||
93 | #define G4x_GMCH_SIZE_VT_1M (0x9 << 8) | ||
94 | #define G4x_GMCH_SIZE_VT_1_5M (0xa << 8) | ||
95 | #define G4x_GMCH_SIZE_VT_2M (0xc << 8) | ||
88 | 96 | ||
89 | #define I810_DRAM_CTL 0x3000 | 97 | #define I810_DRAM_CTL 0x3000 |
90 | #define I810_DRAM_ROW_0 0x00000001 | 98 | #define I810_DRAM_ROW_0 0x00000001 |
diff --git a/drivers/char/agp/intel-gtt.c b/drivers/char/agp/intel-gtt.c index fd3e94f8ab51..5dc1f5db55a7 100644 --- a/drivers/char/agp/intel-gtt.c +++ b/drivers/char/agp/intel-gtt.c | |||
@@ -642,41 +642,85 @@ static unsigned int intel_gtt_stolen_entries(void) | |||
642 | return stolen_entries; | 642 | return stolen_entries; |
643 | } | 643 | } |
644 | 644 | ||
645 | static unsigned int intel_gtt_total_entries(void) | 645 | static void i965_adjust_pgetbl_size(unsigned int size_flag) |
646 | { | ||
647 | u32 pgetbl_ctl, pgetbl_ctl2; | ||
648 | |||
649 | /* ensure that ppgtt is disabled */ | ||
650 | pgetbl_ctl2 = readl(intel_private.registers+I965_PGETBL_CTL2); | ||
651 | pgetbl_ctl2 &= ~I810_PGETBL_ENABLED; | ||
652 | writel(pgetbl_ctl2, intel_private.registers+I965_PGETBL_CTL2); | ||
653 | |||
654 | /* write the new ggtt size */ | ||
655 | pgetbl_ctl = readl(intel_private.registers+I810_PGETBL_CTL); | ||
656 | pgetbl_ctl &= ~I965_PGETBL_SIZE_MASK; | ||
657 | pgetbl_ctl |= size_flag; | ||
658 | writel(pgetbl_ctl, intel_private.registers+I810_PGETBL_CTL); | ||
659 | } | ||
660 | |||
661 | static unsigned int i965_gtt_total_entries(void) | ||
646 | { | 662 | { |
647 | int size; | 663 | int size; |
664 | u32 pgetbl_ctl; | ||
665 | u16 gmch_ctl; | ||
648 | 666 | ||
649 | if (IS_G33 || INTEL_GTT_GEN == 4 || INTEL_GTT_GEN == 5) { | 667 | pci_read_config_word(intel_private.bridge_dev, |
650 | u32 pgetbl_ctl; | 668 | I830_GMCH_CTRL, &gmch_ctl); |
651 | pgetbl_ctl = readl(intel_private.registers+I810_PGETBL_CTL); | ||
652 | 669 | ||
653 | switch (pgetbl_ctl & I965_PGETBL_SIZE_MASK) { | 670 | if (INTEL_GTT_GEN == 5) { |
654 | case I965_PGETBL_SIZE_128KB: | 671 | switch (gmch_ctl & G4x_GMCH_SIZE_MASK) { |
655 | size = KB(128); | 672 | case G4x_GMCH_SIZE_1M: |
656 | break; | 673 | case G4x_GMCH_SIZE_VT_1M: |
657 | case I965_PGETBL_SIZE_256KB: | 674 | i965_adjust_pgetbl_size(I965_PGETBL_SIZE_1MB); |
658 | size = KB(256); | ||
659 | break; | ||
660 | case I965_PGETBL_SIZE_512KB: | ||
661 | size = KB(512); | ||
662 | break; | ||
663 | case I965_PGETBL_SIZE_1MB: | ||
664 | size = KB(1024); | ||
665 | break; | 675 | break; |
666 | case I965_PGETBL_SIZE_2MB: | 676 | case G4x_GMCH_SIZE_VT_1_5M: |
667 | size = KB(2048); | 677 | i965_adjust_pgetbl_size(I965_PGETBL_SIZE_1_5MB); |
668 | break; | 678 | break; |
669 | case I965_PGETBL_SIZE_1_5MB: | 679 | case G4x_GMCH_SIZE_2M: |
670 | size = KB(1024 + 512); | 680 | case G4x_GMCH_SIZE_VT_2M: |
681 | i965_adjust_pgetbl_size(I965_PGETBL_SIZE_2MB); | ||
671 | break; | 682 | break; |
672 | default: | ||
673 | dev_info(&intel_private.pcidev->dev, | ||
674 | "unknown page table size, assuming 512KB\n"); | ||
675 | size = KB(512); | ||
676 | } | 683 | } |
684 | } | ||
677 | 685 | ||
678 | return size/4; | 686 | pgetbl_ctl = readl(intel_private.registers+I810_PGETBL_CTL); |
679 | } else if (INTEL_GTT_GEN == 6) { | 687 | |
688 | switch (pgetbl_ctl & I965_PGETBL_SIZE_MASK) { | ||
689 | case I965_PGETBL_SIZE_128KB: | ||
690 | size = KB(128); | ||
691 | break; | ||
692 | case I965_PGETBL_SIZE_256KB: | ||
693 | size = KB(256); | ||
694 | break; | ||
695 | case I965_PGETBL_SIZE_512KB: | ||
696 | size = KB(512); | ||
697 | break; | ||
698 | /* GTT pagetable sizes bigger than 512KB are not possible on G33! */ | ||
699 | case I965_PGETBL_SIZE_1MB: | ||
700 | size = KB(1024); | ||
701 | break; | ||
702 | case I965_PGETBL_SIZE_2MB: | ||
703 | size = KB(2048); | ||
704 | break; | ||
705 | case I965_PGETBL_SIZE_1_5MB: | ||
706 | size = KB(1024 + 512); | ||
707 | break; | ||
708 | default: | ||
709 | dev_info(&intel_private.pcidev->dev, | ||
710 | "unknown page table size, assuming 512KB\n"); | ||
711 | size = KB(512); | ||
712 | } | ||
713 | |||
714 | return size/4; | ||
715 | } | ||
716 | |||
717 | static unsigned int intel_gtt_total_entries(void) | ||
718 | { | ||
719 | int size; | ||
720 | |||
721 | if (IS_G33 || INTEL_GTT_GEN == 4 || INTEL_GTT_GEN == 5) | ||
722 | return i965_gtt_total_entries(); | ||
723 | else if (INTEL_GTT_GEN == 6) { | ||
680 | u16 snb_gmch_ctl; | 724 | u16 snb_gmch_ctl; |
681 | 725 | ||
682 | pci_read_config_word(intel_private.pcidev, SNB_GMCH_CTRL, &snb_gmch_ctl); | 726 | pci_read_config_word(intel_private.pcidev, SNB_GMCH_CTRL, &snb_gmch_ctl); |