diff options
author | Eric Anholt <eric@anholt.net> | 2007-09-02 22:06:45 -0400 |
---|---|---|
committer | Dave Airlie <airlied@optimus.(none)> | 2007-10-14 20:38:20 -0400 |
commit | c153f45f9b7e30289157bba3ff5682291df16caa (patch) | |
tree | 33f21e1ebd83ec548751f3d490afe6230ab99972 /drivers/char/drm/mga_dma.c | |
parent | b589ee5943a9610ebaea6e4e3433f2ae4d812b0b (diff) |
drm: Replace DRM_IOCTL_ARGS with (dev, data, file_priv) and remove DRM_DEVICE.
The data is now in kernel space, copied in/out as appropriate according to t
This results in DRM_COPY_{TO,FROM}_USER going away, and error paths to deal
with those failures. This also means that XFree86 4.2.0 support for i810 DR
is lost.
Signed-off-by: Dave Airlie <airlied@linux.ie>
Diffstat (limited to 'drivers/char/drm/mga_dma.c')
-rw-r--r-- | drivers/char/drm/mga_dma.c | 85 |
1 files changed, 34 insertions, 51 deletions
diff --git a/drivers/char/drm/mga_dma.c b/drivers/char/drm/mga_dma.c index 95ff450239dd..c567c34cda78 100644 --- a/drivers/char/drm/mga_dma.c +++ b/drivers/char/drm/mga_dma.c | |||
@@ -759,36 +759,30 @@ static int mga_do_dma_bootstrap(struct drm_device * dev, | |||
759 | return err; | 759 | return err; |
760 | } | 760 | } |
761 | 761 | ||
762 | int mga_dma_bootstrap(DRM_IOCTL_ARGS) | 762 | int mga_dma_bootstrap(struct drm_device *dev, void *data, |
763 | struct drm_file *file_priv) | ||
763 | { | 764 | { |
764 | DRM_DEVICE; | 765 | drm_mga_dma_bootstrap_t *bootstrap = data; |
765 | drm_mga_dma_bootstrap_t bootstrap; | ||
766 | int err; | 766 | int err; |
767 | static const int modes[] = { 0, 1, 2, 2, 4, 4, 4, 4 }; | 767 | static const int modes[] = { 0, 1, 2, 2, 4, 4, 4, 4 }; |
768 | const drm_mga_private_t *const dev_priv = | 768 | const drm_mga_private_t *const dev_priv = |
769 | (drm_mga_private_t *) dev->dev_private; | 769 | (drm_mga_private_t *) dev->dev_private; |
770 | 770 | ||
771 | DRM_COPY_FROM_USER_IOCTL(bootstrap, | 771 | err = mga_do_dma_bootstrap(dev, bootstrap); |
772 | (drm_mga_dma_bootstrap_t __user *) data, | ||
773 | sizeof(bootstrap)); | ||
774 | |||
775 | err = mga_do_dma_bootstrap(dev, &bootstrap); | ||
776 | if (err) { | 772 | if (err) { |
777 | mga_do_cleanup_dma(dev, FULL_CLEANUP); | 773 | mga_do_cleanup_dma(dev, FULL_CLEANUP); |
778 | return err; | 774 | return err; |
779 | } | 775 | } |
780 | 776 | ||
781 | if (dev_priv->agp_textures != NULL) { | 777 | if (dev_priv->agp_textures != NULL) { |
782 | bootstrap.texture_handle = dev_priv->agp_textures->offset; | 778 | bootstrap->texture_handle = dev_priv->agp_textures->offset; |
783 | bootstrap.texture_size = dev_priv->agp_textures->size; | 779 | bootstrap->texture_size = dev_priv->agp_textures->size; |
784 | } else { | 780 | } else { |
785 | bootstrap.texture_handle = 0; | 781 | bootstrap->texture_handle = 0; |
786 | bootstrap.texture_size = 0; | 782 | bootstrap->texture_size = 0; |
787 | } | 783 | } |
788 | 784 | ||
789 | bootstrap.agp_mode = modes[bootstrap.agp_mode & 0x07]; | 785 | bootstrap->agp_mode = modes[bootstrap->agp_mode & 0x07]; |
790 | DRM_COPY_TO_USER_IOCTL((drm_mga_dma_bootstrap_t __user *)data, | ||
791 | bootstrap, sizeof(bootstrap)); | ||
792 | 786 | ||
793 | return err; | 787 | return err; |
794 | } | 788 | } |
@@ -1007,20 +1001,17 @@ static int mga_do_cleanup_dma(struct drm_device *dev, int full_cleanup) | |||
1007 | return 0; | 1001 | return 0; |
1008 | } | 1002 | } |
1009 | 1003 | ||
1010 | int mga_dma_init(DRM_IOCTL_ARGS) | 1004 | int mga_dma_init(struct drm_device *dev, void *data, |
1005 | struct drm_file *file_priv) | ||
1011 | { | 1006 | { |
1012 | DRM_DEVICE; | 1007 | drm_mga_init_t *init = data; |
1013 | drm_mga_init_t init; | ||
1014 | int err; | 1008 | int err; |
1015 | 1009 | ||
1016 | LOCK_TEST_WITH_RETURN(dev, file_priv); | 1010 | LOCK_TEST_WITH_RETURN(dev, file_priv); |
1017 | 1011 | ||
1018 | DRM_COPY_FROM_USER_IOCTL(init, (drm_mga_init_t __user *) data, | 1012 | switch (init->func) { |
1019 | sizeof(init)); | ||
1020 | |||
1021 | switch (init.func) { | ||
1022 | case MGA_INIT_DMA: | 1013 | case MGA_INIT_DMA: |
1023 | err = mga_do_init_dma(dev, &init); | 1014 | err = mga_do_init_dma(dev, init); |
1024 | if (err) { | 1015 | if (err) { |
1025 | (void)mga_do_cleanup_dma(dev, FULL_CLEANUP); | 1016 | (void)mga_do_cleanup_dma(dev, FULL_CLEANUP); |
1026 | } | 1017 | } |
@@ -1036,29 +1027,26 @@ int mga_dma_init(DRM_IOCTL_ARGS) | |||
1036 | * Primary DMA stream management | 1027 | * Primary DMA stream management |
1037 | */ | 1028 | */ |
1038 | 1029 | ||
1039 | int mga_dma_flush(DRM_IOCTL_ARGS) | 1030 | int mga_dma_flush(struct drm_device *dev, void *data, |
1031 | struct drm_file *file_priv) | ||
1040 | { | 1032 | { |
1041 | DRM_DEVICE; | ||
1042 | drm_mga_private_t *dev_priv = (drm_mga_private_t *) dev->dev_private; | 1033 | drm_mga_private_t *dev_priv = (drm_mga_private_t *) dev->dev_private; |
1043 | struct drm_lock lock; | 1034 | struct drm_lock *lock = data; |
1044 | 1035 | ||
1045 | LOCK_TEST_WITH_RETURN(dev, file_priv); | 1036 | LOCK_TEST_WITH_RETURN(dev, file_priv); |
1046 | 1037 | ||
1047 | DRM_COPY_FROM_USER_IOCTL(lock, (struct drm_lock __user *) data, | ||
1048 | sizeof(lock)); | ||
1049 | |||
1050 | DRM_DEBUG("%s%s%s\n", | 1038 | DRM_DEBUG("%s%s%s\n", |
1051 | (lock.flags & _DRM_LOCK_FLUSH) ? "flush, " : "", | 1039 | (lock->flags & _DRM_LOCK_FLUSH) ? "flush, " : "", |
1052 | (lock.flags & _DRM_LOCK_FLUSH_ALL) ? "flush all, " : "", | 1040 | (lock->flags & _DRM_LOCK_FLUSH_ALL) ? "flush all, " : "", |
1053 | (lock.flags & _DRM_LOCK_QUIESCENT) ? "idle, " : ""); | 1041 | (lock->flags & _DRM_LOCK_QUIESCENT) ? "idle, " : ""); |
1054 | 1042 | ||
1055 | WRAP_WAIT_WITH_RETURN(dev_priv); | 1043 | WRAP_WAIT_WITH_RETURN(dev_priv); |
1056 | 1044 | ||
1057 | if (lock.flags & (_DRM_LOCK_FLUSH | _DRM_LOCK_FLUSH_ALL)) { | 1045 | if (lock->flags & (_DRM_LOCK_FLUSH | _DRM_LOCK_FLUSH_ALL)) { |
1058 | mga_do_dma_flush(dev_priv); | 1046 | mga_do_dma_flush(dev_priv); |
1059 | } | 1047 | } |
1060 | 1048 | ||
1061 | if (lock.flags & _DRM_LOCK_QUIESCENT) { | 1049 | if (lock->flags & _DRM_LOCK_QUIESCENT) { |
1062 | #if MGA_DMA_DEBUG | 1050 | #if MGA_DMA_DEBUG |
1063 | int ret = mga_do_wait_for_idle(dev_priv); | 1051 | int ret = mga_do_wait_for_idle(dev_priv); |
1064 | if (ret < 0) | 1052 | if (ret < 0) |
@@ -1072,9 +1060,9 @@ int mga_dma_flush(DRM_IOCTL_ARGS) | |||
1072 | } | 1060 | } |
1073 | } | 1061 | } |
1074 | 1062 | ||
1075 | int mga_dma_reset(DRM_IOCTL_ARGS) | 1063 | int mga_dma_reset(struct drm_device *dev, void *data, |
1064 | struct drm_file *file_priv) | ||
1076 | { | 1065 | { |
1077 | DRM_DEVICE; | ||
1078 | drm_mga_private_t *dev_priv = (drm_mga_private_t *) dev->dev_private; | 1066 | drm_mga_private_t *dev_priv = (drm_mga_private_t *) dev->dev_private; |
1079 | 1067 | ||
1080 | LOCK_TEST_WITH_RETURN(dev, file_priv); | 1068 | LOCK_TEST_WITH_RETURN(dev, file_priv); |
@@ -1111,45 +1099,40 @@ static int mga_dma_get_buffers(struct drm_device * dev, | |||
1111 | return 0; | 1099 | return 0; |
1112 | } | 1100 | } |
1113 | 1101 | ||
1114 | int mga_dma_buffers(DRM_IOCTL_ARGS) | 1102 | int mga_dma_buffers(struct drm_device *dev, void *data, |
1103 | struct drm_file *file_priv) | ||
1115 | { | 1104 | { |
1116 | DRM_DEVICE; | ||
1117 | struct drm_device_dma *dma = dev->dma; | 1105 | struct drm_device_dma *dma = dev->dma; |
1118 | drm_mga_private_t *dev_priv = (drm_mga_private_t *) dev->dev_private; | 1106 | drm_mga_private_t *dev_priv = (drm_mga_private_t *) dev->dev_private; |
1119 | struct drm_dma __user *argp = (void __user *)data; | 1107 | struct drm_dma *d = data; |
1120 | struct drm_dma d; | ||
1121 | int ret = 0; | 1108 | int ret = 0; |
1122 | 1109 | ||
1123 | LOCK_TEST_WITH_RETURN(dev, file_priv); | 1110 | LOCK_TEST_WITH_RETURN(dev, file_priv); |
1124 | 1111 | ||
1125 | DRM_COPY_FROM_USER_IOCTL(d, argp, sizeof(d)); | ||
1126 | |||
1127 | /* Please don't send us buffers. | 1112 | /* Please don't send us buffers. |
1128 | */ | 1113 | */ |
1129 | if (d.send_count != 0) { | 1114 | if (d->send_count != 0) { |
1130 | DRM_ERROR("Process %d trying to send %d buffers via drmDMA\n", | 1115 | DRM_ERROR("Process %d trying to send %d buffers via drmDMA\n", |
1131 | DRM_CURRENTPID, d.send_count); | 1116 | DRM_CURRENTPID, d->send_count); |
1132 | return -EINVAL; | 1117 | return -EINVAL; |
1133 | } | 1118 | } |
1134 | 1119 | ||
1135 | /* We'll send you buffers. | 1120 | /* We'll send you buffers. |
1136 | */ | 1121 | */ |
1137 | if (d.request_count < 0 || d.request_count > dma->buf_count) { | 1122 | if (d->request_count < 0 || d->request_count > dma->buf_count) { |
1138 | DRM_ERROR("Process %d trying to get %d buffers (of %d max)\n", | 1123 | DRM_ERROR("Process %d trying to get %d buffers (of %d max)\n", |
1139 | DRM_CURRENTPID, d.request_count, dma->buf_count); | 1124 | DRM_CURRENTPID, d->request_count, dma->buf_count); |
1140 | return -EINVAL; | 1125 | return -EINVAL; |
1141 | } | 1126 | } |
1142 | 1127 | ||
1143 | WRAP_TEST_WITH_RETURN(dev_priv); | 1128 | WRAP_TEST_WITH_RETURN(dev_priv); |
1144 | 1129 | ||
1145 | d.granted_count = 0; | 1130 | d->granted_count = 0; |
1146 | 1131 | ||
1147 | if (d.request_count) { | 1132 | if (d->request_count) { |
1148 | ret = mga_dma_get_buffers(dev, file_priv, &d); | 1133 | ret = mga_dma_get_buffers(dev, file_priv, d); |
1149 | } | 1134 | } |
1150 | 1135 | ||
1151 | DRM_COPY_TO_USER_IOCTL(argp, d, sizeof(d)); | ||
1152 | |||
1153 | return ret; | 1136 | return ret; |
1154 | } | 1137 | } |
1155 | 1138 | ||