diff options
| author | Ian Munsie <imunsie@au1.ibm.com> | 2014-10-08 04:54:50 -0400 |
|---|---|---|
| committer | Michael Ellerman <mpe@ellerman.id.au> | 2014-10-08 05:14:54 -0400 |
| commit | e83d01697583d8610d1d62279758c2a881e3396f (patch) | |
| tree | 167a30304a5b48debcb66955efdf5f68808c1998 /arch/powerpc/platforms/cell | |
| parent | 60666de2dac99777631d0df64257d7fd6a5118fe (diff) | |
powerpc/cell: Move spu_handle_mm_fault() out of cell platform
Currently spu_handle_mm_fault() is in the cell platform.
This code is generically useful for other non-cell co-processors on powerpc.
This patch moves this function out of the cell platform into arch/powerpc/mm so
that others may use it.
Signed-off-by: Ian Munsie <imunsie@au1.ibm.com>
Signed-off-by: Michael Neuling <mikey@neuling.org>
Signed-off-by: Michael Ellerman <mpe@ellerman.id.au>
Diffstat (limited to 'arch/powerpc/platforms/cell')
| -rw-r--r-- | arch/powerpc/platforms/cell/Kconfig | 1 | ||||
| -rw-r--r-- | arch/powerpc/platforms/cell/Makefile | 2 | ||||
| -rw-r--r-- | arch/powerpc/platforms/cell/spu_fault.c | 94 | ||||
| -rw-r--r-- | arch/powerpc/platforms/cell/spufs/fault.c | 4 |
4 files changed, 4 insertions, 97 deletions
diff --git a/arch/powerpc/platforms/cell/Kconfig b/arch/powerpc/platforms/cell/Kconfig index 9978f594cac0..870b6dbd4d18 100644 --- a/arch/powerpc/platforms/cell/Kconfig +++ b/arch/powerpc/platforms/cell/Kconfig | |||
| @@ -86,6 +86,7 @@ config SPU_FS_64K_LS | |||
| 86 | config SPU_BASE | 86 | config SPU_BASE |
| 87 | bool | 87 | bool |
| 88 | default n | 88 | default n |
| 89 | select PPC_COPRO_BASE | ||
| 89 | 90 | ||
| 90 | config CBE_RAS | 91 | config CBE_RAS |
| 91 | bool "RAS features for bare metal Cell BE" | 92 | bool "RAS features for bare metal Cell BE" |
diff --git a/arch/powerpc/platforms/cell/Makefile b/arch/powerpc/platforms/cell/Makefile index fe053e7c73ee..2d16884f67b9 100644 --- a/arch/powerpc/platforms/cell/Makefile +++ b/arch/powerpc/platforms/cell/Makefile | |||
| @@ -20,7 +20,7 @@ spu-manage-$(CONFIG_PPC_CELL_COMMON) += spu_manage.o | |||
| 20 | 20 | ||
| 21 | obj-$(CONFIG_SPU_BASE) += spu_callbacks.o spu_base.o \ | 21 | obj-$(CONFIG_SPU_BASE) += spu_callbacks.o spu_base.o \ |
| 22 | spu_notify.o \ | 22 | spu_notify.o \ |
| 23 | spu_syscalls.o spu_fault.o \ | 23 | spu_syscalls.o \ |
| 24 | $(spu-priv1-y) \ | 24 | $(spu-priv1-y) \ |
| 25 | $(spu-manage-y) \ | 25 | $(spu-manage-y) \ |
| 26 | spufs/ | 26 | spufs/ |
diff --git a/arch/powerpc/platforms/cell/spu_fault.c b/arch/powerpc/platforms/cell/spu_fault.c deleted file mode 100644 index 641e7273d75a..000000000000 --- a/arch/powerpc/platforms/cell/spu_fault.c +++ /dev/null | |||
| @@ -1,94 +0,0 @@ | |||
| 1 | /* | ||
| 2 | * SPU mm fault handler | ||
| 3 | * | ||
| 4 | * (C) Copyright IBM Deutschland Entwicklung GmbH 2007 | ||
| 5 | * | ||
| 6 | * Author: Arnd Bergmann <arndb@de.ibm.com> | ||
| 7 | * Author: Jeremy Kerr <jk@ozlabs.org> | ||
| 8 | * | ||
| 9 | * This program is free software; you can redistribute it and/or modify | ||
| 10 | * it under the terms of the GNU General Public License as published by | ||
| 11 | * the Free Software Foundation; either version 2, or (at your option) | ||
| 12 | * any later version. | ||
| 13 | * | ||
| 14 | * This program is distributed in the hope that it will be useful, | ||
| 15 | * but WITHOUT ANY WARRANTY; without even the implied warranty of | ||
| 16 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the | ||
| 17 | * GNU General Public License for more details. | ||
| 18 | * | ||
| 19 | * You should have received a copy of the GNU General Public License | ||
| 20 | * along with this program; if not, write to the Free Software | ||
| 21 | * Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. | ||
| 22 | */ | ||
| 23 | #include <linux/sched.h> | ||
| 24 | #include <linux/mm.h> | ||
| 25 | #include <linux/export.h> | ||
| 26 | |||
| 27 | #include <asm/spu.h> | ||
| 28 | #include <asm/spu_csa.h> | ||
| 29 | |||
| 30 | /* | ||
| 31 | * This ought to be kept in sync with the powerpc specific do_page_fault | ||
| 32 | * function. Currently, there are a few corner cases that we haven't had | ||
| 33 | * to handle fortunately. | ||
| 34 | */ | ||
| 35 | int spu_handle_mm_fault(struct mm_struct *mm, unsigned long ea, | ||
| 36 | unsigned long dsisr, unsigned *flt) | ||
| 37 | { | ||
| 38 | struct vm_area_struct *vma; | ||
| 39 | unsigned long is_write; | ||
| 40 | int ret; | ||
| 41 | |||
| 42 | if (mm == NULL) | ||
| 43 | return -EFAULT; | ||
| 44 | |||
| 45 | if (mm->pgd == NULL) | ||
| 46 | return -EFAULT; | ||
| 47 | |||
| 48 | down_read(&mm->mmap_sem); | ||
| 49 | ret = -EFAULT; | ||
| 50 | vma = find_vma(mm, ea); | ||
| 51 | if (!vma) | ||
| 52 | goto out_unlock; | ||
| 53 | |||
| 54 | if (ea < vma->vm_start) { | ||
| 55 | if (!(vma->vm_flags & VM_GROWSDOWN)) | ||
| 56 | goto out_unlock; | ||
| 57 | if (expand_stack(vma, ea)) | ||
| 58 | goto out_unlock; | ||
| 59 | } | ||
| 60 | |||
| 61 | is_write = dsisr & MFC_DSISR_ACCESS_PUT; | ||
| 62 | if (is_write) { | ||
| 63 | if (!(vma->vm_flags & VM_WRITE)) | ||
| 64 | goto out_unlock; | ||
| 65 | } else { | ||
| 66 | if (dsisr & MFC_DSISR_ACCESS_DENIED) | ||
| 67 | goto out_unlock; | ||
| 68 | if (!(vma->vm_flags & (VM_READ | VM_EXEC))) | ||
| 69 | goto out_unlock; | ||
| 70 | } | ||
| 71 | |||
| 72 | ret = 0; | ||
| 73 | *flt = handle_mm_fault(mm, vma, ea, is_write ? FAULT_FLAG_WRITE : 0); | ||
| 74 | if (unlikely(*flt & VM_FAULT_ERROR)) { | ||
| 75 | if (*flt & VM_FAULT_OOM) { | ||
| 76 | ret = -ENOMEM; | ||
| 77 | goto out_unlock; | ||
| 78 | } else if (*flt & VM_FAULT_SIGBUS) { | ||
| 79 | ret = -EFAULT; | ||
| 80 | goto out_unlock; | ||
| 81 | } | ||
| 82 | BUG(); | ||
| 83 | } | ||
| 84 | |||
| 85 | if (*flt & VM_FAULT_MAJOR) | ||
| 86 | current->maj_flt++; | ||
| 87 | else | ||
| 88 | current->min_flt++; | ||
| 89 | |||
| 90 | out_unlock: | ||
| 91 | up_read(&mm->mmap_sem); | ||
| 92 | return ret; | ||
| 93 | } | ||
| 94 | EXPORT_SYMBOL_GPL(spu_handle_mm_fault); | ||
diff --git a/arch/powerpc/platforms/cell/spufs/fault.c b/arch/powerpc/platforms/cell/spufs/fault.c index 8cb6260cc80f..e45894a08118 100644 --- a/arch/powerpc/platforms/cell/spufs/fault.c +++ b/arch/powerpc/platforms/cell/spufs/fault.c | |||
| @@ -138,7 +138,7 @@ int spufs_handle_class1(struct spu_context *ctx) | |||
| 138 | if (ctx->state == SPU_STATE_RUNNABLE) | 138 | if (ctx->state == SPU_STATE_RUNNABLE) |
| 139 | ctx->spu->stats.hash_flt++; | 139 | ctx->spu->stats.hash_flt++; |
| 140 | 140 | ||
| 141 | /* we must not hold the lock when entering spu_handle_mm_fault */ | 141 | /* we must not hold the lock when entering copro_handle_mm_fault */ |
| 142 | spu_release(ctx); | 142 | spu_release(ctx); |
| 143 | 143 | ||
| 144 | access = (_PAGE_PRESENT | _PAGE_USER); | 144 | access = (_PAGE_PRESENT | _PAGE_USER); |
| @@ -149,7 +149,7 @@ int spufs_handle_class1(struct spu_context *ctx) | |||
| 149 | 149 | ||
| 150 | /* hashing failed, so try the actual fault handler */ | 150 | /* hashing failed, so try the actual fault handler */ |
| 151 | if (ret) | 151 | if (ret) |
| 152 | ret = spu_handle_mm_fault(current->mm, ea, dsisr, &flt); | 152 | ret = copro_handle_mm_fault(current->mm, ea, dsisr, &flt); |
| 153 | 153 | ||
| 154 | /* | 154 | /* |
| 155 | * This is nasty: we need the state_mutex for all the bookkeeping even | 155 | * This is nasty: we need the state_mutex for all the bookkeeping even |
