All of lore.kernel.org
 help / color / mirror / Atom feed
From: Chris Wilson <chris@chris-wilson.co.uk>
To: "Ville Syrjälä" <ville.syrjala@linux.intel.com>,
	"Maarten Lankhorst" <maarten.lankhorst@linux.intel.com>
Cc: intel-gfx@lists.freedesktop.org
Subject: Re: [PATCH 1/5] drm/i915: Keep vblank irq enabled during vblank evasion.
Date: Mon, 12 Feb 2018 17:24:54 +0000	[thread overview]
Message-ID: <151845629477.18923.1903087671193460671@mail.alporthouse.com> (raw)
In-Reply-To: <20180212165528.GR5453@intel.com>

Quoting Ville Syrjälä (2018-02-12 16:55:28)
> On Mon, Feb 12, 2018 at 04:41:05PM +0100, Maarten Lankhorst wrote:
> > Op 12-02-18 om 16:31 schreef Chris Wilson:
> > > Quoting Maarten Lankhorst (2018-02-12 15:27:34)
> > >> Op 12-02-18 om 16:22 schreef Chris Wilson:
> > >>> Quoting Maarten Lankhorst (2018-02-12 15:16:39)
> > >>>> Op 12-02-18 om 16:10 schreef Chris Wilson:
> > >>>>> Quoting Maarten Lankhorst (2018-02-09 09:54:00)
> > >>>>>> This is a nice preparation for grabbing the uncore lock during evasion.
> > >>>>>> Grabbing the spinlock with the lock held messes up the locking,
> > >>>>>> so it's easier to handover the reference to the eve
> > >>>>>>
> > >>>>>> Signed-off-by: Maarten Lankhorst <maarten.lankhorst@linux.intel.com>
> > >>>>>> ---
> > >>>>>>  drivers/gpu/drm/i915/intel_sprite.c | 11 ++++-------
> > >>>>>>  1 file changed, 4 insertions(+), 7 deletions(-)
> > >>>>>>
> > >>>>>> diff --git a/drivers/gpu/drm/i915/intel_sprite.c b/drivers/gpu/drm/i915/intel_sprite.c
> > >>>>>> index 3be22c0fcfb5..971a1ea0db45 100644
> > >>>>>> --- a/drivers/gpu/drm/i915/intel_sprite.c
> > >>>>>> +++ b/drivers/gpu/drm/i915/intel_sprite.c
> > >>>>>> @@ -109,10 +109,10 @@ void intel_pipe_update_start(const struct intel_crtc_state *new_crtc_state)
> > >>>>>>  
> > >>>>>>         local_irq_disable();
> > >>>>>>  
> > >>>>>> -       if (min <= 0 || max <= 0)
> > >>>>>> +       if (WARN_ON(drm_crtc_vblank_get(&crtc->base)))
> > >>>>>>                 return;
> > >>>>>>  
> > >>>>>> -       if (WARN_ON(drm_crtc_vblank_get(&crtc->base)))
> > >>>>>> +       if (min <= 0 || max <= 0)
> > >>>>>>                 return;
> > >>>>>>  
> > >>>>> The corresponding vblank_put is the one later in update_start(), right?
> > >>>>> I don't think you intended to keep this chunk.
> > >>>>> -Chris
> > >>>> I'm not sure what you mean? The vblank_put is now in pipe_update_end, except if the
> > >>>> event takes over the reference. I think the code is correct. :)
> > >>> Then it's unbalanced in the case of error still.
> > >>> -Chris
> > >> It already would have been for events, hence the WARN_ON there.
> > >> I don't think we can do anything about it, this shouldn't ever
> > >> happen in practice, could be a BUG_ON for all I care. :)
> > > I would much prefer that over intentionally bad code.
> > >
> > > But do we really need to enable the vblank irq here? If the event
> > > requires it, doesn't it already enable the vblank. Here, we only need it
> > > when sleeping, can we not determine we have enough time before the
> > > vblank without enabling the interrupt?
> > I'm not sure why we get a reference to the vblank counter here. Perhaps Ville does?
> 
> We need the vblank irq to be enabled before we check the scanline since
> otherwise we may end up doing:
> 
> 1. check scanline
> 3. vblank irq fires
> 2. enable vblank irq
> 3. wait for the next vblank
> 
> So we'd end up wasting an entire frame.

Step: 2.5, check_scanline?

Something like,

diff --git a/drivers/gpu/drm/i915/intel_sprite.c b/drivers/gpu/drm/i915/intel_sprite.c
index 574bd02c5a2e..70c2ee1c7b8c 100644
--- a/drivers/gpu/drm/i915/intel_sprite.c
+++ b/drivers/gpu/drm/i915/intel_sprite.c
@@ -97,6 +97,7 @@ void intel_pipe_update_start(const struct intel_crtc_state *new_crtc_state)
        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);
+       bool have_vblank_irq = false;
 
        vblank_start = adjusted_mode->crtc_vblank_start;
        if (adjusted_mode->flags & DRM_MODE_FLAG_INTERLACE)
@@ -112,9 +113,6 @@ 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);
@@ -127,6 +125,10 @@ void intel_pipe_update_start(const struct intel_crtc_state *new_crtc_state)
                 */
                prepare_to_wait(wq, &wait, TASK_UNINTERRUPTIBLE);
 
+               if (!have_vblank_irq)
+                       have_vblank_irq = !drm_crtc_vblank_get(&crtc->base);
+
                scanline = intel_get_crtc_scanline(crtc);
                if (scanline < min || scanline > max)
                        break;
@@ -145,8 +147,8 @@ void intel_pipe_update_start(const struct intel_crtc_state *new_crtc_state)
        }
 
        finish_wait(wq, &wait);
-
-       drm_crtc_vblank_put(&crtc->base);
+       if (have_vblank_irq)
+               drm_crtc_vblank_put(&crtc->base);
 
        /*
         * On VLV/CHV DSI the scanline counter would appear to

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

  reply	other threads:[~2018-02-12 17:25 UTC|newest]

Thread overview: 33+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2018-02-09  9:53 [PATCH 0/5] drm/i915: Grab the vblank evasion lock around the entire evasion Maarten Lankhorst
2018-02-09  9:54 ` [PATCH 1/5] drm/i915: Keep vblank irq enabled during vblank evasion Maarten Lankhorst
2018-02-12 15:10   ` Chris Wilson
2018-02-12 15:16     ` Maarten Lankhorst
2018-02-12 15:22       ` Chris Wilson
2018-02-12 15:27         ` Maarten Lankhorst
2018-02-12 15:31           ` Chris Wilson
2018-02-12 15:41             ` Maarten Lankhorst
2018-02-12 16:55               ` Ville Syrjälä
2018-02-12 17:24                 ` Chris Wilson [this message]
2018-02-12 18:06                   ` Ville Syrjälä
2018-02-12 20:55                     ` Chris Wilson
2018-02-13  8:59                       ` Maarten Lankhorst
2018-02-09  9:54 ` [PATCH 2/5] drm/i915: Grab uncore.lock around enabling " Maarten Lankhorst
2018-02-12 15:16   ` Chris Wilson
2018-02-09  9:54 ` [PATCH 3/5] drm/i915: Call i915_pipe_update_start with uncore.lock held Maarten Lankhorst
2018-02-09 23:08   ` James Ausmus
2018-02-10  8:46     ` Maarten Lankhorst
2018-02-10  9:05       ` Chris Wilson
2018-02-12 15:19   ` Chris Wilson
2018-02-12 15:39     ` Maarten Lankhorst
2018-02-12 15:44       ` Chris Wilson
2018-02-12 16:41         ` Maarten Lankhorst
2018-02-09  9:54 ` [PATCH 4/5] drm/i915: Move all locking for plane updates to caller Maarten Lankhorst
2018-02-09  9:54 ` [PATCH 5/5] drm/i915: Use DOUBLE_BUFFER_CTL on top of vblank evasion for GEN9+ Maarten Lankhorst
2018-02-09 10:04 ` [PATCH 0/5] drm/i915: Grab the vblank evasion lock around the entire evasion Chris Wilson
2018-02-09 17:21   ` Maarten Lankhorst
2018-02-12 17:01     ` Ville Syrjälä
2018-02-13 10:19       ` Maarten Lankhorst
2018-02-13 10:40         ` Chris Wilson
2018-02-09 14:24 ` ✗ Fi.CI.BAT: failure for " Patchwork
2018-02-12 15:02 ` ✓ Fi.CI.BAT: success " Patchwork
2018-02-12 16:56 ` ✗ Fi.CI.IGT: warning " 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=151845629477.18923.1903087671193460671@mail.alporthouse.com \
    --to=chris@chris-wilson.co.uk \
    --cc=intel-gfx@lists.freedesktop.org \
    --cc=maarten.lankhorst@linux.intel.com \
    --cc=ville.syrjala@linux.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.