aboutsummaryrefslogtreecommitdiffstats
path: root/arch/sh/mm
diff options
context:
space:
mode:
authorLinus Torvalds <torvalds@linux-foundation.org>2008-10-20 12:13:34 -0400
committerLinus Torvalds <torvalds@linux-foundation.org>2008-10-20 12:13:34 -0400
commited402af3c23a4804b3f8899263e8d0f97c62ab49 (patch)
tree3aa971aea57f900a3060cc0545b199ef611f4dcf /arch/sh/mm
parent096e6f673dc02a6394dc9a7d8f8735c6978f5b91 (diff)
parent40e24c403f325715f9c43b9fed2068641201ee0b (diff)
Merge git://git.kernel.org/pub/scm/linux/kernel/git/lethal/sh-2.6
* git://git.kernel.org/pub/scm/linux/kernel/git/lethal/sh-2.6: (112 commits) sh: Move SH-4 CPU headers down one more level. sh: Only build in gpio.o when CONFIG_GENERIC_GPIO is selected. sh: Migrate common board headers to mach-common/. sh: Move the CPU definition headers from asm/ to cpu/. serial: sh-sci: Add support SCIF of SH7723 video: add sh_mobile_lcdc platform flags video: remove unused sh_mobile_lcdc platform data sh: remove consistent alloc cruft sh: add dynamic crash base address support sh: reduce Migo-R smc91x overruns sh: Fix up some merge damage. Fix debugfs_create_file's error checking method for arch/sh/mm/ Fix debugfs_create_dir's error checking method for arch/sh/kernel/ sh: ap325rxa: Add support RTC RX-8564LC in AP325RXA board sh: Use sh7720 GPIO on magicpanelr2 board sh: Add sh7720 pinmux code sh: Use sh7203 GPIO on rsk7203 board sh: Add sh7203 pinmux code sh: Use sh7723 GPIO on AP325RXA board sh: Add sh7723 pinmux code ...
Diffstat (limited to 'arch/sh/mm')
-rw-r--r--arch/sh/mm/Kconfig6
-rw-r--r--arch/sh/mm/cache-debugfs.c6
-rw-r--r--arch/sh/mm/cache-sh4.c2
-rw-r--r--arch/sh/mm/consistent.c12
-rw-r--r--arch/sh/mm/fault_32.c63
-rw-r--r--arch/sh/mm/init.c74
-rw-r--r--arch/sh/mm/pg-nommu.c1
-rw-r--r--arch/sh/mm/pmb.c2
-rw-r--r--arch/sh/mm/tlb-nommu.c1
9 files changed, 124 insertions, 43 deletions
diff --git a/arch/sh/mm/Kconfig b/arch/sh/mm/Kconfig
index 8a03926ea84f..555ec9714b9e 100644
--- a/arch/sh/mm/Kconfig
+++ b/arch/sh/mm/Kconfig
@@ -132,7 +132,11 @@ config ARCH_SELECT_MEMORY_MODEL
132 132
133config ARCH_ENABLE_MEMORY_HOTPLUG 133config ARCH_ENABLE_MEMORY_HOTPLUG
134 def_bool y 134 def_bool y
135 depends on SPARSEMEM 135 depends on SPARSEMEM && MMU
136
137config ARCH_ENABLE_MEMORY_HOTREMOVE
138 def_bool y
139 depends on SPARSEMEM && MMU
136 140
137config ARCH_MEMORY_PROBE 141config ARCH_MEMORY_PROBE
138 def_bool y 142 def_bool y
diff --git a/arch/sh/mm/cache-debugfs.c b/arch/sh/mm/cache-debugfs.c
index 0e189ccd4a77..5ba067b26591 100644
--- a/arch/sh/mm/cache-debugfs.c
+++ b/arch/sh/mm/cache-debugfs.c
@@ -130,12 +130,18 @@ static int __init cache_debugfs_init(void)
130 dcache_dentry = debugfs_create_file("dcache", S_IRUSR, sh_debugfs_root, 130 dcache_dentry = debugfs_create_file("dcache", S_IRUSR, sh_debugfs_root,
131 (unsigned int *)CACHE_TYPE_DCACHE, 131 (unsigned int *)CACHE_TYPE_DCACHE,
132 &cache_debugfs_fops); 132 &cache_debugfs_fops);
133 if (!dcache_dentry)
134 return -ENOMEM;
133 if (IS_ERR(dcache_dentry)) 135 if (IS_ERR(dcache_dentry))
134 return PTR_ERR(dcache_dentry); 136 return PTR_ERR(dcache_dentry);
135 137
136 icache_dentry = debugfs_create_file("icache", S_IRUSR, sh_debugfs_root, 138 icache_dentry = debugfs_create_file("icache", S_IRUSR, sh_debugfs_root,
137 (unsigned int *)CACHE_TYPE_ICACHE, 139 (unsigned int *)CACHE_TYPE_ICACHE,
138 &cache_debugfs_fops); 140 &cache_debugfs_fops);
141 if (!icache_dentry) {
142 debugfs_remove(dcache_dentry);
143 return -ENOMEM;
144 }
139 if (IS_ERR(icache_dentry)) { 145 if (IS_ERR(icache_dentry)) {
140 debugfs_remove(dcache_dentry); 146 debugfs_remove(dcache_dentry);
141 return PTR_ERR(icache_dentry); 147 return PTR_ERR(icache_dentry);
diff --git a/arch/sh/mm/cache-sh4.c b/arch/sh/mm/cache-sh4.c
index 1fdc8d90254a..5cfe08dbb59e 100644
--- a/arch/sh/mm/cache-sh4.c
+++ b/arch/sh/mm/cache-sh4.c
@@ -261,7 +261,7 @@ void flush_dcache_page(struct page *page)
261} 261}
262 262
263/* TODO: Selective icache invalidation through IC address array.. */ 263/* TODO: Selective icache invalidation through IC address array.. */
264static inline void __uses_jump_to_uncached flush_icache_all(void) 264static void __uses_jump_to_uncached flush_icache_all(void)
265{ 265{
266 unsigned long flags, ccr; 266 unsigned long flags, ccr;
267 267
diff --git a/arch/sh/mm/consistent.c b/arch/sh/mm/consistent.c
index 64b8f7f96f9a..9f8ea3ada4db 100644
--- a/arch/sh/mm/consistent.c
+++ b/arch/sh/mm/consistent.c
@@ -16,14 +16,6 @@
16#include <asm/addrspace.h> 16#include <asm/addrspace.h>
17#include <asm/io.h> 17#include <asm/io.h>
18 18
19struct dma_coherent_mem {
20 void *virt_base;
21 u32 device_base;
22 int size;
23 int flags;
24 unsigned long *bitmap;
25};
26
27void *dma_alloc_coherent(struct device *dev, size_t size, 19void *dma_alloc_coherent(struct device *dev, size_t size,
28 dma_addr_t *dma_handle, gfp_t gfp) 20 dma_addr_t *dma_handle, gfp_t gfp)
29{ 21{
@@ -44,7 +36,7 @@ void *dma_alloc_coherent(struct device *dev, size_t size,
44 */ 36 */
45 dma_cache_sync(dev, ret, size, DMA_BIDIRECTIONAL); 37 dma_cache_sync(dev, ret, size, DMA_BIDIRECTIONAL);
46 38
47 ret_nocache = ioremap_nocache(virt_to_phys(ret), size); 39 ret_nocache = (void __force *)ioremap_nocache(virt_to_phys(ret), size);
48 if (!ret_nocache) { 40 if (!ret_nocache) {
49 free_pages((unsigned long)ret, order); 41 free_pages((unsigned long)ret, order);
50 return NULL; 42 return NULL;
@@ -58,12 +50,10 @@ EXPORT_SYMBOL(dma_alloc_coherent);
58void dma_free_coherent(struct device *dev, size_t size, 50void dma_free_coherent(struct device *dev, size_t size,
59 void *vaddr, dma_addr_t dma_handle) 51 void *vaddr, dma_addr_t dma_handle)
60{ 52{
61 struct dma_coherent_mem *mem = dev ? dev->dma_mem : NULL;
62 int order = get_order(size); 53 int order = get_order(size);
63 54
64 if (!dma_release_from_coherent(dev, order, vaddr)) { 55 if (!dma_release_from_coherent(dev, order, vaddr)) {
65 WARN_ON(irqs_disabled()); /* for portability */ 56 WARN_ON(irqs_disabled()); /* for portability */
66 BUG_ON(mem && mem->flags & DMA_MEMORY_EXCLUSIVE);
67 free_pages((unsigned long)phys_to_virt(dma_handle), order); 57 free_pages((unsigned long)phys_to_virt(dma_handle), order);
68 iounmap(vaddr); 58 iounmap(vaddr);
69 } 59 }
diff --git a/arch/sh/mm/fault_32.c b/arch/sh/mm/fault_32.c
index 0c776fdfbdda..898d477e47c1 100644
--- a/arch/sh/mm/fault_32.c
+++ b/arch/sh/mm/fault_32.c
@@ -2,7 +2,7 @@
2 * Page fault handler for SH with an MMU. 2 * Page fault handler for SH with an MMU.
3 * 3 *
4 * Copyright (C) 1999 Niibe Yutaka 4 * Copyright (C) 1999 Niibe Yutaka
5 * Copyright (C) 2003 - 2007 Paul Mundt 5 * Copyright (C) 2003 - 2008 Paul Mundt
6 * 6 *
7 * Based on linux/arch/i386/mm/fault.c: 7 * Based on linux/arch/i386/mm/fault.c:
8 * Copyright (C) 1995 Linus Torvalds 8 * Copyright (C) 1995 Linus Torvalds
@@ -15,6 +15,7 @@
15#include <linux/mm.h> 15#include <linux/mm.h>
16#include <linux/hardirq.h> 16#include <linux/hardirq.h>
17#include <linux/kprobes.h> 17#include <linux/kprobes.h>
18#include <linux/marker.h>
18#include <asm/io_trapped.h> 19#include <asm/io_trapped.h>
19#include <asm/system.h> 20#include <asm/system.h>
20#include <asm/mmu_context.h> 21#include <asm/mmu_context.h>
@@ -37,10 +38,10 @@ asmlinkage void __kprobes do_page_fault(struct pt_regs *regs,
37 int fault; 38 int fault;
38 siginfo_t info; 39 siginfo_t info;
39 40
40#ifdef CONFIG_SH_KGDB 41 /*
41 if (kgdb_nofault && kgdb_bus_err_hook) 42 * We don't bother with any notifier callbacks here, as they are
42 kgdb_bus_err_hook(); 43 * all handled through the __do_page_fault() fast-path.
43#endif 44 */
44 45
45 tsk = current; 46 tsk = current;
46 si_code = SEGV_MAPERR; 47 si_code = SEGV_MAPERR;
@@ -61,7 +62,6 @@ asmlinkage void __kprobes do_page_fault(struct pt_regs *regs,
61 pgd = get_TTB() + offset; 62 pgd = get_TTB() + offset;
62 pgd_k = swapper_pg_dir + offset; 63 pgd_k = swapper_pg_dir + offset;
63 64
64 /* This will never happen with the folded page table. */
65 if (!pgd_present(*pgd)) { 65 if (!pgd_present(*pgd)) {
66 if (!pgd_present(*pgd_k)) 66 if (!pgd_present(*pgd_k))
67 goto bad_area_nosemaphore; 67 goto bad_area_nosemaphore;
@@ -71,9 +71,13 @@ asmlinkage void __kprobes do_page_fault(struct pt_regs *regs,
71 71
72 pud = pud_offset(pgd, address); 72 pud = pud_offset(pgd, address);
73 pud_k = pud_offset(pgd_k, address); 73 pud_k = pud_offset(pgd_k, address);
74 if (pud_present(*pud) || !pud_present(*pud_k)) 74
75 goto bad_area_nosemaphore; 75 if (!pud_present(*pud)) {
76 set_pud(pud, *pud_k); 76 if (!pud_present(*pud_k))
77 goto bad_area_nosemaphore;
78 set_pud(pud, *pud_k);
79 return;
80 }
77 81
78 pmd = pmd_offset(pud, address); 82 pmd = pmd_offset(pud, address);
79 pmd_k = pmd_offset(pud_k, address); 83 pmd_k = pmd_offset(pud_k, address);
@@ -242,6 +246,25 @@ do_sigbus:
242 goto no_context; 246 goto no_context;
243} 247}
244 248
249static inline int notify_page_fault(struct pt_regs *regs, int trap)
250{
251 int ret = 0;
252
253 trace_mark(kernel_arch_trap_entry, "trap_id %d ip #p%ld",
254 trap >> 5, instruction_pointer(regs));
255
256#ifdef CONFIG_KPROBES
257 if (!user_mode(regs)) {
258 preempt_disable();
259 if (kprobe_running() && kprobe_fault_handler(regs, trap))
260 ret = 1;
261 preempt_enable();
262 }
263#endif
264
265 return ret;
266}
267
245#ifdef CONFIG_SH_STORE_QUEUES 268#ifdef CONFIG_SH_STORE_QUEUES
246/* 269/*
247 * This is a special case for the SH-4 store queues, as pages for this 270 * This is a special case for the SH-4 store queues, as pages for this
@@ -265,12 +288,18 @@ asmlinkage int __kprobes __do_page_fault(struct pt_regs *regs,
265 pmd_t *pmd; 288 pmd_t *pmd;
266 pte_t *pte; 289 pte_t *pte;
267 pte_t entry; 290 pte_t entry;
291 int ret = 0;
292
293 if (notify_page_fault(regs, lookup_exception_vector()))
294 goto out;
268 295
269#ifdef CONFIG_SH_KGDB 296#ifdef CONFIG_SH_KGDB
270 if (kgdb_nofault && kgdb_bus_err_hook) 297 if (kgdb_nofault && kgdb_bus_err_hook)
271 kgdb_bus_err_hook(); 298 kgdb_bus_err_hook();
272#endif 299#endif
273 300
301 ret = 1;
302
274 /* 303 /*
275 * We don't take page faults for P1, P2, and parts of P4, these 304 * We don't take page faults for P1, P2, and parts of P4, these
276 * are always mapped, whether it be due to legacy behaviour in 305 * are always mapped, whether it be due to legacy behaviour in
@@ -280,24 +309,23 @@ asmlinkage int __kprobes __do_page_fault(struct pt_regs *regs,
280 pgd = pgd_offset_k(address); 309 pgd = pgd_offset_k(address);
281 } else { 310 } else {
282 if (unlikely(address >= TASK_SIZE || !current->mm)) 311 if (unlikely(address >= TASK_SIZE || !current->mm))
283 return 1; 312 goto out;
284 313
285 pgd = pgd_offset(current->mm, address); 314 pgd = pgd_offset(current->mm, address);
286 } 315 }
287 316
288 pud = pud_offset(pgd, address); 317 pud = pud_offset(pgd, address);
289 if (pud_none_or_clear_bad(pud)) 318 if (pud_none_or_clear_bad(pud))
290 return 1; 319 goto out;
291 pmd = pmd_offset(pud, address); 320 pmd = pmd_offset(pud, address);
292 if (pmd_none_or_clear_bad(pmd)) 321 if (pmd_none_or_clear_bad(pmd))
293 return 1; 322 goto out;
294
295 pte = pte_offset_kernel(pmd, address); 323 pte = pte_offset_kernel(pmd, address);
296 entry = *pte; 324 entry = *pte;
297 if (unlikely(pte_none(entry) || pte_not_present(entry))) 325 if (unlikely(pte_none(entry) || pte_not_present(entry)))
298 return 1; 326 goto out;
299 if (unlikely(writeaccess && !pte_write(entry))) 327 if (unlikely(writeaccess && !pte_write(entry)))
300 return 1; 328 goto out;
301 329
302 if (writeaccess) 330 if (writeaccess)
303 entry = pte_mkdirty(entry); 331 entry = pte_mkdirty(entry);
@@ -314,5 +342,8 @@ asmlinkage int __kprobes __do_page_fault(struct pt_regs *regs,
314 set_pte(pte, entry); 342 set_pte(pte, entry);
315 update_mmu_cache(NULL, address, entry); 343 update_mmu_cache(NULL, address, entry);
316 344
317 return 0; 345 ret = 0;
346out:
347 trace_mark(kernel_arch_trap_exit, MARK_NOARGS);
348 return ret;
318} 349}
diff --git a/arch/sh/mm/init.c b/arch/sh/mm/init.c
index b75a7acd62fb..2a53943924b2 100644
--- a/arch/sh/mm/init.c
+++ b/arch/sh/mm/init.c
@@ -23,7 +23,19 @@
23 23
24DEFINE_PER_CPU(struct mmu_gather, mmu_gathers); 24DEFINE_PER_CPU(struct mmu_gather, mmu_gathers);
25pgd_t swapper_pg_dir[PTRS_PER_PGD]; 25pgd_t swapper_pg_dir[PTRS_PER_PGD];
26unsigned long cached_to_uncached = 0; 26
27#ifdef CONFIG_SUPERH32
28/*
29 * Handle trivial transitions between cached and uncached
30 * segments, making use of the 1:1 mapping relationship in
31 * 512MB lowmem.
32 *
33 * This is the offset of the uncached section from its cached alias.
34 * Default value only valid in 29 bit mode, in 32bit mode will be
35 * overridden in pmb_init.
36 */
37unsigned long cached_to_uncached = P2SEG - P1SEG;
38#endif
27 39
28#ifdef CONFIG_MMU 40#ifdef CONFIG_MMU
29static void set_pte_phys(unsigned long addr, unsigned long phys, pgprot_t prot) 41static void set_pte_phys(unsigned long addr, unsigned long phys, pgprot_t prot)
@@ -58,9 +70,7 @@ static void set_pte_phys(unsigned long addr, unsigned long phys, pgprot_t prot)
58 } 70 }
59 71
60 set_pte(pte, pfn_pte(phys >> PAGE_SHIFT, prot)); 72 set_pte(pte, pfn_pte(phys >> PAGE_SHIFT, prot));
61 73 flush_tlb_one(get_asid(), addr);
62 if (cached_to_uncached)
63 flush_tlb_one(get_asid(), addr);
64} 74}
65 75
66/* 76/*
@@ -113,7 +123,6 @@ void __init page_table_range_init(unsigned long start, unsigned long end,
113 if (!pmd_present(*pmd)) { 123 if (!pmd_present(*pmd)) {
114 pte_t *pte_table; 124 pte_t *pte_table;
115 pte_table = (pte_t *)alloc_bootmem_low_pages(PAGE_SIZE); 125 pte_table = (pte_t *)alloc_bootmem_low_pages(PAGE_SIZE);
116 memset(pte_table, 0, PAGE_SIZE);
117 pmd_populate_kernel(&init_mm, pmd, pte_table); 126 pmd_populate_kernel(&init_mm, pmd, pte_table);
118 } 127 }
119 128
@@ -165,15 +174,6 @@ void __init paging_init(void)
165#ifdef CONFIG_SUPERH32 174#ifdef CONFIG_SUPERH32
166 /* Set up the uncached fixmap */ 175 /* Set up the uncached fixmap */
167 set_fixmap_nocache(FIX_UNCACHED, __pa(&__uncached_start)); 176 set_fixmap_nocache(FIX_UNCACHED, __pa(&__uncached_start));
168
169#ifdef CONFIG_29BIT
170 /*
171 * Handle trivial transitions between cached and uncached
172 * segments, making use of the 1:1 mapping relationship in
173 * 512MB lowmem.
174 */
175 cached_to_uncached = P2SEG - P1SEG;
176#endif
177#endif 177#endif
178} 178}
179 179
@@ -265,6 +265,35 @@ void free_initrd_mem(unsigned long start, unsigned long end)
265} 265}
266#endif 266#endif
267 267
268#if THREAD_SHIFT < PAGE_SHIFT
269static struct kmem_cache *thread_info_cache;
270
271struct thread_info *alloc_thread_info(struct task_struct *tsk)
272{
273 struct thread_info *ti;
274
275 ti = kmem_cache_alloc(thread_info_cache, GFP_KERNEL);
276 if (unlikely(ti == NULL))
277 return NULL;
278#ifdef CONFIG_DEBUG_STACK_USAGE
279 memset(ti, 0, THREAD_SIZE);
280#endif
281 return ti;
282}
283
284void free_thread_info(struct thread_info *ti)
285{
286 kmem_cache_free(thread_info_cache, ti);
287}
288
289void thread_info_cache_init(void)
290{
291 thread_info_cache = kmem_cache_create("thread_info", THREAD_SIZE,
292 THREAD_SIZE, 0, NULL);
293 BUG_ON(thread_info_cache == NULL);
294}
295#endif /* THREAD_SHIFT < PAGE_SHIFT */
296
268#ifdef CONFIG_MEMORY_HOTPLUG 297#ifdef CONFIG_MEMORY_HOTPLUG
269int arch_add_memory(int nid, u64 start, u64 size) 298int arch_add_memory(int nid, u64 start, u64 size)
270{ 299{
@@ -292,4 +321,21 @@ int memory_add_physaddr_to_nid(u64 addr)
292} 321}
293EXPORT_SYMBOL_GPL(memory_add_physaddr_to_nid); 322EXPORT_SYMBOL_GPL(memory_add_physaddr_to_nid);
294#endif 323#endif
324
325#ifdef CONFIG_MEMORY_HOTREMOVE
326int remove_memory(u64 start, u64 size)
327{
328 unsigned long start_pfn = start >> PAGE_SHIFT;
329 unsigned long end_pfn = start_pfn + (size >> PAGE_SHIFT);
330 int ret;
331
332 ret = offline_pages(start_pfn, end_pfn, 120 * HZ);
333 if (unlikely(ret))
334 printk("%s: Failed, offline_pages() == %d\n", __func__, ret);
335
336 return ret;
337}
338EXPORT_SYMBOL_GPL(remove_memory);
295#endif 339#endif
340
341#endif /* CONFIG_MEMORY_HOTPLUG */
diff --git a/arch/sh/mm/pg-nommu.c b/arch/sh/mm/pg-nommu.c
index 677dd57f0877..91ed4e695ff7 100644
--- a/arch/sh/mm/pg-nommu.c
+++ b/arch/sh/mm/pg-nommu.c
@@ -13,6 +13,7 @@
13#include <linux/kernel.h> 13#include <linux/kernel.h>
14#include <linux/string.h> 14#include <linux/string.h>
15#include <asm/page.h> 15#include <asm/page.h>
16#include <asm/uaccess.h>
16 17
17void copy_page(void *to, void *from) 18void copy_page(void *to, void *from)
18{ 19{
diff --git a/arch/sh/mm/pmb.c b/arch/sh/mm/pmb.c
index cef727669c87..84241676265e 100644
--- a/arch/sh/mm/pmb.c
+++ b/arch/sh/mm/pmb.c
@@ -394,6 +394,8 @@ static int __init pmb_debugfs_init(void)
394 394
395 dentry = debugfs_create_file("pmb", S_IFREG | S_IRUGO, 395 dentry = debugfs_create_file("pmb", S_IFREG | S_IRUGO,
396 sh_debugfs_root, NULL, &pmb_debugfs_fops); 396 sh_debugfs_root, NULL, &pmb_debugfs_fops);
397 if (!dentry)
398 return -ENOMEM;
397 if (IS_ERR(dentry)) 399 if (IS_ERR(dentry))
398 return PTR_ERR(dentry); 400 return PTR_ERR(dentry);
399 401
diff --git a/arch/sh/mm/tlb-nommu.c b/arch/sh/mm/tlb-nommu.c
index 15111bc7ddd6..71c742b5aee3 100644
--- a/arch/sh/mm/tlb-nommu.c
+++ b/arch/sh/mm/tlb-nommu.c
@@ -10,6 +10,7 @@
10#include <linux/kernel.h> 10#include <linux/kernel.h>
11#include <linux/mm.h> 11#include <linux/mm.h>
12#include <asm/pgtable.h> 12#include <asm/pgtable.h>
13#include <asm/tlbflush.h>
13 14
14/* 15/*
15 * Nothing too terribly exciting here .. 16 * Nothing too terribly exciting here ..