[Intel-gfx] [PATCH 3/3] drm/i915: stop using struct_mutex for FBC

Daniel Vetter daniel at ffwll.ch
Wed Jun 17 00:51:11 PDT 2015


On Tue, Jan 02, 2001 at 04:58:59AM -0200, Paulo Zanoni wrote:
> From: Paulo Zanoni <paulo.r.zanoni at intel.com>
> 
> We now have dev_priv->fbc.lock and it should be enough to protect
> everything related to FBC.
> 
> Signed-off-by: Paulo Zanoni <paulo.r.zanoni at intel.com>

Managing stolen memory still needs dev->struct_mutex which means you can
only push down the mutex lock/unlock calls down into intel_fbc_update
right around the compressed memory reallocation. Well maybe do even more
and push it down into the fbc functions in i915_gem_stolen.c.
-Daniel

> ---
>  drivers/gpu/drm/i915/i915_debugfs.c  |  6 ------
>  drivers/gpu/drm/i915/intel_display.c | 18 ++----------------
>  drivers/gpu/drm/i915/intel_drv.h     |  1 +
>  drivers/gpu/drm/i915/intel_fbc.c     | 22 +++++++++++++++++++---
>  4 files changed, 22 insertions(+), 25 deletions(-)
> 
> diff --git a/drivers/gpu/drm/i915/i915_debugfs.c b/drivers/gpu/drm/i915/i915_debugfs.c
> index c99be0e..d36aa639 100644
> --- a/drivers/gpu/drm/i915/i915_debugfs.c
> +++ b/drivers/gpu/drm/i915/i915_debugfs.c
> @@ -1620,13 +1620,9 @@ static int i915_fbc_fc_get(void *data, u64 *val)
>  	if (INTEL_INFO(dev)->gen < 7 || !HAS_FBC(dev))
>  		return -ENODEV;
>  
> -	drm_modeset_lock_all(dev);
>  	mutex_lock(&dev_priv->fbc.lock);
> -
>  	*val = dev_priv->fbc.false_color;
> -
>  	mutex_unlock(&dev_priv->fbc.lock);
> -	drm_modeset_unlock_all(dev);
>  
>  	return 0;
>  }
> @@ -1640,7 +1636,6 @@ static int i915_fbc_fc_set(void *data, u64 val)
>  	if (INTEL_INFO(dev)->gen < 7 || !HAS_FBC(dev))
>  		return -ENODEV;
>  
> -	drm_modeset_lock_all(dev);
>  	mutex_lock(&dev_priv->fbc.lock);
>  
>  	reg = I915_READ(ILK_DPFC_CONTROL);
> @@ -1651,7 +1646,6 @@ static int i915_fbc_fc_set(void *data, u64 val)
>  		   (reg & ~FBC_CTL_FALSE_COLOR));
>  
>  	mutex_unlock(&dev_priv->fbc.lock);
> -	drm_modeset_unlock_all(dev);
>  	return 0;
>  }
>  
> diff --git a/drivers/gpu/drm/i915/intel_display.c b/drivers/gpu/drm/i915/intel_display.c
> index 3f48917..cf3a86d 100644
> --- a/drivers/gpu/drm/i915/intel_display.c
> +++ b/drivers/gpu/drm/i915/intel_display.c
> @@ -4682,9 +4682,7 @@ intel_post_enable_primary(struct drm_crtc *crtc)
>  	 */
>  	hsw_enable_ips(intel_crtc);
>  
> -	mutex_lock(&dev->struct_mutex);
>  	intel_fbc_update(dev);
> -	mutex_unlock(&dev->struct_mutex);
>  
>  	/*
>  	 * Gen2 reports pipe underruns whenever all planes are disabled.
> @@ -4740,10 +4738,7 @@ intel_pre_disable_primary(struct drm_crtc *crtc)
>  	if (HAS_GMCH_DISPLAY(dev))
>  		intel_set_memory_cxsr(dev_priv, false);
>  
> -	mutex_lock(&dev->struct_mutex);
> -	if (dev_priv->fbc.crtc == intel_crtc)
> -		intel_fbc_disable(dev);
> -	mutex_unlock(&dev->struct_mutex);
> +	intel_fbc_disable_crtc(intel_crtc);
>  
>  	/*
>  	 * FIXME IPS should be fine as long as one plane is
> @@ -5045,9 +5040,7 @@ static void ironlake_crtc_disable(struct drm_crtc *crtc)
>  	intel_crtc->active = false;
>  	intel_update_watermarks(crtc);
>  
> -	mutex_lock(&dev->struct_mutex);
>  	intel_fbc_update(dev);
> -	mutex_unlock(&dev->struct_mutex);
>  }
>  
>  static void haswell_crtc_disable(struct drm_crtc *crtc)
> @@ -5100,9 +5093,7 @@ static void haswell_crtc_disable(struct drm_crtc *crtc)
>  	intel_crtc->active = false;
>  	intel_update_watermarks(crtc);
>  
> -	mutex_lock(&dev->struct_mutex);
>  	intel_fbc_update(dev);
> -	mutex_unlock(&dev->struct_mutex);
>  
>  	if (intel_crtc_to_shared_dpll(intel_crtc))
>  		intel_disable_shared_dpll(intel_crtc);
> @@ -6199,9 +6190,7 @@ static void i9xx_crtc_disable(struct drm_crtc *crtc)
>  	intel_crtc->active = false;
>  	intel_update_watermarks(crtc);
>  
> -	mutex_lock(&dev->struct_mutex);
>  	intel_fbc_update(dev);
> -	mutex_unlock(&dev->struct_mutex);
>  }
>  
>  static void intel_crtc_disable_noatomic(struct drm_crtc *crtc)
> @@ -13786,11 +13775,8 @@ static void intel_finish_crtc_commit(struct drm_crtc *crtc)
>  
>  	intel_frontbuffer_flip(dev, intel_crtc->atomic.fb_bits);
>  
> -	if (intel_crtc->atomic.update_fbc) {
> -		mutex_lock(&dev->struct_mutex);
> +	if (intel_crtc->atomic.update_fbc)
>  		intel_fbc_update(dev);
> -		mutex_unlock(&dev->struct_mutex);
> -	}
>  
>  	if (intel_crtc->atomic.post_enable_primary)
>  		intel_post_enable_primary(crtc);
> diff --git a/drivers/gpu/drm/i915/intel_drv.h b/drivers/gpu/drm/i915/intel_drv.h
> index bcafefc..ac34041 100644
> --- a/drivers/gpu/drm/i915/intel_drv.h
> +++ b/drivers/gpu/drm/i915/intel_drv.h
> @@ -1251,6 +1251,7 @@ bool intel_fbc_enabled(struct drm_device *dev);
>  void intel_fbc_update(struct drm_device *dev);
>  void intel_fbc_init(struct drm_i915_private *dev_priv);
>  void intel_fbc_disable(struct drm_device *dev);
> +void intel_fbc_disable_crtc(struct intel_crtc *crtc);
>  void intel_fbc_invalidate(struct drm_i915_private *dev_priv,
>  			  unsigned int frontbuffer_bits,
>  			  enum fb_op_origin origin);
> diff --git a/drivers/gpu/drm/i915/intel_fbc.c b/drivers/gpu/drm/i915/intel_fbc.c
> index 31ff88b..ef52847 100644
> --- a/drivers/gpu/drm/i915/intel_fbc.c
> +++ b/drivers/gpu/drm/i915/intel_fbc.c
> @@ -335,7 +335,6 @@ static void intel_fbc_work_fn(struct work_struct *__work)
>  	struct drm_device *dev = work->crtc->dev;
>  	struct drm_i915_private *dev_priv = dev->dev_private;
>  
> -	mutex_lock(&dev->struct_mutex);
>  	mutex_lock(&dev_priv->fbc.lock);
>  	if (work == dev_priv->fbc.fbc_work) {
>  		/* Double check that we haven't switched fb without cancelling
> @@ -352,7 +351,6 @@ static void intel_fbc_work_fn(struct work_struct *__work)
>  		dev_priv->fbc.fbc_work = NULL;
>  	}
>  	mutex_unlock(&dev_priv->fbc.lock);
> -	mutex_unlock(&dev->struct_mutex);
>  
>  	kfree(work);
>  }
> @@ -366,7 +364,7 @@ static void intel_fbc_cancel_work(struct drm_i915_private *dev_priv)
>  
>  	DRM_DEBUG_KMS("cancelling pending FBC enable\n");
>  
> -	/* Synchronisation is provided by struct_mutex and checking of
> +	/* Synchronisation is provided by fbc.lock and checking of
>  	 * dev_priv->fbc.fbc_work, so we can perform the cancellation
>  	 * entirely asynchronously.
>  	 */
> @@ -454,6 +452,24 @@ void intel_fbc_disable(struct drm_device *dev)
>  	mutex_unlock(&dev_priv->fbc.lock);
>  }
>  
> +/**
> + * intel_fbc_disable_crtc - disable FBC for CRTC
> + * @crtc: the CRTC
> + *
> + * This function is called when the CRTC is being disabled. If it is the FBC
> + * CRTC, then FBC will also be disabled.
> + */
> +void intel_fbc_disable_crtc(struct intel_crtc *crtc)
> +{
> +	struct drm_device *dev = crtc->base.dev;
> +	struct drm_i915_private *dev_priv = dev->dev_private;
> +
> +	mutex_lock(&dev_priv->fbc.lock);
> +	if (dev_priv->fbc.crtc == crtc)
> +		__intel_fbc_disable(dev);
> +	mutex_unlock(&dev_priv->fbc.lock);
> +}
> +
>  const char *intel_no_fbc_reason_str(enum no_fbc_reason reason)
>  {
>  	switch (reason) {
> -- 
> 2.1.4
> 
> _______________________________________________
> Intel-gfx mailing list
> Intel-gfx at lists.freedesktop.org
> http://lists.freedesktop.org/mailman/listinfo/intel-gfx

-- 
Daniel Vetter
Software Engineer, Intel Corporation
http://blog.ffwll.ch


More information about the Intel-gfx mailing list