From patchwork Thu Feb 2 15:13:09 2017 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Chris Wilson X-Patchwork-Id: 9552253 Return-Path: Received: from mail.wl.linuxfoundation.org (pdx-wl-mail.web.codeaurora.org [172.30.200.125]) by pdx-korg-patchwork.web.codeaurora.org (Postfix) with ESMTP id E44D660236 for ; Thu, 2 Feb 2017 15:13:34 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id E2FF928304 for ; Thu, 2 Feb 2017 15:13:34 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id D7A6C28425; Thu, 2 Feb 2017 15:13:34 +0000 (UTC) X-Spam-Checker-Version: SpamAssassin 3.3.1 (2010-03-16) on pdx-wl-mail.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-4.1 required=2.0 tests=BAYES_00,DKIM_SIGNED, RCVD_IN_DNSWL_MED,T_DKIM_INVALID autolearn=ham version=3.3.1 Received: from gabe.freedesktop.org (gabe.freedesktop.org [131.252.210.177]) (using TLSv1.2 with cipher DHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mail.wl.linuxfoundation.org (Postfix) with ESMTPS id 83D3728304 for ; Thu, 2 Feb 2017 15:13:34 +0000 (UTC) Received: from gabe.freedesktop.org (localhost [127.0.0.1]) by gabe.freedesktop.org (Postfix) with ESMTP id 6B8526EA45; Thu, 2 Feb 2017 15:13:32 +0000 (UTC) X-Original-To: intel-gfx@lists.freedesktop.org Delivered-To: intel-gfx@lists.freedesktop.org Received: from mail-wj0-x241.google.com (mail-wj0-x241.google.com [IPv6:2a00:1450:400c:c01::241]) by gabe.freedesktop.org (Postfix) with ESMTPS id B54636EA48 for ; Thu, 2 Feb 2017 15:13:30 +0000 (UTC) Received: by mail-wj0-x241.google.com with SMTP id le4so1336733wjb.0 for ; Thu, 02 Feb 2017 07:13:30 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=sender:from:to:cc:subject:date:message-id:in-reply-to:references; bh=eso0qdHSAyW8vUifJqNyaqoGYHH+PWYM+TLjjyH/CHQ=; b=cQcprbL+0vu4lKTRG1wuf1Oah6KEgWEo1I0YG1INUVjGy97DDQMH/6HeDyfo9BCUCu YYW5A5hnITzV1vHbVmzg3L6zJRFURFACJ9QDvIkYIVcoUwLjQjfvbUYGsCqhTFFTIVi8 6tqWS8NQcSmP5ogR/FnDUeyaAGOJ11vvKaq7XdiYXEv8qTFVGKTG9ZJcxu4v8KfAqeox eBKfPYtESjqC4IpwJXCvZYwR0WO155nClRVVvQidDxWnR2MPAhAgCOIJ6DE0kjDOFWgU x3mpw5eoT+ezMzYIrY0KeR3HZXN77IfVnMJ6N7/FJ92ZiM5ZxxH0d5ZhnAJJCnTbbnwD hJpg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:sender:from:to:cc:subject:date:message-id :in-reply-to:references; bh=eso0qdHSAyW8vUifJqNyaqoGYHH+PWYM+TLjjyH/CHQ=; b=c955DGVxCDBS09+25pq70PZjlgwAaxpC0K89lSdczYLFSvsXCyGws1vRlJ1DYQ0zM3 HCMX8hlPFRGWpcs7U1cLSOVawCVyjnOfJi0sYBh8XDfrQbLmHb9LwZ4xWDCGSLUpj0HH xl+tUdywdJn9TgHkaqHfUu0YrfhiWwfDSBT8/+0MIZoBeYYj6icrmkVKdWqk90xnOph0 SqoBRyUD6SWGq55Rg+WuPSTerltV1di8np6jEisCsN6lgwa1eJLGvcyPVh0EbNFCJvO9 NBAGlYNcnWdFwj06jMdenPq3HboveJvJ7OTVIiee3l8ZBfoY0w7p5fDq7NF+Ggnv65xU qF7w== X-Gm-Message-State: AIkVDXKnJxJxF6k6ftwZadi951sdwiTgOqq7g026R98QB/7Me/nU/+smy2MGUVWLV4P75w== X-Received: by 10.223.139.213 with SMTP id w21mr8076651wra.108.1486048409107; Thu, 02 Feb 2017 07:13:29 -0800 (PST) Received: from haswell.alporthouse.com ([78.156.65.138]) by smtp.gmail.com with ESMTPSA id o81sm3624020wmb.14.2017.02.02.07.13.28 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Thu, 02 Feb 2017 07:13:28 -0800 (PST) From: Chris Wilson To: intel-gfx@lists.freedesktop.org Date: Thu, 2 Feb 2017 15:13:09 +0000 Message-Id: <20170202151312.31406-11-chris@chris-wilson.co.uk> X-Mailer: git-send-email 2.11.0 In-Reply-To: <20170202151312.31406-1-chris@chris-wilson.co.uk> References: <20170202151312.31406-1-chris@chris-wilson.co.uk> Subject: [Intel-gfx] [PATCH 11/14] drm/i915: Replace reset_wait_queue with default_wake_function X-BeenThere: intel-gfx@lists.freedesktop.org X-Mailman-Version: 2.1.18 Precedence: list List-Id: Intel graphics driver community testing & development List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , MIME-Version: 1.0 Errors-To: intel-gfx-bounces@lists.freedesktop.org Sender: "Intel-gfx" X-Virus-Scanned: ClamAV using ClamSMTP If we change the wait_queue_t from using the autoremove_wake_function to the default_wake_function, we no longer have to restore the wait_queue_t entry on the wait_queue_head_t list after being woken up by it, as we are unusual in sleeping multiple times on the same wait_queue_t. Signed-off-by: Chris Wilson --- drivers/gpu/drm/i915/i915_gem_request.c | 28 ++++++---------------------- 1 file changed, 6 insertions(+), 22 deletions(-) diff --git a/drivers/gpu/drm/i915/i915_gem_request.c b/drivers/gpu/drm/i915/i915_gem_request.c index f70a2c3d26cd..6cf1210984d7 100644 --- a/drivers/gpu/drm/i915/i915_gem_request.c +++ b/drivers/gpu/drm/i915/i915_gem_request.c @@ -938,16 +938,6 @@ void __i915_add_request(struct drm_i915_gem_request *request, bool flush_caches) local_bh_enable(); /* Kick the execlists tasklet if just scheduled */ } -static void reset_wait_queue(wait_queue_head_t *q, wait_queue_t *wait) -{ - unsigned long flags; - - spin_lock_irqsave(&q->lock, flags); - if (list_empty(&wait->task_list)) - __add_wait_queue(q, wait); - spin_unlock_irqrestore(&q->lock, flags); -} - static unsigned long local_clock_us(unsigned int *cpu) { unsigned long t; @@ -1042,8 +1032,8 @@ long i915_wait_request(struct drm_i915_gem_request *req, const int state = flags & I915_WAIT_INTERRUPTIBLE ? TASK_INTERRUPTIBLE : TASK_UNINTERRUPTIBLE; wait_queue_head_t *errq = &req->i915->gpu_error.wait_queue; - DEFINE_WAIT(reset); - DEFINE_WAIT(exec); + DEFINE_WAIT_FUNC(reset, default_wake_function); + DEFINE_WAIT_FUNC(exec, default_wake_function); struct intel_wait wait; might_sleep(); @@ -1062,13 +1052,13 @@ long i915_wait_request(struct drm_i915_gem_request *req, trace_i915_gem_request_wait_begin(req); + add_wait_queue(&req->execute, &exec); if (flags & I915_WAIT_LOCKED) add_wait_queue(errq, &reset); wait.tsk = current; restart: - reset_wait_queue(&req->execute, &exec); wait.seqno = i915_gem_request_global_seqno(req); if (!wait.seqno) { do { @@ -1082,21 +1072,16 @@ long i915_wait_request(struct drm_i915_gem_request *req, i915_reset_in_progress(&req->i915->gpu_error)) { __set_current_state(TASK_RUNNING); i915_reset(req->i915); - reset_wait_queue(errq, &reset); continue; } if (signal_pending_state(state, current)) { timeout = -ERESTARTSYS; - break; + goto complete; } timeout = io_schedule_timeout(timeout); } while (timeout); - finish_wait(&req->execute, &exec); - - if (timeout < 0) - goto complete; GEM_BUG_ON(!wait.seqno); } @@ -1156,7 +1141,6 @@ long i915_wait_request(struct drm_i915_gem_request *req, i915_reset_in_progress(&req->i915->gpu_error)) { __set_current_state(TASK_RUNNING); i915_reset(req->i915); - reset_wait_queue(errq, &reset); continue; } @@ -1171,11 +1155,11 @@ long i915_wait_request(struct drm_i915_gem_request *req, } intel_engine_remove_wait(req->engine, &wait); - __set_current_state(TASK_RUNNING); - complete: + __set_current_state(TASK_RUNNING); if (flags & I915_WAIT_LOCKED) remove_wait_queue(errq, &reset); + remove_wait_queue(&req->execute, &exec); trace_i915_gem_request_wait_end(req); return timeout;