From patchwork Wed Oct 11 08:54:12 2017 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: sagar.a.kamble@intel.com X-Patchwork-Id: 9999061 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 4BF4E602BF for ; Wed, 11 Oct 2017 08:51:47 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 3C64228964 for ; Wed, 11 Oct 2017 08:51:47 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 317BD28970; Wed, 11 Oct 2017 08:51:47 +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 C41A528964 for ; Wed, 11 Oct 2017 08:51:46 +0000 (UTC) Received: from gabe.freedesktop.org (localhost [127.0.0.1]) by gabe.freedesktop.org (Postfix) with ESMTP id 6B0F56E3A5; Wed, 11 Oct 2017 08:51:38 +0000 (UTC) X-Original-To: intel-gfx@lists.freedesktop.org Delivered-To: intel-gfx@lists.freedesktop.org Received: from mga14.intel.com (mga14.intel.com [192.55.52.115]) by gabe.freedesktop.org (Postfix) with ESMTPS id 04B5B6E5E3 for ; Wed, 11 Oct 2017 08:51:35 +0000 (UTC) Received: from fmsmga001.fm.intel.com ([10.253.24.23]) by fmsmga103.fm.intel.com with ESMTP/TLS/DHE-RSA-AES256-GCM-SHA384; 11 Oct 2017 01:51:35 -0700 X-ExtLoop1: 1 X-IronPort-AV: E=Sophos; i="5.43,360,1503385200"; d="scan'208"; a="1204581596" Received: from sakamble-desktop.iind.intel.com ([10.223.26.118]) by fmsmga001.fm.intel.com with ESMTP; 11 Oct 2017 01:51:31 -0700 From: Sagar Arun Kamble To: intel-gfx@lists.freedesktop.org Date: Wed, 11 Oct 2017 14:24:12 +0530 Message-Id: <1507712056-25030-18-git-send-email-sagar.a.kamble@intel.com> X-Mailer: git-send-email 1.9.1 In-Reply-To: <1507712056-25030-1-git-send-email-sagar.a.kamble@intel.com> References: <1507712056-25030-1-git-send-email-sagar.a.kamble@intel.com> MIME-Version: 1.0 Subject: [Intel-gfx] [PATCH v13 17/21] drm/i915: Split i915_gem_suspend into gem quiescing and HW suspend 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 GTT mappings are to be suspended post idling GPU and display suspend. Currently GPU was reset in i915_gem_suspend and then GTT mappings were suspended in i915_drm_suspend. Also part of i915_gem_suspend was about suspending HW operations. This separated the HW/GEM suspend across reset. To achieve the complete GEM/HW suspend prior to GPU reset we need to separate i915_gem_suspend functionality into gem quiescing and HW suspend. With this patch new function i915_gem_quiesce is created that will ensure GEM is idle. i915_gem_hw_suspend will ensure all GPU HW operations are suspended. These currently are RPS, GTT mappings suspension. With this patch drm suspend sequence is gem_quiesce followed by gem_hw_suspend. Unload sequence is gem_quiesce->gem_hw_suspend->gem_fini. v2. Split i915_gem_suspend to accommodate GTT mappings suspend as that is not to be done till display suspend. (Chris) v3: s/i915_gem_quiescent/i915_gem_quiesce and s/i915_gem_suspend/ i915_gem_hw_suspend. gem_hw_suspend has to be done prior to gem_fini as engine state/GuC software state would be needed to suspend HW. s/dev_priv/i915 in i915_gem_quiesce and i915_gem_hw_suspend. Doing GuC suspend before suspending GTT mappings as GuC needs to access the shared data. Limiting struct_mutex lock to only gem_sanitize. Signed-off-by: Sagar Arun Kamble Cc: Michal Wajdeczko Cc: MichaƂ Winiarski Cc: Oscar Mateo Cc: Chris Wilson Cc: Joonas Lahtinen --- drivers/gpu/drm/i915/i915_drv.c | 11 +++++++---- drivers/gpu/drm/i915/i915_drv.h | 3 ++- drivers/gpu/drm/i915/i915_gem.c | 29 ++++++++++++++++++++++------- 3 files changed, 31 insertions(+), 12 deletions(-) diff --git a/drivers/gpu/drm/i915/i915_drv.c b/drivers/gpu/drm/i915/i915_drv.c index 8ed3e57..198e774e 100644 --- a/drivers/gpu/drm/i915/i915_drv.c +++ b/drivers/gpu/drm/i915/i915_drv.c @@ -693,8 +693,9 @@ static int i915_load_modeset_init(struct drm_device *dev) return 0; cleanup_gem: - if (i915_gem_suspend(dev_priv)) + if (i915_gem_quiesce(dev_priv)) DRM_ERROR("failed to idle hardware; continuing to unload!\n"); + i915_gem_hw_suspend(dev_priv); i915_gem_fini(dev_priv); cleanup_uc: intel_uc_fini_fw(dev_priv); @@ -1395,9 +1396,11 @@ void i915_driver_unload(struct drm_device *dev) i915_driver_unregister(dev_priv); - if (i915_gem_suspend(dev_priv)) + if (i915_gem_quiesce(dev_priv)) DRM_ERROR("failed to idle hardware; continuing to unload!\n"); + i915_gem_hw_suspend(dev_priv); + intel_display_power_get(dev_priv, POWER_DOMAIN_INIT); drm_atomic_helper_shutdown(dev); @@ -1540,7 +1543,7 @@ static int i915_drm_suspend(struct drm_device *dev) pci_save_state(pdev); - error = i915_gem_suspend(dev_priv); + error = i915_gem_quiesce(dev_priv); if (error) { dev_err(&pdev->dev, "GEM idle failed, resume might fail\n"); @@ -1558,7 +1561,7 @@ static int i915_drm_suspend(struct drm_device *dev) intel_suspend_hw(dev_priv); - i915_gem_suspend_gtt_mappings(dev_priv); + i915_gem_hw_suspend(dev_priv); i915_save_state(dev_priv); diff --git a/drivers/gpu/drm/i915/i915_drv.h b/drivers/gpu/drm/i915/i915_drv.h index bc21da2..f51abc6 100644 --- a/drivers/gpu/drm/i915/i915_drv.h +++ b/drivers/gpu/drm/i915/i915_drv.h @@ -3716,7 +3716,8 @@ void i915_gem_reset_engine(struct intel_engine_cs *engine, void i915_gem_cleanup_engines(struct drm_i915_private *dev_priv); int i915_gem_wait_for_idle(struct drm_i915_private *dev_priv, unsigned int flags); -int __must_check i915_gem_suspend(struct drm_i915_private *dev_priv); +int __must_check i915_gem_quiesce(struct drm_i915_private *dev_priv); +void i915_gem_hw_suspend(struct drm_i915_private *dev_priv); void i915_gem_resume(struct drm_i915_private *dev_priv); int i915_gem_fault(struct vm_fault *vmf); int i915_gem_object_wait(struct drm_i915_gem_object *obj, diff --git a/drivers/gpu/drm/i915/i915_gem.c b/drivers/gpu/drm/i915/i915_gem.c index bcf3ca5..f1a785a 100644 --- a/drivers/gpu/drm/i915/i915_gem.c +++ b/drivers/gpu/drm/i915/i915_gem.c @@ -4650,13 +4650,12 @@ void i915_gem_sanitize(struct drm_i915_private *i915) } } -int i915_gem_suspend(struct drm_i915_private *dev_priv) +int i915_gem_quiesce(struct drm_i915_private *dev_priv) { struct drm_device *dev = &dev_priv->drm; int ret; intel_runtime_pm_get(dev_priv); - intel_suspend_gt_powersave(dev_priv); mutex_lock(&dev->struct_mutex); @@ -4703,6 +4702,26 @@ int i915_gem_suspend(struct drm_i915_private *dev_priv) goto err_unlock; mutex_unlock(&dev->struct_mutex); + intel_runtime_pm_put(dev_priv); + return 0; + +err_unlock: + mutex_unlock(&dev->struct_mutex); + intel_runtime_pm_put(dev_priv); + return ret; +} + +void i915_gem_hw_suspend(struct drm_i915_private *dev_priv) +{ + struct drm_device *dev = &dev_priv->drm; + + intel_runtime_pm_get(dev_priv); + intel_suspend_gt_powersave(dev_priv); + + mutex_lock(&dev->struct_mutex); + + i915_gem_suspend_gtt_mappings(dev_priv); + /* * Neither the BIOS, ourselves or any other kernel * expects the system to be in execlists mode on startup, @@ -4724,13 +4743,9 @@ int i915_gem_suspend(struct drm_i915_private *dev_priv) */ i915_gem_sanitize(dev_priv); - intel_runtime_pm_put(dev_priv); - return 0; - -err_unlock: mutex_unlock(&dev->struct_mutex); + intel_runtime_pm_put(dev_priv); - return ret; } void i915_gem_resume(struct drm_i915_private *dev_priv)