Linux kernel mirror (for testing) git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
kernel os linux

sh: Clean up places that make 29-bit physical assumptions.

Signed-off-by: Stuart Menefy <stuart.menefy@st.com>
Signed-off-by: Paul Mundt <lethal@linux-sh.org>

authored by

Stuart Menefy and committed by
Paul Mundt
d02b08f6 cbaa118e

+71 -36
+4 -1
arch/sh/boot/compressed/misc_32.c
··· 230 230 void decompress_kernel(void) 231 231 { 232 232 output_data = 0; 233 - output_ptr = P2SEGADDR((unsigned long)&_text+PAGE_SIZE); 233 + output_ptr = PHYSADDR((unsigned long)&_text+PAGE_SIZE); 234 + #ifdef CONFIG_29BIT 235 + output_ptr |= P2SEG; 236 + #endif 234 237 free_mem_ptr = (unsigned long)&_end; 235 238 free_mem_end_ptr = free_mem_ptr + HEAP_SIZE; 236 239
+2 -2
arch/sh/kernel/setup.c
··· 82 82 { 83 83 unsigned long size; 84 84 85 - memory_start = (unsigned long)PAGE_OFFSET+__MEMORY_START; 85 + memory_start = (unsigned long)__va(__MEMORY_START); 86 86 size = memparse(p, &p); 87 87 88 88 if (size > __MEMORY_SIZE) { ··· 254 254 data_resource.start = virt_to_phys(_etext); 255 255 data_resource.end = virt_to_phys(_edata)-1; 256 256 257 - memory_start = (unsigned long)PAGE_OFFSET+__MEMORY_START; 257 + memory_start = (unsigned long)__va(__MEMORY_START); 258 258 if (!memory_end) 259 259 memory_end = memory_start + __MEMORY_SIZE; 260 260
+5
arch/sh/kernel/vmlinux_32.lds.S
··· 15 15 ENTRY(_start) 16 16 SECTIONS 17 17 { 18 + #ifdef CONFIG_32BIT 19 + . = CONFIG_PAGE_OFFSET + CONFIG_ZERO_PAGE_OFFSET; 20 + #else 18 21 . = CONFIG_PAGE_OFFSET + CONFIG_MEMORY_START + CONFIG_ZERO_PAGE_OFFSET; 22 + #endif 23 + 19 24 _text = .; /* Text and read-only data */ 20 25 21 26 .empty_zero_page : {
+5 -1
include/asm-sh/addrspace.h
··· 31 31 /* Returns the physical address of a PnSEG (n=1,2) address */ 32 32 #define PHYSADDR(a) (((unsigned long)(a)) & 0x1fffffff) 33 33 34 + #ifdef CONFIG_29BIT 34 35 /* 35 36 * Map an address to a certain privileged segment 36 37 */ ··· 43 42 ((__typeof__(a))(((unsigned long)(a) & 0x1fffffff) | P3SEG)) 44 43 #define P4SEGADDR(a) \ 45 44 ((__typeof__(a))(((unsigned long)(a) & 0x1fffffff) | P4SEG)) 46 - 45 + #endif /* 29BIT */ 47 46 #endif /* P1SEG */ 47 + 48 + /* Check if an address can be reached in 29 bits */ 49 + #define IS_29BIT(a) (((unsigned long)(a)) < 0x20000000) 48 50 49 51 #endif /* __KERNEL__ */ 50 52 #endif /* __ASM_SH_ADDRSPACE_H */
+7 -1
include/asm-sh/cpu-sh4/mmu_context.h
··· 30 30 #define MMUCR_ME (0) 31 31 #endif 32 32 33 + #if defined(CONFIG_32BIT) && defined(CONFIG_CPU_SUBTYPE_ST40) 34 + #define MMUCR_SE (1 << 4) 35 + #else 36 + #define MMUCR_SE (0) 37 + #endif 38 + 33 39 #ifdef CONFIG_SH_STORE_QUEUES 34 40 #define MMUCR_SQMD (1 << 9) 35 41 #else ··· 43 37 #endif 44 38 45 39 #define MMU_NTLB_ENTRIES 64 46 - #define MMU_CONTROL_INIT (0x05|MMUCR_SQMD|MMUCR_ME) 40 + #define MMU_CONTROL_INIT (0x05|MMUCR_SQMD|MMUCR_ME|MMUCR_SE) 47 41 48 42 #define MMU_ITLB_DATA_ARRAY 0xF3000000 49 43 #define MMU_UTLB_DATA_ARRAY 0xF7000000
+1 -15
include/asm-sh/io.h
··· 273 273 #if !defined(CONFIG_MMU) 274 274 #define virt_to_phys(address) ((unsigned long)(address)) 275 275 #define phys_to_virt(address) ((void *)(address)) 276 - #elif defined(CONFIG_SUPERH64) 276 + #else 277 277 #define virt_to_phys(address) (__pa(address)) 278 278 #define phys_to_virt(address) (__va(address)) 279 - #else 280 - /* 281 - * Change virtual addresses to physical addresses and vv. 282 - * These are trivial on the 1:1 Linux/SuperH mapping 283 - */ 284 - static inline unsigned long virt_to_phys(volatile void *address) 285 - { 286 - return PHYSADDR(address); 287 - } 288 - 289 - static inline void *phys_to_virt(unsigned long address) 290 - { 291 - return (void *)P1SEGADDR(address); 292 - } 293 279 #endif 294 280 295 281 /*
+37 -13
include/asm-sh/page.h
··· 5 5 * Copyright (C) 1999 Niibe Yutaka 6 6 */ 7 7 8 + #include <linux/const.h> 9 + 8 10 #ifdef __KERNEL__ 9 11 10 12 /* PAGE_SHIFT determines the page size */ ··· 20 18 # error "Bogus kernel page size?" 21 19 #endif 22 20 23 - #ifdef __ASSEMBLY__ 24 - #define PAGE_SIZE (1 << PAGE_SHIFT) 25 - #else 26 - #define PAGE_SIZE (1UL << PAGE_SHIFT) 27 - #endif 28 - 21 + #define PAGE_SIZE (_AC(1, UL) << PAGE_SHIFT) 29 22 #define PAGE_MASK (~(PAGE_SIZE-1)) 30 23 #define PTE_MASK PAGE_MASK 24 + 25 + /* to align the pointer to the (next) page boundary */ 26 + #define PAGE_ALIGN(addr) (((addr)+PAGE_SIZE-1)&PAGE_MASK) 31 27 32 28 #if defined(CONFIG_HUGETLB_PAGE_SIZE_64K) 33 29 #define HPAGE_SHIFT 16 ··· 104 104 105 105 #endif /* !__ASSEMBLY__ */ 106 106 107 - /* to align the pointer to the (next) page boundary */ 108 - #define PAGE_ALIGN(addr) (((addr)+PAGE_SIZE-1)&PAGE_MASK) 109 - 107 + /* 108 + * __MEMORY_START and SIZE are the physical addresses and size of RAM. 109 + */ 110 110 #define __MEMORY_START CONFIG_MEMORY_START 111 111 #define __MEMORY_SIZE CONFIG_MEMORY_SIZE 112 112 113 + /* 114 + * PAGE_OFFSET is the virtual address of the start of kernel address 115 + * space. 116 + */ 113 117 #define PAGE_OFFSET CONFIG_PAGE_OFFSET 114 - #define __pa(x) ((unsigned long)(x)-PAGE_OFFSET) 115 - #define __va(x) ((void *)((unsigned long)(x)+PAGE_OFFSET)) 116 - #define pfn_to_kaddr(pfn) __va((pfn) << PAGE_SHIFT) 117 118 119 + /* 120 + * Virtual to physical RAM address translation. 121 + * 122 + * In 29 bit mode, the physical offset of RAM from address 0 is visible in 123 + * the kernel virtual address space, and thus we don't have to take 124 + * this into account when translating. However in 32 bit mode this offset 125 + * is not visible (it is part of the PMB mapping) and so needs to be 126 + * added or subtracted as required. 127 + */ 128 + #ifdef CONFIG_32BIT 129 + #define __pa(x) ((unsigned long)(x)-PAGE_OFFSET+__MEMORY_START) 130 + #define __va(x) ((void *)((unsigned long)(x)+PAGE_OFFSET-__MEMORY_START)) 131 + #else 132 + #define __pa(x) ((unsigned long)(x)-PAGE_OFFSET) 133 + #define __va(x) ((void *)((unsigned long)(x)+PAGE_OFFSET)) 134 + #endif 135 + 136 + #define pfn_to_kaddr(pfn) __va((pfn) << PAGE_SHIFT) 118 137 #define page_to_phys(page) (page_to_pfn(page) << PAGE_SHIFT) 119 138 120 - /* PFN start number, because of __MEMORY_START */ 139 + /* 140 + * PFN = physical frame number (ie PFN 0 == physical address 0) 141 + * PFN_START is the PFN of the first page of RAM. By defining this we 142 + * don't have struct page entries for the portion of address space 143 + * between physical address 0 and the start of RAM. 144 + */ 121 145 #define PFN_START (__MEMORY_START >> PAGE_SHIFT) 122 146 #define ARCH_PFN_OFFSET (PFN_START) 123 147 #define virt_to_page(kaddr) pfn_to_page(__pa(kaddr) >> PAGE_SHIFT)
+7 -1
include/asm-sh/pgtable.h
··· 69 69 #define USER_PTRS_PER_PGD (TASK_SIZE/PGDIR_SIZE) 70 70 #define FIRST_USER_ADDRESS 0 71 71 72 - #define PTE_PHYS_MASK (0x20000000 - PAGE_SIZE) 72 + #ifdef CONFIG_32BIT 73 + #define PHYS_ADDR_MASK 0xffffffff 74 + #else 75 + #define PHYS_ADDR_MASK 0x1fffffff 76 + #endif 77 + 78 + #define PTE_PHYS_MASK (PHYS_ADDR_MASK & PAGE_MASK) 73 79 74 80 #ifdef CONFIG_SUPERH32 75 81 #define VMALLOC_START (P3SEG)
+1 -1
include/asm-sh/pgtable_32.h
··· 98 98 #define _PAGE_CLEAR_FLAGS (_PAGE_PROTNONE | _PAGE_ACCESSED | _PAGE_FILE) 99 99 #endif 100 100 101 - #define _PAGE_FLAGS_HARDWARE_MASK (0x1fffffff & ~(_PAGE_CLEAR_FLAGS)) 101 + #define _PAGE_FLAGS_HARDWARE_MASK (PHYS_ADDR_MASK & ~(_PAGE_CLEAR_FLAGS)) 102 102 103 103 /* Hardware flags, page size encoding */ 104 104 #if defined(CONFIG_X2TLB)
+2 -1
include/asm-sh/scatterlist.h
··· 1 1 #ifndef __ASM_SH_SCATTERLIST_H 2 2 #define __ASM_SH_SCATTERLIST_H 3 3 4 + #include <asm/pgtable.h> 4 5 #include <asm/types.h> 5 6 6 7 struct scatterlist { ··· 14 13 unsigned int length; 15 14 }; 16 15 17 - #define ISA_DMA_THRESHOLD (0x1fffffff) 16 + #define ISA_DMA_THRESHOLD PHYS_ADDR_MASK 18 17 19 18 /* These macros should be used after a pci_map_sg call has been done 20 19 * to get bus addresses of each of the SG entries and their lengths.