All of lore.kernel.org
 help / color / mirror / Atom feed
From: "Ville Syrjälä" <ville.syrjala@linux.intel.com>
To: "José Roberto de Souza" <jose.souza@intel.com>
Cc: intel-gfx@lists.freedesktop.org,
	Dhinakaran Pandiyan <dhinakaran.pandiyan@intel.com>,
	Rodrigo Vivi <rodrigo.vivi@intel.com>
Subject: Re: [PATCH] drm/i915/psr: Get pipe id following atomic guidelines
Date: Wed, 28 Nov 2018 23:25:33 +0200	[thread overview]
Message-ID: <20181128212533.GJ9144@intel.com> (raw)
In-Reply-To: <20181128072838.22773-1-jose.souza@intel.com>

On Tue, Nov 27, 2018 at 11:28:38PM -0800, José Roberto de Souza wrote:
> As stated in struct drm_encoder, crtc field should only be used
> by non-atomic drivers.
> 
> So here caching the pipe id in intel_psr_enable() what is way more
> simple and efficient than at every call to
> intel_psr_flush()/invalidate() get the
> drm.mode_config.connection_mutex lock to safely be able to get the
> pipe id by reading drm_connector_state.crtc.
> 
> This should fix the null pointer dereference crash below as the
> previous way to get the pipe id was prone to race conditions.
> 
> Bugzilla: https://bugs.freedesktop.org/show_bug.cgi?id=105959
> Cc: Dhinakaran Pandiyan <dhinakaran.pandiyan@intel.com>
> Cc: Rodrigo Vivi <rodrigo.vivi@intel.com>
> Signed-off-by: José Roberto de Souza <jose.souza@intel.com>
> ---
>  drivers/gpu/drm/i915/i915_drv.h  |  1 +
>  drivers/gpu/drm/i915/intel_psr.c | 19 ++++---------------
>  2 files changed, 5 insertions(+), 15 deletions(-)
> 
> diff --git a/drivers/gpu/drm/i915/i915_drv.h b/drivers/gpu/drm/i915/i915_drv.h
> index f763b30f98d9..9ea39b82836f 100644
> --- a/drivers/gpu/drm/i915/i915_drv.h
> +++ b/drivers/gpu/drm/i915/i915_drv.h
> @@ -494,6 +494,7 @@ struct i915_psr {
>  	bool sink_support;
>  	bool prepared, enabled;
>  	struct intel_dp *dp;
> +	enum pipe pipe;
>  	bool active;
>  	struct work_struct work;
>  	unsigned busy_frontbuffer_bits;
> diff --git a/drivers/gpu/drm/i915/intel_psr.c b/drivers/gpu/drm/i915/intel_psr.c
> index 572e626eadff..11a520074f06 100644
> --- a/drivers/gpu/drm/i915/intel_psr.c
> +++ b/drivers/gpu/drm/i915/intel_psr.c
> @@ -705,6 +705,7 @@ void intel_psr_enable(struct intel_dp *intel_dp,
>  	dev_priv->psr.psr2_enabled = intel_psr2_enabled(dev_priv, crtc_state);
>  	dev_priv->psr.busy_frontbuffer_bits = 0;
>  	dev_priv->psr.prepared = true;
> +	dev_priv->psr.pipe = to_intel_crtc(crtc_state->base.crtc)->pipe;

A step in the right direction. And would be nice if someone could
eventually move the psr state to be a per-crtc thing rather than
a global thing.

>  
>  	if (psr_global_enabled(dev_priv->psr.debug))
>  		intel_psr_enable_locked(dev_priv, crtc_state);
> @@ -1012,9 +1013,6 @@ static void intel_psr_work(struct work_struct *work)
>  void intel_psr_invalidate(struct drm_i915_private *dev_priv,
>  			  unsigned frontbuffer_bits, enum fb_op_origin origin)
>  {
> -	struct drm_crtc *crtc;
> -	enum pipe pipe;
> -
>  	if (!CAN_PSR(dev_priv))
>  		return;
>  
> @@ -1027,10 +1025,7 @@ void intel_psr_invalidate(struct drm_i915_private *dev_priv,
>  		return;
>  	}
>  
> -	crtc = dp_to_dig_port(dev_priv->psr.dp)->base.base.crtc;
> -	pipe = to_intel_crtc(crtc)->pipe;
> -
> -	frontbuffer_bits &= INTEL_FRONTBUFFER_ALL_MASK(pipe);
> +	frontbuffer_bits &= INTEL_FRONTBUFFER_ALL_MASK(dev_priv->psr.pipe);
>  	dev_priv->psr.busy_frontbuffer_bits |= frontbuffer_bits;
>  
>  	if (frontbuffer_bits)
> @@ -1055,9 +1050,6 @@ void intel_psr_invalidate(struct drm_i915_private *dev_priv,
>  void intel_psr_flush(struct drm_i915_private *dev_priv,
>  		     unsigned frontbuffer_bits, enum fb_op_origin origin)
>  {
> -	struct drm_crtc *crtc;
> -	enum pipe pipe;
> -
>  	if (!CAN_PSR(dev_priv))
>  		return;
>  
> @@ -1070,10 +1062,7 @@ void intel_psr_flush(struct drm_i915_private *dev_priv,
>  		return;
>  	}
>  
> -	crtc = dp_to_dig_port(dev_priv->psr.dp)->base.base.crtc;
> -	pipe = to_intel_crtc(crtc)->pipe;
> -
> -	frontbuffer_bits &= INTEL_FRONTBUFFER_ALL_MASK(pipe);
> +	frontbuffer_bits &= INTEL_FRONTBUFFER_ALL_MASK(dev_priv->psr.pipe);
>  	dev_priv->psr.busy_frontbuffer_bits &= ~frontbuffer_bits;
>  
>  	/* By definition flush = invalidate + flush */
> @@ -1087,7 +1076,7 @@ void intel_psr_flush(struct drm_i915_private *dev_priv,
>  		 * but it makes more sense write to the current active
>  		 * pipe.
>  		 */
> -		I915_WRITE(CURSURFLIVE(pipe), 0);
> +		I915_WRITE(CURSURFLIVE(dev_priv->psr.pipe), 0);
>  	}
>  
>  	if (!dev_priv->psr.active && !dev_priv->psr.busy_frontbuffer_bits)
> -- 
> 2.19.2
> 
> _______________________________________________
> Intel-gfx mailing list
> Intel-gfx@lists.freedesktop.org
> https://lists.freedesktop.org/mailman/listinfo/intel-gfx

-- 
Ville Syrjälä
Intel
_______________________________________________
Intel-gfx mailing list
Intel-gfx@lists.freedesktop.org
https://lists.freedesktop.org/mailman/listinfo/intel-gfx

  parent reply	other threads:[~2018-11-28 21:25 UTC|newest]

Thread overview: 30+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2018-11-28  7:28 [PATCH] drm/i915/psr: Get pipe id following atomic guidelines José Roberto de Souza
2018-11-28  7:55 ` ✗ Fi.CI.SPARSE: warning for " Patchwork
2018-11-28  8:23 ` ✓ Fi.CI.BAT: success " Patchwork
2018-11-28 15:14 ` ✗ Fi.CI.IGT: failure " Patchwork
2018-11-28 16:55 ` [PATCH] " Rodrigo Vivi
2018-11-28 18:21   ` Souza, Jose
2018-11-28 18:44     ` Rodrigo Vivi
2018-11-28 20:47 ` ✗ Fi.CI.SPARSE: warning for drm/i915/psr: Get pipe id following atomic guidelines (rev2) Patchwork
2018-11-28 21:02 ` ✗ Fi.CI.BAT: failure " Patchwork
2018-11-28 22:13   ` Souza, Jose
2018-11-29  6:18     ` Rodrigo Vivi
2018-11-29  7:52       ` Saarinen, Jani
2018-11-29 17:36         ` Rodrigo Vivi
2018-11-30 13:04           ` Martin Peres
2018-11-30 17:26             ` Rodrigo Vivi
2018-12-03 12:29               ` Peres, Martin
2018-12-03 20:55                 ` Rodrigo Vivi
2018-12-04 11:25                   ` Peres, Martin
2018-11-28 21:25 ` Ville Syrjälä [this message]
2018-11-29  6:17 ` ✗ Fi.CI.SPARSE: warning for drm/i915/psr: Get pipe id following atomic guidelines (rev3) Patchwork
2018-11-29  6:33 ` ✗ Fi.CI.BAT: failure " Patchwork
2018-11-29 20:26   ` Souza, Jose
2018-11-29 21:23     ` Rodrigo Vivi
2018-11-29 22:05 ` ✗ Fi.CI.SPARSE: warning for drm/i915/psr: Get pipe id following atomic guidelines (rev4) Patchwork
2018-11-29 22:26 ` ✗ Fi.CI.BAT: failure " Patchwork
2018-11-29 23:39   ` Rodrigo Vivi
2018-11-29 23:37 ` ✗ Fi.CI.SPARSE: warning for drm/i915/psr: Get pipe id following atomic guidelines (rev5) Patchwork
2018-11-29 23:52 ` ✓ Fi.CI.BAT: success " Patchwork
2018-11-30 18:05   ` Souza, Jose
2018-11-30 19:02 ` ✓ Fi.CI.IGT: " Patchwork

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=20181128212533.GJ9144@intel.com \
    --to=ville.syrjala@linux.intel.com \
    --cc=dhinakaran.pandiyan@intel.com \
    --cc=intel-gfx@lists.freedesktop.org \
    --cc=jose.souza@intel.com \
    --cc=rodrigo.vivi@intel.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 an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.