Re: [PATCH] drm/i915: Handle drm-layer errors in intel_dp_add_mst_connector

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

 



On Thu, Sep 14, 2017 at 12:59:35PM -0700, James Ausmus wrote:
> Make intel_dp_add_mst_connector handle error returns from the drm_ calls.
> Add intel_connector_destroy to support cleanup on the error path.

That name makes one think that it could be plugged into the connector
.destroy() hook. So I'd rename it to intel_connector_free() or something
like that.

Also the this MST thing just looks like the tip of the iceberg.
I think pretty much every connector has the same problem. But I
guess MST is slightly more interesting since it can happen at
runtime.

> 
> Signed-off-by: James Ausmus <james.ausmus@xxxxxxxxx>
> ---
> 
> Note that this patch is compile/boot tested only on non-MST, as I
> currently don't have MST-enabled HW.
> 
>  drivers/gpu/drm/i915/intel_display.c | 10 ++++++++++
>  drivers/gpu/drm/i915/intel_dp_mst.c  | 24 ++++++++++++++++++++----
>  drivers/gpu/drm/i915/intel_drv.h     |  1 +
>  3 files changed, 31 insertions(+), 4 deletions(-)
> 
> diff --git a/drivers/gpu/drm/i915/intel_display.c b/drivers/gpu/drm/i915/intel_display.c
> index 8599e425abb1..ab261c063032 100644
> --- a/drivers/gpu/drm/i915/intel_display.c
> +++ b/drivers/gpu/drm/i915/intel_display.c
> @@ -6146,6 +6146,16 @@ struct intel_connector *intel_connector_alloc(void)
>  	return connector;
>  }
>  
> +/*
> + * Free the bits allocated by intel_connector_alloc.
> + * Type-specific connector cleanup should be done prior to this.
> + */
> +void intel_connector_destroy(struct intel_connector *connector)
> +{
> +	kfree(to_intel_digital_connector_state(connector->base.state));
> +	kfree(connector);
> +}
> +
>  /* Simple connector->get_hw_state implementation for encoders that support only
>   * one connector and no cloning and hence the encoder state determines the state
>   * of the connector. */
> diff --git a/drivers/gpu/drm/i915/intel_dp_mst.c b/drivers/gpu/drm/i915/intel_dp_mst.c
> index 8e3aad0ea60b..80b3d665e988 100644
> --- a/drivers/gpu/drm/i915/intel_dp_mst.c
> +++ b/drivers/gpu/drm/i915/intel_dp_mst.c
> @@ -451,14 +451,18 @@ static struct drm_connector *intel_dp_add_mst_connector(struct drm_dp_mst_topolo
>  	struct drm_device *dev = intel_dig_port->base.base.dev;
>  	struct intel_connector *intel_connector;
>  	struct drm_connector *connector;
> -	int i;
> +	int i, ret;
>  
>  	intel_connector = intel_connector_alloc();
>  	if (!intel_connector)
>  		return NULL;
>  
>  	connector = &intel_connector->base;
> -	drm_connector_init(dev, connector, &intel_dp_mst_connector_funcs, DRM_MODE_CONNECTOR_DisplayPort);
> +	ret = drm_connector_init(dev, connector, &intel_dp_mst_connector_funcs,
> +				 DRM_MODE_CONNECTOR_DisplayPort);
> +	if (ret)
> +		goto out_init;
> +
>  	drm_connector_helper_add(connector, &intel_dp_mst_connector_helper_funcs);
>  
>  	intel_connector->get_hw_state = intel_dp_mst_get_hw_state;
> @@ -466,14 +470,26 @@ static struct drm_connector *intel_dp_add_mst_connector(struct drm_dp_mst_topolo
>  	intel_connector->port = port;
>  
>  	for (i = PIPE_A; i <= PIPE_C; i++) {
> -		drm_mode_connector_attach_encoder(&intel_connector->base,
> +		ret = drm_mode_connector_attach_encoder(&intel_connector->base,
>  						  &intel_dp->mst_encoders[i]->base.base);
> +		if (ret)
> +			goto out_conn;
>  	}
>  
>  	drm_object_attach_property(&connector->base, dev->mode_config.path_property, 0);
>  	drm_object_attach_property(&connector->base, dev->mode_config.tile_property, 0);
>  
> -	drm_mode_connector_set_path_property(connector, pathprop);
> +	ret = drm_mode_connector_set_path_property(connector, pathprop);
> +

'return connector' here so you can skip the 'if (ret)' things below?

> +out_conn:
> +	if (ret)
> +		drm_connector_cleanup(connector);
> +out_init:
> +	if (ret) {
> +		intel_connector_destroy(intel_connector);
> +		connector = NULL;
> +	}
> +
>  	return connector;
>  }
>  
> diff --git a/drivers/gpu/drm/i915/intel_drv.h b/drivers/gpu/drm/i915/intel_drv.h
> index 307807672896..d13c5c6b46e9 100644
> --- a/drivers/gpu/drm/i915/intel_drv.h
> +++ b/drivers/gpu/drm/i915/intel_drv.h
> @@ -1358,6 +1358,7 @@ void intel_pps_unlock_regs_wa(struct drm_i915_private *dev_priv);
>  void intel_encoder_destroy(struct drm_encoder *encoder);
>  int intel_connector_init(struct intel_connector *);
>  struct intel_connector *intel_connector_alloc(void);
> +void intel_connector_destroy(struct intel_connector *connector);
>  bool intel_connector_get_hw_state(struct intel_connector *connector);
>  void intel_connector_attach_encoder(struct intel_connector *connector,
>  				    struct intel_encoder *encoder);
> -- 
> 2.14.1
> 
> _______________________________________________
> Intel-gfx mailing list
> Intel-gfx@xxxxxxxxxxxxxxxxxxxxx
> https://lists.freedesktop.org/mailman/listinfo/intel-gfx

-- 
Ville Syrjälä
Intel OTC
_______________________________________________
Intel-gfx mailing list
Intel-gfx@xxxxxxxxxxxxxxxxxxxxx
https://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