Skip to content

Commit e83d016

Browse files
Ian Munsiempe
authored andcommitted
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 <[email protected]> Signed-off-by: Michael Neuling <[email protected]> Signed-off-by: Michael Ellerman <[email protected]>
1 parent 60666de commit e83d016

File tree

8 files changed

+33
-14
lines changed

8 files changed

+33
-14
lines changed

arch/powerpc/Kconfig

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -608,6 +608,10 @@ config PPC_SUBPAGE_PROT
608608
to set access permissions (read/write, readonly, or no access)
609609
on the 4k subpages of each 64k page.
610610

611+
config PPC_COPRO_BASE
612+
bool
613+
default n
614+
611615
config SCHED_SMT
612616
bool "SMT (Hyperthreading) scheduler support"
613617
depends on PPC64 && SMP

arch/powerpc/include/asm/copro.h

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,16 @@
1+
/*
2+
* Copyright 2014 IBM Corp.
3+
*
4+
* This program is free software; you can redistribute it and/or
5+
* modify it under the terms of the GNU General Public License
6+
* as published by the Free Software Foundation; either version
7+
* 2 of the License, or (at your option) any later version.
8+
*/
9+
10+
#ifndef _ASM_POWERPC_COPRO_H
11+
#define _ASM_POWERPC_COPRO_H
12+
13+
int copro_handle_mm_fault(struct mm_struct *mm, unsigned long ea,
14+
unsigned long dsisr, unsigned *flt);
15+
16+
#endif /* _ASM_POWERPC_COPRO_H */

arch/powerpc/include/asm/spu.h

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -27,6 +27,8 @@
2727
#include <linux/workqueue.h>
2828
#include <linux/device.h>
2929
#include <linux/mutex.h>
30+
#include <asm/reg.h>
31+
#include <asm/copro.h>
3032

3133
#define LS_SIZE (256 * 1024)
3234
#define LS_ADDR_MASK (LS_SIZE - 1)
@@ -277,9 +279,6 @@ void spu_remove_dev_attr(struct device_attribute *attr);
277279
int spu_add_dev_attr_group(struct attribute_group *attrs);
278280
void spu_remove_dev_attr_group(struct attribute_group *attrs);
279281

280-
int spu_handle_mm_fault(struct mm_struct *mm, unsigned long ea,
281-
unsigned long dsisr, unsigned *flt);
282-
283282
/*
284283
* Notifier blocks:
285284
*

arch/powerpc/mm/Makefile

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -34,3 +34,4 @@ obj-$(CONFIG_TRANSPARENT_HUGEPAGE) += hugepage-hash64.o
3434
obj-$(CONFIG_PPC_SUBPAGE_PROT) += subpage-prot.o
3535
obj-$(CONFIG_NOT_COHERENT_CACHE) += dma-noncoherent.o
3636
obj-$(CONFIG_HIGHMEM) += highmem.o
37+
obj-$(CONFIG_PPC_COPRO_BASE) += copro_fault.o

arch/powerpc/platforms/cell/spu_fault.c renamed to arch/powerpc/mm/copro_fault.c

Lines changed: 6 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
/*
2-
* SPU mm fault handler
2+
* CoProcessor (SPU/AFU) mm fault handler
33
*
44
* (C) Copyright IBM Deutschland Entwicklung GmbH 2007
55
*
@@ -23,16 +23,14 @@
2323
#include <linux/sched.h>
2424
#include <linux/mm.h>
2525
#include <linux/export.h>
26-
27-
#include <asm/spu.h>
28-
#include <asm/spu_csa.h>
26+
#include <asm/reg.h>
2927

3028
/*
3129
* This ought to be kept in sync with the powerpc specific do_page_fault
3230
* function. Currently, there are a few corner cases that we haven't had
3331
* to handle fortunately.
3432
*/
35-
int spu_handle_mm_fault(struct mm_struct *mm, unsigned long ea,
33+
int copro_handle_mm_fault(struct mm_struct *mm, unsigned long ea,
3634
unsigned long dsisr, unsigned *flt)
3735
{
3836
struct vm_area_struct *vma;
@@ -58,12 +56,12 @@ int spu_handle_mm_fault(struct mm_struct *mm, unsigned long ea,
5856
goto out_unlock;
5957
}
6058

61-
is_write = dsisr & MFC_DSISR_ACCESS_PUT;
59+
is_write = dsisr & DSISR_ISSTORE;
6260
if (is_write) {
6361
if (!(vma->vm_flags & VM_WRITE))
6462
goto out_unlock;
6563
} else {
66-
if (dsisr & MFC_DSISR_ACCESS_DENIED)
64+
if (dsisr & DSISR_PROTFAULT)
6765
goto out_unlock;
6866
if (!(vma->vm_flags & (VM_READ | VM_EXEC)))
6967
goto out_unlock;
@@ -91,4 +89,4 @@ int spu_handle_mm_fault(struct mm_struct *mm, unsigned long ea,
9189
up_read(&mm->mmap_sem);
9290
return ret;
9391
}
94-
EXPORT_SYMBOL_GPL(spu_handle_mm_fault);
92+
EXPORT_SYMBOL_GPL(copro_handle_mm_fault);

arch/powerpc/platforms/cell/Kconfig

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -86,6 +86,7 @@ config SPU_FS_64K_LS
8686
config SPU_BASE
8787
bool
8888
default n
89+
select PPC_COPRO_BASE
8990

9091
config CBE_RAS
9192
bool "RAS features for bare metal Cell BE"

arch/powerpc/platforms/cell/Makefile

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -20,7 +20,7 @@ spu-manage-$(CONFIG_PPC_CELL_COMMON) += spu_manage.o
2020

2121
obj-$(CONFIG_SPU_BASE) += spu_callbacks.o spu_base.o \
2222
spu_notify.o \
23-
spu_syscalls.o spu_fault.o \
23+
spu_syscalls.o \
2424
$(spu-priv1-y) \
2525
$(spu-manage-y) \
2626
spufs/

arch/powerpc/platforms/cell/spufs/fault.c

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -138,7 +138,7 @@ int spufs_handle_class1(struct spu_context *ctx)
138138
if (ctx->state == SPU_STATE_RUNNABLE)
139139
ctx->spu->stats.hash_flt++;
140140

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 */
142142
spu_release(ctx);
143143

144144
access = (_PAGE_PRESENT | _PAGE_USER);
@@ -149,7 +149,7 @@ int spufs_handle_class1(struct spu_context *ctx)
149149

150150
/* hashing failed, so try the actual fault handler */
151151
if (ret)
152-
ret = spu_handle_mm_fault(current->mm, ea, dsisr, &flt);
152+
ret = copro_handle_mm_fault(current->mm, ea, dsisr, &flt);
153153

154154
/*
155155
* This is nasty: we need the state_mutex for all the bookkeeping even

0 commit comments

Comments
 (0)