From patchwork Fri Mar 29 22:11:10 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: Michal Wajdeczko X-Patchwork-Id: 10877843 Return-Path: Received: from mail.wl.linuxfoundation.org (pdx-wl-mail.web.codeaurora.org [172.30.200.125]) by pdx-korg-patchwork-2.web.codeaurora.org (Postfix) with ESMTP id 0F57617E0 for ; Fri, 29 Mar 2019 22:12:24 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id EE8FC2906F for ; Fri, 29 Mar 2019 22:12:23 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id E1408292B4; Fri, 29 Mar 2019 22:12:23 +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=-5.2 required=2.0 tests=BAYES_00,MAILING_LIST_MULTI, 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 67BA22906F for ; Fri, 29 Mar 2019 22:12:23 +0000 (UTC) Received: from gabe.freedesktop.org (localhost [127.0.0.1]) by gabe.freedesktop.org (Postfix) with ESMTP id 5F0556E569; Fri, 29 Mar 2019 22:12:20 +0000 (UTC) X-Original-To: intel-gfx@lists.freedesktop.org Delivered-To: intel-gfx@lists.freedesktop.org Received: from mga06.intel.com (mga06.intel.com [134.134.136.31]) by gabe.freedesktop.org (Postfix) with ESMTPS id ED2A36E569 for ; Fri, 29 Mar 2019 22:11:48 +0000 (UTC) X-Amp-Result: SKIPPED(no attachment in message) X-Amp-File-Uploaded: False Received: from fmsmga002.fm.intel.com ([10.253.24.26]) by orsmga104.jf.intel.com with ESMTP/TLS/DHE-RSA-AES256-GCM-SHA384; 29 Mar 2019 15:11:47 -0700 X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="5.60,286,1549958400"; d="scan'208";a="156522334" Received: from irvmail001.ir.intel.com ([163.33.26.43]) by fmsmga002.fm.intel.com with ESMTP; 29 Mar 2019 15:11:46 -0700 Received: from mwajdecz-MOBL1.ger.corp.intel.com (mwajdecz-mobl1.ger.corp.intel.com [10.249.137.139]) by irvmail001.ir.intel.com (8.14.3/8.13.6/MailSET/Hub) with ESMTP id x2TMBN0m017079; Fri, 29 Mar 2019 22:11:44 GMT From: Michal Wajdeczko To: intel-gfx@lists.freedesktop.org Date: Fri, 29 Mar 2019 22:11:10 +0000 Message-Id: <20190329221118.17308-23-michal.wajdeczko@intel.com> X-Mailer: git-send-email 2.10.1.windows.1 In-Reply-To: <20190329221118.17308-1-michal.wajdeczko@intel.com> References: <20190329221118.17308-1-michal.wajdeczko@intel.com> MIME-Version: 1.0 Subject: [Intel-gfx] [PATCH 22/30] drm/i915/guc: New GuC workqueue item submission mechanism X-BeenThere: intel-gfx@lists.freedesktop.org X-Mailman-Version: 2.1.23 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 Work queue items definitions were updated. To simplify the scheduling logic in the GuC firmware, only out-of-order mode of scheduling is now supported. Credits-to: Michel Thierry Signed-off-by: Michal Wajdeczko Cc: Daniele Ceraolo Spurio Cc: Joonas Lahtinen Cc: Tvrtko Ursulin Cc: MichaƂ Winiarski Cc: Tomasz Lis --- drivers/gpu/drm/i915/intel_guc_fwif.h | 18 +++++++++---- drivers/gpu/drm/i915/intel_guc_submission.c | 29 ++++++++++++++------- drivers/gpu/drm/i915/selftests/intel_guc.c | 2 +- 3 files changed, 34 insertions(+), 15 deletions(-) diff --git a/drivers/gpu/drm/i915/intel_guc_fwif.h b/drivers/gpu/drm/i915/intel_guc_fwif.h index a900680ff5a4..004d3d882f6f 100644 --- a/drivers/gpu/drm/i915/intel_guc_fwif.h +++ b/drivers/gpu/drm/i915/intel_guc_fwif.h @@ -49,22 +49,30 @@ #define GUC_DB_SIZE (PAGE_SIZE) #define GUC_WQ_SIZE (PAGE_SIZE * 2) -/* Work queue item header definitions */ +/* Work queue status */ #define WQ_STATUS_ACTIVE 1 #define WQ_STATUS_SUSPENDED 2 #define WQ_STATUS_CMD_ERROR 3 #define WQ_STATUS_ENGINE_ID_NOT_USED 4 #define WQ_STATUS_SUSPENDED_FROM_RESET 5 +#define WQ_STATUS_INVALID 6 + +/* Work queue item header definitions */ #define WQ_TYPE_SHIFT 0 #define WQ_TYPE_BATCH_BUF (0x1 << WQ_TYPE_SHIFT) #define WQ_TYPE_PSEUDO (0x2 << WQ_TYPE_SHIFT) -#define WQ_TYPE_INORDER (0x3 << WQ_TYPE_SHIFT) +#define WQ_TYPE_KMD (0x3 << WQ_TYPE_SHIFT) #define WQ_TYPE_NOOP (0x4 << WQ_TYPE_SHIFT) -#define WQ_TARGET_SHIFT 10 +#define WQ_TYPE_RESUME (0x5 << WQ_TYPE_SHIFT) +#define WQ_TYPE_INVALID (0x6 << WQ_TYPE_SHIFT) +#define WQ_TARGET_SHIFT 8 #define WQ_LEN_SHIFT 16 -#define WQ_NO_WCFLUSH_WAIT (1 << 27) -#define WQ_PRESENT_WORKLOAD (1 << 28) +#define WQ_LEN_MASK (0x7FF << WQ_LEN_SHIFT) +/* Work queue item submit element info definitions */ +#define WQ_SW_CTX_INDEX_SHIFT 0 +#define WQ_SW_COUNTER_SHIFT 11 +#define WQ_RING_TAIL_INDEX_SHIFT 18 #define WQ_RING_TAIL_SHIFT 20 #define WQ_RING_TAIL_MAX 0x7FF /* 2^11 QWords */ #define WQ_RING_TAIL_MASK (WQ_RING_TAIL_MAX << WQ_RING_TAIL_SHIFT) diff --git a/drivers/gpu/drm/i915/intel_guc_submission.c b/drivers/gpu/drm/i915/intel_guc_submission.c index 3104f091abc5..1a27352b73a9 100644 --- a/drivers/gpu/drm/i915/intel_guc_submission.c +++ b/drivers/gpu/drm/i915/intel_guc_submission.c @@ -82,9 +82,14 @@ * Work Items: * There are several types of work items that the host may place into a * workqueue, each with its own requirements and limitations. Currently only - * WQ_TYPE_INORDER is needed to support legacy submission via GuC, which - * represents in-order queue. The kernel driver packs ring tail pointer and an - * ELSP context descriptor dword into Work Item. + * out-of-order WQ_TYPE_KMD is supported by the firmware. + * Our in-orderness is guaranteed by the execlists emulation with two "fake" + * ports that the scheduler uses when submitting to the GuC backend. If we are + * submitting requests for context A in the first port and we place a request + * for context B in the second port, we won't submit more requests for A until + * all the pending ones complete. We have to take this into account if we try + * to change the current execlist emulation model (e.g.: increasing the number + * of fake ports could cause requests to execute in wrong global seqno order). * See guc_add_request() * */ @@ -424,6 +429,7 @@ static void guc_proxy_stage_desc_fini(struct intel_guc_client *client) /* Construct a Work Item and append it to the GuC's Work Queue */ static void guc_wq_item_append(struct intel_guc_client *client, + struct intel_context *ce, u32 target_engine, u32 context_desc, u32 ring_tail, u32 fence_id) { @@ -461,12 +467,15 @@ static void guc_wq_item_append(struct intel_guc_client *client, wqi->header = WQ_TYPE_NOOP | (wqi_len << WQ_LEN_SHIFT); } else { /* Now fill in the 4-word work queue item */ - wqi->header = WQ_TYPE_INORDER | - (wqi_len << WQ_LEN_SHIFT) | + wqi->header = WQ_TYPE_KMD | (target_engine << WQ_TARGET_SHIFT) | - WQ_NO_WCFLUSH_WAIT; + (wqi_len << WQ_LEN_SHIFT); wqi->context_desc = context_desc; - wqi->submit_element_info = ring_tail << WQ_RING_TAIL_SHIFT; + + wqi->submit_element_info = + (ce->sw_context_id << WQ_SW_CTX_INDEX_SHIFT) | + (ce->sw_counter << WQ_SW_COUNTER_SHIFT | + (ring_tail << WQ_RING_TAIL_INDEX_SHIFT)); GEM_BUG_ON(ring_tail > WQ_RING_TAIL_MAX); wqi->fence_id = fence_id; } @@ -500,12 +509,13 @@ static void guc_add_request(struct intel_guc *guc, struct i915_request *rq) { struct intel_guc_client *client = guc->execbuf_client; struct intel_engine_cs *engine = rq->engine; + struct intel_context *ce = rq->hw_context; u32 ctx_desc = lower_32_bits(rq->hw_context->lrc_desc); u32 ring_tail = intel_ring_set_tail(rq->ring, rq->tail) / sizeof(u64); spin_lock(&client->wq_lock); - guc_wq_item_append(client, engine->guc_id, ctx_desc, + guc_wq_item_append(client, ce, engine->guc_id, ctx_desc, ring_tail, rq->fence.seqno); guc_ring_doorbell(client); @@ -569,7 +579,8 @@ static void inject_preempt_context(struct work_struct *work) } spin_lock_irq(&client->wq_lock); - guc_wq_item_append(client, engine->guc_id, lower_32_bits(ce->lrc_desc), + guc_wq_item_append(client, ce, engine->guc_id, + lower_32_bits(ce->lrc_desc), GUC_PREEMPT_BREADCRUMB_BYTES / sizeof(u64), 0); spin_unlock_irq(&client->wq_lock); diff --git a/drivers/gpu/drm/i915/selftests/intel_guc.c b/drivers/gpu/drm/i915/selftests/intel_guc.c index 0102ee90355c..4f9adb2dccda 100644 --- a/drivers/gpu/drm/i915/selftests/intel_guc.c +++ b/drivers/gpu/drm/i915/selftests/intel_guc.c @@ -74,7 +74,7 @@ static int ring_doorbell_nop(struct intel_guc_client *client) spin_lock_irq(&client->wq_lock); - guc_wq_item_append(client, 0, 0, 0, 0); + guc_wq_item_append(client, NULL, 0, 0, 0, 0); guc_ring_doorbell(client); spin_unlock_irq(&client->wq_lock);