[patch 4/4] spufs: convert nopfn to fault
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 @@ -237,11 +237,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; @@ -259,15 +261,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) @@ -282,12 +284,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) @@ -350,20 +352,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 @@ -377,7 +378,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)) @@ -385,14 +386,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) @@ -400,18 +402,18 @@ static unsigned
Re: [patch 4/4] spufs: convert nopfn to fault
Thanks for helping out with merging these Andrew. The problem with this is that these nopfn conversions won't work unless the BUG_ON is removed from mm/memory.c (patch 1/ that I sent you). So there is a little dependency chain here. I guess you could send that patch 1 upstream ASAP, and then let the subsequent non trivial patches filter up in their own time. I don't know, just a heads up. On Wed, May 14, 2008 at 04:12:54PM -0700, Andrew Morton wrote: 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 @@ -237,11 +237,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; @@ -259,15 +261,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) @@ -282,12 +284,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) @@ -350,20 +352,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 @@ -377,7 +378,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)) @@ -385,14 +386,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 =
Re: [patch 4/4] spufs: convert nopfn to fault
On Thu, 15 May 2008 02:53:05 +0200 Nick Piggin [EMAIL PROTECTED] wrote: Thanks for helping out with merging these Andrew. The problem with this is that these nopfn conversions won't work unless the BUG_ON is removed from mm/memory.c (patch 1/ that I sent you). oh. So there is a little dependency chain here. I guess you could send that patch 1 upstream ASAP, and then let the subsequent non trivial patches filter up in their own time. I don't know, just a heads up. OK, I'll include mm-allow-pfnmap-faults.patch in the next linuswards batch. ___ Linuxppc-dev mailing list Linuxppc-dev@ozlabs.org https://ozlabs.org/mailman/listinfo/linuxppc-dev