mirror of
https://github.com/systemd/systemd.git
synced 2024-10-31 07:51:21 +03:00
Merge pull request #8332 from poettering/logind-open-if-needed
logind device resume fix
This commit is contained in:
commit
283def70cf
@ -106,7 +106,7 @@ static int session_device_notify(SessionDevice *sd, enum SessionDeviceNotificati
|
|||||||
return sd_bus_send(sd->session->manager->bus, m, NULL);
|
return sd_bus_send(sd->session->manager->bus, m, NULL);
|
||||||
}
|
}
|
||||||
|
|
||||||
static int sd_eviocrevoke(int fd) {
|
static void sd_eviocrevoke(int fd) {
|
||||||
static bool warned = false;
|
static bool warned = false;
|
||||||
|
|
||||||
assert(fd >= 0);
|
assert(fd >= 0);
|
||||||
@ -118,8 +118,6 @@ static int sd_eviocrevoke(int fd) {
|
|||||||
warned = true;
|
warned = true;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
return 0;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
static int sd_drmsetmaster(int fd) {
|
static int sd_drmsetmaster(int fd) {
|
||||||
@ -166,7 +164,7 @@ static int session_device_open(SessionDevice *sd, bool active) {
|
|||||||
} else
|
} else
|
||||||
/* DRM-Master is granted to the first user who opens a device automatically (ughh,
|
/* DRM-Master is granted to the first user who opens a device automatically (ughh,
|
||||||
* racy!). Hence, we just drop DRM-Master in case we were the first. */
|
* racy!). Hence, we just drop DRM-Master in case we were the first. */
|
||||||
sd_drmdropmaster(fd);
|
(void) sd_drmdropmaster(fd);
|
||||||
break;
|
break;
|
||||||
|
|
||||||
case DEVICE_TYPE_EVDEV:
|
case DEVICE_TYPE_EVDEV:
|
||||||
@ -195,11 +193,19 @@ static int session_device_start(SessionDevice *sd) {
|
|||||||
switch (sd->type) {
|
switch (sd->type) {
|
||||||
|
|
||||||
case DEVICE_TYPE_DRM:
|
case DEVICE_TYPE_DRM:
|
||||||
/* Device is kept open. Simply call drmSetMaster() and hope there is no-one else. In case it fails, we
|
|
||||||
* keep the device paused. Maybe at some point we have a drmStealMaster(). */
|
if (sd->fd < 0) {
|
||||||
r = sd_drmsetmaster(sd->fd);
|
/* Open device if it isn't open yet */
|
||||||
if (r < 0)
|
sd->fd = session_device_open(sd, true);
|
||||||
return r;
|
if (sd->fd < 0)
|
||||||
|
return sd->fd;
|
||||||
|
} else {
|
||||||
|
/* Device is kept open. Simply call drmSetMaster() and hope there is no-one else. In case it fails, we
|
||||||
|
* keep the device paused. Maybe at some point we have a drmStealMaster(). */
|
||||||
|
r = sd_drmsetmaster(sd->fd);
|
||||||
|
if (r < 0)
|
||||||
|
return r;
|
||||||
|
}
|
||||||
break;
|
break;
|
||||||
|
|
||||||
case DEVICE_TYPE_EVDEV:
|
case DEVICE_TYPE_EVDEV:
|
||||||
@ -216,7 +222,7 @@ static int session_device_start(SessionDevice *sd) {
|
|||||||
|
|
||||||
case DEVICE_TYPE_UNKNOWN:
|
case DEVICE_TYPE_UNKNOWN:
|
||||||
default:
|
default:
|
||||||
/* fallback for devices wihout synchronizations */
|
/* fallback for devices without synchronizations */
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -231,6 +237,7 @@ static void session_device_stop(SessionDevice *sd) {
|
|||||||
return;
|
return;
|
||||||
|
|
||||||
switch (sd->type) {
|
switch (sd->type) {
|
||||||
|
|
||||||
case DEVICE_TYPE_DRM:
|
case DEVICE_TYPE_DRM:
|
||||||
/* On DRM devices we simply drop DRM-Master but keep it open.
|
/* On DRM devices we simply drop DRM-Master but keep it open.
|
||||||
* This allows the user to keep resources allocated. The
|
* This allows the user to keep resources allocated. The
|
||||||
@ -238,6 +245,7 @@ static void session_device_stop(SessionDevice *sd) {
|
|||||||
* circumventing this. */
|
* circumventing this. */
|
||||||
sd_drmdropmaster(sd->fd);
|
sd_drmdropmaster(sd->fd);
|
||||||
break;
|
break;
|
||||||
|
|
||||||
case DEVICE_TYPE_EVDEV:
|
case DEVICE_TYPE_EVDEV:
|
||||||
/* Revoke access on evdev file-descriptors during deactivation.
|
/* Revoke access on evdev file-descriptors during deactivation.
|
||||||
* This will basically prevent any operations on the fd and
|
* This will basically prevent any operations on the fd and
|
||||||
@ -245,6 +253,7 @@ static void session_device_stop(SessionDevice *sd) {
|
|||||||
* protection this way. */
|
* protection this way. */
|
||||||
sd_eviocrevoke(sd->fd);
|
sd_eviocrevoke(sd->fd);
|
||||||
break;
|
break;
|
||||||
|
|
||||||
case DEVICE_TYPE_UNKNOWN:
|
case DEVICE_TYPE_UNKNOWN:
|
||||||
default:
|
default:
|
||||||
/* fallback for devices without synchronization */
|
/* fallback for devices without synchronization */
|
||||||
@ -462,6 +471,7 @@ void session_device_resume_all(Session *s) {
|
|||||||
continue;
|
continue;
|
||||||
if (session_device_save(sd) < 0)
|
if (session_device_save(sd) < 0)
|
||||||
continue;
|
continue;
|
||||||
|
|
||||||
session_device_notify(sd, SESSION_DEVICE_RESUME);
|
session_device_notify(sd, SESSION_DEVICE_RESUME);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user