Skip to content

Commit 3ae133b

Browse files
lumagAbhinav Kumar
authored andcommitted
drm/msm/dpu: move CRTC resource assignment to dpu_encoder_virt_atomic_check
Historically CRTC resources (LMs and CTLs) were assigned in dpu_crtc_atomic_begin(). The commit 9222cdd ("drm/msm/dpu: move hw resource tracking to crtc state") simply moved resources to struct dpu_crtc_state, without changing the code sequence. Later on the commit b107603 ("drm/msm/dpu: map mixer/ctl hw blocks in encoder modeset") rearanged the code, but still kept the cstate->num_mixers assignment to happen during commit phase. This makes dpu_crtc_state inconsistent between consequent atomic_check() calls. Move CRTC resource assignment to happen at the end of dpu_encoder_virt_atomic_check(). Fixes: b107603 ("drm/msm/dpu: map mixer/ctl hw blocks in encoder modeset") Signed-off-by: Dmitry Baryshkov <[email protected]> Reviewed-by: Abhinav Kumar <[email protected]> Patchwork: https://patchwork.freedesktop.org/patch/612235/ Link: https://lore.kernel.org/r/[email protected] Signed-off-by: Abhinav Kumar <[email protected]>
1 parent bfecbc2 commit 3ae133b

File tree

2 files changed

+38
-24
lines changed

2 files changed

+38
-24
lines changed

drivers/gpu/drm/msm/disp/dpu1/dpu_crtc.c

Lines changed: 0 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1091,9 +1091,6 @@ static void dpu_crtc_disable(struct drm_crtc *crtc,
10911091

10921092
dpu_core_perf_crtc_update(crtc, 0);
10931093

1094-
memset(cstate->mixers, 0, sizeof(cstate->mixers));
1095-
cstate->num_mixers = 0;
1096-
10971094
/* disable clk & bw control until clk & bw properties are set */
10981095
cstate->bw_control = false;
10991096
cstate->bw_split_vote = false;

drivers/gpu/drm/msm/disp/dpu1/dpu_encoder.c

Lines changed: 38 additions & 21 deletions
Original file line numberDiff line numberDiff line change
@@ -624,6 +624,40 @@ static struct msm_display_topology dpu_encoder_get_topology(
624624
return topology;
625625
}
626626

627+
static void dpu_encoder_assign_crtc_resources(struct dpu_kms *dpu_kms,
628+
struct drm_encoder *drm_enc,
629+
struct dpu_global_state *global_state,
630+
struct drm_crtc_state *crtc_state)
631+
{
632+
struct dpu_crtc_state *cstate;
633+
struct dpu_hw_blk *hw_ctl[MAX_CHANNELS_PER_ENC];
634+
struct dpu_hw_blk *hw_lm[MAX_CHANNELS_PER_ENC];
635+
struct dpu_hw_blk *hw_dspp[MAX_CHANNELS_PER_ENC];
636+
int num_lm, num_ctl, num_dspp, i;
637+
638+
cstate = to_dpu_crtc_state(crtc_state);
639+
640+
memset(cstate->mixers, 0, sizeof(cstate->mixers));
641+
642+
num_ctl = dpu_rm_get_assigned_resources(&dpu_kms->rm, global_state,
643+
drm_enc->base.id, DPU_HW_BLK_CTL, hw_ctl, ARRAY_SIZE(hw_ctl));
644+
num_lm = dpu_rm_get_assigned_resources(&dpu_kms->rm, global_state,
645+
drm_enc->base.id, DPU_HW_BLK_LM, hw_lm, ARRAY_SIZE(hw_lm));
646+
num_dspp = dpu_rm_get_assigned_resources(&dpu_kms->rm, global_state,
647+
drm_enc->base.id, DPU_HW_BLK_DSPP, hw_dspp,
648+
ARRAY_SIZE(hw_dspp));
649+
650+
for (i = 0; i < num_lm; i++) {
651+
int ctl_idx = (i < num_ctl) ? i : (num_ctl-1);
652+
653+
cstate->mixers[i].hw_lm = to_dpu_hw_mixer(hw_lm[i]);
654+
cstate->mixers[i].lm_ctl = to_dpu_hw_ctl(hw_ctl[ctl_idx]);
655+
cstate->mixers[i].hw_dspp = i < num_dspp ? to_dpu_hw_dspp(hw_dspp[i]) : NULL;
656+
}
657+
658+
cstate->num_mixers = num_lm;
659+
}
660+
627661
static int dpu_encoder_virt_atomic_check(
628662
struct drm_encoder *drm_enc,
629663
struct drm_crtc_state *crtc_state,
@@ -692,6 +726,9 @@ static int dpu_encoder_virt_atomic_check(
692726
if (!crtc_state->active_changed || crtc_state->enable)
693727
ret = dpu_rm_reserve(&dpu_kms->rm, global_state,
694728
drm_enc, crtc_state, topology);
729+
if (!ret)
730+
dpu_encoder_assign_crtc_resources(dpu_kms, drm_enc,
731+
global_state, crtc_state);
695732
}
696733

697734
trace_dpu_enc_atomic_check_flags(DRMID(drm_enc), adj_mode->flags);
@@ -1093,14 +1130,11 @@ static void dpu_encoder_virt_atomic_mode_set(struct drm_encoder *drm_enc,
10931130
struct dpu_encoder_virt *dpu_enc;
10941131
struct msm_drm_private *priv;
10951132
struct dpu_kms *dpu_kms;
1096-
struct dpu_crtc_state *cstate;
10971133
struct dpu_global_state *global_state;
10981134
struct dpu_hw_blk *hw_pp[MAX_CHANNELS_PER_ENC];
10991135
struct dpu_hw_blk *hw_ctl[MAX_CHANNELS_PER_ENC];
1100-
struct dpu_hw_blk *hw_lm[MAX_CHANNELS_PER_ENC];
1101-
struct dpu_hw_blk *hw_dspp[MAX_CHANNELS_PER_ENC] = { NULL };
11021136
struct dpu_hw_blk *hw_dsc[MAX_CHANNELS_PER_ENC];
1103-
int num_lm, num_ctl, num_pp, num_dsc;
1137+
int num_ctl, num_pp, num_dsc;
11041138
unsigned int dsc_mask = 0;
11051139
int i;
11061140

@@ -1129,11 +1163,6 @@ static void dpu_encoder_virt_atomic_mode_set(struct drm_encoder *drm_enc,
11291163
ARRAY_SIZE(hw_pp));
11301164
num_ctl = dpu_rm_get_assigned_resources(&dpu_kms->rm, global_state,
11311165
drm_enc->base.id, DPU_HW_BLK_CTL, hw_ctl, ARRAY_SIZE(hw_ctl));
1132-
num_lm = dpu_rm_get_assigned_resources(&dpu_kms->rm, global_state,
1133-
drm_enc->base.id, DPU_HW_BLK_LM, hw_lm, ARRAY_SIZE(hw_lm));
1134-
dpu_rm_get_assigned_resources(&dpu_kms->rm, global_state,
1135-
drm_enc->base.id, DPU_HW_BLK_DSPP, hw_dspp,
1136-
ARRAY_SIZE(hw_dspp));
11371166

11381167
for (i = 0; i < MAX_CHANNELS_PER_ENC; i++)
11391168
dpu_enc->hw_pp[i] = i < num_pp ? to_dpu_hw_pingpong(hw_pp[i])
@@ -1159,18 +1188,6 @@ static void dpu_encoder_virt_atomic_mode_set(struct drm_encoder *drm_enc,
11591188
dpu_enc->cur_master->hw_cdm = hw_cdm ? to_dpu_hw_cdm(hw_cdm) : NULL;
11601189
}
11611190

1162-
cstate = to_dpu_crtc_state(crtc_state);
1163-
1164-
for (i = 0; i < num_lm; i++) {
1165-
int ctl_idx = (i < num_ctl) ? i : (num_ctl-1);
1166-
1167-
cstate->mixers[i].hw_lm = to_dpu_hw_mixer(hw_lm[i]);
1168-
cstate->mixers[i].lm_ctl = to_dpu_hw_ctl(hw_ctl[ctl_idx]);
1169-
cstate->mixers[i].hw_dspp = to_dpu_hw_dspp(hw_dspp[i]);
1170-
}
1171-
1172-
cstate->num_mixers = num_lm;
1173-
11741191
for (i = 0; i < dpu_enc->num_phys_encs; i++) {
11751192
struct dpu_encoder_phys *phys = dpu_enc->phys_encs[i];
11761193

0 commit comments

Comments
 (0)