• Mario Kleiner's avatar
    drm/amd/display: Make pageflip event delivery compatible with VRR. · 71bbe51a
    Mario Kleiner authored
    We want vblank counts and timestamps of flip completion as sent
    in pageflip completion events to be consistent with the vblank
    count and timestamp of the vblank of flip completion, like in non
    VRR mode.
    
    In VRR mode, drm_update_vblank_count() - and thereby vblank
    count and timestamp updates - must be delayed until after the
    end of front-porch of each vblank, as it is only safe to
    calculate vblank timestamps outside of the front-porch, when
    we actually know when the vblank will end or has ended.
    
    The function drm_update_vblank_count() which updates timestamps
    and counts gets called by drm_crtc_accurate_vblank_count() or by
    drm_crtc_handle_vblank().
    
    Therefore we must make sure that pageflip events for a completed
    flip are only sent out after drm_crtc_accurate_vblank_count() or
    drm_crtc_handle_vblank() is executed, after end of front-porch
    for the vblank of flip completion.
    
    Two cases:
    
    a) Pageflip irq handler executes inside front-porch:
       In this case we must defer sending pageflip events until
       drm_crtc_handle_vblank() executes after end of front-porch,
       and thereby calculates proper vblank count and timestamp.
       Iow. the pflip irq handler must just arm a pageflip event
       to be sent out by drm_crtc_handle_vblank() later on.
    
    b) Pageflip irq handler executes after end of front-porch, e.g.,
       after flip completion in back-porch or due to a massively
       delayed handler invocation into the active scanout of the new
       frame. In this case we can call drm_crtc_accurate_vblank_count()
       to safely force calculation of a proper vblank count and
       timestamp, and must send the pageflip completion event
       ourselves from the pageflip irq handler.
    
       This is the same behaviour as needed for standard fixed refresh
       rate mode.
    
    To decide from within pageflip handler if we are in case a) or b),
    we check the current scanout position against the boundary of
    front-porch. In non-VRR mode we just do what we did in the past.
    Signed-off-by: default avatarMario Kleiner <mario.kleiner.de@gmail.com>
    Reviewed-by: default avatarNicholas Kazlauskas <Nicholas.Kazlauskas@amd.com>
    Signed-off-by: default avatarAlex Deucher <alexander.deucher@amd.com>
    71bbe51a
amdgpu_dm.c 181 KB