Commit 1d6ac185 authored by Daniel Vetter's avatar Daniel Vetter Committed by Dave Airlie

drm: Kill DRM_COPY_(TO|FROM)_USER

Less yelling ftw!
Signed-off-by: default avatarDaniel Vetter <daniel.vetter@ffwll.ch>
Signed-off-by: default avatarDave Airlie <airlied@redhat.com>
parent 57ed0f7b
...@@ -114,7 +114,7 @@ int drm_buffer_copy_from_user(struct drm_buffer *buf, ...@@ -114,7 +114,7 @@ int drm_buffer_copy_from_user(struct drm_buffer *buf,
for (idx = 0; idx < nr_pages; ++idx) { for (idx = 0; idx < nr_pages; ++idx) {
if (DRM_COPY_FROM_USER(buf->data[idx], if (copy_from_user(buf->data[idx],
user_data + idx * PAGE_SIZE, user_data + idx * PAGE_SIZE,
min(PAGE_SIZE, size - idx * PAGE_SIZE))) { min(PAGE_SIZE, size - idx * PAGE_SIZE))) {
DRM_ERROR("Failed to copy user data (%p) to drm buffer" DRM_ERROR("Failed to copy user data (%p) to drm buffer"
......
...@@ -820,7 +820,7 @@ static int i915_irq_emit(struct drm_device *dev, void *data, ...@@ -820,7 +820,7 @@ static int i915_irq_emit(struct drm_device *dev, void *data,
result = i915_emit_irq(dev); result = i915_emit_irq(dev);
mutex_unlock(&dev->struct_mutex); mutex_unlock(&dev->struct_mutex);
if (DRM_COPY_TO_USER(emit->irq_seq, &result, sizeof(int))) { if (copy_to_user(emit->irq_seq, &result, sizeof(int))) {
DRM_ERROR("copy_to_user\n"); DRM_ERROR("copy_to_user\n");
return -EFAULT; return -EFAULT;
} }
...@@ -1008,8 +1008,8 @@ static int i915_getparam(struct drm_device *dev, void *data, ...@@ -1008,8 +1008,8 @@ static int i915_getparam(struct drm_device *dev, void *data,
return -EINVAL; return -EINVAL;
} }
if (DRM_COPY_TO_USER(param->value, &value, sizeof(int))) { if (copy_to_user(param->value, &value, sizeof(int))) {
DRM_ERROR("DRM_COPY_TO_USER failed\n"); DRM_ERROR("copy_to_user failed\n");
return -EFAULT; return -EFAULT;
} }
......
...@@ -1075,10 +1075,10 @@ static int mga_dma_get_buffers(struct drm_device *dev, ...@@ -1075,10 +1075,10 @@ static int mga_dma_get_buffers(struct drm_device *dev,
buf->file_priv = file_priv; buf->file_priv = file_priv;
if (DRM_COPY_TO_USER(&d->request_indices[i], if (copy_to_user(&d->request_indices[i],
&buf->idx, sizeof(buf->idx))) &buf->idx, sizeof(buf->idx)))
return -EFAULT; return -EFAULT;
if (DRM_COPY_TO_USER(&d->request_sizes[i], if (copy_to_user(&d->request_sizes[i],
&buf->total, sizeof(buf->total))) &buf->total, sizeof(buf->total)))
return -EFAULT; return -EFAULT;
......
...@@ -1029,7 +1029,7 @@ static int mga_getparam(struct drm_device *dev, void *data, struct drm_file *fil ...@@ -1029,7 +1029,7 @@ static int mga_getparam(struct drm_device *dev, void *data, struct drm_file *fil
return -EINVAL; return -EINVAL;
} }
if (DRM_COPY_TO_USER(param->value, &value, sizeof(int))) { if (copy_to_user(param->value, &value, sizeof(int))) {
DRM_ERROR("copy_to_user\n"); DRM_ERROR("copy_to_user\n");
return -EFAULT; return -EFAULT;
} }
......
...@@ -506,7 +506,7 @@ validate_list(struct nouveau_channel *chan, struct nouveau_cli *cli, ...@@ -506,7 +506,7 @@ validate_list(struct nouveau_channel *chan, struct nouveau_cli *cli,
b->presumed.valid = 0; b->presumed.valid = 0;
relocs++; relocs++;
if (DRM_COPY_TO_USER(&upbbo[nvbo->pbbo_index].presumed, if (copy_to_user(&upbbo[nvbo->pbbo_index].presumed,
&b->presumed, sizeof(b->presumed))) &b->presumed, sizeof(b->presumed)))
return -EFAULT; return -EFAULT;
} }
...@@ -593,7 +593,7 @@ u_memcpya(uint64_t user, unsigned nmemb, unsigned size) ...@@ -593,7 +593,7 @@ u_memcpya(uint64_t user, unsigned nmemb, unsigned size)
if (!mem) if (!mem)
return ERR_PTR(-ENOMEM); return ERR_PTR(-ENOMEM);
if (DRM_COPY_FROM_USER(mem, userptr, size)) { if (copy_from_user(mem, userptr, size)) {
u_free(mem); u_free(mem);
return ERR_PTR(-EFAULT); return ERR_PTR(-EFAULT);
} }
......
...@@ -200,7 +200,7 @@ static int qxl_process_single_command(struct qxl_device *qdev, ...@@ -200,7 +200,7 @@ static int qxl_process_single_command(struct qxl_device *qdev,
for (i = 0; i < cmd->relocs_num; ++i) { for (i = 0; i < cmd->relocs_num; ++i) {
struct drm_qxl_reloc reloc; struct drm_qxl_reloc reloc;
if (DRM_COPY_FROM_USER(&reloc, if (copy_from_user(&reloc,
&((struct drm_qxl_reloc *)(uintptr_t)cmd->relocs)[i], &((struct drm_qxl_reloc *)(uintptr_t)cmd->relocs)[i],
sizeof(reloc))) { sizeof(reloc))) {
ret = -EFAULT; ret = -EFAULT;
...@@ -297,7 +297,7 @@ static int qxl_execbuffer_ioctl(struct drm_device *dev, void *data, ...@@ -297,7 +297,7 @@ static int qxl_execbuffer_ioctl(struct drm_device *dev, void *data,
struct drm_qxl_command *commands = struct drm_qxl_command *commands =
(struct drm_qxl_command *)(uintptr_t)execbuffer->commands; (struct drm_qxl_command *)(uintptr_t)execbuffer->commands;
if (DRM_COPY_FROM_USER(&user_cmd, &commands[cmd_num], if (copy_from_user(&user_cmd, &commands[cmd_num],
sizeof(user_cmd))) sizeof(user_cmd)))
return -EFAULT; return -EFAULT;
......
...@@ -892,10 +892,10 @@ static int r128_cce_get_buffers(struct drm_device *dev, ...@@ -892,10 +892,10 @@ static int r128_cce_get_buffers(struct drm_device *dev,
buf->file_priv = file_priv; buf->file_priv = file_priv;
if (DRM_COPY_TO_USER(&d->request_indices[i], &buf->idx, if (copy_to_user(&d->request_indices[i], &buf->idx,
sizeof(buf->idx))) sizeof(buf->idx)))
return -EFAULT; return -EFAULT;
if (DRM_COPY_TO_USER(&d->request_sizes[i], &buf->total, if (copy_to_user(&d->request_sizes[i], &buf->total,
sizeof(buf->total))) sizeof(buf->total)))
return -EFAULT; return -EFAULT;
......
...@@ -895,16 +895,16 @@ static int r128_cce_dispatch_write_span(struct drm_device *dev, ...@@ -895,16 +895,16 @@ static int r128_cce_dispatch_write_span(struct drm_device *dev,
if (count > 4096 || count <= 0) if (count > 4096 || count <= 0)
return -EMSGSIZE; return -EMSGSIZE;
if (DRM_COPY_FROM_USER(&x, depth->x, sizeof(x))) if (copy_from_user(&x, depth->x, sizeof(x)))
return -EFAULT; return -EFAULT;
if (DRM_COPY_FROM_USER(&y, depth->y, sizeof(y))) if (copy_from_user(&y, depth->y, sizeof(y)))
return -EFAULT; return -EFAULT;
buffer_size = depth->n * sizeof(u32); buffer_size = depth->n * sizeof(u32);
buffer = kmalloc(buffer_size, GFP_KERNEL); buffer = kmalloc(buffer_size, GFP_KERNEL);
if (buffer == NULL) if (buffer == NULL)
return -ENOMEM; return -ENOMEM;
if (DRM_COPY_FROM_USER(buffer, depth->buffer, buffer_size)) { if (copy_from_user(buffer, depth->buffer, buffer_size)) {
kfree(buffer); kfree(buffer);
return -EFAULT; return -EFAULT;
} }
...@@ -916,7 +916,7 @@ static int r128_cce_dispatch_write_span(struct drm_device *dev, ...@@ -916,7 +916,7 @@ static int r128_cce_dispatch_write_span(struct drm_device *dev,
kfree(buffer); kfree(buffer);
return -ENOMEM; return -ENOMEM;
} }
if (DRM_COPY_FROM_USER(mask, depth->mask, mask_size)) { if (copy_from_user(mask, depth->mask, mask_size)) {
kfree(buffer); kfree(buffer);
kfree(mask); kfree(mask);
return -EFAULT; return -EFAULT;
...@@ -999,12 +999,12 @@ static int r128_cce_dispatch_write_pixels(struct drm_device *dev, ...@@ -999,12 +999,12 @@ static int r128_cce_dispatch_write_pixels(struct drm_device *dev,
kfree(x); kfree(x);
return -ENOMEM; return -ENOMEM;
} }
if (DRM_COPY_FROM_USER(x, depth->x, xbuf_size)) { if (copy_from_user(x, depth->x, xbuf_size)) {
kfree(x); kfree(x);
kfree(y); kfree(y);
return -EFAULT; return -EFAULT;
} }
if (DRM_COPY_FROM_USER(y, depth->y, xbuf_size)) { if (copy_from_user(y, depth->y, xbuf_size)) {
kfree(x); kfree(x);
kfree(y); kfree(y);
return -EFAULT; return -EFAULT;
...@@ -1017,7 +1017,7 @@ static int r128_cce_dispatch_write_pixels(struct drm_device *dev, ...@@ -1017,7 +1017,7 @@ static int r128_cce_dispatch_write_pixels(struct drm_device *dev,
kfree(y); kfree(y);
return -ENOMEM; return -ENOMEM;
} }
if (DRM_COPY_FROM_USER(buffer, depth->buffer, buffer_size)) { if (copy_from_user(buffer, depth->buffer, buffer_size)) {
kfree(x); kfree(x);
kfree(y); kfree(y);
kfree(buffer); kfree(buffer);
...@@ -1033,7 +1033,7 @@ static int r128_cce_dispatch_write_pixels(struct drm_device *dev, ...@@ -1033,7 +1033,7 @@ static int r128_cce_dispatch_write_pixels(struct drm_device *dev,
kfree(buffer); kfree(buffer);
return -ENOMEM; return -ENOMEM;
} }
if (DRM_COPY_FROM_USER(mask, depth->mask, mask_size)) { if (copy_from_user(mask, depth->mask, mask_size)) {
kfree(x); kfree(x);
kfree(y); kfree(y);
kfree(buffer); kfree(buffer);
...@@ -1107,9 +1107,9 @@ static int r128_cce_dispatch_read_span(struct drm_device *dev, ...@@ -1107,9 +1107,9 @@ static int r128_cce_dispatch_read_span(struct drm_device *dev,
if (count > 4096 || count <= 0) if (count > 4096 || count <= 0)
return -EMSGSIZE; return -EMSGSIZE;
if (DRM_COPY_FROM_USER(&x, depth->x, sizeof(x))) if (copy_from_user(&x, depth->x, sizeof(x)))
return -EFAULT; return -EFAULT;
if (DRM_COPY_FROM_USER(&y, depth->y, sizeof(y))) if (copy_from_user(&y, depth->y, sizeof(y)))
return -EFAULT; return -EFAULT;
BEGIN_RING(7); BEGIN_RING(7);
...@@ -1162,12 +1162,12 @@ static int r128_cce_dispatch_read_pixels(struct drm_device *dev, ...@@ -1162,12 +1162,12 @@ static int r128_cce_dispatch_read_pixels(struct drm_device *dev,
kfree(x); kfree(x);
return -ENOMEM; return -ENOMEM;
} }
if (DRM_COPY_FROM_USER(x, depth->x, xbuf_size)) { if (copy_from_user(x, depth->x, xbuf_size)) {
kfree(x); kfree(x);
kfree(y); kfree(y);
return -EFAULT; return -EFAULT;
} }
if (DRM_COPY_FROM_USER(y, depth->y, ybuf_size)) { if (copy_from_user(y, depth->y, ybuf_size)) {
kfree(x); kfree(x);
kfree(y); kfree(y);
return -EFAULT; return -EFAULT;
...@@ -1524,7 +1524,7 @@ static int r128_cce_stipple(struct drm_device *dev, void *data, struct drm_file ...@@ -1524,7 +1524,7 @@ static int r128_cce_stipple(struct drm_device *dev, void *data, struct drm_file
DEV_INIT_TEST_WITH_RETURN(dev_priv); DEV_INIT_TEST_WITH_RETURN(dev_priv);
if (DRM_COPY_FROM_USER(&mask, stipple->mask, 32 * sizeof(u32))) if (copy_from_user(&mask, stipple->mask, 32 * sizeof(u32)))
return -EFAULT; return -EFAULT;
RING_SPACE_TEST_WITH_RETURN(dev_priv); RING_SPACE_TEST_WITH_RETURN(dev_priv);
...@@ -1622,7 +1622,7 @@ static int r128_getparam(struct drm_device *dev, void *data, struct drm_file *fi ...@@ -1622,7 +1622,7 @@ static int r128_getparam(struct drm_device *dev, void *data, struct drm_file *fi
return -EINVAL; return -EINVAL;
} }
if (DRM_COPY_TO_USER(param->value, &value, sizeof(int))) { if (copy_to_user(param->value, &value, sizeof(int))) {
DRM_ERROR("copy_to_user\n"); DRM_ERROR("copy_to_user\n");
return -EFAULT; return -EFAULT;
} }
......
...@@ -75,7 +75,7 @@ static int r300_emit_cliprects(drm_radeon_private_t *dev_priv, ...@@ -75,7 +75,7 @@ static int r300_emit_cliprects(drm_radeon_private_t *dev_priv,
OUT_RING(CP_PACKET0(R300_RE_CLIPRECT_TL_0, nr * 2 - 1)); OUT_RING(CP_PACKET0(R300_RE_CLIPRECT_TL_0, nr * 2 - 1));
for (i = 0; i < nr; ++i) { for (i = 0; i < nr; ++i) {
if (DRM_COPY_FROM_USER if (copy_from_user
(&box, &cmdbuf->boxes[n + i], sizeof(box))) { (&box, &cmdbuf->boxes[n + i], sizeof(box))) {
DRM_ERROR("copy cliprect faulted\n"); DRM_ERROR("copy cliprect faulted\n");
return -EFAULT; return -EFAULT;
...@@ -928,12 +928,12 @@ static int r300_scratch(drm_radeon_private_t *dev_priv, ...@@ -928,12 +928,12 @@ static int r300_scratch(drm_radeon_private_t *dev_priv,
buf_idx = drm_buffer_pointer_to_dword(cmdbuf->buffer, 0); buf_idx = drm_buffer_pointer_to_dword(cmdbuf->buffer, 0);
*buf_idx *= 2; /* 8 bytes per buf */ *buf_idx *= 2; /* 8 bytes per buf */
if (DRM_COPY_TO_USER(ref_age_base + *buf_idx, if (copy_to_user(ref_age_base + *buf_idx,
&dev_priv->scratch_ages[header.scratch.reg], &dev_priv->scratch_ages[header.scratch.reg],
sizeof(u32))) sizeof(u32)))
return -EINVAL; return -EINVAL;
if (DRM_COPY_FROM_USER(&h_pending, if (copy_from_user(&h_pending,
ref_age_base + *buf_idx + 1, ref_age_base + *buf_idx + 1,
sizeof(u32))) sizeof(u32)))
return -EINVAL; return -EINVAL;
...@@ -943,7 +943,7 @@ static int r300_scratch(drm_radeon_private_t *dev_priv, ...@@ -943,7 +943,7 @@ static int r300_scratch(drm_radeon_private_t *dev_priv,
h_pending--; h_pending--;
if (DRM_COPY_TO_USER(ref_age_base + *buf_idx + 1, if (copy_to_user(ref_age_base + *buf_idx + 1,
&h_pending, &h_pending,
sizeof(u32))) sizeof(u32)))
return -EINVAL; return -EINVAL;
......
...@@ -2515,7 +2515,7 @@ int r600_cp_dispatch_texture(struct drm_device *dev, ...@@ -2515,7 +2515,7 @@ int r600_cp_dispatch_texture(struct drm_device *dev,
buf = radeon_freelist_get(dev); buf = radeon_freelist_get(dev);
if (!buf) { if (!buf) {
DRM_DEBUG("EAGAIN\n"); DRM_DEBUG("EAGAIN\n");
if (DRM_COPY_TO_USER(tex->image, image, sizeof(*image))) if (copy_to_user(tex->image, image, sizeof(*image)))
return -EFAULT; return -EFAULT;
return -EAGAIN; return -EAGAIN;
} }
...@@ -2528,7 +2528,7 @@ int r600_cp_dispatch_texture(struct drm_device *dev, ...@@ -2528,7 +2528,7 @@ int r600_cp_dispatch_texture(struct drm_device *dev,
buffer = buffer =
(u32 *) ((char *)dev->agp_buffer_map->handle + buf->offset); (u32 *) ((char *)dev->agp_buffer_map->handle + buf->offset);
if (DRM_COPY_FROM_USER(buffer, data, pass_size)) { if (copy_from_user(buffer, data, pass_size)) {
DRM_ERROR("EFAULT on pad, %d bytes\n", pass_size); DRM_ERROR("EFAULT on pad, %d bytes\n", pass_size);
return -EFAULT; return -EFAULT;
} }
......
...@@ -2386,7 +2386,7 @@ int r600_cs_legacy(struct drm_device *dev, void *data, struct drm_file *filp, ...@@ -2386,7 +2386,7 @@ int r600_cs_legacy(struct drm_device *dev, void *data, struct drm_file *filp,
ib_chunk = &parser.chunks[parser.chunk_ib_idx]; ib_chunk = &parser.chunks[parser.chunk_ib_idx];
parser.ib.length_dw = ib_chunk->length_dw; parser.ib.length_dw = ib_chunk->length_dw;
*l = parser.ib.length_dw; *l = parser.ib.length_dw;
if (DRM_COPY_FROM_USER(ib, ib_chunk->user_ptr, ib_chunk->length_dw * 4)) { if (copy_from_user(ib, ib_chunk->user_ptr, ib_chunk->length_dw * 4)) {
r = -EFAULT; r = -EFAULT;
r600_cs_parser_fini(&parser, r); r600_cs_parser_fini(&parser, r);
return r; return r;
......
...@@ -2020,10 +2020,10 @@ static int radeon_cp_get_buffers(struct drm_device *dev, ...@@ -2020,10 +2020,10 @@ static int radeon_cp_get_buffers(struct drm_device *dev,
buf->file_priv = file_priv; buf->file_priv = file_priv;
if (DRM_COPY_TO_USER(&d->request_indices[i], &buf->idx, if (copy_to_user(&d->request_indices[i], &buf->idx,
sizeof(buf->idx))) sizeof(buf->idx)))
return -EFAULT; return -EFAULT;
if (DRM_COPY_TO_USER(&d->request_sizes[i], &buf->total, if (copy_to_user(&d->request_sizes[i], &buf->total,
sizeof(buf->total))) sizeof(buf->total)))
return -EFAULT; return -EFAULT;
......
...@@ -192,7 +192,7 @@ int radeon_cs_parser_init(struct radeon_cs_parser *p, void *data) ...@@ -192,7 +192,7 @@ int radeon_cs_parser_init(struct radeon_cs_parser *p, void *data)
return -ENOMEM; return -ENOMEM;
} }
chunk_array_ptr = (uint64_t *)(unsigned long)(cs->chunks); chunk_array_ptr = (uint64_t *)(unsigned long)(cs->chunks);
if (DRM_COPY_FROM_USER(p->chunks_array, chunk_array_ptr, if (copy_from_user(p->chunks_array, chunk_array_ptr,
sizeof(uint64_t)*cs->num_chunks)) { sizeof(uint64_t)*cs->num_chunks)) {
return -EFAULT; return -EFAULT;
} }
...@@ -208,7 +208,7 @@ int radeon_cs_parser_init(struct radeon_cs_parser *p, void *data) ...@@ -208,7 +208,7 @@ int radeon_cs_parser_init(struct radeon_cs_parser *p, void *data)
uint32_t __user *cdata; uint32_t __user *cdata;
chunk_ptr = (void __user*)(unsigned long)p->chunks_array[i]; chunk_ptr = (void __user*)(unsigned long)p->chunks_array[i];
if (DRM_COPY_FROM_USER(&user_chunk, chunk_ptr, if (copy_from_user(&user_chunk, chunk_ptr,
sizeof(struct drm_radeon_cs_chunk))) { sizeof(struct drm_radeon_cs_chunk))) {
return -EFAULT; return -EFAULT;
} }
...@@ -252,7 +252,7 @@ int radeon_cs_parser_init(struct radeon_cs_parser *p, void *data) ...@@ -252,7 +252,7 @@ int radeon_cs_parser_init(struct radeon_cs_parser *p, void *data)
if (p->chunks[i].kdata == NULL) { if (p->chunks[i].kdata == NULL) {
return -ENOMEM; return -ENOMEM;
} }
if (DRM_COPY_FROM_USER(p->chunks[i].kdata, cdata, size)) { if (copy_from_user(p->chunks[i].kdata, cdata, size)) {
return -EFAULT; return -EFAULT;
} }
if (p->chunks[i].chunk_id == RADEON_CHUNK_ID_FLAGS) { if (p->chunks[i].chunk_id == RADEON_CHUNK_ID_FLAGS) {
...@@ -472,7 +472,7 @@ static int radeon_cs_ib_fill(struct radeon_device *rdev, struct radeon_cs_parser ...@@ -472,7 +472,7 @@ static int radeon_cs_ib_fill(struct radeon_device *rdev, struct radeon_cs_parser
} }
parser->const_ib.is_const_ib = true; parser->const_ib.is_const_ib = true;
parser->const_ib.length_dw = ib_chunk->length_dw; parser->const_ib.length_dw = ib_chunk->length_dw;
if (DRM_COPY_FROM_USER(parser->const_ib.ptr, if (copy_from_user(parser->const_ib.ptr,
ib_chunk->user_ptr, ib_chunk->user_ptr,
ib_chunk->length_dw * 4)) ib_chunk->length_dw * 4))
return -EFAULT; return -EFAULT;
...@@ -495,7 +495,7 @@ static int radeon_cs_ib_fill(struct radeon_device *rdev, struct radeon_cs_parser ...@@ -495,7 +495,7 @@ static int radeon_cs_ib_fill(struct radeon_device *rdev, struct radeon_cs_parser
parser->ib.length_dw = ib_chunk->length_dw; parser->ib.length_dw = ib_chunk->length_dw;
if (ib_chunk->kdata) if (ib_chunk->kdata)
memcpy(parser->ib.ptr, ib_chunk->kdata, ib_chunk->length_dw * 4); memcpy(parser->ib.ptr, ib_chunk->kdata, ib_chunk->length_dw * 4);
else if (DRM_COPY_FROM_USER(parser->ib.ptr, ib_chunk->user_ptr, ib_chunk->length_dw * 4)) else if (copy_from_user(parser->ib.ptr, ib_chunk->user_ptr, ib_chunk->length_dw * 4))
return -EFAULT; return -EFAULT;
return 0; return 0;
} }
......
...@@ -302,7 +302,7 @@ int radeon_irq_emit(struct drm_device *dev, void *data, struct drm_file *file_pr ...@@ -302,7 +302,7 @@ int radeon_irq_emit(struct drm_device *dev, void *data, struct drm_file *file_pr
result = radeon_emit_irq(dev); result = radeon_emit_irq(dev);
if (DRM_COPY_TO_USER(emit->irq_seq, &result, sizeof(int))) { if (copy_to_user(emit->irq_seq, &result, sizeof(int))) {
DRM_ERROR("copy_to_user\n"); DRM_ERROR("copy_to_user\n");
return -EFAULT; return -EFAULT;
} }
......
...@@ -223,7 +223,7 @@ int radeon_info_ioctl(struct drm_device *dev, void *data, struct drm_file *filp) ...@@ -223,7 +223,7 @@ int radeon_info_ioctl(struct drm_device *dev, void *data, struct drm_file *filp)
*value = rdev->accel_working; *value = rdev->accel_working;
break; break;
case RADEON_INFO_CRTC_FROM_ID: case RADEON_INFO_CRTC_FROM_ID:
if (DRM_COPY_FROM_USER(value, value_ptr, sizeof(uint32_t))) { if (copy_from_user(value, value_ptr, sizeof(uint32_t))) {
DRM_ERROR("copy_from_user %s:%u\n", __func__, __LINE__); DRM_ERROR("copy_from_user %s:%u\n", __func__, __LINE__);
return -EFAULT; return -EFAULT;
} }
...@@ -269,7 +269,7 @@ int radeon_info_ioctl(struct drm_device *dev, void *data, struct drm_file *filp) ...@@ -269,7 +269,7 @@ int radeon_info_ioctl(struct drm_device *dev, void *data, struct drm_file *filp)
* *
* When returning, the value is 1 if filp owns hyper-z access, * When returning, the value is 1 if filp owns hyper-z access,
* 0 otherwise. */ * 0 otherwise. */
if (DRM_COPY_FROM_USER(value, value_ptr, sizeof(uint32_t))) { if (copy_from_user(value, value_ptr, sizeof(uint32_t))) {
DRM_ERROR("copy_from_user %s:%u\n", __func__, __LINE__); DRM_ERROR("copy_from_user %s:%u\n", __func__, __LINE__);
return -EFAULT; return -EFAULT;
} }
...@@ -281,7 +281,7 @@ int radeon_info_ioctl(struct drm_device *dev, void *data, struct drm_file *filp) ...@@ -281,7 +281,7 @@ int radeon_info_ioctl(struct drm_device *dev, void *data, struct drm_file *filp)
break; break;
case RADEON_INFO_WANT_CMASK: case RADEON_INFO_WANT_CMASK:
/* The same logic as Hyper-Z. */ /* The same logic as Hyper-Z. */
if (DRM_COPY_FROM_USER(value, value_ptr, sizeof(uint32_t))) { if (copy_from_user(value, value_ptr, sizeof(uint32_t))) {
DRM_ERROR("copy_from_user %s:%u\n", __func__, __LINE__); DRM_ERROR("copy_from_user %s:%u\n", __func__, __LINE__);
return -EFAULT; return -EFAULT;
} }
...@@ -417,7 +417,7 @@ int radeon_info_ioctl(struct drm_device *dev, void *data, struct drm_file *filp) ...@@ -417,7 +417,7 @@ int radeon_info_ioctl(struct drm_device *dev, void *data, struct drm_file *filp)
*value = rdev->fastfb_working; *value = rdev->fastfb_working;
break; break;
case RADEON_INFO_RING_WORKING: case RADEON_INFO_RING_WORKING:
if (DRM_COPY_FROM_USER(value, value_ptr, sizeof(uint32_t))) { if (copy_from_user(value, value_ptr, sizeof(uint32_t))) {
DRM_ERROR("copy_from_user %s:%u\n", __func__, __LINE__); DRM_ERROR("copy_from_user %s:%u\n", __func__, __LINE__);
return -EFAULT; return -EFAULT;
} }
...@@ -465,7 +465,7 @@ int radeon_info_ioctl(struct drm_device *dev, void *data, struct drm_file *filp) ...@@ -465,7 +465,7 @@ int radeon_info_ioctl(struct drm_device *dev, void *data, struct drm_file *filp)
DRM_DEBUG_KMS("Invalid request %d\n", info->request); DRM_DEBUG_KMS("Invalid request %d\n", info->request);
return -EINVAL; return -EINVAL;
} }
if (DRM_COPY_TO_USER(value_ptr, (char*)value, value_size)) { if (copy_to_user(value_ptr, (char*)value, value_size)) {
DRM_ERROR("copy_to_user %s:%u\n", __func__, __LINE__); DRM_ERROR("copy_to_user %s:%u\n", __func__, __LINE__);
return -EFAULT; return -EFAULT;
} }
......
...@@ -243,7 +243,7 @@ int radeon_mem_alloc(struct drm_device *dev, void *data, struct drm_file *file_p ...@@ -243,7 +243,7 @@ int radeon_mem_alloc(struct drm_device *dev, void *data, struct drm_file *file_p
if (!block) if (!block)
return -ENOMEM; return -ENOMEM;
if (DRM_COPY_TO_USER(alloc->region_offset, &block->start, if (copy_to_user(alloc->region_offset, &block->start,
sizeof(int))) { sizeof(int))) {
DRM_ERROR("copy_to_user\n"); DRM_ERROR("copy_to_user\n");
return -EFAULT; return -EFAULT;
......
...@@ -1810,7 +1810,7 @@ static int radeon_cp_dispatch_texture(struct drm_device * dev, ...@@ -1810,7 +1810,7 @@ static int radeon_cp_dispatch_texture(struct drm_device * dev,
} }
if (!buf) { if (!buf) {
DRM_DEBUG("EAGAIN\n"); DRM_DEBUG("EAGAIN\n");
if (DRM_COPY_TO_USER(tex->image, image, sizeof(*image))) if (copy_to_user(tex->image, image, sizeof(*image)))
return -EFAULT; return -EFAULT;
return -EAGAIN; return -EAGAIN;
} }
...@@ -1823,7 +1823,7 @@ static int radeon_cp_dispatch_texture(struct drm_device * dev, ...@@ -1823,7 +1823,7 @@ static int radeon_cp_dispatch_texture(struct drm_device * dev,
#define RADEON_COPY_MT(_buf, _data, _width) \ #define RADEON_COPY_MT(_buf, _data, _width) \
do { \ do { \
if (DRM_COPY_FROM_USER(_buf, _data, (_width))) {\ if (copy_from_user(_buf, _data, (_width))) {\
DRM_ERROR("EFAULT on pad, %d bytes\n", (_width)); \ DRM_ERROR("EFAULT on pad, %d bytes\n", (_width)); \
return -EFAULT; \ return -EFAULT; \
} \ } \
...@@ -2168,7 +2168,7 @@ static int radeon_cp_clear(struct drm_device *dev, void *data, struct drm_file * ...@@ -2168,7 +2168,7 @@ static int radeon_cp_clear(struct drm_device *dev, void *data, struct drm_file *
if (sarea_priv->nbox > RADEON_NR_SAREA_CLIPRECTS) if (sarea_priv->nbox > RADEON_NR_SAREA_CLIPRECTS)
sarea_priv->nbox = RADEON_NR_SAREA_CLIPRECTS; sarea_priv->nbox = RADEON_NR_SAREA_CLIPRECTS;
if (DRM_COPY_FROM_USER(&depth_boxes, clear->depth_boxes, if (copy_from_user(&depth_boxes, clear->depth_boxes,
sarea_priv->nbox * sizeof(depth_boxes[0]))) sarea_priv->nbox * sizeof(depth_boxes[0])))
return -EFAULT; return -EFAULT;
...@@ -2436,7 +2436,7 @@ static int radeon_cp_texture(struct drm_device *dev, void *data, struct drm_file ...@@ -2436,7 +2436,7 @@ static int radeon_cp_texture(struct drm_device *dev, void *data, struct drm_file
return -EINVAL; return -EINVAL;
} }
if (DRM_COPY_FROM_USER(&image, if (copy_from_user(&image,
(drm_radeon_tex_image_t __user *) tex->image, (drm_radeon_tex_image_t __user *) tex->image,
sizeof(image))) sizeof(image)))
return -EFAULT; return -EFAULT;
...@@ -2460,7 +2460,7 @@ static int radeon_cp_stipple(struct drm_device *dev, void *data, struct drm_file ...@@ -2460,7 +2460,7 @@ static int radeon_cp_stipple(struct drm_device *dev, void *data, struct drm_file
LOCK_TEST_WITH_RETURN(dev, file_priv); LOCK_TEST_WITH_RETURN(dev, file_priv);
if (DRM_COPY_FROM_USER(&mask, stipple->mask, 32 * sizeof(u32))) if (copy_from_user(&mask, stipple->mask, 32 * sizeof(u32)))
return -EFAULT; return -EFAULT;
RING_SPACE_TEST_WITH_RETURN(dev_priv); RING_SPACE_TEST_WITH_RETURN(dev_priv);
...@@ -2585,13 +2585,13 @@ static int radeon_cp_vertex2(struct drm_device *dev, void *data, struct drm_file ...@@ -2585,13 +2585,13 @@ static int radeon_cp_vertex2(struct drm_device *dev, void *data, struct drm_file
drm_radeon_prim_t prim; drm_radeon_prim_t prim;
drm_radeon_tcl_prim_t tclprim; drm_radeon_tcl_prim_t tclprim;
if (DRM_COPY_FROM_USER(&prim, &vertex->prim[i], sizeof(prim))) if (copy_from_user(&prim, &vertex->prim[i], sizeof(prim)))
return -EFAULT; return -EFAULT;
if (prim.stateidx != laststate) { if (prim.stateidx != laststate) {
drm_radeon_state_t state; drm_radeon_state_t state;
if (DRM_COPY_FROM_USER(&state, if (copy_from_user(&state,
&vertex->state[prim.stateidx], &vertex->state[prim.stateidx],
sizeof(state))) sizeof(state)))
return -EFAULT; return -EFAULT;
...@@ -2799,7 +2799,7 @@ static int radeon_emit_packet3_cliprect(struct drm_device *dev, ...@@ -2799,7 +2799,7 @@ static int radeon_emit_packet3_cliprect(struct drm_device *dev,
do { do {
if (i < cmdbuf->nbox) { if (i < cmdbuf->nbox) {
if (DRM_COPY_FROM_USER(&box, &boxes[i], sizeof(box))) if (copy_from_user(&box, &boxes[i], sizeof(box)))
return -EFAULT; return -EFAULT;
/* FIXME The second and subsequent times round /* FIXME The second and subsequent times round
* this loop, send a WAIT_UNTIL_3D_IDLE before * this loop, send a WAIT_UNTIL_3D_IDLE before
...@@ -3116,7 +3116,7 @@ static int radeon_cp_getparam(struct drm_device *dev, void *data, struct drm_fil ...@@ -3116,7 +3116,7 @@ static int radeon_cp_getparam(struct drm_device *dev, void *data, struct drm_fil
return -EINVAL; return -EINVAL;
} }
if (DRM_COPY_TO_USER(param->value, &value, sizeof(int))) { if (copy_to_user(param->value, &value, sizeof(int))) {
DRM_ERROR("copy_to_user\n"); DRM_ERROR("copy_to_user\n");
return -EFAULT; return -EFAULT;
} }
......
...@@ -990,10 +990,10 @@ static int savage_bci_get_buffers(struct drm_device *dev, ...@@ -990,10 +990,10 @@ static int savage_bci_get_buffers(struct drm_device *dev,
buf->file_priv = file_priv; buf->file_priv = file_priv;
if (DRM_COPY_TO_USER(&d->request_indices[i], if (copy_to_user(&d->request_indices[i],
&buf->idx, sizeof(buf->idx))) &buf->idx, sizeof(buf->idx)))
return -EFAULT; return -EFAULT;
if (DRM_COPY_TO_USER(&d->request_sizes[i], if (copy_to_user(&d->request_sizes[i],
&buf->total, sizeof(buf->total))) &buf->total, sizeof(buf->total)))
return -EFAULT; return -EFAULT;
......
...@@ -992,7 +992,7 @@ int savage_bci_cmdbuf(struct drm_device *dev, void *data, struct drm_file *file_ ...@@ -992,7 +992,7 @@ int savage_bci_cmdbuf(struct drm_device *dev, void *data, struct drm_file *file_
if (kcmd_addr == NULL) if (kcmd_addr == NULL)
return -ENOMEM; return -ENOMEM;
if (DRM_COPY_FROM_USER(kcmd_addr, cmdbuf->cmd_addr, if (copy_from_user(kcmd_addr, cmdbuf->cmd_addr,
cmdbuf->size * 8)) cmdbuf->size * 8))
{ {
kfree(kcmd_addr); kfree(kcmd_addr);
...@@ -1007,7 +1007,7 @@ int savage_bci_cmdbuf(struct drm_device *dev, void *data, struct drm_file *file_ ...@@ -1007,7 +1007,7 @@ int savage_bci_cmdbuf(struct drm_device *dev, void *data, struct drm_file *file_
goto done; goto done;
} }
if (DRM_COPY_FROM_USER(kvb_addr, cmdbuf->vb_addr, if (copy_from_user(kvb_addr, cmdbuf->vb_addr,
cmdbuf->vb_size)) { cmdbuf->vb_size)) {
ret = -EFAULT; ret = -EFAULT;
goto done; goto done;
...@@ -1022,7 +1022,7 @@ int savage_bci_cmdbuf(struct drm_device *dev, void *data, struct drm_file *file_ ...@@ -1022,7 +1022,7 @@ int savage_bci_cmdbuf(struct drm_device *dev, void *data, struct drm_file *file_
goto done; goto done;
} }
if (DRM_COPY_FROM_USER(kbox_addr, cmdbuf->box_addr, if (copy_from_user(kbox_addr, cmdbuf->box_addr,
cmdbuf->nbox * sizeof(struct drm_clip_rect))) { cmdbuf->nbox * sizeof(struct drm_clip_rect))) {
ret = -EFAULT; ret = -EFAULT;
goto done; goto done;
......
...@@ -273,7 +273,7 @@ static int via_dispatch_cmdbuffer(struct drm_device *dev, drm_via_cmdbuffer_t *c ...@@ -273,7 +273,7 @@ static int via_dispatch_cmdbuffer(struct drm_device *dev, drm_via_cmdbuffer_t *c
if (cmd->size > VIA_PCI_BUF_SIZE) if (cmd->size > VIA_PCI_BUF_SIZE)
return -ENOMEM; return -ENOMEM;
if (DRM_COPY_FROM_USER(dev_priv->pci_buf, cmd->buf, cmd->size)) if (copy_from_user(dev_priv->pci_buf, cmd->buf, cmd->size))
return -EFAULT; return -EFAULT;
/* /*
...@@ -346,7 +346,7 @@ static int via_dispatch_pci_cmdbuffer(struct drm_device *dev, ...@@ -346,7 +346,7 @@ static int via_dispatch_pci_cmdbuffer(struct drm_device *dev,
if (cmd->size > VIA_PCI_BUF_SIZE) if (cmd->size > VIA_PCI_BUF_SIZE)
return -ENOMEM; return -ENOMEM;
if (DRM_COPY_FROM_USER(dev_priv->pci_buf, cmd->buf, cmd->size)) if (copy_from_user(dev_priv->pci_buf, cmd->buf, cmd->size))
return -EFAULT; return -EFAULT;
if ((ret = if ((ret =
......
...@@ -48,13 +48,6 @@ static inline void writeq(u64 val, void __iomem *reg) ...@@ -48,13 +48,6 @@ static inline void writeq(u64 val, void __iomem *reg)
/** Read/write memory barrier */ /** Read/write memory barrier */
#define DRM_MEMORYBARRIER() mb() #define DRM_MEMORYBARRIER() mb()
/** Other copying of data to kernel space */
#define DRM_COPY_FROM_USER(arg1, arg2, arg3) \
copy_from_user(arg1, arg2, arg3)
/** Other copying of data from kernel space */
#define DRM_COPY_TO_USER(arg1, arg2, arg3) \
copy_to_user(arg1, arg2, arg3)
#define DRM_WAIT_ON( ret, queue, timeout, condition ) \ #define DRM_WAIT_ON( ret, queue, timeout, condition ) \
do { \ do { \
DECLARE_WAITQUEUE(entry, current); \ DECLARE_WAITQUEUE(entry, current); \
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment