From 363f4273dd4aec3e26cc57ecb6c20f27e6c813d8 Mon Sep 17 00:00:00 2001 From: Daniel Martin Date: Fri, 11 Dec 2015 12:05:22 +0100 Subject: modesetting: Consume all available udev events at once 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 [hdegoede@redhat.com: Keep goto out so that we always call RRGetInfo()] Reviewed-by: Hans de Goede Signed-off-by: Hans de Goede --- hw/xfree86/drivers/modesetting/drmmode_display.c | 10 ++++++---- 1 file changed, 6 insertions(+), 4 deletions(-) (limited to 'hw/xfree86/drivers') diff --git a/hw/xfree86/drivers/modesetting/drmmode_display.c b/hw/xfree86/drivers/modesetting/drmmode_display.c index 6b933e49b..b895d628a 100644 --- a/hw/xfree86/drivers/modesetting/drmmode_display.c +++ b/hw/xfree86/drivers/modesetting/drmmode_display.c @@ -2269,11 +2269,14 @@ 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); @@ -2339,7 +2342,6 @@ out_free_res: drmModeFreeResources(mode_res); out: RRGetInfo(xf86ScrnToScreen(scrn), TRUE); - udev_device_unref(dev); } #endif -- cgit v1.2.3