From: Nick Piggin [EMAIL PROTECTED]
spufs: convert nopfn to fault
Signed-off-by: Nick Piggin [EMAIL PROTECTED]
Acked-by: Jeremy Kerr [EMAIL PROTECTED]
Cc: Paul Mackerras [EMAIL PROTECTED]
Cc: Benjamin Herrenschmidt [EMAIL PROTECTED]
Signed-off-by: Andrew Morton [EMAIL PROTECTED]
---
arch/powerpc/platforms/cell/spufs/file.c | 98 -
arch/powerpc/platforms/cell/spufs/sputrace.c |8 -
2 files changed, 54 insertions(+), 52 deletions(-)
diff -puN arch/powerpc/platforms/cell/spufs/file.c~spufs-convert-nopfn-to-fault
arch/powerpc/platforms/cell/spufs/file.c
--- a/arch/powerpc/platforms/cell/spufs/file.c~spufs-convert-nopfn-to-fault
+++ a/arch/powerpc/platforms/cell/spufs/file.c
@@ -238,11 +238,13 @@ spufs_mem_write(struct file *file, const
return size;
}
-static unsigned long spufs_mem_mmap_nopfn(struct vm_area_struct *vma,
- unsigned long address)
+static int
+spufs_mem_mmap_fault(struct vm_area_struct *vma, struct vm_fault *vmf)
{
struct spu_context *ctx = vma-vm_file-private_data;
- unsigned long pfn, offset, addr0 = address;
+ unsigned long address = (unsigned long)vmf-virtual_address;
+ unsigned long pfn, offset;
+
#ifdef CONFIG_SPU_FS_64K_LS
struct spu_state *csa = ctx-csa;
int psize;
@@ -260,15 +262,15 @@ static unsigned long spufs_mem_mmap_nopf
}
#endif /* CONFIG_SPU_FS_64K_LS */
- offset = (address - vma-vm_start) + (vma-vm_pgoff PAGE_SHIFT);
+ offset = vmf-pgoff PAGE_SHIFT;
if (offset = LS_SIZE)
- return NOPFN_SIGBUS;
+ return VM_FAULT_SIGBUS;
- pr_debug(spufs_mem_mmap_nopfn address=0x%lx - 0x%lx, offset=0x%lx\n,
-addr0, address, offset);
+ pr_debug(spufs_mem_mmap_fault address=0x%lx, offset=0x%lx\n,
+ address, offset);
if (spu_acquire(ctx))
- return NOPFN_REFAULT;
+ return VM_FAULT_NOPAGE;
if (ctx-state == SPU_STATE_SAVED) {
vma-vm_page_prot = __pgprot(pgprot_val(vma-vm_page_prot)
@@ -283,12 +285,12 @@ static unsigned long spufs_mem_mmap_nopf
spu_release(ctx);
- return NOPFN_REFAULT;
+ return VM_FAULT_NOPAGE;
}
static struct vm_operations_struct spufs_mem_mmap_vmops = {
- .nopfn = spufs_mem_mmap_nopfn,
+ .fault = spufs_mem_mmap_fault,
};
static int spufs_mem_mmap(struct file *file, struct vm_area_struct *vma)
@@ -351,20 +353,19 @@ static const struct file_operations spuf
#endif
};
-static unsigned long spufs_ps_nopfn(struct vm_area_struct *vma,
- unsigned long address,
+static int spufs_ps_fault(struct vm_area_struct *vma,
+ struct vm_fault *vmf,
unsigned long ps_offs,
unsigned long ps_size)
{
struct spu_context *ctx = vma-vm_file-private_data;
- unsigned long area, offset = address - vma-vm_start;
+ unsigned long area, offset = vmf-pgoff PAGE_SHIFT;
int ret = 0;
- spu_context_nospu_trace(spufs_ps_nopfn__enter, ctx);
+ spu_context_nospu_trace(spufs_ps_fault__enter, ctx);
- offset += vma-vm_pgoff PAGE_SHIFT;
if (offset = ps_size)
- return NOPFN_SIGBUS;
+ return VM_FAULT_SIGBUS;
/*
* Because we release the mmap_sem, the context may be destroyed while
@@ -378,7 +379,7 @@ static unsigned long spufs_ps_nopfn(stru
* pages to hand out to the user, but we don't want to wait
* with the mmap_sem held.
* It is possible to drop the mmap_sem here, but then we need
-* to return NOPFN_REFAULT because the mappings may have
+* to return VM_FAULT_NOPAGE because the mappings may have
* hanged.
*/
if (spu_acquire(ctx))
@@ -386,14 +387,15 @@ static unsigned long spufs_ps_nopfn(stru
if (ctx-state == SPU_STATE_SAVED) {
up_read(current-mm-mmap_sem);
- spu_context_nospu_trace(spufs_ps_nopfn__sleep, ctx);
+ spu_context_nospu_trace(spufs_ps_fault__sleep, ctx);
ret = spufs_wait(ctx-run_wq, ctx-state == SPU_STATE_RUNNABLE);
- spu_context_trace(spufs_ps_nopfn__wake, ctx, ctx-spu);
+ spu_context_trace(spufs_ps_fault__wake, ctx, ctx-spu);
down_read(current-mm-mmap_sem);
} else {
area = ctx-spu-problem_phys + ps_offs;
- vm_insert_pfn(vma, address, (area + offset) PAGE_SHIFT);
- spu_context_trace(spufs_ps_nopfn__insert, ctx, ctx-spu);
+ vm_insert_pfn(vma, (unsigned long)vmf-virtual_address,
+ (area + offset) PAGE_SHIFT);
+ spu_context_trace(spufs_ps_fault__insert, ctx, ctx-spu);
}
if (!ret)
@@ -401,18 +403,18 @@ static unsigned