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, by initializing the connector with
drm_connector_dynamic_register() - which doesn't add the connector to
the list - and registering it with drm_connector_dynamic_register() -
which adds the connector to the list - after the initialization is
complete.

v2: Rebase on the change which moves adding the connector to the
    connector list only later when calling
    drm_connector_dynamic_register().

Cc: Lyude Paul <ly...@redhat.com>
Reviewed-by: Rodrigo Vivi <rodrigo.v...@intel.com> (v1)
Signed-off-by: Imre Deak <imre.d...@intel.com>
---
 drivers/gpu/drm/i915/display/intel_dp_mst.c | 27 +++++++--------------
 1 file changed, 9 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 123c4ece62688..debe4d0eee11f 100644
--- a/drivers/gpu/drm/i915/display/intel_dp_mst.c
+++ b/drivers/gpu/drm/i915/display/intel_dp_mst.c
@@ -1731,6 +1731,8 @@ mst_topology_add_connector(struct drm_dp_mst_topology_mgr 
*mgr,
        if (!intel_connector)
                return NULL;
 
+       connector = &intel_connector->base;
+
        intel_connector->get_hw_state = mst_connector_get_hw_state;
        intel_connector->sync_state = intel_dp_connector_sync_state;
        intel_connector->mst_port = intel_dp;
@@ -1739,30 +1741,19 @@ mst_topology_add_connector(struct 
drm_dp_mst_topology_mgr *mgr,
 
        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, &mst_connector_funcs,
-                                DRM_MODE_CONNECTOR_DisplayPort);
+       ret = drm_connector_dynamic_init(display->drm, connector, 
&mst_connector_funcs,
+                                        DRM_MODE_CONNECTOR_DisplayPort, NULL);
        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, &mst_connector_helper_funcs);
 
        for_each_pipe(display, pipe) {
-- 
2.44.2

Reply via email to