Commit 8eb1396d authored by Jocelyn Falempe's avatar Jocelyn Falempe Committed by Povilas Kanapickas
Browse files

xf86/logind: Fix drm_drop_master before vt_reldisp

When switching to VT, the ioctl DRM_DROP_MASTER must be done before
the ioctl VT_RELDISP. Otherwise the kernel can't change the modesetting
reliably, and this leads to the console not showing up in some cases, like
after unplugging a docking station with a DP or HDMI monitor.

Before doing the VT_RELDISP, send a dbus message to logind, to
pause the drm device, so logind will do the ioctl DRM_DROP_MASTER.

With this patch, it changes the order logind will send the resume
event, and drm will be sent last instead of first.
so there is a also fix to call systemd_logind_vtenter() at the right time.
Signed-off-by: Jocelyn Falempe's avatarJocelyn Falempe <>
Reviewed-by: default avatarHans de Goede <>
(cherry picked from commit da9d012a)
parent 6834f977
Pipeline #457896 passed with stages
in 6 minutes and 9 seconds
......@@ -382,6 +382,17 @@ xf86VTLeave(void)
for (i = 0; i < xf86NumGPUScreens; i++)
if (systemd_logind_controls_session()) {
for (i = 0; i < xf86_num_platform_devices; i++) {
if (xf86_platform_devices[i].flags & XF86_PDEV_SERVER_FD) {
int major, minor;
major = xf86_platform_odev_attributes(i)->major;
minor = xf86_platform_odev_attributes(i)->minor;
systemd_logind_drop_master(major, minor);
if (!xf86VTSwitchAway())
goto switch_failed;
......@@ -303,6 +303,20 @@ cleanup:
* Send a message to logind, to pause the drm device
* and ensure the drm_drop_master is done before
* VT_RELDISP when switching VT
void systemd_logind_drop_master(int _major, int _minor)
struct systemd_logind_info *info = &logind_info;
dbus_int32_t major = _major;
dbus_int32_t minor = _minor;
systemd_logind_ack_pause(info, minor, major);
static DBusHandlerResult
message_filter(DBusConnection * connection, DBusMessage * message, void *data)
......@@ -33,6 +33,7 @@ int systemd_logind_take_fd(int major, int minor, const char *path, Bool *paus);
void systemd_logind_release_fd(int major, int minor, int fd);
int systemd_logind_controls_session(void);
void systemd_logind_vtenter(void);
void systemd_logind_drop_master(int major, int minor);
#define systemd_logind_init()
#define systemd_logind_fini()
......@@ -40,6 +41,7 @@ void systemd_logind_vtenter(void);
#define systemd_logind_release_fd(major, minor, fd) close(fd)
#define systemd_logind_controls_session() 0
#define systemd_logind_vtenter()
#define systemd_logind_drop_master(major, minor)
Supports Markdown
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment