[udisplay] Don't use write combining memory

Since udisplay's framebuffer is now an arbitrary vmo, don't try to map
it as write combining, since that can conflict with whatever the
buffer's original policy was.

ZX-2196 #done

Test: k crash on NUC, NUC with the simple intel driver, and vim2
Change-Id: I16e4f3baeb2341ef81478478e592b97a9945a14d
diff --git a/kernel/dev/udisplay/udisplay.cpp b/kernel/dev/udisplay/udisplay.cpp
index 95ae143..2725fca 100644
--- a/kernel/dev/udisplay/udisplay.cpp
+++ b/kernel/dev/udisplay/udisplay.cpp
@@ -20,8 +20,7 @@
 
 #define LOCAL_TRACE 0
 
-constexpr uint kFramebufferArchMmuFlags = ARCH_MMU_FLAG_WRITE_COMBINING | ARCH_MMU_FLAG_PERM_READ |
-    ARCH_MMU_FLAG_PERM_WRITE;
+constexpr uint kFramebufferArchMmuFlags = ARCH_MMU_FLAG_PERM_READ | ARCH_MMU_FLAG_PERM_WRITE;
 
 static qrcodegen::QrCode qrcode;
 
@@ -96,7 +95,7 @@
             }
         }
     }
-
+    gfxconsole_flush();
 }
 
 void udisplay_clear_framebuffer_vmo() {
@@ -144,7 +143,7 @@
 
     // bind the display to the gfxconsole
     g_udisplay.info.framebuffer = g_udisplay.framebuffer_virt;
-    g_udisplay.info.flags = DISPLAY_FLAG_HW_FRAMEBUFFER | DISPLAY_FLAG_CRASH_FRAMEBUFFER;
+    g_udisplay.info.flags = DISPLAY_FLAG_NEEDS_CACHE_FLUSH | DISPLAY_FLAG_CRASH_FRAMEBUFFER;
     gfxconsole_bind_display(&g_udisplay.info, nullptr);
 
     return ZX_OK;
diff --git a/kernel/include/dev/display.h b/kernel/include/dev/display.h
index 5de44ac..dc762da 100644
--- a/kernel/include/dev/display.h
+++ b/kernel/include/dev/display.h
@@ -20,6 +20,7 @@
 void display_pre_freq_change(void);
 void display_post_freq_change(void);
 
+// Has no effect if DISPLAY_FLAG_CRASH_FRAMEBUFFER is set
 #define DISPLAY_FLAG_HW_FRAMEBUFFER    (1<<0)
 #define DISPLAY_FLAG_NEEDS_CACHE_FLUSH (1<<1)
 
diff --git a/kernel/include/lib/gfxconsole.h b/kernel/include/lib/gfxconsole.h
index f6c2520..aa419ea 100644
--- a/kernel/include/lib/gfxconsole.h
+++ b/kernel/include/lib/gfxconsole.h
@@ -17,5 +17,6 @@
 void gfxconsole_start(gfx_surface *surface, gfx_surface *hw_surface);
 void gfxconsole_bind_display(struct display_info *info, void *raw_sw_fb);
 void gfxconsole_putpixel(unsigned x, unsigned y, unsigned color);
+void gfxconsole_flush(void);
 
 __END_CDECLS
diff --git a/kernel/lib/gfxconsole/gfxconsole.c b/kernel/lib/gfxconsole/gfxconsole.c
index e39de24..e324a10 100644
--- a/kernel/lib/gfxconsole/gfxconsole.c
+++ b/kernel/lib/gfxconsole/gfxconsole.c
@@ -162,6 +162,8 @@
                 0, gfxconsole.y * font->height);
         }
         gfx_flush(gfxconsole.hw_surface);
+    } else {
+        gfx_flush(gfxconsole.surface);
     }
 }
 
@@ -333,3 +335,12 @@
     register_print_callback(&cb);
     active = true;
 }
+
+void gfxconsole_flush() {
+    if (gfxconsole.surface != gfxconsole.hw_surface) {
+        gfx_surface_blend(gfxconsole.hw_surface, gfxconsole.surface, 0, 0);
+        gfx_flush(gfxconsole.hw_surface);
+    } else {
+        gfx_flush(gfxconsole.surface);
+    }
+}