public inbox for intel-gfx@lists.freedesktop.org
 help / color / mirror / Atom feed
From: Daniel Vetter <daniel@ffwll.ch>
To: Paulo Zanoni <przanoni@gmail.com>
Cc: intel-gfx@lists.freedesktop.org, Paulo Zanoni <paulo.r.zanoni@intel.com>
Subject: Re: [PATCH 3/3] drm/i915: stop using struct_mutex for FBC
Date: Wed, 17 Jun 2015 09:51:11 +0200	[thread overview]
Message-ID: <20150617075111.GB23637@phenom.ffwll.local> (raw)
In-Reply-To: <978418739-1927-4-git-send-email-przanoni@gmail.com>

On Tue, Jan 02, 2001 at 04:58:59AM -0200, Paulo Zanoni wrote:
> From: Paulo Zanoni <paulo.r.zanoni@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@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@lists.freedesktop.org
> http://lists.freedesktop.org/mailman/listinfo/intel-gfx

-- 
Daniel Vetter
Software Engineer, Intel Corporation
http://blog.ffwll.ch
_______________________________________________
Intel-gfx mailing list
Intel-gfx@lists.freedesktop.org
http://lists.freedesktop.org/mailman/listinfo/intel-gfx

  reply	other threads:[~2015-06-17  7:48 UTC|newest]

Thread overview: 13+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2001-01-02  6:58 [PATCH 0/3] FBC locking Paulo Zanoni
2001-01-02  6:58 ` [PATCH 1/3] drm/i915: don't increment the FBC threshold at fbc_enable Paulo Zanoni
2001-01-02  6:58 ` [PATCH 2/3] drm/i915: add the FBC mutex Paulo Zanoni
2015-06-17  7:47   ` Chris Wilson
2015-06-17  7:52   ` Chris Wilson
2015-06-17 19:39     ` Paulo Zanoni
2015-06-17 20:25       ` Chris Wilson
2015-06-17 20:47         ` Paulo Zanoni
2015-06-18  8:37           ` Chris Wilson
2015-06-17  8:21   ` Daniel Vetter
2001-01-02  6:58 ` [PATCH 3/3] drm/i915: stop using struct_mutex for FBC Paulo Zanoni
2015-06-17  7:51   ` Daniel Vetter [this message]
2015-06-16 22:23 ` [PATCH 0/3] FBC locking Paulo Zanoni

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20150617075111.GB23637@phenom.ffwll.local \
    --to=daniel@ffwll.ch \
    --cc=intel-gfx@lists.freedesktop.org \
    --cc=paulo.r.zanoni@intel.com \
    --cc=przanoni@gmail.com \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox