linux: Drain the console fd of data when using evdev for keyboards
Works around a silly bug in the kernel that causes wakeup storms after too many keypresses. Should fix the kernel bug too, but this at least keeps the idle wakeup count below 1000/sec.
This commit is contained in:
parent
6d21fbf006
commit
446d9443ce
|
@ -85,6 +85,14 @@ restoreVtPerms(void)
|
||||||
chown(vtname, vtPermSave[2], vtPermSave[3]);
|
chown(vtname, vtPermSave[2], vtPermSave[3]);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
static void *console_handler;
|
||||||
|
|
||||||
|
static void
|
||||||
|
drain_console(int fd, void *closure)
|
||||||
|
{
|
||||||
|
tcflush(fd, TCIOFLUSH);
|
||||||
|
}
|
||||||
|
|
||||||
void
|
void
|
||||||
xf86OpenConsole(void)
|
xf86OpenConsole(void)
|
||||||
{
|
{
|
||||||
|
@ -300,6 +308,10 @@ xf86OpenConsole(void)
|
||||||
cfsetispeed(&nTty, 9600);
|
cfsetispeed(&nTty, 9600);
|
||||||
cfsetospeed(&nTty, 9600);
|
cfsetospeed(&nTty, 9600);
|
||||||
tcsetattr(xf86Info.consoleFd, TCSANOW, &nTty);
|
tcsetattr(xf86Info.consoleFd, TCSANOW, &nTty);
|
||||||
|
|
||||||
|
/* need to keep the buffer clean, else the kernel gets angry */
|
||||||
|
console_handler = xf86AddGeneralHandler(xf86Info.consoleFd,
|
||||||
|
drain_console, NULL);
|
||||||
}
|
}
|
||||||
|
|
||||||
/* we really should have a InitOSInputDevices() function instead
|
/* we really should have a InitOSInputDevices() function instead
|
||||||
|
@ -346,6 +358,11 @@ xf86CloseConsole()
|
||||||
|
|
||||||
if (ShareVTs) return;
|
if (ShareVTs) return;
|
||||||
|
|
||||||
|
if (console_handler) {
|
||||||
|
xf86RemoveGeneralHandler(console_handler);
|
||||||
|
console_handler = NULL;
|
||||||
|
};
|
||||||
|
|
||||||
#if defined(DO_OS_FONTRESTORE)
|
#if defined(DO_OS_FONTRESTORE)
|
||||||
if (ioctl(xf86Info.consoleFd, VT_GETSTATE, &vts) < 0)
|
if (ioctl(xf86Info.consoleFd, VT_GETSTATE, &vts) < 0)
|
||||||
xf86Msg(X_WARNING, "xf86CloseConsole: VT_GETSTATE failed: %s\n",
|
xf86Msg(X_WARNING, "xf86CloseConsole: VT_GETSTATE failed: %s\n",
|
||||||
|
|
Loading…
Reference in New Issue
Block a user