diff options
author | Daniel Vetter <daniel.vetter@ffwll.ch> | 2010-08-27 10:13:52 -0400 |
---|---|---|
committer | Chris Wilson <chris@chris-wilson.co.uk> | 2010-09-08 16:20:10 -0400 |
commit | d8d9abcd35aeebd633cba2e99c384f4e004ccb84 (patch) | |
tree | f3b4fa8f70112fcacf710fe1654b9ee514aa5e0d /drivers/char | |
parent | 3e921f980fdd5b972efb7f368b2a847a01804184 (diff) |
intel-gtt: sane variable names for intel_gtt_stolen_entries
This somewhat aligns it with the version in drm/i915/i915_dma.c.
Changes:
- s/gtt_entries/stolen_size
- track overhead entries in a seperate var (the effective gtt size
calculation will be extracted later on).
- subtract the overhead at the end instead of in each clause.
Signed-off-by: Daniel Vetter <daniel.vetter@ffwll.ch>
Signed-off-by: Chris Wilson <chris@chris-wilson.co.uk>
Diffstat (limited to 'drivers/char')
-rw-r--r-- | drivers/char/agp/intel-gtt.c | 108 |
1 files changed, 56 insertions, 52 deletions
diff --git a/drivers/char/agp/intel-gtt.c b/drivers/char/agp/intel-gtt.c index a997a202832e..79eb106c6f08 100644 --- a/drivers/char/agp/intel-gtt.c +++ b/drivers/char/agp/intel-gtt.c | |||
@@ -534,11 +534,12 @@ static struct aper_size_info_fixed intel_i830_sizes[] = | |||
534 | static unsigned int intel_gtt_stolen_entries(void) | 534 | static unsigned int intel_gtt_stolen_entries(void) |
535 | { | 535 | { |
536 | u16 gmch_ctrl; | 536 | u16 gmch_ctrl; |
537 | unsigned int gtt_entries = 0; | ||
538 | u8 rdct; | 537 | u8 rdct; |
539 | int local = 0; | 538 | int local = 0; |
540 | static const int ddt[4] = { 0, 16, 32, 64 }; | 539 | static const int ddt[4] = { 0, 16, 32, 64 }; |
541 | int size; /* reserved space (in kb) at the top of stolen memory */ | 540 | int size; /* reserved space (in kb) at the top of stolen memory */ |
541 | unsigned int overhead_entries, stolen_entries; | ||
542 | unsigned int stolen_size = 0; | ||
542 | 543 | ||
543 | pci_read_config_word(intel_private.bridge_dev, | 544 | pci_read_config_word(intel_private.bridge_dev, |
544 | I830_GMCH_CTRL, &gmch_ctrl); | 545 | I830_GMCH_CTRL, &gmch_ctrl); |
@@ -605,26 +606,28 @@ static unsigned int intel_gtt_stolen_entries(void) | |||
605 | size = agp_bridge->driver->fetch_size() + 4; | 606 | size = agp_bridge->driver->fetch_size() + 4; |
606 | } | 607 | } |
607 | 608 | ||
609 | overhead_entries = size/4; | ||
610 | |||
608 | if (intel_private.bridge_dev->device == PCI_DEVICE_ID_INTEL_82830_HB || | 611 | if (intel_private.bridge_dev->device == PCI_DEVICE_ID_INTEL_82830_HB || |
609 | intel_private.bridge_dev->device == PCI_DEVICE_ID_INTEL_82845G_HB) { | 612 | intel_private.bridge_dev->device == PCI_DEVICE_ID_INTEL_82845G_HB) { |
610 | switch (gmch_ctrl & I830_GMCH_GMS_MASK) { | 613 | switch (gmch_ctrl & I830_GMCH_GMS_MASK) { |
611 | case I830_GMCH_GMS_STOLEN_512: | 614 | case I830_GMCH_GMS_STOLEN_512: |
612 | gtt_entries = KB(512) - KB(size); | 615 | stolen_size = KB(512); |
613 | break; | 616 | break; |
614 | case I830_GMCH_GMS_STOLEN_1024: | 617 | case I830_GMCH_GMS_STOLEN_1024: |
615 | gtt_entries = MB(1) - KB(size); | 618 | stolen_size = MB(1); |
616 | break; | 619 | break; |
617 | case I830_GMCH_GMS_STOLEN_8192: | 620 | case I830_GMCH_GMS_STOLEN_8192: |
618 | gtt_entries = MB(8) - KB(size); | 621 | stolen_size = MB(8); |
619 | break; | 622 | break; |
620 | case I830_GMCH_GMS_LOCAL: | 623 | case I830_GMCH_GMS_LOCAL: |
621 | rdct = readb(intel_private.registers+I830_RDRAM_CHANNEL_TYPE); | 624 | rdct = readb(intel_private.registers+I830_RDRAM_CHANNEL_TYPE); |
622 | gtt_entries = (I830_RDRAM_ND(rdct) + 1) * | 625 | stolen_size = (I830_RDRAM_ND(rdct) + 1) * |
623 | MB(ddt[I830_RDRAM_DDT(rdct)]); | 626 | MB(ddt[I830_RDRAM_DDT(rdct)]); |
624 | local = 1; | 627 | local = 1; |
625 | break; | 628 | break; |
626 | default: | 629 | default: |
627 | gtt_entries = 0; | 630 | stolen_size = 0; |
628 | break; | 631 | break; |
629 | } | 632 | } |
630 | } else if (IS_SNB) { | 633 | } else if (IS_SNB) { |
@@ -635,143 +638,144 @@ static unsigned int intel_gtt_stolen_entries(void) | |||
635 | pci_read_config_word(intel_private.pcidev, SNB_GMCH_CTRL, &snb_gmch_ctl); | 638 | pci_read_config_word(intel_private.pcidev, SNB_GMCH_CTRL, &snb_gmch_ctl); |
636 | switch (snb_gmch_ctl & SNB_GMCH_GMS_STOLEN_MASK) { | 639 | switch (snb_gmch_ctl & SNB_GMCH_GMS_STOLEN_MASK) { |
637 | case SNB_GMCH_GMS_STOLEN_32M: | 640 | case SNB_GMCH_GMS_STOLEN_32M: |
638 | gtt_entries = MB(32) - KB(size); | 641 | stolen_size = MB(32); |
639 | break; | 642 | break; |
640 | case SNB_GMCH_GMS_STOLEN_64M: | 643 | case SNB_GMCH_GMS_STOLEN_64M: |
641 | gtt_entries = MB(64) - KB(size); | 644 | stolen_size = MB(64); |
642 | break; | 645 | break; |
643 | case SNB_GMCH_GMS_STOLEN_96M: | 646 | case SNB_GMCH_GMS_STOLEN_96M: |
644 | gtt_entries = MB(96) - KB(size); | 647 | stolen_size = MB(96); |
645 | break; | 648 | break; |
646 | case SNB_GMCH_GMS_STOLEN_128M: | 649 | case SNB_GMCH_GMS_STOLEN_128M: |
647 | gtt_entries = MB(128) - KB(size); | 650 | stolen_size = MB(128); |
648 | break; | 651 | break; |
649 | case SNB_GMCH_GMS_STOLEN_160M: | 652 | case SNB_GMCH_GMS_STOLEN_160M: |
650 | gtt_entries = MB(160) - KB(size); | 653 | stolen_size = MB(160); |
651 | break; | 654 | break; |
652 | case SNB_GMCH_GMS_STOLEN_192M: | 655 | case SNB_GMCH_GMS_STOLEN_192M: |
653 | gtt_entries = MB(192) - KB(size); | 656 | stolen_size = MB(192); |
654 | break; | 657 | break; |
655 | case SNB_GMCH_GMS_STOLEN_224M: | 658 | case SNB_GMCH_GMS_STOLEN_224M: |
656 | gtt_entries = MB(224) - KB(size); | 659 | stolen_size = MB(224); |
657 | break; | 660 | break; |
658 | case SNB_GMCH_GMS_STOLEN_256M: | 661 | case SNB_GMCH_GMS_STOLEN_256M: |
659 | gtt_entries = MB(256) - KB(size); | 662 | stolen_size = MB(256); |
660 | break; | 663 | break; |
661 | case SNB_GMCH_GMS_STOLEN_288M: | 664 | case SNB_GMCH_GMS_STOLEN_288M: |
662 | gtt_entries = MB(288) - KB(size); | 665 | stolen_size = MB(288); |
663 | break; | 666 | break; |
664 | case SNB_GMCH_GMS_STOLEN_320M: | 667 | case SNB_GMCH_GMS_STOLEN_320M: |
665 | gtt_entries = MB(320) - KB(size); | 668 | stolen_size = MB(320); |
666 | break; | 669 | break; |
667 | case SNB_GMCH_GMS_STOLEN_352M: | 670 | case SNB_GMCH_GMS_STOLEN_352M: |
668 | gtt_entries = MB(352) - KB(size); | 671 | stolen_size = MB(352); |
669 | break; | 672 | break; |
670 | case SNB_GMCH_GMS_STOLEN_384M: | 673 | case SNB_GMCH_GMS_STOLEN_384M: |
671 | gtt_entries = MB(384) - KB(size); | 674 | stolen_size = MB(384); |
672 | break; | 675 | break; |
673 | case SNB_GMCH_GMS_STOLEN_416M: | 676 | case SNB_GMCH_GMS_STOLEN_416M: |
674 | gtt_entries = MB(416) - KB(size); | 677 | stolen_size = MB(416); |
675 | break; | 678 | break; |
676 | case SNB_GMCH_GMS_STOLEN_448M: | 679 | case SNB_GMCH_GMS_STOLEN_448M: |
677 | gtt_entries = MB(448) - KB(size); | 680 | stolen_size = MB(448); |
678 | break; | 681 | break; |
679 | case SNB_GMCH_GMS_STOLEN_480M: | 682 | case SNB_GMCH_GMS_STOLEN_480M: |
680 | gtt_entries = MB(480) - KB(size); | 683 | stolen_size = MB(480); |
681 | break; | 684 | break; |
682 | case SNB_GMCH_GMS_STOLEN_512M: | 685 | case SNB_GMCH_GMS_STOLEN_512M: |
683 | gtt_entries = MB(512) - KB(size); | 686 | stolen_size = MB(512); |
684 | break; | 687 | break; |
685 | } | 688 | } |
686 | } else { | 689 | } else { |
687 | switch (gmch_ctrl & I855_GMCH_GMS_MASK) { | 690 | switch (gmch_ctrl & I855_GMCH_GMS_MASK) { |
688 | case I855_GMCH_GMS_STOLEN_1M: | 691 | case I855_GMCH_GMS_STOLEN_1M: |
689 | gtt_entries = MB(1) - KB(size); | 692 | stolen_size = MB(1); |
690 | break; | 693 | break; |
691 | case I855_GMCH_GMS_STOLEN_4M: | 694 | case I855_GMCH_GMS_STOLEN_4M: |
692 | gtt_entries = MB(4) - KB(size); | 695 | stolen_size = MB(4); |
693 | break; | 696 | break; |
694 | case I855_GMCH_GMS_STOLEN_8M: | 697 | case I855_GMCH_GMS_STOLEN_8M: |
695 | gtt_entries = MB(8) - KB(size); | 698 | stolen_size = MB(8); |
696 | break; | 699 | break; |
697 | case I855_GMCH_GMS_STOLEN_16M: | 700 | case I855_GMCH_GMS_STOLEN_16M: |
698 | gtt_entries = MB(16) - KB(size); | 701 | stolen_size = MB(16); |
699 | break; | 702 | break; |
700 | case I855_GMCH_GMS_STOLEN_32M: | 703 | case I855_GMCH_GMS_STOLEN_32M: |
701 | gtt_entries = MB(32) - KB(size); | 704 | stolen_size = MB(32); |
702 | break; | 705 | break; |
703 | case I915_GMCH_GMS_STOLEN_48M: | 706 | case I915_GMCH_GMS_STOLEN_48M: |
704 | /* Check it's really I915G */ | 707 | /* Check it's really I915G */ |
705 | if (IS_I915 || IS_I965 || IS_G33 || IS_G4X) | 708 | if (IS_I915 || IS_I965 || IS_G33 || IS_G4X) |
706 | gtt_entries = MB(48) - KB(size); | 709 | stolen_size = MB(48); |
707 | else | 710 | else |
708 | gtt_entries = 0; | 711 | stolen_size = 0; |
709 | break; | 712 | break; |
710 | case I915_GMCH_GMS_STOLEN_64M: | 713 | case I915_GMCH_GMS_STOLEN_64M: |
711 | /* Check it's really I915G */ | 714 | /* Check it's really I915G */ |
712 | if (IS_I915 || IS_I965 || IS_G33 || IS_G4X) | 715 | if (IS_I915 || IS_I965 || IS_G33 || IS_G4X) |
713 | gtt_entries = MB(64) - KB(size); | 716 | stolen_size = MB(64); |
714 | else | 717 | else |
715 | gtt_entries = 0; | 718 | stolen_size = 0; |
716 | break; | 719 | break; |
717 | case G33_GMCH_GMS_STOLEN_128M: | 720 | case G33_GMCH_GMS_STOLEN_128M: |
718 | if (IS_G33 || IS_I965 || IS_G4X) | 721 | if (IS_G33 || IS_I965 || IS_G4X) |
719 | gtt_entries = MB(128) - KB(size); | 722 | stolen_size = MB(128); |
720 | else | 723 | else |
721 | gtt_entries = 0; | 724 | stolen_size = 0; |
722 | break; | 725 | break; |
723 | case G33_GMCH_GMS_STOLEN_256M: | 726 | case G33_GMCH_GMS_STOLEN_256M: |
724 | if (IS_G33 || IS_I965 || IS_G4X) | 727 | if (IS_G33 || IS_I965 || IS_G4X) |
725 | gtt_entries = MB(256) - KB(size); | 728 | stolen_size = MB(256); |
726 | else | 729 | else |
727 | gtt_entries = 0; | 730 | stolen_size = 0; |
728 | break; | 731 | break; |
729 | case INTEL_GMCH_GMS_STOLEN_96M: | 732 | case INTEL_GMCH_GMS_STOLEN_96M: |
730 | if (IS_I965 || IS_G4X) | 733 | if (IS_I965 || IS_G4X) |
731 | gtt_entries = MB(96) - KB(size); | 734 | stolen_size = MB(96); |
732 | else | 735 | else |
733 | gtt_entries = 0; | 736 | stolen_size = 0; |
734 | break; | 737 | break; |
735 | case INTEL_GMCH_GMS_STOLEN_160M: | 738 | case INTEL_GMCH_GMS_STOLEN_160M: |
736 | if (IS_I965 || IS_G4X) | 739 | if (IS_I965 || IS_G4X) |
737 | gtt_entries = MB(160) - KB(size); | 740 | stolen_size = MB(160); |
738 | else | 741 | else |
739 | gtt_entries = 0; | 742 | stolen_size = 0; |
740 | break; | 743 | break; |
741 | case INTEL_GMCH_GMS_STOLEN_224M: | 744 | case INTEL_GMCH_GMS_STOLEN_224M: |
742 | if (IS_I965 || IS_G4X) | 745 | if (IS_I965 || IS_G4X) |
743 | gtt_entries = MB(224) - KB(size); | 746 | stolen_size = MB(224); |
744 | else | 747 | else |
745 | gtt_entries = 0; | 748 | stolen_size = 0; |
746 | break; | 749 | break; |
747 | case INTEL_GMCH_GMS_STOLEN_352M: | 750 | case INTEL_GMCH_GMS_STOLEN_352M: |
748 | if (IS_I965 || IS_G4X) | 751 | if (IS_I965 || IS_G4X) |
749 | gtt_entries = MB(352) - KB(size); | 752 | stolen_size = MB(352); |
750 | else | 753 | else |
751 | gtt_entries = 0; | 754 | stolen_size = 0; |
752 | break; | 755 | break; |
753 | default: | 756 | default: |
754 | gtt_entries = 0; | 757 | stolen_size = 0; |
755 | break; | 758 | break; |
756 | } | 759 | } |
757 | } | 760 | } |
758 | 761 | ||
759 | if (!local && gtt_entries > intel_max_stolen) { | 762 | if (!local && stolen_size > intel_max_stolen) { |
760 | dev_info(&intel_private.bridge_dev->dev, | 763 | dev_info(&intel_private.bridge_dev->dev, |
761 | "detected %dK stolen memory, trimming to %dK\n", | 764 | "detected %dK stolen memory, trimming to %dK\n", |
762 | gtt_entries / KB(1), intel_max_stolen / KB(1)); | 765 | stolen_size / KB(1), intel_max_stolen / KB(1)); |
763 | gtt_entries = intel_max_stolen / KB(4); | 766 | stolen_size = intel_max_stolen; |
764 | } else if (gtt_entries > 0) { | 767 | } else if (stolen_size > 0) { |
765 | dev_info(&intel_private.bridge_dev->dev, "detected %dK %s memory\n", | 768 | dev_info(&intel_private.bridge_dev->dev, "detected %dK %s memory\n", |
766 | gtt_entries / KB(1), local ? "local" : "stolen"); | 769 | stolen_size / KB(1), local ? "local" : "stolen"); |
767 | gtt_entries /= KB(4); | ||
768 | } else { | 770 | } else { |
769 | dev_info(&intel_private.bridge_dev->dev, | 771 | dev_info(&intel_private.bridge_dev->dev, |
770 | "no pre-allocated video memory detected\n"); | 772 | "no pre-allocated video memory detected\n"); |
771 | gtt_entries = 0; | 773 | stolen_size = 0; |
772 | } | 774 | } |
773 | 775 | ||
774 | return gtt_entries; | 776 | stolen_entries = stolen_size/KB(4) - overhead_entries; |
777 | |||
778 | return stolen_entries; | ||
775 | } | 779 | } |
776 | 780 | ||
777 | static unsigned int intel_gtt_mappable_entries(void) | 781 | static unsigned int intel_gtt_mappable_entries(void) |