From 58dd07e837e58b60791bfae2824762ac97b1af2f Mon Sep 17 00:00:00 2001 From: Alex Deucher Date: Thu, 26 May 2011 18:57:40 -0400 Subject: [PATCH] radeon/kms: re-use old bo if we fail to alloc a new one If we fail to alloc a new bo for the desktop, re-use the old one if it is big enough. Should fix: https://bugs.freedesktop.org/show_bug.cgi?id=37545 The driver allocates a buffer large enough for dualhead (1024x768 + 1600x1200). When the user turns off the LVDS port, the driver tries to allocate a new 1600x1200 buffer for just the VGA monitor before freeing the previous dualhead allocation. Since there isn't enough VRAM available for both the dualhead allocation and the VGA-only allocation, the modeset fails. If the old allocation is big enough for the new display request, just re-use the old one. Signed-off-by: Alex Deucher --- src/drmmode_display.c | 10 ++++++++-- 1 files changed, 8 insertions(+), 2 deletions(-) diff --git a/src/drmmode_display.c b/src/drmmode_display.c index afa4c26..2f30707 100644 --- a/src/drmmode_display.c +++ b/src/drmmode_display.c @@ -1242,8 +1242,14 @@ drmmode_xf86crtc_resize (ScrnInfoPtr scrn, int width, int height) scrn->displayWidth = pitch / cpp; info->front_bo = radeon_bo_open(info->bufmgr, 0, screen_size, 0, RADEON_GEM_DOMAIN_VRAM, 0); - if (!info->front_bo) - goto fail; + if (!info->front_bo) { + if (old_front && (screen_size <= old_front->size)) { + info->front_bo = old_front; + old_front = NULL; + old_fb_id = 0; + } else + goto fail; + } #if X_BYTE_ORDER == X_BIG_ENDIAN switch (cpp) { -- 1.7.1.1