aboutsummaryrefslogtreecommitdiffstats
path: root/drivers/char
diff options
context:
space:
mode:
authorMichel Dänzer <michel@tungstengraphics.com>2007-05-08 01:21:14 -0400
committerDave Airlie <airlied@linux.ie>2007-05-08 01:21:14 -0400
commit453ff94ca502d0a7441912823f20ed130f685429 (patch)
tree50858e0644a9ceb879310369cc84ce7ebd4c0f21 /drivers/char
parentf2b04cd219e5c0f1214c0eeeec814ddd08a12c1b (diff)
radeon: Don't mess up page flipping when a file descriptor is closed.
There can still be other contexts that may use page flipping later on, so do just unilaterally 'clean it up', which could lead to the wrong page being displayed, e.g. when running 3D apps with a GLX compositing manager such as compiz using page flipping. Signed-off-by: Dave Airlie <airlied@linux.ie>
Diffstat (limited to 'drivers/char')
-rw-r--r--drivers/char/drm/radeon_drv.h1
-rw-r--r--drivers/char/drm/radeon_state.c46
2 files changed, 19 insertions, 28 deletions
diff --git a/drivers/char/drm/radeon_drv.h b/drivers/char/drm/radeon_drv.h
index 97c27da2d26d..54f49ef4bef0 100644
--- a/drivers/char/drm/radeon_drv.h
+++ b/drivers/char/drm/radeon_drv.h
@@ -243,7 +243,6 @@ typedef struct drm_radeon_private {
243 243
244 int do_boxes; 244 int do_boxes;
245 int page_flipping; 245 int page_flipping;
246 int current_page;
247 246
248 u32 color_fmt; 247 u32 color_fmt;
249 unsigned int front_offset; 248 unsigned int front_offset;
diff --git a/drivers/char/drm/radeon_state.c b/drivers/char/drm/radeon_state.c
index d6041911c474..98c5f1d3a8e7 100644
--- a/drivers/char/drm/radeon_state.c
+++ b/drivers/char/drm/radeon_state.c
@@ -773,7 +773,7 @@ static void radeon_clear_box(drm_radeon_private_t * dev_priv,
773 RADEON_GMC_SRC_DATATYPE_COLOR | 773 RADEON_GMC_SRC_DATATYPE_COLOR |
774 RADEON_ROP3_P | RADEON_GMC_CLR_CMP_CNTL_DIS); 774 RADEON_ROP3_P | RADEON_GMC_CLR_CMP_CNTL_DIS);
775 775
776 if (dev_priv->page_flipping && dev_priv->current_page == 1) { 776 if (dev_priv->sarea_priv->pfCurrentPage == 1) {
777 OUT_RING(dev_priv->front_pitch_offset); 777 OUT_RING(dev_priv->front_pitch_offset);
778 } else { 778 } else {
779 OUT_RING(dev_priv->back_pitch_offset); 779 OUT_RING(dev_priv->back_pitch_offset);
@@ -861,7 +861,7 @@ static void radeon_cp_dispatch_clear(drm_device_t * dev,
861 861
862 dev_priv->stats.clears++; 862 dev_priv->stats.clears++;
863 863
864 if (dev_priv->page_flipping && dev_priv->current_page == 1) { 864 if (dev_priv->sarea_priv->pfCurrentPage == 1) {
865 unsigned int tmp = flags; 865 unsigned int tmp = flags;
866 866
867 flags &= ~(RADEON_FRONT | RADEON_BACK); 867 flags &= ~(RADEON_FRONT | RADEON_BACK);
@@ -1382,7 +1382,7 @@ static void radeon_cp_dispatch_swap(drm_device_t * dev)
1382 /* Make this work even if front & back are flipped: 1382 /* Make this work even if front & back are flipped:
1383 */ 1383 */
1384 OUT_RING(CP_PACKET0(RADEON_SRC_PITCH_OFFSET, 1)); 1384 OUT_RING(CP_PACKET0(RADEON_SRC_PITCH_OFFSET, 1));
1385 if (dev_priv->current_page == 0) { 1385 if (dev_priv->sarea_priv->pfCurrentPage == 0) {
1386 OUT_RING(dev_priv->back_pitch_offset); 1386 OUT_RING(dev_priv->back_pitch_offset);
1387 OUT_RING(dev_priv->front_pitch_offset); 1387 OUT_RING(dev_priv->front_pitch_offset);
1388 } else { 1388 } else {
@@ -1416,12 +1416,12 @@ static void radeon_cp_dispatch_flip(drm_device_t * dev)
1416{ 1416{
1417 drm_radeon_private_t *dev_priv = dev->dev_private; 1417 drm_radeon_private_t *dev_priv = dev->dev_private;
1418 drm_sarea_t *sarea = (drm_sarea_t *) dev_priv->sarea->handle; 1418 drm_sarea_t *sarea = (drm_sarea_t *) dev_priv->sarea->handle;
1419 int offset = (dev_priv->current_page == 1) 1419 int offset = (dev_priv->sarea_priv->pfCurrentPage == 1)
1420 ? dev_priv->front_offset : dev_priv->back_offset; 1420 ? dev_priv->front_offset : dev_priv->back_offset;
1421 RING_LOCALS; 1421 RING_LOCALS;
1422 DRM_DEBUG("%s: page=%d pfCurrentPage=%d\n", 1422 DRM_DEBUG("%s: pfCurrentPage=%d\n",
1423 __FUNCTION__, 1423 __FUNCTION__,
1424 dev_priv->current_page, dev_priv->sarea_priv->pfCurrentPage); 1424 dev_priv->sarea_priv->pfCurrentPage);
1425 1425
1426 /* Do some trivial performance monitoring... 1426 /* Do some trivial performance monitoring...
1427 */ 1427 */
@@ -1449,8 +1449,8 @@ static void radeon_cp_dispatch_flip(drm_device_t * dev)
1449 * performing the swapbuffer ioctl. 1449 * performing the swapbuffer ioctl.
1450 */ 1450 */
1451 dev_priv->sarea_priv->last_frame++; 1451 dev_priv->sarea_priv->last_frame++;
1452 dev_priv->sarea_priv->pfCurrentPage = dev_priv->current_page = 1452 dev_priv->sarea_priv->pfCurrentPage =
1453 1 - dev_priv->current_page; 1453 1 - dev_priv->sarea_priv->pfCurrentPage;
1454 1454
1455 BEGIN_RING(2); 1455 BEGIN_RING(2);
1456 1456
@@ -2152,24 +2152,10 @@ static int radeon_do_init_pageflip(drm_device_t * dev)
2152 ADVANCE_RING(); 2152 ADVANCE_RING();
2153 2153
2154 dev_priv->page_flipping = 1; 2154 dev_priv->page_flipping = 1;
2155 dev_priv->current_page = 0;
2156 dev_priv->sarea_priv->pfCurrentPage = dev_priv->current_page;
2157 2155
2158 return 0; 2156 if (dev_priv->sarea_priv->pfCurrentPage != 1)
2159} 2157 dev_priv->sarea_priv->pfCurrentPage = 0;
2160
2161/* Called whenever a client dies, from drm_release.
2162 * NOTE: Lock isn't necessarily held when this is called!
2163 */
2164static int radeon_do_cleanup_pageflip(drm_device_t * dev)
2165{
2166 drm_radeon_private_t *dev_priv = dev->dev_private;
2167 DRM_DEBUG("\n");
2168 2158
2169 if (dev_priv->current_page != 0)
2170 radeon_cp_dispatch_flip(dev);
2171
2172 dev_priv->page_flipping = 0;
2173 return 0; 2159 return 0;
2174} 2160}
2175 2161
@@ -3174,9 +3160,7 @@ void radeon_driver_preclose(drm_device_t * dev, DRMFILE filp)
3174{ 3160{
3175 if (dev->dev_private) { 3161 if (dev->dev_private) {
3176 drm_radeon_private_t *dev_priv = dev->dev_private; 3162 drm_radeon_private_t *dev_priv = dev->dev_private;
3177 if (dev_priv->page_flipping) { 3163 dev_priv->page_flipping = 0;
3178 radeon_do_cleanup_pageflip(dev);
3179 }
3180 radeon_mem_release(filp, dev_priv->gart_heap); 3164 radeon_mem_release(filp, dev_priv->gart_heap);
3181 radeon_mem_release(filp, dev_priv->fb_heap); 3165 radeon_mem_release(filp, dev_priv->fb_heap);
3182 radeon_surfaces_release(filp, dev_priv); 3166 radeon_surfaces_release(filp, dev_priv);
@@ -3185,6 +3169,14 @@ void radeon_driver_preclose(drm_device_t * dev, DRMFILE filp)
3185 3169
3186void radeon_driver_lastclose(drm_device_t * dev) 3170void radeon_driver_lastclose(drm_device_t * dev)
3187{ 3171{
3172 if (dev->dev_private) {
3173 drm_radeon_private_t *dev_priv = dev->dev_private;
3174
3175 if (dev_priv->sarea_priv &&
3176 dev_priv->sarea_priv->pfCurrentPage != 0)
3177 radeon_cp_dispatch_flip(dev);
3178 }
3179
3188 radeon_do_release(dev); 3180 radeon_do_release(dev);
3189} 3181}
3190 3182