From: Dave A. <ai...@us...> - 2003-06-10 02:08:11
|
Update of /cvsroot/linux-vax/kernel-2.4/arch/ppc/mm In directory sc8-pr-cvs1:/tmp/cvs-serv23180/arch/ppc/mm Modified Files: init.c mmu_decl.h pgtable.c ppc_mmu.c Log Message: DA: sync to Marcelo 2.4.18 + remove init_mmap (no longer needed) Index: init.c =================================================================== RCS file: /cvsroot/linux-vax/kernel-2.4/arch/ppc/mm/init.c,v retrieving revision 1.2 retrieving revision 1.3 diff -u -r1.2 -r1.3 --- init.c 10 Apr 2002 15:04:12 -0000 1.2 +++ init.c 10 Jun 2003 01:46:06 -0000 1.3 @@ -1,5 +1,5 @@ /* - * BK Id: SCCS/s.init.c 1.36 09/22/01 14:03:09 paulus + * BK Id: SCCS/s.init.c 1.40 01/25/02 15:15:24 benh */ /* * PowerPC version @@ -49,8 +49,6 @@ #include "mem_pieces.h" #include "mmu_decl.h" -#define MAX_LOW_MEM (0xF0000000UL - KERNELBASE) - mmu_gather_t mmu_gathers[NR_CPUS]; void *end_of_DRAM; @@ -62,6 +60,9 @@ int boot_mapsize; unsigned long totalram_pages; unsigned long totalhigh_pages; +#ifdef CONFIG_ALL_PPC +unsigned long agp_special_page; +#endif extern char _end[]; extern char etext[], _stext[]; @@ -85,7 +86,7 @@ char *klimit = _end; struct mem_pieces phys_avail; -extern char *sysmap; +extern char *sysmap; extern unsigned long sysmap_size; /* @@ -97,8 +98,6 @@ /* max amount of RAM to use */ unsigned long __max_memory; -/* max amount of low RAM to map in */ -unsigned long __max_low_memory = MAX_LOW_MEM; int do_check_pgt_cache(int low, int high) { @@ -313,12 +312,7 @@ if (__max_memory && total_memory > __max_memory) total_memory = __max_memory; total_lowmem = total_memory; - if (total_lowmem > __max_low_memory) { - total_lowmem = __max_low_memory; -#ifndef CONFIG_HIGHMEM - total_memory = total_lowmem; -#endif /* CONFIG_HIGHMEM */ - } + adjust_total_lowmem(); end_of_DRAM = __va(total_lowmem); set_phys_avail(total_lowmem); @@ -352,9 +346,10 @@ ppc_md.progress("MMU:exit", 0x211); #ifdef CONFIG_BOOTX_TEXT - /* Must be done last, or ppc_md.progress will die */ - if (have_of) - map_boot_text(); + /* By default, we are no longer mapped */ + boot_text_mapped = 0; + /* Must be done last, or ppc_md.progress will die. */ + map_boot_text(); #endif } @@ -474,20 +469,22 @@ } #endif /* CONFIG_BLK_DEV_INITRD */ -#if defined(CONFIG_ALL_PPC) +#if defined(CONFIG_ALL_PPC) /* mark the RTAS pages as reserved */ if ( rtas_data ) for (addr = (ulong)__va(rtas_data); addr < PAGE_ALIGN((ulong)__va(rtas_data)+rtas_size) ; addr += PAGE_SIZE) SetPageReserved(virt_to_page(addr)); + if (agp_special_page) + SetPageReserved(virt_to_page(agp_special_page)); #endif /* defined(CONFIG_ALL_PPC) */ if ( sysmap ) for (addr = (unsigned long)sysmap; addr < PAGE_ALIGN((unsigned long)sysmap+sysmap_size) ; addr += PAGE_SIZE) SetPageReserved(virt_to_page(addr)); - + for (addr = PAGE_OFFSET; addr < (unsigned long)end_of_DRAM; addr += PAGE_SIZE) { if (!PageReserved(virt_to_page(addr))) @@ -526,6 +523,10 @@ if (sysmap) printk("System.map loaded at 0x%08x for debugger, size: %ld bytes\n", (unsigned int)sysmap, sysmap_size); +#if defined(CONFIG_ALL_PPC) + if (agp_special_page) + printk(KERN_INFO "AGP special page: 0x%08lx\n", agp_special_page); +#endif /* defined(CONFIG_ALL_PPC) */ mem_init_done = 1; } @@ -572,6 +573,20 @@ /* remove the sysmap pages from the available memory */ if (sysmap) mem_pieces_remove(&phys_avail, __pa(sysmap), sysmap_size, 1); + /* Because of some uninorth weirdness, we need a page of + * memory as high as possible (it must be outside of the + * bus address seen as the AGP aperture). It will be used + * by the r128 DRM driver + * + * FIXME: We need to make sure that page doesn't overlap any of the\ + * above. This could be done by improving mem_pieces_find to be able + * to do a backward search from the end of the list. + */ + if (_machine == _MACH_Pmac && find_devices("uni-north-agp")) { + agp_special_page = (total_memory - PAGE_SIZE); + mem_pieces_remove(&phys_avail, agp_special_page, PAGE_SIZE, 0); + agp_special_page = (unsigned long)__va(agp_special_page); + } #endif /* CONFIG_ALL_PPC */ } Index: mmu_decl.h =================================================================== RCS file: /cvsroot/linux-vax/kernel-2.4/arch/ppc/mm/mmu_decl.h,v retrieving revision 1.1 retrieving revision 1.2 diff -u -r1.1 -r1.2 --- mmu_decl.h 10 Apr 2002 15:04:12 -0000 1.1 +++ mmu_decl.h 10 Jun 2003 01:46:06 -0000 1.2 @@ -24,7 +24,8 @@ */ extern void mapin_ram(void); -extern void bat_mapin_ram(void); +extern void bat_mapin_ram(unsigned long bat2, unsigned long bat3); +extern void adjust_total_lowmem(void); extern int map_page(unsigned long va, unsigned long pa, int flags); extern void setbat(int index, unsigned long virt, unsigned long phys, unsigned int size, int flags); Index: pgtable.c =================================================================== RCS file: /cvsroot/linux-vax/kernel-2.4/arch/ppc/mm/pgtable.c,v retrieving revision 1.1 retrieving revision 1.2 diff -u -r1.1 -r1.2 --- pgtable.c 10 Apr 2002 15:04:12 -0000 1.1 +++ pgtable.c 10 Jun 2003 01:46:06 -0000 1.2 @@ -41,6 +41,11 @@ unsigned long ioremap_bot; int io_bat_index; +/* Maximum 768Mb of lowmem. On SMP, this value will be + * trimmed down to whatever can be covered by BATs though. + */ +#define MAX_LOW_MEM 0x30000000 + #ifndef CONFIG_SMP struct pgtable_cache_struct quicklists; #endif @@ -49,6 +54,10 @@ #define HAVE_BATS 1 #endif +#ifdef HAVE_BATS +static unsigned long __bat2, __bat3; +#endif + extern char etext[], _stext[]; #ifdef HAVE_BATS @@ -186,6 +195,65 @@ return err; } +void __init +adjust_total_lowmem(void) +{ + unsigned long max_low_mem = MAX_LOW_MEM; + +#ifdef HAVE_BATS + unsigned long bat_max = 0x10000000; + unsigned long align; + unsigned long ram = total_lowmem; + int is601 = 0; + + /* 601s have smaller BATs */ + if (PVR_VER(mfspr(PVR)) == 1) { + bat_max = 0x00800000; + is601 = 1; + } + + /* Make sure we don't map a block larger than the + smallest alignment of the physical address. */ + /* alignment of ram_phys_base */ + align = ~(ram_phys_base-1) & ram_phys_base; + /* set BAT block size to MIN(max_size, align) */ + if (align && align < bat_max) + bat_max = align; + + /* Calculate BAT values */ + __bat2 = 1UL << __ilog2(ram); + if (__bat2 > bat_max) + __bat2 = bat_max; + ram -= __bat2; + if (ram) { + __bat3 = 1UL << __ilog2(ram); + if (__bat3 > bat_max) + __bat3 = bat_max; + ram -= __bat3; + } + + printk(KERN_INFO "Memory BAT mapping: BAT2=%ldMb, BAT3=%ldMb, residual: %ldMb\n", + __bat2 >> 20, __bat3 >> 20, ram >> 20); + + /* On SMP, we limit the lowmem to the area mapped with BATs. + * We also assume nobody will do SMP with 601s + */ +#ifdef CONFIG_SMP + if (!is601) + max_low_mem = __bat2 + __bat3; +#endif /* CONFIG_SMP */ + +#endif /* HAVE_BATS */ + if (total_lowmem > max_low_mem) { + total_lowmem = max_low_mem; +#ifndef CONFIG_HIGHMEM + printk(KERN_INFO "Warning, memory limited to %ld Mb, use CONFIG_HIGHMEM" + " to reach %ld Mb\n", max_low_mem >> 20, total_lowmem >> 20); + total_memory = total_lowmem; +#endif /* CONFIG_HIGHMEM */ + } +} + /* * Map in all of physical memory starting at KERNELBASE. */ @@ -195,7 +263,7 @@ #ifdef HAVE_BATS if (!__map_without_bats) - bat_mapin_ram(); + bat_mapin_ram(__bat2, __bat3); #endif /* HAVE_BATS */ v = KERNELBASE; Index: ppc_mmu.c =================================================================== RCS file: /cvsroot/linux-vax/kernel-2.4/arch/ppc/mm/ppc_mmu.c,v retrieving revision 1.2 retrieving revision 1.3 diff -u -r1.2 -r1.3 --- ppc_mmu.c 13 Apr 2002 16:09:15 -0000 1.2 +++ ppc_mmu.c 10 Jun 2003 01:46:06 -0000 1.3 @@ -86,37 +86,16 @@ return 0; } -void __init bat_mapin_ram(void) +void __init bat_mapin_ram(unsigned long bat2, unsigned long bat3) { - unsigned long tot, bl, done; - unsigned long max_size = (256<<20); - unsigned long align; - - /* Set up BAT2 and if necessary BAT3 to cover RAM. */ - - /* Make sure we don't map a block larger than the - smallest alignment of the physical address. */ - /* alignment of ram_phys_base */ - align = ~(ram_phys_base-1) & ram_phys_base; - /* set BAT block size to MIN(max_size, align) */ - if (align && align < max_size) - max_size = align; - + unsigned long tot, done; + tot = total_lowmem; - for (bl = 128<<10; bl < max_size; bl <<= 1) { - if (bl * 2 > tot) - break; - } - - setbat(2, KERNELBASE, ram_phys_base, bl, _PAGE_KERNEL); + setbat(2, KERNELBASE, ram_phys_base, bat2, _PAGE_KERNEL); done = (unsigned long)bat_addrs[2].limit - KERNELBASE + 1; - if ((done < tot) && !bat_addrs[3].limit) { - /* use BAT3 to cover a bit more */ + if ((done < tot) && !bat_addrs[3].limit && bat3) { tot -= done; - for (bl = 128<<10; bl < max_size; bl <<= 1) - if (bl * 2 > tot) - break; - setbat(3, KERNELBASE+done, ram_phys_base+done, bl, + setbat(3, KERNELBASE+done, ram_phys_base+done, bat3, _PAGE_KERNEL); } } |