[Intel-gfx] [PATCH 3/3] drm/i915: Flatten intel_dp_check_mst_status()

Maarten Lankhorst maarten.lankhorst at linux.intel.com
Wed Sep 16 06:07:16 PDT 2015


Op 27-08-15 om 17:36 schreef ville.syrjala at linux.intel.com:
> From: Ville Syrjälä <ville.syrjala at linux.intel.com>
>
> Restructure intel_dp_check_mst_status() to be more straightforward to
> read.
>
> Signed-off-by: Ville Syrjälä <ville.syrjala at linux.intel.com>
> ---
>  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.


More information about the Intel-gfx mailing list