derekf pushed a commit to branch master.

http://git.enlightenment.org/core/efl.git/commit/?id=27f88b534a4a630db4d57814d9c6d8a3d2d8f512

commit 27f88b534a4a630db4d57814d9c6d8a3d2d8f512
Author: Derek Foreman <[email protected]>
Date:   Mon Jul 24 16:03:10 2017 -0500

    elput: Fix multiple open/close of drm devices
    
    When I added the code to probe drm devices to ensure they're
    modeset capable (ref 414d406b3b442216543cdaef112787696ae09898)
    I didn't realize elput didn't allow us to open and close more than
    one drm device at startup without blowing up libinput.
    
    This is a somewhat dirty hack to rough that in.
    
    The problem is that open/close the device during startup will
    result in an async "gone" callback from logind, which then kicks
    off an input shutdown.  We need to try harder to only do that
    shutdown when it makes sense.
---
 src/lib/elput/elput_logind.c  | 18 ++++++++++++++++++
 src/lib/elput/elput_private.h |  2 ++
 2 files changed, 20 insertions(+)

diff --git a/src/lib/elput/elput_logind.c b/src/lib/elput/elput_logind.c
index aa9006e5bb..91eaffcbda 100644
--- a/src/lib/elput/elput_logind.c
+++ b/src/lib/elput/elput_logind.c
@@ -84,6 +84,7 @@ _cb_device_paused(void *data, const Eldbus_Message *msg)
    uint32_t maj, min;
 
    em = data;
+   if (!em->drm_opens) return;
 
    if (eldbus_message_error_get(msg, &errname, &errmsg))
      {
@@ -93,6 +94,20 @@ _cb_device_paused(void *data, const Eldbus_Message *msg)
 
    if (eldbus_message_arguments_get(msg, "uus", &maj, &min, &type))
      {
+        /* If we opened a device during probing then we're still going
+         * to get a "gone" callback when we release it, so we'd better
+         * eat that instead of treating it like losing the drm device
+         * we currently have open, and crapping up libinput's internals
+         * for a nice deferred explosion at shutdown...
+         *
+         * FIXME: do this better?
+         */
+        if ((em->drm_opens > 1) && (maj == 226) && !strcmp(type, "gone"))
+          {
+             em->drm_opens--;
+             return;
+          }
+
         if (!strcmp(type, "pause"))
           _logind_device_pause_complete(em, maj, min);
 
@@ -607,6 +622,9 @@ _logind_open(Elput_Manager *em, const char *path, int flags)
    fd = _logind_device_take(em, major(st.st_rdev), minor(st.st_rdev));
    if (fd < 0) return fd;
 
+   if (major(st.st_rdev) == 226) //DRM_MAJOR
+     em->drm_opens++;
+
    fl = fcntl(fd, F_GETFL);
    if (fl < 0) goto err;
 
diff --git a/src/lib/elput/elput_private.h b/src/lib/elput/elput_private.h
index 5b38c14ab6..709871c368 100644
--- a/src/lib/elput/elput_private.h
+++ b/src/lib/elput/elput_private.h
@@ -279,6 +279,8 @@ struct _Elput_Manager
      } cached;
    int output_w, output_h;
 
+   int drm_opens;
+
    Elput_Input input;
    Eina_Bool del : 1;
 };

-- 


Reply via email to