[PATCH xserver] modesetting: Consume all available udev events at once
Daniel Martin
daniel.martin at secunet.com
Fri Dec 11 03:05:22 PST 2015
From: Daniel Martin <consume.noise at gmail.com>
We get multiple udev events for actions like docking a laptop into its
station or plugging a monitor to the station. By consuming as much
events as we can, we reduce the number of output re-evalutions.
I.e. having a Lenovo X250 in a ThinkPad Ultra Dock and plugging a
monitor to the station generates 5 udev events. Or having 2 monitors
attached to the station and docking the laptop generates 7 events.
It depends on the timing how many events can consumed at once.
Signed-off-by: Daniel Martin <consume.noise at gmail.com>
---
hw/xfree86/drivers/modesetting/drmmode_display.c | 13 +++++++------
1 file changed, 7 insertions(+), 6 deletions(-)
diff --git a/hw/xfree86/drivers/modesetting/drmmode_display.c b/hw/xfree86/drivers/modesetting/drmmode_display.c
index 0d34ca1..eeccb82 100644
--- a/hw/xfree86/drivers/modesetting/drmmode_display.c
+++ b/hw/xfree86/drivers/modesetting/drmmode_display.c
@@ -1944,16 +1944,19 @@ drmmode_handle_uevents(int fd, void *closure)
drmModeResPtr mode_res;
xf86CrtcConfigPtr config = XF86_CRTC_CONFIG_PTR(scrn);
int i, j;
- Bool found;
+ Bool found = FALSE;
Bool changed = FALSE;
- dev = udev_monitor_receive_device(drmmode->uevent_monitor);
- if (!dev)
+ while ((dev = udev_monitor_receive_device(drmmode->uevent_monitor))) {
+ udev_device_unref(dev);
+ found = TRUE;
+ }
+ if (!found)
return;
mode_res = drmModeGetResources(drmmode->fd);
if (!mode_res)
- goto out;
+ return;
if (mode_res->count_crtcs != config->num_crtc) {
ErrorF("number of CRTCs changed - failed to handle, %d vs %d\n", mode_res->count_crtcs, config->num_crtc);
@@ -2012,9 +2015,7 @@ drmmode_handle_uevents(int fd, void *closure)
out_free_res:
drmModeFreeResources(mode_res);
-out:
RRGetInfo(xf86ScrnToScreen(scrn), TRUE);
- udev_device_unref(dev);
}
#endif
--
2.6.2
More information about the xorg-devel
mailing list