From patchwork Wed Jan 31 06:14:38 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: sagar.a.kamble@intel.com X-Patchwork-Id: 10193289 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 6161E60380 for ; Wed, 31 Jan 2018 06:11:11 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 51A4B2842B for ; Wed, 31 Jan 2018 06:11:11 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 45EDB28445; Wed, 31 Jan 2018 06:11: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 A5E1F2842B for ; Wed, 31 Jan 2018 06:11:10 +0000 (UTC) Received: from gabe.freedesktop.org (localhost [127.0.0.1]) by gabe.freedesktop.org (Postfix) with ESMTP id 093736E06D; Wed, 31 Jan 2018 06:11:10 +0000 (UTC) X-Original-To: intel-gfx@lists.freedesktop.org Delivered-To: intel-gfx@lists.freedesktop.org Received: from mga17.intel.com (mga17.intel.com [192.55.52.151]) by gabe.freedesktop.org (Postfix) with ESMTPS id E9D626E1FE for ; Wed, 31 Jan 2018 06:11:06 +0000 (UTC) X-Amp-Result: SKIPPED(no attachment in message) X-Amp-File-Uploaded: False Received: from fmsmga004.fm.intel.com ([10.253.24.48]) by fmsmga107.fm.intel.com with ESMTP/TLS/DHE-RSA-AES256-GCM-SHA384; 30 Jan 2018 22:11:06 -0800 X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="5.46,438,1511856000"; d="scan'208";a="26107475" Received: from sakamble-desktop.iind.intel.com ([10.223.26.10]) by fmsmga004.fm.intel.com with ESMTP; 30 Jan 2018 22:11:05 -0800 From: Sagar Arun Kamble To: intel-gfx@lists.freedesktop.org Date: Wed, 31 Jan 2018 11:44:38 +0530 Message-Id: <1517379279-12967-2-git-send-email-sagar.a.kamble@intel.com> X-Mailer: git-send-email 1.9.1 In-Reply-To: <1517379279-12967-1-git-send-email-sagar.a.kamble@intel.com> References: <1517379279-12967-1-git-send-email-sagar.a.kamble@intel.com> Subject: [Intel-gfx] [PATCH 2/3] drm/i915/guc: Handle interrupt based logging with lack of SSE4.1, relay and other setup 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: , MIME-Version: 1.0 Errors-To: intel-gfx-bounces@lists.freedesktop.org Sender: "Intel-gfx" X-Virus-Scanned: ClamAV using ClamSMTP On some systems like skl-gvtdvm, SSE4.1 movntdqa might not be available. movntdqa is needed for efficient capture of the logs from uncached GuC log buffer. GuC init was tied with this support and other setup needed for interrupt based GuC log capture like relay channel/file support and uncached mapping support. With this patch, GuC init is now unblocked from lack of this support. SSE and relay support init/fini is now being done by new functions intel_guc_log_init|fini_runtime() which makes relay functions static. We have introduced two states "supported" and "enabled". Supported is set when we have SSE4.1 support and have relay, GuC log, WC mapping available. Enabled is set when support is present and user has requested logging through i915_modparams.guc_log_level. While at this change, fixed unwind order in intel_uc_fini_misc. Signed-off-by: Sagar Arun Kamble Cc: Chris Wilson Cc: Michal Wajdeczko Cc: Michal Winiarski Cc: Tvrtko Ursulin --- drivers/gpu/drm/i915/intel_guc.c | 2 +- drivers/gpu/drm/i915/intel_guc_log.c | 97 ++++++++++++++++++++++++++---------- drivers/gpu/drm/i915/intel_guc_log.h | 16 +++++- drivers/gpu/drm/i915/intel_uc.c | 14 ++---- 4 files changed, 90 insertions(+), 39 deletions(-) diff --git a/drivers/gpu/drm/i915/intel_guc.c b/drivers/gpu/drm/i915/intel_guc.c index 21140cc..a9e5848 100644 --- a/drivers/gpu/drm/i915/intel_guc.c +++ b/drivers/gpu/drm/i915/intel_guc.c @@ -458,7 +458,7 @@ int intel_guc_resume(struct drm_i915_private *dev_priv) if (guc->fw.load_status != INTEL_UC_FIRMWARE_SUCCESS) return 0; - if (i915_modparams.guc_log_level) + if (guc->log.runtime.enabled) gen9_enable_guc_interrupts(dev_priv); data[0] = INTEL_GUC_ACTION_EXIT_S_STATE; diff --git a/drivers/gpu/drm/i915/intel_guc_log.c b/drivers/gpu/drm/i915/intel_guc_log.c index 3fbe93a..3454e0c 100644 --- a/drivers/gpu/drm/i915/intel_guc_log.c +++ b/drivers/gpu/drm/i915/intel_guc_log.c @@ -438,7 +438,7 @@ void intel_guc_log_init_early(struct intel_guc *guc) INIT_WORK(&guc->log.runtime.flush_work, capture_logs_work); } -int intel_guc_log_relay_create(struct intel_guc *guc) +static int guc_log_relay_create(struct intel_guc *guc) { struct drm_i915_private *dev_priv = guc_to_i915(guc); struct rchan *guc_log_relay_chan; @@ -486,12 +486,10 @@ int intel_guc_log_relay_create(struct intel_guc *guc) err: mutex_unlock(&guc->log.runtime.relay_lock); - /* logging will be off */ - i915_modparams.guc_log_level = 0; return ret; } -void intel_guc_log_relay_destroy(struct intel_guc *guc) +static void guc_log_relay_destroy(struct intel_guc *guc) { mutex_lock(&guc->log.runtime.relay_lock); @@ -509,18 +507,51 @@ void intel_guc_log_relay_destroy(struct intel_guc *guc) mutex_unlock(&guc->log.runtime.relay_lock); } +void intel_guc_log_init_runtime(struct intel_guc *guc) +{ + /* + * We require SSE 4.1 for fast reads from the GuC log buffer and + * it should likely be present on the chipsets supporting GuC based + * submisssions. Runtime logging is to be supported if SSE 4.1 support + * is present and relay & uncached buffer can be setup. + */ + guc->log.runtime.supported = i915_has_memcpy_from_wc(); + if (!guc->log.runtime.supported) { + DRM_DEBUG_DRIVER("SSE4.1 support not present. Runtime logging " + "disabled\n"); + return; + } + + if (guc_log_relay_create(guc)) { + DRM_ERROR("Couldn't allocate relay for GuC log. Runtime logging" + " disabled\n"); + guc->log.runtime.supported = false; + } +} + +void intel_guc_log_fini_runtime(struct intel_guc *guc) +{ + guc_log_relay_destroy(guc); + guc->log.runtime.supported = false; +} + static int guc_log_late_setup(struct intel_guc *guc) { struct drm_i915_private *dev_priv = guc_to_i915(guc); int ret; + if (!guc->log.runtime.supported) { + ret = -ENODEV; + goto err; + } + if (!guc_log_has_runtime(guc)) { /* * If log was disabled at boot time, then setup needed to handle * log buffer flush interrupts would not have been done yet, so * do that now. */ - ret = intel_guc_log_relay_create(guc); + ret = guc_log_relay_create(guc); if (ret) goto err; @@ -545,10 +576,18 @@ static int guc_log_late_setup(struct intel_guc *guc) guc_log_runtime_destroy(guc); mutex_unlock(&dev_priv->drm.struct_mutex); err_relay: - intel_guc_log_relay_destroy(guc); + guc_log_relay_destroy(guc); err: - /* logging will remain off */ - i915_modparams.guc_log_level = 0; + mutex_lock(&dev_priv->drm.struct_mutex); + intel_runtime_pm_get(dev_priv); + gen9_disable_guc_interrupts(dev_priv); + guc->log.runtime.enabled = false; + intel_runtime_pm_put(dev_priv); + mutex_unlock(&dev_priv->drm.struct_mutex); + + /* runtime logging will remain off */ + guc->log.runtime.supported = false; + return ret; } @@ -571,7 +610,7 @@ static void guc_flush_logs(struct intel_guc *guc) { struct drm_i915_private *dev_priv = guc_to_i915(guc); - if (!USES_GUC_SUBMISSION(dev_priv) || !i915_modparams.guc_log_level) + if (!USES_GUC_SUBMISSION(dev_priv) || !guc->log.runtime.enabled) return; /* First disable the interrupts, will be renabled afterwards */ @@ -605,16 +644,6 @@ int intel_guc_log_create(struct intel_guc *guc) GEM_BUG_ON(guc->log.vma); - /* - * We require SSE 4.1 for fast reads from the GuC log buffer and - * it should be present on the chipsets supporting GuC based - * submisssions. - */ - if (WARN_ON(!i915_has_memcpy_from_wc())) { - ret = -EINVAL; - goto err; - } - vma = intel_guc_allocate_vma(guc, GUC_LOG_SIZE); if (IS_ERR(vma)) { ret = PTR_ERR(vma); @@ -623,28 +652,41 @@ int intel_guc_log_create(struct intel_guc *guc) guc->log.vma = vma; - if (i915_modparams.guc_log_level) { + /* + * We are making runtime creation optional based on support as + * we can continue to use GuC and base log support. + */ + if (i915_modparams.guc_log_level && guc->log.runtime.supported) { ret = guc_log_runtime_create(guc); - if (ret < 0) - goto err_vma; + if (ret < 0) { + DRM_ERROR("GuC log runtime create failed. Runtime " + "logging disabled\n"); + guc->log.runtime.supported = false; + } } /* each allocated unit is a page */ - flags = GUC_LOG_VALID | GUC_LOG_NOTIFY_ON_HALF_FULL | + flags = GUC_LOG_VALID | (GUC_LOG_DPC_PAGES << GUC_LOG_DPC_SHIFT) | (GUC_LOG_ISR_PAGES << GUC_LOG_ISR_SHIFT) | (GUC_LOG_CRASH_PAGES << GUC_LOG_CRASH_SHIFT); + if (guc->log.runtime.supported) { + flags |= GUC_LOG_NOTIFY_ON_HALF_FULL; + guc->log.runtime.enabled = true; + } + offset = guc_ggtt_offset(vma) >> PAGE_SHIFT; /* in pages */ guc->log.flags = (offset << GUC_LOG_BUF_ADDR_SHIFT) | flags; return 0; -err_vma: - i915_vma_unpin_and_release(&guc->log.vma); err: /* logging will be off */ i915_modparams.guc_log_level = 0; + /* runtime logging will remain off */ + guc->log.runtime.supported = false; + return ret; } @@ -720,6 +762,8 @@ int intel_guc_log_control(struct intel_guc *guc, u64 control_val) i915_modparams.guc_log_level = 0; } + guc->log.runtime.enabled = enable_logging; + return ret; } @@ -742,10 +786,11 @@ void i915_guc_log_unregister(struct drm_i915_private *dev_priv) /* GuC logging is currently the only user of Guc2Host interrupts */ intel_runtime_pm_get(dev_priv); gen9_disable_guc_interrupts(dev_priv); + guc->log.runtime.enabled = false; intel_runtime_pm_put(dev_priv); guc_log_runtime_destroy(guc); mutex_unlock(&dev_priv->drm.struct_mutex); - intel_guc_log_relay_destroy(guc); + guc_log_relay_destroy(guc); } diff --git a/drivers/gpu/drm/i915/intel_guc_log.h b/drivers/gpu/drm/i915/intel_guc_log.h index dab0e94..c89c331 100644 --- a/drivers/gpu/drm/i915/intel_guc_log.h +++ b/drivers/gpu/drm/i915/intel_guc_log.h @@ -44,6 +44,18 @@ struct intel_guc_log { struct i915_vma *vma; /* The runtime stuff gets created only when GuC logging gets enabled */ struct { + /* + * Support based on movntdqa availability, GuC log, relay and + * runtime creation status. + */ + bool supported; + + /* + * Status based on "supported" and user request for logging + * through i915_modparams.guc_log_level. + */ + bool enabled; + void *buf_addr; struct workqueue_struct *flush_wq; struct work_struct flush_work; @@ -62,8 +74,8 @@ struct intel_guc_log { int intel_guc_log_create(struct intel_guc *guc); void intel_guc_log_destroy(struct intel_guc *guc); void intel_guc_log_init_early(struct intel_guc *guc); -int intel_guc_log_relay_create(struct intel_guc *guc); -void intel_guc_log_relay_destroy(struct intel_guc *guc); +void intel_guc_log_init_runtime(struct intel_guc *guc); +void intel_guc_log_fini_runtime(struct intel_guc *guc); int intel_guc_log_control(struct intel_guc *guc, u64 control_val); void i915_guc_log_register(struct drm_i915_private *dev_priv); void i915_guc_log_unregister(struct drm_i915_private *dev_priv); diff --git a/drivers/gpu/drm/i915/intel_uc.c b/drivers/gpu/drm/i915/intel_uc.c index e3f3509..1cc0d86 100644 --- a/drivers/gpu/drm/i915/intel_uc.c +++ b/drivers/gpu/drm/i915/intel_uc.c @@ -250,16 +250,10 @@ int intel_uc_init_misc(struct drm_i915_private *dev_priv) goto err; } - ret = intel_guc_log_relay_create(guc); - if (ret) { - DRM_ERROR("Couldn't allocate relay for GuC log\n"); - goto err_relay; - } + intel_guc_log_init_runtime(guc); return 0; -err_relay: - intel_guc_fini_wq(guc); err: return ret; } @@ -271,9 +265,9 @@ void intel_uc_fini_misc(struct drm_i915_private *dev_priv) if (!USES_GUC(dev_priv)) return; - intel_guc_fini_wq(guc); + intel_guc_log_fini_runtime(guc); - intel_guc_log_relay_destroy(guc); + intel_guc_fini_wq(guc); } int intel_uc_init(struct drm_i915_private *dev_priv) @@ -386,7 +380,7 @@ int intel_uc_init_hw(struct drm_i915_private *dev_priv) } if (USES_GUC_SUBMISSION(dev_priv)) { - if (i915_modparams.guc_log_level) + if (guc->log.runtime.enabled) gen9_enable_guc_interrupts(dev_priv); ret = intel_guc_submission_enable(guc);