Re: [xserver] modesetting: Consume all available udev events at once

2016-09-23 Thread Hans de Goede

Hi,

On 12/11/2015 01:05 PM, Daniel Martin wrote:

From: Daniel Martin 

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 


Thank you for the patch one small comment below.


---
 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;


This change means that you're now no longer calling RRGetInfo() in this exit
path, which seems like an unrelated change.

I've applied this patch to my tree with this bit ommitted; and I will include
it in the pull-req with fixes for 1.19 I'm working on.




 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




Regards,

Hans
___
xorg-devel@lists.x.org: X.Org development
Archives: http://lists.x.org/archives/xorg-devel
Info: https://lists.x.org/mailman/listinfo/xorg-devel

[PATCH xserver] modesetting: Consume all available udev events at once

2015-12-11 Thread Daniel Martin
From: Daniel Martin 

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 
---
 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

___
xorg-devel@lists.x.org: X.Org development
Archives: http://lists.x.org/archives/xorg-devel
Info: http://lists.x.org/mailman/listinfo/xorg-devel