dri-devel Archive on lore.kernel.org
 help / color / mirror / Atom feed
  • * [PATCH AUTOSEL 4.19 20/97] drm/atomic-helper: Complete fake_commit->flip_done potentially earlier
           [not found] <20190108192949.122407-1-sashal@kernel.org>
           [not found] ` <20190108192949.122407-1-sashal-DgEjT+Ai2ygdnm+yROfE0A@public.gmane.org>
    @ 2019-01-08 19:28 ` Sasha Levin
      2019-01-08 19:28 ` [PATCH AUTOSEL 4.19 26/97] drm/amdgpu: Correct get_crtc_scanoutpos behavior when vpos >= vtotal Sasha Levin
      2 siblings, 0 replies; 5+ messages in thread
    From: Sasha Levin @ 2019-01-08 19:28 UTC (permalink / raw)
      To: linux-kernel, stable; +Cc: Sasha Levin, dri-devel
    
    From: Ville Syrjälä <ville.syrjala@linux.intel.com>
    
    [ Upstream commit 2de42f79bb21a412f40ade8831eb6fc445cb78a4 ]
    
    Consider the following scenario:
    1. nonblocking enable crtc
    2. wait for the event
    3. nonblocking disable crtc
    
    On i915 this can lead to a spurious -EBUSY from step 3 on
    account of non-enabled planes getting the fake_commit in step 1
    and we don't complete the fake_commit-> flip_done until
    drm_atomic_helper_commit_hw_done() which can happen a long
    time after the flip event was sent out.
    
    This will become somewhat easy to hit on SKL+ once we start
    to add all the planes for the crtc to every modeset commit
    for the purposes of forcing a watermark register programming
    [1].
    
    To make the race a little less pronounced let's complete
    fake_commit->flip_done after drm_atomic_helper_wait_for_flip_done().
    For the single crtc case this should make the race quite
    theoretical, assuming drm_atomic_helper_wait_for_flip_done()
    actually has to wait for the real commit flip_done. In case
    the real commit flip_done gets completed singificantly before
    drm_atomic_helper_wait_for_flip_done(), or we are dealing with
    multiple crtcs whose vblanks don't line up nicely the race still
    exists.
    
    [1] https://patchwork.freedesktop.org/patch/262670/
    
    Cc: Maarten Lankhorst <maarten.lankhorst@linux.intel.com>
    Fixes: 080de2e5be2d ("drm/atomic: Check for busy planes/connectors before setting the commit")
    Testcase: igt/kms_cursor_legacy/*nonblocking-modeset-vs-cursor-atomic
    Signed-off-by: Ville Syrjälä <ville.syrjala@linux.intel.com>
    Link: https://patchwork.freedesktop.org/patch/msgid/20181122143412.11655-1-ville.syrjala@linux.intel.com
    Reviewed-by: Maarten Lankhorst <maarten.lankhorst@linux.intel.com>
    Signed-off-by: Sasha Levin <sashal@kernel.org>
    ---
     drivers/gpu/drm/drm_atomic_helper.c | 3 +++
     1 file changed, 3 insertions(+)
    
    diff --git a/drivers/gpu/drm/drm_atomic_helper.c b/drivers/gpu/drm/drm_atomic_helper.c
    index 1bb4c318bdd4..f77bff5aa307 100644
    --- a/drivers/gpu/drm/drm_atomic_helper.c
    +++ b/drivers/gpu/drm/drm_atomic_helper.c
    @@ -1425,6 +1425,9 @@ void drm_atomic_helper_wait_for_flip_done(struct drm_device *dev,
     			DRM_ERROR("[CRTC:%d:%s] flip_done timed out\n",
     				  crtc->base.id, crtc->name);
     	}
    +
    +	if (old_state->fake_commit)
    +		complete_all(&old_state->fake_commit->flip_done);
     }
     EXPORT_SYMBOL(drm_atomic_helper_wait_for_flip_done);
     
    -- 
    2.19.1
    
    _______________________________________________
    dri-devel mailing list
    dri-devel@lists.freedesktop.org
    https://lists.freedesktop.org/mailman/listinfo/dri-devel
    
    ^ permalink raw reply related	[flat|nested] 5+ messages in thread
  • * [PATCH AUTOSEL 4.19 26/97] drm/amdgpu: Correct get_crtc_scanoutpos behavior when vpos >= vtotal
           [not found] <20190108192949.122407-1-sashal@kernel.org>
           [not found] ` <20190108192949.122407-1-sashal-DgEjT+Ai2ygdnm+yROfE0A@public.gmane.org>
      2019-01-08 19:28 ` [PATCH AUTOSEL 4.19 20/97] drm/atomic-helper: Complete fake_commit->flip_done potentially earlier Sasha Levin
    @ 2019-01-08 19:28 ` Sasha Levin
      2 siblings, 0 replies; 5+ messages in thread
    From: Sasha Levin @ 2019-01-08 19:28 UTC (permalink / raw)
      To: linux-kernel, stable
      Cc: Nicholas Kazlauskas, Alex Deucher, Sasha Levin, amd-gfx,
    	dri-devel
    
    From: Nicholas Kazlauskas <nicholas.kazlauskas@amd.com>
    
    [ Upstream commit 520f08df45fbe300ed650da786a74093d658b7e1 ]
    
    When variable refresh rate is active the hardware counter can return
    a position >= vtotal. This results in a vpos being returned from
    amdgpu_display_get_crtc_scanoutpos that's a positive value. The
    positive value indicates to the caller that the display is
    currently in scanout when the display is actually still in vblank.
    
    This is because the vfront porch duration is unknown with variable
    refresh active and will end when either a page flip occurs or the
    timeout specified by the driver/display is reached.
    
    The behavior of the amdgpu_display_get_crtc_scanoutpos remains the
    same when the position is below vtotal. When the position is above
    vtotal the function will return a value that is effectively -vbl_end,
    the size of the vback porch.
    
    The only caller affected by this change is the DRM helper for
    calculating vblank timestamps. This change corrects behavior for
    calculating the page flip timestamp from being the previous timestamp
    to the calculation to the next timestamp when position >= vtotal.
    
    Signed-off-by: Nicholas Kazlauskas <nicholas.kazlauskas@amd.com>
    Reviewed-by: Harry Wentland <harry.wentland@amd.com>
    Signed-off-by: Alex Deucher <alexander.deucher@amd.com>
    Signed-off-by: Sasha Levin <sashal@kernel.org>
    ---
     drivers/gpu/drm/amd/amdgpu/amdgpu_display.c | 7 ++++++-
     1 file changed, 6 insertions(+), 1 deletion(-)
    
    diff --git a/drivers/gpu/drm/amd/amdgpu/amdgpu_display.c b/drivers/gpu/drm/amd/amdgpu/amdgpu_display.c
    index 686a26de50f9..9c940bbed608 100644
    --- a/drivers/gpu/drm/amd/amdgpu/amdgpu_display.c
    +++ b/drivers/gpu/drm/amd/amdgpu/amdgpu_display.c
    @@ -857,7 +857,12 @@ int amdgpu_display_get_crtc_scanoutpos(struct drm_device *dev,
     	/* Inside "upper part" of vblank area? Apply corrective offset if so: */
     	if (in_vbl && (*vpos >= vbl_start)) {
     		vtotal = mode->crtc_vtotal;
    -		*vpos = *vpos - vtotal;
    +
    +		/* With variable refresh rate displays the vpos can exceed
    +		 * the vtotal value. Clamp to 0 to return -vbl_end instead
    +		 * of guessing the remaining number of lines until scanout.
    +		 */
    +		*vpos = (*vpos < vtotal) ? (*vpos - vtotal) : 0;
     	}
     
     	/* Correct for shifted end of vbl at vbl_end. */
    -- 
    2.19.1
    
    ^ permalink raw reply related	[flat|nested] 5+ messages in thread

  • end of thread, other threads:[~2019-01-08 19:30 UTC | newest]
    
    Thread overview: 5+ messages (download: mbox.gz follow: Atom feed
    -- links below jump to the message on this page --
         [not found] <20190108192949.122407-1-sashal@kernel.org>
         [not found] ` <20190108192949.122407-1-sashal-DgEjT+Ai2ygdnm+yROfE0A@public.gmane.org>
    2019-01-08 19:28   ` [PATCH AUTOSEL 4.19 03/97] drm/amd/display: Guard against null stream_state in set_crc_source Sasha Levin
    2019-01-08 19:28   ` [PATCH AUTOSEL 4.19 04/97] drm/amdkfd: fix interrupt spin lock Sasha Levin
    2019-01-08 19:28   ` [PATCH AUTOSEL 4.19 30/97] drm/amdgpu: Reorder uvd ring init before uvd resume Sasha Levin
    2019-01-08 19:28 ` [PATCH AUTOSEL 4.19 20/97] drm/atomic-helper: Complete fake_commit->flip_done potentially earlier Sasha Levin
    2019-01-08 19:28 ` [PATCH AUTOSEL 4.19 26/97] drm/amdgpu: Correct get_crtc_scanoutpos behavior when vpos >= vtotal Sasha Levin
    

    This is a public inbox, see mirroring instructions
    for how to clone and mirror all data and code used for this inbox