From: Eric Anholt Subject: [PATCH 2/4] Add io_ variants of wait_event() and wait_event_interruptible() Date: Mon, 1 Nov 2010 13:23:42 -0700 Message-ID: <1288643024-5706-3-git-send-email-eric@anholt.net> References: <1288643024-5706-1-git-send-email-eric@anholt.net> Mime-Version: 1.0 Content-Type: text/plain; charset="us-ascii" Content-Transfer-Encoding: 7bit Return-path: In-Reply-To: <1288643024-5706-1-git-send-email-eric@anholt.net> List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Sender: intel-gfx-bounces+gcfxdi-intel-gfx=m.gmane.org@lists.freedesktop.org Errors-To: intel-gfx-bounces+gcfxdi-intel-gfx=m.gmane.org@lists.freedesktop.org To: intel-gfx@lists.freedesktop.org List-Id: intel-gfx@lists.freedesktop.org These tell the scheduler that we're waiting on IO, and still "busy". Signed-off-by: Eric Anholt --- include/linux/wait.h | 46 ++++++++++++++++++++++++++++++++++++++++++++++ 1 files changed, 46 insertions(+), 0 deletions(-) diff --git a/include/linux/wait.h b/include/linux/wait.h index 3efc9f3..b299c2b 100644 --- a/include/linux/wait.h +++ b/include/linux/wait.h @@ -202,6 +202,19 @@ do { \ finish_wait(&wq, &__wait); \ } while (0) +#define __io_wait_event(wq, condition) \ +do { \ + DEFINE_WAIT(__wait); \ + \ + for (;;) { \ + prepare_to_wait(&wq, &__wait, TASK_UNINTERRUPTIBLE); \ + if (condition) \ + break; \ + io_schedule(); \ + } \ + finish_wait(&wq, &__wait); \ +} while (0) + /** * wait_event - sleep until a condition gets true * @wq: the waitqueue to wait on @@ -221,6 +234,13 @@ do { \ __wait_event(wq, condition); \ } while (0) +#define io_wait_event(wq, condition) \ +do { \ + if (condition) \ + break; \ + __io_wait_event(wq, condition); \ +} while (0) + #define __wait_event_timeout(wq, condition, ret) \ do { \ DEFINE_WAIT(__wait); \ @@ -260,6 +280,24 @@ do { \ __ret; \ }) +#define __io_wait_event_interruptible(wq, condition, ret) \ +do { \ + DEFINE_WAIT(__wait); \ + \ + for (;;) { \ + prepare_to_wait(&wq, &__wait, TASK_INTERRUPTIBLE); \ + if (condition) \ + break; \ + if (!signal_pending(current)) { \ + io_schedule(); \ + continue; \ + } \ + ret = -ERESTARTSYS; \ + break; \ + } \ + finish_wait(&wq, &__wait); \ +} while (0) + #define __wait_event_interruptible(wq, condition, ret) \ do { \ DEFINE_WAIT(__wait); \ @@ -301,6 +339,14 @@ do { \ __ret; \ }) +#define io_wait_event_interruptible(wq, condition) \ +({ \ + int __ret = 0; \ + if (!(condition)) \ + __io_wait_event_interruptible(wq, condition, __ret); \ + __ret; \ +}) + #define __wait_event_interruptible_timeout(wq, condition, ret) \ do { \ DEFINE_WAIT(__wait); \ -- 1.7.2.3