All of lore.kernel.org
 help / color / mirror / Atom feed
From: Tarun Vyas <tarun.vyas@intel.com>
To: Rodrigo Vivi <rodrigo.vivi@intel.com>
Cc: Deak@otc-chromeosbuild-5, Pandiyan@otc-chromeosbuild-5,
	Dhinakaran <dhinakaran.pandiyan@intel.com>,
	intel-gfx@lists.freedesktop.org
Subject: Re: [PATCH] drm/i915: Wait for PSR exit before checking for vblank evasion for an atomic update
Date: Wed, 2 May 2018 11:19:14 -0700	[thread overview]
Message-ID: <20180502181913.GA14677@otc-chromeosbuild-5> (raw)
In-Reply-To: <20180430171933.GI3617@intel.com>

On Mon, Apr 30, 2018 at 10:19:33AM -0700, Rodrigo Vivi wrote:
> On Sun, Apr 29, 2018 at 09:00:18PM -0700, Tarun Vyas wrote:
> > From: Tarun <tarun.vyas@intel.com>
> > 
> > The PIPEDSL freezes on PSR entry and if PSR hasn't fully exited, then
> > the pipe_update_start call schedules itself out to check back later.
> > 
> > On ChromeOS-4.4 kernel, which is fairly up-to-date w.r.t drm/i915 but
> > lags w.r.t core kernel code, hot plugging an external display triggers
> > tons of "potential atomic update errors" in the dmesg, on *pipe A*. A
> > closer analysis reveals that we try to read the scanline 3 times and
> > eventually timeout, b/c PSR hasn't exited fully leading to a PIPEDSL
> > stuck @ 1599. This issue is not seen on upstream kernels, b/c for *some*
> > reason we loop inside intel_pipe_update start for ~2+ msec which in this
> > case is more than enough to exit PSR fully, hence an *unstuck* PIPEDSL
> > counter, hence no error. On the other hand, the ChromeOS kernel spends
> > ~1.1 msec looping inside intel_pipe_update_start and hence errors out
> > b/c the source is still in PSR.
> > 
> > Regardless, we should wait for PSR exit (if PSR is supported and active
> > on the current pipe) before reading the PIPEDSL, b/c if we haven't
> > fully exited PSR, then checking for vblank evasion isn't actually
> > applicable.
> > 
> > This scenario applies to a configuration with an additional pipe,
> > as of now.
> 
> I honestly believe you picking the wrong culprit here. By "coincidence".
> PSR will allow DC state with screen on and DC state will mess up with all
> registers reads....
> 
> probably what you are missing you your kernel is some power domain
> grab that would keep DC_OFF and consequently a sane read of these
> registers.
> 
> Maybe Imre has a quick idea of what you could be missing on your kernel
> that we already have on upstream one.
> 
> Thanks,
> Rodrigo.
>
Thanks for the quick response Rodrigo !
Some key observations based on my experiments so far:
       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);                 
                                                                                  
                scanline = intel_get_crtc_scanline(crtc);                         
                if (scanline < min || scanline > max)                             
                        break;                                                    
                                                                                  
                if (timeout <= 0) {                                               
                        DRM_ERROR("Potential atomic update failure on pipe %c\n", 
                                  pipe_name(crtc->pipe));                         
                        break;                                                    
                }                                                                 
                                                                                  
                local_irq_enable();                                               
                                                                                  
                timeout = schedule_timeout(timeout);                              
                                                                                  
                local_irq_disable();                                              
        }
1. In the above loop inside pipe_update_start, the *first time*, we read the PIPEDSL, with PSR1 and external display connected, it always reads 1599, for *both* the kernels(upstream and ChromeOS-4.4) . The PSR_STATUS also reads the exact same for *both* kernels and shows that we haven't *fully* exited PSR.

2. The difference between the two kernels comes after this first read of the PIPEDSL. ChromeOS-4.4 spends ~1 msec inside that loop and upstream spends ~2msec. I suspect that it is because of the scheduling changes between the two kernels, b/c I can't find any i915 specific code running in that loop, except for vblank processing.

3. So to summarize it, both the kernels are in the same state w.r.t PSR and PIPEDSL value when they read the PIPEDSL for the first time inside the loop. *When* the kernels *transition* to a *full PSR exit* is what is differing.

My rationale for this patch is that, the pipe_update_start function is meant to evade 100 usec before a vblank, but, *if* we haven't *fully* exited PSR (which is true for both the kernels for the first PIPEDSL read), then vblank evasion is *not applicable* b/c the PIPEDSL will be messed up. So we shouldn't bother evading vblank until we have fully exited PSR.

Thanks,
Tarun
> > 
> > ---
> >  drivers/gpu/drm/i915/intel_sprite.c | 7 +++++--
> >  1 file changed, 5 insertions(+), 2 deletions(-)
> > 
> > diff --git a/drivers/gpu/drm/i915/intel_sprite.c b/drivers/gpu/drm/i915/intel_sprite.c
> > index aa1dfaa692b9..135b41568503 100644
> > --- a/drivers/gpu/drm/i915/intel_sprite.c
> > +++ b/drivers/gpu/drm/i915/intel_sprite.c
> > @@ -107,14 +107,17 @@ void intel_pipe_update_start(const struct intel_crtc_state *new_crtc_state)
> >  						      VBLANK_EVASION_TIME_US);
> >  	max = vblank_start - 1;
> >  
> > -	local_irq_disable();
> > -
> >  	if (min <= 0 || max <= 0)
> >  		return;
> >  
> >  	if (WARN_ON(drm_crtc_vblank_get(&crtc->base)))
> >  		return;
> >  
> > +	if(new_crtc_state->has_psr && dev_priv->psr.active)
> > +		intel_wait_for_register(dev_priv, EDP_PSR_STATUS, EDP_PSR_STATUS_STATE_MASK, EDP_PSR_STATUS_STATE_IDLE, 5);
> > +
> > +	local_irq_disable();
> > +
> >  	crtc->debug.min_vbl = min;
> >  	crtc->debug.max_vbl = max;
> >  	trace_i915_pipe_update_start(crtc);
> > -- 
> > 2.13.5
> > 
> > _______________________________________________
> > Intel-gfx mailing list
> > Intel-gfx@lists.freedesktop.org
> > https://lists.freedesktop.org/mailman/listinfo/intel-gfx
_______________________________________________
Intel-gfx mailing list
Intel-gfx@lists.freedesktop.org
https://lists.freedesktop.org/mailman/listinfo/intel-gfx

  reply	other threads:[~2018-05-02 18:19 UTC|newest]

Thread overview: 13+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2018-04-30  4:00 [PATCH] drm/i915: Wait for PSR exit before checking for vblank evasion for an atomic update Tarun Vyas
2018-04-30  8:20 ` Jani Nikula
2018-04-30 10:48 ` ✗ Fi.CI.CHECKPATCH: warning for " Patchwork
2018-04-30 11:04 ` ✓ Fi.CI.BAT: success " Patchwork
2018-04-30 13:39 ` ✓ Fi.CI.IGT: " Patchwork
2018-04-30 17:19 ` [PATCH] " Rodrigo Vivi
2018-05-02 18:19   ` Tarun Vyas [this message]
2018-05-02 18:51     ` Ville Syrjälä
2018-05-02 20:04       ` Rodrigo Vivi
2018-05-02 22:31         ` Tarun Vyas
2018-05-03 16:58           ` Rodrigo Vivi
2018-05-03 17:08             ` Tarun Vyas
2018-05-14 12:53 ` Jani Nikula

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=20180502181913.GA14677@otc-chromeosbuild-5 \
    --to=tarun.vyas@intel.com \
    --cc=Deak@otc-chromeosbuild-5 \
    --cc=Pandiyan@otc-chromeosbuild-5 \
    --cc=dhinakaran.pandiyan@intel.com \
    --cc=intel-gfx@lists.freedesktop.org \
    --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.