if (ret)
                goto try_dmabuf;
 
+       if (!surface->scanout)
+               goto err_not_scanout;
+
        ret = vmw_kms_new_framebuffer_surface(dev_priv, surface, &vfb,
                                              mode_cmd->width, mode_cmd->height);
 
        }
 
        return &vfb->base;
+
+err_not_scanout:
+       DRM_ERROR("surface not marked as scanout\n");
+       /* vmw_user_surface_lookup takes one ref */
+       vmw_surface_unreference(&surface);
+
+       return NULL;
 }
 
 static int vmw_kms_fb_changed(struct drm_device *dev)
 
 #define VMW_RES_SURFACE ttm_driver_type1
 #define VMW_RES_STREAM ttm_driver_type2
 
+/* XXX: This isn't a real hardware flag, but just a hack for kernel to
+ * know about primary surfaces. Find a better way to accomplish this.
+ */
+#define SVGA3D_SURFACE_HINT_SCANOUT (1 << 9)
+
 struct vmw_user_context {
        struct ttm_base_object base;
        struct vmw_resource res;
        if (unlikely(ret != 0))
                goto out_err1;
 
+       if (srf->flags & SVGA3D_SURFACE_HINT_SCANOUT) {
+               /* we should not send this flag down to hardware since
+                * its not a official one
+                */
+               srf->flags &= ~SVGA3D_SURFACE_HINT_SCANOUT;
+               srf->scanout = true;
+       } else {
+               srf->scanout = false;
+       }
 
-       if (srf->flags & (1 << 9) &&
+       if (srf->scanout &&
            srf->num_sizes == 1 &&
            srf->sizes[0].width == 64 &&
            srf->sizes[0].height == 64 &&