From patchwork Wed Sep 20 14:37:05 2017 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: Mika Kuoppala X-Patchwork-Id: 9961549 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 3717C60208 for ; Wed, 20 Sep 2017 14:39:11 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 2926528414 for ; Wed, 20 Sep 2017 14:39:11 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 1DF952917E; Wed, 20 Sep 2017 14:39:11 +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.2 required=2.0 tests=BAYES_00, RCVD_IN_DNSWL_MED 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 A77C228414 for ; Wed, 20 Sep 2017 14:39:09 +0000 (UTC) Received: from gabe.freedesktop.org (localhost [127.0.0.1]) by gabe.freedesktop.org (Postfix) with ESMTP id E6F706E0BE; Wed, 20 Sep 2017 14:39:08 +0000 (UTC) X-Original-To: intel-gfx@lists.freedesktop.org Delivered-To: intel-gfx@lists.freedesktop.org Received: from mga03.intel.com (mga03.intel.com [134.134.136.65]) by gabe.freedesktop.org (Postfix) with ESMTPS id A36696E762 for ; Wed, 20 Sep 2017 14:39:07 +0000 (UTC) Received: from orsmga002.jf.intel.com ([10.7.209.21]) by orsmga103.jf.intel.com with ESMTP/TLS/DHE-RSA-AES256-GCM-SHA384; 20 Sep 2017 07:39:07 -0700 X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="5.42,421,1500966000"; d="scan'208";a="137522485" Received: from rosetta.fi.intel.com ([10.237.72.186]) by orsmga002.jf.intel.com with ESMTP; 20 Sep 2017 07:39:05 -0700 Received: by rosetta.fi.intel.com (Postfix, from userid 1000) id 57A31840066; Wed, 20 Sep 2017 17:37:09 +0300 (EEST) From: Mika Kuoppala To: intel-gfx@lists.freedesktop.org Date: Wed, 20 Sep 2017 17:37:05 +0300 Message-Id: <20170920143705.11277-9-mika.kuoppala@intel.com> X-Mailer: git-send-email 2.11.0 In-Reply-To: <20170920143705.11277-1-mika.kuoppala@intel.com> References: <20170920143705.11277-1-mika.kuoppala@intel.com> MIME-Version: 1.0 Subject: [Intel-gfx] [PATCH 8/8] drm/i915: Improve GuC request coalescing 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 Now that we can keep track of what ports we have dequeued, coalesce only those ports instead of iterating through all ports. Cc: Michał Winiarski Cc: Chris Wilson Signed-off-by: Mika Kuoppala Reviewed-by: Michał Winiarski --- drivers/gpu/drm/i915/i915_guc_submission.c | 31 +++++++++++++++++------------- drivers/gpu/drm/i915/intel_ringbuffer.h | 9 +++++++++ 2 files changed, 27 insertions(+), 13 deletions(-) diff --git a/drivers/gpu/drm/i915/i915_guc_submission.c b/drivers/gpu/drm/i915/i915_guc_submission.c index 359f57a59cba..1057a0fb9f27 100644 --- a/drivers/gpu/drm/i915/i915_guc_submission.c +++ b/drivers/gpu/drm/i915/i915_guc_submission.c @@ -485,11 +485,13 @@ static void guc_ring_doorbell(struct i915_guc_client *client) /** * i915_guc_submit() - Submit commands through GuC * @engine: engine associated with the commands + * @first: index of first execlist port to start coalescing from * * The only error here arises if the doorbell hardware isn't functioning * as expected, which really shouldn't happen. */ -static void i915_guc_submit(struct intel_engine_cs *engine) +static void i915_guc_submit(struct intel_engine_cs *engine, + const unsigned int first) { struct drm_i915_private *dev_priv = engine->i915; struct intel_guc *guc = &dev_priv->guc; @@ -498,7 +500,7 @@ static void i915_guc_submit(struct intel_engine_cs *engine) const unsigned int engine_id = engine->id; unsigned int n; - for (n = 0; n < execlist_active_ports(el); n++) { + for (n = first; n < execlist_active_ports(el); n++) { struct execlist_port *port; struct drm_i915_gem_request *rq; unsigned int count; @@ -506,21 +508,22 @@ static void i915_guc_submit(struct intel_engine_cs *engine) port = execlist_port_index(el, n); rq = port_unpack(port, &count); - if (rq && count == 0) { - port_set(port, port_pack(rq, ++count)); + GEM_BUG_ON(!rq); + GEM_BUG_ON(count); - if (i915_vma_is_map_and_fenceable(rq->ring->vma)) - POSTING_READ_FW(GUC_STATUS); + port_set(port, port_pack(rq, ++count)); - spin_lock(&client->wq_lock); + if (i915_vma_is_map_and_fenceable(rq->ring->vma)) + POSTING_READ_FW(GUC_STATUS); - guc_wq_item_append(client, rq); - guc_ring_doorbell(client); + spin_lock(&client->wq_lock); - client->submissions[engine_id] += 1; + guc_wq_item_append(client, rq); + guc_ring_doorbell(client); - spin_unlock(&client->wq_lock); - } + client->submissions[engine_id] += 1; + + spin_unlock(&client->wq_lock); } } @@ -566,6 +569,7 @@ static void i915_guc_dequeue(struct intel_engine_cs *engine) struct drm_i915_gem_request *last = NULL; bool submit = false; struct rb_node *rb; + unsigned int first_idx; spin_lock_irq(&engine->timeline->lock); rb = el->first; @@ -575,6 +579,7 @@ static void i915_guc_dequeue(struct intel_engine_cs *engine) goto done; port = execlist_request_port(el); + first_idx = execlist_get_port_index(el, port); do { struct i915_priolist *p = rb_entry(rb, typeof(*p), node); @@ -614,7 +619,7 @@ static void i915_guc_dequeue(struct intel_engine_cs *engine) el->first = rb; if (submit) { port_assign(port, last); - i915_guc_submit(engine); + i915_guc_submit(engine, first_idx); } spin_unlock_irq(&engine->timeline->lock); } diff --git a/drivers/gpu/drm/i915/intel_ringbuffer.h b/drivers/gpu/drm/i915/intel_ringbuffer.h index efa5a8ea1ecb..f2eb32539300 100644 --- a/drivers/gpu/drm/i915/intel_ringbuffer.h +++ b/drivers/gpu/drm/i915/intel_ringbuffer.h @@ -556,6 +556,15 @@ execlist_port_index(struct intel_engine_execlist * const el, return &el->port[__port_idx(el->port_head, n, el->port_mask)]; } +static inline unsigned int +execlist_get_port_index(const struct intel_engine_execlist * const el, + const struct execlist_port * const port) +{ + const unsigned int n = port_index(port, el); + + return __port_idx(n, -el->port_head, el->port_mask); +} + static inline struct execlist_port * execlist_port_head(struct intel_engine_execlist * const el) {