OSDN Git Service

minigbm/msm: Add workaround for waffle
authorRob Clark <robdclark@google.com>
Fri, 7 Aug 2020 15:08:30 +0000 (08:08 -0700)
committerCommit Bot <commit-bot@chromium.org>
Mon, 10 Aug 2020 15:50:39 +0000 (15:50 +0000)
Waffle does not support modifiers, detect it and fall back to linear
buffers.  Fixes glmark2-waffle, glbench/windowmanagertest, etc.

BUG=b:158238296, b:153675943
TEST=run glmark2-waffle and verify it displays correct
TEST=run graphics.Sanity and verify that it passes
TEST=start ui and verify that it still picks UBWC modifier

Change-Id: I591136c8d07bd32beb6f4efa63971821193ce39e
Exempt-From-Owner-Approval: already CR+2 from owner
Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/minigbm/+/2343173
Tested-by: Rob Clark <robdclark@chromium.org>
Commit-Queue: Rob Clark <robdclark@chromium.org>
Reviewed-by: Rob Clark <robdclark@chromium.org>
Auto-Submit: Rob Clark <robdclark@chromium.org>

Makefile
msm.c

index 35f92f2..8238026 100644 (file)
--- a/Makefile
+++ b/Makefile
@@ -25,6 +25,9 @@ endif
 ifdef DRV_MESON
        CFLAGS += $(shell $(PKG_CONFIG) --cflags libdrm_meson)
 endif
+ifdef DRV_MSM
+       CFLAGS += -ldl
+endif
 ifdef DRV_RADEON
        CFLAGS += $(shell $(PKG_CONFIG) --cflags libdrm_radeon)
 endif
diff --git a/msm.c b/msm.c
index 4f98a57..07ed7c7 100644 (file)
--- a/msm.c
+++ b/msm.c
@@ -7,6 +7,7 @@
 #ifdef DRV_MSM
 
 #include <assert.h>
+#include <dlfcn.h>
 #include <drm_fourcc.h>
 #include <errno.h>
 #include <inttypes.h>
@@ -157,6 +158,29 @@ static void msm_add_ubwc_combinations(struct driver *drv, const uint32_t *format
        }
 }
 
+/**
+ * Check for buggy apps that are known to not support modifiers, to avoid surprising them
+ * with a UBWC buffer.
+ */
+static bool should_avoid_ubwc(void)
+{
+#ifndef __ANDROID__
+       /* waffle is buggy and, requests a renderable buffer (which on qcom platforms, we
+        * want to use UBWC), and then passes it to the kernel discarding the modifier.
+        * So mesa ends up correctly rendering to as tiled+compressed, but kernel tries
+        * to display as linear.  Other platforms do not see this issue, simply because
+        * they only use compressed (ex, AFBC) with the BO_USE_SCANOUT flag.
+        *
+        * See b/163137550
+        */
+       if (dlsym(RTLD_DEFAULT, "waffle_display_connect")) {
+               drv_log("WARNING: waffle detected, disabling UBWC\n");
+               return true;
+       }
+#endif
+       return false;
+}
+
 static int msm_init(struct driver *drv)
 {
        struct format_metadata metadata;
@@ -190,6 +214,9 @@ static int msm_init(struct driver *drv)
 
        drv_modify_linear_combinations(drv);
 
+       if (should_avoid_ubwc())
+               return 0;
+
        metadata.tiling = MSM_UBWC_TILING;
        metadata.priority = 2;
        metadata.modifier = DRM_FORMAT_MOD_QCOM_COMPRESSED;