[PATCH 3/4] drm/i915/dp_mst: Expose a connector to kernel users after it's properly initialized

Rodrigo Vivi rodrigo.vivi at intel.com
Fri Nov 15 20:18:33 UTC 2024


On Fri, Nov 15, 2024 at 06:41:58PM +0200, Imre Deak wrote:
> After a connector is added to the drm_mode_config::connector_list, it's
> visible to any in-kernel users looking up connectors via the above list.
> Make sure that the connector is properly initialized before such
> look-ups.
> 
> Signed-off-by: Imre Deak <imre.deak at intel.com>

Reviewed-by: Rodrigo Vivi <rodrigo.vivi at intel.com>

> ---
>  drivers/gpu/drm/i915/display/intel_dp_mst.c | 29 ++++++++-------------
>  1 file changed, 11 insertions(+), 18 deletions(-)
> 
> diff --git a/drivers/gpu/drm/i915/display/intel_dp_mst.c b/drivers/gpu/drm/i915/display/intel_dp_mst.c
> index f058360a26413..d91a1d1fb26f4 100644
> --- a/drivers/gpu/drm/i915/display/intel_dp_mst.c
> +++ b/drivers/gpu/drm/i915/display/intel_dp_mst.c
> @@ -1719,6 +1719,8 @@ static struct drm_connector *intel_dp_add_mst_connector(struct drm_dp_mst_topolo
>  	if (!intel_connector)
>  		return NULL;
>  
> +	connector = &intel_connector->base;
> +
>  	intel_connector->get_hw_state = intel_dp_mst_get_hw_state;
>  	intel_connector->sync_state = intel_dp_connector_sync_state;
>  	intel_connector->mst_port = intel_dp;
> @@ -1727,30 +1729,19 @@ static struct drm_connector *intel_dp_add_mst_connector(struct drm_dp_mst_topolo
>  
>  	intel_dp_init_modeset_retry_work(intel_connector);
>  
> -	/*
> -	 * TODO: The following drm_connector specific initialization belongs
> -	 * to DRM core, however it happens atm too late in
> -	 * drm_connector_init(). That function will also expose the connector
> -	 * to in-kernel users, so it can't be called until the connector is
> -	 * sufficiently initialized; init the device pointer used by the
> -	 * following DSC setup, until a fix moving this to DRM core.
> -	 */
> -	intel_connector->base.dev = mgr->dev;
> -
> -	intel_connector->dp.dsc_decompression_aux = drm_dp_mst_dsc_aux_for_port(port);
> -	intel_dp_mst_read_decompression_port_dsc_caps(intel_dp, intel_connector);
> -	intel_connector->dp.dsc_hblank_expansion_quirk =
> -		detect_dsc_hblank_expansion_quirk(intel_connector);
> -
> -	connector = &intel_connector->base;
> -	ret = drm_connector_init(display->drm, connector, &intel_dp_mst_connector_funcs,
> -				 DRM_MODE_CONNECTOR_DisplayPort);
> +	ret = drm_connector_init_core(display->drm, connector, &intel_dp_mst_connector_funcs,
> +				      DRM_MODE_CONNECTOR_DisplayPort);
>  	if (ret) {
>  		drm_dp_mst_put_port_malloc(port);
>  		intel_connector_free(intel_connector);
>  		return NULL;
>  	}
>  
> +	intel_connector->dp.dsc_decompression_aux = drm_dp_mst_dsc_aux_for_port(port);
> +	intel_dp_mst_read_decompression_port_dsc_caps(intel_dp, intel_connector);
> +	intel_connector->dp.dsc_hblank_expansion_quirk =
> +		detect_dsc_hblank_expansion_quirk(intel_connector);
> +
>  	drm_connector_helper_add(connector, &intel_dp_mst_connector_helper_funcs);
>  
>  	for_each_pipe(display, pipe) {
> @@ -1771,6 +1762,8 @@ static struct drm_connector *intel_dp_add_mst_connector(struct drm_dp_mst_topolo
>  		drm_dbg_kms(display->drm, "[%s:%d] HDCP MST init failed, skipping.\n",
>  			    connector->name, connector->base.id);
>  
> +	drm_connector_add(connector);
> +
>  	return connector;
>  
>  err:
> -- 
> 2.44.2
> 


More information about the Intel-gfx mailing list