• Ville Syrjälä's avatar
    drm/i915: Perform vblank evasion around legacy cursor updates · 1de63528
    Ville Syrjälä authored
    Our legacy cursor updates are actually mailbox updates.
    Ie. the hardware latches things once per frame on start of
    vblank, but we issue an number of updates per frame,
    withough any attempt to synchronize against the vblank
    in software. So in theory only the last update issued
    during the frame will latch, and the previous ones are
    discarded.
    
    However this can lead to problems with maintaining the
    ggtt/iommu mappings as we have no idea which updates
    will actually latch.
    
    The problem is exacerbated by the hardware's annoying disarming
    behaviour; any non-arming register write will disarm an already
    armed update, only to be rearmed later by the arming register
    (CURBASE in case of cursors). If a disarming write happens
    just before the start of vblank, and the arming write happens
    after start of vblank we have effectively prevented the hardware
    from latching anything. And if we manage to straddle multiple
    sequential vblank starts in this manner we effectively prevent
    the hardware from latching any new registers for an arbitrary
    amount of time. This provides more time for the (potentially
    still in use by the hardware) gtt/iommu mappings to be torn
    down.
    
    A partial solution, of course, is to use vblank evasion to
    avoid the register writes from spreading on both sides of
    the start of vblank.
    
    I've previously highlighted this problem as a general issue
    affecting mailbox updates. I even added some notes to the
    {i9xx,skl}_crtc_planes_update_arm() to remind us that the noarm
    and arm phases both need to pulled into the vblank evasion
    critical section if we actually decided to implement mailbox
    updates in general. But as I never impelemented the noarm+arm
    split for cursors we don't have to worry about that for the
    moment.
    
    We've been lucky enough so far that this hasn't really caused
    problems. One thing that does help is that Xorg generally
    sticks to the same cursor BO. But igt seems pretty good at
    hitting this on MTL now, so apparently we have to start
    thinking about this.
    
    v2: Wait for PSR exit to avoid the vblank evasion timeout (1ms)
        tripping due to PSR exit latency (~5ms typically)
    Reviewed-by: default avatarUma Shankar <uma.shankar@intel.com>
    Signed-off-by: default avatarVille Syrjälä <ville.syrjala@linux.intel.com>
    Link: https://patchwork.freedesktop.org/patch/msgid/20240116204927.23499-1-ville.syrjala@linux.intel.comReviewed-by: default avatarJouni Högander <jouni.hogander@intel.com>
    Reviewed-by: default avatarUma Shankar <uma.shankar@intel.com>
    1de63528
intel_cursor.c 24.8 KB