• Michael Spang's avatar
    ozone: drm: Clean up error handling around page flips · bb1059e5
    Michael Spang authored
    The page flip code mixes two error handling styles and in many cases
    returns the same status (or in some cases, inconsistent statuses) through
    the return value and also via the SwapCompletionCallback.
    
    The page flip code also supports two modes: real page flips and test page
    flips, which are used to validate configurations before use. Real page
    flips crash the GPU process if the return value indicates failure, but
    obviously this is not expected to occur so in practice those always
    return success, and pass status information through the
    SwapCompletionCallback. Test page flips are the opposite: they must
    return their status in the return value, and pass a dummy completion
    callback which ignores its arguments.
    
    There are actually no asynchronous failure cases, despite a fair amount
    of code trying to account for that possibility such as the coalescing of
    SwapResults in PageFlipRequest. We can take advantage of this to avoid
    passing the SwapCompletionCallback into most functions, and simply use
    the return value as the only status return. The only complication is that
    successful completion is always asynchronous, and may even require
    tracking multiple underlying page flip events, as in hardware mirroring
    scenarios.
    
    This patch handles that issue by registering PageFlipCallbacks for all of
    the individual page flip events as usual, but only passing ownership of
    the SwapCompletionCallback into the PageFlipRequest at the last minute,
    after all of the individual page flips have been submitted succesfully.
    
    After hiding the SwapCompletionCallback from most of the DRM internals,
    test page flips no longer need to construct a dummy
    SwapCompletionCallback. They also don't need to construct any
    PageFlipCallbacks, since they don't generate any page flip events - this
    simplifies that logic as well by moving construction of each
    PageFlipCallback to immediately after a successful page flip request.
    Moving creation of those callbacks later also removes any requirement to
    make manual calls to PageFlipRequest::Signal to fixup failure cases.
    
    Since failures of real page flips triggered by SchedulePageFlip() simply
    crash the process, there is no need for a return value. This patch moves
    the CHECK() which cause these crashes inside of SchedulePageFlip(), and
    removes the return value.
    
    As a result, TestPageFlip() and all of the internal methods called via
    ActualSchedulePageFlip() use return values exclusively for status
    information, and never see the SwapCompletionCallback.
    SchedulePageFlip(), on the other hand, receives the SwapCompletionCallack
    and uses it exclusively for its status, and returns void.
    
    Bug: 851997
    Test: unit tests, various display configurations on cros
    
    Change-Id: I87408275b0958281ef79a6b5086a38b2c3c08ee1
    Reviewed-on: https://chromium-review.googlesource.com/1104859
    Commit-Queue: Michael Spang <spang@chromium.org>
    Reviewed-by: default avatarDaniel Nicoara <dnicoara@chromium.org>
    Cr-Commit-Position: refs/heads/master@{#569973}
    bb1059e5
drm_window.h 4.42 KB