]> git.baikalelectronics.ru Git - kernel.git/commitdiff
drm/i915: Flatten intel_dp_check_mst_status() a bit
authorVille Syrjälä <ville.syrjala@linux.intel.com>
Fri, 17 Apr 2020 15:27:33 +0000 (18:27 +0300)
committerVille Syrjälä <ville.syrjala@linux.intel.com>
Mon, 20 Apr 2020 18:21:11 +0000 (21:21 +0300)
Make intel_dp_check_mst_status() somewhat legible by humans.

Note that the return value of drm_dp_mst_hpd_irq() is always
either 0 or -ENOMEM, and we never did anything with the latter
so we can just ignore the whole thing.

We can also get rid of the direct drm_dp_mst_topology_mgr_set_mst(false)
call since returning -EINVAL causes the caller to do the very same call
for us.

Cc: Lyude Paul <lyude@redhat.com>
Signed-off-by: Ville Syrjälä <ville.syrjala@linux.intel.com>
Link: https://patchwork.freedesktop.org/patch/msgid/20200417152734.464-1-ville.syrjala@linux.intel.com
Reviewed-by: Lyude Paul <lyude@redhat.com>
drivers/gpu/drm/i915/display/intel_dp.c

index a71d29136595937156e58339a4d2c4156a90eb46..ca2193c6f7f1e547d786cde67c4e66a2085fff4f 100644 (file)
@@ -5625,61 +5625,55 @@ static int
 intel_dp_check_mst_status(struct intel_dp *intel_dp)
 {
        struct drm_i915_private *i915 = dp_to_i915(intel_dp);
-       bool bret;
 
-       if (intel_dp->is_mst) {
-               u8 esi[DP_DPRX_ESI_LEN] = { 0 };
-               int ret = 0;
+       if (!intel_dp->is_mst)
+               return -EINVAL;
+
+       WARN_ON_ONCE(intel_dp->active_mst_links < 0);
+
+       for (;;) {
+               u8 esi[DP_DPRX_ESI_LEN] = {};
+               bool bret, handled;
                int retry;
-               bool handled;
 
-               WARN_ON_ONCE(intel_dp->active_mst_links < 0);
                bret = intel_dp_get_sink_irq_esi(intel_dp, esi);
-go_again:
-               if (bret == true) {
-
-                       /* check link status - esi[10] = 0x200c */
-                       if (intel_dp->active_mst_links > 0 &&
-                           !drm_dp_channel_eq_ok(&esi[10], intel_dp->lane_count)) {
-                               drm_dbg_kms(&i915->drm,
-                                           "channel EQ not ok, retraining\n");
-                               intel_dp_start_link_train(intel_dp);
-                               intel_dp_stop_link_train(intel_dp);
-                       }
+               if (!bret) {
+                       drm_dbg_kms(&i915->drm,
+                                   "failed to get ESI - device may have failed\n");
+                       return -EINVAL;
+               }
 
-                       drm_dbg_kms(&i915->drm, "got esi %3ph\n", esi);
-                       ret = drm_dp_mst_hpd_irq(&intel_dp->mst_mgr, esi, &handled);
-
-                       if (handled) {
-                               for (retry = 0; retry < 3; retry++) {
-                                       int wret;
-                                       wret = drm_dp_dpcd_write(&intel_dp->aux,
-                                                                DP_SINK_COUNT_ESI+1,
-                                                                &esi[1], 3);
-                                       if (wret == 3) {
-                                               break;
-                                       }
-                               }
+               /* check link status - esi[10] = 0x200c */
+               /*
+                * FIXME kill this and use the SST retraining approach
+                * for MST as well.
+                */
+               if (intel_dp->active_mst_links > 0 &&
+                   !drm_dp_channel_eq_ok(&esi[10], intel_dp->lane_count)) {
+                       drm_dbg_kms(&i915->drm,
+                                   "channel EQ not ok, retraining\n");
+                       intel_dp_start_link_train(intel_dp);
+                       intel_dp_stop_link_train(intel_dp);
+               }
 
-                               bret = intel_dp_get_sink_irq_esi(intel_dp, esi);
-                               if (bret == true) {
-                                       drm_dbg_kms(&i915->drm,
-                                                   "got esi2 %3ph\n", esi);
-                                       goto go_again;
-                               }
-                       } else
-                               ret = 0;
+               drm_dbg_kms(&i915->drm, "got esi %3ph\n", esi);
 
-                       return ret;
-               } else {
-                       drm_dbg_kms(&i915->drm,
-                                   "failed to get ESI - device may have failed\n");
-                       intel_dp->is_mst = false;
-                       drm_dp_mst_topology_mgr_set_mst(&intel_dp->mst_mgr,
-                                                       intel_dp->is_mst);
+               drm_dp_mst_hpd_irq(&intel_dp->mst_mgr, esi, &handled);
+               if (!handled)
+                       break;
+
+               for (retry = 0; retry < 3; retry++) {
+                       int wret;
+
+                       wret = drm_dp_dpcd_write(&intel_dp->aux,
+                                                DP_SINK_COUNT_ESI+1,
+                                                &esi[1], 3);
+                       if (wret == 3)
+                               break;
                }
        }
-       return -EINVAL;
+
+       return 0;
 }
 
 static bool