diff options
Diffstat (limited to 'arch/sh/mm')
| -rw-r--r-- | arch/sh/mm/Makefile_32 | 1 | ||||
| -rw-r--r-- | arch/sh/mm/Makefile_64 | 1 | ||||
| -rw-r--r-- | arch/sh/mm/asids-debugfs.c | 79 | ||||
| -rw-r--r-- | arch/sh/mm/consistent.c | 7 | ||||
| -rw-r--r-- | arch/sh/mm/fault_32.c | 17 | ||||
| -rw-r--r-- | arch/sh/mm/ioremap_32.c | 3 | ||||
| -rw-r--r-- | arch/sh/mm/mmap.c | 94 |
7 files changed, 183 insertions, 19 deletions
diff --git a/arch/sh/mm/Makefile_32 b/arch/sh/mm/Makefile_32 index f066e76da204..cb2f3f299591 100644 --- a/arch/sh/mm/Makefile_32 +++ b/arch/sh/mm/Makefile_32 | |||
| @@ -18,6 +18,7 @@ mmu-y := tlb-nommu.o pg-nommu.o | |||
| 18 | mmu-$(CONFIG_MMU) := fault_32.o tlbflush_32.o ioremap_32.o | 18 | mmu-$(CONFIG_MMU) := fault_32.o tlbflush_32.o ioremap_32.o |
| 19 | 19 | ||
| 20 | obj-y += $(mmu-y) | 20 | obj-y += $(mmu-y) |
| 21 | obj-$(CONFIG_DEBUG_FS) += asids-debugfs.o | ||
| 21 | 22 | ||
| 22 | ifdef CONFIG_DEBUG_FS | 23 | ifdef CONFIG_DEBUG_FS |
| 23 | obj-$(CONFIG_CPU_SH4) += cache-debugfs.o | 24 | obj-$(CONFIG_CPU_SH4) += cache-debugfs.o |
diff --git a/arch/sh/mm/Makefile_64 b/arch/sh/mm/Makefile_64 index 9481d0f54efd..2863ffb7006d 100644 --- a/arch/sh/mm/Makefile_64 +++ b/arch/sh/mm/Makefile_64 | |||
| @@ -13,6 +13,7 @@ obj-y += cache-sh5.o | |||
| 13 | endif | 13 | endif |
| 14 | 14 | ||
| 15 | obj-y += $(mmu-y) | 15 | obj-y += $(mmu-y) |
| 16 | obj-$(CONFIG_DEBUG_FS) += asids-debugfs.o | ||
| 16 | 17 | ||
| 17 | obj-$(CONFIG_HUGETLB_PAGE) += hugetlbpage.o | 18 | obj-$(CONFIG_HUGETLB_PAGE) += hugetlbpage.o |
| 18 | obj-$(CONFIG_NUMA) += numa.o | 19 | obj-$(CONFIG_NUMA) += numa.o |
diff --git a/arch/sh/mm/asids-debugfs.c b/arch/sh/mm/asids-debugfs.c new file mode 100644 index 000000000000..8e912a15e94f --- /dev/null +++ b/arch/sh/mm/asids-debugfs.c | |||
| @@ -0,0 +1,79 @@ | |||
| 1 | /* | ||
| 2 | * debugfs ops for process ASIDs | ||
| 3 | * | ||
| 4 | * Copyright (C) 2000, 2001 Paolo Alberelli | ||
| 5 | * Copyright (C) 2003 - 2008 Paul Mundt | ||
| 6 | * Copyright (C) 2003, 2004 Richard Curnow | ||
| 7 | * | ||
| 8 | * Provides a debugfs file that lists out the ASIDs currently associated | ||
| 9 | * with the processes. | ||
| 10 | * | ||
| 11 | * In the SH-5 case, if the DM.PC register is examined through the debug | ||
| 12 | * link, this shows ASID + PC. To make use of this, the PID->ASID | ||
| 13 | * relationship needs to be known. This is primarily for debugging. | ||
| 14 | * | ||
| 15 | * This file is subject to the terms and conditions of the GNU General Public | ||
| 16 | * License. See the file "COPYING" in the main directory of this archive | ||
| 17 | * for more details. | ||
| 18 | */ | ||
| 19 | #include <linux/init.h> | ||
| 20 | #include <linux/module.h> | ||
| 21 | #include <linux/debugfs.h> | ||
| 22 | #include <linux/seq_file.h> | ||
| 23 | #include <linux/spinlock.h> | ||
| 24 | #include <asm/processor.h> | ||
| 25 | #include <asm/mmu_context.h> | ||
| 26 | |||
| 27 | static int asids_seq_show(struct seq_file *file, void *iter) | ||
| 28 | { | ||
| 29 | struct task_struct *p; | ||
| 30 | |||
| 31 | read_lock(&tasklist_lock); | ||
| 32 | |||
| 33 | for_each_process(p) { | ||
| 34 | int pid = p->pid; | ||
| 35 | |||
| 36 | if (unlikely(!pid)) | ||
| 37 | continue; | ||
| 38 | |||
| 39 | if (p->mm) | ||
| 40 | seq_printf(file, "%5d : %02lx\n", pid, | ||
| 41 | cpu_asid(smp_processor_id(), p->mm)); | ||
| 42 | else | ||
| 43 | seq_printf(file, "%5d : (none)\n", pid); | ||
| 44 | } | ||
| 45 | |||
| 46 | read_unlock(&tasklist_lock); | ||
| 47 | |||
| 48 | return 0; | ||
| 49 | } | ||
| 50 | |||
| 51 | static int asids_debugfs_open(struct inode *inode, struct file *file) | ||
| 52 | { | ||
| 53 | return single_open(file, asids_seq_show, inode->i_private); | ||
| 54 | } | ||
| 55 | |||
| 56 | static const struct file_operations asids_debugfs_fops = { | ||
| 57 | .owner = THIS_MODULE, | ||
| 58 | .open = asids_debugfs_open, | ||
| 59 | .read = seq_read, | ||
| 60 | .llseek = seq_lseek, | ||
| 61 | .release = single_release, | ||
| 62 | }; | ||
| 63 | |||
| 64 | static int __init asids_debugfs_init(void) | ||
| 65 | { | ||
| 66 | struct dentry *asids_dentry; | ||
| 67 | |||
| 68 | asids_dentry = debugfs_create_file("asids", S_IRUSR, sh_debugfs_root, | ||
| 69 | NULL, &asids_debugfs_fops); | ||
| 70 | if (!asids_dentry) | ||
| 71 | return -ENOMEM; | ||
| 72 | if (IS_ERR(asids_dentry)) | ||
| 73 | return PTR_ERR(asids_dentry); | ||
| 74 | |||
| 75 | return 0; | ||
| 76 | } | ||
| 77 | module_init(asids_debugfs_init); | ||
| 78 | |||
| 79 | MODULE_LICENSE("GPL v2"); | ||
diff --git a/arch/sh/mm/consistent.c b/arch/sh/mm/consistent.c index 9f8ea3ada4db..edcd5fbf9651 100644 --- a/arch/sh/mm/consistent.c +++ b/arch/sh/mm/consistent.c | |||
| @@ -42,6 +42,8 @@ void *dma_alloc_coherent(struct device *dev, size_t size, | |||
| 42 | return NULL; | 42 | return NULL; |
| 43 | } | 43 | } |
| 44 | 44 | ||
| 45 | split_page(pfn_to_page(virt_to_phys(ret) >> PAGE_SHIFT), order); | ||
| 46 | |||
| 45 | *dma_handle = virt_to_phys(ret); | 47 | *dma_handle = virt_to_phys(ret); |
| 46 | return ret_nocache; | 48 | return ret_nocache; |
| 47 | } | 49 | } |
| @@ -51,10 +53,13 @@ void dma_free_coherent(struct device *dev, size_t size, | |||
| 51 | void *vaddr, dma_addr_t dma_handle) | 53 | void *vaddr, dma_addr_t dma_handle) |
| 52 | { | 54 | { |
| 53 | int order = get_order(size); | 55 | int order = get_order(size); |
| 56 | unsigned long pfn = dma_handle >> PAGE_SHIFT; | ||
| 57 | int k; | ||
| 54 | 58 | ||
| 55 | if (!dma_release_from_coherent(dev, order, vaddr)) { | 59 | if (!dma_release_from_coherent(dev, order, vaddr)) { |
| 56 | WARN_ON(irqs_disabled()); /* for portability */ | 60 | WARN_ON(irqs_disabled()); /* for portability */ |
| 57 | free_pages((unsigned long)phys_to_virt(dma_handle), order); | 61 | for (k = 0; k < (1 << order); k++) |
| 62 | __free_pages(pfn_to_page(pfn + k), 0); | ||
| 58 | iounmap(vaddr); | 63 | iounmap(vaddr); |
| 59 | } | 64 | } |
| 60 | } | 65 | } |
diff --git a/arch/sh/mm/fault_32.c b/arch/sh/mm/fault_32.c index 898d477e47c1..31a33ebdef6f 100644 --- a/arch/sh/mm/fault_32.c +++ b/arch/sh/mm/fault_32.c | |||
| @@ -20,7 +20,6 @@ | |||
| 20 | #include <asm/system.h> | 20 | #include <asm/system.h> |
| 21 | #include <asm/mmu_context.h> | 21 | #include <asm/mmu_context.h> |
| 22 | #include <asm/tlbflush.h> | 22 | #include <asm/tlbflush.h> |
| 23 | #include <asm/kgdb.h> | ||
| 24 | 23 | ||
| 25 | /* | 24 | /* |
| 26 | * This routine handles page faults. It determines the address, | 25 | * This routine handles page faults. It determines the address, |
| @@ -265,17 +264,6 @@ static inline int notify_page_fault(struct pt_regs *regs, int trap) | |||
| 265 | return ret; | 264 | return ret; |
| 266 | } | 265 | } |
| 267 | 266 | ||
| 268 | #ifdef CONFIG_SH_STORE_QUEUES | ||
| 269 | /* | ||
| 270 | * This is a special case for the SH-4 store queues, as pages for this | ||
| 271 | * space still need to be faulted in before it's possible to flush the | ||
| 272 | * store queue cache for writeout to the remapped region. | ||
| 273 | */ | ||
| 274 | #define P3_ADDR_MAX (P4SEG_STORE_QUE + 0x04000000) | ||
| 275 | #else | ||
| 276 | #define P3_ADDR_MAX P4SEG | ||
| 277 | #endif | ||
| 278 | |||
| 279 | /* | 267 | /* |
| 280 | * Called with interrupts disabled. | 268 | * Called with interrupts disabled. |
| 281 | */ | 269 | */ |
| @@ -293,11 +281,6 @@ asmlinkage int __kprobes __do_page_fault(struct pt_regs *regs, | |||
| 293 | if (notify_page_fault(regs, lookup_exception_vector())) | 281 | if (notify_page_fault(regs, lookup_exception_vector())) |
| 294 | goto out; | 282 | goto out; |
| 295 | 283 | ||
| 296 | #ifdef CONFIG_SH_KGDB | ||
| 297 | if (kgdb_nofault && kgdb_bus_err_hook) | ||
| 298 | kgdb_bus_err_hook(); | ||
| 299 | #endif | ||
| 300 | |||
| 301 | ret = 1; | 284 | ret = 1; |
| 302 | 285 | ||
| 303 | /* | 286 | /* |
diff --git a/arch/sh/mm/ioremap_32.c b/arch/sh/mm/ioremap_32.c index 882a32ebc6b7..32946fba123e 100644 --- a/arch/sh/mm/ioremap_32.c +++ b/arch/sh/mm/ioremap_32.c | |||
| @@ -116,9 +116,10 @@ EXPORT_SYMBOL(__ioremap); | |||
| 116 | void __iounmap(void __iomem *addr) | 116 | void __iounmap(void __iomem *addr) |
| 117 | { | 117 | { |
| 118 | unsigned long vaddr = (unsigned long __force)addr; | 118 | unsigned long vaddr = (unsigned long __force)addr; |
| 119 | unsigned long seg = PXSEG(vaddr); | ||
| 119 | struct vm_struct *p; | 120 | struct vm_struct *p; |
| 120 | 121 | ||
| 121 | if (PXSEG(vaddr) < P3SEG || is_pci_memaddr(vaddr)) | 122 | if (seg < P3SEG || seg >= P3_ADDR_MAX || is_pci_memaddr(vaddr)) |
| 122 | return; | 123 | return; |
| 123 | 124 | ||
| 124 | #ifdef CONFIG_32BIT | 125 | #ifdef CONFIG_32BIT |
diff --git a/arch/sh/mm/mmap.c b/arch/sh/mm/mmap.c index 8837d511710a..931f4d003fa0 100644 --- a/arch/sh/mm/mmap.c +++ b/arch/sh/mm/mmap.c | |||
| @@ -9,7 +9,101 @@ | |||
| 9 | */ | 9 | */ |
| 10 | #include <linux/io.h> | 10 | #include <linux/io.h> |
| 11 | #include <linux/mm.h> | 11 | #include <linux/mm.h> |
| 12 | #include <linux/mman.h> | ||
| 13 | #include <linux/module.h> | ||
| 12 | #include <asm/page.h> | 14 | #include <asm/page.h> |
| 15 | #include <asm/processor.h> | ||
| 16 | |||
| 17 | #ifdef CONFIG_MMU | ||
| 18 | unsigned long shm_align_mask = PAGE_SIZE - 1; /* Sane caches */ | ||
| 19 | EXPORT_SYMBOL(shm_align_mask); | ||
| 20 | |||
| 21 | /* | ||
| 22 | * To avoid cache aliases, we map the shared page with same color. | ||
| 23 | */ | ||
| 24 | #define COLOUR_ALIGN(addr, pgoff) \ | ||
| 25 | ((((addr) + shm_align_mask) & ~shm_align_mask) + \ | ||
| 26 | (((pgoff) << PAGE_SHIFT) & shm_align_mask)) | ||
| 27 | |||
| 28 | unsigned long arch_get_unmapped_area(struct file *filp, unsigned long addr, | ||
| 29 | unsigned long len, unsigned long pgoff, unsigned long flags) | ||
| 30 | { | ||
| 31 | struct mm_struct *mm = current->mm; | ||
| 32 | struct vm_area_struct *vma; | ||
| 33 | unsigned long start_addr; | ||
| 34 | int do_colour_align; | ||
| 35 | |||
| 36 | if (flags & MAP_FIXED) { | ||
| 37 | /* We do not accept a shared mapping if it would violate | ||
| 38 | * cache aliasing constraints. | ||
| 39 | */ | ||
| 40 | if ((flags & MAP_SHARED) && (addr & shm_align_mask)) | ||
| 41 | return -EINVAL; | ||
| 42 | return addr; | ||
| 43 | } | ||
| 44 | |||
| 45 | if (unlikely(len > TASK_SIZE)) | ||
| 46 | return -ENOMEM; | ||
| 47 | |||
| 48 | do_colour_align = 0; | ||
| 49 | if (filp || (flags & MAP_SHARED)) | ||
| 50 | do_colour_align = 1; | ||
| 51 | |||
| 52 | if (addr) { | ||
| 53 | if (do_colour_align) | ||
| 54 | addr = COLOUR_ALIGN(addr, pgoff); | ||
| 55 | else | ||
| 56 | addr = PAGE_ALIGN(addr); | ||
| 57 | |||
| 58 | vma = find_vma(mm, addr); | ||
| 59 | if (TASK_SIZE - len >= addr && | ||
| 60 | (!vma || addr + len <= vma->vm_start)) | ||
| 61 | return addr; | ||
| 62 | } | ||
| 63 | |||
| 64 | if (len > mm->cached_hole_size) { | ||
| 65 | start_addr = addr = mm->free_area_cache; | ||
| 66 | } else { | ||
| 67 | mm->cached_hole_size = 0; | ||
| 68 | start_addr = addr = TASK_UNMAPPED_BASE; | ||
| 69 | } | ||
| 70 | |||
| 71 | full_search: | ||
| 72 | if (do_colour_align) | ||
| 73 | addr = COLOUR_ALIGN(addr, pgoff); | ||
| 74 | else | ||
| 75 | addr = PAGE_ALIGN(mm->free_area_cache); | ||
| 76 | |||
| 77 | for (vma = find_vma(mm, addr); ; vma = vma->vm_next) { | ||
| 78 | /* At this point: (!vma || addr < vma->vm_end). */ | ||
| 79 | if (unlikely(TASK_SIZE - len < addr)) { | ||
| 80 | /* | ||
| 81 | * Start a new search - just in case we missed | ||
| 82 | * some holes. | ||
| 83 | */ | ||
| 84 | if (start_addr != TASK_UNMAPPED_BASE) { | ||
| 85 | start_addr = addr = TASK_UNMAPPED_BASE; | ||
| 86 | mm->cached_hole_size = 0; | ||
| 87 | goto full_search; | ||
| 88 | } | ||
| 89 | return -ENOMEM; | ||
| 90 | } | ||
| 91 | if (likely(!vma || addr + len <= vma->vm_start)) { | ||
| 92 | /* | ||
| 93 | * Remember the place where we stopped the search: | ||
| 94 | */ | ||
| 95 | mm->free_area_cache = addr + len; | ||
| 96 | return addr; | ||
| 97 | } | ||
| 98 | if (addr + mm->cached_hole_size < vma->vm_start) | ||
| 99 | mm->cached_hole_size = vma->vm_start - addr; | ||
| 100 | |||
| 101 | addr = vma->vm_end; | ||
| 102 | if (do_colour_align) | ||
| 103 | addr = COLOUR_ALIGN(addr, pgoff); | ||
| 104 | } | ||
| 105 | } | ||
| 106 | #endif /* CONFIG_MMU */ | ||
| 13 | 107 | ||
| 14 | /* | 108 | /* |
| 15 | * You really shouldn't be using read() or write() on /dev/mem. This | 109 | * You really shouldn't be using read() or write() on /dev/mem. This |
