diff options
author | Dave Airlie <airlied@redhat.com> | 2008-11-27 23:22:24 -0500 |
---|---|---|
committer | Dave Airlie <airlied@linux.ie> | 2008-12-29 02:47:22 -0500 |
commit | 7c1c2871a6a3a114853ec6836e9035ac1c0c7f7a (patch) | |
tree | 1b5debcc86ff20bd5e11b42ea5c52da42214e376 /drivers/gpu/drm/radeon/radeon_state.c | |
parent | e7f7ab45ebcb54fd5f814ea15ea079e079662f67 (diff) |
drm: move to kref per-master structures.
This is step one towards having multiple masters sharing a drm
device in order to get fast-user-switching to work.
It splits out the information associated with the drm master
into a separate kref counted structure, and allocates this when
a master opens the device node. It also allows the current master
to abdicate (say while VT switched), and a new master to take over
the hardware.
It moves the Intel and radeon drivers to using the sarea from
within the new master structures.
Signed-off-by: Dave Airlie <airlied@redhat.com>
Diffstat (limited to 'drivers/gpu/drm/radeon/radeon_state.c')
-rw-r--r-- | drivers/gpu/drm/radeon/radeon_state.c | 166 |
1 files changed, 92 insertions, 74 deletions
diff --git a/drivers/gpu/drm/radeon/radeon_state.c b/drivers/gpu/drm/radeon/radeon_state.c index 5d7153fcc7b0..ef940a079dcb 100644 --- a/drivers/gpu/drm/radeon/radeon_state.c +++ b/drivers/gpu/drm/radeon/radeon_state.c | |||
@@ -742,13 +742,14 @@ static struct { | |||
742 | */ | 742 | */ |
743 | 743 | ||
744 | static void radeon_clear_box(drm_radeon_private_t * dev_priv, | 744 | static void radeon_clear_box(drm_radeon_private_t * dev_priv, |
745 | struct drm_radeon_master_private *master_priv, | ||
745 | int x, int y, int w, int h, int r, int g, int b) | 746 | int x, int y, int w, int h, int r, int g, int b) |
746 | { | 747 | { |
747 | u32 color; | 748 | u32 color; |
748 | RING_LOCALS; | 749 | RING_LOCALS; |
749 | 750 | ||
750 | x += dev_priv->sarea_priv->boxes[0].x1; | 751 | x += master_priv->sarea_priv->boxes[0].x1; |
751 | y += dev_priv->sarea_priv->boxes[0].y1; | 752 | y += master_priv->sarea_priv->boxes[0].y1; |
752 | 753 | ||
753 | switch (dev_priv->color_fmt) { | 754 | switch (dev_priv->color_fmt) { |
754 | case RADEON_COLOR_FORMAT_RGB565: | 755 | case RADEON_COLOR_FORMAT_RGB565: |
@@ -776,7 +777,7 @@ static void radeon_clear_box(drm_radeon_private_t * dev_priv, | |||
776 | RADEON_GMC_SRC_DATATYPE_COLOR | | 777 | RADEON_GMC_SRC_DATATYPE_COLOR | |
777 | RADEON_ROP3_P | RADEON_GMC_CLR_CMP_CNTL_DIS); | 778 | RADEON_ROP3_P | RADEON_GMC_CLR_CMP_CNTL_DIS); |
778 | 779 | ||
779 | if (dev_priv->sarea_priv->pfCurrentPage == 1) { | 780 | if (master_priv->sarea_priv->pfCurrentPage == 1) { |
780 | OUT_RING(dev_priv->front_pitch_offset); | 781 | OUT_RING(dev_priv->front_pitch_offset); |
781 | } else { | 782 | } else { |
782 | OUT_RING(dev_priv->back_pitch_offset); | 783 | OUT_RING(dev_priv->back_pitch_offset); |
@@ -790,7 +791,7 @@ static void radeon_clear_box(drm_radeon_private_t * dev_priv, | |||
790 | ADVANCE_RING(); | 791 | ADVANCE_RING(); |
791 | } | 792 | } |
792 | 793 | ||
793 | static void radeon_cp_performance_boxes(drm_radeon_private_t * dev_priv) | 794 | static void radeon_cp_performance_boxes(drm_radeon_private_t *dev_priv, struct drm_radeon_master_private *master_priv) |
794 | { | 795 | { |
795 | /* Collapse various things into a wait flag -- trying to | 796 | /* Collapse various things into a wait flag -- trying to |
796 | * guess if userspase slept -- better just to have them tell us. | 797 | * guess if userspase slept -- better just to have them tell us. |
@@ -807,12 +808,12 @@ static void radeon_cp_performance_boxes(drm_radeon_private_t * dev_priv) | |||
807 | /* Purple box for page flipping | 808 | /* Purple box for page flipping |
808 | */ | 809 | */ |
809 | if (dev_priv->stats.boxes & RADEON_BOX_FLIP) | 810 | if (dev_priv->stats.boxes & RADEON_BOX_FLIP) |
810 | radeon_clear_box(dev_priv, 4, 4, 8, 8, 255, 0, 255); | 811 | radeon_clear_box(dev_priv, master_priv, 4, 4, 8, 8, 255, 0, 255); |
811 | 812 | ||
812 | /* Red box if we have to wait for idle at any point | 813 | /* Red box if we have to wait for idle at any point |
813 | */ | 814 | */ |
814 | if (dev_priv->stats.boxes & RADEON_BOX_WAIT_IDLE) | 815 | if (dev_priv->stats.boxes & RADEON_BOX_WAIT_IDLE) |
815 | radeon_clear_box(dev_priv, 16, 4, 8, 8, 255, 0, 0); | 816 | radeon_clear_box(dev_priv, master_priv, 16, 4, 8, 8, 255, 0, 0); |
816 | 817 | ||
817 | /* Blue box: lost context? | 818 | /* Blue box: lost context? |
818 | */ | 819 | */ |
@@ -820,12 +821,12 @@ static void radeon_cp_performance_boxes(drm_radeon_private_t * dev_priv) | |||
820 | /* Yellow box for texture swaps | 821 | /* Yellow box for texture swaps |
821 | */ | 822 | */ |
822 | if (dev_priv->stats.boxes & RADEON_BOX_TEXTURE_LOAD) | 823 | if (dev_priv->stats.boxes & RADEON_BOX_TEXTURE_LOAD) |
823 | radeon_clear_box(dev_priv, 40, 4, 8, 8, 255, 255, 0); | 824 | radeon_clear_box(dev_priv, master_priv, 40, 4, 8, 8, 255, 255, 0); |
824 | 825 | ||
825 | /* Green box if hardware never idles (as far as we can tell) | 826 | /* Green box if hardware never idles (as far as we can tell) |
826 | */ | 827 | */ |
827 | if (!(dev_priv->stats.boxes & RADEON_BOX_DMA_IDLE)) | 828 | if (!(dev_priv->stats.boxes & RADEON_BOX_DMA_IDLE)) |
828 | radeon_clear_box(dev_priv, 64, 4, 8, 8, 0, 255, 0); | 829 | radeon_clear_box(dev_priv, master_priv, 64, 4, 8, 8, 0, 255, 0); |
829 | 830 | ||
830 | /* Draw bars indicating number of buffers allocated | 831 | /* Draw bars indicating number of buffers allocated |
831 | * (not a great measure, easily confused) | 832 | * (not a great measure, easily confused) |
@@ -834,7 +835,7 @@ static void radeon_cp_performance_boxes(drm_radeon_private_t * dev_priv) | |||
834 | if (dev_priv->stats.requested_bufs > 100) | 835 | if (dev_priv->stats.requested_bufs > 100) |
835 | dev_priv->stats.requested_bufs = 100; | 836 | dev_priv->stats.requested_bufs = 100; |
836 | 837 | ||
837 | radeon_clear_box(dev_priv, 4, 16, | 838 | radeon_clear_box(dev_priv, master_priv, 4, 16, |
838 | dev_priv->stats.requested_bufs, 4, | 839 | dev_priv->stats.requested_bufs, 4, |
839 | 196, 128, 128); | 840 | 196, 128, 128); |
840 | } | 841 | } |
@@ -848,11 +849,13 @@ static void radeon_cp_performance_boxes(drm_radeon_private_t * dev_priv) | |||
848 | */ | 849 | */ |
849 | 850 | ||
850 | static void radeon_cp_dispatch_clear(struct drm_device * dev, | 851 | static void radeon_cp_dispatch_clear(struct drm_device * dev, |
852 | struct drm_master *master, | ||
851 | drm_radeon_clear_t * clear, | 853 | drm_radeon_clear_t * clear, |
852 | drm_radeon_clear_rect_t * depth_boxes) | 854 | drm_radeon_clear_rect_t * depth_boxes) |
853 | { | 855 | { |
854 | drm_radeon_private_t *dev_priv = dev->dev_private; | 856 | drm_radeon_private_t *dev_priv = dev->dev_private; |
855 | drm_radeon_sarea_t *sarea_priv = dev_priv->sarea_priv; | 857 | struct drm_radeon_master_private *master_priv = master->driver_priv; |
858 | drm_radeon_sarea_t *sarea_priv = master_priv->sarea_priv; | ||
856 | drm_radeon_depth_clear_t *depth_clear = &dev_priv->depth_clear; | 859 | drm_radeon_depth_clear_t *depth_clear = &dev_priv->depth_clear; |
857 | int nbox = sarea_priv->nbox; | 860 | int nbox = sarea_priv->nbox; |
858 | struct drm_clip_rect *pbox = sarea_priv->boxes; | 861 | struct drm_clip_rect *pbox = sarea_priv->boxes; |
@@ -864,7 +867,7 @@ static void radeon_cp_dispatch_clear(struct drm_device * dev, | |||
864 | 867 | ||
865 | dev_priv->stats.clears++; | 868 | dev_priv->stats.clears++; |
866 | 869 | ||
867 | if (dev_priv->sarea_priv->pfCurrentPage == 1) { | 870 | if (sarea_priv->pfCurrentPage == 1) { |
868 | unsigned int tmp = flags; | 871 | unsigned int tmp = flags; |
869 | 872 | ||
870 | flags &= ~(RADEON_FRONT | RADEON_BACK); | 873 | flags &= ~(RADEON_FRONT | RADEON_BACK); |
@@ -890,7 +893,7 @@ static void radeon_cp_dispatch_clear(struct drm_device * dev, | |||
890 | 893 | ||
891 | /* Make sure we restore the 3D state next time. | 894 | /* Make sure we restore the 3D state next time. |
892 | */ | 895 | */ |
893 | dev_priv->sarea_priv->ctx_owner = 0; | 896 | sarea_priv->ctx_owner = 0; |
894 | 897 | ||
895 | for (i = 0; i < nbox; i++) { | 898 | for (i = 0; i < nbox; i++) { |
896 | int x = pbox[i].x1; | 899 | int x = pbox[i].x1; |
@@ -967,7 +970,7 @@ static void radeon_cp_dispatch_clear(struct drm_device * dev, | |||
967 | /* Make sure we restore the 3D state next time. | 970 | /* Make sure we restore the 3D state next time. |
968 | * we haven't touched any "normal" state - still need this? | 971 | * we haven't touched any "normal" state - still need this? |
969 | */ | 972 | */ |
970 | dev_priv->sarea_priv->ctx_owner = 0; | 973 | sarea_priv->ctx_owner = 0; |
971 | 974 | ||
972 | if ((dev_priv->flags & RADEON_HAS_HIERZ) | 975 | if ((dev_priv->flags & RADEON_HAS_HIERZ) |
973 | && (flags & RADEON_USE_HIERZ)) { | 976 | && (flags & RADEON_USE_HIERZ)) { |
@@ -1214,7 +1217,7 @@ static void radeon_cp_dispatch_clear(struct drm_device * dev, | |||
1214 | 1217 | ||
1215 | /* Make sure we restore the 3D state next time. | 1218 | /* Make sure we restore the 3D state next time. |
1216 | */ | 1219 | */ |
1217 | dev_priv->sarea_priv->ctx_owner = 0; | 1220 | sarea_priv->ctx_owner = 0; |
1218 | 1221 | ||
1219 | for (i = 0; i < nbox; i++) { | 1222 | for (i = 0; i < nbox; i++) { |
1220 | 1223 | ||
@@ -1285,7 +1288,7 @@ static void radeon_cp_dispatch_clear(struct drm_device * dev, | |||
1285 | 1288 | ||
1286 | /* Make sure we restore the 3D state next time. | 1289 | /* Make sure we restore the 3D state next time. |
1287 | */ | 1290 | */ |
1288 | dev_priv->sarea_priv->ctx_owner = 0; | 1291 | sarea_priv->ctx_owner = 0; |
1289 | 1292 | ||
1290 | for (i = 0; i < nbox; i++) { | 1293 | for (i = 0; i < nbox; i++) { |
1291 | 1294 | ||
@@ -1328,20 +1331,21 @@ static void radeon_cp_dispatch_clear(struct drm_device * dev, | |||
1328 | * wait on this value before performing the clear ioctl. We | 1331 | * wait on this value before performing the clear ioctl. We |
1329 | * need this because the card's so damned fast... | 1332 | * need this because the card's so damned fast... |
1330 | */ | 1333 | */ |
1331 | dev_priv->sarea_priv->last_clear++; | 1334 | sarea_priv->last_clear++; |
1332 | 1335 | ||
1333 | BEGIN_RING(4); | 1336 | BEGIN_RING(4); |
1334 | 1337 | ||
1335 | RADEON_CLEAR_AGE(dev_priv->sarea_priv->last_clear); | 1338 | RADEON_CLEAR_AGE(sarea_priv->last_clear); |
1336 | RADEON_WAIT_UNTIL_IDLE(); | 1339 | RADEON_WAIT_UNTIL_IDLE(); |
1337 | 1340 | ||
1338 | ADVANCE_RING(); | 1341 | ADVANCE_RING(); |
1339 | } | 1342 | } |
1340 | 1343 | ||
1341 | static void radeon_cp_dispatch_swap(struct drm_device * dev) | 1344 | static void radeon_cp_dispatch_swap(struct drm_device *dev, struct drm_master *master) |
1342 | { | 1345 | { |
1343 | drm_radeon_private_t *dev_priv = dev->dev_private; | 1346 | drm_radeon_private_t *dev_priv = dev->dev_private; |
1344 | drm_radeon_sarea_t *sarea_priv = dev_priv->sarea_priv; | 1347 | struct drm_radeon_master_private *master_priv = master->driver_priv; |
1348 | drm_radeon_sarea_t *sarea_priv = master_priv->sarea_priv; | ||
1345 | int nbox = sarea_priv->nbox; | 1349 | int nbox = sarea_priv->nbox; |
1346 | struct drm_clip_rect *pbox = sarea_priv->boxes; | 1350 | struct drm_clip_rect *pbox = sarea_priv->boxes; |
1347 | int i; | 1351 | int i; |
@@ -1351,7 +1355,7 @@ static void radeon_cp_dispatch_swap(struct drm_device * dev) | |||
1351 | /* Do some trivial performance monitoring... | 1355 | /* Do some trivial performance monitoring... |
1352 | */ | 1356 | */ |
1353 | if (dev_priv->do_boxes) | 1357 | if (dev_priv->do_boxes) |
1354 | radeon_cp_performance_boxes(dev_priv); | 1358 | radeon_cp_performance_boxes(dev_priv, master_priv); |
1355 | 1359 | ||
1356 | /* Wait for the 3D stream to idle before dispatching the bitblt. | 1360 | /* Wait for the 3D stream to idle before dispatching the bitblt. |
1357 | * This will prevent data corruption between the two streams. | 1361 | * This will prevent data corruption between the two streams. |
@@ -1385,7 +1389,7 @@ static void radeon_cp_dispatch_swap(struct drm_device * dev) | |||
1385 | /* Make this work even if front & back are flipped: | 1389 | /* Make this work even if front & back are flipped: |
1386 | */ | 1390 | */ |
1387 | OUT_RING(CP_PACKET0(RADEON_SRC_PITCH_OFFSET, 1)); | 1391 | OUT_RING(CP_PACKET0(RADEON_SRC_PITCH_OFFSET, 1)); |
1388 | if (dev_priv->sarea_priv->pfCurrentPage == 0) { | 1392 | if (sarea_priv->pfCurrentPage == 0) { |
1389 | OUT_RING(dev_priv->back_pitch_offset); | 1393 | OUT_RING(dev_priv->back_pitch_offset); |
1390 | OUT_RING(dev_priv->front_pitch_offset); | 1394 | OUT_RING(dev_priv->front_pitch_offset); |
1391 | } else { | 1395 | } else { |
@@ -1405,31 +1409,32 @@ static void radeon_cp_dispatch_swap(struct drm_device * dev) | |||
1405 | * throttle the framerate by waiting for this value before | 1409 | * throttle the framerate by waiting for this value before |
1406 | * performing the swapbuffer ioctl. | 1410 | * performing the swapbuffer ioctl. |
1407 | */ | 1411 | */ |
1408 | dev_priv->sarea_priv->last_frame++; | 1412 | sarea_priv->last_frame++; |
1409 | 1413 | ||
1410 | BEGIN_RING(4); | 1414 | BEGIN_RING(4); |
1411 | 1415 | ||
1412 | RADEON_FRAME_AGE(dev_priv->sarea_priv->last_frame); | 1416 | RADEON_FRAME_AGE(sarea_priv->last_frame); |
1413 | RADEON_WAIT_UNTIL_2D_IDLE(); | 1417 | RADEON_WAIT_UNTIL_2D_IDLE(); |
1414 | 1418 | ||
1415 | ADVANCE_RING(); | 1419 | ADVANCE_RING(); |
1416 | } | 1420 | } |
1417 | 1421 | ||
1418 | static void radeon_cp_dispatch_flip(struct drm_device * dev) | 1422 | void radeon_cp_dispatch_flip(struct drm_device *dev, struct drm_master *master) |
1419 | { | 1423 | { |
1420 | drm_radeon_private_t *dev_priv = dev->dev_private; | 1424 | drm_radeon_private_t *dev_priv = dev->dev_private; |
1421 | struct drm_sarea *sarea = (struct drm_sarea *) dev_priv->sarea->handle; | 1425 | struct drm_radeon_master_private *master_priv = master->driver_priv; |
1422 | int offset = (dev_priv->sarea_priv->pfCurrentPage == 1) | 1426 | struct drm_sarea *sarea = (struct drm_sarea *)master_priv->sarea->handle; |
1427 | int offset = (master_priv->sarea_priv->pfCurrentPage == 1) | ||
1423 | ? dev_priv->front_offset : dev_priv->back_offset; | 1428 | ? dev_priv->front_offset : dev_priv->back_offset; |
1424 | RING_LOCALS; | 1429 | RING_LOCALS; |
1425 | DRM_DEBUG("pfCurrentPage=%d\n", | 1430 | DRM_DEBUG("pfCurrentPage=%d\n", |
1426 | dev_priv->sarea_priv->pfCurrentPage); | 1431 | master_priv->sarea_priv->pfCurrentPage); |
1427 | 1432 | ||
1428 | /* Do some trivial performance monitoring... | 1433 | /* Do some trivial performance monitoring... |
1429 | */ | 1434 | */ |
1430 | if (dev_priv->do_boxes) { | 1435 | if (dev_priv->do_boxes) { |
1431 | dev_priv->stats.boxes |= RADEON_BOX_FLIP; | 1436 | dev_priv->stats.boxes |= RADEON_BOX_FLIP; |
1432 | radeon_cp_performance_boxes(dev_priv); | 1437 | radeon_cp_performance_boxes(dev_priv, master_priv); |
1433 | } | 1438 | } |
1434 | 1439 | ||
1435 | /* Update the frame offsets for both CRTCs | 1440 | /* Update the frame offsets for both CRTCs |
@@ -1441,7 +1446,7 @@ static void radeon_cp_dispatch_flip(struct drm_device * dev) | |||
1441 | ((sarea->frame.y * dev_priv->front_pitch + | 1446 | ((sarea->frame.y * dev_priv->front_pitch + |
1442 | sarea->frame.x * (dev_priv->color_fmt - 2)) & ~7) | 1447 | sarea->frame.x * (dev_priv->color_fmt - 2)) & ~7) |
1443 | + offset); | 1448 | + offset); |
1444 | OUT_RING_REG(RADEON_CRTC2_OFFSET, dev_priv->sarea_priv->crtc2_base | 1449 | OUT_RING_REG(RADEON_CRTC2_OFFSET, master_priv->sarea_priv->crtc2_base |
1445 | + offset); | 1450 | + offset); |
1446 | 1451 | ||
1447 | ADVANCE_RING(); | 1452 | ADVANCE_RING(); |
@@ -1450,13 +1455,13 @@ static void radeon_cp_dispatch_flip(struct drm_device * dev) | |||
1450 | * throttle the framerate by waiting for this value before | 1455 | * throttle the framerate by waiting for this value before |
1451 | * performing the swapbuffer ioctl. | 1456 | * performing the swapbuffer ioctl. |
1452 | */ | 1457 | */ |
1453 | dev_priv->sarea_priv->last_frame++; | 1458 | master_priv->sarea_priv->last_frame++; |
1454 | dev_priv->sarea_priv->pfCurrentPage = | 1459 | master_priv->sarea_priv->pfCurrentPage = |
1455 | 1 - dev_priv->sarea_priv->pfCurrentPage; | 1460 | 1 - master_priv->sarea_priv->pfCurrentPage; |
1456 | 1461 | ||
1457 | BEGIN_RING(2); | 1462 | BEGIN_RING(2); |
1458 | 1463 | ||
1459 | RADEON_FRAME_AGE(dev_priv->sarea_priv->last_frame); | 1464 | RADEON_FRAME_AGE(master_priv->sarea_priv->last_frame); |
1460 | 1465 | ||
1461 | ADVANCE_RING(); | 1466 | ADVANCE_RING(); |
1462 | } | 1467 | } |
@@ -1494,11 +1499,13 @@ typedef struct { | |||
1494 | } drm_radeon_tcl_prim_t; | 1499 | } drm_radeon_tcl_prim_t; |
1495 | 1500 | ||
1496 | static void radeon_cp_dispatch_vertex(struct drm_device * dev, | 1501 | static void radeon_cp_dispatch_vertex(struct drm_device * dev, |
1502 | struct drm_file *file_priv, | ||
1497 | struct drm_buf * buf, | 1503 | struct drm_buf * buf, |
1498 | drm_radeon_tcl_prim_t * prim) | 1504 | drm_radeon_tcl_prim_t * prim) |
1499 | { | 1505 | { |
1500 | drm_radeon_private_t *dev_priv = dev->dev_private; | 1506 | drm_radeon_private_t *dev_priv = dev->dev_private; |
1501 | drm_radeon_sarea_t *sarea_priv = dev_priv->sarea_priv; | 1507 | struct drm_radeon_master_private *master_priv = file_priv->master->driver_priv; |
1508 | drm_radeon_sarea_t *sarea_priv = master_priv->sarea_priv; | ||
1502 | int offset = dev_priv->gart_buffers_offset + buf->offset + prim->start; | 1509 | int offset = dev_priv->gart_buffers_offset + buf->offset + prim->start; |
1503 | int numverts = (int)prim->numverts; | 1510 | int numverts = (int)prim->numverts; |
1504 | int nbox = sarea_priv->nbox; | 1511 | int nbox = sarea_priv->nbox; |
@@ -1539,13 +1546,14 @@ static void radeon_cp_dispatch_vertex(struct drm_device * dev, | |||
1539 | } while (i < nbox); | 1546 | } while (i < nbox); |
1540 | } | 1547 | } |
1541 | 1548 | ||
1542 | static void radeon_cp_discard_buffer(struct drm_device * dev, struct drm_buf * buf) | 1549 | static void radeon_cp_discard_buffer(struct drm_device *dev, struct drm_master *master, struct drm_buf *buf) |
1543 | { | 1550 | { |
1544 | drm_radeon_private_t *dev_priv = dev->dev_private; | 1551 | drm_radeon_private_t *dev_priv = dev->dev_private; |
1552 | struct drm_radeon_master_private *master_priv = master->driver_priv; | ||
1545 | drm_radeon_buf_priv_t *buf_priv = buf->dev_private; | 1553 | drm_radeon_buf_priv_t *buf_priv = buf->dev_private; |
1546 | RING_LOCALS; | 1554 | RING_LOCALS; |
1547 | 1555 | ||
1548 | buf_priv->age = ++dev_priv->sarea_priv->last_dispatch; | 1556 | buf_priv->age = ++master_priv->sarea_priv->last_dispatch; |
1549 | 1557 | ||
1550 | /* Emit the vertex buffer age */ | 1558 | /* Emit the vertex buffer age */ |
1551 | BEGIN_RING(2); | 1559 | BEGIN_RING(2); |
@@ -1590,12 +1598,14 @@ static void radeon_cp_dispatch_indirect(struct drm_device * dev, | |||
1590 | } | 1598 | } |
1591 | } | 1599 | } |
1592 | 1600 | ||
1593 | static void radeon_cp_dispatch_indices(struct drm_device * dev, | 1601 | static void radeon_cp_dispatch_indices(struct drm_device *dev, |
1602 | struct drm_master *master, | ||
1594 | struct drm_buf * elt_buf, | 1603 | struct drm_buf * elt_buf, |
1595 | drm_radeon_tcl_prim_t * prim) | 1604 | drm_radeon_tcl_prim_t * prim) |
1596 | { | 1605 | { |
1597 | drm_radeon_private_t *dev_priv = dev->dev_private; | 1606 | drm_radeon_private_t *dev_priv = dev->dev_private; |
1598 | drm_radeon_sarea_t *sarea_priv = dev_priv->sarea_priv; | 1607 | struct drm_radeon_master_private *master_priv = master->driver_priv; |
1608 | drm_radeon_sarea_t *sarea_priv = master_priv->sarea_priv; | ||
1599 | int offset = dev_priv->gart_buffers_offset + prim->offset; | 1609 | int offset = dev_priv->gart_buffers_offset + prim->offset; |
1600 | u32 *data; | 1610 | u32 *data; |
1601 | int dwords; | 1611 | int dwords; |
@@ -1870,7 +1880,7 @@ static int radeon_cp_dispatch_texture(struct drm_device * dev, | |||
1870 | ADVANCE_RING(); | 1880 | ADVANCE_RING(); |
1871 | COMMIT_RING(); | 1881 | COMMIT_RING(); |
1872 | 1882 | ||
1873 | radeon_cp_discard_buffer(dev, buf); | 1883 | radeon_cp_discard_buffer(dev, file_priv->master, buf); |
1874 | 1884 | ||
1875 | /* Update the input parameters for next time */ | 1885 | /* Update the input parameters for next time */ |
1876 | image->y += height; | 1886 | image->y += height; |
@@ -2110,7 +2120,8 @@ static int radeon_surface_free(struct drm_device *dev, void *data, struct drm_fi | |||
2110 | static int radeon_cp_clear(struct drm_device *dev, void *data, struct drm_file *file_priv) | 2120 | static int radeon_cp_clear(struct drm_device *dev, void *data, struct drm_file *file_priv) |
2111 | { | 2121 | { |
2112 | drm_radeon_private_t *dev_priv = dev->dev_private; | 2122 | drm_radeon_private_t *dev_priv = dev->dev_private; |
2113 | drm_radeon_sarea_t *sarea_priv = dev_priv->sarea_priv; | 2123 | struct drm_radeon_master_private *master_priv = file_priv->master->driver_priv; |
2124 | drm_radeon_sarea_t *sarea_priv = master_priv->sarea_priv; | ||
2114 | drm_radeon_clear_t *clear = data; | 2125 | drm_radeon_clear_t *clear = data; |
2115 | drm_radeon_clear_rect_t depth_boxes[RADEON_NR_SAREA_CLIPRECTS]; | 2126 | drm_radeon_clear_rect_t depth_boxes[RADEON_NR_SAREA_CLIPRECTS]; |
2116 | DRM_DEBUG("\n"); | 2127 | DRM_DEBUG("\n"); |
@@ -2126,7 +2137,7 @@ static int radeon_cp_clear(struct drm_device *dev, void *data, struct drm_file * | |||
2126 | sarea_priv->nbox * sizeof(depth_boxes[0]))) | 2137 | sarea_priv->nbox * sizeof(depth_boxes[0]))) |
2127 | return -EFAULT; | 2138 | return -EFAULT; |
2128 | 2139 | ||
2129 | radeon_cp_dispatch_clear(dev, clear, depth_boxes); | 2140 | radeon_cp_dispatch_clear(dev, file_priv->master, clear, depth_boxes); |
2130 | 2141 | ||
2131 | COMMIT_RING(); | 2142 | COMMIT_RING(); |
2132 | return 0; | 2143 | return 0; |
@@ -2134,9 +2145,10 @@ static int radeon_cp_clear(struct drm_device *dev, void *data, struct drm_file * | |||
2134 | 2145 | ||
2135 | /* Not sure why this isn't set all the time: | 2146 | /* Not sure why this isn't set all the time: |
2136 | */ | 2147 | */ |
2137 | static int radeon_do_init_pageflip(struct drm_device * dev) | 2148 | static int radeon_do_init_pageflip(struct drm_device *dev, struct drm_master *master) |
2138 | { | 2149 | { |
2139 | drm_radeon_private_t *dev_priv = dev->dev_private; | 2150 | drm_radeon_private_t *dev_priv = dev->dev_private; |
2151 | struct drm_radeon_master_private *master_priv = master->driver_priv; | ||
2140 | RING_LOCALS; | 2152 | RING_LOCALS; |
2141 | 2153 | ||
2142 | DRM_DEBUG("\n"); | 2154 | DRM_DEBUG("\n"); |
@@ -2153,8 +2165,8 @@ static int radeon_do_init_pageflip(struct drm_device * dev) | |||
2153 | 2165 | ||
2154 | dev_priv->page_flipping = 1; | 2166 | dev_priv->page_flipping = 1; |
2155 | 2167 | ||
2156 | if (dev_priv->sarea_priv->pfCurrentPage != 1) | 2168 | if (master_priv->sarea_priv->pfCurrentPage != 1) |
2157 | dev_priv->sarea_priv->pfCurrentPage = 0; | 2169 | master_priv->sarea_priv->pfCurrentPage = 0; |
2158 | 2170 | ||
2159 | return 0; | 2171 | return 0; |
2160 | } | 2172 | } |
@@ -2172,9 +2184,9 @@ static int radeon_cp_flip(struct drm_device *dev, void *data, struct drm_file *f | |||
2172 | RING_SPACE_TEST_WITH_RETURN(dev_priv); | 2184 | RING_SPACE_TEST_WITH_RETURN(dev_priv); |
2173 | 2185 | ||
2174 | if (!dev_priv->page_flipping) | 2186 | if (!dev_priv->page_flipping) |
2175 | radeon_do_init_pageflip(dev); | 2187 | radeon_do_init_pageflip(dev, file_priv->master); |
2176 | 2188 | ||
2177 | radeon_cp_dispatch_flip(dev); | 2189 | radeon_cp_dispatch_flip(dev, file_priv->master); |
2178 | 2190 | ||
2179 | COMMIT_RING(); | 2191 | COMMIT_RING(); |
2180 | return 0; | 2192 | return 0; |
@@ -2183,7 +2195,9 @@ static int radeon_cp_flip(struct drm_device *dev, void *data, struct drm_file *f | |||
2183 | static int radeon_cp_swap(struct drm_device *dev, void *data, struct drm_file *file_priv) | 2195 | static int radeon_cp_swap(struct drm_device *dev, void *data, struct drm_file *file_priv) |
2184 | { | 2196 | { |
2185 | drm_radeon_private_t *dev_priv = dev->dev_private; | 2197 | drm_radeon_private_t *dev_priv = dev->dev_private; |
2186 | drm_radeon_sarea_t *sarea_priv = dev_priv->sarea_priv; | 2198 | struct drm_radeon_master_private *master_priv = file_priv->master->driver_priv; |
2199 | drm_radeon_sarea_t *sarea_priv = master_priv->sarea_priv; | ||
2200 | |||
2187 | DRM_DEBUG("\n"); | 2201 | DRM_DEBUG("\n"); |
2188 | 2202 | ||
2189 | LOCK_TEST_WITH_RETURN(dev, file_priv); | 2203 | LOCK_TEST_WITH_RETURN(dev, file_priv); |
@@ -2193,8 +2207,8 @@ static int radeon_cp_swap(struct drm_device *dev, void *data, struct drm_file *f | |||
2193 | if (sarea_priv->nbox > RADEON_NR_SAREA_CLIPRECTS) | 2207 | if (sarea_priv->nbox > RADEON_NR_SAREA_CLIPRECTS) |
2194 | sarea_priv->nbox = RADEON_NR_SAREA_CLIPRECTS; | 2208 | sarea_priv->nbox = RADEON_NR_SAREA_CLIPRECTS; |
2195 | 2209 | ||
2196 | radeon_cp_dispatch_swap(dev); | 2210 | radeon_cp_dispatch_swap(dev, file_priv->master); |
2197 | dev_priv->sarea_priv->ctx_owner = 0; | 2211 | sarea_priv->ctx_owner = 0; |
2198 | 2212 | ||
2199 | COMMIT_RING(); | 2213 | COMMIT_RING(); |
2200 | return 0; | 2214 | return 0; |
@@ -2203,7 +2217,8 @@ static int radeon_cp_swap(struct drm_device *dev, void *data, struct drm_file *f | |||
2203 | static int radeon_cp_vertex(struct drm_device *dev, void *data, struct drm_file *file_priv) | 2217 | static int radeon_cp_vertex(struct drm_device *dev, void *data, struct drm_file *file_priv) |
2204 | { | 2218 | { |
2205 | drm_radeon_private_t *dev_priv = dev->dev_private; | 2219 | drm_radeon_private_t *dev_priv = dev->dev_private; |
2206 | drm_radeon_sarea_t *sarea_priv = dev_priv->sarea_priv; | 2220 | struct drm_radeon_master_private *master_priv = file_priv->master->driver_priv; |
2221 | drm_radeon_sarea_t *sarea_priv; | ||
2207 | struct drm_device_dma *dma = dev->dma; | 2222 | struct drm_device_dma *dma = dev->dma; |
2208 | struct drm_buf *buf; | 2223 | struct drm_buf *buf; |
2209 | drm_radeon_vertex_t *vertex = data; | 2224 | drm_radeon_vertex_t *vertex = data; |
@@ -2211,6 +2226,8 @@ static int radeon_cp_vertex(struct drm_device *dev, void *data, struct drm_file | |||
2211 | 2226 | ||
2212 | LOCK_TEST_WITH_RETURN(dev, file_priv); | 2227 | LOCK_TEST_WITH_RETURN(dev, file_priv); |
2213 | 2228 | ||
2229 | sarea_priv = master_priv->sarea_priv; | ||
2230 | |||
2214 | DRM_DEBUG("pid=%d index=%d count=%d discard=%d\n", | 2231 | DRM_DEBUG("pid=%d index=%d count=%d discard=%d\n", |
2215 | DRM_CURRENTPID, vertex->idx, vertex->count, vertex->discard); | 2232 | DRM_CURRENTPID, vertex->idx, vertex->count, vertex->discard); |
2216 | 2233 | ||
@@ -2263,13 +2280,13 @@ static int radeon_cp_vertex(struct drm_device *dev, void *data, struct drm_file | |||
2263 | prim.finish = vertex->count; /* unused */ | 2280 | prim.finish = vertex->count; /* unused */ |
2264 | prim.prim = vertex->prim; | 2281 | prim.prim = vertex->prim; |
2265 | prim.numverts = vertex->count; | 2282 | prim.numverts = vertex->count; |
2266 | prim.vc_format = dev_priv->sarea_priv->vc_format; | 2283 | prim.vc_format = sarea_priv->vc_format; |
2267 | 2284 | ||
2268 | radeon_cp_dispatch_vertex(dev, buf, &prim); | 2285 | radeon_cp_dispatch_vertex(dev, file_priv, buf, &prim); |
2269 | } | 2286 | } |
2270 | 2287 | ||
2271 | if (vertex->discard) { | 2288 | if (vertex->discard) { |
2272 | radeon_cp_discard_buffer(dev, buf); | 2289 | radeon_cp_discard_buffer(dev, file_priv->master, buf); |
2273 | } | 2290 | } |
2274 | 2291 | ||
2275 | COMMIT_RING(); | 2292 | COMMIT_RING(); |
@@ -2279,7 +2296,8 @@ static int radeon_cp_vertex(struct drm_device *dev, void *data, struct drm_file | |||
2279 | static int radeon_cp_indices(struct drm_device *dev, void *data, struct drm_file *file_priv) | 2296 | static int radeon_cp_indices(struct drm_device *dev, void *data, struct drm_file *file_priv) |
2280 | { | 2297 | { |
2281 | drm_radeon_private_t *dev_priv = dev->dev_private; | 2298 | drm_radeon_private_t *dev_priv = dev->dev_private; |
2282 | drm_radeon_sarea_t *sarea_priv = dev_priv->sarea_priv; | 2299 | struct drm_radeon_master_private *master_priv = file_priv->master->driver_priv; |
2300 | drm_radeon_sarea_t *sarea_priv; | ||
2283 | struct drm_device_dma *dma = dev->dma; | 2301 | struct drm_device_dma *dma = dev->dma; |
2284 | struct drm_buf *buf; | 2302 | struct drm_buf *buf; |
2285 | drm_radeon_indices_t *elts = data; | 2303 | drm_radeon_indices_t *elts = data; |
@@ -2288,6 +2306,8 @@ static int radeon_cp_indices(struct drm_device *dev, void *data, struct drm_file | |||
2288 | 2306 | ||
2289 | LOCK_TEST_WITH_RETURN(dev, file_priv); | 2307 | LOCK_TEST_WITH_RETURN(dev, file_priv); |
2290 | 2308 | ||
2309 | sarea_priv = master_priv->sarea_priv; | ||
2310 | |||
2291 | DRM_DEBUG("pid=%d index=%d start=%d end=%d discard=%d\n", | 2311 | DRM_DEBUG("pid=%d index=%d start=%d end=%d discard=%d\n", |
2292 | DRM_CURRENTPID, elts->idx, elts->start, elts->end, | 2312 | DRM_CURRENTPID, elts->idx, elts->start, elts->end, |
2293 | elts->discard); | 2313 | elts->discard); |
@@ -2353,11 +2373,11 @@ static int radeon_cp_indices(struct drm_device *dev, void *data, struct drm_file | |||
2353 | prim.prim = elts->prim; | 2373 | prim.prim = elts->prim; |
2354 | prim.offset = 0; /* offset from start of dma buffers */ | 2374 | prim.offset = 0; /* offset from start of dma buffers */ |
2355 | prim.numverts = RADEON_MAX_VB_VERTS; /* duh */ | 2375 | prim.numverts = RADEON_MAX_VB_VERTS; /* duh */ |
2356 | prim.vc_format = dev_priv->sarea_priv->vc_format; | 2376 | prim.vc_format = sarea_priv->vc_format; |
2357 | 2377 | ||
2358 | radeon_cp_dispatch_indices(dev, buf, &prim); | 2378 | radeon_cp_dispatch_indices(dev, file_priv->master, buf, &prim); |
2359 | if (elts->discard) { | 2379 | if (elts->discard) { |
2360 | radeon_cp_discard_buffer(dev, buf); | 2380 | radeon_cp_discard_buffer(dev, file_priv->master, buf); |
2361 | } | 2381 | } |
2362 | 2382 | ||
2363 | COMMIT_RING(); | 2383 | COMMIT_RING(); |
@@ -2468,7 +2488,7 @@ static int radeon_cp_indirect(struct drm_device *dev, void *data, struct drm_fil | |||
2468 | */ | 2488 | */ |
2469 | radeon_cp_dispatch_indirect(dev, buf, indirect->start, indirect->end); | 2489 | radeon_cp_dispatch_indirect(dev, buf, indirect->start, indirect->end); |
2470 | if (indirect->discard) { | 2490 | if (indirect->discard) { |
2471 | radeon_cp_discard_buffer(dev, buf); | 2491 | radeon_cp_discard_buffer(dev, file_priv->master, buf); |
2472 | } | 2492 | } |
2473 | 2493 | ||
2474 | COMMIT_RING(); | 2494 | COMMIT_RING(); |
@@ -2478,7 +2498,8 @@ static int radeon_cp_indirect(struct drm_device *dev, void *data, struct drm_fil | |||
2478 | static int radeon_cp_vertex2(struct drm_device *dev, void *data, struct drm_file *file_priv) | 2498 | static int radeon_cp_vertex2(struct drm_device *dev, void *data, struct drm_file *file_priv) |
2479 | { | 2499 | { |
2480 | drm_radeon_private_t *dev_priv = dev->dev_private; | 2500 | drm_radeon_private_t *dev_priv = dev->dev_private; |
2481 | drm_radeon_sarea_t *sarea_priv = dev_priv->sarea_priv; | 2501 | struct drm_radeon_master_private *master_priv = file_priv->master->driver_priv; |
2502 | drm_radeon_sarea_t *sarea_priv; | ||
2482 | struct drm_device_dma *dma = dev->dma; | 2503 | struct drm_device_dma *dma = dev->dma; |
2483 | struct drm_buf *buf; | 2504 | struct drm_buf *buf; |
2484 | drm_radeon_vertex2_t *vertex = data; | 2505 | drm_radeon_vertex2_t *vertex = data; |
@@ -2487,6 +2508,8 @@ static int radeon_cp_vertex2(struct drm_device *dev, void *data, struct drm_file | |||
2487 | 2508 | ||
2488 | LOCK_TEST_WITH_RETURN(dev, file_priv); | 2509 | LOCK_TEST_WITH_RETURN(dev, file_priv); |
2489 | 2510 | ||
2511 | sarea_priv = master_priv->sarea_priv; | ||
2512 | |||
2490 | DRM_DEBUG("pid=%d index=%d discard=%d\n", | 2513 | DRM_DEBUG("pid=%d index=%d discard=%d\n", |
2491 | DRM_CURRENTPID, vertex->idx, vertex->discard); | 2514 | DRM_CURRENTPID, vertex->idx, vertex->discard); |
2492 | 2515 | ||
@@ -2547,12 +2570,12 @@ static int radeon_cp_vertex2(struct drm_device *dev, void *data, struct drm_file | |||
2547 | tclprim.offset = prim.numverts * 64; | 2570 | tclprim.offset = prim.numverts * 64; |
2548 | tclprim.numverts = RADEON_MAX_VB_VERTS; /* duh */ | 2571 | tclprim.numverts = RADEON_MAX_VB_VERTS; /* duh */ |
2549 | 2572 | ||
2550 | radeon_cp_dispatch_indices(dev, buf, &tclprim); | 2573 | radeon_cp_dispatch_indices(dev, file_priv->master, buf, &tclprim); |
2551 | } else { | 2574 | } else { |
2552 | tclprim.numverts = prim.numverts; | 2575 | tclprim.numverts = prim.numverts; |
2553 | tclprim.offset = 0; /* not used */ | 2576 | tclprim.offset = 0; /* not used */ |
2554 | 2577 | ||
2555 | radeon_cp_dispatch_vertex(dev, buf, &tclprim); | 2578 | radeon_cp_dispatch_vertex(dev, file_priv, buf, &tclprim); |
2556 | } | 2579 | } |
2557 | 2580 | ||
2558 | if (sarea_priv->nbox == 1) | 2581 | if (sarea_priv->nbox == 1) |
@@ -2560,7 +2583,7 @@ static int radeon_cp_vertex2(struct drm_device *dev, void *data, struct drm_file | |||
2560 | } | 2583 | } |
2561 | 2584 | ||
2562 | if (vertex->discard) { | 2585 | if (vertex->discard) { |
2563 | radeon_cp_discard_buffer(dev, buf); | 2586 | radeon_cp_discard_buffer(dev, file_priv->master, buf); |
2564 | } | 2587 | } |
2565 | 2588 | ||
2566 | COMMIT_RING(); | 2589 | COMMIT_RING(); |
@@ -2909,7 +2932,7 @@ static int radeon_cp_cmdbuf(struct drm_device *dev, void *data, struct drm_file | |||
2909 | goto err; | 2932 | goto err; |
2910 | } | 2933 | } |
2911 | 2934 | ||
2912 | radeon_cp_discard_buffer(dev, buf); | 2935 | radeon_cp_discard_buffer(dev, file_priv->master, buf); |
2913 | break; | 2936 | break; |
2914 | 2937 | ||
2915 | case RADEON_CMD_PACKET3: | 2938 | case RADEON_CMD_PACKET3: |
@@ -3020,7 +3043,7 @@ static int radeon_cp_getparam(struct drm_device *dev, void *data, struct drm_fil | |||
3020 | */ | 3043 | */ |
3021 | case RADEON_PARAM_SAREA_HANDLE: | 3044 | case RADEON_PARAM_SAREA_HANDLE: |
3022 | /* The lock is the first dword in the sarea. */ | 3045 | /* The lock is the first dword in the sarea. */ |
3023 | value = (long)dev->lock.hw_lock; | 3046 | /* no users of this parameter */ |
3024 | break; | 3047 | break; |
3025 | #endif | 3048 | #endif |
3026 | case RADEON_PARAM_GART_TEX_HANDLE: | 3049 | case RADEON_PARAM_GART_TEX_HANDLE: |
@@ -3064,6 +3087,7 @@ static int radeon_cp_getparam(struct drm_device *dev, void *data, struct drm_fil | |||
3064 | static int radeon_cp_setparam(struct drm_device *dev, void *data, struct drm_file *file_priv) | 3087 | static int radeon_cp_setparam(struct drm_device *dev, void *data, struct drm_file *file_priv) |
3065 | { | 3088 | { |
3066 | drm_radeon_private_t *dev_priv = dev->dev_private; | 3089 | drm_radeon_private_t *dev_priv = dev->dev_private; |
3090 | struct drm_radeon_master_private *master_priv = file_priv->master->driver_priv; | ||
3067 | drm_radeon_setparam_t *sp = data; | 3091 | drm_radeon_setparam_t *sp = data; |
3068 | struct drm_radeon_driver_file_fields *radeon_priv; | 3092 | struct drm_radeon_driver_file_fields *radeon_priv; |
3069 | 3093 | ||
@@ -3078,12 +3102,14 @@ static int radeon_cp_setparam(struct drm_device *dev, void *data, struct drm_fil | |||
3078 | DRM_DEBUG("color tiling disabled\n"); | 3102 | DRM_DEBUG("color tiling disabled\n"); |
3079 | dev_priv->front_pitch_offset &= ~RADEON_DST_TILE_MACRO; | 3103 | dev_priv->front_pitch_offset &= ~RADEON_DST_TILE_MACRO; |
3080 | dev_priv->back_pitch_offset &= ~RADEON_DST_TILE_MACRO; | 3104 | dev_priv->back_pitch_offset &= ~RADEON_DST_TILE_MACRO; |
3081 | dev_priv->sarea_priv->tiling_enabled = 0; | 3105 | if (master_priv->sarea_priv) |
3106 | master_priv->sarea_priv->tiling_enabled = 0; | ||
3082 | } else if (sp->value == 1) { | 3107 | } else if (sp->value == 1) { |
3083 | DRM_DEBUG("color tiling enabled\n"); | 3108 | DRM_DEBUG("color tiling enabled\n"); |
3084 | dev_priv->front_pitch_offset |= RADEON_DST_TILE_MACRO; | 3109 | dev_priv->front_pitch_offset |= RADEON_DST_TILE_MACRO; |
3085 | dev_priv->back_pitch_offset |= RADEON_DST_TILE_MACRO; | 3110 | dev_priv->back_pitch_offset |= RADEON_DST_TILE_MACRO; |
3086 | dev_priv->sarea_priv->tiling_enabled = 1; | 3111 | if (master_priv->sarea_priv) |
3112 | master_priv->sarea_priv->tiling_enabled = 1; | ||
3087 | } | 3113 | } |
3088 | break; | 3114 | break; |
3089 | case RADEON_SETPARAM_PCIGART_LOCATION: | 3115 | case RADEON_SETPARAM_PCIGART_LOCATION: |
@@ -3129,14 +3155,6 @@ void radeon_driver_preclose(struct drm_device *dev, struct drm_file *file_priv) | |||
3129 | 3155 | ||
3130 | void radeon_driver_lastclose(struct drm_device *dev) | 3156 | void radeon_driver_lastclose(struct drm_device *dev) |
3131 | { | 3157 | { |
3132 | if (dev->dev_private) { | ||
3133 | drm_radeon_private_t *dev_priv = dev->dev_private; | ||
3134 | |||
3135 | if (dev_priv->sarea_priv && | ||
3136 | dev_priv->sarea_priv->pfCurrentPage != 0) | ||
3137 | radeon_cp_dispatch_flip(dev); | ||
3138 | } | ||
3139 | |||
3140 | radeon_do_release(dev); | 3158 | radeon_do_release(dev); |
3141 | } | 3159 | } |
3142 | 3160 | ||