From: YAEGASHI T. <t...@ke...> - 2002-06-08 16:24:46
|
Hi, The CVS kernel seems still broken and cannot build. Here's the patch of some bug fix and updates, especially for hp690 and Dreamcast. I hope this helps someone. This patch includes updates of memory management code along with CONFIG_DISCONTIGMEM support for hp690. With this patch hp690 seems to work fine in discontiguous 32MB RAM configuration. For Dreamcast, the kernel boots up normally, but after entering multi-user mode it occasionally complains kernel BUG in mm/slab.c. I'm not certain whether my changes cause this bug or not. Index: ChangeLog =================================================================== RCS file: /cvsroot/linuxsh/linux/ChangeLog,v retrieving revision 1.73 diff -u -r1.73 ChangeLog --- ChangeLog 28 May 2002 02:16:43 -0000 1.73 +++ ChangeLog 8 Jun 2002 15:09:48 -0000 @@ -1,3 +1,40 @@ +2002-06-08 YAEGASHI Takeshi <t...@ke...> + + General updates. + * arch/sh/boot/compressed/Makefile: Supply jiffies_64 symbol value + which is referred in vmlinux.lds. + * arch/sh/kernel/pcibios.c (pcibios_align_resource): Remove old + function prototype. + * arch/sh/kernel/sh_ksyms.c: Include <linux/tty.h> to export + screen_info symbol. + * include/asm-sh/processsor.h: Include <linux/cache.h> which need to + be included from drivers/pci/pci.c. + + Dreamcast updates. + * arch/sh/kernel/pci-dc.c: Place subsys_initcall(pcibios_init). + * drivers/input/joystick/maplecontrol.c: Include <linux/slab.h> + instead of obsoleted <linux/malloc.h>. + + MM updates and CONFIG_DISCONTIGMEM support. + * include/asm-sh/pgalloc.h (pmd_free_tlb): Bug fix. + (ptep_get_and_clear): Bug fix. + * include/asm-sh/page.h (__PFN_START): New macro. + (page_to_pfn, pfn_to_page, pfn_valid, virt_to_page, + virt_addr_valid): Define macros according to CONFIG_DISCONTIGMEM. + (VALID_PAGE): Removed. + (page_to_phys, phys_to_page): New definitions. + * include/asm-sh/mmzone.h (PHYSADDR_TO_NID): New definition. + (PFN_TO_NID, ADDR_TO_MAPBASE, PFN_TO_MAPBASE, LOCAL_MAP_NR): New + macros. + (VALID_PAGE, phys_to_page, page_to_phys): Removed. + * include/asm-sh/pgtable.h (pte_pfn, pfn_pte): New macros. + * arch/sh/mm/init.c (discontig_page_data): Declare with each bdata + member initilized. + (mem_init): Adjust max_mapnr, num_phys_pages, high_memory when + CONFIG_DISCONTIGMEM=y. + * arch/sh/kernel/setup.c (setup_arch): Don't reinitialize already + initialized NODE_DATA's. + 2002-05-24 Paul Mundt <le...@ch...> * arch/sh/Config.help, arch/sh/config.in, arch/sh/kernel/Makefile: Index: arch/sh/boot/compressed/Makefile =================================================================== RCS file: /cvsroot/linuxsh/linux/arch/sh/boot/compressed/Makefile,v retrieving revision 1.1.1.1 diff -u -r1.1.1.1 Makefile --- arch/sh/boot/compressed/Makefile 15 Oct 2001 20:44:47 -0000 1.1.1.1 +++ arch/sh/boot/compressed/Makefile 8 Jun 2002 15:09:48 -0000 @@ -13,7 +13,7 @@ OBJECTS += ../../kernel/sh_bios.o endif -ZLDFLAGS = -e startup -T $(TOPDIR)/arch/sh/vmlinux.lds +ZLDFLAGS = -e startup -T $(TOPDIR)/arch/sh/vmlinux.lds --defsym jiffies_64=0 # # ZIMAGE_OFFSET is the load offset of the compression loader Index: arch/sh/kernel/pci-dc.c =================================================================== RCS file: /cvsroot/linuxsh/linux/arch/sh/kernel/pci-dc.c,v retrieving revision 1.1.1.1 diff -u -r1.1.1.1 pci-dc.c --- arch/sh/kernel/pci-dc.c 15 Oct 2001 20:44:49 -0000 1.1.1.1 +++ arch/sh/kernel/pci-dc.c 8 Jun 2002 15:09:49 -0000 @@ -164,13 +164,14 @@ } -void __init pcibios_init(void) +static void __init pcibios_init(void) { pci_root_bus = pci_scan_bus(0, &pci_config_ops, NULL); /* pci_assign_unassigned_resources(); */ pci_fixup_irqs(no_swizzle, map_dc_irq); } +subsys_initcall(pcibios_init); /* Haven't done anything here as yet */ char * __init pcibios_setup(char *str) Index: arch/sh/kernel/pcibios.c =================================================================== RCS file: /cvsroot/linuxsh/linux/arch/sh/kernel/pcibios.c,v retrieving revision 1.2 diff -u -r1.2 pcibios.c --- arch/sh/kernel/pcibios.c 23 May 2002 01:31:04 -0000 1.2 +++ arch/sh/kernel/pcibios.c 8 Jun 2002 15:09:49 -0000 @@ -60,7 +60,6 @@ * addresses to be allocated in the 0x000-0x0ff region * modulo 0x400. */ -void pcibios_align_resource(void *data, struct resource *res, unsigned long size) void pcibios_align_resource(void *data, struct resource *res, unsigned long size, unsigned long align) { Index: arch/sh/kernel/setup.c =================================================================== RCS file: /cvsroot/linuxsh/linux/arch/sh/kernel/setup.c,v retrieving revision 1.6 diff -u -r1.6 setup.c --- arch/sh/kernel/setup.c 24 May 2002 14:40:45 -0000 1.6 +++ arch/sh/kernel/setup.c 8 Jun 2002 15:09:49 -0000 @@ -352,9 +352,6 @@ #define PFN_PHYS(x) ((x) << PAGE_SHIFT) #ifdef CONFIG_DISCONTIGMEM - NODE_DATA(0)->bdata = &discontig_node_bdata[0]; - NODE_DATA(1)->bdata = &discontig_node_bdata[1]; - bootmap_size = init_bootmem_node(NODE_DATA(1), PFN_UP(__MEMORY_START_2ND), PFN_UP(__MEMORY_START_2ND), Index: arch/sh/kernel/sh_ksyms.c =================================================================== RCS file: /cvsroot/linuxsh/linux/arch/sh/kernel/sh_ksyms.c,v retrieving revision 1.4 diff -u -r1.4 sh_ksyms.c --- arch/sh/kernel/sh_ksyms.c 12 Apr 2002 04:26:28 -0000 1.4 +++ arch/sh/kernel/sh_ksyms.c 8 Jun 2002 15:09:49 -0000 @@ -11,6 +11,7 @@ #include <linux/vmalloc.h> #include <linux/pci.h> #include <linux/irq.h> +#include <linux/tty.h> #include <asm/semaphore.h> #include <asm/processor.h> Index: arch/sh/mm/init.c =================================================================== RCS file: /cvsroot/linuxsh/linux/arch/sh/mm/init.c,v retrieving revision 1.4 diff -u -r1.4 init.c --- arch/sh/mm/init.c 22 May 2002 07:37:02 -0000 1.4 +++ arch/sh/mm/init.c 8 Jun 2002 15:09:49 -0000 @@ -45,8 +45,11 @@ unsigned long mmu_context_cache; #ifdef CONFIG_DISCONTIGMEM -pg_data_t discontig_page_data[NR_NODES]; -bootmem_data_t discontig_node_bdata[NR_NODES]; +static bootmem_data_t discontig_node_bdata[NR_NODES]; +pg_data_t discontig_page_data[NR_NODES] = { + { bdata: &discontig_node_bdata[0] }, + { bdata: &discontig_node_bdata[1] }, +}; #endif void show_mem(void) @@ -142,6 +145,11 @@ max_mapnr = num_physpages = MAX_LOW_PFN - START_PFN; high_memory = (void *)__va(MAX_LOW_PFN * PAGE_SIZE); +#ifdef CONFIG_DISCONTIGMEM + max_mapnr += __MEMORY_SIZE_2ND >> PAGE_SHIFT; + num_physpages += __MEMORY_SIZE_2ND >> PAGE_SHIFT; + high_memory = (void *)__va(__MEMORY_START_2ND + __MEMORY_SIZE_2ND); +#endif /* clear the zero-page */ memset(empty_zero_page, 0, PAGE_SIZE); Index: drivers/input/joystick/maplecontrol.c =================================================================== RCS file: /cvsroot/linuxsh/linux/drivers/input/joystick/maplecontrol.c,v retrieving revision 1.1 diff -u -r1.1 maplecontrol.c --- drivers/input/joystick/maplecontrol.c 19 Mar 2002 23:50:07 -0000 1.1 +++ drivers/input/joystick/maplecontrol.c 8 Jun 2002 15:09:49 -0000 @@ -5,7 +5,7 @@ */ #include <linux/kernel.h> -#include <linux/malloc.h> +#include <linux/slab.h> #include <linux/input.h> #include <linux/module.h> #include <linux/init.h> Index: include/asm-sh/mmzone.h =================================================================== RCS file: /cvsroot/linuxsh/linux/include/asm-sh/mmzone.h,v retrieving revision 1.1.1.1 diff -u -r1.1.1.1 mmzone.h --- include/asm-sh/mmzone.h 15 Oct 2001 20:45:10 -0000 1.1.1.1 +++ include/asm-sh/mmzone.h 8 Jun 2002 15:09:49 -0000 @@ -11,11 +11,19 @@ #include <linux/config.h> /* Currently, just for HP690 */ -#define PHYSADDR_TO_NID(phys) ((((phys) - __MEMORY_START) >= 0x01000000)?1:0) +static inline int __physaddr_to_nid(unsigned long phys) +{ + if (phys >= __MEMORY_START && phys < __MEMORY_START_2ND) + return 0; + if (phys >= __MEMORY_START_2ND && + phys < __MEMORY_START_2ND + __MEMORY_SIZE_2ND) + return 1; + return 2; +} +#define PHYSADDR_TO_NID(phys) __physaddr_to_nid(phys) #define NR_NODES 2 extern pg_data_t discontig_page_data[NR_NODES]; -extern bootmem_data_t discontig_node_bdata[NR_NODES]; #ifdef CONFIG_DISCONTIGMEM /* @@ -37,25 +45,30 @@ */ #define NODE_MEM_MAP(nid) (NODE_DATA(nid)->node_mem_map) -#define phys_to_page(phys) \ -({ unsigned int node = PHYSADDR_TO_NID(phys); \ - NODE_MEM_MAP(node) \ - + (((phys) - NODE_DATA(node)->node_start_paddr) >> PAGE_SHIFT); }) +/* + * Given a page frame number, convert it to a node id. + */ +#define PFN_TO_NID(pfn) PHYSADDR_TO_NID((pfn) << PAGE_SHIFT) -static inline int is_valid_page(struct page *page) -{ - unsigned int i; +/* + * Given a kaddr, ADDR_TO_MAPBASE finds the owning node of the memory + * and return the mem_map of that node. + */ +#define ADDR_TO_MAPBASE(kaddr) NODE_MEM_MAP(KVADDR_TO_NID(kaddr)) - for (i = 0; i < NR_NODES; i++) { - if (page >= NODE_MEM_MAP(i) && - page < NODE_MEM_MAP(i) + NODE_DATA(i)->node_size) - return 1; - } - return 0; -} +/* + * Given a page frame number, find the owning node of the memory + * and return the mem_map of that node. + */ +#define PFN_TO_MAPBASE(pfn) NODE_MEM_MAP(PFN_TO_NID(pfn)) -#define VALID_PAGE(page) is_valid_page(page) -#define page_to_phys(page) PHYSADDR(page_address(page)) +/* + * Given a kaddr, LOCAL_MEM_MAP finds the owning node of the memory + * and returns the index corresponding to the appropriate page in the + * node's mem_map. + */ +#define LOCAL_MAP_NR(addr) \ + (((unsigned long)(addr) & 0x00ffffff) >> PAGE_SHIFT) #endif /* CONFIG_DISCONTIGMEM */ #endif Index: include/asm-sh/page.h =================================================================== RCS file: /cvsroot/linuxsh/linux/include/asm-sh/page.h,v retrieving revision 1.2 diff -u -r1.2 page.h --- include/asm-sh/page.h 22 Mar 2002 03:58:40 -0000 1.2 +++ include/asm-sh/page.h 8 Jun 2002 15:09:49 -0000 @@ -70,6 +70,7 @@ #define __MEMORY_START CONFIG_MEMORY_START #define __MEMORY_SIZE CONFIG_MEMORY_SIZE +#define __PFN_START (__MEMORY_START >> PAGE_SHIFT) #ifdef CONFIG_DISCONTIGMEM /* Just for HP690, for now.. */ #define __MEMORY_START_2ND (__MEMORY_START+0x02000000) @@ -80,16 +81,60 @@ #define __pa(x) ((unsigned long)(x)-PAGE_OFFSET) #define __va(x) ((void *)((unsigned long)(x)+PAGE_OFFSET)) -#ifndef CONFIG_DISCONTIGMEM -#define phys_to_page(phys) (mem_map + (((phys)-__MEMORY_START) >> PAGE_SHIFT)) -#define VALID_PAGE(page) ((page - mem_map) < max_mapnr) -#define page_to_phys(page) (((page - mem_map) << PAGE_SHIFT) + __MEMORY_START) -#endif - #define VM_DATA_DEFAULT_FLAGS (VM_READ | VM_WRITE | VM_EXEC | \ VM_MAYREAD | VM_MAYWRITE | VM_MAYEXEC) -#define virt_to_page(kaddr) phys_to_page(__pa(kaddr)) +/* + * Conversion between a struct page and a physical address. + * + * Note: when converting an unknown physical address to a + * struct page, the resulting pointer must be validated + * using VALID_PAGE(). It must return an invalid struct page + * for any physical address not corresponding to a system + * RAM address. + * + * page_to_pfn(page) convert a struct page * to a PFN number + * pfn_to_page(pfn) convert a _valid_ PFN number to struct page * + * pfn_valid(pfn) indicates whether a PFN number is valid + * + * virt_to_page(k) convert a _valid_ virtual address to struct page * + * virt_addr_valid(k) indicates whether a virtual address is valid + */ +#ifndef CONFIG_DISCONTIGMEM + +#define page_to_pfn(page) (((page) - mem_map) + __PFN_START) +#define pfn_to_page(pfn) ((mem_map + (pfn)) - __PFN_START) +#define pfn_valid(pfn) ((pfn) >= __PFN_START && (pfn) < __PFN_START + max_mapnr) + +#define virt_to_page(kaddr) pfn_to_page(__pa(kaddr) >> PAGE_SHIFT) +#define virt_addr_valid(kaddr) pfn_valid(__pa(kaddr) >> PAGE_SHIFT) + +#else +/* + * This is more complex. We have a set of mem_map arrays spread + * around in memory. + */ +#define page_to_pfn(page) \ + (((page) - page_zone(page)->zone_mem_map) \ + + (page_zone(page)->zone_start_paddr >> PAGE_SHIFT)) + +#define pfn_to_page(pfn) \ + (PFN_TO_MAPBASE(pfn) + LOCAL_MAP_NR((pfn) << PAGE_SHIFT)) + +#define pfn_valid(pfn) (PFN_TO_NID(pfn) < NR_NODES) + +#define virt_to_page(kaddr) \ + (ADDR_TO_MAPBASE(kaddr) + LOCAL_MAP_NR(kaddr)) + +#define virt_addr_valid(kaddr) (KVADDR_TO_NID(kaddr) < NR_NODES) + +#endif + +/* + * For BIO. "will die". Kill me when bio_to_phys() and bvec_to_phys() die. + */ +#define page_to_phys(page) (page_to_pfn(page) << PAGE_SHIFT) +#define phys_to_page(phys) pfn_to_page((phys) >> PAGE_SHIFT) #ifndef __ASSEMBLY__ Index: include/asm-sh/pgalloc.h =================================================================== RCS file: /cvsroot/linuxsh/linux/include/asm-sh/pgalloc.h,v retrieving revision 1.9 diff -u -r1.9 pgalloc.h --- include/asm-sh/pgalloc.h 23 May 2002 01:51:13 -0000 1.9 +++ include/asm-sh/pgalloc.h 8 Jun 2002 15:09:49 -0000 @@ -47,7 +47,7 @@ #define pmd_alloc_one(mm, addr) ({ BUG(); ((pmd_t *)2); }) #define pmd_free(x) do { } while (0) -#define pmd_free_tlb(x) do { } while (0) +#define pmd_free_tlb(tlb, x) do { } while (0) #define pgd_populate(mm, pmd, pte) BUG() #if defined(__SH4__) @@ -65,7 +65,7 @@ struct page *page; unsigned long pfn = pte_pfn(pte); if (pfn_valid(pfn)) { - page = pfn_to_page(page); + page = pfn_to_page(pfn); if (!page->mapping || list_empty(&page->mapping->i_mmap_shared)) __clear_bit(PG_mapped, &page->flags); Index: include/asm-sh/pgtable.h =================================================================== RCS file: /cvsroot/linuxsh/linux/include/asm-sh/pgtable.h,v retrieving revision 1.9 diff -u -r1.9 pgtable.h --- include/asm-sh/pgtable.h 22 May 2002 07:37:02 -0000 1.9 +++ include/asm-sh/pgtable.h 8 Jun 2002 15:09:49 -0000 @@ -132,6 +132,9 @@ #define __S110 PAGE_SHARED #define __S111 PAGE_SHARED +#define pte_pfn(pte) (pte_val(pte) >> PAGE_SHIFT) +#define pfn_pte(pfn,prot) (__pte(((pfn) << PAGE_SHIFT) | pgprot_val(prot))) + #define pte_none(x) (!pte_val(x)) #define pte_present(x) (pte_val(x) & (_PAGE_PRESENT | _PAGE_PROTNONE)) #define pte_clear(xp) do { set_pte(xp, __pte(0)); } while (0) Index: include/asm-sh/processor.h =================================================================== RCS file: /cvsroot/linuxsh/linux/include/asm-sh/processor.h,v retrieving revision 1.4 diff -u -r1.4 processor.h --- include/asm-sh/processor.h 19 Mar 2002 23:48:06 -0000 1.4 +++ include/asm-sh/processor.h 8 Jun 2002 15:09:49 -0000 @@ -9,6 +9,7 @@ #include <asm/page.h> #include <asm/types.h> +#include <linux/cache.h> #include <linux/threads.h> /* -- YAEGASHI Takeshi <t...@ke...> <ta...@ya...> <yae...@do...> |