aboutsummaryrefslogtreecommitdiffstats
path: root/drivers/char/drm/i810_dma.c
diff options
context:
space:
mode:
authorEric Anholt <eric@anholt.net>2007-08-25 06:23:09 -0400
committerDave Airlie <airlied@optimus.(none)>2007-10-14 20:38:20 -0400
commit6c340eac0285f3d62406d2d902d0e96fbf2a5dc0 (patch)
treea92039951cb7eaced306cfff2bad6af0ac5257ad /drivers/char/drm/i810_dma.c
parent20caafa6ecb2487d9b223aa33e7cc704f912a758 (diff)
drm: Replace filp in ioctl arguments with drm_file *file_priv.
As a fallout, replace filp storage with file_priv storage for "unique identifier of a client" all over the DRM. There is a 1:1 mapping, so this should be a noop. This could be a minor performance improvement, as everyth on Linux dereferenced filp to get file_priv anyway, while only the mmap ioct went the other direction. Signed-off-by: Dave Airlie <airlied@linux.ie>
Diffstat (limited to 'drivers/char/drm/i810_dma.c')
-rw-r--r--drivers/char/drm/i810_dma.c127
1 files changed, 58 insertions, 69 deletions
diff --git a/drivers/char/drm/i810_dma.c b/drivers/char/drm/i810_dma.c
index bfb35ab11809..3f1aca87432f 100644
--- a/drivers/char/drm/i810_dma.c
+++ b/drivers/char/drm/i810_dma.c
@@ -120,10 +120,9 @@ static const struct file_operations i810_buffer_fops = {
120 .fasync = drm_fasync, 120 .fasync = drm_fasync,
121}; 121};
122 122
123static int i810_map_buffer(struct drm_buf * buf, struct file *filp) 123static int i810_map_buffer(struct drm_buf * buf, struct drm_file *file_priv)
124{ 124{
125 struct drm_file *priv = filp->private_data; 125 struct drm_device *dev = file_priv->head->dev;
126 struct drm_device *dev = priv->head->dev;
127 drm_i810_buf_priv_t *buf_priv = buf->dev_private; 126 drm_i810_buf_priv_t *buf_priv = buf->dev_private;
128 drm_i810_private_t *dev_priv = dev->dev_private; 127 drm_i810_private_t *dev_priv = dev->dev_private;
129 const struct file_operations *old_fops; 128 const struct file_operations *old_fops;
@@ -133,14 +132,14 @@ static int i810_map_buffer(struct drm_buf * buf, struct file *filp)
133 return -EINVAL; 132 return -EINVAL;
134 133
135 down_write(&current->mm->mmap_sem); 134 down_write(&current->mm->mmap_sem);
136 old_fops = filp->f_op; 135 old_fops = file_priv->filp->f_op;
137 filp->f_op = &i810_buffer_fops; 136 file_priv->filp->f_op = &i810_buffer_fops;
138 dev_priv->mmap_buffer = buf; 137 dev_priv->mmap_buffer = buf;
139 buf_priv->virtual = (void *)do_mmap(filp, 0, buf->total, 138 buf_priv->virtual = (void *)do_mmap(file_priv->filp, 0, buf->total,
140 PROT_READ | PROT_WRITE, 139 PROT_READ | PROT_WRITE,
141 MAP_SHARED, buf->bus_address); 140 MAP_SHARED, buf->bus_address);
142 dev_priv->mmap_buffer = NULL; 141 dev_priv->mmap_buffer = NULL;
143 filp->f_op = old_fops; 142 file_priv->filp->f_op = old_fops;
144 if (IS_ERR(buf_priv->virtual)) { 143 if (IS_ERR(buf_priv->virtual)) {
145 /* Real error */ 144 /* Real error */
146 DRM_ERROR("mmap error\n"); 145 DRM_ERROR("mmap error\n");
@@ -173,7 +172,7 @@ static int i810_unmap_buffer(struct drm_buf * buf)
173} 172}
174 173
175static int i810_dma_get_buffer(struct drm_device * dev, drm_i810_dma_t * d, 174static int i810_dma_get_buffer(struct drm_device * dev, drm_i810_dma_t * d,
176 struct file *filp) 175 struct drm_file *file_priv)
177{ 176{
178 struct drm_buf *buf; 177 struct drm_buf *buf;
179 drm_i810_buf_priv_t *buf_priv; 178 drm_i810_buf_priv_t *buf_priv;
@@ -186,13 +185,13 @@ static int i810_dma_get_buffer(struct drm_device * dev, drm_i810_dma_t * d,
186 return retcode; 185 return retcode;
187 } 186 }
188 187
189 retcode = i810_map_buffer(buf, filp); 188 retcode = i810_map_buffer(buf, file_priv);
190 if (retcode) { 189 if (retcode) {
191 i810_freelist_put(dev, buf); 190 i810_freelist_put(dev, buf);
192 DRM_ERROR("mapbuf failed, retcode %d\n", retcode); 191 DRM_ERROR("mapbuf failed, retcode %d\n", retcode);
193 return retcode; 192 return retcode;
194 } 193 }
195 buf->filp = filp; 194 buf->file_priv = file_priv;
196 buf_priv = buf->dev_private; 195 buf_priv = buf->dev_private;
197 d->granted = 1; 196 d->granted = 1;
198 d->request_idx = buf->idx; 197 d->request_idx = buf->idx;
@@ -473,11 +472,10 @@ static int i810_dma_init_compat(drm_i810_init_t * init, unsigned long arg)
473 return 0; 472 return 0;
474} 473}
475 474
476static int i810_dma_init(struct inode *inode, struct file *filp, 475static int i810_dma_init(struct inode *inode, struct drm_file *file_priv,
477 unsigned int cmd, unsigned long arg) 476 unsigned int cmd, unsigned long arg)
478{ 477{
479 struct drm_file *priv = filp->private_data; 478 struct drm_device *dev = file_priv->head->dev;
480 struct drm_device *dev = priv->head->dev;
481 drm_i810_private_t *dev_priv; 479 drm_i810_private_t *dev_priv;
482 drm_i810_init_t init; 480 drm_i810_init_t init;
483 int retcode = 0; 481 int retcode = 0;
@@ -968,7 +966,8 @@ static int i810_flush_queue(struct drm_device * dev)
968} 966}
969 967
970/* Must be called with the lock held */ 968/* Must be called with the lock held */
971static void i810_reclaim_buffers(struct drm_device * dev, struct file *filp) 969static void i810_reclaim_buffers(struct drm_device * dev,
970 struct drm_file *file_priv)
972{ 971{
973 struct drm_device_dma *dma = dev->dma; 972 struct drm_device_dma *dma = dev->dma;
974 int i; 973 int i;
@@ -986,7 +985,7 @@ static void i810_reclaim_buffers(struct drm_device * dev, struct file *filp)
986 struct drm_buf *buf = dma->buflist[i]; 985 struct drm_buf *buf = dma->buflist[i];
987 drm_i810_buf_priv_t *buf_priv = buf->dev_private; 986 drm_i810_buf_priv_t *buf_priv = buf->dev_private;
988 987
989 if (buf->filp == filp && buf_priv) { 988 if (buf->file_priv == file_priv && buf_priv) {
990 int used = cmpxchg(buf_priv->in_use, I810_BUF_CLIENT, 989 int used = cmpxchg(buf_priv->in_use, I810_BUF_CLIENT,
991 I810_BUF_FREE); 990 I810_BUF_FREE);
992 991
@@ -998,23 +997,21 @@ static void i810_reclaim_buffers(struct drm_device * dev, struct file *filp)
998 } 997 }
999} 998}
1000 999
1001static int i810_flush_ioctl(struct inode *inode, struct file *filp, 1000static int i810_flush_ioctl(struct inode *inode, struct drm_file *file_priv,
1002 unsigned int cmd, unsigned long arg) 1001 unsigned int cmd, unsigned long arg)
1003{ 1002{
1004 struct drm_file *priv = filp->private_data; 1003 struct drm_device *dev = file_priv->head->dev;
1005 struct drm_device *dev = priv->head->dev;
1006 1004
1007 LOCK_TEST_WITH_RETURN(dev, filp); 1005 LOCK_TEST_WITH_RETURN(dev, file_priv);
1008 1006
1009 i810_flush_queue(dev); 1007 i810_flush_queue(dev);
1010 return 0; 1008 return 0;
1011} 1009}
1012 1010
1013static int i810_dma_vertex(struct inode *inode, struct file *filp, 1011static int i810_dma_vertex(struct inode *inode, struct drm_file *file_priv,
1014 unsigned int cmd, unsigned long arg) 1012 unsigned int cmd, unsigned long arg)
1015{ 1013{
1016 struct drm_file *priv = filp->private_data; 1014 struct drm_device *dev = file_priv->head->dev;
1017 struct drm_device *dev = priv->head->dev;
1018 struct drm_device_dma *dma = dev->dma; 1015 struct drm_device_dma *dma = dev->dma;
1019 drm_i810_private_t *dev_priv = (drm_i810_private_t *) dev->dev_private; 1016 drm_i810_private_t *dev_priv = (drm_i810_private_t *) dev->dev_private;
1020 u32 *hw_status = dev_priv->hw_status_page; 1017 u32 *hw_status = dev_priv->hw_status_page;
@@ -1026,7 +1023,7 @@ static int i810_dma_vertex(struct inode *inode, struct file *filp,
1026 (&vertex, (drm_i810_vertex_t __user *) arg, sizeof(vertex))) 1023 (&vertex, (drm_i810_vertex_t __user *) arg, sizeof(vertex)))
1027 return -EFAULT; 1024 return -EFAULT;
1028 1025
1029 LOCK_TEST_WITH_RETURN(dev, filp); 1026 LOCK_TEST_WITH_RETURN(dev, file_priv);
1030 1027
1031 DRM_DEBUG("i810 dma vertex, idx %d used %d discard %d\n", 1028 DRM_DEBUG("i810 dma vertex, idx %d used %d discard %d\n",
1032 vertex.idx, vertex.used, vertex.discard); 1029 vertex.idx, vertex.used, vertex.discard);
@@ -1046,18 +1043,17 @@ static int i810_dma_vertex(struct inode *inode, struct file *filp,
1046 return 0; 1043 return 0;
1047} 1044}
1048 1045
1049static int i810_clear_bufs(struct inode *inode, struct file *filp, 1046static int i810_clear_bufs(struct inode *inode, struct drm_file *file_priv,
1050 unsigned int cmd, unsigned long arg) 1047 unsigned int cmd, unsigned long arg)
1051{ 1048{
1052 struct drm_file *priv = filp->private_data; 1049 struct drm_device *dev = file_priv->head->dev;
1053 struct drm_device *dev = priv->head->dev;
1054 drm_i810_clear_t clear; 1050 drm_i810_clear_t clear;
1055 1051
1056 if (copy_from_user 1052 if (copy_from_user
1057 (&clear, (drm_i810_clear_t __user *) arg, sizeof(clear))) 1053 (&clear, (drm_i810_clear_t __user *) arg, sizeof(clear)))
1058 return -EFAULT; 1054 return -EFAULT;
1059 1055
1060 LOCK_TEST_WITH_RETURN(dev, filp); 1056 LOCK_TEST_WITH_RETURN(dev, file_priv);
1061 1057
1062 /* GH: Someone's doing nasty things... */ 1058 /* GH: Someone's doing nasty things... */
1063 if (!dev->dev_private) { 1059 if (!dev->dev_private) {
@@ -1069,25 +1065,24 @@ static int i810_clear_bufs(struct inode *inode, struct file *filp,
1069 return 0; 1065 return 0;
1070} 1066}
1071 1067
1072static int i810_swap_bufs(struct inode *inode, struct file *filp, 1068static int i810_swap_bufs(struct inode *inode, struct drm_file *file_priv,
1073 unsigned int cmd, unsigned long arg) 1069 unsigned int cmd, unsigned long arg)
1074{ 1070{
1075 struct drm_file *priv = filp->private_data; 1071 struct drm_device *dev = file_priv->head->dev;
1076 struct drm_device *dev = priv->head->dev;
1077 1072
1078 DRM_DEBUG("i810_swap_bufs\n"); 1073 DRM_DEBUG("i810_swap_bufs\n");
1079 1074
1080 LOCK_TEST_WITH_RETURN(dev, filp); 1075 LOCK_TEST_WITH_RETURN(dev, file_priv);
1081 1076
1082 i810_dma_dispatch_swap(dev); 1077 i810_dma_dispatch_swap(dev);
1083 return 0; 1078 return 0;
1084} 1079}
1085 1080
1086static int i810_getage(struct inode *inode, struct file *filp, unsigned int cmd, 1081static int i810_getage(struct inode *inode, struct drm_file *file_priv,
1082 unsigned int cmd,
1087 unsigned long arg) 1083 unsigned long arg)
1088{ 1084{
1089 struct drm_file *priv = filp->private_data; 1085 struct drm_device *dev = file_priv->head->dev;
1090 struct drm_device *dev = priv->head->dev;
1091 drm_i810_private_t *dev_priv = (drm_i810_private_t *) dev->dev_private; 1086 drm_i810_private_t *dev_priv = (drm_i810_private_t *) dev->dev_private;
1092 u32 *hw_status = dev_priv->hw_status_page; 1087 u32 *hw_status = dev_priv->hw_status_page;
1093 drm_i810_sarea_t *sarea_priv = (drm_i810_sarea_t *) 1088 drm_i810_sarea_t *sarea_priv = (drm_i810_sarea_t *)
@@ -1097,11 +1092,10 @@ static int i810_getage(struct inode *inode, struct file *filp, unsigned int cmd,
1097 return 0; 1092 return 0;
1098} 1093}
1099 1094
1100static int i810_getbuf(struct inode *inode, struct file *filp, unsigned int cmd, 1095static int i810_getbuf(struct inode *inode, struct drm_file *file_priv,
1101 unsigned long arg) 1096 unsigned int cmd, unsigned long arg)
1102{ 1097{
1103 struct drm_file *priv = filp->private_data; 1098 struct drm_device *dev = file_priv->head->dev;
1104 struct drm_device *dev = priv->head->dev;
1105 int retcode = 0; 1099 int retcode = 0;
1106 drm_i810_dma_t d; 1100 drm_i810_dma_t d;
1107 drm_i810_private_t *dev_priv = (drm_i810_private_t *) dev->dev_private; 1101 drm_i810_private_t *dev_priv = (drm_i810_private_t *) dev->dev_private;
@@ -1112,11 +1106,11 @@ static int i810_getbuf(struct inode *inode, struct file *filp, unsigned int cmd,
1112 if (copy_from_user(&d, (drm_i810_dma_t __user *) arg, sizeof(d))) 1106 if (copy_from_user(&d, (drm_i810_dma_t __user *) arg, sizeof(d)))
1113 return -EFAULT; 1107 return -EFAULT;
1114 1108
1115 LOCK_TEST_WITH_RETURN(dev, filp); 1109 LOCK_TEST_WITH_RETURN(dev, file_priv);
1116 1110
1117 d.granted = 0; 1111 d.granted = 0;
1118 1112
1119 retcode = i810_dma_get_buffer(dev, &d, filp); 1113 retcode = i810_dma_get_buffer(dev, &d, file_priv);
1120 1114
1121 DRM_DEBUG("i810_dma: %d returning %d, granted = %d\n", 1115 DRM_DEBUG("i810_dma: %d returning %d, granted = %d\n",
1122 current->pid, retcode, d.granted); 1116 current->pid, retcode, d.granted);
@@ -1128,15 +1122,15 @@ static int i810_getbuf(struct inode *inode, struct file *filp, unsigned int cmd,
1128 return retcode; 1122 return retcode;
1129} 1123}
1130 1124
1131static int i810_copybuf(struct inode *inode, 1125static int i810_copybuf(struct inode *inode, struct drm_file *file_priv,
1132 struct file *filp, unsigned int cmd, unsigned long arg) 1126 unsigned int cmd, unsigned long arg)
1133{ 1127{
1134 /* Never copy - 2.4.x doesn't need it */ 1128 /* Never copy - 2.4.x doesn't need it */
1135 return 0; 1129 return 0;
1136} 1130}
1137 1131
1138static int i810_docopy(struct inode *inode, struct file *filp, unsigned int cmd, 1132static int i810_docopy(struct inode *inode, struct drm_file *file_priv,
1139 unsigned long arg) 1133 unsigned int cmd, unsigned long arg)
1140{ 1134{
1141 /* Never copy - 2.4.x doesn't need it */ 1135 /* Never copy - 2.4.x doesn't need it */
1142 return 0; 1136 return 0;
@@ -1202,11 +1196,10 @@ static void i810_dma_dispatch_mc(struct drm_device * dev, struct drm_buf * buf,
1202 ADVANCE_LP_RING(); 1196 ADVANCE_LP_RING();
1203} 1197}
1204 1198
1205static int i810_dma_mc(struct inode *inode, struct file *filp, 1199static int i810_dma_mc(struct inode *inode, struct drm_file *file_priv,
1206 unsigned int cmd, unsigned long arg) 1200 unsigned int cmd, unsigned long arg)
1207{ 1201{
1208 struct drm_file *priv = filp->private_data; 1202 struct drm_device *dev = file_priv->head->dev;
1209 struct drm_device *dev = priv->head->dev;
1210 struct drm_device_dma *dma = dev->dma; 1203 struct drm_device_dma *dma = dev->dma;
1211 drm_i810_private_t *dev_priv = (drm_i810_private_t *) dev->dev_private; 1204 drm_i810_private_t *dev_priv = (drm_i810_private_t *) dev->dev_private;
1212 u32 *hw_status = dev_priv->hw_status_page; 1205 u32 *hw_status = dev_priv->hw_status_page;
@@ -1217,7 +1210,7 @@ static int i810_dma_mc(struct inode *inode, struct file *filp,
1217 if (copy_from_user(&mc, (drm_i810_mc_t __user *) arg, sizeof(mc))) 1210 if (copy_from_user(&mc, (drm_i810_mc_t __user *) arg, sizeof(mc)))
1218 return -EFAULT; 1211 return -EFAULT;
1219 1212
1220 LOCK_TEST_WITH_RETURN(dev, filp); 1213 LOCK_TEST_WITH_RETURN(dev, file_priv);
1221 1214
1222 if (mc.idx >= dma->buf_count || mc.idx < 0) 1215 if (mc.idx >= dma->buf_count || mc.idx < 0)
1223 return -EINVAL; 1216 return -EINVAL;
@@ -1233,21 +1226,19 @@ static int i810_dma_mc(struct inode *inode, struct file *filp,
1233 return 0; 1226 return 0;
1234} 1227}
1235 1228
1236static int i810_rstatus(struct inode *inode, struct file *filp, 1229static int i810_rstatus(struct inode *inode, struct drm_file *file_priv,
1237 unsigned int cmd, unsigned long arg) 1230 unsigned int cmd, unsigned long arg)
1238{ 1231{
1239 struct drm_file *priv = filp->private_data; 1232 struct drm_device *dev = file_priv->head->dev;
1240 struct drm_device *dev = priv->head->dev;
1241 drm_i810_private_t *dev_priv = (drm_i810_private_t *) dev->dev_private; 1233 drm_i810_private_t *dev_priv = (drm_i810_private_t *) dev->dev_private;
1242 1234
1243 return (int)(((u32 *) (dev_priv->hw_status_page))[4]); 1235 return (int)(((u32 *) (dev_priv->hw_status_page))[4]);
1244} 1236}
1245 1237
1246static int i810_ov0_info(struct inode *inode, struct file *filp, 1238static int i810_ov0_info(struct inode *inode, struct drm_file *file_priv,
1247 unsigned int cmd, unsigned long arg) 1239 unsigned int cmd, unsigned long arg)
1248{ 1240{
1249 struct drm_file *priv = filp->private_data; 1241 struct drm_device *dev = file_priv->head->dev;
1250 struct drm_device *dev = priv->head->dev;
1251 drm_i810_private_t *dev_priv = (drm_i810_private_t *) dev->dev_private; 1242 drm_i810_private_t *dev_priv = (drm_i810_private_t *) dev->dev_private;
1252 drm_i810_overlay_t data; 1243 drm_i810_overlay_t data;
1253 1244
@@ -1259,26 +1250,24 @@ static int i810_ov0_info(struct inode *inode, struct file *filp,
1259 return 0; 1250 return 0;
1260} 1251}
1261 1252
1262static int i810_fstatus(struct inode *inode, struct file *filp, 1253static int i810_fstatus(struct inode *inode, struct drm_file *file_priv,
1263 unsigned int cmd, unsigned long arg) 1254 unsigned int cmd, unsigned long arg)
1264{ 1255{
1265 struct drm_file *priv = filp->private_data; 1256 struct drm_device *dev = file_priv->head->dev;
1266 struct drm_device *dev = priv->head->dev;
1267 drm_i810_private_t *dev_priv = (drm_i810_private_t *) dev->dev_private; 1257 drm_i810_private_t *dev_priv = (drm_i810_private_t *) dev->dev_private;
1268 1258
1269 LOCK_TEST_WITH_RETURN(dev, filp); 1259 LOCK_TEST_WITH_RETURN(dev, file_priv);
1270 1260
1271 return I810_READ(0x30008); 1261 return I810_READ(0x30008);
1272} 1262}
1273 1263
1274static int i810_ov0_flip(struct inode *inode, struct file *filp, 1264static int i810_ov0_flip(struct inode *inode, struct drm_file *file_priv,
1275 unsigned int cmd, unsigned long arg) 1265 unsigned int cmd, unsigned long arg)
1276{ 1266{
1277 struct drm_file *priv = filp->private_data; 1267 struct drm_device *dev = file_priv->head->dev;
1278 struct drm_device *dev = priv->head->dev;
1279 drm_i810_private_t *dev_priv = (drm_i810_private_t *) dev->dev_private; 1268 drm_i810_private_t *dev_priv = (drm_i810_private_t *) dev->dev_private;
1280 1269
1281 LOCK_TEST_WITH_RETURN(dev, filp); 1270 LOCK_TEST_WITH_RETURN(dev, file_priv);
1282 1271
1283 //Tell the overlay to update 1272 //Tell the overlay to update
1284 I810_WRITE(0x30000, dev_priv->overlay_physical | 0x80000000); 1273 I810_WRITE(0x30000, dev_priv->overlay_physical | 0x80000000);
@@ -1310,16 +1299,15 @@ static int i810_do_cleanup_pageflip(struct drm_device * dev)
1310 return 0; 1299 return 0;
1311} 1300}
1312 1301
1313static int i810_flip_bufs(struct inode *inode, struct file *filp, 1302static int i810_flip_bufs(struct inode *inode, struct drm_file *file_priv,
1314 unsigned int cmd, unsigned long arg) 1303 unsigned int cmd, unsigned long arg)
1315{ 1304{
1316 struct drm_file *priv = filp->private_data; 1305 struct drm_device *dev = file_priv->head->dev;
1317 struct drm_device *dev = priv->head->dev;
1318 drm_i810_private_t *dev_priv = dev->dev_private; 1306 drm_i810_private_t *dev_priv = dev->dev_private;
1319 1307
1320 DRM_DEBUG("%s\n", __FUNCTION__); 1308 DRM_DEBUG("%s\n", __FUNCTION__);
1321 1309
1322 LOCK_TEST_WITH_RETURN(dev, filp); 1310 LOCK_TEST_WITH_RETURN(dev, file_priv);
1323 1311
1324 if (!dev_priv->page_flipping) 1312 if (!dev_priv->page_flipping)
1325 i810_do_init_pageflip(dev); 1313 i810_do_init_pageflip(dev);
@@ -1345,7 +1333,7 @@ void i810_driver_lastclose(struct drm_device * dev)
1345 i810_dma_cleanup(dev); 1333 i810_dma_cleanup(dev);
1346} 1334}
1347 1335
1348void i810_driver_preclose(struct drm_device * dev, DRMFILE filp) 1336void i810_driver_preclose(struct drm_device * dev, struct drm_file *file_priv)
1349{ 1337{
1350 if (dev->dev_private) { 1338 if (dev->dev_private) {
1351 drm_i810_private_t *dev_priv = dev->dev_private; 1339 drm_i810_private_t *dev_priv = dev->dev_private;
@@ -1355,9 +1343,10 @@ void i810_driver_preclose(struct drm_device * dev, DRMFILE filp)
1355 } 1343 }
1356} 1344}
1357 1345
1358void i810_driver_reclaim_buffers_locked(struct drm_device * dev, struct file *filp) 1346void i810_driver_reclaim_buffers_locked(struct drm_device * dev,
1347 struct drm_file *file_priv)
1359{ 1348{
1360 i810_reclaim_buffers(dev, filp); 1349 i810_reclaim_buffers(dev, file_priv);
1361} 1350}
1362 1351
1363int i810_driver_dma_quiescent(struct drm_device * dev) 1352int i810_driver_dma_quiescent(struct drm_device * dev)