1. 10 Apr, 2019 29 commits
  2. 04 Apr, 2019 1 commit
  3. 03 Apr, 2019 10 commits
    • Nicholas Kazlauskas's avatar
      drm/amd/display: Prevent cursor hotspot overflow for RV overlay planes · 6752bea8
      Nicholas Kazlauskas authored
      [Why]
      The actual position for the cursor on the screen is essentially:
      
      x_out = x - x_plane - x_hotspot
      y_out = y - y_plane - y_hotspot
      
      The register values for cursor position and cursor hotspot need to be
      greater than zero when programmed, but we also need to subtract off
      the plane position to display the cursor at the correct position.
      
      Since we don't want x or y to be less than zero, we add the plane
      position as a positive value to x_hotspot or y_hotspot. However, what
      this doesn't take into account is that the hotspot registers are limited
      by the maximum cursor size.
      
      On DCN10 the cursor hotspot regitsers are masked to 0xFF, so they have
      a maximum value of 0-255. Values greater this will wrap, causing the
      cursor to display in the wrong position.
      
      In practice this means that for sufficiently large plane positions, the
      cursor will be drawn twice on the screen, and can cause screen flashes
      or p-state WARNS depending on what the wrapped value is.
      
      So we need a way to remove the value from x_plane and y_plane without
      exceeding the maximum cursor size.
      
      [How]
      Subtract as much as x_plane/y_plane as possible from x and y and place
      the remainder in the cursor hotspot register.
      
      The value for x_hotspot and y_hotspot can still wrap around but it
      won't happen in a case where the cursor is actually enabled.
      
      The cursor plane needs to intersect at least one pixel of the plane's
      rectangle to be enabled, so the cursor position + hotspot provided by
      userspace must always be strictly less than the maximum cursor size for
      the cursor to actually be enabled.
      Signed-off-by: default avatarNicholas Kazlauskas <nicholas.kazlauskas@amd.com>
      Reviewed-by: default avatarSun peng Li <Sunpeng.Li@amd.com>
      Acked-by: default avatarBhawanpreet Lakha <Bhawanpreet.Lakha@amd.com>
      Signed-off-by: default avatarAlex Deucher <alexander.deucher@amd.com>
      6752bea8
    • Leo Li's avatar
      drm/amd/display: Fix "dc has no member named dml" compile error · 805ab8f7
      Leo Li authored
      For DCN disabled builds, dc->dml is stripped out. Therefore, guard usage
      in dc_create_state() with CONFIG_DRM_AMD_DC_DCN1_0.
      
      It fixes the following error:
      
      drivers/gpu/drm/amd/amdgpu/../display/dc/core/dc.c: In function 'dc_create_state':
      >> drivers/gpu/drm/amd/amdgpu/../display/dc/core/dc.c:1237:34: error: 'struct dc' has no member named 'dml'
           memcpy(&context->bw_ctx.dml, &dc->dml, sizeof(struct display_mode_lib));
                                           ^~
      Signed-off-by: default avatarLeo Li <sunpeng.li@amd.com>
      Acked-by: default avatarAlex Deucher <alexander.deucher@amd.com>
      Reviewed-by: default avatarNicholas Kazlauskas <nicholas.kazlauskas@amd.com>
      Signed-off-by: default avatarAlex Deucher <alexander.deucher@amd.com>
      805ab8f7
    • Aidan Wood's avatar
      drm/amd/display: Fix multi-thread writing to 1 state · 813d20dc
      Aidan Wood authored
      [Why]
      Multiple threads were writing back to one global VBA in DC resulting
      in multiple threads overwriting eachother's data
      
      [How]
      Add an instance of DML (which contains VBA) to each context and
      change all calls that used dc->dml to use context->dml. Created a
      seperate copy constructor for linux in a case where there is no
      access to DC.
      Signed-off-by: default avatarAidan Wood <Aidan.Wood@amd.com>
      Reviewed-by: default avatarJun Lei <Jun.Lei@amd.com>
      Acked-by: default avatarBhawanpreet Lakha <Bhawanpreet.Lakha@amd.com>
      Signed-off-by: default avatarAlex Deucher <alexander.deucher@amd.com>
      813d20dc
    • 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
    • Mario Kleiner's avatar
      drm/amd/display: In VRR mode, do DRM core vblank handling at end of vblank. (v2) · d2574c33
      Mario Kleiner authored
      In VRR mode, proper vblank/pageflip timestamps can only be computed
      after the display scanout position has left front-porch. Therefore
      delay calls to drm_crtc_handle_vblank(), and thereby calls to
      drm_update_vblank_count() and pageflip event delivery, to after the
      end of front-porch when in VRR mode.
      
      We add a new vupdate irq, which triggers at the end of the vupdate
      interval, ie. at the end of vblank, and calls the core vblank handler
      function. The new irq handler is not executed in standard non-VRR
      mode, so vblank handling for fixed refresh rate mode is identical
      to the past implementation.
      
      v2: Implement feedback by Nicholas and Paul Menzel.
      Signed-off-by: default avatarMario Kleiner <mario.kleiner.de@gmail.com>
      Acked-by: default avatarHarry Wentland <harry.wentland@amd.com>
      Reviewed-by: default avatarNicholas Kazlauskas <Nicholas.Kazlauskas@amd.com>
      Signed-off-by: default avatarAlex Deucher <alexander.deucher@amd.com>
      d2574c33
    • Mario Kleiner's avatar
      drm/amd/display: Rework vrr flip throttling for late vblank irq. · fdd1fe57
      Mario Kleiner authored
      For throttling to work correctly, we always need a baseline vblank
      count last_flip_vblank that increments at start of front-porch.
      
      This is the case for drm_crtc_vblank_count() in non-VRR mode, where
      the vblank irq fires at start of front-porch and triggers DRM core
      vblank handling, but it is no longer the case in VRR mode, where
      core vblank handling is done later, after end of front-porch.
      
      Therefore drm_crtc_vblank_count() is no longer useful for this.
      We also can't use drm_crtc_accurate_vblank_count(), as that would
      screw up vblank timestamps in VRR mode when called in front-porch.
      
      To solve this, use the cooked hardware vblank counter returned by
      amdgpu_get_vblank_counter_kms() instead, as that one is cooked to
      always increment at start of front-porch, independent of when
      vblank related irq's fire.
      
      This patch allows vblank irq handling to happen anywhere within
      vblank of even after it, without a negative impact on flip
      throttling, so followup patches can shift the vblank core
      handling trigger point wherever they need it.
      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>
      fdd1fe57
    • Mario Kleiner's avatar
      drm/amd/display: Prevent vblank irq disable while VRR is active. (v3) · 66b0c973
      Mario Kleiner authored
      During VRR mode we can not allow vblank irq dis-/enable
      transitions, as an enable after a disable can happen at
      an arbitrary time during the video refresh cycle, e.g.,
      with a high likelyhood inside vblank front-porch. An
      enable during front-porch would cause vblank timestamp
      updates/calculations which are completely bogus, given
      the code can't know when the vblank will end as long
      as we are in front-porch with no page flip completed.
      
      Hold a permanent vblank reference on the crtc while
      in active VRR mode to prevent a vblank disable, and
      drop the reference again when switching back to fixed
      refresh rate non-VRR mode.
      
      v2: Make sure transition is also handled if vrr is
          disabled and stream gets disabled in the same
          atomic commit by moving the call to the transition
          function outside of plane commit.
          Suggested by Nicholas.
      
      v3: Trivial rebase onto previous patch.
      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>
      66b0c973
    • Mario Kleiner's avatar
      drm/amd/display: Update VRR state earlier in atomic_commit_tail. · e854194c
      Mario Kleiner authored
      We need the VRR active/inactive state info earlier in
      the commit sequence, so VRR related setup functions like
      amdgpu_dm_handle_vrr_transition() know the final VRR state
      when they need to do their hw setup work.
      
      Split update_freesync_state_on_stream() into an early part,
      that can run at the beginning of commit tail before the
      vrr transition handling, and a late part that must run after
      vrr transition handling inside the commit planes code for
      enabled crtc's.
      
      Suggested by Nicholas Kazlauskas.
      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>
      e854194c
    • Kent Russell's avatar
      drm/amdgpu: Allow switching to CUSTOM profile on Vega20 · e178f107
      Kent Russell authored
      Vega20 stores a CUSTOM profile on the GPU, but it may not be valid. Add
      a bool to vega20_hwmgr to determine whether or not a valid CUSTOM
      profile has been set, and use that to check when a user requests
      switching to the CUSTOM profile without passing in any arguments. Then
      if the CUSTOM profile has been set already, we can switch to it without
      providing the parameters again
      Signed-off-by: default avatarKent Russell <kent.russell@amd.com>
      Reviewed-by: default avatarEvan Quan <evan.quan@amd.com>
      Signed-off-by: default avatarAlex Deucher <alexander.deucher@amd.com>
      e178f107
    • Kent Russell's avatar
      drm/amdgpu: Allow switching to CUSTOM profile on Vega10 v2 · bbdf38cc
      Kent Russell authored
      Don't return an error if the CUSTOM profile is selected, just apply it
      with the values saved to the GPU. But ensure that we zero out the
      copy stored in adev to ensure that a valid profile has been submitted at
      some point first
      
      v2: Fix comment that wasn't updated from previous patch
      Signed-off-by: default avatarKent Russell <kent.russell@amd.com>
      Reviewed-by: default avatarEvan Quan <evan.quan@amd.com>
      Signed-off-by: default avatarAlex Deucher <alexander.deucher@amd.com>
      bbdf38cc