From patchwork Fri Sep 29 12:42:49 2017 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: Mika Kuoppala X-Patchwork-Id: 9977967 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 030996034B for ; Fri, 29 Sep 2017 12:44:28 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id E1F952985D for ; Fri, 29 Sep 2017 12:44:27 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id D660A29863; Fri, 29 Sep 2017 12:44:27 +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 C99942985D for ; Fri, 29 Sep 2017 12:44:26 +0000 (UTC) Received: from gabe.freedesktop.org (localhost [127.0.0.1]) by gabe.freedesktop.org (Postfix) with ESMTP id 119E76EB41; Fri, 29 Sep 2017 12:44:25 +0000 (UTC) X-Original-To: intel-gfx@lists.freedesktop.org Delivered-To: intel-gfx@lists.freedesktop.org Received: from mga11.intel.com (mga11.intel.com [192.55.52.93]) by gabe.freedesktop.org (Postfix) with ESMTPS id A7C216EB41 for ; Fri, 29 Sep 2017 12:44:23 +0000 (UTC) Received: from orsmga002.jf.intel.com ([10.7.209.21]) by fmsmga102.fm.intel.com with ESMTP/TLS/DHE-RSA-AES256-GCM-SHA384; 29 Sep 2017 05:44:22 -0700 X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="5.42,452,1500966000"; d="scan'208";a="140889097" Received: from rosetta.fi.intel.com ([10.237.72.186]) by orsmga002.jf.intel.com with ESMTP; 29 Sep 2017 05:44:19 -0700 Received: by rosetta.fi.intel.com (Postfix, from userid 1000) id C8CCF840A99; Fri, 29 Sep 2017 15:42:50 +0300 (EEST) From: Mika Kuoppala To: intel-gfx@lists.freedesktop.org Date: Fri, 29 Sep 2017 15:42:49 +0300 Message-Id: <20170929124249.10202-3-mika.kuoppala@intel.com> X-Mailer: git-send-email 2.11.0 In-Reply-To: <20170929124249.10202-1-mika.kuoppala@intel.com> References: <20170929124249.10202-1-mika.kuoppala@intel.com> MIME-Version: 1.0 Subject: [Intel-gfx] [PATCH 3/3] 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, submit only those ports instead of iterating through all ports. v2: s/coalesce/submit (Michał) v3: rebase to new naming 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 d6071396da32..093211e74ad4 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 < execlists_active_ports(execlists); n++) { + for (n = first; n < execlists_active_ports(execlists); 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 = execlists_port(execlists, 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); } } @@ -567,6 +570,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 = execlists->first; @@ -576,6 +580,7 @@ static void i915_guc_dequeue(struct intel_engine_cs *engine) goto done; port = execlists_request_port(execlists); + first_idx = execlists_port_index(execlists, port); do { struct i915_priolist *p = rb_entry(rb, typeof(*p), node); @@ -615,7 +620,7 @@ static void i915_guc_dequeue(struct intel_engine_cs *engine) execlists->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 c09d1c93fd15..5adf6d023f3e 100644 --- a/drivers/gpu/drm/i915/intel_ringbuffer.h +++ b/drivers/gpu/drm/i915/intel_ringbuffer.h @@ -557,6 +557,15 @@ execlists_port(struct intel_engine_execlists * const execlists, return &execlists->port[port_n(execlists, n)]; } +static inline unsigned int +execlists_port_index(const struct intel_engine_execlists * const execlists, + const struct execlist_port * const port) +{ + const unsigned int n = port_index(port, execlists); + + return __port_n(n, -execlists->port_head, execlists->port_mask); +} + static inline struct execlist_port * execlists_port_head(struct intel_engine_execlists * const execlists) {