aboutsummaryrefslogtreecommitdiffstats
path: root/arch
diff options
context:
space:
mode:
authorDavid S. Miller <davem@davemloft.net>2008-02-13 21:20:14 -0500
committerDavid S. Miller <davem@davemloft.net>2008-04-24 02:32:09 -0400
commit25b0c659dfb94f1ddaeda7a8c88ef7043f57f419 (patch)
treeb2ac5d0105d0e5dbcb3df984fe8d91e3dacaf0aa /arch
parent3b2a7e23a9808e349bc5fb32327bacc5e81be79c (diff)
[SPARC64]: Start using LMB information in bootmem_init().
This allows us to kill the incredibly complicated and stupid function trim_pavail(). Signed-off-by: David S. Miller <davem@davemloft.net>
Diffstat (limited to 'arch')
-rw-r--r--arch/sparc64/mm/init.c132
1 files changed, 6 insertions, 126 deletions
diff --git a/arch/sparc64/mm/init.c b/arch/sparc64/mm/init.c
index 6eb76243fa9d..3e6c4ecb8fee 100644
--- a/arch/sparc64/mm/init.c
+++ b/arch/sparc64/mm/init.c
@@ -775,115 +775,6 @@ static unsigned long __init choose_bootmap_pfn(unsigned long start_pfn,
775 prom_halt(); 775 prom_halt();
776} 776}
777 777
778static void __init trim_pavail(unsigned long *cur_size_p,
779 unsigned long *end_of_phys_p)
780{
781 unsigned long to_trim = *cur_size_p - cmdline_memory_size;
782 unsigned long avoid_start, avoid_end;
783 int i;
784
785 to_trim = PAGE_ALIGN(to_trim);
786
787 avoid_start = avoid_end = 0;
788#ifdef CONFIG_BLK_DEV_INITRD
789 avoid_start = initrd_start;
790 avoid_end = PAGE_ALIGN(initrd_end);
791#endif
792
793 /* Trim some pavail[] entries in order to satisfy the
794 * requested "mem=xxx" kernel command line specification.
795 *
796 * We must not trim off the kernel image area nor the
797 * initial ramdisk range (if any). Also, we must not trim
798 * any pavail[] entry down to zero in order to preserve
799 * the invariant that all pavail[] entries have a non-zero
800 * size which is assumed by all of the code in here.
801 */
802 for (i = 0; i < pavail_ents; i++) {
803 unsigned long start, end, kern_end;
804 unsigned long trim_low, trim_high, n;
805
806 kern_end = PAGE_ALIGN(kern_base + kern_size);
807
808 trim_low = start = pavail[i].phys_addr;
809 trim_high = end = start + pavail[i].reg_size;
810
811 if (kern_base >= start &&
812 kern_base < end) {
813 trim_low = kern_base;
814 if (kern_end >= end)
815 continue;
816 }
817 if (kern_end >= start &&
818 kern_end < end) {
819 trim_high = kern_end;
820 }
821 if (avoid_start &&
822 avoid_start >= start &&
823 avoid_start < end) {
824 if (trim_low > avoid_start)
825 trim_low = avoid_start;
826 if (avoid_end >= end)
827 continue;
828 }
829 if (avoid_end &&
830 avoid_end >= start &&
831 avoid_end < end) {
832 if (trim_high < avoid_end)
833 trim_high = avoid_end;
834 }
835
836 if (trim_high <= trim_low)
837 continue;
838
839 if (trim_low == start && trim_high == end) {
840 /* Whole chunk is available for trimming.
841 * Trim all except one page, in order to keep
842 * entry non-empty.
843 */
844 n = (end - start) - PAGE_SIZE;
845 if (n > to_trim)
846 n = to_trim;
847
848 if (n) {
849 pavail[i].phys_addr += n;
850 pavail[i].reg_size -= n;
851 to_trim -= n;
852 }
853 } else {
854 n = (trim_low - start);
855 if (n > to_trim)
856 n = to_trim;
857
858 if (n) {
859 pavail[i].phys_addr += n;
860 pavail[i].reg_size -= n;
861 to_trim -= n;
862 }
863 if (to_trim) {
864 n = end - trim_high;
865 if (n > to_trim)
866 n = to_trim;
867 if (n) {
868 pavail[i].reg_size -= n;
869 to_trim -= n;
870 }
871 }
872 }
873
874 if (!to_trim)
875 break;
876 }
877
878 /* Recalculate. */
879 *cur_size_p = 0UL;
880 for (i = 0; i < pavail_ents; i++) {
881 *end_of_phys_p = pavail[i].phys_addr +
882 pavail[i].reg_size;
883 *cur_size_p += pavail[i].reg_size;
884 }
885}
886
887static void __init find_ramdisk(unsigned long phys_base) 778static void __init find_ramdisk(unsigned long phys_base)
888{ 779{
889#ifdef CONFIG_BLK_DEV_INITRD 780#ifdef CONFIG_BLK_DEV_INITRD
@@ -935,25 +826,11 @@ static unsigned long __init bootmem_init(unsigned long *pages_avail,
935 unsigned long phys_base) 826 unsigned long phys_base)
936{ 827{
937 unsigned long bootmap_size, end_pfn; 828 unsigned long bootmap_size, end_pfn;
938 unsigned long end_of_phys_memory = 0UL; 829 unsigned long bootmap_pfn, size;
939 unsigned long bootmap_pfn, bytes_avail, size;
940 int i; 830 int i;
941 831
942 bytes_avail = 0UL; 832 *pages_avail = lmb_phys_mem_size() >> PAGE_SHIFT;
943 for (i = 0; i < pavail_ents; i++) { 833 end_pfn = lmb_end_of_DRAM() >> PAGE_SHIFT;
944 end_of_phys_memory = pavail[i].phys_addr +
945 pavail[i].reg_size;
946 bytes_avail += pavail[i].reg_size;
947 }
948
949 if (cmdline_memory_size &&
950 bytes_avail > cmdline_memory_size)
951 trim_pavail(&bytes_avail,
952 &end_of_phys_memory);
953
954 *pages_avail = bytes_avail >> PAGE_SHIFT;
955
956 end_pfn = end_of_phys_memory >> PAGE_SHIFT;
957 834
958 /* Initialize the boot-time allocator. */ 835 /* Initialize the boot-time allocator. */
959 max_pfn = max_low_pfn = end_pfn; 836 max_pfn = max_low_pfn = end_pfn;
@@ -1355,6 +1232,9 @@ void __init paging_init(void)
1355 1232
1356 find_ramdisk(phys_base); 1233 find_ramdisk(phys_base);
1357 1234
1235 if (cmdline_memory_size)
1236 lmb_enforce_memory_limit(phys_base + cmdline_memory_size);
1237
1358 lmb_analyze(); 1238 lmb_analyze();
1359 lmb_dump_all(); 1239 lmb_dump_all();
1360 1240