From patchwork Thu Jun 9 01:46:04 2016 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Dhinakaran Pandiyan X-Patchwork-Id: 9166111 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 4FE4760467 for ; Thu, 9 Jun 2016 01:34:17 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 41D7026E1A for ; Thu, 9 Jun 2016 01:34:17 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 363132824F; Thu, 9 Jun 2016 01:34:17 +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]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 9949E26E1A for ; Thu, 9 Jun 2016 01:34:16 +0000 (UTC) Received: from gabe.freedesktop.org (localhost [127.0.0.1]) by gabe.freedesktop.org (Postfix) with ESMTP id C7BD06EA21; Thu, 9 Jun 2016 01:34:15 +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 ESMTP id 3EE996EA21 for ; Thu, 9 Jun 2016 01:34:14 +0000 (UTC) Received: from fmsmga003.fm.intel.com ([10.253.24.29]) by orsmga101.jf.intel.com with ESMTP; 08 Jun 2016 18:34:14 -0700 X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="5.26,442,1459839600"; d="scan'208";a="716193921" Received: from skylake.jf.intel.com ([10.54.75.142]) by FMSMGA003.fm.intel.com with ESMTP; 08 Jun 2016 18:34:13 -0700 From: Dhinakaran Pandiyan To: intel-gfx@lists.freedesktop.org Date: Wed, 8 Jun 2016 18:46:04 -0700 Message-Id: <1465436764-29950-4-git-send-email-dhinakaran.pandiyan@intel.com> X-Mailer: git-send-email 2.5.0 In-Reply-To: <1465436764-29950-1-git-send-email-dhinakaran.pandiyan@intel.com> References: <1465436764-29950-1-git-send-email-dhinakaran.pandiyan@intel.com> Cc: Rodrigo Vivi Subject: [Intel-gfx] [PATCH 3/3] drm/i915/psr: Do not activate PSR when vblank interrupts are enabled 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 PSR in CHV, unlike HSW, can get activated even if vblanks interrupts are enabled. But, the pipe is not expected to generate timings signals when PSR is active. Specifically, we do not get vblank interrupts in CHV if PSR becomes active. This has led to drm_wait_vblank timing out. Let's disable PSR using the vblank prepare hook that gets called before enabling vblank interrupts and keep it disabled until the interrupts are not needed. Signed-off-by: Dhinakaran Pandiyan Reviewed-by: Rodrigo Vivi --- drivers/gpu/drm/i915/i915_drv.h | 1 + drivers/gpu/drm/i915/i915_irq.c | 12 ++++++++ drivers/gpu/drm/i915/intel_drv.h | 2 ++ drivers/gpu/drm/i915/intel_psr.c | 61 +++++++++++++++++++++++++++++++++++++++- 4 files changed, 75 insertions(+), 1 deletion(-) diff --git a/drivers/gpu/drm/i915/i915_drv.h b/drivers/gpu/drm/i915/i915_drv.h index e4c8e34..03f311e 100644 --- a/drivers/gpu/drm/i915/i915_drv.h +++ b/drivers/gpu/drm/i915/i915_drv.h @@ -994,6 +994,7 @@ struct i915_psr { bool psr2_support; bool aux_frame_sync; bool link_standby; + bool vlv_src_timing; }; enum intel_pch { diff --git a/drivers/gpu/drm/i915/i915_irq.c b/drivers/gpu/drm/i915/i915_irq.c index caaf1e2..77f3d76 100644 --- a/drivers/gpu/drm/i915/i915_irq.c +++ b/drivers/gpu/drm/i915/i915_irq.c @@ -2790,6 +2790,16 @@ static int gen8_enable_vblank(struct drm_device *dev, unsigned int pipe) return 0; } +static void valleyview_prepare_vblank(struct drm_device *dev, unsigned int pipe) +{ + vlv_psr_src_timing_get(dev); +} + +static void valleyview_unprepare_vblank(struct drm_device *dev, unsigned int pipe){ + + vlv_psr_src_timing_put(dev); +} + /* Called from drm generic code, passed 'crtc' which * we use as a pipe index */ @@ -4610,6 +4620,8 @@ void intel_irq_init(struct drm_i915_private *dev_priv) dev->driver->irq_uninstall = cherryview_irq_uninstall; dev->driver->enable_vblank = valleyview_enable_vblank; dev->driver->disable_vblank = valleyview_disable_vblank; + dev->driver->prepare_vblank = valleyview_prepare_vblank; + dev->driver->unprepare_vblank = valleyview_unprepare_vblank; dev_priv->display.hpd_irq_setup = i915_hpd_irq_setup; } else if (IS_VALLEYVIEW(dev_priv)) { dev->driver->irq_handler = valleyview_irq_handler; diff --git a/drivers/gpu/drm/i915/intel_drv.h b/drivers/gpu/drm/i915/intel_drv.h index 9b5f663..e2078fd 100644 --- a/drivers/gpu/drm/i915/intel_drv.h +++ b/drivers/gpu/drm/i915/intel_drv.h @@ -1511,6 +1511,8 @@ void intel_psr_flush(struct drm_device *dev, void intel_psr_init(struct drm_device *dev); void intel_psr_single_frame_update(struct drm_device *dev, unsigned frontbuffer_bits); +void vlv_psr_src_timing_get(struct drm_device *dev); +void vlv_psr_src_timing_put(struct drm_device *dev); /* intel_runtime_pm.c */ int intel_power_domains_init(struct drm_i915_private *); diff --git a/drivers/gpu/drm/i915/intel_psr.c b/drivers/gpu/drm/i915/intel_psr.c index 29a09bf..c95e680 100644 --- a/drivers/gpu/drm/i915/intel_psr.c +++ b/drivers/gpu/drm/i915/intel_psr.c @@ -462,6 +462,7 @@ void intel_psr_enable(struct intel_dp *intel_dp) /* Enable PSR on the panel */ vlv_psr_enable_sink(intel_dp); + dev_priv->psr.vlv_src_timing = false; /* On HSW+ enable_source also means go to PSR entry/active * state as soon as idle_frame achieved and here would be @@ -608,8 +609,10 @@ static void intel_psr_work(struct work_struct *work) * The delayed work can race with an invalidate hence we need to * recheck. Since psr_flush first clears this and then reschedules we * won't ever miss a flush when bailing out here. + * Also, do not enable PSR if source is required to generate timing + * signals like vblanks. */ - if (dev_priv->psr.busy_frontbuffer_bits) + if (dev_priv->psr.busy_frontbuffer_bits || dev_priv->psr.vlv_src_timing) goto unlock; intel_psr_activate(intel_dp); @@ -708,6 +711,62 @@ void intel_psr_single_frame_update(struct drm_device *dev, } /** + * vlv_psr_src_timing_get - src timing generation requested + * + * CHV does not have HW tracking to trigger PSR exit when VBI are enabled nor + * does enabling vblank interrupts prevent PSR entry. This function is called + * before enabling VBI to exit PSR and prevent PSR re-entry until vblanks are + * disabled again. + */ +void vlv_psr_src_timing_get(struct drm_device *dev) +{ + struct drm_i915_private *dev_priv = dev->dev_private; + + mutex_lock(&dev_priv->psr.lock); + if (!dev_priv->psr.enabled) { + mutex_unlock(&dev_priv->psr.lock); + return; + } + + //Handle racing with intel_psr_work with this flag + dev_priv->psr.vlv_src_timing = true; + + if(dev_priv->psr.active) + intel_psr_exit(dev); + + mutex_unlock(&dev_priv->psr.lock); + +} + + +/** + * vlv_psr_src_timing_put - src timing generation not required + * + * CHV does not have HW tracking to trigger PSR exit when VBI are enabled nor + * does enabling vblank interrupts prevent PSR entry. This function is called + * when VBI are not required and PSR can be activated. + */ +void vlv_psr_src_timing_put(struct drm_device *dev) +{ + struct drm_i915_private *dev_priv = dev->dev_private; + + mutex_lock(&dev_priv->psr.lock); + if (!dev_priv->psr.enabled) { + mutex_unlock(&dev_priv->psr.lock); + return; + } + + dev_priv->psr.vlv_src_timing = false; + + if (!dev_priv->psr.active) + if (!work_busy(&dev_priv->psr.work.work)) + schedule_delayed_work(&dev_priv->psr.work, + msecs_to_jiffies(100)); + + mutex_unlock(&dev_priv->psr.lock); +} + +/** * intel_psr_invalidate - Invalidade PSR * @dev: DRM device * @frontbuffer_bits: frontbuffer plane tracking bits