From patchwork Fri Jan 5 08:46:55 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: 10146087 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 C09A360244 for ; Fri, 5 Jan 2018 08:43:40 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id B8A3B288A1 for ; Fri, 5 Jan 2018 08:43:40 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id ADB6D288A7; Fri, 5 Jan 2018 08:43:40 +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 4C1D8288A1 for ; Fri, 5 Jan 2018 08:43:40 +0000 (UTC) Received: from gabe.freedesktop.org (localhost [127.0.0.1]) by gabe.freedesktop.org (Postfix) with ESMTP id 6E1B16E2E9; Fri, 5 Jan 2018 08:43:39 +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 B3D9D6E2E8 for ; Fri, 5 Jan 2018 08:43:37 +0000 (UTC) X-Amp-Result: SKIPPED(no attachment in message) X-Amp-File-Uploaded: False Received: from fmsmga005.fm.intel.com ([10.253.24.32]) by orsmga103.jf.intel.com with ESMTP/TLS/DHE-RSA-AES256-GCM-SHA384; 05 Jan 2018 00:43:37 -0800 X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="5.46,317,1511856000"; d="scan'208";a="192452312" Received: from sakamble-desktop.iind.intel.com ([10.223.26.10]) by fmsmga005.fm.intel.com with ESMTP; 05 Jan 2018 00:43:33 -0800 From: Sagar Arun Kamble To: intel-gfx@lists.freedesktop.org Date: Fri, 5 Jan 2018 14:16:55 +0530 Message-Id: <1515142021-24232-4-git-send-email-sagar.a.kamble@intel.com> X-Mailer: git-send-email 1.9.1 In-Reply-To: <1515142021-24232-1-git-send-email-sagar.a.kamble@intel.com> References: <1515142021-24232-1-git-send-email-sagar.a.kamble@intel.com> Subject: [Intel-gfx] [PATCH v4 3/9] drm/i915/guc: Separate creation/release of runtime logging data from base logging data 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: , MIME-Version: 1.0 Errors-To: intel-gfx-bounces@lists.freedesktop.org Sender: "Intel-gfx" X-Virus-Scanned: ClamAV using ClamSMTP GuC log runtime/relay channel data will get released during i915 unregister, and only GuC log vma needs to be released during fini. To achieve this, prepare separate helpers to create/destroy base and runtime logging. This separation is also needed to couple runtime log data and interrupts handling together. In future we might not want to consider runtime data creation failure as catastrophic to abort GuC load. Then we can ignore the return error codes from intel_guc_log_runtime_create(). v2: Rebase. v3: Refined usage of intel_guc_log_destroy and created new function intel_guc_log_runtime_destroy. (Tvrtko) Added intel_guc_log_runtime_create to separate the creation part as well. v4: Rebase. Signed-off-by: Sagar Arun Kamble Cc: Michal Wajdeczko Cc: Daniele Ceraolo Spurio Cc: Tvrtko Ursulin Cc: Chris Wilson Cc: Joonas Lahtinen --- drivers/gpu/drm/i915/intel_guc.c | 8 +++++++- drivers/gpu/drm/i915/intel_guc_log.c | 22 ++++++++-------------- drivers/gpu/drm/i915/intel_guc_log.h | 2 ++ 3 files changed, 17 insertions(+), 15 deletions(-) diff --git a/drivers/gpu/drm/i915/intel_guc.c b/drivers/gpu/drm/i915/intel_guc.c index 7278bde..9dac3ee 100644 --- a/drivers/gpu/drm/i915/intel_guc.c +++ b/drivers/gpu/drm/i915/intel_guc.c @@ -168,9 +168,13 @@ int intel_guc_init(struct intel_guc *guc) if (ret) goto err_shared; - ret = intel_guc_ads_create(guc); + ret = intel_guc_log_runtime_create(guc); if (ret) goto err_log; + + ret = intel_guc_ads_create(guc); + if (ret) + goto err_log_runtime; GEM_BUG_ON(!guc->ads_vma); /* We need to notify the guc whenever we change the GGTT */ @@ -178,6 +182,8 @@ int intel_guc_init(struct intel_guc *guc) return 0; +err_log_runtime: + intel_guc_log_runtime_destroy(guc); err_log: intel_guc_log_destroy(guc); err_shared: diff --git a/drivers/gpu/drm/i915/intel_guc_log.c b/drivers/gpu/drm/i915/intel_guc_log.c index 84ae6f8..d866645 100644 --- a/drivers/gpu/drm/i915/intel_guc_log.c +++ b/drivers/gpu/drm/i915/intel_guc_log.c @@ -356,7 +356,7 @@ static bool guc_log_has_runtime(struct intel_guc *guc) return guc->log.runtime.buf_addr != NULL; } -static int guc_log_runtime_create(struct intel_guc *guc) +int intel_guc_log_runtime_create(struct intel_guc *guc) { struct drm_i915_private *dev_priv = guc_to_i915(guc); void *vaddr; @@ -364,6 +364,9 @@ static int guc_log_runtime_create(struct intel_guc *guc) size_t n_subbufs, subbuf_size; int ret; + if (i915_modparams.guc_log_level < 0) + return 0; + lockdep_assert_held(&dev_priv->drm.struct_mutex); GEM_BUG_ON(guc_log_has_runtime(guc)); @@ -419,7 +422,7 @@ static int guc_log_runtime_create(struct intel_guc *guc) return ret; } -static void guc_log_runtime_destroy(struct intel_guc *guc) +void intel_guc_log_runtime_destroy(struct intel_guc *guc) { /* * It's possible that the runtime stuff was never allocated because @@ -445,7 +448,7 @@ static int guc_log_late_setup(struct intel_guc *guc) * handle log buffer flush interrupts would not have been done yet, * so do that now. */ - ret = guc_log_runtime_create(guc); + ret = intel_guc_log_runtime_create(guc); if (ret) goto err; } @@ -457,7 +460,7 @@ static int guc_log_late_setup(struct intel_guc *guc) return 0; err_runtime: - guc_log_runtime_destroy(guc); + intel_guc_log_runtime_destroy(guc); err: /* logging will remain off */ i915_modparams.guc_log_level = -1; @@ -535,12 +538,6 @@ int intel_guc_log_create(struct intel_guc *guc) guc->log.vma = vma; - if (i915_modparams.guc_log_level >= 0) { - ret = guc_log_runtime_create(guc); - if (ret < 0) - goto err_vma; - } - /* each allocated unit is a page */ flags = GUC_LOG_VALID | GUC_LOG_NOTIFY_ON_HALF_FULL | (GUC_LOG_DPC_PAGES << GUC_LOG_DPC_SHIFT) | @@ -552,8 +549,6 @@ int intel_guc_log_create(struct intel_guc *guc) return 0; -err_vma: - i915_vma_unpin_and_release(&guc->log.vma); err: /* logging will be off */ i915_modparams.guc_log_level = -1; @@ -562,7 +557,6 @@ int intel_guc_log_create(struct intel_guc *guc) void intel_guc_log_destroy(struct intel_guc *guc) { - guc_log_runtime_destroy(guc); i915_vma_unpin_and_release(&guc->log.vma); } @@ -638,6 +632,6 @@ void i915_guc_log_unregister(struct drm_i915_private *dev_priv) mutex_lock(&dev_priv->drm.struct_mutex); /* GuC logging is currently the only user of Guc2Host interrupts */ intel_guc_disable_interrupts(&dev_priv->guc); - guc_log_runtime_destroy(&dev_priv->guc); + intel_guc_log_runtime_destroy(&dev_priv->guc); mutex_unlock(&dev_priv->drm.struct_mutex); } diff --git a/drivers/gpu/drm/i915/intel_guc_log.h b/drivers/gpu/drm/i915/intel_guc_log.h index f512cf7..345447a 100644 --- a/drivers/gpu/drm/i915/intel_guc_log.h +++ b/drivers/gpu/drm/i915/intel_guc_log.h @@ -52,6 +52,8 @@ struct intel_guc_log { int intel_guc_log_create(struct intel_guc *guc); void intel_guc_log_destroy(struct intel_guc *guc); +int intel_guc_log_runtime_create(struct intel_guc *guc); +void intel_guc_log_runtime_destroy(struct intel_guc *guc); int i915_guc_log_control(struct drm_i915_private *dev_priv, 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);