epoll: Add a flag, EPOLLWAKEUP, to prevent suspend while epoll events are ready

When an epoll_event, that has the EPOLLWAKEUP flag set, is ready, a
wakeup_source will be active to prevent suspend. This can be used to
handle wakeup events from a driver that support poll, e.g. input, if
that driver wakes up the waitqueue passed to epoll before allowing
suspend.

Signed-off-by: Arve Hjønnevåg <arve@android.com>
Reviewed-by: NeilBrown <neilb@suse.de>
Signed-off-by: Rafael J. Wysocki <rjw@sisk.pl>
This commit is contained in:
Arve Hjønnevåg 2012-05-01 21:33:34 +02:00 committed by Rafael J. Wysocki
parent b86ff9820f
commit 4d7e30d989
3 changed files with 103 additions and 4 deletions

View file

@ -26,6 +26,18 @@
#define EPOLL_CTL_DEL 2
#define EPOLL_CTL_MOD 3
/*
* Request the handling of system wakeup events so as to prevent system suspends
* from happening while those events are being processed.
*
* Assuming neither EPOLLET nor EPOLLONESHOT is set, system suspends will not be
* re-allowed until epoll_wait is called again after consuming the wakeup
* event(s).
*
* Requires CAP_EPOLLWAKEUP
*/
#define EPOLLWAKEUP (1 << 29)
/* Set the One Shot behaviour for the target file descriptor */
#define EPOLLONESHOT (1 << 30)