From patchwork Thu Jan 7 16:36:17 2016 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Tvrtko Ursulin X-Patchwork-Id: 7978391 Return-Path: X-Original-To: patchwork-intel-gfx@patchwork.kernel.org Delivered-To: patchwork-parsemail@patchwork1.web.kernel.org Received: from mail.kernel.org (mail.kernel.org [198.145.29.136]) by patchwork1.web.kernel.org (Postfix) with ESMTP id 8D0669F32E for ; Thu, 7 Jan 2016 16:36:33 +0000 (UTC) Received: from mail.kernel.org (localhost [127.0.0.1]) by mail.kernel.org (Postfix) with ESMTP id BA4B720142 for ; Thu, 7 Jan 2016 16:36:32 +0000 (UTC) Received: from gabe.freedesktop.org (gabe.freedesktop.org [131.252.210.177]) by mail.kernel.org (Postfix) with ESMTP id CD67220138 for ; Thu, 7 Jan 2016 16:36:31 +0000 (UTC) Received: from gabe.freedesktop.org (localhost [127.0.0.1]) by gabe.freedesktop.org (Postfix) with ESMTP id 332386E6B4; Thu, 7 Jan 2016 08:36:31 -0800 (PST) X-Original-To: Intel-gfx@lists.freedesktop.org Delivered-To: Intel-gfx@lists.freedesktop.org Received: from mga04.intel.com (mga04.intel.com [192.55.52.120]) by gabe.freedesktop.org (Postfix) with ESMTP id 3379E6E6B0 for ; Thu, 7 Jan 2016 08:36:29 -0800 (PST) Received: from fmsmga002.fm.intel.com ([10.253.24.26]) by fmsmga104.fm.intel.com with ESMTP; 07 Jan 2016 08:36:30 -0800 X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="5.20,533,1444719600"; d="scan'208";a="888325781" Received: from tursulin-linux.isw.intel.com ([10.102.226.196]) by fmsmga002.fm.intel.com with ESMTP; 07 Jan 2016 08:36:28 -0800 From: Tvrtko Ursulin To: Intel-gfx@lists.freedesktop.org Date: Thu, 7 Jan 2016 16:36:17 +0000 Message-Id: <1452184581-21075-3-git-send-email-tvrtko.ursulin@linux.intel.com> X-Mailer: git-send-email 1.9.1 In-Reply-To: <1452184581-21075-1-git-send-email-tvrtko.ursulin@linux.intel.com> References: <1452184581-21075-1-git-send-email-tvrtko.ursulin@linux.intel.com> Subject: [Intel-gfx] [PATCH 2/6] drm/i915: Don't need a timer to wake us up 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-Spam-Status: No, score=-4.2 required=5.0 tests=BAYES_00, RCVD_IN_DNSWL_MED, RP_MATCHES_RCVD, UNPARSEABLE_RELAY autolearn=unavailable version=3.3.1 X-Spam-Checker-Version: SpamAssassin 3.3.1 (2010-03-16) on mail.kernel.org X-Virus-Scanned: ClamAV using ClamSMTP From: Tvrtko Ursulin Looks like the sleeping loop in __i915_wait_request can be simplified by using io_schedule_timeout instead of setting up and destroying a timer. Signed-off-by: Tvrtko Ursulin Cc: Chris Wilson --- drivers/gpu/drm/i915/i915_gem.c | 28 ++++++++-------------------- 1 file changed, 8 insertions(+), 20 deletions(-) diff --git a/drivers/gpu/drm/i915/i915_gem.c b/drivers/gpu/drm/i915/i915_gem.c index 6c60e04fc09c..de98dc41fb9f 100644 --- a/drivers/gpu/drm/i915/i915_gem.c +++ b/drivers/gpu/drm/i915/i915_gem.c @@ -1135,11 +1135,6 @@ i915_gem_check_wedge(struct i915_gpu_error *error, return 0; } -static void fake_irq(unsigned long data) -{ - wake_up_process((struct task_struct *)data); -} - static bool missed_irq(struct drm_i915_private *dev_priv, struct intel_engine_cs *ring) { @@ -1291,7 +1286,7 @@ int __i915_wait_request(struct drm_i915_gem_request *req, } for (;;) { - struct timer_list timer; + long sched_timeout; prepare_to_wait(&ring->irq_queue, &wait, state); @@ -1321,21 +1316,14 @@ int __i915_wait_request(struct drm_i915_gem_request *req, break; } - timer.function = NULL; - if (timeout || missed_irq(dev_priv, ring)) { - unsigned long expire; - - setup_timer_on_stack(&timer, fake_irq, (unsigned long)current); - expire = missed_irq(dev_priv, ring) ? jiffies + 1 : timeout_expire; - mod_timer(&timer, expire); - } - - io_schedule(); + if (timeout) + sched_timeout = timeout_expire - jiffies; + else if (missed_irq(dev_priv, ring)) + sched_timeout = 1; + else + sched_timeout = MAX_SCHEDULE_TIMEOUT; - if (timer.function) { - del_singleshot_timer_sync(&timer); - destroy_timer_on_stack(&timer); - } + io_schedule_timeout(sched_timeout); } if (!irq_test_in_progress) ring->irq_put(ring);