From 7dd16e56841e4b79eab88df06938f7766d8b7206 Mon Sep 17 00:00:00 2001 From: Chris Wilson Date: Thu, 5 Feb 2015 08:12:56 +0000 Subject: [PATCH] sna: Clear the resized framebuffer if wedged We always try to make sure the scanout is initialised before use, but if the GPU is wedged we need to fallback to use the CPU to do the clears. Signed-off-by: Chris Wilson --- src/sna/sna_display.c | 36 +++++++++++++++++++++++++----------- 1 file changed, 25 insertions(+), 11 deletions(-) diff --git a/src/sna/sna_display.c b/src/sna/sna_display.c index a37362fe..fa2970ff 100644 --- a/src/sna/sna_display.c +++ b/src/sna/sna_display.c @@ -4282,12 +4282,19 @@ static void copy_front(struct sna *sna, PixmapPtr old, PixmapPtr new) return; if (old_priv->clear) { - (void)sna->render.fill_one(sna, new, new_priv->gpu_bo, - old_priv->clear_color, - 0, 0, - new->drawable.width, - new->drawable.height, - GXcopy); + bool ok = false; + if (!wedged(sna)) + ok = sna->render.fill_one(sna, new, new_priv->gpu_bo, + old_priv->clear_color, + 0, 0, + new->drawable.width, + new->drawable.height, + GXcopy); + if (!ok) { + void *ptr = kgem_bo_map__gtt(&sna->kgem, new_priv->gpu_bo); + if (ptr) + memset(ptr, 0, new_priv->gpu_bo->pitch*new->drawable.height); + } new_priv->clear = true; new_priv->clear_color = old_priv->clear_color; } else { @@ -4343,11 +4350,18 @@ static void copy_front(struct sna *sna, PixmapPtr old, PixmapPtr new) __FUNCTION__, box.x2, box.y2, sx, sy, dx, dy)); if (box.x2 != new->drawable.width || box.y2 != new->drawable.height) { - (void)sna->render.fill_one(sna, new, new_priv->gpu_bo, 0, - 0, 0, - new->drawable.width, - new->drawable.height, - GXclear); + bool ok = false; + if (!wedged(sna)) + ok = sna->render.fill_one(sna, new, new_priv->gpu_bo, 0, + 0, 0, + new->drawable.width, + new->drawable.height, + GXclear); + if (!ok) { + void *ptr = kgem_bo_map__gtt(&sna->kgem, new_priv->gpu_bo); + if (ptr) + memset(ptr, 0, new_priv->gpu_bo->pitch*new->drawable.height); + } } (void)sna->render.copy_boxes(sna, GXcopy, &old->drawable, old_priv->gpu_bo, sx, sy,