[Cbe-oss-dev] + spufs-use-the-new-vm_ops-access.patch added to -mm tree

Arnd Bergmann arnd at arndb.de
Fri May 16 19:33:41 EST 2008


On Friday 16 May 2008, akpm at linux-foundation.org wrote:

> diff -puN arch/powerpc/platforms/cell/spufs/file.c~spufs-use-the-new-vm_ops-access arch/powerpc/platforms/cell/spufs/file.c
> --- a/arch/powerpc/platforms/cell/spufs/file.c~spufs-use-the-new-vm_ops-access
> +++ a/arch/powerpc/platforms/cell/spufs/file.c
> @@ -287,9 +287,32 @@ spufs_mem_mmap_fault(struct vm_area_stru
>  	return VM_FAULT_NOPAGE;
>  }
>  
> +static int spufs_mem_mmep_access(struct vm_area_struct *vma,
> +				unsigned long address,
> +				void *buf, int len, int write)
> +{
> +	struct spu_context *ctx = vma->vm_file->private_data;
> +	unsigned long offset = address - vma->vm_start;
> +	char *local_store;
> +
> +	if (write && !(vma->vm_flags & VM_WRITE))
> +		return -EACCES;
> +	if (spu_acquire(ctx))
> +		return -EINTR;
> +	if ((offset + len) > vma->vm_end)
> +		len = vma->vm_end - offset;
> +	local_store = ctx->ops->get_ls(ctx);
> +	if (write)
> +		memcpy_toio(local_store + offset, buf, len);
> +	else
> +		memcpy_fromio(buf, local_store + offset, len);
> +	spu_release(ctx);
> +	return len;
> +}
>  
>  static struct vm_operations_struct spufs_mem_mmap_vmops = {
>  	.fault = spufs_mem_mmap_fault,
> +	.access = spufs_mem_mmep_access,
>  };

Great patch, thanks for working on this! It's been a long-running
bug that we'll be able to close with when this gets in.

The code looks correct, but I think the spelling should be adapted
so it's named 'spufs_mem_mmap_access' instead of 'spufs_mem_mmep_access'.

I'm also not entirely sure about the memcpy_{from,to}io, in all other
places in spufs, we just use plain pointer derefences, which I assume
is safe on local store (it does not have side-effects), and get_ls
may return either an ioremapped page or a kernel memory page, depending
on the state of ctx. Shouldn't matter either way, but the current code
triggers a sparse warning.

	Arnd <><



More information about the cbe-oss-dev mailing list