From: Gustavo Padovan gustavo.padovan@collabora.co.uk
struct sync_merge_data already have documentation on top of the struct definition. No need to duplicate it.
Signed-off-by: Gustavo Padovan gustavo.padovan@collabora.co.uk Reviewed-by: Maarten Lankhorst maarten.lankhorst@linux.intel.com --- drivers/staging/android/uapi/sync.h | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-)
diff --git a/drivers/staging/android/uapi/sync.h b/drivers/staging/android/uapi/sync.h index a0cf357..4467c76 100644 --- a/drivers/staging/android/uapi/sync.h +++ b/drivers/staging/android/uapi/sync.h @@ -21,9 +21,9 @@ * @fence: returns the fd of the new fence to userspace */ struct sync_merge_data { - __s32 fd2; /* fd of second fence */ - char name[32]; /* name of new fence */ - __s32 fence; /* fd on newly created fence */ + __s32 fd2; + char name[32]; + __s32 fence; };
/**
From: Gustavo Padovan gustavo.padovan@collabora.co.uk
This function had copies in 3 different files. Unify them in kernel.h.
Cc: Joe Perches joe@perches.com Cc: Andrew Morton akpm@linux-foundation.org Cc: David Airlie airlied@linux.ie Cc: Daniel Vetter daniel.vetter@intel.com Cc: Rob Clark robdclark@gmail.com Signed-off-by: Gustavo Padovan gustavo.padovan@collabora.co.uk --- drivers/gpu/drm/etnaviv/etnaviv_gem_submit.c | 11 +++-------- drivers/gpu/drm/i915/i915_drv.h | 5 ----- drivers/gpu/drm/i915/i915_gem.c | 14 +++++++------- drivers/gpu/drm/i915/i915_gem_execbuffer.c | 14 +++++++------- drivers/gpu/drm/msm/msm_gem_submit.c | 11 +++-------- include/linux/kernel.h | 5 +++++ 6 files changed, 25 insertions(+), 35 deletions(-)
diff --git a/drivers/gpu/drm/etnaviv/etnaviv_gem_submit.c b/drivers/gpu/drm/etnaviv/etnaviv_gem_submit.c index 1aba01a..5420bc5 100644 --- a/drivers/gpu/drm/etnaviv/etnaviv_gem_submit.c +++ b/drivers/gpu/drm/etnaviv/etnaviv_gem_submit.c @@ -28,11 +28,6 @@ #define BO_LOCKED 0x4000 #define BO_PINNED 0x2000
-static inline void __user *to_user_ptr(u64 address) -{ - return (void __user *)(uintptr_t)address; -} - static struct etnaviv_gem_submit *submit_create(struct drm_device *dev, struct etnaviv_gpu *gpu, size_t nr) { @@ -351,21 +346,21 @@ int etnaviv_ioctl_gem_submit(struct drm_device *dev, void *data, cmdbuf->exec_state = args->exec_state; cmdbuf->ctx = file->driver_priv;
- ret = copy_from_user(bos, to_user_ptr(args->bos), + ret = copy_from_user(bos, u64_to_user_ptr(args->bos), args->nr_bos * sizeof(*bos)); if (ret) { ret = -EFAULT; goto err_submit_cmds; }
- ret = copy_from_user(relocs, to_user_ptr(args->relocs), + ret = copy_from_user(relocs, u64_to_user_ptr(args->relocs), args->nr_relocs * sizeof(*relocs)); if (ret) { ret = -EFAULT; goto err_submit_cmds; }
- ret = copy_from_user(stream, to_user_ptr(args->stream), + ret = copy_from_user(stream, u64_to_user_ptr(args->stream), args->stream_size); if (ret) { ret = -EFAULT; diff --git a/drivers/gpu/drm/i915/i915_drv.h b/drivers/gpu/drm/i915/i915_drv.h index b0847b9..c446895 100644 --- a/drivers/gpu/drm/i915/i915_drv.h +++ b/drivers/gpu/drm/i915/i915_drv.h @@ -3564,11 +3564,6 @@ static inline i915_reg_t i915_vgacntrl_reg(struct drm_device *dev) return VGACNTRL; }
-static inline void __user *to_user_ptr(u64 address) -{ - return (void __user *)(uintptr_t)address; -} - static inline unsigned long msecs_to_jiffies_timeout(const unsigned int m) { unsigned long j = msecs_to_jiffies(m); diff --git a/drivers/gpu/drm/i915/i915_gem.c b/drivers/gpu/drm/i915/i915_gem.c index bb44bad..cd11790 100644 --- a/drivers/gpu/drm/i915/i915_gem.c +++ b/drivers/gpu/drm/i915/i915_gem.c @@ -324,7 +324,7 @@ i915_gem_phys_pwrite(struct drm_i915_gem_object *obj, { struct drm_device *dev = obj->base.dev; void *vaddr = obj->phys_handle->vaddr + args->offset; - char __user *user_data = to_user_ptr(args->data_ptr); + char __user *user_data = u64_to_user_ptr(args->data_ptr); int ret = 0;
/* We manually control the domain here and pretend that it @@ -605,7 +605,7 @@ i915_gem_shmem_pread(struct drm_device *dev, int needs_clflush = 0; struct sg_page_iter sg_iter;
- user_data = to_user_ptr(args->data_ptr); + user_data = u64_to_user_ptr(args->data_ptr); remain = args->size;
obj_do_bit17_swizzling = i915_gem_object_needs_bit17_swizzle(obj); @@ -692,7 +692,7 @@ i915_gem_pread_ioctl(struct drm_device *dev, void *data, return 0;
if (!access_ok(VERIFY_WRITE, - to_user_ptr(args->data_ptr), + u64_to_user_ptr(args->data_ptr), args->size)) return -EFAULT;
@@ -783,7 +783,7 @@ i915_gem_gtt_pwrite_fast(struct drm_device *dev, if (ret) goto out_unpin;
- user_data = to_user_ptr(args->data_ptr); + user_data = u64_to_user_ptr(args->data_ptr); remain = args->size;
offset = i915_gem_obj_ggtt_offset(obj) + args->offset; @@ -907,7 +907,7 @@ i915_gem_shmem_pwrite(struct drm_device *dev, int needs_clflush_before = 0; struct sg_page_iter sg_iter;
- user_data = to_user_ptr(args->data_ptr); + user_data = u64_to_user_ptr(args->data_ptr); remain = args->size;
obj_do_bit17_swizzling = i915_gem_object_needs_bit17_swizzle(obj); @@ -1036,12 +1036,12 @@ i915_gem_pwrite_ioctl(struct drm_device *dev, void *data, return 0;
if (!access_ok(VERIFY_READ, - to_user_ptr(args->data_ptr), + u64_to_user_ptr(args->data_ptr), args->size)) return -EFAULT;
if (likely(!i915.prefault_disable)) { - ret = fault_in_multipages_readable(to_user_ptr(args->data_ptr), + ret = fault_in_multipages_readable(u64_to_user_ptr(args->data_ptr), args->size); if (ret) return -EFAULT; diff --git a/drivers/gpu/drm/i915/i915_gem_execbuffer.c b/drivers/gpu/drm/i915/i915_gem_execbuffer.c index dccb517..6715893 100644 --- a/drivers/gpu/drm/i915/i915_gem_execbuffer.c +++ b/drivers/gpu/drm/i915/i915_gem_execbuffer.c @@ -517,7 +517,7 @@ i915_gem_execbuffer_relocate_vma(struct i915_vma *vma, struct drm_i915_gem_exec_object2 *entry = vma->exec_entry; int remain, ret;
- user_relocs = to_user_ptr(entry->relocs_ptr); + user_relocs = u64_to_user_ptr(entry->relocs_ptr);
remain = entry->relocation_count; while (remain) { @@ -869,7 +869,7 @@ i915_gem_execbuffer_relocate_slow(struct drm_device *dev, u64 invalid_offset = (u64)-1; int j;
- user_relocs = to_user_ptr(exec[i].relocs_ptr); + user_relocs = u64_to_user_ptr(exec[i].relocs_ptr);
if (copy_from_user(reloc+total, user_relocs, exec[i].relocation_count * sizeof(*reloc))) { @@ -1013,7 +1013,7 @@ validate_exec_list(struct drm_device *dev, invalid_flags |= EXEC_OBJECT_NEEDS_GTT;
for (i = 0; i < count; i++) { - char __user *ptr = to_user_ptr(exec[i].relocs_ptr); + char __user *ptr = u64_to_user_ptr(exec[i].relocs_ptr); int length; /* limited by fault_in_pages_readable() */
if (exec[i].flags & invalid_flags) @@ -1687,7 +1687,7 @@ i915_gem_execbuffer(struct drm_device *dev, void *data, return -ENOMEM; } ret = copy_from_user(exec_list, - to_user_ptr(args->buffers_ptr), + u64_to_user_ptr(args->buffers_ptr), sizeof(*exec_list) * args->buffer_count); if (ret != 0) { DRM_DEBUG("copy %d exec entries failed %d\n", @@ -1723,7 +1723,7 @@ i915_gem_execbuffer(struct drm_device *dev, void *data, ret = i915_gem_do_execbuffer(dev, data, file, &exec2, exec2_list); if (!ret) { struct drm_i915_gem_exec_object __user *user_exec_list = - to_user_ptr(args->buffers_ptr); + u64_to_user_ptr(args->buffers_ptr);
/* Copy the new buffer offsets back to the user's exec list. */ for (i = 0; i < args->buffer_count; i++) { @@ -1777,7 +1777,7 @@ i915_gem_execbuffer2(struct drm_device *dev, void *data, return -ENOMEM; } ret = copy_from_user(exec2_list, - to_user_ptr(args->buffers_ptr), + u64_to_user_ptr(args->buffers_ptr), sizeof(*exec2_list) * args->buffer_count); if (ret != 0) { DRM_DEBUG("copy %d exec entries failed %d\n", @@ -1790,7 +1790,7 @@ i915_gem_execbuffer2(struct drm_device *dev, void *data, if (!ret) { /* Copy the new buffer offsets back to the user's exec list. */ struct drm_i915_gem_exec_object2 __user *user_exec_list = - to_user_ptr(args->buffers_ptr); + u64_to_user_ptr(args->buffers_ptr); int i;
for (i = 0; i < args->buffer_count; i++) { diff --git a/drivers/gpu/drm/msm/msm_gem_submit.c b/drivers/gpu/drm/msm/msm_gem_submit.c index 6d7cd3f..951a753 100644 --- a/drivers/gpu/drm/msm/msm_gem_submit.c +++ b/drivers/gpu/drm/msm/msm_gem_submit.c @@ -28,11 +28,6 @@ #define BO_LOCKED 0x4000 #define BO_PINNED 0x2000
-static inline void __user *to_user_ptr(u64 address) -{ - return (void __user *)(uintptr_t)address; -} - static struct msm_gem_submit *submit_create(struct drm_device *dev, struct msm_gpu *gpu, int nr) { @@ -68,7 +63,7 @@ static int submit_lookup_objects(struct msm_gem_submit *submit, struct drm_gem_object *obj; struct msm_gem_object *msm_obj; void __user *userptr = - to_user_ptr(args->bos + (i * sizeof(submit_bo))); + u64_to_user_ptr(args->bos + (i * sizeof(submit_bo)));
ret = copy_from_user(&submit_bo, userptr, sizeof(submit_bo)); if (ret) { @@ -257,7 +252,7 @@ static int submit_reloc(struct msm_gem_submit *submit, struct msm_gem_object *ob for (i = 0; i < nr_relocs; i++) { struct drm_msm_gem_submit_reloc submit_reloc; void __user *userptr = - to_user_ptr(relocs + (i * sizeof(submit_reloc))); + u64_to_user_ptr(relocs + (i * sizeof(submit_reloc))); uint32_t iova, off; bool valid;
@@ -357,7 +352,7 @@ int msm_ioctl_gem_submit(struct drm_device *dev, void *data, for (i = 0; i < args->nr_cmds; i++) { struct drm_msm_gem_submit_cmd submit_cmd; void __user *userptr = - to_user_ptr(args->cmds + (i * sizeof(submit_cmd))); + u64_to_user_ptr(args->cmds + (i * sizeof(submit_cmd))); struct msm_gem_object *msm_obj; uint32_t iova;
diff --git a/include/linux/kernel.h b/include/linux/kernel.h index f31638c..2564dad 100644 --- a/include/linux/kernel.h +++ b/include/linux/kernel.h @@ -53,6 +53,11 @@
#define ARRAY_SIZE(arr) (sizeof(arr) / sizeof((arr)[0]) + __must_be_array(arr))
+static inline void __user *u64_to_user_ptr(u64 address) +{ + return (void __user *)(uintptr_t)address; +} + /* * This looks more complex than it should be. But we need to * get the type for the ~ right in round_down (it needs to be
On Fri, 2016-03-18 at 10:27 -0300, Gustavo Padovan wrote:
From: Gustavo Padovan gustavo.padovan@collabora.co.uk
This function had copies in 3 different files. Unify them in kernel.h.
This function might be used more in drm files in a separate patch too:
$ git grep -n -E "__user.*(\s*uintptr_t\s*)" drivers/gpu/drm drivers/gpu/drm/armada/armada_gem.c:385: ptr = (char __user *)(uintptr_t)args->ptr; drivers/gpu/drm/etnaviv/etnaviv_gem_submit.c:33: return (void __user *)(uintptr_t)address; drivers/gpu/drm/i915/i915_drv.h:3581: return (void __user *)(uintptr_t)address; drivers/gpu/drm/msm/msm_gem_submit.c:33: return (void __user *)(uintptr_t)address; drivers/gpu/drm/nouveau/nouveau_gem.c:471: (void __force __user *)(uintptr_t)user_pbbo_ptr; drivers/gpu/drm/nouveau/nouveau_gem.c:568: void __user *userptr = (void __force __user *)(uintptr_t)user; drivers/gpu/drm/tegra/drm.c:333: (void __user *)(uintptr_t)args->cmdbufs; drivers/gpu/drm/tegra/drm.c:335: (void __user *)(uintptr_t)args->relocs; drivers/gpu/drm/tegra/drm.c:337: (void __user *)(uintptr_t)args->waitchks; drivers/gpu/drm/tegra/drm.c:392: if (copy_from_user(&syncpt, (void __user *)(uintptr_t)args->syncpts, drivers/gpu/drm/vc4/vc4_bo.c:502: (void __user *)(uintptr_t)args->data, drivers/gpu/drm/vc4/vc4_gem.c:123: if (copy_to_user((void __user *)(uintptr_t)get_state->bo, drivers/gpu/drm/vc4/vc4_gem.c:553: (void __user *)(uintptr_t)args->bo_handles, drivers/gpu/drm/vc4/vc4_gem.c:627: (void __user *)(uintptr_t)args->bin_cl, drivers/gpu/drm/vc4/vc4_gem.c:634: (void __user *)(uintptr_t)args->shader_rec, drivers/gpu/drm/vc4/vc4_gem.c:641: (void __user *)(uintptr_t)args->uniforms, drivers/gpu/drm/virtio/virtgpu_ioctl.c:126: user_bo_handles = (void __user *)(uintptr_t)exbuf->bo_handles; drivers/gpu/drm/virtio/virtgpu_ioctl.c:161: if (copy_from_user(buf, (void __user *)(uintptr_t)exbuf->command,
Use the newly added u64_to_user_pointer a bit more frequently.
Signed-off-by: Joe Perches joe@perches.com --- drivers/gpu/drm/armada/armada_gem.c | 2 +- drivers/gpu/drm/nouveau/nouveau_gem.c | 7 ++++--- drivers/gpu/drm/tegra/drm.c | 15 ++++++++------- drivers/gpu/drm/vc4/vc4_bo.c | 4 ++-- drivers/gpu/drm/vc4/vc4_gem.c | 10 +++++----- drivers/gpu/drm/virtio/virtgpu_ioctl.c | 5 ++--- 6 files changed, 22 insertions(+), 21 deletions(-)
diff --git a/drivers/gpu/drm/armada/armada_gem.c b/drivers/gpu/drm/armada/armada_gem.c index 6e731db..7629dd2 100644 --- a/drivers/gpu/drm/armada/armada_gem.c +++ b/drivers/gpu/drm/armada/armada_gem.c @@ -382,7 +382,7 @@ int armada_gem_pwrite_ioctl(struct drm_device *dev, void *data, if (args->size == 0) return 0;
- ptr = (char __user *)(uintptr_t)args->ptr; + ptr = u64_to_user_ptr(args->ptr);
if (!access_ok(VERIFY_READ, ptr, args->size)) return -EFAULT; diff --git a/drivers/gpu/drm/nouveau/nouveau_gem.c b/drivers/gpu/drm/nouveau/nouveau_gem.c index a0865c4..1a6604c9 100644 --- a/drivers/gpu/drm/nouveau/nouveau_gem.c +++ b/drivers/gpu/drm/nouveau/nouveau_gem.c @@ -467,11 +467,12 @@ validate_list(struct nouveau_channel *chan, struct nouveau_cli *cli, uint64_t user_pbbo_ptr) { struct nouveau_drm *drm = chan->drm; - struct drm_nouveau_gem_pushbuf_bo __user *upbbo = - (void __force __user *)(uintptr_t)user_pbbo_ptr; + struct drm_nouveau_gem_pushbuf_bo __user *upbbo; struct nouveau_bo *nvbo; int ret, relocs = 0;
+ upbbo = u64_to_user_ptr(user_pbbo_ptr); + list_for_each_entry(nvbo, list, entry) { struct drm_nouveau_gem_pushbuf_bo *b = &pbbo[nvbo->pbbo_index];
@@ -565,7 +566,7 @@ static inline void * u_memcpya(uint64_t user, unsigned nmemb, unsigned size) { void *mem; - void __user *userptr = (void __force __user *)(uintptr_t)user; + void __user *userptr = u64_to_user_ptr(user);
size *= nmemb;
diff --git a/drivers/gpu/drm/tegra/drm.c b/drivers/gpu/drm/tegra/drm.c index 8e6b18c..b20c87d 100644 --- a/drivers/gpu/drm/tegra/drm.c +++ b/drivers/gpu/drm/tegra/drm.c @@ -329,12 +329,9 @@ int tegra_drm_submit(struct tegra_drm_context *context, unsigned int num_cmdbufs = args->num_cmdbufs; unsigned int num_relocs = args->num_relocs; unsigned int num_waitchks = args->num_waitchks; - struct drm_tegra_cmdbuf __user *cmdbufs = - (void __user *)(uintptr_t)args->cmdbufs; - struct drm_tegra_reloc __user *relocs = - (void __user *)(uintptr_t)args->relocs; - struct drm_tegra_waitchk __user *waitchks = - (void __user *)(uintptr_t)args->waitchks; + struct drm_tegra_cmdbuf __user *cmdbufs; + struct drm_tegra_reloc __user *relocs; + struct drm_tegra_waitchk __user *waitchks; struct drm_tegra_syncpt syncpt; struct host1x_job *job; int err; @@ -354,6 +351,10 @@ int tegra_drm_submit(struct tegra_drm_context *context, job->class = context->client->base.class; job->serialize = true;
+ cmdbufs = u64_to_user_ptr(args->cmdbufs); + relocs = u64_to_user_ptr(args->relocs); + waitchks = u64_to_user_ptr(args->waitchks); + while (num_cmdbufs) { struct drm_tegra_cmdbuf cmdbuf; struct host1x_bo *bo; @@ -389,7 +390,7 @@ int tegra_drm_submit(struct tegra_drm_context *context, goto fail; }
- if (copy_from_user(&syncpt, (void __user *)(uintptr_t)args->syncpts, + if (copy_from_user(&syncpt, u64_to_user_ptr(args->syncpts), sizeof(syncpt))) { err = -EFAULT; goto fail; diff --git a/drivers/gpu/drm/vc4/vc4_bo.c b/drivers/gpu/drm/vc4/vc4_bo.c index 9807bc9..fe3a4aa 100644 --- a/drivers/gpu/drm/vc4/vc4_bo.c +++ b/drivers/gpu/drm/vc4/vc4_bo.c @@ -499,8 +499,8 @@ vc4_create_shader_bo_ioctl(struct drm_device *dev, void *data, return PTR_ERR(bo);
if (copy_from_user(bo->base.vaddr, - (void __user *)(uintptr_t)args->data, - args->size)) { + u64_to_user_ptr(args->data), + args->size)) { ret = -EFAULT; goto fail; } diff --git a/drivers/gpu/drm/vc4/vc4_gem.c b/drivers/gpu/drm/vc4/vc4_gem.c index 8d4384f..89d7931 100644 --- a/drivers/gpu/drm/vc4/vc4_gem.c +++ b/drivers/gpu/drm/vc4/vc4_gem.c @@ -120,7 +120,7 @@ vc4_get_hang_state_ioctl(struct drm_device *dev, void *data, bo_state[i].size = vc4_bo->base.base.size; }
- if (copy_to_user((void __user *)(uintptr_t)get_state->bo, + if (copy_to_user(u64_to_user_ptr(get_state->bo), bo_state, state->bo_count * sizeof(*bo_state))) ret = -EFAULT; @@ -550,7 +550,7 @@ vc4_cl_lookup_bos(struct drm_device *dev, }
ret = copy_from_user(handles, - (void __user *)(uintptr_t)args->bo_handles, + u64_to_user_ptr(args->bo_handles), exec->bo_count * sizeof(uint32_t)); if (ret) { DRM_ERROR("Failed to copy in GEM handles\n"); @@ -624,21 +624,21 @@ vc4_get_bcl(struct drm_device *dev, struct vc4_exec_info *exec) exec->shader_state_size = args->shader_rec_count;
if (copy_from_user(bin, - (void __user *)(uintptr_t)args->bin_cl, + u64_to_user_ptr(args->bin_cl), args->bin_cl_size)) { ret = -EFAULT; goto fail; }
if (copy_from_user(exec->shader_rec_u, - (void __user *)(uintptr_t)args->shader_rec, + u64_to_user_ptr(args->shader_rec), args->shader_rec_size)) { ret = -EFAULT; goto fail; }
if (copy_from_user(exec->uniforms_u, - (void __user *)(uintptr_t)args->uniforms, + u64_to_user_ptr(args->uniforms), args->uniforms_size)) { ret = -EFAULT; goto fail; diff --git a/drivers/gpu/drm/virtio/virtgpu_ioctl.c b/drivers/gpu/drm/virtio/virtgpu_ioctl.c index b4de18e..e602bb6 100644 --- a/drivers/gpu/drm/virtio/virtgpu_ioctl.c +++ b/drivers/gpu/drm/virtio/virtgpu_ioctl.c @@ -123,7 +123,7 @@ static int virtio_gpu_execbuffer(struct drm_device *dev, return -ENOMEM; }
- user_bo_handles = (void __user *)(uintptr_t)exbuf->bo_handles; + user_bo_handles = u64_to_user_ptr(exbuf->bo_handles); if (copy_from_user(bo_handles, user_bo_handles, exbuf->num_bo_handles * sizeof(uint32_t))) { ret = -EFAULT; @@ -158,8 +158,7 @@ static int virtio_gpu_execbuffer(struct drm_device *dev, ret = -ENOMEM; goto out_unresv; } - if (copy_from_user(buf, (void __user *)(uintptr_t)exbuf->command, - exbuf->size)) { + if (copy_from_user(buf, u64_to_user_ptr(exbuf->command), exbuf->size)) { kfree(buf); ret = -EFAULT; goto out_unresv;
Hi Joe,
[auto build test WARNING on drm/drm-next] [also build test WARNING on next-20160318] [cannot apply to v4.5] [if your patch is applied to the wrong git tree, please drop us a note to help improving the system]
url: https://github.com/0day-ci/linux/commits/Joe-Perches/gpu-drm-Use-u64_to_user... base: git://people.freedesktop.org/~airlied/linux.git drm-next config: m68k-allmodconfig (attached as .config) reproduce: wget https://git.kernel.org/cgit/linux/kernel/git/wfg/lkp-tests.git/plain/sbin/ma... -O ~/bin/make.cross chmod +x ~/bin/make.cross # save the attached .config to linux build tree make.cross ARCH=m68k
All warnings (new ones prefixed by >>):
drivers/gpu/drm/vc4/vc4_bo.c: In function 'vc4_create_shader_bo_ioctl': drivers/gpu/drm/vc4/vc4_bo.c:502:2: error: implicit declaration of function 'u64_to_user_ptr' [-Werror=implicit-function-declaration] if (copy_from_user(bo->base.vaddr, ^ In file included from arch/m68k/include/asm/uaccess.h:4:0, from include/linux/uaccess.h:5, from include/linux/highmem.h:8, from include/drm/drmP.h:40, from drivers/gpu/drm/vc4/vc4_drv.h:9, from drivers/gpu/drm/vc4/vc4_bo.c:21:
arch/m68k/include/asm/uaccess_mm.h:368:2: warning: passing argument 2 of '__constant_copy_from_user' makes pointer from integer without a cast
__constant_copy_from_user(to, from, n) : \ ^
arch/m68k/include/asm/uaccess_mm.h:379:37: note: in expansion of macro '__copy_from_user'
#define copy_from_user(to, from, n) __copy_from_user(to, from, n) ^ drivers/gpu/drm/vc4/vc4_bo.c:502:6: note: in expansion of macro 'copy_from_user' if (copy_from_user(bo->base.vaddr, ^ arch/m68k/include/asm/uaccess_mm.h:239:1: note: expected 'const void *' but argument is of type 'int' __constant_copy_from_user(void *to, const void __user *from, unsigned long n) ^
arch/m68k/include/asm/uaccess_mm.h:369:2: warning: passing argument 2 of '__generic_copy_from_user' makes pointer from integer without a cast
__generic_copy_from_user(to, from, n)) ^
arch/m68k/include/asm/uaccess_mm.h:379:37: note: in expansion of macro '__copy_from_user'
#define copy_from_user(to, from, n) __copy_from_user(to, from, n) ^ drivers/gpu/drm/vc4/vc4_bo.c:502:6: note: in expansion of macro 'copy_from_user' if (copy_from_user(bo->base.vaddr, ^ arch/m68k/include/asm/uaccess_mm.h:202:15: note: expected 'const void *' but argument is of type 'int' unsigned long __generic_copy_from_user(void *to, const void __user *from, unsigned long n); ^ cc1: some warnings being treated as errors -- drivers/gpu/drm/vc4/vc4_gem.c: In function 'vc4_get_hang_state_ioctl': drivers/gpu/drm/vc4/vc4_gem.c:123:2: error: implicit declaration of function 'u64_to_user_ptr' [-Werror=implicit-function-declaration] if (copy_to_user(u64_to_user_ptr(get_state->bo), ^ In file included from arch/m68k/include/asm/uaccess.h:4:0, from include/linux/uaccess.h:5, from include/linux/highmem.h:8, from include/drm/drmP.h:40, from drivers/gpu/drm/vc4/vc4_drv.h:9, from drivers/gpu/drm/vc4/vc4_gem.c:31:
arch/m68k/include/asm/uaccess_mm.h:373:2: warning: passing argument 1 of '__constant_copy_to_user' makes pointer from integer without a cast
__constant_copy_to_user(to, from, n) : \ ^
arch/m68k/include/asm/uaccess_mm.h:380:35: note: in expansion of macro '__copy_to_user'
#define copy_to_user(to, from, n) __copy_to_user(to, from, n) ^ drivers/gpu/drm/vc4/vc4_gem.c:123:6: note: in expansion of macro 'copy_to_user' if (copy_to_user(u64_to_user_ptr(get_state->bo), ^ arch/m68k/include/asm/uaccess_mm.h:320:1: note: expected 'void *' but argument is of type 'int' __constant_copy_to_user(void __user *to, const void *from, unsigned long n) ^
arch/m68k/include/asm/uaccess_mm.h:374:2: warning: passing argument 1 of '__generic_copy_to_user' makes pointer from integer without a cast
__generic_copy_to_user(to, from, n)) ^
arch/m68k/include/asm/uaccess_mm.h:380:35: note: in expansion of macro '__copy_to_user'
#define copy_to_user(to, from, n) __copy_to_user(to, from, n) ^ drivers/gpu/drm/vc4/vc4_gem.c:123:6: note: in expansion of macro 'copy_to_user' if (copy_to_user(u64_to_user_ptr(get_state->bo), ^ arch/m68k/include/asm/uaccess_mm.h:203:15: note: expected 'void *' but argument is of type 'int' unsigned long __generic_copy_to_user(void __user *to, const void *from, unsigned long n); ^ drivers/gpu/drm/vc4/vc4_gem.c: In function 'vc4_cl_lookup_bos':
arch/m68k/include/asm/uaccess_mm.h:368:2: warning: passing argument 2 of '__constant_copy_from_user' makes pointer from integer without a cast
__constant_copy_from_user(to, from, n) : \ ^
arch/m68k/include/asm/uaccess_mm.h:379:37: note: in expansion of macro '__copy_from_user'
#define copy_from_user(to, from, n) __copy_from_user(to, from, n) ^ drivers/gpu/drm/vc4/vc4_gem.c:552:8: note: in expansion of macro 'copy_from_user' ret = copy_from_user(handles, ^ arch/m68k/include/asm/uaccess_mm.h:239:1: note: expected 'const void *' but argument is of type 'int' __constant_copy_from_user(void *to, const void __user *from, unsigned long n) ^
arch/m68k/include/asm/uaccess_mm.h:369:2: warning: passing argument 2 of '__generic_copy_from_user' makes pointer from integer without a cast
__generic_copy_from_user(to, from, n)) ^
arch/m68k/include/asm/uaccess_mm.h:379:37: note: in expansion of macro '__copy_from_user'
#define copy_from_user(to, from, n) __copy_from_user(to, from, n) ^ drivers/gpu/drm/vc4/vc4_gem.c:552:8: note: in expansion of macro 'copy_from_user' ret = copy_from_user(handles, ^ arch/m68k/include/asm/uaccess_mm.h:202:15: note: expected 'const void *' but argument is of type 'int' unsigned long __generic_copy_from_user(void *to, const void __user *from, unsigned long n); ^ drivers/gpu/drm/vc4/vc4_gem.c: In function 'vc4_get_bcl':
arch/m68k/include/asm/uaccess_mm.h:368:2: warning: passing argument 2 of '__constant_copy_from_user' makes pointer from integer without a cast
__constant_copy_from_user(to, from, n) : \ ^
arch/m68k/include/asm/uaccess_mm.h:379:37: note: in expansion of macro '__copy_from_user'
#define copy_from_user(to, from, n) __copy_from_user(to, from, n) ^ drivers/gpu/drm/vc4/vc4_gem.c:626:6: note: in expansion of macro 'copy_from_user' if (copy_from_user(bin, ^ arch/m68k/include/asm/uaccess_mm.h:239:1: note: expected 'const void *' but argument is of type 'int' __constant_copy_from_user(void *to, const void __user *from, unsigned long n) ^
arch/m68k/include/asm/uaccess_mm.h:369:2: warning: passing argument 2 of '__generic_copy_from_user' makes pointer from integer without a cast
__generic_copy_from_user(to, from, n)) ^
arch/m68k/include/asm/uaccess_mm.h:379:37: note: in expansion of macro '__copy_from_user'
#define copy_from_user(to, from, n) __copy_from_user(to, from, n) ^ drivers/gpu/drm/vc4/vc4_gem.c:626:6: note: in expansion of macro 'copy_from_user' if (copy_from_user(bin, ^ arch/m68k/include/asm/uaccess_mm.h:202:15: note: expected 'const void *' but argument is of type 'int' unsigned long __generic_copy_from_user(void *to, const void __user *from, unsigned long n); ^
arch/m68k/include/asm/uaccess_mm.h:368:2: warning: passing argument 2 of '__constant_copy_from_user' makes pointer from integer without a cast
__constant_copy_from_user(to, from, n) : \ ^
arch/m68k/include/asm/uaccess_mm.h:379:37: note: in expansion of macro '__copy_from_user'
#define copy_from_user(to, from, n) __copy_from_user(to, from, n) ^ drivers/gpu/drm/vc4/vc4_gem.c:633:6: note: in expansion of macro 'copy_from_user' if (copy_from_user(exec->shader_rec_u, ^ arch/m68k/include/asm/uaccess_mm.h:239:1: note: expected 'const void *' but argument is of type 'int' __constant_copy_from_user(void *to, const void __user *from, unsigned long n) ^
arch/m68k/include/asm/uaccess_mm.h:369:2: warning: passing argument 2 of '__generic_copy_from_user' makes pointer from integer without a cast
__generic_copy_from_user(to, from, n)) ^
arch/m68k/include/asm/uaccess_mm.h:379:37: note: in expansion of macro '__copy_from_user'
#define copy_from_user(to, from, n) __copy_from_user(to, from, n) ^ drivers/gpu/drm/vc4/vc4_gem.c:633:6: note: in expansion of macro 'copy_from_user' if (copy_from_user(exec->shader_rec_u, ^ arch/m68k/include/asm/uaccess_mm.h:202:15: note: expected 'const void *' but argument is of type 'int' unsigned long __generic_copy_from_user(void *to, const void __user *from, unsigned long n); ^
arch/m68k/include/asm/uaccess_mm.h:368:2: warning: passing argument 2 of '__constant_copy_from_user' makes pointer from integer without a cast
__constant_copy_from_user(to, from, n) : \ ^
arch/m68k/include/asm/uaccess_mm.h:379:37: note: in expansion of macro '__copy_from_user'
#define copy_from_user(to, from, n) __copy_from_user(to, from, n) ^ drivers/gpu/drm/vc4/vc4_gem.c:640:6: note: in expansion of macro 'copy_from_user' if (copy_from_user(exec->uniforms_u, ^ arch/m68k/include/asm/uaccess_mm.h:239:1: note: expected 'const void *' but argument is of type 'int' __constant_copy_from_user(void *to, const void __user *from, unsigned long n) ^
arch/m68k/include/asm/uaccess_mm.h:369:2: warning: passing argument 2 of '__generic_copy_from_user' makes pointer from integer without a cast
__generic_copy_from_user(to, from, n)) ^
arch/m68k/include/asm/uaccess_mm.h:379:37: note: in expansion of macro '__copy_from_user'
#define copy_from_user(to, from, n) __copy_from_user(to, from, n) ^ drivers/gpu/drm/vc4/vc4_gem.c:640:6: note: in expansion of macro 'copy_from_user' if (copy_from_user(exec->uniforms_u, ^ arch/m68k/include/asm/uaccess_mm.h:202:15: note: expected 'const void *' but argument is of type 'int' unsigned long __generic_copy_from_user(void *to, const void __user *from, unsigned long n); ^ cc1: some warnings being treated as errors
vim +/__constant_copy_from_user +368 arch/m68k/include/asm/uaccess_mm.h
^1da177e include/asm-m68k/uaccess.h Linus Torvalds 2005-04-16 197 } \ ^1da177e include/asm-m68k/uaccess.h Linus Torvalds 2005-04-16 198 __gu_err; \ ^1da177e include/asm-m68k/uaccess.h Linus Torvalds 2005-04-16 199 }) d94af931 include/asm-m68k/uaccess.h Roman Zippel 2006-06-23 200 #define get_user(x, ptr) __get_user(x, ptr) ^1da177e include/asm-m68k/uaccess.h Linus Torvalds 2005-04-16 201 d94af931 include/asm-m68k/uaccess.h Roman Zippel 2006-06-23 202 unsigned long __generic_copy_from_user(void *to, const void __user *from, unsigned long n); d94af931 include/asm-m68k/uaccess.h Roman Zippel 2006-06-23 @203 unsigned long __generic_copy_to_user(void __user *to, const void *from, unsigned long n); ^1da177e include/asm-m68k/uaccess.h Linus Torvalds 2005-04-16 204 53617825 include/asm-m68k/uaccess.h Roman Zippel 2006-06-25 205 #define __constant_copy_from_user_asm(res, to, from, tmp, n, s1, s2, s3)\ 53617825 include/asm-m68k/uaccess.h Roman Zippel 2006-06-25 206 asm volatile ("\n" \ e08d703c arch/m68k/include/asm/uaccess_mm.h Greg Ungerer 2011-10-14 207 "1: "MOVES"."#s1" (%2)+,%3\n" \ 53617825 include/asm-m68k/uaccess.h Roman Zippel 2006-06-25 208 " move."#s1" %3,(%1)+\n" \ e08d703c arch/m68k/include/asm/uaccess_mm.h Greg Ungerer 2011-10-14 209 "2: "MOVES"."#s2" (%2)+,%3\n" \ 53617825 include/asm-m68k/uaccess.h Roman Zippel 2006-06-25 210 " move."#s2" %3,(%1)+\n" \ 53617825 include/asm-m68k/uaccess.h Roman Zippel 2006-06-25 211 " .ifnc ""#s3"",""\n" \ e08d703c arch/m68k/include/asm/uaccess_mm.h Greg Ungerer 2011-10-14 212 "3: "MOVES"."#s3" (%2)+,%3\n" \ 53617825 include/asm-m68k/uaccess.h Roman Zippel 2006-06-25 213 " move."#s3" %3,(%1)+\n" \ 53617825 include/asm-m68k/uaccess.h Roman Zippel 2006-06-25 214 " .endif\n" \ 53617825 include/asm-m68k/uaccess.h Roman Zippel 2006-06-25 215 "4:\n" \ 53617825 include/asm-m68k/uaccess.h Roman Zippel 2006-06-25 216 " .section __ex_table,"a"\n" \ 53617825 include/asm-m68k/uaccess.h Roman Zippel 2006-06-25 217 " .align 4\n" \ 53617825 include/asm-m68k/uaccess.h Roman Zippel 2006-06-25 218 " .long 1b,10f\n" \ 53617825 include/asm-m68k/uaccess.h Roman Zippel 2006-06-25 219 " .long 2b,20f\n" \ 53617825 include/asm-m68k/uaccess.h Roman Zippel 2006-06-25 220 " .ifnc ""#s3"",""\n" \ 53617825 include/asm-m68k/uaccess.h Roman Zippel 2006-06-25 221 " .long 3b,30f\n" \ 53617825 include/asm-m68k/uaccess.h Roman Zippel 2006-06-25 222 " .endif\n" \ 53617825 include/asm-m68k/uaccess.h Roman Zippel 2006-06-25 223 " .previous\n" \ 53617825 include/asm-m68k/uaccess.h Roman Zippel 2006-06-25 224 "\n" \ 53617825 include/asm-m68k/uaccess.h Roman Zippel 2006-06-25 225 " .section .fixup,"ax"\n" \ 53617825 include/asm-m68k/uaccess.h Roman Zippel 2006-06-25 226 " .even\n" \ 53617825 include/asm-m68k/uaccess.h Roman Zippel 2006-06-25 227 "10: clr."#s1" (%1)+\n" \ 53617825 include/asm-m68k/uaccess.h Roman Zippel 2006-06-25 228 "20: clr."#s2" (%1)+\n" \ 53617825 include/asm-m68k/uaccess.h Roman Zippel 2006-06-25 229 " .ifnc ""#s3"",""\n" \ 53617825 include/asm-m68k/uaccess.h Roman Zippel 2006-06-25 230 "30: clr."#s3" (%1)+\n" \ 53617825 include/asm-m68k/uaccess.h Roman Zippel 2006-06-25 231 " .endif\n" \ 53617825 include/asm-m68k/uaccess.h Roman Zippel 2006-06-25 232 " moveq.l #"#n",%0\n" \ 53617825 include/asm-m68k/uaccess.h Roman Zippel 2006-06-25 233 " jra 4b\n" \ 53617825 include/asm-m68k/uaccess.h Roman Zippel 2006-06-25 234 " .previous\n" \ 53617825 include/asm-m68k/uaccess.h Roman Zippel 2006-06-25 235 : "+d" (res), "+&a" (to), "+a" (from), "=&d" (tmp) \ 53617825 include/asm-m68k/uaccess.h Roman Zippel 2006-06-25 236 : : "memory") 53617825 include/asm-m68k/uaccess.h Roman Zippel 2006-06-25 237 d94af931 include/asm-m68k/uaccess.h Roman Zippel 2006-06-23 238 static __always_inline unsigned long d94af931 include/asm-m68k/uaccess.h Roman Zippel 2006-06-23 239 __constant_copy_from_user(void *to, const void __user *from, unsigned long n) ^1da177e include/asm-m68k/uaccess.h Linus Torvalds 2005-04-16 240 { d94af931 include/asm-m68k/uaccess.h Roman Zippel 2006-06-23 241 unsigned long res = 0, tmp; ^1da177e include/asm-m68k/uaccess.h Linus Torvalds 2005-04-16 242 ^1da177e include/asm-m68k/uaccess.h Linus Torvalds 2005-04-16 243 switch (n) { ^1da177e include/asm-m68k/uaccess.h Linus Torvalds 2005-04-16 244 case 1: b971018b include/asm-m68k/uaccess.h Al Viro 2006-10-11 245 __get_user_asm(res, *(u8 *)to, (u8 __user *)from, u8, b, d, 1); 53617825 include/asm-m68k/uaccess.h Roman Zippel 2006-06-25 246 break; ^1da177e include/asm-m68k/uaccess.h Linus Torvalds 2005-04-16 247 case 2: 631d8b67 arch/m68k/include/asm/uaccess_mm.h Geert Uytterhoeven 2013-06-09 248 __get_user_asm(res, *(u16 *)to, (u16 __user *)from, u16, w, r, 2); 53617825 include/asm-m68k/uaccess.h Roman Zippel 2006-06-25 249 break; 53617825 include/asm-m68k/uaccess.h Roman Zippel 2006-06-25 250 case 3: 53617825 include/asm-m68k/uaccess.h Roman Zippel 2006-06-25 251 __constant_copy_from_user_asm(res, to, from, tmp, 3, w, b,); 53617825 include/asm-m68k/uaccess.h Roman Zippel 2006-06-25 252 break; ^1da177e include/asm-m68k/uaccess.h Linus Torvalds 2005-04-16 253 case 4: b971018b include/asm-m68k/uaccess.h Al Viro 2006-10-11 254 __get_user_asm(res, *(u32 *)to, (u32 __user *)from, u32, l, r, 4); 53617825 include/asm-m68k/uaccess.h Roman Zippel 2006-06-25 255 break; 53617825 include/asm-m68k/uaccess.h Roman Zippel 2006-06-25 256 case 5: 53617825 include/asm-m68k/uaccess.h Roman Zippel 2006-06-25 257 __constant_copy_from_user_asm(res, to, from, tmp, 5, l, b,); 53617825 include/asm-m68k/uaccess.h Roman Zippel 2006-06-25 258 break; 53617825 include/asm-m68k/uaccess.h Roman Zippel 2006-06-25 259 case 6: 53617825 include/asm-m68k/uaccess.h Roman Zippel 2006-06-25 260 __constant_copy_from_user_asm(res, to, from, tmp, 6, l, w,); 53617825 include/asm-m68k/uaccess.h Roman Zippel 2006-06-25 261 break; 53617825 include/asm-m68k/uaccess.h Roman Zippel 2006-06-25 262 case 7: 53617825 include/asm-m68k/uaccess.h Roman Zippel 2006-06-25 263 __constant_copy_from_user_asm(res, to, from, tmp, 7, l, w, b); 53617825 include/asm-m68k/uaccess.h Roman Zippel 2006-06-25 264 break; 53617825 include/asm-m68k/uaccess.h Roman Zippel 2006-06-25 265 case 8: 53617825 include/asm-m68k/uaccess.h Roman Zippel 2006-06-25 266 __constant_copy_from_user_asm(res, to, from, tmp, 8, l, l,); 53617825 include/asm-m68k/uaccess.h Roman Zippel 2006-06-25 267 break; 53617825 include/asm-m68k/uaccess.h Roman Zippel 2006-06-25 268 case 9: 53617825 include/asm-m68k/uaccess.h Roman Zippel 2006-06-25 269 __constant_copy_from_user_asm(res, to, from, tmp, 9, l, l, b); 53617825 include/asm-m68k/uaccess.h Roman Zippel 2006-06-25 270 break; 53617825 include/asm-m68k/uaccess.h Roman Zippel 2006-06-25 271 case 10: 53617825 include/asm-m68k/uaccess.h Roman Zippel 2006-06-25 272 __constant_copy_from_user_asm(res, to, from, tmp, 10, l, l, w); 53617825 include/asm-m68k/uaccess.h Roman Zippel 2006-06-25 273 break; 53617825 include/asm-m68k/uaccess.h Roman Zippel 2006-06-25 274 case 12: 53617825 include/asm-m68k/uaccess.h Roman Zippel 2006-06-25 275 __constant_copy_from_user_asm(res, to, from, tmp, 12, l, l, l); 53617825 include/asm-m68k/uaccess.h Roman Zippel 2006-06-25 276 break; 53617825 include/asm-m68k/uaccess.h Roman Zippel 2006-06-25 277 default: 53617825 include/asm-m68k/uaccess.h Roman Zippel 2006-06-25 278 /* we limit the inlined version to 3 moves */ 53617825 include/asm-m68k/uaccess.h Roman Zippel 2006-06-25 279 return __generic_copy_from_user(to, from, n); d94af931 include/asm-m68k/uaccess.h Roman Zippel 2006-06-23 280 } d94af931 include/asm-m68k/uaccess.h Roman Zippel 2006-06-23 281 d94af931 include/asm-m68k/uaccess.h Roman Zippel 2006-06-23 282 return res; d94af931 include/asm-m68k/uaccess.h Roman Zippel 2006-06-23 283 } ^1da177e include/asm-m68k/uaccess.h Linus Torvalds 2005-04-16 284 53617825 include/asm-m68k/uaccess.h Roman Zippel 2006-06-25 285 #define __constant_copy_to_user_asm(res, to, from, tmp, n, s1, s2, s3) \ 53617825 include/asm-m68k/uaccess.h Roman Zippel 2006-06-25 286 asm volatile ("\n" \ 53617825 include/asm-m68k/uaccess.h Roman Zippel 2006-06-25 287 " move."#s1" (%2)+,%3\n" \ e08d703c arch/m68k/include/asm/uaccess_mm.h Greg Ungerer 2011-10-14 288 "11: "MOVES"."#s1" %3,(%1)+\n" \ 53617825 include/asm-m68k/uaccess.h Roman Zippel 2006-06-25 289 "12: move."#s2" (%2)+,%3\n" \ e08d703c arch/m68k/include/asm/uaccess_mm.h Greg Ungerer 2011-10-14 290 "21: "MOVES"."#s2" %3,(%1)+\n" \ 53617825 include/asm-m68k/uaccess.h Roman Zippel 2006-06-25 291 "22:\n" \ 53617825 include/asm-m68k/uaccess.h Roman Zippel 2006-06-25 292 " .ifnc ""#s3"",""\n" \ 53617825 include/asm-m68k/uaccess.h Roman Zippel 2006-06-25 293 " move."#s3" (%2)+,%3\n" \ e08d703c arch/m68k/include/asm/uaccess_mm.h Greg Ungerer 2011-10-14 294 "31: "MOVES"."#s3" %3,(%1)+\n" \ 53617825 include/asm-m68k/uaccess.h Roman Zippel 2006-06-25 295 "32:\n" \ 53617825 include/asm-m68k/uaccess.h Roman Zippel 2006-06-25 296 " .endif\n" \ 53617825 include/asm-m68k/uaccess.h Roman Zippel 2006-06-25 297 "4:\n" \ 53617825 include/asm-m68k/uaccess.h Roman Zippel 2006-06-25 298 "\n" \ 53617825 include/asm-m68k/uaccess.h Roman Zippel 2006-06-25 299 " .section __ex_table,"a"\n" \ 53617825 include/asm-m68k/uaccess.h Roman Zippel 2006-06-25 300 " .align 4\n" \ 53617825 include/asm-m68k/uaccess.h Roman Zippel 2006-06-25 301 " .long 11b,5f\n" \ 53617825 include/asm-m68k/uaccess.h Roman Zippel 2006-06-25 302 " .long 12b,5f\n" \ 53617825 include/asm-m68k/uaccess.h Roman Zippel 2006-06-25 303 " .long 21b,5f\n" \ 53617825 include/asm-m68k/uaccess.h Roman Zippel 2006-06-25 304 " .long 22b,5f\n" \ 53617825 include/asm-m68k/uaccess.h Roman Zippel 2006-06-25 305 " .ifnc ""#s3"",""\n" \ 53617825 include/asm-m68k/uaccess.h Roman Zippel 2006-06-25 306 " .long 31b,5f\n" \ 53617825 include/asm-m68k/uaccess.h Roman Zippel 2006-06-25 307 " .long 32b,5f\n" \ 53617825 include/asm-m68k/uaccess.h Roman Zippel 2006-06-25 308 " .endif\n" \ 53617825 include/asm-m68k/uaccess.h Roman Zippel 2006-06-25 309 " .previous\n" \ 53617825 include/asm-m68k/uaccess.h Roman Zippel 2006-06-25 310 "\n" \ 53617825 include/asm-m68k/uaccess.h Roman Zippel 2006-06-25 311 " .section .fixup,"ax"\n" \ 53617825 include/asm-m68k/uaccess.h Roman Zippel 2006-06-25 312 " .even\n" \ 53617825 include/asm-m68k/uaccess.h Roman Zippel 2006-06-25 313 "5: moveq.l #"#n",%0\n" \ 53617825 include/asm-m68k/uaccess.h Roman Zippel 2006-06-25 314 " jra 4b\n" \ 53617825 include/asm-m68k/uaccess.h Roman Zippel 2006-06-25 315 " .previous\n" \ 53617825 include/asm-m68k/uaccess.h Roman Zippel 2006-06-25 316 : "+d" (res), "+a" (to), "+a" (from), "=&d" (tmp) \ 53617825 include/asm-m68k/uaccess.h Roman Zippel 2006-06-25 317 : : "memory") 53617825 include/asm-m68k/uaccess.h Roman Zippel 2006-06-25 318 d94af931 include/asm-m68k/uaccess.h Roman Zippel 2006-06-23 319 static __always_inline unsigned long 11c40f8a include/asm-m68k/uaccess.h Al Viro 2006-01-12 320 __constant_copy_to_user(void __user *to, const void *from, unsigned long n) ^1da177e include/asm-m68k/uaccess.h Linus Torvalds 2005-04-16 321 { d94af931 include/asm-m68k/uaccess.h Roman Zippel 2006-06-23 322 unsigned long res = 0, tmp; d94af931 include/asm-m68k/uaccess.h Roman Zippel 2006-06-23 323 ^1da177e include/asm-m68k/uaccess.h Linus Torvalds 2005-04-16 324 switch (n) { ^1da177e include/asm-m68k/uaccess.h Linus Torvalds 2005-04-16 325 case 1: b971018b include/asm-m68k/uaccess.h Al Viro 2006-10-11 326 __put_user_asm(res, *(u8 *)from, (u8 __user *)to, b, d, 1); 53617825 include/asm-m68k/uaccess.h Roman Zippel 2006-06-25 327 break; ^1da177e include/asm-m68k/uaccess.h Linus Torvalds 2005-04-16 328 case 2: 631d8b67 arch/m68k/include/asm/uaccess_mm.h Geert Uytterhoeven 2013-06-09 329 __put_user_asm(res, *(u16 *)from, (u16 __user *)to, w, r, 2); 53617825 include/asm-m68k/uaccess.h Roman Zippel 2006-06-25 330 break; 53617825 include/asm-m68k/uaccess.h Roman Zippel 2006-06-25 331 case 3: 53617825 include/asm-m68k/uaccess.h Roman Zippel 2006-06-25 332 __constant_copy_to_user_asm(res, to, from, tmp, 3, w, b,); 53617825 include/asm-m68k/uaccess.h Roman Zippel 2006-06-25 333 break; ^1da177e include/asm-m68k/uaccess.h Linus Torvalds 2005-04-16 334 case 4: b971018b include/asm-m68k/uaccess.h Al Viro 2006-10-11 335 __put_user_asm(res, *(u32 *)from, (u32 __user *)to, l, r, 4); 53617825 include/asm-m68k/uaccess.h Roman Zippel 2006-06-25 336 break; 53617825 include/asm-m68k/uaccess.h Roman Zippel 2006-06-25 337 case 5: 53617825 include/asm-m68k/uaccess.h Roman Zippel 2006-06-25 338 __constant_copy_to_user_asm(res, to, from, tmp, 5, l, b,); 53617825 include/asm-m68k/uaccess.h Roman Zippel 2006-06-25 339 break; 53617825 include/asm-m68k/uaccess.h Roman Zippel 2006-06-25 340 case 6: 53617825 include/asm-m68k/uaccess.h Roman Zippel 2006-06-25 341 __constant_copy_to_user_asm(res, to, from, tmp, 6, l, w,); 53617825 include/asm-m68k/uaccess.h Roman Zippel 2006-06-25 342 break; 53617825 include/asm-m68k/uaccess.h Roman Zippel 2006-06-25 343 case 7: 53617825 include/asm-m68k/uaccess.h Roman Zippel 2006-06-25 344 __constant_copy_to_user_asm(res, to, from, tmp, 7, l, w, b); 53617825 include/asm-m68k/uaccess.h Roman Zippel 2006-06-25 345 break; 53617825 include/asm-m68k/uaccess.h Roman Zippel 2006-06-25 346 case 8: 53617825 include/asm-m68k/uaccess.h Roman Zippel 2006-06-25 347 __constant_copy_to_user_asm(res, to, from, tmp, 8, l, l,); 53617825 include/asm-m68k/uaccess.h Roman Zippel 2006-06-25 348 break; 53617825 include/asm-m68k/uaccess.h Roman Zippel 2006-06-25 349 case 9: 53617825 include/asm-m68k/uaccess.h Roman Zippel 2006-06-25 350 __constant_copy_to_user_asm(res, to, from, tmp, 9, l, l, b); 53617825 include/asm-m68k/uaccess.h Roman Zippel 2006-06-25 351 break; 53617825 include/asm-m68k/uaccess.h Roman Zippel 2006-06-25 352 case 10: 53617825 include/asm-m68k/uaccess.h Roman Zippel 2006-06-25 353 __constant_copy_to_user_asm(res, to, from, tmp, 10, l, l, w); 53617825 include/asm-m68k/uaccess.h Roman Zippel 2006-06-25 354 break; 53617825 include/asm-m68k/uaccess.h Roman Zippel 2006-06-25 355 case 12: 53617825 include/asm-m68k/uaccess.h Roman Zippel 2006-06-25 356 __constant_copy_to_user_asm(res, to, from, tmp, 12, l, l, l); 53617825 include/asm-m68k/uaccess.h Roman Zippel 2006-06-25 357 break; 53617825 include/asm-m68k/uaccess.h Roman Zippel 2006-06-25 358 default: 53617825 include/asm-m68k/uaccess.h Roman Zippel 2006-06-25 359 /* limit the inlined version to 3 moves */ 53617825 include/asm-m68k/uaccess.h Roman Zippel 2006-06-25 360 return __generic_copy_to_user(to, from, n); d94af931 include/asm-m68k/uaccess.h Roman Zippel 2006-06-23 361 } d94af931 include/asm-m68k/uaccess.h Roman Zippel 2006-06-23 362 d94af931 include/asm-m68k/uaccess.h Roman Zippel 2006-06-23 363 return res; ^1da177e include/asm-m68k/uaccess.h Linus Torvalds 2005-04-16 364 } ^1da177e include/asm-m68k/uaccess.h Linus Torvalds 2005-04-16 365 d94af931 include/asm-m68k/uaccess.h Roman Zippel 2006-06-23 366 #define __copy_from_user(to, from, n) \ ^1da177e include/asm-m68k/uaccess.h Linus Torvalds 2005-04-16 367 (__builtin_constant_p(n) ? \ ^1da177e include/asm-m68k/uaccess.h Linus Torvalds 2005-04-16 @368 __constant_copy_from_user(to, from, n) : \ ^1da177e include/asm-m68k/uaccess.h Linus Torvalds 2005-04-16 @369 __generic_copy_from_user(to, from, n)) ^1da177e include/asm-m68k/uaccess.h Linus Torvalds 2005-04-16 370 d94af931 include/asm-m68k/uaccess.h Roman Zippel 2006-06-23 371 #define __copy_to_user(to, from, n) \ ^1da177e include/asm-m68k/uaccess.h Linus Torvalds 2005-04-16 372 (__builtin_constant_p(n) ? \ ^1da177e include/asm-m68k/uaccess.h Linus Torvalds 2005-04-16 @373 __constant_copy_to_user(to, from, n) : \ ^1da177e include/asm-m68k/uaccess.h Linus Torvalds 2005-04-16 @374 __generic_copy_to_user(to, from, n)) ^1da177e include/asm-m68k/uaccess.h Linus Torvalds 2005-04-16 375 d94af931 include/asm-m68k/uaccess.h Roman Zippel 2006-06-23 376 #define __copy_to_user_inatomic __copy_to_user d94af931 include/asm-m68k/uaccess.h Roman Zippel 2006-06-23 377 #define __copy_from_user_inatomic __copy_from_user ^1da177e include/asm-m68k/uaccess.h Linus Torvalds 2005-04-16 378 d94af931 include/asm-m68k/uaccess.h Roman Zippel 2006-06-23 @379 #define copy_from_user(to, from, n) __copy_from_user(to, from, n) d94af931 include/asm-m68k/uaccess.h Roman Zippel 2006-06-23 @380 #define copy_to_user(to, from, n) __copy_to_user(to, from, n) ^1da177e include/asm-m68k/uaccess.h Linus Torvalds 2005-04-16 381 d8ce7263 arch/m68k/include/asm/uaccess_mm.h Geert Uytterhoeven 2012-05-29 382 #define user_addr_max() \ d8ce7263 arch/m68k/include/asm/uaccess_mm.h Geert Uytterhoeven 2012-05-29 383 (segment_eq(get_fs(), USER_DS) ? TASK_SIZE : ~0UL)
:::::: The code at line 368 was first introduced by commit :::::: 1da177e4c3f41524e886b7f1b8a0c1fc7321cac2 Linux-2.6.12-rc2
:::::: TO: Linus Torvalds torvalds@ppc970.osdl.org :::::: CC: Linus Torvalds torvalds@ppc970.osdl.org
--- 0-DAY kernel test infrastructure Open Source Technology Center https://lists.01.org/pipermail/kbuild-all Intel Corporation
On Sat, 2016-03-19 at 01:39 +0800, kbuild test robot wrote:
Hi Joe,
[auto build test WARNING on drm/drm-next] [also build test WARNING on next-20160318] [cannot apply to v4.5] [if your patch is applied to the wrong git tree, please drop us a note to help improving the system]
Thanks, but this depends on Gustavo's patches too.
Hi Joe,
[auto build test ERROR on drm/drm-next] [also build test ERROR on next-20160318] [cannot apply to v4.5] [if your patch is applied to the wrong git tree, please drop us a note to help improving the system]
url: https://github.com/0day-ci/linux/commits/Joe-Perches/gpu-drm-Use-u64_to_user... base: git://people.freedesktop.org/~airlied/linux.git drm-next config: xtensa-allmodconfig (attached as .config) reproduce: wget https://git.kernel.org/cgit/linux/kernel/git/wfg/lkp-tests.git/plain/sbin/ma... -O ~/bin/make.cross chmod +x ~/bin/make.cross # save the attached .config to linux build tree make.cross ARCH=xtensa
All error/warnings (new ones prefixed by >>):
drivers/gpu/drm/vc4/vc4_bo.c: In function 'vc4_create_shader_bo_ioctl':
drivers/gpu/drm/vc4/vc4_bo.c:502:2: error: implicit declaration of function 'u64_to_user_ptr' [-Werror=implicit-function-declaration]
if (copy_from_user(bo->base.vaddr, ^ In file included from include/linux/uaccess.h:5:0, from include/linux/highmem.h:8, from include/drm/drmP.h:40, from drivers/gpu/drm/vc4/vc4_drv.h:9, from drivers/gpu/drm/vc4/vc4_bo.c:21:
arch/xtensa/include/asm/uaccess.h:429:37: warning: passing argument 2 of '__generic_copy_from_user' makes pointer from integer without a cast
#define copy_from_user(to, from, n) __generic_copy_from_user((to), (from), (n)) ^
drivers/gpu/drm/vc4/vc4_bo.c:502:6: note: in expansion of macro 'copy_from_user'
if (copy_from_user(bo->base.vaddr, ^ arch/xtensa/include/asm/uaccess.h:418:1: note: expected 'const void *' but argument is of type 'int' __generic_copy_from_user(void *to, const void *from, unsigned long n) ^ cc1: some warnings being treated as errors -- drivers/gpu/drm/vc4/vc4_gem.c: In function 'vc4_get_hang_state_ioctl':
drivers/gpu/drm/vc4/vc4_gem.c:123:2: error: implicit declaration of function 'u64_to_user_ptr' [-Werror=implicit-function-declaration]
if (copy_to_user(u64_to_user_ptr(get_state->bo), ^ In file included from include/linux/uaccess.h:5:0, from include/linux/highmem.h:8, from include/drm/drmP.h:40, from drivers/gpu/drm/vc4/vc4_drv.h:9, from drivers/gpu/drm/vc4/vc4_gem.c:31:
arch/xtensa/include/asm/uaccess.h:428:35: warning: passing argument 1 of '__generic_copy_to_user' makes pointer from integer without a cast
#define copy_to_user(to, from, n) __generic_copy_to_user((to), (from), (n)) ^
drivers/gpu/drm/vc4/vc4_gem.c:123:6: note: in expansion of macro 'copy_to_user'
if (copy_to_user(u64_to_user_ptr(get_state->bo), ^ arch/xtensa/include/asm/uaccess.h:409:1: note: expected 'void *' but argument is of type 'int' __generic_copy_to_user(void *to, const void *from, unsigned long n) ^ drivers/gpu/drm/vc4/vc4_gem.c: In function 'vc4_cl_lookup_bos':
arch/xtensa/include/asm/uaccess.h:429:37: warning: passing argument 2 of '__generic_copy_from_user' makes pointer from integer without a cast
#define copy_from_user(to, from, n) __generic_copy_from_user((to), (from), (n)) ^
drivers/gpu/drm/vc4/vc4_gem.c:552:8: note: in expansion of macro 'copy_from_user'
ret = copy_from_user(handles, ^ arch/xtensa/include/asm/uaccess.h:418:1: note: expected 'const void *' but argument is of type 'int' __generic_copy_from_user(void *to, const void *from, unsigned long n) ^ drivers/gpu/drm/vc4/vc4_gem.c: In function 'vc4_get_bcl':
arch/xtensa/include/asm/uaccess.h:429:37: warning: passing argument 2 of '__generic_copy_from_user' makes pointer from integer without a cast
#define copy_from_user(to, from, n) __generic_copy_from_user((to), (from), (n)) ^ drivers/gpu/drm/vc4/vc4_gem.c:626:6: note: in expansion of macro 'copy_from_user' if (copy_from_user(bin, ^ arch/xtensa/include/asm/uaccess.h:418:1: note: expected 'const void *' but argument is of type 'int' __generic_copy_from_user(void *to, const void *from, unsigned long n) ^
arch/xtensa/include/asm/uaccess.h:429:37: warning: passing argument 2 of '__generic_copy_from_user' makes pointer from integer without a cast
#define copy_from_user(to, from, n) __generic_copy_from_user((to), (from), (n)) ^ drivers/gpu/drm/vc4/vc4_gem.c:633:6: note: in expansion of macro 'copy_from_user' if (copy_from_user(exec->shader_rec_u, ^ arch/xtensa/include/asm/uaccess.h:418:1: note: expected 'const void *' but argument is of type 'int' __generic_copy_from_user(void *to, const void *from, unsigned long n) ^
arch/xtensa/include/asm/uaccess.h:429:37: warning: passing argument 2 of '__generic_copy_from_user' makes pointer from integer without a cast
#define copy_from_user(to, from, n) __generic_copy_from_user((to), (from), (n)) ^ drivers/gpu/drm/vc4/vc4_gem.c:640:6: note: in expansion of macro 'copy_from_user' if (copy_from_user(exec->uniforms_u, ^ arch/xtensa/include/asm/uaccess.h:418:1: note: expected 'const void *' but argument is of type 'int' __generic_copy_from_user(void *to, const void *from, unsigned long n) ^ cc1: some warnings being treated as errors -- drivers/gpu/drm/virtio/virtgpu_ioctl.c: In function 'virtio_gpu_execbuffer':
drivers/gpu/drm/virtio/virtgpu_ioctl.c:126:3: error: implicit declaration of function 'u64_to_user_ptr' [-Werror=implicit-function-declaration]
user_bo_handles = u64_to_user_ptr(exbuf->bo_handles); ^
drivers/gpu/drm/virtio/virtgpu_ioctl.c:126:19: warning: assignment makes pointer from integer without a cast
user_bo_handles = u64_to_user_ptr(exbuf->bo_handles); ^ In file included from include/linux/uaccess.h:5:0, from include/linux/highmem.h:8, from include/drm/drmP.h:40, from drivers/gpu/drm/virtio/virtgpu_ioctl.c:28:
arch/xtensa/include/asm/uaccess.h:429:37: warning: passing argument 2 of '__generic_copy_from_user' makes pointer from integer without a cast
#define copy_from_user(to, from, n) __generic_copy_from_user((to), (from), (n)) ^
drivers/gpu/drm/virtio/virtgpu_ioctl.c:161:6: note: in expansion of macro 'copy_from_user'
if (copy_from_user(buf, u64_to_user_ptr(exbuf->command), exbuf->size)) { ^ arch/xtensa/include/asm/uaccess.h:418:1: note: expected 'const void *' but argument is of type 'int' __generic_copy_from_user(void *to, const void *from, unsigned long n) ^ cc1: some warnings being treated as errors
vim +/u64_to_user_ptr +502 drivers/gpu/drm/vc4/vc4_bo.c
463873d5 Eric Anholt 2015-11-30 496 } 463873d5 Eric Anholt 2015-11-30 497 463873d5 Eric Anholt 2015-11-30 498 bo = vc4_bo_create(dev, args->size, true); 2c68f1fc Eric Anholt 2016-01-25 499 if (IS_ERR(bo)) 2c68f1fc Eric Anholt 2016-01-25 500 return PTR_ERR(bo); 463873d5 Eric Anholt 2015-11-30 501 585cb132 Dan Carpenter 2016-03-08 @502 if (copy_from_user(bo->base.vaddr, 3f3044e5 Joe Perches 2016-03-18 503 u64_to_user_ptr(args->data), 585cb132 Dan Carpenter 2016-03-08 504 args->size)) { 585cb132 Dan Carpenter 2016-03-08 505 ret = -EFAULT;
:::::: The code at line 502 was first introduced by commit :::::: 585cb132a48190b554aecda2ebc3e2911fcbb665 drm/vc4: Return -EFAULT on copy_from_user() failure
:::::: TO: Dan Carpenter dan.carpenter@oracle.com :::::: CC: Eric Anholt eric@anholt.net
--- 0-DAY kernel test infrastructure Open Source Technology Center https://lists.01.org/pipermail/kbuild-all Intel Corporation
Hi Joe,
[auto build test WARNING on drm/drm-next] [also build test WARNING on next-20160318] [cannot apply to v4.5] [if your patch is applied to the wrong git tree, please drop us a note to help improving the system]
url: https://github.com/0day-ci/linux/commits/Joe-Perches/gpu-drm-Use-u64_to_user... base: git://people.freedesktop.org/~airlied/linux.git drm-next config: mips-allmodconfig (attached as .config) reproduce: wget https://git.kernel.org/cgit/linux/kernel/git/wfg/lkp-tests.git/plain/sbin/ma... -O ~/bin/make.cross chmod +x ~/bin/make.cross # save the attached .config to linux build tree make.cross ARCH=mips
All warnings (new ones prefixed by >>):
In file included from include/linux/uaccess.h:5:0, from include/linux/highmem.h:8, from include/drm/drmP.h:40, from drivers/gpu/drm/vc4/vc4_drv.h:9, from drivers/gpu/drm/vc4/vc4_bo.c:21: drivers/gpu/drm/vc4/vc4_bo.c: In function 'vc4_create_shader_bo_ioctl': drivers/gpu/drm/vc4/vc4_bo.c:503:7: error: implicit declaration of function 'u64_to_user_ptr' [-Werror=implicit-function-declaration] u64_to_user_ptr(args->data), ^ arch/mips/include/asm/uaccess.h:1161:15: note: in definition of macro 'copy_from_user' __cu_from = (from); \ ^
arch/mips/include/asm/uaccess.h:1161:12: warning: assignment makes pointer from integer without a cast [-Wint-conversion]
__cu_from = (from); \ ^ drivers/gpu/drm/vc4/vc4_bo.c:502:6: note: in expansion of macro 'copy_from_user' if (copy_from_user(bo->base.vaddr, ^ cc1: some warnings being treated as errors -- In file included from arch/mips/include/asm/module.h:6:0, from include/linux/module.h:24, from drivers/gpu/drm/vc4/vc4_gem.c:24: drivers/gpu/drm/vc4/vc4_gem.c: In function 'vc4_get_hang_state_ioctl': drivers/gpu/drm/vc4/vc4_gem.c:123:19: error: implicit declaration of function 'u64_to_user_ptr' [-Werror=implicit-function-declaration] if (copy_to_user(u64_to_user_ptr(get_state->bo), ^ arch/mips/include/asm/uaccess.h:930:13: note: in definition of macro 'copy_to_user' __cu_to = (to); \ ^ arch/mips/include/asm/uaccess.h:930:10: warning: assignment makes pointer from integer without a cast [-Wint-conversion] __cu_to = (to); \ ^ drivers/gpu/drm/vc4/vc4_gem.c:123:6: note: in expansion of macro 'copy_to_user' if (copy_to_user(u64_to_user_ptr(get_state->bo), ^ drivers/gpu/drm/vc4/vc4_gem.c: In function 'vc4_cl_lookup_bos':
arch/mips/include/asm/uaccess.h:1161:12: warning: assignment makes pointer from integer without a cast [-Wint-conversion]
__cu_from = (from); \ ^ drivers/gpu/drm/vc4/vc4_gem.c:552:8: note: in expansion of macro 'copy_from_user' ret = copy_from_user(handles, ^ drivers/gpu/drm/vc4/vc4_gem.c: In function 'vc4_get_bcl':
arch/mips/include/asm/uaccess.h:1161:12: warning: assignment makes pointer from integer without a cast [-Wint-conversion]
__cu_from = (from); \ ^ drivers/gpu/drm/vc4/vc4_gem.c:626:6: note: in expansion of macro 'copy_from_user' if (copy_from_user(bin, ^
arch/mips/include/asm/uaccess.h:1161:12: warning: assignment makes pointer from integer without a cast [-Wint-conversion]
__cu_from = (from); \ ^ drivers/gpu/drm/vc4/vc4_gem.c:633:6: note: in expansion of macro 'copy_from_user' if (copy_from_user(exec->shader_rec_u, ^
arch/mips/include/asm/uaccess.h:1161:12: warning: assignment makes pointer from integer without a cast [-Wint-conversion]
__cu_from = (from); \ ^ drivers/gpu/drm/vc4/vc4_gem.c:640:6: note: in expansion of macro 'copy_from_user' if (copy_from_user(exec->uniforms_u, ^ cc1: some warnings being treated as errors
vim +1161 arch/mips/include/asm/uaccess.h
^1da177e include/asm-mips/uaccess.h Linus Torvalds 2005-04-16 1145 * ^1da177e include/asm-mips/uaccess.h Linus Torvalds 2005-04-16 1146 * Copy data from user space to kernel space. ^1da177e include/asm-mips/uaccess.h Linus Torvalds 2005-04-16 1147 * ^1da177e include/asm-mips/uaccess.h Linus Torvalds 2005-04-16 1148 * Returns number of bytes that could not be copied. ^1da177e include/asm-mips/uaccess.h Linus Torvalds 2005-04-16 1149 * On success, this will be zero. ^1da177e include/asm-mips/uaccess.h Linus Torvalds 2005-04-16 1150 * ^1da177e include/asm-mips/uaccess.h Linus Torvalds 2005-04-16 1151 * If some data could not be copied, this function will pad the copied ^1da177e include/asm-mips/uaccess.h Linus Torvalds 2005-04-16 1152 * data to the requested size using zero bytes. ^1da177e include/asm-mips/uaccess.h Linus Torvalds 2005-04-16 1153 */ ^1da177e include/asm-mips/uaccess.h Linus Torvalds 2005-04-16 1154 #define copy_from_user(to, from, n) \ ^1da177e include/asm-mips/uaccess.h Linus Torvalds 2005-04-16 1155 ({ \ ^1da177e include/asm-mips/uaccess.h Linus Torvalds 2005-04-16 1156 void *__cu_to; \ fe00f943 include/asm-mips/uaccess.h Ralf Baechle 2005-03-01 1157 const void __user *__cu_from; \ ^1da177e include/asm-mips/uaccess.h Linus Torvalds 2005-04-16 1158 long __cu_len; \ ^1da177e include/asm-mips/uaccess.h Linus Torvalds 2005-04-16 1159 \ ^1da177e include/asm-mips/uaccess.h Linus Torvalds 2005-04-16 1160 __cu_to = (to); \ ^1da177e include/asm-mips/uaccess.h Linus Torvalds 2005-04-16 @1161 __cu_from = (from); \ ^1da177e include/asm-mips/uaccess.h Linus Torvalds 2005-04-16 1162 __cu_len = (n); \ 12060666 arch/mips/include/asm/uaccess.h Paul Burton 2015-05-24 1163 if (eva_kernel_access()) { \ 05c65160 arch/mips/include/asm/uaccess.h Markos Chandras 2013-12-11 1164 __cu_len = __invoke_copy_from_kernel(__cu_to, \ 05c65160 arch/mips/include/asm/uaccess.h Markos Chandras 2013-12-11 1165 __cu_from, \ 05c65160 arch/mips/include/asm/uaccess.h Markos Chandras 2013-12-11 1166 __cu_len); \ 05c65160 arch/mips/include/asm/uaccess.h Markos Chandras 2013-12-11 1167 } else { \ ef41f460 arch/mips/include/asm/uaccess.h Ralf Baechle 2009-04-28 1168 if (access_ok(VERIFY_READ, __cu_from, __cu_len)) { \ ef41f460 arch/mips/include/asm/uaccess.h Ralf Baechle 2009-04-28 1169 might_fault(); \
:::::: The code at line 1161 was first introduced by commit :::::: 1da177e4c3f41524e886b7f1b8a0c1fc7321cac2 Linux-2.6.12-rc2
:::::: TO: Linus Torvalds torvalds@ppc970.osdl.org :::::: CC: Linus Torvalds torvalds@ppc970.osdl.org
--- 0-DAY kernel test infrastructure Open Source Technology Center https://lists.01.org/pipermail/kbuild-all Intel Corporation
From: Gustavo Padovan gustavo.padovan@collabora.co.uk
Change SYNC_IOC_FILE_INFO (former SYNC_IOC_FENCE_INFO) behaviour to avoid future API breaks and optimize buffer allocation.
Now num_fences can be filled by the caller to inform how many fences it wants to retrieve from the kernel. If the num_fences passed is greater than zero info->sync_fence_info should point to a buffer with enough space to fit all fences.
However if num_fences passed to the kernel is 0, the kernel will reply with number of fences of the sync_file.
Sending first an ioctl with num_fences = 0 can optimize buffer allocation, in a first call with num_fences = 0 userspace will receive the actual number of fences in the num_fences filed.
Then it can allocate a buffer with the correct size on sync_fence_info and call SYNC_IOC_FILE_INFO again, but now with the actual value of num_fences in the sync_file.
info->sync_fence_info was converted to __u64 pointer to prevent 32bit compatibility issues. And a flags member was added.
An example userspace code for the later would be:
struct sync_file_info *info; int err, size, num_fences;
info = malloc(sizeof(*info));
info.flags = 0; err = ioctl(fd, SYNC_IOC_FILE_INFO, info); num_fences = info->num_fences;
if (num_fences) { info.flags = 0; size = sizeof(struct sync_fence_info) * num_fences; info->num_fences = num_fences; info->sync_fence_info = (uint64_t) calloc(num_fences, sizeof(struct sync_fence_info));
err = ioctl(fd, SYNC_IOC_FILE_INFO, info); }
Finally the IOCTLs numbers were changed to avoid any potential old userspace running the old API to get weird errors. Changing the opcodes will make them fail right away. This is just a precaution, there no upstream users of these interfaces yet and the only user is Android, but we don't expect anyone trying to run android userspace and all it dependencies on top of upstream kernels.
Signed-off-by: Gustavo Padovan gustavo.padovan@collabora.co.uk Reviewed-by: Maarten Lankhorst maarten.lankhorst@linux.intel.com Acked-by: Greg Hackmann ghackmann@google.com Acked-by: Rob Clark robdclark@gmail.com Acked-by: Daniel Vetter daniel.vetter@ffwll.ch
--- v2: fix fence_info memory leak
v3: Comments from Emil Velikov - improve commit message - remove __u64 cast - remove check for output fields in file_info - clean up sync_fill_fence_info()
Comments from Maarten Lankhorst - remove in.num_fences && !in.sync_fence_info check - remove info->len and use only num_fences to calculate size
Comments from Dan Carpenter - fix info->sync_fence_info documentation
v4: remove allocated struct sync_file_info (comment from Maarten)
v5: merge all commits that were changing the ABI
v6: fix -Wint-to-pointer-cast error on info.sync_fence_info --- drivers/staging/android/sync.c | 76 ++++++++++++++++++++----------------- drivers/staging/android/uapi/sync.h | 36 +++++++++++++----- 2 files changed, 67 insertions(+), 45 deletions(-)
diff --git a/drivers/staging/android/sync.c b/drivers/staging/android/sync.c index 3a8f210..f9c6094 100644 --- a/drivers/staging/android/sync.c +++ b/drivers/staging/android/sync.c @@ -445,6 +445,11 @@ static long sync_file_ioctl_merge(struct sync_file *sync_file, goto err_put_fd; }
+ if (data.flags || data.pad) { + err = -EINVAL; + goto err_put_fd; + } + fence2 = sync_file_fdget(data.fd2); if (!fence2) { err = -ENOENT; @@ -479,13 +484,9 @@ err_put_fd: return err; }
-static int sync_fill_fence_info(struct fence *fence, void *data, int size) +static void sync_fill_fence_info(struct fence *fence, + struct sync_fence_info *info) { - struct sync_fence_info *info = data; - - if (size < sizeof(*info)) - return -ENOMEM; - strlcpy(info->obj_name, fence->ops->get_timeline_name(fence), sizeof(info->obj_name)); strlcpy(info->driver_name, fence->ops->get_driver_name(fence), @@ -495,58 +496,63 @@ static int sync_fill_fence_info(struct fence *fence, void *data, int size) else info->status = 0; info->timestamp_ns = ktime_to_ns(fence->timestamp); - - return sizeof(*info); }
static long sync_file_ioctl_fence_info(struct sync_file *sync_file, unsigned long arg) { - struct sync_file_info *info; + struct sync_file_info info; + struct sync_fence_info *fence_info = NULL; __u32 size; - __u32 len = 0; int ret, i;
- if (copy_from_user(&size, (void __user *)arg, sizeof(size))) + if (copy_from_user(&info, (void __user *)arg, sizeof(info))) return -EFAULT;
- if (size < sizeof(struct sync_file_info)) + if (info.flags || info.pad) return -EINVAL;
- if (size > 4096) - size = 4096; - - info = kzalloc(size, GFP_KERNEL); - if (!info) - return -ENOMEM; - - strlcpy(info->name, sync_file->name, sizeof(info->name)); - info->status = atomic_read(&sync_file->status); - if (info->status >= 0) - info->status = !info->status; - - len = sizeof(struct sync_file_info); + /* + * Passing num_fences = 0 means that userspace doesn't want to + * retrieve any sync_fence_info. If num_fences = 0 we skip filling + * sync_fence_info and return the actual number of fences on + * info->num_fences. + */ + if (!info.num_fences) + goto no_fences;
- for (i = 0; i < sync_file->num_fences; ++i) { - struct fence *fence = sync_file->cbs[i].fence; + if (info.num_fences < sync_file->num_fences) + return -EINVAL;
- ret = sync_fill_fence_info(fence, (u8 *)info + len, size - len); + size = sync_file->num_fences * sizeof(*fence_info); + fence_info = kzalloc(size, GFP_KERNEL); + if (!fence_info) + return -ENOMEM;
- if (ret < 0) - goto out; + for (i = 0; i < sync_file->num_fences; ++i) + sync_fill_fence_info(sync_file->cbs[i].fence, &fence_info[i]);
- len += ret; + if (copy_to_user(u64_to_user_ptr(info.sync_fence_info), fence_info, + size)) { + ret = -EFAULT; + goto out; }
- info->len = len; +no_fences: + strlcpy(info.name, sync_file->name, sizeof(info.name)); + info.status = atomic_read(&sync_file->status); + if (info.status >= 0) + info.status = !info.status; + + info.num_fences = sync_file->num_fences;
- if (copy_to_user((void __user *)arg, info, len)) + if (copy_to_user((void __user *)arg, &info, sizeof(info))) ret = -EFAULT; else ret = 0;
out: - kfree(info); + kfree(fence_info);
return ret; } @@ -560,7 +566,7 @@ static long sync_file_ioctl(struct file *file, unsigned int cmd, case SYNC_IOC_MERGE: return sync_file_ioctl_merge(sync_file, arg);
- case SYNC_IOC_FENCE_INFO: + case SYNC_IOC_FILE_INFO: return sync_file_ioctl_fence_info(sync_file, arg);
default: diff --git a/drivers/staging/android/uapi/sync.h b/drivers/staging/android/uapi/sync.h index 4467c76..fbadb8a 100644 --- a/drivers/staging/android/uapi/sync.h +++ b/drivers/staging/android/uapi/sync.h @@ -16,14 +16,18 @@
/** * struct sync_merge_data - data passed to merge ioctl - * @fd2: file descriptor of second fence * @name: name of new fence + * @fd2: file descriptor of second fence * @fence: returns the fd of the new fence to userspace + * @flags: merge_data flags + * @pad: padding for 64-bit alignment, should always be zero */ struct sync_merge_data { - __s32 fd2; char name[32]; + __s32 fd2; __s32 fence; + __u32 flags; + __u32 pad; };
/** @@ -31,42 +35,54 @@ struct sync_merge_data { * @obj_name: name of parent sync_timeline * @driver_name: name of driver implementing the parent * @status: status of the fence 0:active 1:signaled <0:error + * @flags: fence_info flags * @timestamp_ns: timestamp of status change in nanoseconds */ struct sync_fence_info { char obj_name[32]; char driver_name[32]; __s32 status; + __u32 flags; __u64 timestamp_ns; };
/** * struct sync_file_info - data returned from fence info ioctl - * @len: ioctl caller writes the size of the buffer its passing in. - * ioctl returns length of sync_file_info returned to - * userspace including pt_info. * @name: name of fence * @status: status of fence. 1: signaled 0:active <0:error - * @sync_fence_info: array of sync_fence_info for every fence in the sync_file + * @flags: sync_file_info flags + * @num_fences number of fences in the sync_file + * @pad: padding for 64-bit alignment, should always be zero + * @sync_fence_info: pointer to array of structs sync_fence_info with all + * fences in the sync_file */ struct sync_file_info { - __u32 len; char name[32]; __s32 status; + __u32 flags; + __u32 num_fences; + __u32 pad;
- __u8 sync_fence_info[0]; + __u64 sync_fence_info; };
#define SYNC_IOC_MAGIC '>'
/** + * Opcodes 0, 1 and 2 were burned during a API change to avoid users of the + * old API to get weird errors when trying to handling sync_files. The API + * change happened during the de-stage of the Sync Framework when there was + * no upstream users available. + */ + +/** * DOC: SYNC_IOC_MERGE - merge two fences * * Takes a struct sync_merge_data. Creates a new fence containing copies of * the sync_pts in both the calling fd and sync_merge_data.fd2. Returns the * new fence's fd in sync_merge_data.fence */ -#define SYNC_IOC_MERGE _IOWR(SYNC_IOC_MAGIC, 1, struct sync_merge_data) +#define SYNC_IOC_MERGE _IOWR(SYNC_IOC_MAGIC, 3, struct sync_merge_data)
/** * DOC: SYNC_IOC_FENCE_INFO - get detailed information on a fence @@ -79,6 +95,6 @@ struct sync_file_info { * pt_info is a buffer containing sync_pt_infos for every sync_pt in the fence. * To iterate over the sync_pt_infos, use the sync_pt_info.len field. */ -#define SYNC_IOC_FENCE_INFO _IOWR(SYNC_IOC_MAGIC, 2, struct sync_file_info) +#define SYNC_IOC_FILE_INFO _IOWR(SYNC_IOC_MAGIC, 4, struct sync_file_info)
#endif /* _UAPI_LINUX_SYNC_H */
Hi Greg,
Any comments on this?
Thanks,
Gustavo
2016-03-18 Gustavo Padovan gustavo@padovan.org:
From: Gustavo Padovan gustavo.padovan@collabora.co.uk
Change SYNC_IOC_FILE_INFO (former SYNC_IOC_FENCE_INFO) behaviour to avoid future API breaks and optimize buffer allocation.
Now num_fences can be filled by the caller to inform how many fences it wants to retrieve from the kernel. If the num_fences passed is greater than zero info->sync_fence_info should point to a buffer with enough space to fit all fences.
However if num_fences passed to the kernel is 0, the kernel will reply with number of fences of the sync_file.
Sending first an ioctl with num_fences = 0 can optimize buffer allocation, in a first call with num_fences = 0 userspace will receive the actual number of fences in the num_fences filed.
Then it can allocate a buffer with the correct size on sync_fence_info and call SYNC_IOC_FILE_INFO again, but now with the actual value of num_fences in the sync_file.
info->sync_fence_info was converted to __u64 pointer to prevent 32bit compatibility issues. And a flags member was added.
An example userspace code for the later would be:
struct sync_file_info *info; int err, size, num_fences;
info = malloc(sizeof(*info));
info.flags = 0; err = ioctl(fd, SYNC_IOC_FILE_INFO, info); num_fences = info->num_fences;
if (num_fences) { info.flags = 0; size = sizeof(struct sync_fence_info) * num_fences; info->num_fences = num_fences; info->sync_fence_info = (uint64_t) calloc(num_fences, sizeof(struct sync_fence_info));
err = ioctl(fd, SYNC_IOC_FILE_INFO, info);
}
Finally the IOCTLs numbers were changed to avoid any potential old userspace running the old API to get weird errors. Changing the opcodes will make them fail right away. This is just a precaution, there no upstream users of these interfaces yet and the only user is Android, but we don't expect anyone trying to run android userspace and all it dependencies on top of upstream kernels.
Signed-off-by: Gustavo Padovan gustavo.padovan@collabora.co.uk Reviewed-by: Maarten Lankhorst maarten.lankhorst@linux.intel.com Acked-by: Greg Hackmann ghackmann@google.com Acked-by: Rob Clark robdclark@gmail.com Acked-by: Daniel Vetter daniel.vetter@ffwll.ch
v2: fix fence_info memory leak
v3: Comments from Emil Velikov
- improve commit message
- remove __u64 cast
- remove check for output fields in file_info
- clean up sync_fill_fence_info()
Comments from Maarten Lankhorst
- remove in.num_fences && !in.sync_fence_info check
- remove info->len and use only num_fences to calculate size
Comments from Dan Carpenter
- fix info->sync_fence_info documentation
v4: remove allocated struct sync_file_info (comment from Maarten)
v5: merge all commits that were changing the ABI
v6: fix -Wint-to-pointer-cast error on info.sync_fence_info
drivers/staging/android/sync.c | 76 ++++++++++++++++++++----------------- drivers/staging/android/uapi/sync.h | 36 +++++++++++++----- 2 files changed, 67 insertions(+), 45 deletions(-)
diff --git a/drivers/staging/android/sync.c b/drivers/staging/android/sync.c index 3a8f210..f9c6094 100644 --- a/drivers/staging/android/sync.c +++ b/drivers/staging/android/sync.c @@ -445,6 +445,11 @@ static long sync_file_ioctl_merge(struct sync_file *sync_file, goto err_put_fd; }
- if (data.flags || data.pad) {
err = -EINVAL;
goto err_put_fd;
- }
- fence2 = sync_file_fdget(data.fd2); if (!fence2) { err = -ENOENT;
@@ -479,13 +484,9 @@ err_put_fd: return err; }
-static int sync_fill_fence_info(struct fence *fence, void *data, int size) +static void sync_fill_fence_info(struct fence *fence,
struct sync_fence_info *info)
{
- struct sync_fence_info *info = data;
- if (size < sizeof(*info))
return -ENOMEM;
- strlcpy(info->obj_name, fence->ops->get_timeline_name(fence), sizeof(info->obj_name)); strlcpy(info->driver_name, fence->ops->get_driver_name(fence),
@@ -495,58 +496,63 @@ static int sync_fill_fence_info(struct fence *fence, void *data, int size) else info->status = 0; info->timestamp_ns = ktime_to_ns(fence->timestamp);
- return sizeof(*info);
}
static long sync_file_ioctl_fence_info(struct sync_file *sync_file, unsigned long arg) {
- struct sync_file_info *info;
- struct sync_file_info info;
- struct sync_fence_info *fence_info = NULL; __u32 size;
__u32 len = 0; int ret, i;
if (copy_from_user(&size, (void __user *)arg, sizeof(size)))
- if (copy_from_user(&info, (void __user *)arg, sizeof(info))) return -EFAULT;
- if (size < sizeof(struct sync_file_info))
- if (info.flags || info.pad) return -EINVAL;
- if (size > 4096)
size = 4096;
- info = kzalloc(size, GFP_KERNEL);
- if (!info)
return -ENOMEM;
- strlcpy(info->name, sync_file->name, sizeof(info->name));
- info->status = atomic_read(&sync_file->status);
- if (info->status >= 0)
info->status = !info->status;
- len = sizeof(struct sync_file_info);
- /*
* Passing num_fences = 0 means that userspace doesn't want to
* retrieve any sync_fence_info. If num_fences = 0 we skip filling
* sync_fence_info and return the actual number of fences on
* info->num_fences.
*/
- if (!info.num_fences)
goto no_fences;
- for (i = 0; i < sync_file->num_fences; ++i) {
struct fence *fence = sync_file->cbs[i].fence;
- if (info.num_fences < sync_file->num_fences)
return -EINVAL;
ret = sync_fill_fence_info(fence, (u8 *)info + len, size - len);
- size = sync_file->num_fences * sizeof(*fence_info);
- fence_info = kzalloc(size, GFP_KERNEL);
- if (!fence_info)
return -ENOMEM;
if (ret < 0)
goto out;
- for (i = 0; i < sync_file->num_fences; ++i)
sync_fill_fence_info(sync_file->cbs[i].fence, &fence_info[i]);
len += ret;
- if (copy_to_user(u64_to_user_ptr(info.sync_fence_info), fence_info,
size)) {
ret = -EFAULT;
}goto out;
- info->len = len;
+no_fences:
- strlcpy(info.name, sync_file->name, sizeof(info.name));
- info.status = atomic_read(&sync_file->status);
- if (info.status >= 0)
info.status = !info.status;
- info.num_fences = sync_file->num_fences;
- if (copy_to_user((void __user *)arg, info, len))
- if (copy_to_user((void __user *)arg, &info, sizeof(info))) ret = -EFAULT; else ret = 0;
out:
- kfree(info);
kfree(fence_info);
return ret;
} @@ -560,7 +566,7 @@ static long sync_file_ioctl(struct file *file, unsigned int cmd, case SYNC_IOC_MERGE: return sync_file_ioctl_merge(sync_file, arg);
- case SYNC_IOC_FENCE_INFO:
case SYNC_IOC_FILE_INFO: return sync_file_ioctl_fence_info(sync_file, arg);
default:
diff --git a/drivers/staging/android/uapi/sync.h b/drivers/staging/android/uapi/sync.h index 4467c76..fbadb8a 100644 --- a/drivers/staging/android/uapi/sync.h +++ b/drivers/staging/android/uapi/sync.h @@ -16,14 +16,18 @@
/**
- struct sync_merge_data - data passed to merge ioctl
- @fd2: file descriptor of second fence
- @name: name of new fence
- @fd2: file descriptor of second fence
- @fence: returns the fd of the new fence to userspace
- @flags: merge_data flags
*/
- @pad: padding for 64-bit alignment, should always be zero
struct sync_merge_data {
- __s32 fd2; char name[32];
- __s32 fd2; __s32 fence;
- __u32 flags;
- __u32 pad;
};
/** @@ -31,42 +35,54 @@ struct sync_merge_data {
- @obj_name: name of parent sync_timeline
- @driver_name: name of driver implementing the parent
- @status: status of the fence 0:active 1:signaled <0:error
*/
- @flags: fence_info flags
- @timestamp_ns: timestamp of status change in nanoseconds
struct sync_fence_info { char obj_name[32]; char driver_name[32]; __s32 status;
- __u32 flags; __u64 timestamp_ns;
};
/**
- struct sync_file_info - data returned from fence info ioctl
- @len: ioctl caller writes the size of the buffer its passing in.
ioctl returns length of sync_file_info returned to
userspace including pt_info.
- @name: name of fence
- @status: status of fence. 1: signaled 0:active <0:error
- @sync_fence_info: array of sync_fence_info for every fence in the sync_file
- @flags: sync_file_info flags
- @num_fences number of fences in the sync_file
- @pad: padding for 64-bit alignment, should always be zero
- @sync_fence_info: pointer to array of structs sync_fence_info with all
*/
fences in the sync_file
struct sync_file_info {
- __u32 len; char name[32]; __s32 status;
- __u32 flags;
- __u32 num_fences;
- __u32 pad;
- __u8 sync_fence_info[0];
- __u64 sync_fence_info;
};
#define SYNC_IOC_MAGIC '>'
/**
- Opcodes 0, 1 and 2 were burned during a API change to avoid users of the
- old API to get weird errors when trying to handling sync_files. The API
- change happened during the de-stage of the Sync Framework when there was
- no upstream users available.
- */
+/**
- DOC: SYNC_IOC_MERGE - merge two fences
- Takes a struct sync_merge_data. Creates a new fence containing copies of
- the sync_pts in both the calling fd and sync_merge_data.fd2. Returns the
- new fence's fd in sync_merge_data.fence
*/ -#define SYNC_IOC_MERGE _IOWR(SYNC_IOC_MAGIC, 1, struct sync_merge_data) +#define SYNC_IOC_MERGE _IOWR(SYNC_IOC_MAGIC, 3, struct sync_merge_data)
/**
- DOC: SYNC_IOC_FENCE_INFO - get detailed information on a fence
@@ -79,6 +95,6 @@ struct sync_file_info {
- pt_info is a buffer containing sync_pt_infos for every sync_pt in the fence.
- To iterate over the sync_pt_infos, use the sync_pt_info.len field.
*/ -#define SYNC_IOC_FENCE_INFO _IOWR(SYNC_IOC_MAGIC, 2, struct sync_file_info) +#define SYNC_IOC_FILE_INFO _IOWR(SYNC_IOC_MAGIC, 4, struct sync_file_info)
#endif /* _UAPI_LINUX_SYNC_H */
2.5.0
Hi Greg,
Any comment on this?
Thanks,
Gustavo
2016-03-18 Gustavo Padovan gustavo@padovan.org:
From: Gustavo Padovan gustavo.padovan@collabora.co.uk
Change SYNC_IOC_FILE_INFO (former SYNC_IOC_FENCE_INFO) behaviour to avoid future API breaks and optimize buffer allocation.
Now num_fences can be filled by the caller to inform how many fences it wants to retrieve from the kernel. If the num_fences passed is greater than zero info->sync_fence_info should point to a buffer with enough space to fit all fences.
However if num_fences passed to the kernel is 0, the kernel will reply with number of fences of the sync_file.
Sending first an ioctl with num_fences = 0 can optimize buffer allocation, in a first call with num_fences = 0 userspace will receive the actual number of fences in the num_fences filed.
Then it can allocate a buffer with the correct size on sync_fence_info and call SYNC_IOC_FILE_INFO again, but now with the actual value of num_fences in the sync_file.
info->sync_fence_info was converted to __u64 pointer to prevent 32bit compatibility issues. And a flags member was added.
An example userspace code for the later would be:
struct sync_file_info *info; int err, size, num_fences;
info = malloc(sizeof(*info));
info.flags = 0; err = ioctl(fd, SYNC_IOC_FILE_INFO, info); num_fences = info->num_fences;
if (num_fences) { info.flags = 0; size = sizeof(struct sync_fence_info) * num_fences; info->num_fences = num_fences; info->sync_fence_info = (uint64_t) calloc(num_fences, sizeof(struct sync_fence_info));
err = ioctl(fd, SYNC_IOC_FILE_INFO, info);
}
Finally the IOCTLs numbers were changed to avoid any potential old userspace running the old API to get weird errors. Changing the opcodes will make them fail right away. This is just a precaution, there no upstream users of these interfaces yet and the only user is Android, but we don't expect anyone trying to run android userspace and all it dependencies on top of upstream kernels.
Signed-off-by: Gustavo Padovan gustavo.padovan@collabora.co.uk Reviewed-by: Maarten Lankhorst maarten.lankhorst@linux.intel.com Acked-by: Greg Hackmann ghackmann@google.com Acked-by: Rob Clark robdclark@gmail.com Acked-by: Daniel Vetter daniel.vetter@ffwll.ch
v2: fix fence_info memory leak
v3: Comments from Emil Velikov
- improve commit message
- remove __u64 cast
- remove check for output fields in file_info
- clean up sync_fill_fence_info()
Comments from Maarten Lankhorst
- remove in.num_fences && !in.sync_fence_info check
- remove info->len and use only num_fences to calculate size
Comments from Dan Carpenter
- fix info->sync_fence_info documentation
v4: remove allocated struct sync_file_info (comment from Maarten)
v5: merge all commits that were changing the ABI
v6: fix -Wint-to-pointer-cast error on info.sync_fence_info
drivers/staging/android/sync.c | 76 ++++++++++++++++++++----------------- drivers/staging/android/uapi/sync.h | 36 +++++++++++++----- 2 files changed, 67 insertions(+), 45 deletions(-)
diff --git a/drivers/staging/android/sync.c b/drivers/staging/android/sync.c index 3a8f210..f9c6094 100644 --- a/drivers/staging/android/sync.c +++ b/drivers/staging/android/sync.c @@ -445,6 +445,11 @@ static long sync_file_ioctl_merge(struct sync_file *sync_file, goto err_put_fd; }
- if (data.flags || data.pad) {
err = -EINVAL;
goto err_put_fd;
- }
- fence2 = sync_file_fdget(data.fd2); if (!fence2) { err = -ENOENT;
@@ -479,13 +484,9 @@ err_put_fd: return err; }
-static int sync_fill_fence_info(struct fence *fence, void *data, int size) +static void sync_fill_fence_info(struct fence *fence,
struct sync_fence_info *info)
{
- struct sync_fence_info *info = data;
- if (size < sizeof(*info))
return -ENOMEM;
- strlcpy(info->obj_name, fence->ops->get_timeline_name(fence), sizeof(info->obj_name)); strlcpy(info->driver_name, fence->ops->get_driver_name(fence),
@@ -495,58 +496,63 @@ static int sync_fill_fence_info(struct fence *fence, void *data, int size) else info->status = 0; info->timestamp_ns = ktime_to_ns(fence->timestamp);
- return sizeof(*info);
}
static long sync_file_ioctl_fence_info(struct sync_file *sync_file, unsigned long arg) {
- struct sync_file_info *info;
- struct sync_file_info info;
- struct sync_fence_info *fence_info = NULL; __u32 size;
__u32 len = 0; int ret, i;
if (copy_from_user(&size, (void __user *)arg, sizeof(size)))
- if (copy_from_user(&info, (void __user *)arg, sizeof(info))) return -EFAULT;
- if (size < sizeof(struct sync_file_info))
- if (info.flags || info.pad) return -EINVAL;
- if (size > 4096)
size = 4096;
- info = kzalloc(size, GFP_KERNEL);
- if (!info)
return -ENOMEM;
- strlcpy(info->name, sync_file->name, sizeof(info->name));
- info->status = atomic_read(&sync_file->status);
- if (info->status >= 0)
info->status = !info->status;
- len = sizeof(struct sync_file_info);
- /*
* Passing num_fences = 0 means that userspace doesn't want to
* retrieve any sync_fence_info. If num_fences = 0 we skip filling
* sync_fence_info and return the actual number of fences on
* info->num_fences.
*/
- if (!info.num_fences)
goto no_fences;
- for (i = 0; i < sync_file->num_fences; ++i) {
struct fence *fence = sync_file->cbs[i].fence;
- if (info.num_fences < sync_file->num_fences)
return -EINVAL;
ret = sync_fill_fence_info(fence, (u8 *)info + len, size - len);
- size = sync_file->num_fences * sizeof(*fence_info);
- fence_info = kzalloc(size, GFP_KERNEL);
- if (!fence_info)
return -ENOMEM;
if (ret < 0)
goto out;
- for (i = 0; i < sync_file->num_fences; ++i)
sync_fill_fence_info(sync_file->cbs[i].fence, &fence_info[i]);
len += ret;
- if (copy_to_user(u64_to_user_ptr(info.sync_fence_info), fence_info,
size)) {
ret = -EFAULT;
}goto out;
- info->len = len;
+no_fences:
- strlcpy(info.name, sync_file->name, sizeof(info.name));
- info.status = atomic_read(&sync_file->status);
- if (info.status >= 0)
info.status = !info.status;
- info.num_fences = sync_file->num_fences;
- if (copy_to_user((void __user *)arg, info, len))
- if (copy_to_user((void __user *)arg, &info, sizeof(info))) ret = -EFAULT; else ret = 0;
out:
- kfree(info);
kfree(fence_info);
return ret;
} @@ -560,7 +566,7 @@ static long sync_file_ioctl(struct file *file, unsigned int cmd, case SYNC_IOC_MERGE: return sync_file_ioctl_merge(sync_file, arg);
- case SYNC_IOC_FENCE_INFO:
case SYNC_IOC_FILE_INFO: return sync_file_ioctl_fence_info(sync_file, arg);
default:
diff --git a/drivers/staging/android/uapi/sync.h b/drivers/staging/android/uapi/sync.h index 4467c76..fbadb8a 100644 --- a/drivers/staging/android/uapi/sync.h +++ b/drivers/staging/android/uapi/sync.h @@ -16,14 +16,18 @@
/**
- struct sync_merge_data - data passed to merge ioctl
- @fd2: file descriptor of second fence
- @name: name of new fence
- @fd2: file descriptor of second fence
- @fence: returns the fd of the new fence to userspace
- @flags: merge_data flags
*/
- @pad: padding for 64-bit alignment, should always be zero
struct sync_merge_data {
- __s32 fd2; char name[32];
- __s32 fd2; __s32 fence;
- __u32 flags;
- __u32 pad;
};
/** @@ -31,42 +35,54 @@ struct sync_merge_data {
- @obj_name: name of parent sync_timeline
- @driver_name: name of driver implementing the parent
- @status: status of the fence 0:active 1:signaled <0:error
*/
- @flags: fence_info flags
- @timestamp_ns: timestamp of status change in nanoseconds
struct sync_fence_info { char obj_name[32]; char driver_name[32]; __s32 status;
- __u32 flags; __u64 timestamp_ns;
};
/**
- struct sync_file_info - data returned from fence info ioctl
- @len: ioctl caller writes the size of the buffer its passing in.
ioctl returns length of sync_file_info returned to
userspace including pt_info.
- @name: name of fence
- @status: status of fence. 1: signaled 0:active <0:error
- @sync_fence_info: array of sync_fence_info for every fence in the sync_file
- @flags: sync_file_info flags
- @num_fences number of fences in the sync_file
- @pad: padding for 64-bit alignment, should always be zero
- @sync_fence_info: pointer to array of structs sync_fence_info with all
*/
fences in the sync_file
struct sync_file_info {
- __u32 len; char name[32]; __s32 status;
- __u32 flags;
- __u32 num_fences;
- __u32 pad;
- __u8 sync_fence_info[0];
- __u64 sync_fence_info;
};
#define SYNC_IOC_MAGIC '>'
/**
- Opcodes 0, 1 and 2 were burned during a API change to avoid users of the
- old API to get weird errors when trying to handling sync_files. The API
- change happened during the de-stage of the Sync Framework when there was
- no upstream users available.
- */
+/**
- DOC: SYNC_IOC_MERGE - merge two fences
- Takes a struct sync_merge_data. Creates a new fence containing copies of
- the sync_pts in both the calling fd and sync_merge_data.fd2. Returns the
- new fence's fd in sync_merge_data.fence
*/ -#define SYNC_IOC_MERGE _IOWR(SYNC_IOC_MAGIC, 1, struct sync_merge_data) +#define SYNC_IOC_MERGE _IOWR(SYNC_IOC_MAGIC, 3, struct sync_merge_data)
/**
- DOC: SYNC_IOC_FENCE_INFO - get detailed information on a fence
@@ -79,6 +95,6 @@ struct sync_file_info {
- pt_info is a buffer containing sync_pt_infos for every sync_pt in the fence.
- To iterate over the sync_pt_infos, use the sync_pt_info.len field.
*/ -#define SYNC_IOC_FENCE_INFO _IOWR(SYNC_IOC_MAGIC, 2, struct sync_file_info) +#define SYNC_IOC_FILE_INFO _IOWR(SYNC_IOC_MAGIC, 4, struct sync_file_info)
#endif /* _UAPI_LINUX_SYNC_H */
2.5.0
dri-devel@lists.freedesktop.org