From patchwork Tue Mar 28 18:00:27 2017 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: =?utf-8?q?Micha=C5=82_Winiarski?= X-Patchwork-Id: 9650317 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 650AE601D7 for ; Tue, 28 Mar 2017 18:01:31 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 6B45A2844E for ; Tue, 28 Mar 2017 18:01:31 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 5DEDF28464; Tue, 28 Mar 2017 18:01:31 +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 E558A2844E for ; Tue, 28 Mar 2017 18:01:30 +0000 (UTC) Received: from gabe.freedesktop.org (localhost [127.0.0.1]) by gabe.freedesktop.org (Postfix) with ESMTP id 66B6C6E650; Tue, 28 Mar 2017 18:01:29 +0000 (UTC) X-Original-To: intel-gfx@lists.freedesktop.org Delivered-To: intel-gfx@lists.freedesktop.org Received: from mga14.intel.com (mga14.intel.com [192.55.52.115]) by gabe.freedesktop.org (Postfix) with ESMTPS id 62F55894EB for ; Tue, 28 Mar 2017 18:01:27 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=simple/simple; d=intel.com; i=@intel.com; q=dns/txt; s=intel; t=1490724087; x=1522260087; h=from:to:cc:subject:date:message-id:in-reply-to: references:mime-version:content-transfer-encoding; bh=YY/sUyQUEiIxgjWQt52UpWbQ4niEld//fJ0oKvvadZo=; b=laC7hggR1MILVR2jCb3R+6VgCiTezP1vi665DEGeEFjVJDTIPuk0QQWh O7ie66B9BAvLo6Kk9PkPcpdnvlVrYA==; Received: from fmsmga002.fm.intel.com ([10.253.24.26]) by fmsmga103.fm.intel.com with ESMTP/TLS/DHE-RSA-AES256-GCM-SHA384; 28 Mar 2017 11:01:26 -0700 X-ExtLoop1: 1 X-IronPort-AV: E=Sophos; i="5.36,237,1486454400"; d="scan'208"; a="1148045161" Received: from irsmsx102.ger.corp.intel.com ([163.33.3.155]) by fmsmga002.fm.intel.com with ESMTP; 28 Mar 2017 11:01:25 -0700 Received: from mwiniars-main.igk.intel.com (172.28.171.152) by IRSMSX102.ger.corp.intel.com (163.33.3.155) with Microsoft SMTP Server id 14.3.319.2; Tue, 28 Mar 2017 19:01:25 +0100 From: =?UTF-8?q?Micha=C5=82=20Winiarski?= To: Date: Tue, 28 Mar 2017 20:00:27 +0200 Message-ID: <20170328180029.1073-2-michal.winiarski@intel.com> X-Mailer: git-send-email 2.9.3 In-Reply-To: <20170328180029.1073-1-michal.winiarski@intel.com> References: <20170328180029.1073-1-michal.winiarski@intel.com> MIME-Version: 1.0 X-Originating-IP: [172.28.171.152] Subject: [Intel-gfx] [RFC 2/4] drm/i915/scheduler: Make insert_request resubmission aware 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: , Errors-To: intel-gfx-bounces@lists.freedesktop.org Sender: "Intel-gfx" X-Virus-Scanned: ClamAV using ClamSMTP Normally when we're inserting requests with equal priority, we're using FIFO ordering. However, when we're resubmitting requests it's helpful to be able to ensure that they're executed before their dependencies, meaning that we need to use LIFO ordering instead. Cc: Chris Wilson Cc: Joonas Lahtinen Cc: Tvrtko Ursulin Signed-off-by: MichaƂ Winiarski --- drivers/gpu/drm/i915/intel_lrc.c | 15 ++++++++++----- 1 file changed, 10 insertions(+), 5 deletions(-) diff --git a/drivers/gpu/drm/i915/intel_lrc.c b/drivers/gpu/drm/i915/intel_lrc.c index 301ae7c..107cf91 100644 --- a/drivers/gpu/drm/i915/intel_lrc.c +++ b/drivers/gpu/drm/i915/intel_lrc.c @@ -611,12 +611,15 @@ static void intel_lrc_irq_handler(unsigned long data) intel_uncore_forcewake_put(dev_priv, engine->fw_domains); } -static bool insert_request(struct i915_priotree *pt, struct rb_root *root) +static bool insert_request(struct i915_priotree *pt, struct rb_root *root, + bool reinsert) { struct rb_node **p, *rb; bool first = true; - /* most positive priority is scheduled first, equal priorities fifo */ + /* most positive priority is scheduled first, + * equal priorities - fifo, except when we're reinserting - lifo + */ rb = NULL; p = &root->rb_node; while (*p) { @@ -624,7 +627,8 @@ static bool insert_request(struct i915_priotree *pt, struct rb_root *root) rb = *p; pos = rb_entry(rb, typeof(*pos), node); - if (pt->priority > pos->priority) { + if ((pt->priority > pos->priority) || + ((pt->priority == pos->priority) && reinsert)) { p = &rb->rb_left; } else { p = &rb->rb_right; @@ -645,7 +649,8 @@ static void execlists_submit_request(struct drm_i915_gem_request *request) /* Will be called from irq-context when using foreign fences. */ spin_lock_irqsave(&engine->timeline->lock, flags); - if (insert_request(&request->priotree, &engine->execlist_queue)) { + if (insert_request(&request->priotree, + &engine->execlist_queue, false)) { engine->execlist_first = &request->priotree.node; if (execlists_elsp_ready(engine)) tasklet_hi_schedule(&engine->irq_tasklet); @@ -742,7 +747,7 @@ static void execlists_schedule(struct drm_i915_gem_request *request, int prio) pt->priority = prio; rb_erase(&pt->node, &engine->execlist_queue); - if (insert_request(pt, &engine->execlist_queue)) + if (insert_request(pt, &engine->execlist_queue, false)) engine->execlist_first = &pt->node; }