]> www.infradead.org Git - users/hch/dma-mapping.git/commitdiff
drm/msm/dpu: make sure phys resources are properly initialized
authorDmitry Baryshkov <dmitry.baryshkov@linaro.org>
Tue, 3 Sep 2024 03:22:44 +0000 (06:22 +0300)
committerAbhinav Kumar <quic_abhinavk@quicinc.com>
Mon, 14 Oct 2024 20:16:16 +0000 (13:16 -0700)
The commit b954fa6baaca ("drm/msm/dpu: Refactor rm iterator") removed
zero-init of the hw_ctl array, but didn't change the error condition,
that checked for hw_ctl[i] being NULL. At the same time because of the
early returns in case of an error dpu_encoder_phys might be left with
the resources assigned in the previous state. Rework assigning of hw_pp
/ hw_ctl to the dpu_encoder_phys in order to make sure they are always
set correctly.

Fixes: b954fa6baaca ("drm/msm/dpu: Refactor rm iterator")
Suggested-by: Abhinav Kumar <quic_abhinavk@quicinc.com>
Signed-off-by: Dmitry Baryshkov <dmitry.baryshkov@linaro.org>
Reviewed-by: Abhinav Kumar <quic_abhinavk@quicinc.com>
Patchwork: https://patchwork.freedesktop.org/patch/612233/
Link: https://lore.kernel.org/r/20240903-dpu-mode-config-width-v6-1-617e1ecc4b7a@linaro.org
Signed-off-by: Abhinav Kumar <quic_abhinavk@quicinc.com>
drivers/gpu/drm/msm/disp/dpu1/dpu_encoder.c

index 3b171bf227d16f301545eefeac1e2bf61085b218..949ebda2fa82961309ad5f8f718791b37297bf6a 100644 (file)
@@ -1174,21 +1174,20 @@ static void dpu_encoder_virt_atomic_mode_set(struct drm_encoder *drm_enc,
        for (i = 0; i < dpu_enc->num_phys_encs; i++) {
                struct dpu_encoder_phys *phys = dpu_enc->phys_encs[i];
 
-               if (!dpu_enc->hw_pp[i]) {
+               phys->hw_pp = dpu_enc->hw_pp[i];
+               if (!phys->hw_pp) {
                        DPU_ERROR_ENC(dpu_enc,
                                "no pp block assigned at idx: %d\n", i);
                        return;
                }
 
-               if (!hw_ctl[i]) {
+               phys->hw_ctl = i < num_ctl ? to_dpu_hw_ctl(hw_ctl[i]) : NULL;
+               if (!phys->hw_ctl) {
                        DPU_ERROR_ENC(dpu_enc,
                                "no ctl block assigned at idx: %d\n", i);
                        return;
                }
 
-               phys->hw_pp = dpu_enc->hw_pp[i];
-               phys->hw_ctl = to_dpu_hw_ctl(hw_ctl[i]);
-
                phys->cached_mode = crtc_state->adjusted_mode;
                if (phys->ops.atomic_mode_set)
                        phys->ops.atomic_mode_set(phys, crtc_state, conn_state);