From: Tony Cheng <tony.cheng@xxxxxxx> - also consolidate dc create failure using destruct Signed-off-by: Tony Cheng <tony.cheng at amd.com> Acked-by: Harry Wentland <harry.wentland at amd.com> --- .../gpu/drm/amd/dal/dc/adapter/adapter_service.c | 25 -------- drivers/gpu/drm/amd/dal/dc/bios/bios_parser.c | 2 +- drivers/gpu/drm/amd/dal/dc/core/dc.c | 72 ++++++++++++++-------- drivers/gpu/drm/amd/dal/dc/core/dc_link_ddc.c | 10 +-- drivers/gpu/drm/amd/dal/dc/dc_types.h | 1 + .../gpu/drm/amd/dal/dc/dce100/dce100_resource.c | 3 - .../gpu/drm/amd/dal/dc/dce110/dce110_resource.c | 4 -- .../gpu/drm/amd/dal/dc/dce112/dce112_resource.c | 4 -- drivers/gpu/drm/amd/dal/dc/dce80/dce80_resource.c | 4 -- .../amd/dal/include/adapter_service_interface.h | 5 -- 10 files changed, 52 insertions(+), 78 deletions(-) diff --git a/drivers/gpu/drm/amd/dal/dc/adapter/adapter_service.c b/drivers/gpu/drm/amd/dal/dc/adapter/adapter_service.c index f2e633e3ab74..435b222c48a4 100644 --- a/drivers/gpu/drm/amd/dal/dc/adapter/adapter_service.c +++ b/drivers/gpu/drm/amd/dal/dc/adapter/adapter_service.c @@ -595,9 +595,6 @@ static bool generate_feature_set( static void adapter_service_destruct( struct adapter_service *as) { - struct dc_bios *dcb = as->ctx->dc_bios; - - dal_i2caux_destroy(&as->i2caux); dal_asic_capability_destroy(&as->asic_cap); } @@ -659,14 +656,6 @@ static bool adapter_service_construct( dcb = as->ctx->dc_bios; - /* Create I2C AUX */ - as->i2caux = dal_i2caux_create(as->ctx); - - if (!as->i2caux) { - ASSERT_CRITICAL(false); - goto failed_to_create_i2caux; - } - dcb->funcs->post_init(dcb, as); /* Generate backlight translation table and initializes @@ -680,9 +669,6 @@ static bool adapter_service_construct( return true; failed_to_generate_features: - dal_i2caux_destroy(&as->i2caux); - -failed_to_create_i2caux: dal_asic_capability_destroy(&as->asic_cap); return false; @@ -966,17 +952,6 @@ bool dal_adapter_service_get_feature_value(struct adapter_service *as, return true; } -/* - * dal_adapter_service_get_i2caux - * - * Get i2c aux handler - */ -struct i2caux *dal_adapter_service_get_i2caux( - struct adapter_service *as) -{ - return as->i2caux; -} - bool dal_adapter_service_get_embedded_panel_info( struct adapter_service *as, struct embedded_panel_info *info) diff --git a/drivers/gpu/drm/amd/dal/dc/bios/bios_parser.c b/drivers/gpu/drm/amd/dal/dc/bios/bios_parser.c index 41093c21ce30..586df420f87b 100644 --- a/drivers/gpu/drm/amd/dal/dc/bios/bios_parser.c +++ b/drivers/gpu/drm/amd/dal/dc/bios/bios_parser.c @@ -2968,7 +2968,7 @@ static bool i2c_read( /* TODO route this through drm i2c_adapter */ result = dal_i2caux_submit_i2c_command( - dal_adapter_service_get_i2caux(as), + ddc->ctx->i2caux, ddc, &cmd); } diff --git a/drivers/gpu/drm/amd/dal/dc/core/dc.c b/drivers/gpu/drm/amd/dal/dc/core/dc.c index ec33cf9a7fd0..766cdb1d4286 100644 --- a/drivers/gpu/drm/amd/dal/dc/core/dc.c +++ b/drivers/gpu/drm/amd/dal/dc/core/dc.c @@ -479,6 +479,39 @@ static void allocate_dc_stream_funcs(struct core_dc *core_dc) set_test_pattern; } +static void destruct(struct core_dc *dc) +{ + resource_validate_ctx_destruct(dc->current_context); + + dm_free(dc->temp_flip_context); + dc->current_context = NULL; + + destroy_links(dc); + + if (dc->res_pool) + dc->res_pool->funcs->destroy(&dc->res_pool); + + if (dc->ctx->gpio_service) + dal_gpio_service_destroy(&dc->ctx->gpio_service); + + if (dc->ctx->adapter_srv) + dal_adapter_service_destroy(&dc->ctx->adapter_srv); + + if (dc->ctx->i2caux) + dal_i2caux_destroy(&dc->ctx->i2caux); + + if (dc->ctx->created_bios) + dal_bios_parser_destroy(&dc->ctx->dc_bios); + + if (dc->ctx->logger) + dal_logger_destroy(&dc->ctx->logger); + + dm_free(dc->current_context); + dm_free(dc->ctx); + + dc->ctx = NULL; +} + static bool construct(struct core_dc *dc, const struct dc_init_data *init_params) { @@ -543,6 +576,14 @@ static bool construct(struct core_dc *dc, dc_ctx->created_bios = true; } + /* Create I2C AUX */ + dc_ctx->i2caux = dal_i2caux_create(dc_ctx); + + if (!dc_ctx->i2caux) { + ASSERT_CRITICAL(false); + goto failed_to_create_i2caux; + } + /* TODO: Refactor DCE code to remove AS and asic caps */ if (dc_version < DCE_VERSION_MAX) { /* Create adapter service */ @@ -552,6 +593,7 @@ static bool construct(struct core_dc *dc, dm_error("%s: create_as() failed!\n", __func__); goto as_fail; } + dc_ctx->adapter_srv = as; } /* Create GPIO service */ @@ -583,42 +625,18 @@ static bool construct(struct core_dc *dc, /**** error handling here ****/ create_links_fail: - dc->res_pool->funcs->destroy(&dc->res_pool); create_resource_fail: - if (dc->ctx->gpio_service) - dal_gpio_service_destroy(&dc_ctx->gpio_service); gpio_fail: - if (as) - dal_adapter_service_destroy(&as); as_fail: - if (dc->ctx->created_bios) - dal_bios_parser_destroy(&dc->ctx->dc_bios); +failed_to_create_i2caux: bios_fail: - dal_logger_destroy(&dc_ctx->logger); logger_fail: - dm_free(dc->current_context); val_ctx_fail: - dm_free(dc_ctx); ctx_fail: + destruct(dc); return false; } -static void destruct(struct core_dc *dc) -{ - dal_gpio_service_destroy(&dc->ctx->gpio_service); - resource_validate_ctx_destruct(dc->current_context); - dm_free(dc->current_context); - dm_free(dc->temp_flip_context); - dc->current_context = NULL; - destroy_links(dc); - dc->res_pool->funcs->destroy(&dc->res_pool); - dal_logger_destroy(&dc->ctx->logger); - if (dc->ctx->created_bios) - dal_bios_parser_destroy(&dc->ctx->dc_bios); - dm_free(dc->ctx); - dc->ctx = NULL; -} - /* void ProgramPixelDurationV(unsigned int pixelClockInKHz ) { @@ -1710,7 +1728,7 @@ bool dc_submit_i2c( struct ddc_service *ddc = link->ddc; return dal_i2caux_submit_i2c_command( - dal_adapter_service_get_i2caux(ddc->as), + ddc->ctx->i2caux, ddc->ddc_pin, cmd); } diff --git a/drivers/gpu/drm/amd/dal/dc/core/dc_link_ddc.c b/drivers/gpu/drm/amd/dal/dc/core/dc_link_ddc.c index c440d9d123ad..c945d4b27def 100644 --- a/drivers/gpu/drm/amd/dal/dc/core/dc_link_ddc.c +++ b/drivers/gpu/drm/amd/dal/dc/core/dc_link_ddc.c @@ -507,7 +507,7 @@ static uint8_t aux_read_edid_block( } if (!dal_i2caux_submit_aux_command( - dal_adapter_service_get_i2caux(ddc->as), + ddc->ctx->i2caux, ddc->ddc_pin, &cmd)) /* cannot read, break*/ @@ -530,7 +530,7 @@ static uint8_t aux_read_edid_block( cmd.payloads = payloads; result = dal_i2caux_submit_aux_command( - dal_adapter_service_get_i2caux(ddc->as), + ddc->ctx->i2caux, ddc->ddc_pin, &cmd); @@ -927,7 +927,7 @@ bool dal_ddc_service_query_ddc_data( dal_ddc_aux_payloads_get_count(payloads); ret = dal_i2caux_submit_aux_command( - dal_adapter_service_get_i2caux(ddc->as), + ddc->ctx->i2caux, ddc->ddc_pin, &command); @@ -989,7 +989,7 @@ enum ddc_result dal_ddc_service_read_dpcd_data( } if (dal_i2caux_submit_aux_command( - dal_adapter_service_get_i2caux(ddc->as), + ddc->ctx->i2caux, ddc->ddc_pin, &command)) return DDC_RESULT_SUCESSFULL; @@ -1023,7 +1023,7 @@ enum ddc_result dal_ddc_service_write_dpcd_data( } if (dal_i2caux_submit_aux_command( - dal_adapter_service_get_i2caux(ddc->as), + ddc->ctx->i2caux, ddc->ddc_pin, &command)) return DDC_RESULT_SUCESSFULL; diff --git a/drivers/gpu/drm/amd/dal/dc/dc_types.h b/drivers/gpu/drm/amd/dal/dc/dc_types.h index b30dfbf7281e..15f45180a0cf 100644 --- a/drivers/gpu/drm/amd/dal/dc/dc_types.h +++ b/drivers/gpu/drm/amd/dal/dc/dc_types.h @@ -81,6 +81,7 @@ struct dc_context { bool created_bios; struct gpio_service *gpio_service; struct i2caux *i2caux; + struct adapter_service *adapter_srv; }; /* diff --git a/drivers/gpu/drm/amd/dal/dc/dce100/dce100_resource.c b/drivers/gpu/drm/amd/dal/dc/dce100/dce100_resource.c index d1587fe3b854..81319166ed16 100644 --- a/drivers/gpu/drm/amd/dal/dc/dce100/dce100_resource.c +++ b/drivers/gpu/drm/amd/dal/dc/dce100/dce100_resource.c @@ -659,9 +659,6 @@ static void destruct(struct dce110_resource_pool *pool) if (pool->base.irqs != NULL) dal_irq_service_destroy(&pool->base.irqs); - - if (pool->base.adapter_srv != NULL) - dal_adapter_service_destroy(&pool->base.adapter_srv); } static enum dc_status validate_mapped_resource( diff --git a/drivers/gpu/drm/amd/dal/dc/dce110/dce110_resource.c b/drivers/gpu/drm/amd/dal/dc/dce110/dce110_resource.c index 33f4455e80f6..15958e6cedd1 100644 --- a/drivers/gpu/drm/amd/dal/dc/dce110/dce110_resource.c +++ b/drivers/gpu/drm/amd/dal/dc/dce110/dce110_resource.c @@ -631,10 +631,6 @@ static void destruct(struct dce110_resource_pool *pool) if (pool->base.irqs != NULL) { dal_irq_service_destroy(&pool->base.irqs); } - - if (pool->base.adapter_srv != NULL) { - dal_adapter_service_destroy(&pool->base.adapter_srv); - } } diff --git a/drivers/gpu/drm/amd/dal/dc/dce112/dce112_resource.c b/drivers/gpu/drm/amd/dal/dc/dce112/dce112_resource.c index 5d53a0b9e8e1..950c505cde66 100644 --- a/drivers/gpu/drm/amd/dal/dc/dce112/dce112_resource.c +++ b/drivers/gpu/drm/amd/dal/dc/dce112/dce112_resource.c @@ -692,10 +692,6 @@ static void destruct(struct dce110_resource_pool *pool) if (pool->base.irqs != NULL) { dal_irq_service_destroy(&pool->base.irqs); } - - if (pool->base.adapter_srv != NULL) { - dal_adapter_service_destroy(&pool->base.adapter_srv); - } } static struct clock_source *find_matching_pll(struct resource_context *res_ctx, diff --git a/drivers/gpu/drm/amd/dal/dc/dce80/dce80_resource.c b/drivers/gpu/drm/amd/dal/dc/dce80/dce80_resource.c index 932f37559da9..1e38c9aacdad 100644 --- a/drivers/gpu/drm/amd/dal/dc/dce80/dce80_resource.c +++ b/drivers/gpu/drm/amd/dal/dc/dce80/dce80_resource.c @@ -609,10 +609,6 @@ static void destruct(struct dce110_resource_pool *pool) if (pool->base.irqs != NULL) { dal_irq_service_destroy(&pool->base.irqs); } - - if (pool->base.adapter_srv != NULL) { - dal_adapter_service_destroy(&pool->base.adapter_srv); - } } static enum dc_status validate_mapped_resource( diff --git a/drivers/gpu/drm/amd/dal/include/adapter_service_interface.h b/drivers/gpu/drm/amd/dal/include/adapter_service_interface.h index 7b001f0aa9db..39adbbf25638 100644 --- a/drivers/gpu/drm/amd/dal/include/adapter_service_interface.h +++ b/drivers/gpu/drm/amd/dal/include/adapter_service_interface.h @@ -297,7 +297,6 @@ struct adapter_service { struct dc_context *ctx; struct asic_capability *asic_cap; enum dce_environment dce_environment; - struct i2caux *i2caux; uint32_t platform_methods_mask; uint32_t ac_level_percentage; uint32_t dc_level_percentage; @@ -371,10 +370,6 @@ bool dal_adapter_service_get_i2c_info( struct graphics_object_id id, struct graphics_object_i2c_info *i2c_info); -/* Get i2c aux handler */ -struct i2caux *dal_adapter_service_get_i2caux( - struct adapter_service *as); - struct dal_asic_runtime_flags dal_adapter_service_get_asic_runtime_flags( struct adapter_service *as); -- 2.10.1