summaryrefslogtreecommitdiff
path: root/src/lib/elput/elput_logind.c
diff options
context:
space:
mode:
authorDerek Foreman <derekf@osg.samsung.com>2017-07-24 16:03:10 -0500
committerDerek Foreman <derekf@osg.samsung.com>2017-07-24 16:06:52 -0500
commit27f88b534a4a630db4d57814d9c6d8a3d2d8f512 (patch)
tree1724b0a8be4404250d168b7087ddbaecb5d9896f /src/lib/elput/elput_logind.c
parentaae4d21b633d4cfe6839c1685fbebf59e199b60d (diff)
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.
Diffstat (limited to 'src/lib/elput/elput_logind.c')
-rw-r--r--src/lib/elput/elput_logind.c18
1 files changed, 18 insertions, 0 deletions
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)
84 uint32_t maj, min; 84 uint32_t maj, min;
85 85
86 em = data; 86 em = data;
87 if (!em->drm_opens) return;
87 88
88 if (eldbus_message_error_get(msg, &errname, &errmsg)) 89 if (eldbus_message_error_get(msg, &errname, &errmsg))
89 { 90 {
@@ -93,6 +94,20 @@ _cb_device_paused(void *data, const Eldbus_Message *msg)
93 94
94 if (eldbus_message_arguments_get(msg, "uus", &maj, &min, &type)) 95 if (eldbus_message_arguments_get(msg, "uus", &maj, &min, &type))
95 { 96 {
97 /* If we opened a device during probing then we're still going
98 * to get a "gone" callback when we release it, so we'd better
99 * eat that instead of treating it like losing the drm device
100 * we currently have open, and crapping up libinput's internals
101 * for a nice deferred explosion at shutdown...
102 *
103 * FIXME: do this better?
104 */
105 if ((em->drm_opens > 1) && (maj == 226) && !strcmp(type, "gone"))
106 {
107 em->drm_opens--;
108 return;
109 }
110
96 if (!strcmp(type, "pause")) 111 if (!strcmp(type, "pause"))
97 _logind_device_pause_complete(em, maj, min); 112 _logind_device_pause_complete(em, maj, min);
98 113
@@ -607,6 +622,9 @@ _logind_open(Elput_Manager *em, const char *path, int flags)
607 fd = _logind_device_take(em, major(st.st_rdev), minor(st.st_rdev)); 622 fd = _logind_device_take(em, major(st.st_rdev), minor(st.st_rdev));
608 if (fd < 0) return fd; 623 if (fd < 0) return fd;
609 624
625 if (major(st.st_rdev) == 226) //DRM_MAJOR
626 em->drm_opens++;
627
610 fl = fcntl(fd, F_GETFL); 628 fl = fcntl(fd, F_GETFL);
611 if (fl < 0) goto err; 629 if (fl < 0) goto err;
612 630