diff options
Diffstat (limited to 'drivers/char/drm/i830_dma.c')
-rw-r--r-- | drivers/char/drm/i830_dma.c | 99 |
1 files changed, 44 insertions, 55 deletions
diff --git a/drivers/char/drm/i830_dma.c b/drivers/char/drm/i830_dma.c index 0bb1cbf48109..f314f8709657 100644 --- a/drivers/char/drm/i830_dma.c +++ b/drivers/char/drm/i830_dma.c | |||
@@ -122,10 +122,9 @@ static const struct file_operations i830_buffer_fops = { | |||
122 | .fasync = drm_fasync, | 122 | .fasync = drm_fasync, |
123 | }; | 123 | }; |
124 | 124 | ||
125 | static int i830_map_buffer(struct drm_buf * buf, struct file *filp) | 125 | static int i830_map_buffer(struct drm_buf * buf, struct drm_file *file_priv) |
126 | { | 126 | { |
127 | struct drm_file *priv = filp->private_data; | 127 | struct drm_device *dev = file_priv->head->dev; |
128 | struct drm_device *dev = priv->head->dev; | ||
129 | drm_i830_buf_priv_t *buf_priv = buf->dev_private; | 128 | drm_i830_buf_priv_t *buf_priv = buf->dev_private; |
130 | drm_i830_private_t *dev_priv = dev->dev_private; | 129 | drm_i830_private_t *dev_priv = dev->dev_private; |
131 | const struct file_operations *old_fops; | 130 | const struct file_operations *old_fops; |
@@ -136,13 +135,13 @@ static int i830_map_buffer(struct drm_buf * buf, struct file *filp) | |||
136 | return -EINVAL; | 135 | return -EINVAL; |
137 | 136 | ||
138 | down_write(¤t->mm->mmap_sem); | 137 | down_write(¤t->mm->mmap_sem); |
139 | old_fops = filp->f_op; | 138 | old_fops = file_priv->filp->f_op; |
140 | filp->f_op = &i830_buffer_fops; | 139 | file_priv->filp->f_op = &i830_buffer_fops; |
141 | dev_priv->mmap_buffer = buf; | 140 | dev_priv->mmap_buffer = buf; |
142 | virtual = do_mmap(filp, 0, buf->total, PROT_READ | PROT_WRITE, | 141 | virtual = do_mmap(file_priv->filp, 0, buf->total, PROT_READ | PROT_WRITE, |
143 | MAP_SHARED, buf->bus_address); | 142 | MAP_SHARED, buf->bus_address); |
144 | dev_priv->mmap_buffer = NULL; | 143 | dev_priv->mmap_buffer = NULL; |
145 | filp->f_op = old_fops; | 144 | file_priv->filp->f_op = old_fops; |
146 | if (IS_ERR((void *)virtual)) { /* ugh */ | 145 | if (IS_ERR((void *)virtual)) { /* ugh */ |
147 | /* Real error */ | 146 | /* Real error */ |
148 | DRM_ERROR("mmap error\n"); | 147 | DRM_ERROR("mmap error\n"); |
@@ -177,7 +176,7 @@ static int i830_unmap_buffer(struct drm_buf * buf) | |||
177 | } | 176 | } |
178 | 177 | ||
179 | static int i830_dma_get_buffer(struct drm_device * dev, drm_i830_dma_t * d, | 178 | static int i830_dma_get_buffer(struct drm_device * dev, drm_i830_dma_t * d, |
180 | struct file *filp) | 179 | struct drm_file *file_priv) |
181 | { | 180 | { |
182 | struct drm_buf *buf; | 181 | struct drm_buf *buf; |
183 | drm_i830_buf_priv_t *buf_priv; | 182 | drm_i830_buf_priv_t *buf_priv; |
@@ -190,13 +189,13 @@ static int i830_dma_get_buffer(struct drm_device * dev, drm_i830_dma_t * d, | |||
190 | return retcode; | 189 | return retcode; |
191 | } | 190 | } |
192 | 191 | ||
193 | retcode = i830_map_buffer(buf, filp); | 192 | retcode = i830_map_buffer(buf, file_priv); |
194 | if (retcode) { | 193 | if (retcode) { |
195 | i830_freelist_put(dev, buf); | 194 | i830_freelist_put(dev, buf); |
196 | DRM_ERROR("mapbuf failed, retcode %d\n", retcode); | 195 | DRM_ERROR("mapbuf failed, retcode %d\n", retcode); |
197 | return retcode; | 196 | return retcode; |
198 | } | 197 | } |
199 | buf->filp = filp; | 198 | buf->file_priv = file_priv; |
200 | buf_priv = buf->dev_private; | 199 | buf_priv = buf->dev_private; |
201 | d->granted = 1; | 200 | d->granted = 1; |
202 | d->request_idx = buf->idx; | 201 | d->request_idx = buf->idx; |
@@ -451,11 +450,10 @@ static int i830_dma_initialize(struct drm_device * dev, | |||
451 | return 0; | 450 | return 0; |
452 | } | 451 | } |
453 | 452 | ||
454 | static int i830_dma_init(struct inode *inode, struct file *filp, | 453 | static int i830_dma_init(struct inode *inode, struct drm_file *file_priv, |
455 | unsigned int cmd, unsigned long arg) | 454 | unsigned int cmd, unsigned long arg) |
456 | { | 455 | { |
457 | struct drm_file *priv = filp->private_data; | 456 | struct drm_device *dev = file_priv->head->dev; |
458 | struct drm_device *dev = priv->head->dev; | ||
459 | drm_i830_private_t *dev_priv; | 457 | drm_i830_private_t *dev_priv; |
460 | drm_i830_init_t init; | 458 | drm_i830_init_t init; |
461 | int retcode = 0; | 459 | int retcode = 0; |
@@ -1248,7 +1246,7 @@ static int i830_flush_queue(struct drm_device * dev) | |||
1248 | } | 1246 | } |
1249 | 1247 | ||
1250 | /* Must be called with the lock held */ | 1248 | /* Must be called with the lock held */ |
1251 | static void i830_reclaim_buffers(struct drm_device * dev, struct file *filp) | 1249 | static void i830_reclaim_buffers(struct drm_device * dev, struct drm_file *file_priv) |
1252 | { | 1250 | { |
1253 | struct drm_device_dma *dma = dev->dma; | 1251 | struct drm_device_dma *dma = dev->dma; |
1254 | int i; | 1252 | int i; |
@@ -1266,7 +1264,7 @@ static void i830_reclaim_buffers(struct drm_device * dev, struct file *filp) | |||
1266 | struct drm_buf *buf = dma->buflist[i]; | 1264 | struct drm_buf *buf = dma->buflist[i]; |
1267 | drm_i830_buf_priv_t *buf_priv = buf->dev_private; | 1265 | drm_i830_buf_priv_t *buf_priv = buf->dev_private; |
1268 | 1266 | ||
1269 | if (buf->filp == filp && buf_priv) { | 1267 | if (buf->file_priv == file_priv && buf_priv) { |
1270 | int used = cmpxchg(buf_priv->in_use, I830_BUF_CLIENT, | 1268 | int used = cmpxchg(buf_priv->in_use, I830_BUF_CLIENT, |
1271 | I830_BUF_FREE); | 1269 | I830_BUF_FREE); |
1272 | 1270 | ||
@@ -1278,23 +1276,21 @@ static void i830_reclaim_buffers(struct drm_device * dev, struct file *filp) | |||
1278 | } | 1276 | } |
1279 | } | 1277 | } |
1280 | 1278 | ||
1281 | static int i830_flush_ioctl(struct inode *inode, struct file *filp, | 1279 | static int i830_flush_ioctl(struct inode *inode, struct drm_file *file_priv, |
1282 | unsigned int cmd, unsigned long arg) | 1280 | unsigned int cmd, unsigned long arg) |
1283 | { | 1281 | { |
1284 | struct drm_file *priv = filp->private_data; | 1282 | struct drm_device *dev = file_priv->head->dev; |
1285 | struct drm_device *dev = priv->head->dev; | ||
1286 | 1283 | ||
1287 | LOCK_TEST_WITH_RETURN(dev, filp); | 1284 | LOCK_TEST_WITH_RETURN(dev, file_priv); |
1288 | 1285 | ||
1289 | i830_flush_queue(dev); | 1286 | i830_flush_queue(dev); |
1290 | return 0; | 1287 | return 0; |
1291 | } | 1288 | } |
1292 | 1289 | ||
1293 | static int i830_dma_vertex(struct inode *inode, struct file *filp, | 1290 | static int i830_dma_vertex(struct inode *inode, struct drm_file *file_priv, |
1294 | unsigned int cmd, unsigned long arg) | 1291 | unsigned int cmd, unsigned long arg) |
1295 | { | 1292 | { |
1296 | struct drm_file *priv = filp->private_data; | 1293 | struct drm_device *dev = file_priv->head->dev; |
1297 | struct drm_device *dev = priv->head->dev; | ||
1298 | struct drm_device_dma *dma = dev->dma; | 1294 | struct drm_device_dma *dma = dev->dma; |
1299 | drm_i830_private_t *dev_priv = (drm_i830_private_t *) dev->dev_private; | 1295 | drm_i830_private_t *dev_priv = (drm_i830_private_t *) dev->dev_private; |
1300 | u32 *hw_status = dev_priv->hw_status_page; | 1296 | u32 *hw_status = dev_priv->hw_status_page; |
@@ -1306,7 +1302,7 @@ static int i830_dma_vertex(struct inode *inode, struct file *filp, | |||
1306 | (&vertex, (drm_i830_vertex_t __user *) arg, sizeof(vertex))) | 1302 | (&vertex, (drm_i830_vertex_t __user *) arg, sizeof(vertex))) |
1307 | return -EFAULT; | 1303 | return -EFAULT; |
1308 | 1304 | ||
1309 | LOCK_TEST_WITH_RETURN(dev, filp); | 1305 | LOCK_TEST_WITH_RETURN(dev, file_priv); |
1310 | 1306 | ||
1311 | DRM_DEBUG("i830 dma vertex, idx %d used %d discard %d\n", | 1307 | DRM_DEBUG("i830 dma vertex, idx %d used %d discard %d\n", |
1312 | vertex.idx, vertex.used, vertex.discard); | 1308 | vertex.idx, vertex.used, vertex.discard); |
@@ -1324,18 +1320,17 @@ static int i830_dma_vertex(struct inode *inode, struct file *filp, | |||
1324 | return 0; | 1320 | return 0; |
1325 | } | 1321 | } |
1326 | 1322 | ||
1327 | static int i830_clear_bufs(struct inode *inode, struct file *filp, | 1323 | static int i830_clear_bufs(struct inode *inode, struct drm_file *file_priv, |
1328 | unsigned int cmd, unsigned long arg) | 1324 | unsigned int cmd, unsigned long arg) |
1329 | { | 1325 | { |
1330 | struct drm_file *priv = filp->private_data; | 1326 | struct drm_device *dev = file_priv->head->dev; |
1331 | struct drm_device *dev = priv->head->dev; | ||
1332 | drm_i830_clear_t clear; | 1327 | drm_i830_clear_t clear; |
1333 | 1328 | ||
1334 | if (copy_from_user | 1329 | if (copy_from_user |
1335 | (&clear, (drm_i830_clear_t __user *) arg, sizeof(clear))) | 1330 | (&clear, (drm_i830_clear_t __user *) arg, sizeof(clear))) |
1336 | return -EFAULT; | 1331 | return -EFAULT; |
1337 | 1332 | ||
1338 | LOCK_TEST_WITH_RETURN(dev, filp); | 1333 | LOCK_TEST_WITH_RETURN(dev, file_priv); |
1339 | 1334 | ||
1340 | /* GH: Someone's doing nasty things... */ | 1335 | /* GH: Someone's doing nasty things... */ |
1341 | if (!dev->dev_private) { | 1336 | if (!dev->dev_private) { |
@@ -1348,15 +1343,14 @@ static int i830_clear_bufs(struct inode *inode, struct file *filp, | |||
1348 | return 0; | 1343 | return 0; |
1349 | } | 1344 | } |
1350 | 1345 | ||
1351 | static int i830_swap_bufs(struct inode *inode, struct file *filp, | 1346 | static int i830_swap_bufs(struct inode *inode, struct drm_file *file_priv, |
1352 | unsigned int cmd, unsigned long arg) | 1347 | unsigned int cmd, unsigned long arg) |
1353 | { | 1348 | { |
1354 | struct drm_file *priv = filp->private_data; | 1349 | struct drm_device *dev = file_priv->head->dev; |
1355 | struct drm_device *dev = priv->head->dev; | ||
1356 | 1350 | ||
1357 | DRM_DEBUG("i830_swap_bufs\n"); | 1351 | DRM_DEBUG("i830_swap_bufs\n"); |
1358 | 1352 | ||
1359 | LOCK_TEST_WITH_RETURN(dev, filp); | 1353 | LOCK_TEST_WITH_RETURN(dev, file_priv); |
1360 | 1354 | ||
1361 | i830_dma_dispatch_swap(dev); | 1355 | i830_dma_dispatch_swap(dev); |
1362 | return 0; | 1356 | return 0; |
@@ -1386,16 +1380,15 @@ static int i830_do_cleanup_pageflip(struct drm_device * dev) | |||
1386 | return 0; | 1380 | return 0; |
1387 | } | 1381 | } |
1388 | 1382 | ||
1389 | static int i830_flip_bufs(struct inode *inode, struct file *filp, | 1383 | static int i830_flip_bufs(struct inode *inode, struct drm_file *file_priv, |
1390 | unsigned int cmd, unsigned long arg) | 1384 | unsigned int cmd, unsigned long arg) |
1391 | { | 1385 | { |
1392 | struct drm_file *priv = filp->private_data; | 1386 | struct drm_device *dev = file_priv->head->dev; |
1393 | struct drm_device *dev = priv->head->dev; | ||
1394 | drm_i830_private_t *dev_priv = dev->dev_private; | 1387 | drm_i830_private_t *dev_priv = dev->dev_private; |
1395 | 1388 | ||
1396 | DRM_DEBUG("%s\n", __FUNCTION__); | 1389 | DRM_DEBUG("%s\n", __FUNCTION__); |
1397 | 1390 | ||
1398 | LOCK_TEST_WITH_RETURN(dev, filp); | 1391 | LOCK_TEST_WITH_RETURN(dev, file_priv); |
1399 | 1392 | ||
1400 | if (!dev_priv->page_flipping) | 1393 | if (!dev_priv->page_flipping) |
1401 | i830_do_init_pageflip(dev); | 1394 | i830_do_init_pageflip(dev); |
@@ -1404,11 +1397,10 @@ static int i830_flip_bufs(struct inode *inode, struct file *filp, | |||
1404 | return 0; | 1397 | return 0; |
1405 | } | 1398 | } |
1406 | 1399 | ||
1407 | static int i830_getage(struct inode *inode, struct file *filp, unsigned int cmd, | 1400 | static int i830_getage(struct inode *inode, struct drm_file *file_priv, unsigned int cmd, |
1408 | unsigned long arg) | 1401 | unsigned long arg) |
1409 | { | 1402 | { |
1410 | struct drm_file *priv = filp->private_data; | 1403 | struct drm_device *dev = file_priv->head->dev; |
1411 | struct drm_device *dev = priv->head->dev; | ||
1412 | drm_i830_private_t *dev_priv = (drm_i830_private_t *) dev->dev_private; | 1404 | drm_i830_private_t *dev_priv = (drm_i830_private_t *) dev->dev_private; |
1413 | u32 *hw_status = dev_priv->hw_status_page; | 1405 | u32 *hw_status = dev_priv->hw_status_page; |
1414 | drm_i830_sarea_t *sarea_priv = (drm_i830_sarea_t *) | 1406 | drm_i830_sarea_t *sarea_priv = (drm_i830_sarea_t *) |
@@ -1418,11 +1410,10 @@ static int i830_getage(struct inode *inode, struct file *filp, unsigned int cmd, | |||
1418 | return 0; | 1410 | return 0; |
1419 | } | 1411 | } |
1420 | 1412 | ||
1421 | static int i830_getbuf(struct inode *inode, struct file *filp, unsigned int cmd, | 1413 | static int i830_getbuf(struct inode *inode, struct drm_file *file_priv, |
1422 | unsigned long arg) | 1414 | unsigned int cmd, unsigned long arg) |
1423 | { | 1415 | { |
1424 | struct drm_file *priv = filp->private_data; | 1416 | struct drm_device *dev = file_priv->head->dev; |
1425 | struct drm_device *dev = priv->head->dev; | ||
1426 | int retcode = 0; | 1417 | int retcode = 0; |
1427 | drm_i830_dma_t d; | 1418 | drm_i830_dma_t d; |
1428 | drm_i830_private_t *dev_priv = (drm_i830_private_t *) dev->dev_private; | 1419 | drm_i830_private_t *dev_priv = (drm_i830_private_t *) dev->dev_private; |
@@ -1434,11 +1425,11 @@ static int i830_getbuf(struct inode *inode, struct file *filp, unsigned int cmd, | |||
1434 | if (copy_from_user(&d, (drm_i830_dma_t __user *) arg, sizeof(d))) | 1425 | if (copy_from_user(&d, (drm_i830_dma_t __user *) arg, sizeof(d))) |
1435 | return -EFAULT; | 1426 | return -EFAULT; |
1436 | 1427 | ||
1437 | LOCK_TEST_WITH_RETURN(dev, filp); | 1428 | LOCK_TEST_WITH_RETURN(dev, file_priv); |
1438 | 1429 | ||
1439 | d.granted = 0; | 1430 | d.granted = 0; |
1440 | 1431 | ||
1441 | retcode = i830_dma_get_buffer(dev, &d, filp); | 1432 | retcode = i830_dma_get_buffer(dev, &d, file_priv); |
1442 | 1433 | ||
1443 | DRM_DEBUG("i830_dma: %d returning %d, granted = %d\n", | 1434 | DRM_DEBUG("i830_dma: %d returning %d, granted = %d\n", |
1444 | current->pid, retcode, d.granted); | 1435 | current->pid, retcode, d.granted); |
@@ -1451,23 +1442,22 @@ static int i830_getbuf(struct inode *inode, struct file *filp, unsigned int cmd, | |||
1451 | } | 1442 | } |
1452 | 1443 | ||
1453 | static int i830_copybuf(struct inode *inode, | 1444 | static int i830_copybuf(struct inode *inode, |
1454 | struct file *filp, unsigned int cmd, unsigned long arg) | 1445 | struct drm_file *file_priv, unsigned int cmd, unsigned long arg) |
1455 | { | 1446 | { |
1456 | /* Never copy - 2.4.x doesn't need it */ | 1447 | /* Never copy - 2.4.x doesn't need it */ |
1457 | return 0; | 1448 | return 0; |
1458 | } | 1449 | } |
1459 | 1450 | ||
1460 | static int i830_docopy(struct inode *inode, struct file *filp, unsigned int cmd, | 1451 | static int i830_docopy(struct inode *inode, struct drm_file *file_priv, unsigned int cmd, |
1461 | unsigned long arg) | 1452 | unsigned long arg) |
1462 | { | 1453 | { |
1463 | return 0; | 1454 | return 0; |
1464 | } | 1455 | } |
1465 | 1456 | ||
1466 | static int i830_getparam(struct inode *inode, struct file *filp, | 1457 | static int i830_getparam(struct inode *inode, struct drm_file *file_priv, |
1467 | unsigned int cmd, unsigned long arg) | 1458 | unsigned int cmd, unsigned long arg) |
1468 | { | 1459 | { |
1469 | struct drm_file *priv = filp->private_data; | 1460 | struct drm_device *dev = file_priv->head->dev; |
1470 | struct drm_device *dev = priv->head->dev; | ||
1471 | drm_i830_private_t *dev_priv = dev->dev_private; | 1461 | drm_i830_private_t *dev_priv = dev->dev_private; |
1472 | drm_i830_getparam_t param; | 1462 | drm_i830_getparam_t param; |
1473 | int value; | 1463 | int value; |
@@ -1497,11 +1487,10 @@ static int i830_getparam(struct inode *inode, struct file *filp, | |||
1497 | return 0; | 1487 | return 0; |
1498 | } | 1488 | } |
1499 | 1489 | ||
1500 | static int i830_setparam(struct inode *inode, struct file *filp, | 1490 | static int i830_setparam(struct inode *inode, struct drm_file *file_priv, |
1501 | unsigned int cmd, unsigned long arg) | 1491 | unsigned int cmd, unsigned long arg) |
1502 | { | 1492 | { |
1503 | struct drm_file *priv = filp->private_data; | 1493 | struct drm_device *dev = file_priv->head->dev; |
1504 | struct drm_device *dev = priv->head->dev; | ||
1505 | drm_i830_private_t *dev_priv = dev->dev_private; | 1494 | drm_i830_private_t *dev_priv = dev->dev_private; |
1506 | drm_i830_setparam_t param; | 1495 | drm_i830_setparam_t param; |
1507 | 1496 | ||
@@ -1542,7 +1531,7 @@ void i830_driver_lastclose(struct drm_device * dev) | |||
1542 | i830_dma_cleanup(dev); | 1531 | i830_dma_cleanup(dev); |
1543 | } | 1532 | } |
1544 | 1533 | ||
1545 | void i830_driver_preclose(struct drm_device * dev, DRMFILE filp) | 1534 | void i830_driver_preclose(struct drm_device * dev, struct drm_file *file_priv) |
1546 | { | 1535 | { |
1547 | if (dev->dev_private) { | 1536 | if (dev->dev_private) { |
1548 | drm_i830_private_t *dev_priv = dev->dev_private; | 1537 | drm_i830_private_t *dev_priv = dev->dev_private; |
@@ -1552,9 +1541,9 @@ void i830_driver_preclose(struct drm_device * dev, DRMFILE filp) | |||
1552 | } | 1541 | } |
1553 | } | 1542 | } |
1554 | 1543 | ||
1555 | void i830_driver_reclaim_buffers_locked(struct drm_device * dev, struct file *filp) | 1544 | void i830_driver_reclaim_buffers_locked(struct drm_device * dev, struct drm_file *file_priv) |
1556 | { | 1545 | { |
1557 | i830_reclaim_buffers(dev, filp); | 1546 | i830_reclaim_buffers(dev, file_priv); |
1558 | } | 1547 | } |
1559 | 1548 | ||
1560 | int i830_driver_dma_quiescent(struct drm_device * dev) | 1549 | int i830_driver_dma_quiescent(struct drm_device * dev) |