From patchwork Thu Oct 5 09:13:43 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: 9986649 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 5007E6029B for ; Thu, 5 Oct 2017 09:18:04 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 529DC28AC1 for ; Thu, 5 Oct 2017 09:18:04 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 4718C28ADD; Thu, 5 Oct 2017 09:18:04 +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 A588328AE2 for ; Thu, 5 Oct 2017 09:18:03 +0000 (UTC) Received: from gabe.freedesktop.org (localhost [127.0.0.1]) by gabe.freedesktop.org (Postfix) with ESMTP id E35C86E25A; Thu, 5 Oct 2017 09:18:02 +0000 (UTC) X-Original-To: intel-gfx@lists.freedesktop.org Delivered-To: intel-gfx@lists.freedesktop.org Received: from mga02.intel.com (mga02.intel.com [134.134.136.20]) by gabe.freedesktop.org (Postfix) with ESMTPS id 96A0789F85 for ; Thu, 5 Oct 2017 09:18:01 +0000 (UTC) Received: from orsmga004.jf.intel.com ([10.7.209.38]) by orsmga101.jf.intel.com with ESMTP/TLS/DHE-RSA-AES256-GCM-SHA384; 05 Oct 2017 02:18:00 -0700 X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="5.42,481,1500966000"; d="scan'208";a="135455380" Received: from irsmsx102.ger.corp.intel.com ([163.33.3.155]) by orsmga004.jf.intel.com with ESMTP; 05 Oct 2017 02:17:59 -0700 Received: from localhost (172.28.171.152) by IRSMSX102.ger.corp.intel.com (163.33.3.155) with Microsoft SMTP Server (TLS) id 14.3.319.2; Thu, 5 Oct 2017 10:17:59 +0100 From: =?UTF-8?q?Micha=C5=82=20Winiarski?= To: Date: Thu, 5 Oct 2017 11:13:43 +0200 Message-ID: <20171005091349.9315-4-michal.winiarski@intel.com> X-Mailer: git-send-email 2.13.5 In-Reply-To: <20171005091349.9315-1-michal.winiarski@intel.com> References: <20171005091349.9315-1-michal.winiarski@intel.com> MIME-Version: 1.0 X-Originating-IP: [172.28.171.152] Cc: Dave Gordon Subject: [Intel-gfx] [PATCH 04/10] drm/i915/guc: Add a second client, to be used for preemption 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 From: Dave Gordon This second client is created with priority KMD_HIGH, and marked as preemptive. This will allow us to request preemption using GuC actions. Cc: Chris Wilson Cc: Jeff Mcgee Cc: Michal Wajdeczko Cc: Oscar Mateo Signed-off-by: Dave Gordon Signed-off-by: MichaƂ Winiarski Reviewed-by: Chris Wilson --- drivers/gpu/drm/i915/i915_debugfs.c | 4 ++++ drivers/gpu/drm/i915/i915_guc_submission.c | 32 ++++++++++++++++++++++++++---- drivers/gpu/drm/i915/intel_uc.h | 1 + 3 files changed, 33 insertions(+), 4 deletions(-) diff --git a/drivers/gpu/drm/i915/i915_debugfs.c b/drivers/gpu/drm/i915/i915_debugfs.c index b4a6ac60e7c6..1a963c13cab8 100644 --- a/drivers/gpu/drm/i915/i915_debugfs.c +++ b/drivers/gpu/drm/i915/i915_debugfs.c @@ -2488,6 +2488,10 @@ static int i915_guc_info(struct seq_file *m, void *data) seq_printf(m, "\nGuC execbuf client @ %p:\n", guc->execbuf_client); i915_guc_client_info(m, dev_priv, guc->execbuf_client); + if (guc->preempt_client) { + seq_printf(m, "\nGuC preempt client\n"); + i915_guc_client_info(m, dev_priv, guc->preempt_client); + } i915_guc_log_info(m, dev_priv); diff --git a/drivers/gpu/drm/i915/i915_guc_submission.c b/drivers/gpu/drm/i915/i915_guc_submission.c index 374501a67274..e8052e86426d 100644 --- a/drivers/gpu/drm/i915/i915_guc_submission.c +++ b/drivers/gpu/drm/i915/i915_guc_submission.c @@ -331,6 +331,8 @@ static void guc_stage_desc_init(struct intel_guc *guc, memset(desc, 0, sizeof(*desc)); desc->attribute = GUC_STAGE_DESC_ATTR_ACTIVE | GUC_STAGE_DESC_ATTR_KERNEL; + if (client->priority <= GUC_CLIENT_PRIORITY_HIGH) + desc->attribute |= GUC_STAGE_DESC_ATTR_PREEMPT; desc->stage_id = client->stage_id; desc->priority = client->priority; desc->db_id = client->doorbell_id; @@ -1154,7 +1156,7 @@ int i915_guc_submission_enable(struct drm_i915_private *dev_priv) sizeof(struct guc_wq_item) * I915_NUM_ENGINES > GUC_WQ_SIZE); - if (!client) { + if (!guc->execbuf_client) { client = guc_client_alloc(dev_priv, INTEL_INFO(dev_priv)->ring_mask, GUC_CLIENT_PRIORITY_KMD_NORMAL, @@ -1167,15 +1169,29 @@ int i915_guc_submission_enable(struct drm_i915_private *dev_priv) guc->execbuf_client = client; } + if (!guc->preempt_client) { + client = guc_client_alloc(dev_priv, + INTEL_INFO(dev_priv)->ring_mask, + GUC_CLIENT_PRIORITY_KMD_HIGH, + dev_priv->preempt_context); + if (IS_ERR(client)) { + DRM_ERROR("Failed to create GuC client for preemption!\n"); + err = PTR_ERR(client); + goto err_free_clients; + } + + guc->preempt_client = client; + } + err = intel_guc_sample_forcewake(guc); if (err) - goto err_execbuf_client; + goto err_free_clients; guc_reset_wq(client); err = guc_init_doorbell_hw(guc); if (err) - goto err_execbuf_client; + goto err_free_clients; /* Take over from manual control of ELSP (execlists) */ guc_interrupts_capture(dev_priv); @@ -1187,7 +1203,11 @@ int i915_guc_submission_enable(struct drm_i915_private *dev_priv) return 0; -err_execbuf_client: +err_free_clients: + if (guc->preempt_client) { + guc_client_free(guc->preempt_client); + guc->preempt_client = NULL; + } guc_client_free(guc->execbuf_client); guc->execbuf_client = NULL; return err; @@ -1202,6 +1222,10 @@ void i915_guc_submission_disable(struct drm_i915_private *dev_priv) /* Revert back to manual ELSP submission */ intel_engines_reset_default_submission(dev_priv); + if (guc->preempt_client) { + guc_client_free(guc->preempt_client); + guc->preempt_client = NULL; + } guc_client_free(guc->execbuf_client); guc->execbuf_client = NULL; } diff --git a/drivers/gpu/drm/i915/intel_uc.h b/drivers/gpu/drm/i915/intel_uc.h index 10e8f0ed02e4..c6c6f8513bbf 100644 --- a/drivers/gpu/drm/i915/intel_uc.h +++ b/drivers/gpu/drm/i915/intel_uc.h @@ -107,6 +107,7 @@ struct intel_guc { struct ida stage_ids; struct i915_guc_client *execbuf_client; + struct i915_guc_client *preempt_client; DECLARE_BITMAP(doorbell_bitmap, GUC_NUM_DOORBELLS); uint32_t db_cacheline; /* Cyclic counter mod pagesize */