Thank you for your contribution! Sashiko AI review found 2 potential
issues to consider:
- [Medium] drm/i915: unreachable noop check in
  intel_crtc_complete_noop_async_flip()
- [Medium] drm/i915: intel_crtc_complete_noop_async_flip() checks
  cleared uapi.event
--

commit 828bac38a449130d5473b2a45f7f646152241cec
Author: Ville Syrjälä <[email protected]>

drm/i915: Complete no-op "async flips" by hand

This commit adds helpers to manually send the vblank event for atomic
async flip commits when no planes are updated.

> diff --git a/drivers/gpu/drm/i915/display/intel_display.c 
> b/drivers/gpu/drm/i915/display/intel_display.c
> index f79caeb5a82ec..dd12929284bb8 100644
> --- a/drivers/gpu/drm/i915/display/intel_display.c
> +++ b/drivers/gpu/drm/i915/display/intel_display.c
> @@ -1190,6 +1190,42 @@ static void intel_crtc_disable_flip_done(struct 
> intel_atomic_state *state,
>       }
>  }
>  
> +static void intel_crtc_complete_noop_async_flip(struct intel_crtc_state 
> *crtc_state)
> +{
> +     struct intel_display *display = to_intel_display(crtc_state);
> +     struct intel_crtc *crtc = to_intel_crtc(crtc_state->uapi.crtc);
> +
> +     if (!crtc_state->do_async_flip)
> +             return;
> +
> +     /*
> +      * If there are planes actually performing the async flip then
> +      * the commit will be completed via the flip done interrupt
> +      * handler. For a fully no-op "async flip" the commit must
> +      * be completed by hand as no interrupt will be raised.
> +      */
> +     if (crtc_state->update_planes)
> +             return;

[Severity: Medium]
Can crtc_state->do_async_flip ever be true when crtc_state->update_planes
is zero?

intel_crtc_duplicate_state() initializes both fields to zero/false, and the
only place that sets new_crtc_state->do_async_flip = true is
intel_plane_atomic_check_with_state() -> intel_plane_atomic_calc_changes()
for a visible plane, after intel_plane_atomic_check_with_state() has
already set BIT(plane->id) in new_crtc_state->update_planes:

drivers/gpu/drm/i915/display/intel_plane.c:intel_plane_atomic_check_with_state()
 {
        ...
        if (new_plane_state->uapi.visible || old_plane_state->uapi.visible)
                new_crtc_state->update_planes |= BIT(plane->id);
        ...
        return intel_plane_atomic_calc_changes(old_crtc_state, new_crtc_state,
                                               old_plane_state, 
new_plane_state);
}

When no visible planes are in the atomic state, crtc_state->do_async_flip
remains false (unlike crtc_state->uapi.async_flip), so this function always
returns early on the first check and never completes a no-op async flip.

> +
> +     if (crtc_state->uapi.event) {
> +             spin_lock_irq(&display->drm->event_lock);
> +             drm_crtc_send_vblank_event(&crtc->base,
> +                                        crtc_state->uapi.event);
> +             spin_unlock_irq(&display->drm->event_lock);
> +
> +             crtc_state->uapi.event = NULL;
> +     }
> +}

[Severity: Medium]
Will crtc_state->uapi.event always be NULL by the time
intel_crtc_complete_noop_async_flip() runs?

In intel_atomic_commit_tail(), commit_modeset_enables() runs before
intel_atomic_complete_noop_async_flips().  When new_crtc_state->do_async_flip
is true, intel_update_crtc() -> intel_pipe_update_start() calls
intel_crtc_prepare_vblank_event(new_crtc_state, &crtc->flip_done_event),
which moves new_crtc_state->uapi.event into crtc->flip_done_event and sets
new_crtc_state->uapi.event = NULL.  With update_planes == 0, no flip-done
interrupt will fire to consume crtc->flip_done_event, leaving the event
unsent and causing drm_atomic_helper_wait_for_flip_done() to time out.

-- 
Sashiko AI review · 
https://sashiko.dev/#/patchset/[email protected]?part=10

Reply via email to