xf86EloReadInput(): fix xserver unresponsiveness during touch The fix for bug #14109 ensures all bytes are emptied from the OS buffer by looping until xf86WaitForInput returns 0. This patch just changes the timeout from 1 millisecond to 0: we don't want the X server to block if there's no more serial data. It also removes the Vmin and Vtime options, which were making the calls to read() block until a complete 10-byte packet buffer could be filled. At 9600 bps, this could pause the X server for up to 9 ms. The code can already handle partial buffers, so all we have to do is get rid of the Vmin. Also, if xf86EloGetPacket() returns !Success, we should continue rather than break so the xf86WaitForInput call can decide whether to exit, in case there's more data in the buffer. Before the fix, glxgears was giving me about 390 FPS normally and down to 140 FPS when dragging an empty area of the touchscreen. Now it's basically unchanged when the touchscreen is in use (390 -> 385 FPS). --- xf86-input-elographics-1.2.3/src/xf86Elo.c.orig 2009-10-26 15:35:56.000000000 -0400 +++ xf86-input-elographics-1.2.3/src/xf86Elo.c 2009-10-26 16:11:59.000000000 -0400 @@ -421,15 +421,17 @@ #endif DBG(4, ErrorF("Entering ReadInput\n")); + /* - * Try to get a packet. + * Read bytes until there's no data left. We may have more or less than + * one packet worth of data in the OS buffer. */ - while (xf86WaitForInput(local->fd, ELO_MAX_WAIT/100) > 0) { + do { if(xf86EloGetPacket(priv->packet_buf, &priv->packet_buf_p, &priv->checksum, local->fd) != Success) - break; + continue; /* * Process only ELO_TOUCHs here. @@ -488,6 +490,7 @@ (state == ELO_PRESS) ? "Press" : ((state == ELO_RELEASE) ? "Release" : "Stream"))); } } + while (xf86WaitForInput(local->fd, 0) > 0); /* don't wait, just check */ } @@ -1059,8 +1062,6 @@ "StopBits", "1", "DataBits", "8", "Parity", "None", - "Vmin", "10", - "Vtime", "1", "FlowControl", "None", NULL };