From: Andrey Grodzovsky <Andrey.Grodzovsky@xxxxxxx> We can keep a 1:1 relation between a link and a physical connector and hence skip the iteration. This function is used in context of only physical connetors. Change-Id: I3379e620b8400f02dc80a50927b66e9e06406579 Signed-off-by: Andrey Grodzovsky <Andrey.Grodzovsky at amd.com> Reviewed-by: Harry Wentland <Harry.Wentland at amd.com> --- .../drm/amd/display/amdgpu_dm/amdgpu_dm_helpers.c | 36 +++------------------- .../drm/amd/display/amdgpu_dm/amdgpu_dm_types.c | 1 + drivers/gpu/drm/amd/display/dc/dc.h | 2 ++ 3 files changed, 8 insertions(+), 31 deletions(-) diff --git a/drivers/gpu/drm/amd/display/amdgpu_dm/amdgpu_dm_helpers.c b/drivers/gpu/drm/amd/display/amdgpu_dm/amdgpu_dm_helpers.c index e503677110c3..961d8d13d725 100644 --- a/drivers/gpu/drm/amd/display/amdgpu_dm/amdgpu_dm_helpers.c +++ b/drivers/gpu/drm/amd/display/amdgpu_dm/amdgpu_dm_helpers.c @@ -148,21 +148,6 @@ static struct amdgpu_connector *get_connector_for_sink( return NULL; } -static struct amdgpu_connector *get_connector_for_link( - struct drm_device *dev, - const struct dc_link *link) -{ - struct drm_connector *connector; - - list_for_each_entry(connector, &dev->mode_config.connector_list, head) { - struct amdgpu_connector *aconnector = to_amdgpu_connector(connector); - if (aconnector->dc_link == link) - return aconnector; - } - - return NULL; -} - static void get_payload_table( struct amdgpu_connector *aconnector, struct dp_mst_stream_allocation_table *proposed_table) @@ -362,9 +347,7 @@ bool dm_helpers_dp_mst_start_top_mgr( const struct dc_link *link, bool boot) { - struct amdgpu_device *adev = ctx->driver_context; - struct drm_device *dev = adev->ddev; - struct amdgpu_connector *aconnector = get_connector_for_link(dev, link); + struct amdgpu_connector *aconnector = link->priv; if (!aconnector) { DRM_ERROR("Failed to found connector for link!"); @@ -387,9 +370,7 @@ void dm_helpers_dp_mst_stop_top_mgr( struct dc_context *ctx, const struct dc_link *link) { - struct amdgpu_device *adev = ctx->driver_context; - struct drm_device *dev = adev->ddev; - struct amdgpu_connector *aconnector = get_connector_for_link(dev, link); + struct amdgpu_connector *aconnector = link->priv; if (!aconnector) { DRM_ERROR("Failed to found connector for link!"); @@ -411,9 +392,7 @@ bool dm_helpers_dp_read_dpcd( uint32_t size) { - struct amdgpu_device *adev = ctx->driver_context; - struct drm_device *dev = adev->ddev; - struct amdgpu_connector *aconnector = get_connector_for_link(dev, link); + struct amdgpu_connector *aconnector = link->priv; if (!aconnector) { DRM_ERROR("Failed to found connector for link!"); @@ -431,10 +410,7 @@ bool dm_helpers_dp_write_dpcd( const uint8_t *data, uint32_t size) { - - struct amdgpu_device *adev = ctx->driver_context; - struct drm_device *dev = adev->ddev; - struct amdgpu_connector *aconnector = get_connector_for_link(dev, link); + struct amdgpu_connector *aconnector = link->priv; if (!aconnector) { DRM_ERROR("Failed to found connector for link!"); @@ -450,9 +426,7 @@ bool dm_helpers_submit_i2c( const struct dc_link *link, struct i2c_command *cmd) { - struct amdgpu_device *adev = ctx->driver_context; - struct drm_device *dev = adev->ddev; - struct amdgpu_connector *aconnector = get_connector_for_link(dev, link); + struct amdgpu_connector *aconnector = link->priv; struct i2c_msg *msgs; int i = 0; int num = cmd->number_of_payloads; diff --git a/drivers/gpu/drm/amd/display/amdgpu_dm/amdgpu_dm_types.c b/drivers/gpu/drm/amd/display/amdgpu_dm/amdgpu_dm_types.c index 0424b2d65793..5e231c3ff482 100644 --- a/drivers/gpu/drm/amd/display/amdgpu_dm/amdgpu_dm_types.c +++ b/drivers/gpu/drm/amd/display/amdgpu_dm/amdgpu_dm_types.c @@ -2175,6 +2175,7 @@ int amdgpu_dm_connector_init( struct dc *dc = dm->dc; const struct dc_link *link = dc_get_link_at_index(dc, link_index); struct amdgpu_i2c_adapter *i2c; + ((struct dc_link *)link)->priv = aconnector; DRM_DEBUG_KMS("%s()\n", __func__); diff --git a/drivers/gpu/drm/amd/display/dc/dc.h b/drivers/gpu/drm/amd/display/dc/dc.h index 9dd8b2ad4c59..6bb6ad23b31b 100644 --- a/drivers/gpu/drm/amd/display/dc/dc.h +++ b/drivers/gpu/drm/amd/display/dc/dc.h @@ -592,6 +592,8 @@ struct dc_link { struct psr_caps psr_caps; bool test_pattern_enabled; union compliance_test_state compliance_test_state; + + void *priv; }; struct dpcd_caps { -- 2.11.0