[PATCH 2/2] drm/msm/dpu: clean up some impossibilities
abhinavk at codeaurora.org
abhinavk at codeaurora.org
Tue Sep 8 20:52:58 UTC 2020
On 2020-09-08 13:11, Rob Clark wrote:
> On Tue, Sep 8, 2020 at 12:44 PM <abhinavk at codeaurora.org> wrote:
>>
>> On 2020-09-07 10:04, Rob Clark wrote:
>> > From: Rob Clark <robdclark at chromium.org>
>> >
>> > Signed-off-by: Rob Clark <robdclark at chromium.org>
Reviewed-by: Abhinav Kumar <abhinavk at codeaurora.org>
>> > ---
>> > drivers/gpu/drm/msm/disp/dpu1/dpu_crtc.c | 81 ++++--------------------
>> > 1 file changed, 12 insertions(+), 69 deletions(-)
>> >
>> > diff --git a/drivers/gpu/drm/msm/disp/dpu1/dpu_crtc.c
>> > b/drivers/gpu/drm/msm/disp/dpu1/dpu_crtc.c
>> > index 89c0245b5de5..ad49b0e17fcb 100644
>> > --- a/drivers/gpu/drm/msm/disp/dpu1/dpu_crtc.c
>> > +++ b/drivers/gpu/drm/msm/disp/dpu1/dpu_crtc.c
>> > @@ -265,11 +265,6 @@ enum dpu_intf_mode dpu_crtc_get_intf_mode(struct
>> > drm_crtc *crtc)
>> > {
>> > struct drm_encoder *encoder;
>> >
>> > - if (!crtc) {
>> > - DPU_ERROR("invalid crtc\n");
>> > - return INTF_MODE_NONE;
>> > - }
>> > -
>> > /*
>> > * TODO: This function is called from dpu debugfs and as part of
>> > atomic
>> > * check. When called from debugfs, the crtc->mutex must be held to
>> > @@ -500,12 +495,6 @@ static void dpu_crtc_atomic_begin(struct drm_crtc
>> > *crtc,
>> > struct dpu_crtc_state *cstate;
>> > struct drm_encoder *encoder;
>> > struct drm_device *dev;
>> > - unsigned long flags;
>> > -
>> > - if (!crtc) {
>> > - DPU_ERROR("invalid crtc\n");
>> > - return;
>> > - }
>> >
>> > if (!crtc->state->enable) {
>> > DPU_DEBUG("crtc%d -> enable %d, skip atomic_begin\n",
>> > @@ -521,15 +510,6 @@ static void dpu_crtc_atomic_begin(struct drm_crtc
>> > *crtc,
>> >
>> > _dpu_crtc_setup_lm_bounds(crtc, crtc->state);
>> >
>> > - if (dpu_crtc->event) {
>> > - WARN_ON(dpu_crtc->event);
>> > - } else {
>> > - spin_lock_irqsave(&dev->event_lock, flags);
>> > - dpu_crtc->event = crtc->state->event;
>> > - crtc->state->event = NULL;
>> > - spin_unlock_irqrestore(&dev->event_lock, flags);
>> > - }
>> > -
>> > /* encoder will trigger pending mask now */
>> > drm_for_each_encoder_mask(encoder, crtc->dev,
>> > crtc->state->encoder_mask)
>> > dpu_encoder_trigger_kickoff_pending(encoder);
>> > @@ -583,14 +563,11 @@ static void dpu_crtc_atomic_flush(struct drm_crtc
>> > *crtc,
>> > return;
>> > }
>> >
>> > - if (dpu_crtc->event) {
>> > - DPU_DEBUG("already received dpu_crtc->event\n");
>> > - } else {
>> > - spin_lock_irqsave(&dev->event_lock, flags);
>> > - dpu_crtc->event = crtc->state->event;
>> > - crtc->state->event = NULL;
>> > - spin_unlock_irqrestore(&dev->event_lock, flags);
>> > - }
>> > + WARN_ON(dpu_crtc->event);
>> before the patch "move vblank events to complete_commit()", the
>> dpu_crtc
>> events
>> were consumed in the _dpu_crtc_complete_flip(). So there was a chance
>> that if the vblank event
>> did not come in time before the next commit, dpu_crtc->event will not
>> be
>> consumed.
>>
>> But after the patch, _dpu_crtc_complete_flip() is being signaled in
>> dpu_crtc_complete_commit()
>> which will always happen, so is there any case where we will hit this
>> warning at all or will this
>> catch some other condition?
>
> The core drm-atomic bits will reject an incoming atomic update if the
> previous one has not completed, so other than a coding bug, this
> WARN_ON() should not be hit.. it's only purpose is to make it very
> obvious if someone breaks something :-)
>
> BR,
> -R
>
>>
>> > + spin_lock_irqsave(&dev->event_lock, flags);
>> > + dpu_crtc->event = crtc->state->event;
>> > + crtc->state->event = NULL;
>> > + spin_unlock_irqrestore(&dev->event_lock, flags);
>> >
>> > /*
>> > * If no mixers has been allocated in dpu_crtc_atomic_check(),
>> > @@ -635,14 +612,7 @@ static void dpu_crtc_atomic_flush(struct drm_crtc
>> > *crtc,
>> > static void dpu_crtc_destroy_state(struct drm_crtc *crtc,
>> > struct drm_crtc_state *state)
>> > {
>> > - struct dpu_crtc_state *cstate;
>> > -
>> > - if (!crtc || !state) {
>> > - DPU_ERROR("invalid argument(s)\n");
>> > - return;
>> > - }
>> > -
>> > - cstate = to_dpu_crtc_state(state);
>> > + struct dpu_crtc_state *cstate = to_dpu_crtc_state(state);
>> >
>> > DPU_DEBUG("crtc%d\n", crtc->base.id);
>> >
>> > @@ -731,14 +701,8 @@ static void dpu_crtc_reset(struct drm_crtc *crtc)
>> > */
>> > static struct drm_crtc_state *dpu_crtc_duplicate_state(struct drm_crtc
>> > *crtc)
>> > {
>> > - struct dpu_crtc_state *cstate, *old_cstate;
>> > -
>> > - if (!crtc || !crtc->state) {
>> > - DPU_ERROR("invalid argument(s)\n");
>> > - return NULL;
>> > - }
>> > + struct dpu_crtc_state *cstate, *old_cstate =
>> > to_dpu_crtc_state(crtc->state);
>> >
>> > - old_cstate = to_dpu_crtc_state(crtc->state);
>> > cstate = kmemdup(old_cstate, sizeof(*old_cstate), GFP_KERNEL);
>> > if (!cstate) {
>> > DPU_ERROR("failed to allocate state\n");
>> > @@ -754,19 +718,12 @@ static struct drm_crtc_state
>> > *dpu_crtc_duplicate_state(struct drm_crtc *crtc)
>> > static void dpu_crtc_disable(struct drm_crtc *crtc,
>> > struct drm_crtc_state *old_crtc_state)
>> > {
>> > - struct dpu_crtc *dpu_crtc;
>> > - struct dpu_crtc_state *cstate;
>> > + struct dpu_crtc *dpu_crtc = to_dpu_crtc(crtc);
>> > + struct dpu_crtc_state *cstate = to_dpu_crtc_state(crtc->state);
>> > struct drm_encoder *encoder;
>> > unsigned long flags;
>> > bool release_bandwidth = false;
>> >
>> > - if (!crtc || !crtc->state) {
>> > - DPU_ERROR("invalid crtc\n");
>> > - return;
>> > - }
>> > - dpu_crtc = to_dpu_crtc(crtc);
>> > - cstate = to_dpu_crtc_state(crtc->state);
>> > -
>> > DRM_DEBUG_KMS("crtc%d\n", crtc->base.id);
>> >
>> > /* Disable/save vblank irq handling */
>> > @@ -825,19 +782,13 @@ static void dpu_crtc_disable(struct drm_crtc
>> > *crtc,
>> > static void dpu_crtc_enable(struct drm_crtc *crtc,
>> > struct drm_crtc_state *old_crtc_state)
>> > {
>> > - struct dpu_crtc *dpu_crtc;
>> > + struct dpu_crtc *dpu_crtc = to_dpu_crtc(crtc);
>> > struct drm_encoder *encoder;
>> > bool request_bandwidth = false;
>> >
>> > - if (!crtc) {
>> > - DPU_ERROR("invalid crtc\n");
>> > - return;
>> > - }
>> > -
>> > pm_runtime_get_sync(crtc->dev->dev);
>> >
>> > DRM_DEBUG_KMS("crtc%d\n", crtc->base.id);
>> > - dpu_crtc = to_dpu_crtc(crtc);
>> >
>> > drm_for_each_encoder_mask(encoder, crtc->dev,
>> > crtc->state->encoder_mask) {
>> > /* in video mode, we hold an extra bandwidth reference
>> > @@ -873,9 +824,9 @@ struct plane_state {
>> > static int dpu_crtc_atomic_check(struct drm_crtc *crtc,
>> > struct drm_crtc_state *state)
>> > {
>> > - struct dpu_crtc *dpu_crtc;
>> > + struct dpu_crtc *dpu_crtc = to_dpu_crtc(crtc);
>> > + struct dpu_crtc_state *cstate = to_dpu_crtc_state(state);
>> > struct plane_state *pstates;
>> > - struct dpu_crtc_state *cstate;
>> >
>> > const struct drm_plane_state *pstate;
>> > struct drm_plane *plane;
>> > @@ -889,16 +840,8 @@ static int dpu_crtc_atomic_check(struct drm_crtc
>> > *crtc,
>> > int left_zpos_cnt = 0, right_zpos_cnt = 0;
>> > struct drm_rect crtc_rect = { 0 };
>> >
>> > - if (!crtc) {
>> > - DPU_ERROR("invalid crtc\n");
>> > - return -EINVAL;
>> > - }
>> > -
>> > pstates = kzalloc(sizeof(*pstates) * DPU_STAGE_MAX * 4, GFP_KERNEL);
>> >
>> > - dpu_crtc = to_dpu_crtc(crtc);
>> > - cstate = to_dpu_crtc_state(state);
>> > -
>> > if (!state->enable || !state->active) {
>> > DPU_DEBUG("crtc%d -> enable %d, active %d, skip atomic_check\n",
>> > crtc->base.id, state->enable, state->active);
> _______________________________________________
> dri-devel mailing list
> dri-devel at lists.freedesktop.org
> https://lists.freedesktop.org/mailman/listinfo/dri-devel
More information about the dri-devel
mailing list