On Mon, Sep 18, 2017 at 3:21 PM, Dhinakaran Pandiyan
<dhinakaran.pandi...@intel.com> wrote:
> Rewriting this code without the goto, I believe, makes it more readable.
> One functional change that has been included is the handling of failed ESI
> register reads. Instead of disabling MST only for the first failed read, we
> now disable MST on subsequent failed reads too. A failed ESI read is
> problematic irrespective of whether it is the first or not.
>
> Cc: James Ausmus <james.aus...@intel.com>
> Cc: Jani Nikula <jani.nik...@intel.com>
> Cc: Ville Syrjälä <ville.syrj...@linux.intel.com>
> Signed-off-by: Dhinakaran Pandiyan <dhinakaran.pandi...@intel.com>
> ---
>  drivers/gpu/drm/i915/intel_dp.c | 75 
> +++++++++++++++++------------------------
>  1 file changed, 31 insertions(+), 44 deletions(-)
>
> diff --git a/drivers/gpu/drm/i915/intel_dp.c b/drivers/gpu/drm/i915/intel_dp.c
> index 98e7b96ca826..cc129aa444ac 100644
> --- a/drivers/gpu/drm/i915/intel_dp.c
> +++ b/drivers/gpu/drm/i915/intel_dp.c
> @@ -4191,57 +4191,44 @@ static void intel_dp_handle_test_request(struct 
> intel_dp *intel_dp)
>  static int
>  intel_dp_check_mst_status(struct intel_dp *intel_dp)
>  {
> -       bool bret;
> +       u8 esi[DP_DPRX_ESI_LEN] = { 0 };
> +       struct intel_digital_port *intel_dig_port = dp_to_dig_port(intel_dp);
>
> -       if (intel_dp->is_mst) {
> -               u8 esi[DP_DPRX_ESI_LEN] = { 0 };
> -               int ret = 0;
> -               int retry;
> +       if (!intel_dp->is_mst)
> +               return -EINVAL;
> +
> +       while (intel_dp_get_sink_irq_esi(intel_dp, esi)) {

It looks like if the underlying drm_dp_dpcd_read fails and returns
-EIO, for instance, you'll get true back from
intel_dp_get_sink_irq_esi, and you'll still go in to the while, but
with a potentially invalid esi. Granted, this is a problem in the
original code as well, but it seems like something that should be
fixed during the refactoring.


> +               int ret, retry;
>                 bool handled;
> -               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 &&
> -                           !drm_dp_channel_eq_ok(&esi[10], 
> intel_dp->lane_count)) {
> -                               DRM_DEBUG_KMS("channel EQ not ok, 
> retraining\n");
> -                               intel_dp_start_link_train(intel_dp);
> -                               intel_dp_stop_link_train(intel_dp);
> -                       }
>
> -                       DRM_DEBUG_KMS("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;
> -                                       }
> -                               }
> +               DRM_DEBUG_KMS("ESI %3ph\n", esi);
>
> -                               bret = intel_dp_get_sink_irq_esi(intel_dp, 
> esi);
> -                               if (bret == true) {
> -                                       DRM_DEBUG_KMS("got esi2 %3ph\n", esi);
> -                                       goto go_again;
> -                               }
> -                       } else
> -                               ret = 0;
> +               /* check link status - esi[10] = 0x200c */
> +               if (intel_dp->active_mst_links &&
> +                   !drm_dp_channel_eq_ok(&esi[10], intel_dp->lane_count)) {
> +                       intel_dp_start_link_train(intel_dp);
> +                       intel_dp_stop_link_train(intel_dp);
> +               }
>
> -                       return ret;
> -               } else {
> -                       struct intel_digital_port *intel_dig_port = 
> dp_to_dig_port(intel_dp);
> -                       DRM_DEBUG_KMS("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);
> -                       /* send a hotplug event */
> -                       
> drm_kms_helper_hotplug_event(intel_dig_port->base.base.dev);
> +               ret = drm_dp_mst_hpd_irq(&intel_dp->mst_mgr, esi, &handled);

You're no longer using the value returned by drm_dp_mst_hpd_irq

> +               if (!handled)
> +                       return 0;
> +
> +               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;
>                 }
>         }
> +
> +       DRM_DEBUG_KMS("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_kms_helper_hotplug_event(intel_dig_port->base.base.dev);
>         return -EINVAL;
>  }
>
> --
> 2.11.0
>



-- 


James Ausmus
_______________________________________________
Intel-gfx mailing list
Intel-gfx@lists.freedesktop.org
https://lists.freedesktop.org/mailman/listinfo/intel-gfx

Reply via email to