drm/msm/dpu: Fail atomic_check if multiple outputs request CDM block
authorJessica Zhang <quic_jesszhan@quicinc.com>
Sat, 15 Feb 2025 00:14:29 +0000 (16:14 -0800)
committerDmitry Baryshkov <dmitry.baryshkov@linaro.org>
Wed, 5 Mar 2025 02:34:12 +0000 (04:34 +0200)
Currently, our hardware only supports a single output using CDM block at
most. Because of this, we cannot support cases where both writeback and DP
output request CDM simultaneously

To avoid this happening when CWB is enabled, change
msm_display_topoloy.needs_cdm into a num_cdm counter to track how many
outputs are requesting CDM block. Return EINVAL if multiple outputs are
trying to reserve CDM.

Signed-off-by: Jessica Zhang <quic_jesszhan@quicinc.com>
Reviewed-by: Dmitry Baryshkov <dmitry.baryshkov@linaro.org>
Patchwork: https://patchwork.freedesktop.org/patch/637499/
Link: https://lore.kernel.org/r/20250214-concurrent-wb-v6-6-a44c293cf422@quicinc.com
Signed-off-by: Dmitry Baryshkov <dmitry.baryshkov@linaro.org>
drivers/gpu/drm/msm/disp/dpu1/dpu_encoder.c
drivers/gpu/drm/msm/disp/dpu1/dpu_rm.c
drivers/gpu/drm/msm/disp/dpu1/dpu_rm.h

index a4091e861e31204a0b9aff806a879856800f1ba0..9b6ed3ab43174e3941450c81d9a9966b404e6f74 100644 (file)
@@ -700,10 +700,10 @@ void dpu_encoder_update_topology(struct drm_encoder *drm_enc,
                fb = conn_state->writeback_job->fb;
 
                if (fb && MSM_FORMAT_IS_YUV(msm_framebuffer_format(fb)))
-                       topology->needs_cdm = true;
+                       topology->num_cdm++;
        } else if (disp_info->intf_type == INTF_DP) {
                if (msm_dp_is_yuv_420_enabled(priv->dp[disp_info->h_tile_instance[0]], adj_mode))
-                       topology->needs_cdm = true;
+                       topology->num_cdm++;
        }
 }
 
index 0fbb92021b184c4792ddfe059e98b3acf7bc7cc6..4da2e47265d41f48e690257fba7f14198cd26d1d 100644 (file)
@@ -585,7 +585,8 @@ static int _dpu_rm_reserve_dsc(struct dpu_rm *rm,
 
 static int _dpu_rm_reserve_cdm(struct dpu_rm *rm,
                               struct dpu_global_state *global_state,
-                              uint32_t crtc_id)
+                              uint32_t crtc_id,
+                              int num_cdm)
 {
        /* try allocating only one CDM block */
        if (!rm->cdm_blk) {
@@ -593,6 +594,11 @@ static int _dpu_rm_reserve_cdm(struct dpu_rm *rm,
                return -EIO;
        }
 
+       if (num_cdm > 1) {
+               DPU_ERROR("More than 1 INTF requesting CDM\n");
+               return -EINVAL;
+       }
+
        if (global_state->cdm_to_crtc_id) {
                DPU_ERROR("CDM_0 is already allocated\n");
                return -EIO;
@@ -629,8 +635,8 @@ static int _dpu_rm_make_reservation(
        if (ret)
                return ret;
 
-       if (topology->needs_cdm) {
-               ret = _dpu_rm_reserve_cdm(rm, global_state, crtc_id);
+       if (topology->num_cdm > 0) {
+               ret = _dpu_rm_reserve_cdm(rm, global_state, crtc_id, topology->num_cdm);
                if (ret) {
                        DPU_ERROR("unable to find CDM blk\n");
                        return ret;
index b854e42d319d2c482e4e1732239754979f6950dd..a19dbdb1b6f48ad708f0d512c2460d092856f52f 100644 (file)
@@ -51,7 +51,8 @@ struct dpu_rm_sspp_requirements {
  * @num_intf:     number of interfaces the panel is mounted on
  * @num_dspp:     number of dspp blocks used
  * @num_dsc:      number of Display Stream Compression (DSC) blocks used
- * @needs_cdm:    indicates whether cdm block is needed for this display topology
+ * @num_cdm:      indicates how many outputs are requesting cdm block for
+ *                    this display topology
  * @cwb_enabled:  indicates whether CWB is enabled for this display topology
  */
 struct msm_display_topology {
@@ -59,7 +60,7 @@ struct msm_display_topology {
        u32 num_intf;
        u32 num_dspp;
        u32 num_dsc;
-       bool needs_cdm;
+       int num_cdm;
        bool cwb_enabled;
 };