All of lore.kernel.org
 help / color / mirror / Atom feed
From: "Ville Syrjälä" <ville.syrjala@linux.intel.com>
To: Chris Wilson <chris@chris-wilson.co.uk>
Cc: intel-gfx@lists.freedesktop.org
Subject: Re: [PATCH v2] RFC drm/i915: Only acquire vblank-irq when waiting for vblank evade
Date: Tue, 13 Feb 2018 15:01:23 +0200	[thread overview]
Message-ID: <20180213130123.GB5453@intel.com> (raw)
In-Reply-To: <20180212222111.6780-1-chris@chris-wilson.co.uk>

On Mon, Feb 12, 2018 at 10:21:11PM +0000, Chris Wilson wrote:
> Cc: Ville Syrjälä <ville.syrjala@linux.intel.com>
> Cc: Maarten Lankhorst <maarten.lankhorst@linux.intel.com>
> ---
>  drivers/gpu/drm/i915/intel_sprite.c | 65 ++++++++++++++++++++++---------------
>  1 file changed, 38 insertions(+), 27 deletions(-)
> 
> diff --git a/drivers/gpu/drm/i915/intel_sprite.c b/drivers/gpu/drm/i915/intel_sprite.c
> index e098e4b2c85c..ad707c97a9d9 100644
> --- a/drivers/gpu/drm/i915/intel_sprite.c
> +++ b/drivers/gpu/drm/i915/intel_sprite.c
> @@ -74,6 +74,14 @@ int intel_usecs_to_scanlines(const struct drm_display_mode *adjusted_mode,
>  #define VBLANK_EVASION_TIME_US 100
>  #endif
>  
> +static inline bool scanline_in_vblank(struct intel_crtc *crtc,
> +				      int min, int max,
> +				      int *scanline)

The function name is wrong. Not sure what to call it really.
scanline_ok(), or reverse the condition and call it
scanline_bad() or scanline_in_danger_zone() (cue Kenny Loggins)?

> +{
> +	*scanline = intel_get_crtc_scanline(crtc);
> +	return *scanline < min || *scanline > max;
> +}
> +
>  /**
>   * intel_pipe_update_start() - start update of a set of display registers
>   * @new_crtc_state: the new crtc state
> @@ -91,12 +99,9 @@ void intel_pipe_update_start(const struct intel_crtc_state *new_crtc_state)
>  	struct intel_crtc *crtc = to_intel_crtc(new_crtc_state->base.crtc);
>  	struct drm_i915_private *dev_priv = to_i915(crtc->base.dev);
>  	const struct drm_display_mode *adjusted_mode = &new_crtc_state->base.adjusted_mode;
> -	long timeout = msecs_to_jiffies_timeout(1);
>  	int scanline, min, max, vblank_start;
> -	wait_queue_head_t *wq = drm_crtc_vblank_waitqueue(&crtc->base);
>  	bool need_vlv_dsi_wa = (IS_VALLEYVIEW(dev_priv) || IS_CHERRYVIEW(dev_priv)) &&
>  		intel_crtc_has_type(new_crtc_state, INTEL_OUTPUT_DSI);
> -	DEFINE_WAIT(wait);
>  
>  	vblank_start = adjusted_mode->crtc_vblank_start;
>  	if (adjusted_mode->flags & DRM_MODE_FLAG_INTERLACE)
> @@ -112,41 +117,46 @@ void intel_pipe_update_start(const struct intel_crtc_state *new_crtc_state)
>  	if (min <= 0 || max <= 0)
>  		return;
>  
> -	if (WARN_ON(drm_crtc_vblank_get(&crtc->base)))
> -		return;
> -
>  	crtc->debug.min_vbl = min;
>  	crtc->debug.max_vbl = max;
>  	trace_i915_pipe_update_start(crtc);
>  
> -	for (;;) {
> -		/*
> -		 * prepare_to_wait() has a memory barrier, which guarantees
> -		 * other CPUs can see the task state update by the time we
> -		 * read the scanline.
> -		 */
> -		prepare_to_wait(wq, &wait, TASK_UNINTERRUPTIBLE);
> +	if (!scanline_in_vblank(crtc, min, max, &scanline)) {

'goto skip_evade' to avoid messing with the loop indentation?

> +		wait_queue_head_t *wq = drm_crtc_vblank_waitqueue(&crtc->base);
> +		long timeout = msecs_to_jiffies_timeout(1);
> +		DEFINE_WAIT(wait);
>  
> -		scanline = intel_get_crtc_scanline(crtc);
> -		if (scanline < min || scanline > max)
> -			break;
> +		if (WARN_ON(drm_crtc_vblank_get(&crtc->base)))
> +			goto skip_evade;
>  
> -		if (timeout <= 0) {
> -			DRM_ERROR("Potential atomic update failure on pipe %c\n",
> -				  pipe_name(crtc->pipe));
> -			break;
> -		}
> +		for (;;) {
> +			/*
> +			 * prepare_to_wait() has a memory barrier, which
> +			 * guarantees other CPUs can see the task state update
> +			 * by the time we read the scanline.
> +			 */
> +			prepare_to_wait(wq, &wait, TASK_UNINTERRUPTIBLE);
>  
> -		local_irq_enable();
> +			if (scanline_in_vblank(crtc, min, max, &scanline))
> +				break;
>  
> -		timeout = schedule_timeout(timeout);
> +			if (timeout <= 0) {
> +				DRM_ERROR("Potential atomic update failure on pipe %c\n",
> +					  pipe_name(crtc->pipe));
> +				break;
> +			}
>  
> -		local_irq_disable();
> -	}
> +			local_irq_enable();
>  
> -	finish_wait(wq, &wait);
> +			timeout = schedule_timeout(timeout);
>  
> -	drm_crtc_vblank_put(&crtc->base);
> +			local_irq_disable();
> +		}
> +
> +		finish_wait(wq, &wait);
> +
> +		drm_crtc_vblank_put(&crtc->base);
> +	}
>  
>  	/*
>  	 * On VLV/CHV DSI the scanline counter would appear to
> @@ -166,6 +176,7 @@ void intel_pipe_update_start(const struct intel_crtc_state *new_crtc_state)
>  	while (need_vlv_dsi_wa && scanline == vblank_start)
>  		scanline = intel_get_crtc_scanline(crtc);

I think we'll need to do the dsi w/a regardless, so the label should be
before it.

>  
> +skip_evade:
>  	crtc->debug.scanline_start = scanline;
>  	crtc->debug.start_vbl_time = ktime_get();
>  	crtc->debug.start_vbl_count = intel_crtc_get_vblank_counter(crtc);
> -- 
> 2.16.1

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

  reply	other threads:[~2018-02-13 13:01 UTC|newest]

Thread overview: 5+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2018-02-12 21:37 [PATCH] RFC drm/i915: Only acquire vblank-irq when waiting for vblank evade Chris Wilson
2018-02-12 22:16 ` ✗ Fi.CI.BAT: warning for " Patchwork
2018-02-12 22:21 ` [PATCH v2] " Chris Wilson
2018-02-13 13:01   ` Ville Syrjälä [this message]
2018-02-12 22:53 ` ✗ Fi.CI.BAT: failure for RFC drm/i915: Only acquire vblank-irq when waiting for vblank evade (rev2) 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=20180213130123.GB5453@intel.com \
    --to=ville.syrjala@linux.intel.com \
    --cc=chris@chris-wilson.co.uk \
    --cc=intel-gfx@lists.freedesktop.org \
    /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.