Re: [PATCH 3/3] drm/i915: Flatten intel_dp_check_mst_status()

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



Op 27-08-15 om 17:36 schreef ville.syrjala@xxxxxxxxxxxxxxx:
> From: Ville Syrjälä <ville.syrjala@xxxxxxxxxxxxxxx>
>
> Restructure intel_dp_check_mst_status() to be more straightforward to
> read.
>
> Signed-off-by: Ville Syrjälä <ville.syrjala@xxxxxxxxxxxxxxx>
> ---
>  drivers/gpu/drm/i915/intel_dp.c | 92 +++++++++++++++++++++--------------------
>  1 file changed, 47 insertions(+), 45 deletions(-)
>
> diff --git a/drivers/gpu/drm/i915/intel_dp.c b/drivers/gpu/drm/i915/intel_dp.c
> index 6c34784..033ee20 100644
> --- a/drivers/gpu/drm/i915/intel_dp.c
> +++ b/drivers/gpu/drm/i915/intel_dp.c
> <snip>

> +	for (;;) {
>  		bool handled;
> -		bret = intel_dp_get_sink_irq_esi(intel_dp, esi);
> -go_again:
> -		if (bret == true) {
> +		int retry;
> +		int ret;
>  
> -			drm_modeset_lock(&dev->mode_config.connection_mutex, NULL);
> +		drm_modeset_lock(&dev->mode_config.connection_mutex, NULL);
>  
> -			/* 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_complete_link_train(intel_dp);
> -				intel_dp_stop_link_train(intel_dp);
> -			}
> +		/* 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_complete_link_train(intel_dp);
> +			intel_dp_stop_link_train(intel_dp);
> +		}
>  
> -			drm_modeset_unlock(&dev->mode_config.connection_mutex);
>  
> -			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_modeset_unlock(&dev->mode_config.connection_mutex);
>  
> -				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;
> +		DRM_DEBUG_KMS("got esi %3ph\n", esi);
> +		ret = drm_dp_mst_hpd_irq(&intel_dp->mst_mgr, esi, &handled);
>  
> -			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);
> +		if (!handled)
> +			return 0;
> +
> +		for (retry = 0; retry < 3; retry++) {
> +			int wret = drm_dp_dpcd_write(&intel_dp->aux,
> +						     DP_SINK_COUNT_ESI+1,
> +						     &esi[1], 3);
> +			if (wret == 3)
> +				break;
>  		}
> +
> +		bret = intel_dp_get_sink_irq_esi(intel_dp, esi);
> +		if (!bret)
> +			return ret;
^This seemed like a bug the first time I looked at it with the indent changes.

Original indent with if (handled) {.. } seems better here, but with a continue instead of a goto.
I think a single return ret; would make it more clear when the loop finishes.

The original code sets ret = 0 when handled = false, but looking a  drm_dp_mst_hpd_irq
this is unneeded.


> +
> +		DRM_DEBUG_KMS("got esi2 %3ph\n", esi);
>  	}
> +
>  	return -EINVAL;
Can this -EINVAL be removed? It cannot be reached any more.
_______________________________________________
Intel-gfx mailing list
Intel-gfx@xxxxxxxxxxxxxxxxxxxxx
http://lists.freedesktop.org/mailman/listinfo/intel-gfx




[Index of Archives]     [Linux USB Devel]     [Linux Audio Users]     [Yosemite News]     [Linux Kernel]     [Linux SCSI]
  Powered by Linux