drm/i915: Fix intel_dp_mst_compute_link_config
authorStanislav Lisovskiy <stanislav.lisovskiy@intel.com>
Tue, 1 Nov 2022 09:42:18 +0000 (11:42 +0200)
committerStanislav Lisovskiy <stanislav.lisovskiy@intel.com>
Tue, 13 Dec 2022 16:17:52 +0000 (18:17 +0200)
We currently always exit that bpp loop because
drm_dp_atomic_find_vcpi_slots doesn't care if we actually
can fit those or not.
I think that wasn't the initial intention here, especially when
we keep trying with lower bpps, we are supposed to keep trying
until we actually find some _working_ configuration, which isn't the
case here.
So added that drm_dp_mst_check here, so that we can make sure
that try all the bpps before we fail.

Reviewed-by: Vinod Govindapillai <vinod.govindapillai@intel.com>
Signed-off-by: Stanislav Lisovskiy <stanislav.lisovskiy@intel.com>
Link: https://patchwork.freedesktop.org/patch/msgid/20221101094222.22091-3-stanislav.lisovskiy@intel.com
drivers/gpu/drm/i915/display/intel_dp_mst.c

index 4077a97..823dfce 100644 (file)
@@ -60,6 +60,7 @@ static int intel_dp_mst_compute_link_config(struct intel_encoder *encoder,
        const struct drm_display_mode *adjusted_mode =
                &crtc_state->hw.adjusted_mode;
        int bpp, slots = -EINVAL;
+       int ret = 0;
 
        mst_state = drm_atomic_get_mst_topology_state(state, &intel_dp->mst_mgr);
        if (IS_ERR(mst_state))
@@ -85,10 +86,21 @@ static int intel_dp_mst_compute_link_config(struct intel_encoder *encoder,
                                                      connector->port, crtc_state->pbn);
                if (slots == -EDEADLK)
                        return slots;
-               if (slots >= 0)
-                       break;
+               if (slots >= 0) {
+                       ret = drm_dp_mst_atomic_check(state);
+                       /*
+                        * If we got slots >= 0 and we can fit those based on check
+                        * then we can exit the loop. Otherwise keep trying.
+                        */
+                       if (!ret)
+                               break;
+               }
        }
 
+       /* Despite slots are non-zero, we still failed the atomic check */
+       if (ret && slots >= 0)
+               slots = ret;
+
        if (slots < 0) {
                drm_dbg_kms(&i915->drm, "failed finding vcpi slots:%d\n",
                            slots);