OSDN Git Service

drm_hwcomposer: Fix drmSetMaster() usage
authorJohn Stultz <john.stultz@linaro.org>
Tue, 2 Feb 2021 01:34:45 +0000 (01:34 +0000)
committerJohn Stultz <john.stultz@linaro.org>
Thu, 11 Feb 2021 20:52:13 +0000 (20:52 +0000)
After commit 3b24cd911ebf ("drm_hwcomposer: Ensure composer has
master access to DRM/KMS") was merged I started seeing failures
on 5.4 based kernels.

Diggin into it, it seemed on those kernels drmSetMaster() was
always returning -EACCES, due to the following upstream kernel
change not being present:
  https://git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git/commit/?id=45bc3d26c95a8fc63a7d8668ca9e57ef0883351c

That change landed around 5.6, so for older kernels we need to
make sure older kernels without this patch still work. So this
patch, as suggested by Roman Stratiienko, reworks the logic
so we call drmSetMaster() and then check drmIsMaster(), rather
then failing due to the return value.

With this patch, things are back to working on both hikey960
and db845c with 5.4 based kernels.

Signed-off-by: John Stultz <john.stultz@linaro.org>
Change-Id: I7f2adba3ddbd36169b6d26baf49299046efcf906

drm/DrmDevice.cpp

index 5d46c36..4e750f8 100644 (file)
@@ -145,10 +145,10 @@ std::tuple<int, int> DrmDevice::Init(const char *path, int num_displays) {
   }
 #endif
 
-  ret = drmSetMaster(fd());
-  if (ret) {
-    ALOGE("drmSetMaster() failed with errno: %d", errno);
-    return std::make_tuple(ret, 0);
+  drmSetMaster(fd());
+  if (!drmIsMaster(fd())) {
+    ALOGE("DRM/KMS master access required");
+    return std::make_tuple(-EACCES, 0);
   }
 
   drmModeResPtr res = drmModeGetResources(fd());