aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorDaniel Vetter <daniel.vetter@ffwll.ch>2013-12-11 05:34:44 -0500
committerDave Airlie <airlied@redhat.com>2013-12-17 20:35:01 -0500
commit1d6ac185c32134233f77ce44800ceb4ab9361401 (patch)
tree189d3bac69aa35ed8e8f3f249c0d79a751351d5a
parent57ed0f7b4375f4cb0ec3eccbc81f262294eefbcd (diff)
drm: Kill DRM_COPY_(TO|FROM)_USER
Less yelling ftw! Signed-off-by: Daniel Vetter <daniel.vetter@ffwll.ch> Signed-off-by: Dave Airlie <airlied@redhat.com>
-rw-r--r--drivers/gpu/drm/drm_buffer.c2
-rw-r--r--drivers/gpu/drm/i915/i915_dma.c6
-rw-r--r--drivers/gpu/drm/mga/mga_dma.c4
-rw-r--r--drivers/gpu/drm/mga/mga_state.c2
-rw-r--r--drivers/gpu/drm/nouveau/nouveau_gem.c4
-rw-r--r--drivers/gpu/drm/qxl/qxl_ioctl.c4
-rw-r--r--drivers/gpu/drm/r128/r128_cce.c4
-rw-r--r--drivers/gpu/drm/r128/r128_state.c28
-rw-r--r--drivers/gpu/drm/radeon/r300_cmdbuf.c8
-rw-r--r--drivers/gpu/drm/radeon/r600_cp.c4
-rw-r--r--drivers/gpu/drm/radeon/r600_cs.c2
-rw-r--r--drivers/gpu/drm/radeon/radeon_cp.c4
-rw-r--r--drivers/gpu/drm/radeon/radeon_cs.c10
-rw-r--r--drivers/gpu/drm/radeon/radeon_irq.c2
-rw-r--r--drivers/gpu/drm/radeon/radeon_kms.c10
-rw-r--r--drivers/gpu/drm/radeon/radeon_mem.c2
-rw-r--r--drivers/gpu/drm/radeon/radeon_state.c18
-rw-r--r--drivers/gpu/drm/savage/savage_bci.c4
-rw-r--r--drivers/gpu/drm/savage/savage_state.c6
-rw-r--r--drivers/gpu/drm/via/via_dma.c4
-rw-r--r--include/drm/drm_os_linux.h7
21 files changed, 64 insertions, 71 deletions
diff --git a/drivers/gpu/drm/drm_buffer.c b/drivers/gpu/drm/drm_buffer.c
index 39a718340319..0406110f83ed 100644
--- a/drivers/gpu/drm/drm_buffer.c
+++ b/drivers/gpu/drm/drm_buffer.c
@@ -114,7 +114,7 @@ int drm_buffer_copy_from_user(struct drm_buffer *buf,
114 114
115 for (idx = 0; idx < nr_pages; ++idx) { 115 for (idx = 0; idx < nr_pages; ++idx) {
116 116
117 if (DRM_COPY_FROM_USER(buf->data[idx], 117 if (copy_from_user(buf->data[idx],
118 user_data + idx * PAGE_SIZE, 118 user_data + idx * PAGE_SIZE,
119 min(PAGE_SIZE, size - idx * PAGE_SIZE))) { 119 min(PAGE_SIZE, size - idx * PAGE_SIZE))) {
120 DRM_ERROR("Failed to copy user data (%p) to drm buffer" 120 DRM_ERROR("Failed to copy user data (%p) to drm buffer"
diff --git a/drivers/gpu/drm/i915/i915_dma.c b/drivers/gpu/drm/i915/i915_dma.c
index 4c18dfcf67d3..bf38e99410a4 100644
--- a/drivers/gpu/drm/i915/i915_dma.c
+++ b/drivers/gpu/drm/i915/i915_dma.c
@@ -820,7 +820,7 @@ static int i915_irq_emit(struct drm_device *dev, void *data,
820 result = i915_emit_irq(dev); 820 result = i915_emit_irq(dev);
821 mutex_unlock(&dev->struct_mutex); 821 mutex_unlock(&dev->struct_mutex);
822 822
823 if (DRM_COPY_TO_USER(emit->irq_seq, &result, sizeof(int))) { 823 if (copy_to_user(emit->irq_seq, &result, sizeof(int))) {
824 DRM_ERROR("copy_to_user\n"); 824 DRM_ERROR("copy_to_user\n");
825 return -EFAULT; 825 return -EFAULT;
826 } 826 }
@@ -1008,8 +1008,8 @@ static int i915_getparam(struct drm_device *dev, void *data,
1008 return -EINVAL; 1008 return -EINVAL;
1009 } 1009 }
1010 1010
1011 if (DRM_COPY_TO_USER(param->value, &value, sizeof(int))) { 1011 if (copy_to_user(param->value, &value, sizeof(int))) {
1012 DRM_ERROR("DRM_COPY_TO_USER failed\n"); 1012 DRM_ERROR("copy_to_user failed\n");
1013 return -EFAULT; 1013 return -EFAULT;
1014 } 1014 }
1015 1015
diff --git a/drivers/gpu/drm/mga/mga_dma.c b/drivers/gpu/drm/mga/mga_dma.c
index 087db33f6cff..c3bf059ba720 100644
--- a/drivers/gpu/drm/mga/mga_dma.c
+++ b/drivers/gpu/drm/mga/mga_dma.c
@@ -1075,10 +1075,10 @@ static int mga_dma_get_buffers(struct drm_device *dev,
1075 1075
1076 buf->file_priv = file_priv; 1076 buf->file_priv = file_priv;
1077 1077
1078 if (DRM_COPY_TO_USER(&d->request_indices[i], 1078 if (copy_to_user(&d->request_indices[i],
1079 &buf->idx, sizeof(buf->idx))) 1079 &buf->idx, sizeof(buf->idx)))
1080 return -EFAULT; 1080 return -EFAULT;
1081 if (DRM_COPY_TO_USER(&d->request_sizes[i], 1081 if (copy_to_user(&d->request_sizes[i],
1082 &buf->total, sizeof(buf->total))) 1082 &buf->total, sizeof(buf->total)))
1083 return -EFAULT; 1083 return -EFAULT;
1084 1084
diff --git a/drivers/gpu/drm/mga/mga_state.c b/drivers/gpu/drm/mga/mga_state.c
index 37cc2fb4eadd..314685b7f41f 100644
--- a/drivers/gpu/drm/mga/mga_state.c
+++ b/drivers/gpu/drm/mga/mga_state.c
@@ -1029,7 +1029,7 @@ static int mga_getparam(struct drm_device *dev, void *data, struct drm_file *fil
1029 return -EINVAL; 1029 return -EINVAL;
1030 } 1030 }
1031 1031
1032 if (DRM_COPY_TO_USER(param->value, &value, sizeof(int))) { 1032 if (copy_to_user(param->value, &value, sizeof(int))) {
1033 DRM_ERROR("copy_to_user\n"); 1033 DRM_ERROR("copy_to_user\n");
1034 return -EFAULT; 1034 return -EFAULT;
1035 } 1035 }
diff --git a/drivers/gpu/drm/nouveau/nouveau_gem.c b/drivers/gpu/drm/nouveau/nouveau_gem.c
index 78a27f8ad7d9..0447163cd2b4 100644
--- a/drivers/gpu/drm/nouveau/nouveau_gem.c
+++ b/drivers/gpu/drm/nouveau/nouveau_gem.c
@@ -506,7 +506,7 @@ validate_list(struct nouveau_channel *chan, struct nouveau_cli *cli,
506 b->presumed.valid = 0; 506 b->presumed.valid = 0;
507 relocs++; 507 relocs++;
508 508
509 if (DRM_COPY_TO_USER(&upbbo[nvbo->pbbo_index].presumed, 509 if (copy_to_user(&upbbo[nvbo->pbbo_index].presumed,
510 &b->presumed, sizeof(b->presumed))) 510 &b->presumed, sizeof(b->presumed)))
511 return -EFAULT; 511 return -EFAULT;
512 } 512 }
@@ -593,7 +593,7 @@ u_memcpya(uint64_t user, unsigned nmemb, unsigned size)
593 if (!mem) 593 if (!mem)
594 return ERR_PTR(-ENOMEM); 594 return ERR_PTR(-ENOMEM);
595 595
596 if (DRM_COPY_FROM_USER(mem, userptr, size)) { 596 if (copy_from_user(mem, userptr, size)) {
597 u_free(mem); 597 u_free(mem);
598 return ERR_PTR(-EFAULT); 598 return ERR_PTR(-EFAULT);
599 } 599 }
diff --git a/drivers/gpu/drm/qxl/qxl_ioctl.c b/drivers/gpu/drm/qxl/qxl_ioctl.c
index 7b95c75e9626..0bb86e6d41b4 100644
--- a/drivers/gpu/drm/qxl/qxl_ioctl.c
+++ b/drivers/gpu/drm/qxl/qxl_ioctl.c
@@ -200,7 +200,7 @@ static int qxl_process_single_command(struct qxl_device *qdev,
200 for (i = 0; i < cmd->relocs_num; ++i) { 200 for (i = 0; i < cmd->relocs_num; ++i) {
201 struct drm_qxl_reloc reloc; 201 struct drm_qxl_reloc reloc;
202 202
203 if (DRM_COPY_FROM_USER(&reloc, 203 if (copy_from_user(&reloc,
204 &((struct drm_qxl_reloc *)(uintptr_t)cmd->relocs)[i], 204 &((struct drm_qxl_reloc *)(uintptr_t)cmd->relocs)[i],
205 sizeof(reloc))) { 205 sizeof(reloc))) {
206 ret = -EFAULT; 206 ret = -EFAULT;
@@ -297,7 +297,7 @@ static int qxl_execbuffer_ioctl(struct drm_device *dev, void *data,
297 struct drm_qxl_command *commands = 297 struct drm_qxl_command *commands =
298 (struct drm_qxl_command *)(uintptr_t)execbuffer->commands; 298 (struct drm_qxl_command *)(uintptr_t)execbuffer->commands;
299 299
300 if (DRM_COPY_FROM_USER(&user_cmd, &commands[cmd_num], 300 if (copy_from_user(&user_cmd, &commands[cmd_num],
301 sizeof(user_cmd))) 301 sizeof(user_cmd)))
302 return -EFAULT; 302 return -EFAULT;
303 303
diff --git a/drivers/gpu/drm/r128/r128_cce.c b/drivers/gpu/drm/r128/r128_cce.c
index c451257f08fb..59459fe4e8c5 100644
--- a/drivers/gpu/drm/r128/r128_cce.c
+++ b/drivers/gpu/drm/r128/r128_cce.c
@@ -892,10 +892,10 @@ static int r128_cce_get_buffers(struct drm_device *dev,
892 892
893 buf->file_priv = file_priv; 893 buf->file_priv = file_priv;
894 894
895 if (DRM_COPY_TO_USER(&d->request_indices[i], &buf->idx, 895 if (copy_to_user(&d->request_indices[i], &buf->idx,
896 sizeof(buf->idx))) 896 sizeof(buf->idx)))
897 return -EFAULT; 897 return -EFAULT;
898 if (DRM_COPY_TO_USER(&d->request_sizes[i], &buf->total, 898 if (copy_to_user(&d->request_sizes[i], &buf->total,
899 sizeof(buf->total))) 899 sizeof(buf->total)))
900 return -EFAULT; 900 return -EFAULT;
901 901
diff --git a/drivers/gpu/drm/r128/r128_state.c b/drivers/gpu/drm/r128/r128_state.c
index 01dd9aef9f0e..818986b52e8c 100644
--- a/drivers/gpu/drm/r128/r128_state.c
+++ b/drivers/gpu/drm/r128/r128_state.c
@@ -895,16 +895,16 @@ static int r128_cce_dispatch_write_span(struct drm_device *dev,
895 if (count > 4096 || count <= 0) 895 if (count > 4096 || count <= 0)
896 return -EMSGSIZE; 896 return -EMSGSIZE;
897 897
898 if (DRM_COPY_FROM_USER(&x, depth->x, sizeof(x))) 898 if (copy_from_user(&x, depth->x, sizeof(x)))
899 return -EFAULT; 899 return -EFAULT;
900 if (DRM_COPY_FROM_USER(&y, depth->y, sizeof(y))) 900 if (copy_from_user(&y, depth->y, sizeof(y)))
901 return -EFAULT; 901 return -EFAULT;
902 902
903 buffer_size = depth->n * sizeof(u32); 903 buffer_size = depth->n * sizeof(u32);
904 buffer = kmalloc(buffer_size, GFP_KERNEL); 904 buffer = kmalloc(buffer_size, GFP_KERNEL);
905 if (buffer == NULL) 905 if (buffer == NULL)
906 return -ENOMEM; 906 return -ENOMEM;
907 if (DRM_COPY_FROM_USER(buffer, depth->buffer, buffer_size)) { 907 if (copy_from_user(buffer, depth->buffer, buffer_size)) {
908 kfree(buffer); 908 kfree(buffer);
909 return -EFAULT; 909 return -EFAULT;
910 } 910 }
@@ -916,7 +916,7 @@ static int r128_cce_dispatch_write_span(struct drm_device *dev,
916 kfree(buffer); 916 kfree(buffer);
917 return -ENOMEM; 917 return -ENOMEM;
918 } 918 }
919 if (DRM_COPY_FROM_USER(mask, depth->mask, mask_size)) { 919 if (copy_from_user(mask, depth->mask, mask_size)) {
920 kfree(buffer); 920 kfree(buffer);
921 kfree(mask); 921 kfree(mask);
922 return -EFAULT; 922 return -EFAULT;
@@ -999,12 +999,12 @@ static int r128_cce_dispatch_write_pixels(struct drm_device *dev,
999 kfree(x); 999 kfree(x);
1000 return -ENOMEM; 1000 return -ENOMEM;
1001 } 1001 }
1002 if (DRM_COPY_FROM_USER(x, depth->x, xbuf_size)) { 1002 if (copy_from_user(x, depth->x, xbuf_size)) {
1003 kfree(x); 1003 kfree(x);
1004 kfree(y); 1004 kfree(y);
1005 return -EFAULT; 1005 return -EFAULT;
1006 } 1006 }
1007 if (DRM_COPY_FROM_USER(y, depth->y, xbuf_size)) { 1007 if (copy_from_user(y, depth->y, xbuf_size)) {
1008 kfree(x); 1008 kfree(x);
1009 kfree(y); 1009 kfree(y);
1010 return -EFAULT; 1010 return -EFAULT;
@@ -1017,7 +1017,7 @@ static int r128_cce_dispatch_write_pixels(struct drm_device *dev,
1017 kfree(y); 1017 kfree(y);
1018 return -ENOMEM; 1018 return -ENOMEM;
1019 } 1019 }
1020 if (DRM_COPY_FROM_USER(buffer, depth->buffer, buffer_size)) { 1020 if (copy_from_user(buffer, depth->buffer, buffer_size)) {
1021 kfree(x); 1021 kfree(x);
1022 kfree(y); 1022 kfree(y);
1023 kfree(buffer); 1023 kfree(buffer);
@@ -1033,7 +1033,7 @@ static int r128_cce_dispatch_write_pixels(struct drm_device *dev,
1033 kfree(buffer); 1033 kfree(buffer);
1034 return -ENOMEM; 1034 return -ENOMEM;
1035 } 1035 }
1036 if (DRM_COPY_FROM_USER(mask, depth->mask, mask_size)) { 1036 if (copy_from_user(mask, depth->mask, mask_size)) {
1037 kfree(x); 1037 kfree(x);
1038 kfree(y); 1038 kfree(y);
1039 kfree(buffer); 1039 kfree(buffer);
@@ -1107,9 +1107,9 @@ static int r128_cce_dispatch_read_span(struct drm_device *dev,
1107 if (count > 4096 || count <= 0) 1107 if (count > 4096 || count <= 0)
1108 return -EMSGSIZE; 1108 return -EMSGSIZE;
1109 1109
1110 if (DRM_COPY_FROM_USER(&x, depth->x, sizeof(x))) 1110 if (copy_from_user(&x, depth->x, sizeof(x)))
1111 return -EFAULT; 1111 return -EFAULT;
1112 if (DRM_COPY_FROM_USER(&y, depth->y, sizeof(y))) 1112 if (copy_from_user(&y, depth->y, sizeof(y)))
1113 return -EFAULT; 1113 return -EFAULT;
1114 1114
1115 BEGIN_RING(7); 1115 BEGIN_RING(7);
@@ -1162,12 +1162,12 @@ static int r128_cce_dispatch_read_pixels(struct drm_device *dev,
1162 kfree(x); 1162 kfree(x);
1163 return -ENOMEM; 1163 return -ENOMEM;
1164 } 1164 }
1165 if (DRM_COPY_FROM_USER(x, depth->x, xbuf_size)) { 1165 if (copy_from_user(x, depth->x, xbuf_size)) {
1166 kfree(x); 1166 kfree(x);
1167 kfree(y); 1167 kfree(y);
1168 return -EFAULT; 1168 return -EFAULT;
1169 } 1169 }
1170 if (DRM_COPY_FROM_USER(y, depth->y, ybuf_size)) { 1170 if (copy_from_user(y, depth->y, ybuf_size)) {
1171 kfree(x); 1171 kfree(x);
1172 kfree(y); 1172 kfree(y);
1173 return -EFAULT; 1173 return -EFAULT;
@@ -1524,7 +1524,7 @@ static int r128_cce_stipple(struct drm_device *dev, void *data, struct drm_file
1524 1524
1525 DEV_INIT_TEST_WITH_RETURN(dev_priv); 1525 DEV_INIT_TEST_WITH_RETURN(dev_priv);
1526 1526
1527 if (DRM_COPY_FROM_USER(&mask, stipple->mask, 32 * sizeof(u32))) 1527 if (copy_from_user(&mask, stipple->mask, 32 * sizeof(u32)))
1528 return -EFAULT; 1528 return -EFAULT;
1529 1529
1530 RING_SPACE_TEST_WITH_RETURN(dev_priv); 1530 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 return -EINVAL; 1622 return -EINVAL;
1623 } 1623 }
1624 1624
1625 if (DRM_COPY_TO_USER(param->value, &value, sizeof(int))) { 1625 if (copy_to_user(param->value, &value, sizeof(int))) {
1626 DRM_ERROR("copy_to_user\n"); 1626 DRM_ERROR("copy_to_user\n");
1627 return -EFAULT; 1627 return -EFAULT;
1628 } 1628 }
diff --git a/drivers/gpu/drm/radeon/r300_cmdbuf.c b/drivers/gpu/drm/radeon/r300_cmdbuf.c
index 60170ea5e3a2..84b1d5367a11 100644
--- a/drivers/gpu/drm/radeon/r300_cmdbuf.c
+++ b/drivers/gpu/drm/radeon/r300_cmdbuf.c
@@ -75,7 +75,7 @@ static int r300_emit_cliprects(drm_radeon_private_t *dev_priv,
75 OUT_RING(CP_PACKET0(R300_RE_CLIPRECT_TL_0, nr * 2 - 1)); 75 OUT_RING(CP_PACKET0(R300_RE_CLIPRECT_TL_0, nr * 2 - 1));
76 76
77 for (i = 0; i < nr; ++i) { 77 for (i = 0; i < nr; ++i) {
78 if (DRM_COPY_FROM_USER 78 if (copy_from_user
79 (&box, &cmdbuf->boxes[n + i], sizeof(box))) { 79 (&box, &cmdbuf->boxes[n + i], sizeof(box))) {
80 DRM_ERROR("copy cliprect faulted\n"); 80 DRM_ERROR("copy cliprect faulted\n");
81 return -EFAULT; 81 return -EFAULT;
@@ -928,12 +928,12 @@ static int r300_scratch(drm_radeon_private_t *dev_priv,
928 buf_idx = drm_buffer_pointer_to_dword(cmdbuf->buffer, 0); 928 buf_idx = drm_buffer_pointer_to_dword(cmdbuf->buffer, 0);
929 *buf_idx *= 2; /* 8 bytes per buf */ 929 *buf_idx *= 2; /* 8 bytes per buf */
930 930
931 if (DRM_COPY_TO_USER(ref_age_base + *buf_idx, 931 if (copy_to_user(ref_age_base + *buf_idx,
932 &dev_priv->scratch_ages[header.scratch.reg], 932 &dev_priv->scratch_ages[header.scratch.reg],
933 sizeof(u32))) 933 sizeof(u32)))
934 return -EINVAL; 934 return -EINVAL;
935 935
936 if (DRM_COPY_FROM_USER(&h_pending, 936 if (copy_from_user(&h_pending,
937 ref_age_base + *buf_idx + 1, 937 ref_age_base + *buf_idx + 1,
938 sizeof(u32))) 938 sizeof(u32)))
939 return -EINVAL; 939 return -EINVAL;
@@ -943,7 +943,7 @@ static int r300_scratch(drm_radeon_private_t *dev_priv,
943 943
944 h_pending--; 944 h_pending--;
945 945
946 if (DRM_COPY_TO_USER(ref_age_base + *buf_idx + 1, 946 if (copy_to_user(ref_age_base + *buf_idx + 1,
947 &h_pending, 947 &h_pending,
948 sizeof(u32))) 948 sizeof(u32)))
949 return -EINVAL; 949 return -EINVAL;
diff --git a/drivers/gpu/drm/radeon/r600_cp.c b/drivers/gpu/drm/radeon/r600_cp.c
index d8eb48bff0ed..8c9b7e26533c 100644
--- a/drivers/gpu/drm/radeon/r600_cp.c
+++ b/drivers/gpu/drm/radeon/r600_cp.c
@@ -2515,7 +2515,7 @@ int r600_cp_dispatch_texture(struct drm_device *dev,
2515 buf = radeon_freelist_get(dev); 2515 buf = radeon_freelist_get(dev);
2516 if (!buf) { 2516 if (!buf) {
2517 DRM_DEBUG("EAGAIN\n"); 2517 DRM_DEBUG("EAGAIN\n");
2518 if (DRM_COPY_TO_USER(tex->image, image, sizeof(*image))) 2518 if (copy_to_user(tex->image, image, sizeof(*image)))
2519 return -EFAULT; 2519 return -EFAULT;
2520 return -EAGAIN; 2520 return -EAGAIN;
2521 } 2521 }
@@ -2528,7 +2528,7 @@ int r600_cp_dispatch_texture(struct drm_device *dev,
2528 buffer = 2528 buffer =
2529 (u32 *) ((char *)dev->agp_buffer_map->handle + buf->offset); 2529 (u32 *) ((char *)dev->agp_buffer_map->handle + buf->offset);
2530 2530
2531 if (DRM_COPY_FROM_USER(buffer, data, pass_size)) { 2531 if (copy_from_user(buffer, data, pass_size)) {
2532 DRM_ERROR("EFAULT on pad, %d bytes\n", pass_size); 2532 DRM_ERROR("EFAULT on pad, %d bytes\n", pass_size);
2533 return -EFAULT; 2533 return -EFAULT;
2534 } 2534 }
diff --git a/drivers/gpu/drm/radeon/r600_cs.c b/drivers/gpu/drm/radeon/r600_cs.c
index 5dceea6f71ae..d824f7fed47d 100644
--- a/drivers/gpu/drm/radeon/r600_cs.c
+++ b/drivers/gpu/drm/radeon/r600_cs.c
@@ -2386,7 +2386,7 @@ int r600_cs_legacy(struct drm_device *dev, void *data, struct drm_file *filp,
2386 ib_chunk = &parser.chunks[parser.chunk_ib_idx]; 2386 ib_chunk = &parser.chunks[parser.chunk_ib_idx];
2387 parser.ib.length_dw = ib_chunk->length_dw; 2387 parser.ib.length_dw = ib_chunk->length_dw;
2388 *l = parser.ib.length_dw; 2388 *l = parser.ib.length_dw;
2389 if (DRM_COPY_FROM_USER(ib, ib_chunk->user_ptr, ib_chunk->length_dw * 4)) { 2389 if (copy_from_user(ib, ib_chunk->user_ptr, ib_chunk->length_dw * 4)) {
2390 r = -EFAULT; 2390 r = -EFAULT;
2391 r600_cs_parser_fini(&parser, r); 2391 r600_cs_parser_fini(&parser, r);
2392 return r; 2392 return r;
diff --git a/drivers/gpu/drm/radeon/radeon_cp.c b/drivers/gpu/drm/radeon/radeon_cp.c
index 3cae2bbc1854..d73013e6f58a 100644
--- a/drivers/gpu/drm/radeon/radeon_cp.c
+++ b/drivers/gpu/drm/radeon/radeon_cp.c
@@ -2020,10 +2020,10 @@ static int radeon_cp_get_buffers(struct drm_device *dev,
2020 2020
2021 buf->file_priv = file_priv; 2021 buf->file_priv = file_priv;
2022 2022
2023 if (DRM_COPY_TO_USER(&d->request_indices[i], &buf->idx, 2023 if (copy_to_user(&d->request_indices[i], &buf->idx,
2024 sizeof(buf->idx))) 2024 sizeof(buf->idx)))
2025 return -EFAULT; 2025 return -EFAULT;
2026 if (DRM_COPY_TO_USER(&d->request_sizes[i], &buf->total, 2026 if (copy_to_user(&d->request_sizes[i], &buf->total,
2027 sizeof(buf->total))) 2027 sizeof(buf->total)))
2028 return -EFAULT; 2028 return -EFAULT;
2029 2029
diff --git a/drivers/gpu/drm/radeon/radeon_cs.c b/drivers/gpu/drm/radeon/radeon_cs.c
index 0b366169d64d..a8e3342fd4a9 100644
--- a/drivers/gpu/drm/radeon/radeon_cs.c
+++ b/drivers/gpu/drm/radeon/radeon_cs.c
@@ -192,7 +192,7 @@ int radeon_cs_parser_init(struct radeon_cs_parser *p, void *data)
192 return -ENOMEM; 192 return -ENOMEM;
193 } 193 }
194 chunk_array_ptr = (uint64_t *)(unsigned long)(cs->chunks); 194 chunk_array_ptr = (uint64_t *)(unsigned long)(cs->chunks);
195 if (DRM_COPY_FROM_USER(p->chunks_array, chunk_array_ptr, 195 if (copy_from_user(p->chunks_array, chunk_array_ptr,
196 sizeof(uint64_t)*cs->num_chunks)) { 196 sizeof(uint64_t)*cs->num_chunks)) {
197 return -EFAULT; 197 return -EFAULT;
198 } 198 }
@@ -208,7 +208,7 @@ int radeon_cs_parser_init(struct radeon_cs_parser *p, void *data)
208 uint32_t __user *cdata; 208 uint32_t __user *cdata;
209 209
210 chunk_ptr = (void __user*)(unsigned long)p->chunks_array[i]; 210 chunk_ptr = (void __user*)(unsigned long)p->chunks_array[i];
211 if (DRM_COPY_FROM_USER(&user_chunk, chunk_ptr, 211 if (copy_from_user(&user_chunk, chunk_ptr,
212 sizeof(struct drm_radeon_cs_chunk))) { 212 sizeof(struct drm_radeon_cs_chunk))) {
213 return -EFAULT; 213 return -EFAULT;
214 } 214 }
@@ -252,7 +252,7 @@ int radeon_cs_parser_init(struct radeon_cs_parser *p, void *data)
252 if (p->chunks[i].kdata == NULL) { 252 if (p->chunks[i].kdata == NULL) {
253 return -ENOMEM; 253 return -ENOMEM;
254 } 254 }
255 if (DRM_COPY_FROM_USER(p->chunks[i].kdata, cdata, size)) { 255 if (copy_from_user(p->chunks[i].kdata, cdata, size)) {
256 return -EFAULT; 256 return -EFAULT;
257 } 257 }
258 if (p->chunks[i].chunk_id == RADEON_CHUNK_ID_FLAGS) { 258 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 } 472 }
473 parser->const_ib.is_const_ib = true; 473 parser->const_ib.is_const_ib = true;
474 parser->const_ib.length_dw = ib_chunk->length_dw; 474 parser->const_ib.length_dw = ib_chunk->length_dw;
475 if (DRM_COPY_FROM_USER(parser->const_ib.ptr, 475 if (copy_from_user(parser->const_ib.ptr,
476 ib_chunk->user_ptr, 476 ib_chunk->user_ptr,
477 ib_chunk->length_dw * 4)) 477 ib_chunk->length_dw * 4))
478 return -EFAULT; 478 return -EFAULT;
@@ -495,7 +495,7 @@ static int radeon_cs_ib_fill(struct radeon_device *rdev, struct radeon_cs_parser
495 parser->ib.length_dw = ib_chunk->length_dw; 495 parser->ib.length_dw = ib_chunk->length_dw;
496 if (ib_chunk->kdata) 496 if (ib_chunk->kdata)
497 memcpy(parser->ib.ptr, ib_chunk->kdata, ib_chunk->length_dw * 4); 497 memcpy(parser->ib.ptr, ib_chunk->kdata, ib_chunk->length_dw * 4);
498 else if (DRM_COPY_FROM_USER(parser->ib.ptr, ib_chunk->user_ptr, ib_chunk->length_dw * 4)) 498 else if (copy_from_user(parser->ib.ptr, ib_chunk->user_ptr, ib_chunk->length_dw * 4))
499 return -EFAULT; 499 return -EFAULT;
500 return 0; 500 return 0;
501} 501}
diff --git a/drivers/gpu/drm/radeon/radeon_irq.c b/drivers/gpu/drm/radeon/radeon_irq.c
index ded2f0564b83..244b19bab2e7 100644
--- a/drivers/gpu/drm/radeon/radeon_irq.c
+++ b/drivers/gpu/drm/radeon/radeon_irq.c
@@ -302,7 +302,7 @@ int radeon_irq_emit(struct drm_device *dev, void *data, struct drm_file *file_pr
302 302
303 result = radeon_emit_irq(dev); 303 result = radeon_emit_irq(dev);
304 304
305 if (DRM_COPY_TO_USER(emit->irq_seq, &result, sizeof(int))) { 305 if (copy_to_user(emit->irq_seq, &result, sizeof(int))) {
306 DRM_ERROR("copy_to_user\n"); 306 DRM_ERROR("copy_to_user\n");
307 return -EFAULT; 307 return -EFAULT;
308 } 308 }
diff --git a/drivers/gpu/drm/radeon/radeon_kms.c b/drivers/gpu/drm/radeon/radeon_kms.c
index 55d0b474bd37..daa28b6a6832 100644
--- a/drivers/gpu/drm/radeon/radeon_kms.c
+++ b/drivers/gpu/drm/radeon/radeon_kms.c
@@ -223,7 +223,7 @@ int radeon_info_ioctl(struct drm_device *dev, void *data, struct drm_file *filp)
223 *value = rdev->accel_working; 223 *value = rdev->accel_working;
224 break; 224 break;
225 case RADEON_INFO_CRTC_FROM_ID: 225 case RADEON_INFO_CRTC_FROM_ID:
226 if (DRM_COPY_FROM_USER(value, value_ptr, sizeof(uint32_t))) { 226 if (copy_from_user(value, value_ptr, sizeof(uint32_t))) {
227 DRM_ERROR("copy_from_user %s:%u\n", __func__, __LINE__); 227 DRM_ERROR("copy_from_user %s:%u\n", __func__, __LINE__);
228 return -EFAULT; 228 return -EFAULT;
229 } 229 }
@@ -269,7 +269,7 @@ int radeon_info_ioctl(struct drm_device *dev, void *data, struct drm_file *filp)
269 * 269 *
270 * When returning, the value is 1 if filp owns hyper-z access, 270 * When returning, the value is 1 if filp owns hyper-z access,
271 * 0 otherwise. */ 271 * 0 otherwise. */
272 if (DRM_COPY_FROM_USER(value, value_ptr, sizeof(uint32_t))) { 272 if (copy_from_user(value, value_ptr, sizeof(uint32_t))) {
273 DRM_ERROR("copy_from_user %s:%u\n", __func__, __LINE__); 273 DRM_ERROR("copy_from_user %s:%u\n", __func__, __LINE__);
274 return -EFAULT; 274 return -EFAULT;
275 } 275 }
@@ -281,7 +281,7 @@ int radeon_info_ioctl(struct drm_device *dev, void *data, struct drm_file *filp)
281 break; 281 break;
282 case RADEON_INFO_WANT_CMASK: 282 case RADEON_INFO_WANT_CMASK:
283 /* The same logic as Hyper-Z. */ 283 /* The same logic as Hyper-Z. */
284 if (DRM_COPY_FROM_USER(value, value_ptr, sizeof(uint32_t))) { 284 if (copy_from_user(value, value_ptr, sizeof(uint32_t))) {
285 DRM_ERROR("copy_from_user %s:%u\n", __func__, __LINE__); 285 DRM_ERROR("copy_from_user %s:%u\n", __func__, __LINE__);
286 return -EFAULT; 286 return -EFAULT;
287 } 287 }
@@ -417,7 +417,7 @@ int radeon_info_ioctl(struct drm_device *dev, void *data, struct drm_file *filp)
417 *value = rdev->fastfb_working; 417 *value = rdev->fastfb_working;
418 break; 418 break;
419 case RADEON_INFO_RING_WORKING: 419 case RADEON_INFO_RING_WORKING:
420 if (DRM_COPY_FROM_USER(value, value_ptr, sizeof(uint32_t))) { 420 if (copy_from_user(value, value_ptr, sizeof(uint32_t))) {
421 DRM_ERROR("copy_from_user %s:%u\n", __func__, __LINE__); 421 DRM_ERROR("copy_from_user %s:%u\n", __func__, __LINE__);
422 return -EFAULT; 422 return -EFAULT;
423 } 423 }
@@ -465,7 +465,7 @@ int radeon_info_ioctl(struct drm_device *dev, void *data, struct drm_file *filp)
465 DRM_DEBUG_KMS("Invalid request %d\n", info->request); 465 DRM_DEBUG_KMS("Invalid request %d\n", info->request);
466 return -EINVAL; 466 return -EINVAL;
467 } 467 }
468 if (DRM_COPY_TO_USER(value_ptr, (char*)value, value_size)) { 468 if (copy_to_user(value_ptr, (char*)value, value_size)) {
469 DRM_ERROR("copy_to_user %s:%u\n", __func__, __LINE__); 469 DRM_ERROR("copy_to_user %s:%u\n", __func__, __LINE__);
470 return -EFAULT; 470 return -EFAULT;
471 } 471 }
diff --git a/drivers/gpu/drm/radeon/radeon_mem.c b/drivers/gpu/drm/radeon/radeon_mem.c
index d54d2d7c9031..146d253f1131 100644
--- a/drivers/gpu/drm/radeon/radeon_mem.c
+++ b/drivers/gpu/drm/radeon/radeon_mem.c
@@ -243,7 +243,7 @@ int radeon_mem_alloc(struct drm_device *dev, void *data, struct drm_file *file_p
243 if (!block) 243 if (!block)
244 return -ENOMEM; 244 return -ENOMEM;
245 245
246 if (DRM_COPY_TO_USER(alloc->region_offset, &block->start, 246 if (copy_to_user(alloc->region_offset, &block->start,
247 sizeof(int))) { 247 sizeof(int))) {
248 DRM_ERROR("copy_to_user\n"); 248 DRM_ERROR("copy_to_user\n");
249 return -EFAULT; 249 return -EFAULT;
diff --git a/drivers/gpu/drm/radeon/radeon_state.c b/drivers/gpu/drm/radeon/radeon_state.c
index 4d20910899d4..956ab7f14e16 100644
--- a/drivers/gpu/drm/radeon/radeon_state.c
+++ b/drivers/gpu/drm/radeon/radeon_state.c
@@ -1810,7 +1810,7 @@ static int radeon_cp_dispatch_texture(struct drm_device * dev,
1810 } 1810 }
1811 if (!buf) { 1811 if (!buf) {
1812 DRM_DEBUG("EAGAIN\n"); 1812 DRM_DEBUG("EAGAIN\n");
1813 if (DRM_COPY_TO_USER(tex->image, image, sizeof(*image))) 1813 if (copy_to_user(tex->image, image, sizeof(*image)))
1814 return -EFAULT; 1814 return -EFAULT;
1815 return -EAGAIN; 1815 return -EAGAIN;
1816 } 1816 }
@@ -1823,7 +1823,7 @@ static int radeon_cp_dispatch_texture(struct drm_device * dev,
1823 1823
1824#define RADEON_COPY_MT(_buf, _data, _width) \ 1824#define RADEON_COPY_MT(_buf, _data, _width) \
1825 do { \ 1825 do { \
1826 if (DRM_COPY_FROM_USER(_buf, _data, (_width))) {\ 1826 if (copy_from_user(_buf, _data, (_width))) {\
1827 DRM_ERROR("EFAULT on pad, %d bytes\n", (_width)); \ 1827 DRM_ERROR("EFAULT on pad, %d bytes\n", (_width)); \
1828 return -EFAULT; \ 1828 return -EFAULT; \
1829 } \ 1829 } \
@@ -2168,7 +2168,7 @@ static int radeon_cp_clear(struct drm_device *dev, void *data, struct drm_file *
2168 if (sarea_priv->nbox > RADEON_NR_SAREA_CLIPRECTS) 2168 if (sarea_priv->nbox > RADEON_NR_SAREA_CLIPRECTS)
2169 sarea_priv->nbox = RADEON_NR_SAREA_CLIPRECTS; 2169 sarea_priv->nbox = RADEON_NR_SAREA_CLIPRECTS;
2170 2170
2171 if (DRM_COPY_FROM_USER(&depth_boxes, clear->depth_boxes, 2171 if (copy_from_user(&depth_boxes, clear->depth_boxes,
2172 sarea_priv->nbox * sizeof(depth_boxes[0]))) 2172 sarea_priv->nbox * sizeof(depth_boxes[0])))
2173 return -EFAULT; 2173 return -EFAULT;
2174 2174
@@ -2436,7 +2436,7 @@ static int radeon_cp_texture(struct drm_device *dev, void *data, struct drm_file
2436 return -EINVAL; 2436 return -EINVAL;
2437 } 2437 }
2438 2438
2439 if (DRM_COPY_FROM_USER(&image, 2439 if (copy_from_user(&image,
2440 (drm_radeon_tex_image_t __user *) tex->image, 2440 (drm_radeon_tex_image_t __user *) tex->image,
2441 sizeof(image))) 2441 sizeof(image)))
2442 return -EFAULT; 2442 return -EFAULT;
@@ -2460,7 +2460,7 @@ static int radeon_cp_stipple(struct drm_device *dev, void *data, struct drm_file
2460 2460
2461 LOCK_TEST_WITH_RETURN(dev, file_priv); 2461 LOCK_TEST_WITH_RETURN(dev, file_priv);
2462 2462
2463 if (DRM_COPY_FROM_USER(&mask, stipple->mask, 32 * sizeof(u32))) 2463 if (copy_from_user(&mask, stipple->mask, 32 * sizeof(u32)))
2464 return -EFAULT; 2464 return -EFAULT;
2465 2465
2466 RING_SPACE_TEST_WITH_RETURN(dev_priv); 2466 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 drm_radeon_prim_t prim; 2585 drm_radeon_prim_t prim;
2586 drm_radeon_tcl_prim_t tclprim; 2586 drm_radeon_tcl_prim_t tclprim;
2587 2587
2588 if (DRM_COPY_FROM_USER(&prim, &vertex->prim[i], sizeof(prim))) 2588 if (copy_from_user(&prim, &vertex->prim[i], sizeof(prim)))
2589 return -EFAULT; 2589 return -EFAULT;
2590 2590
2591 if (prim.stateidx != laststate) { 2591 if (prim.stateidx != laststate) {
2592 drm_radeon_state_t state; 2592 drm_radeon_state_t state;
2593 2593
2594 if (DRM_COPY_FROM_USER(&state, 2594 if (copy_from_user(&state,
2595 &vertex->state[prim.stateidx], 2595 &vertex->state[prim.stateidx],
2596 sizeof(state))) 2596 sizeof(state)))
2597 return -EFAULT; 2597 return -EFAULT;
@@ -2799,7 +2799,7 @@ static int radeon_emit_packet3_cliprect(struct drm_device *dev,
2799 2799
2800 do { 2800 do {
2801 if (i < cmdbuf->nbox) { 2801 if (i < cmdbuf->nbox) {
2802 if (DRM_COPY_FROM_USER(&box, &boxes[i], sizeof(box))) 2802 if (copy_from_user(&box, &boxes[i], sizeof(box)))
2803 return -EFAULT; 2803 return -EFAULT;
2804 /* FIXME The second and subsequent times round 2804 /* FIXME The second and subsequent times round
2805 * this loop, send a WAIT_UNTIL_3D_IDLE before 2805 * 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 return -EINVAL; 3116 return -EINVAL;
3117 } 3117 }
3118 3118
3119 if (DRM_COPY_TO_USER(param->value, &value, sizeof(int))) { 3119 if (copy_to_user(param->value, &value, sizeof(int))) {
3120 DRM_ERROR("copy_to_user\n"); 3120 DRM_ERROR("copy_to_user\n");
3121 return -EFAULT; 3121 return -EFAULT;
3122 } 3122 }
diff --git a/drivers/gpu/drm/savage/savage_bci.c b/drivers/gpu/drm/savage/savage_bci.c
index b17d0710871a..6e673fa968e5 100644
--- a/drivers/gpu/drm/savage/savage_bci.c
+++ b/drivers/gpu/drm/savage/savage_bci.c
@@ -990,10 +990,10 @@ static int savage_bci_get_buffers(struct drm_device *dev,
990 990
991 buf->file_priv = file_priv; 991 buf->file_priv = file_priv;
992 992
993 if (DRM_COPY_TO_USER(&d->request_indices[i], 993 if (copy_to_user(&d->request_indices[i],
994 &buf->idx, sizeof(buf->idx))) 994 &buf->idx, sizeof(buf->idx)))
995 return -EFAULT; 995 return -EFAULT;
996 if (DRM_COPY_TO_USER(&d->request_sizes[i], 996 if (copy_to_user(&d->request_sizes[i],
997 &buf->total, sizeof(buf->total))) 997 &buf->total, sizeof(buf->total)))
998 return -EFAULT; 998 return -EFAULT;
999 999
diff --git a/drivers/gpu/drm/savage/savage_state.c b/drivers/gpu/drm/savage/savage_state.c
index b35e75ed890c..2d3e56d94be3 100644
--- a/drivers/gpu/drm/savage/savage_state.c
+++ b/drivers/gpu/drm/savage/savage_state.c
@@ -992,7 +992,7 @@ int savage_bci_cmdbuf(struct drm_device *dev, void *data, struct drm_file *file_
992 if (kcmd_addr == NULL) 992 if (kcmd_addr == NULL)
993 return -ENOMEM; 993 return -ENOMEM;
994 994
995 if (DRM_COPY_FROM_USER(kcmd_addr, cmdbuf->cmd_addr, 995 if (copy_from_user(kcmd_addr, cmdbuf->cmd_addr,
996 cmdbuf->size * 8)) 996 cmdbuf->size * 8))
997 { 997 {
998 kfree(kcmd_addr); 998 kfree(kcmd_addr);
@@ -1007,7 +1007,7 @@ int savage_bci_cmdbuf(struct drm_device *dev, void *data, struct drm_file *file_
1007 goto done; 1007 goto done;
1008 } 1008 }
1009 1009
1010 if (DRM_COPY_FROM_USER(kvb_addr, cmdbuf->vb_addr, 1010 if (copy_from_user(kvb_addr, cmdbuf->vb_addr,
1011 cmdbuf->vb_size)) { 1011 cmdbuf->vb_size)) {
1012 ret = -EFAULT; 1012 ret = -EFAULT;
1013 goto done; 1013 goto done;
@@ -1022,7 +1022,7 @@ int savage_bci_cmdbuf(struct drm_device *dev, void *data, struct drm_file *file_
1022 goto done; 1022 goto done;
1023 } 1023 }
1024 1024
1025 if (DRM_COPY_FROM_USER(kbox_addr, cmdbuf->box_addr, 1025 if (copy_from_user(kbox_addr, cmdbuf->box_addr,
1026 cmdbuf->nbox * sizeof(struct drm_clip_rect))) { 1026 cmdbuf->nbox * sizeof(struct drm_clip_rect))) {
1027 ret = -EFAULT; 1027 ret = -EFAULT;
1028 goto done; 1028 goto done;
diff --git a/drivers/gpu/drm/via/via_dma.c b/drivers/gpu/drm/via/via_dma.c
index 652f9b43ec9d..3436fdad22c5 100644
--- a/drivers/gpu/drm/via/via_dma.c
+++ b/drivers/gpu/drm/via/via_dma.c
@@ -273,7 +273,7 @@ static int via_dispatch_cmdbuffer(struct drm_device *dev, drm_via_cmdbuffer_t *c
273 if (cmd->size > VIA_PCI_BUF_SIZE) 273 if (cmd->size > VIA_PCI_BUF_SIZE)
274 return -ENOMEM; 274 return -ENOMEM;
275 275
276 if (DRM_COPY_FROM_USER(dev_priv->pci_buf, cmd->buf, cmd->size)) 276 if (copy_from_user(dev_priv->pci_buf, cmd->buf, cmd->size))
277 return -EFAULT; 277 return -EFAULT;
278 278
279 /* 279 /*
@@ -346,7 +346,7 @@ static int via_dispatch_pci_cmdbuffer(struct drm_device *dev,
346 346
347 if (cmd->size > VIA_PCI_BUF_SIZE) 347 if (cmd->size > VIA_PCI_BUF_SIZE)
348 return -ENOMEM; 348 return -ENOMEM;
349 if (DRM_COPY_FROM_USER(dev_priv->pci_buf, cmd->buf, cmd->size)) 349 if (copy_from_user(dev_priv->pci_buf, cmd->buf, cmd->size))
350 return -EFAULT; 350 return -EFAULT;
351 351
352 if ((ret = 352 if ((ret =
diff --git a/include/drm/drm_os_linux.h b/include/drm/drm_os_linux.h
index cf12233ef7ed..2953b1d83022 100644
--- a/include/drm/drm_os_linux.h
+++ b/include/drm/drm_os_linux.h
@@ -48,13 +48,6 @@ static inline void writeq(u64 val, void __iomem *reg)
48/** Read/write memory barrier */ 48/** Read/write memory barrier */
49#define DRM_MEMORYBARRIER() mb() 49#define DRM_MEMORYBARRIER() mb()
50 50
51/** Other copying of data to kernel space */
52#define DRM_COPY_FROM_USER(arg1, arg2, arg3) \
53 copy_from_user(arg1, arg2, arg3)
54/** Other copying of data from kernel space */
55#define DRM_COPY_TO_USER(arg1, arg2, arg3) \
56 copy_to_user(arg1, arg2, arg3)
57
58#define DRM_WAIT_ON( ret, queue, timeout, condition ) \ 51#define DRM_WAIT_ON( ret, queue, timeout, condition ) \
59do { \ 52do { \
60 DECLARE_WAITQUEUE(entry, current); \ 53 DECLARE_WAITQUEUE(entry, current); \