From eb9bc133fc426e67b397e661bfd22bf62009d9d3 Mon Sep 17 00:00:00 2001 From: Dave Airlie Date: Fri, 20 Nov 2009 09:23:31 +1000 Subject: kms: recalculate the flush limits after screen resize. When we resize the front buffer we need to reduce the flush limits appropriately. Signed-off-by: Dave Airlie --- src/drmmode_display.c | 1 + src/radeon.h | 1 + src/radeon_kms.c | 26 ++++++++++++++++++++++---- 3 files changed, 24 insertions(+), 4 deletions(-) diff --git a/src/drmmode_display.c b/src/drmmode_display.c index 29c3ff17..31479812 100644 --- a/src/drmmode_display.c +++ b/src/drmmode_display.c @@ -1095,6 +1095,7 @@ drmmode_xf86crtc_resize (ScrnInfoPtr scrn, int width, int height) if (old_front) radeon_bo_unref(old_front); + radeon_kms_update_vram_limit(scrn, screen_size); return TRUE; fail: diff --git a/src/radeon.h b/src/radeon.h index 7fd297e9..5cdc3dbb 100644 --- a/src/radeon.h +++ b/src/radeon.h @@ -1282,6 +1282,7 @@ extern void radeon_cs_flush_indirect(ScrnInfoPtr pScrn); extern void radeon_ddx_cs_start(ScrnInfoPtr pScrn, int num, const char *file, const char *func, int line); +void radeon_kms_update_vram_limit(ScrnInfoPtr pScrn, int new_fb_size); #endif struct radeon_bo *radeon_get_pixmap_bo(PixmapPtr pPix); void radeon_set_pixmap_bo(PixmapPtr pPix, struct radeon_bo *bo); diff --git a/src/radeon_kms.c b/src/radeon_kms.c index 8e46a8a2..5a4255f9 100644 --- a/src/radeon_kms.c +++ b/src/radeon_kms.c @@ -946,13 +946,31 @@ static Bool radeon_setup_kernel_mem(ScreenPtr pScreen) } xf86DrvMsg(pScrn->scrnIndex, X_INFO, "Front buffer size: %dK\n", info->front_bo->size/1024); - xf86DrvMsg(pScrn->scrnIndex, X_INFO, "Remaining VRAM size (used for pixmaps): %dK\n", remain_size_bytes/1024); + radeon_kms_update_vram_limit(pScrn, screen_size); + return TRUE; +} - /* set the emit limit at 90% of VRAM */ - remain_size_bytes = (remain_size_bytes / 10) * 9; +void radeon_kms_update_vram_limit(ScrnInfoPtr pScrn, int new_fb_size) +{ + xf86CrtcConfigPtr xf86_config = XF86_CRTC_CONFIG_PTR(pScrn); + RADEONInfoPtr info = RADEONPTR(pScrn); + int remain_size_bytes; + int total_size_bytes; + int c; + for (c = 0; c < xf86_config->num_crtc; c++) { + if (info->cursor_bo[c] != NULL) { + total_size_bytes += (64 * 4 * 64); + } + } + + total_size_bytes += new_fb_size; + remain_size_bytes = info->vram_size - new_fb_size; + remain_size_bytes = (remain_size_bytes / 10) * 9; radeon_cs_set_limit(info->cs, RADEON_GEM_DOMAIN_VRAM, remain_size_bytes); - return TRUE; + + xf86DrvMsg(pScrn->scrnIndex, X_INFO, "VRAM usage limit set to %dK\n", remain_size_bytes / 1024); } + #endif -- cgit v1.2.3