[PATCH] drm/amd/display: Ensure valid event timestamp for cursor-only commits

Harry Wentland harry.wentland at amd.com
Tue Jul 12 18:31:14 UTC 2022


On 2022-07-12 11:23, Alex Deucher wrote:
> On Mon, Jul 11, 2022 at 10:51 AM Michel Dänzer <michel at daenzer.net> wrote:
>>
>> From: Michel Dänzer <mdaenzer at redhat.com>
>>
>> Requires enabling the vblank machinery for them.
>>
>> Bug: https://gitlab.freedesktop.org/drm/amd/-/issues/2030>>> Signed-off-by: Michel Dänzer <mdaenzer at redhat.com>
> 
> This looks correct to me, but it would be good if one of the display
> guys could take a look.
> Acked-by: Alex Deucher <alexander.deucher at amd.com>
> 

Looks fine to me.

Reviewed-by: Harry Wentland <harry.wentland at amd.com>

Harry

> Alex
> 
>> ---
>>  .../gpu/drm/amd/display/amdgpu_dm/amdgpu_dm.c | 43 +++++++++++++++++--
>>  1 file changed, 40 insertions(+), 3 deletions(-)
>>
>> diff --git a/drivers/gpu/drm/amd/display/amdgpu_dm/amdgpu_dm.c b/drivers/gpu/drm/amd/display/amdgpu_dm/amdgpu_dm.c
>> index 9dd2e0601ea8..b0667e2f3fdd 100644
>> --- a/drivers/gpu/drm/amd/display/amdgpu_dm/amdgpu_dm.c
>> +++ b/drivers/gpu/drm/amd/display/amdgpu_dm/amdgpu_dm.c
>> @@ -462,6 +462,26 @@ static void dm_pflip_high_irq(void *interrupt_params)
>>                      vrr_active, (int) !e);
>>  }
>>
>> +static void dm_crtc_handle_vblank(struct amdgpu_crtc *acrtc)
>> +{
>> +       struct drm_crtc *crtc = &acrtc->base;
>> +       struct drm_device *dev = crtc->dev;
>> +       unsigned long flags;
>> +
>> +       drm_crtc_handle_vblank(crtc);
>> +
>> +       spin_lock_irqsave(&dev->event_lock, flags);
>> +
>> +       /* Send completion event for cursor-only commits */
>> +       if (acrtc->event && acrtc->pflip_status != AMDGPU_FLIP_SUBMITTED) {
>> +               drm_crtc_send_vblank_event(crtc, acrtc->event);
>> +               drm_crtc_vblank_put(crtc);
>> +               acrtc->event = NULL;
>> +       }
>> +
>> +       spin_unlock_irqrestore(&dev->event_lock, flags);
>> +}
>> +
>>  static void dm_vupdate_high_irq(void *interrupt_params)
>>  {
>>         struct common_irq_params *irq_params = interrupt_params;
>> @@ -500,7 +520,7 @@ static void dm_vupdate_high_irq(void *interrupt_params)
>>                  * if a pageflip happened inside front-porch.
>>                  */
>>                 if (vrr_active) {
>> -                       drm_crtc_handle_vblank(&acrtc->base);
>> +                       dm_crtc_handle_vblank(acrtc);
>>
>>                         /* BTR processing for pre-DCE12 ASICs */
>>                         if (acrtc->dm_irq_params.stream &&
>> @@ -552,7 +572,7 @@ static void dm_crtc_high_irq(void *interrupt_params)
>>          * to dm_vupdate_high_irq after end of front-porch.
>>          */
>>         if (!vrr_active)
>> -               drm_crtc_handle_vblank(&acrtc->base);
>> +               dm_crtc_handle_vblank(acrtc);
>>
>>         /**
>>          * Following stuff must happen at start of vblank, for crc
>> @@ -9134,6 +9154,7 @@ static void amdgpu_dm_commit_planes(struct drm_atomic_state *state,
>>         struct amdgpu_bo *abo;
>>         uint32_t target_vblank, last_flip_vblank;
>>         bool vrr_active = amdgpu_dm_vrr_active(acrtc_state);
>> +       bool cursor_update = false;
>>         bool pflip_present = false;
>>         struct {
>>                 struct dc_surface_update surface_updates[MAX_SURFACES];
>> @@ -9169,8 +9190,13 @@ static void amdgpu_dm_commit_planes(struct drm_atomic_state *state,
>>                 struct dm_plane_state *dm_new_plane_state = to_dm_plane_state(new_plane_state);
>>
>>                 /* Cursor plane is handled after stream updates */
>> -               if (plane->type == DRM_PLANE_TYPE_CURSOR)
>> +               if (plane->type == DRM_PLANE_TYPE_CURSOR) {
>> +                       if ((fb && crtc == pcrtc) ||
>> +                           (old_plane_state->fb && old_plane_state->crtc == pcrtc))
>> +                               cursor_update = true;
>> +
>>                         continue;
>> +               }
>>
>>                 if (!fb || !crtc || pcrtc != crtc)
>>                         continue;
>> @@ -9333,6 +9359,17 @@ static void amdgpu_dm_commit_planes(struct drm_atomic_state *state,
>>                                 bundle->stream_update.vrr_infopacket =
>>                                         &acrtc_state->stream->vrr_infopacket;
>>                 }
>> +       } else if (cursor_update && acrtc_state->active_planes > 0 &&
>> +                  !acrtc_state->force_dpms_off &&
>> +                  acrtc_attach->base.state->event) {
>> +               drm_crtc_vblank_get(pcrtc);
>> +
>> +               spin_lock_irqsave(&pcrtc->dev->event_lock, flags);
>> +
>> +               acrtc_attach->event = acrtc_attach->base.state->event;
>> +               acrtc_attach->base.state->event = NULL;
>> +
>> +               spin_unlock_irqrestore(&pcrtc->dev->event_lock, flags);
>>         }
>>
>>         /* Update the planes if changed or disable if we don't have any. */
>> --
>> 2.36.1
>>



More information about the amd-gfx mailing list