drm/amd/display: remove hw access from dc_destroy
authorJun Lei <Jun.Lei@amd.com>
Thu, 15 Aug 2019 19:22:34 +0000 (15:22 -0400)
committerAlex Deucher <alexander.deucher@amd.com>
Fri, 13 Sep 2019 23:02:52 +0000 (18:02 -0500)
[why]
dc_destroy should only clean up SW, this is because GPUs may be
removed before driver unload, leading to HW to be unavailable.

[how]
remove GPIO close as part of GPIO destroy, this is unnecessary because
GPIO is not shared, and GPIOs are generally closed after being opened

Add tracking to HW access during destructor to make future issues
easier to pinpoint, and block access to prevent hangs.

Signed-off-by: Jun Lei <Jun.Lei@amd.com>
Reviewed-by: Yongqiang Sun <yongqiang.sun@amd.com>
Acked-by: Bhawanpreet Lakha <Bhawanpreet.Lakha@amd.com>
Signed-off-by: Alex Deucher <alexander.deucher@amd.com>
drivers/gpu/drm/amd/display/dc/clk_mgr/dcn10/rv1_clk_mgr.c
drivers/gpu/drm/amd/display/dc/core/dc.c
drivers/gpu/drm/amd/display/dc/core/dc_link.c
drivers/gpu/drm/amd/display/dc/dc.h
drivers/gpu/drm/amd/display/dc/dc_stream.h
drivers/gpu/drm/amd/display/dc/dce/dce_abm.c
drivers/gpu/drm/amd/display/dc/dce/dce_dmcu.c
drivers/gpu/drm/amd/display/dc/gpio/gpio_base.c
drivers/gpu/drm/amd/display/dc/gpio/gpio_service.c

index 47f529c..5b3d36d 100644 (file)
@@ -139,6 +139,9 @@ static void rv1_update_clocks(struct clk_mgr *clk_mgr_base,
 
        ASSERT(clk_mgr->pp_smu);
 
+       if (dc->work_arounds.skip_clock_update)
+               return;
+
        pp_smu = &clk_mgr->pp_smu->rv_funcs;
 
        display_count = clk_mgr_helper_get_active_display_cnt(dc, context);
index bd39f10..d54f5b9 100644 (file)
@@ -1886,6 +1886,7 @@ static void commit_planes_do_stream_update(struct dc *dc,
                struct dc_state *context)
 {
        int j;
+       bool should_program_abm;
 
        // Stream updates
        for (j = 0; j < dc->res_pool->pipe_count; j++) {
@@ -1966,14 +1967,21 @@ static void commit_planes_do_stream_update(struct dc *dc,
                        }
 
                        if (stream_update->abm_level && pipe_ctx->stream_res.abm) {
-                               if (pipe_ctx->stream_res.tg->funcs->is_blanked) {
-                                       // if otg funcs defined check if blanked before programming
-                                       if (!pipe_ctx->stream_res.tg->funcs->is_blanked(pipe_ctx->stream_res.tg))
+                               should_program_abm = true;
+
+                               // if otg funcs defined check if blanked before programming
+                               if (pipe_ctx->stream_res.tg->funcs->is_blanked)
+                                       if (pipe_ctx->stream_res.tg->funcs->is_blanked(pipe_ctx->stream_res.tg))
+                                               should_program_abm = false;
+
+                               if (should_program_abm) {
+                                       if (*stream_update->abm_level == ABM_LEVEL_IMMEDIATE_DISABLE) {
+                                               pipe_ctx->stream_res.abm->funcs->set_abm_immediate_disable(pipe_ctx->stream_res.abm);
+                                       } else {
                                                pipe_ctx->stream_res.abm->funcs->set_abm_level(
                                                        pipe_ctx->stream_res.abm, stream->abm_level);
-                               } else
-                                       pipe_ctx->stream_res.abm->funcs->set_abm_level(
-                                               pipe_ctx->stream_res.abm, stream->abm_level);
+                                       }
+                               }
                        }
                }
        }
index 1ef2339..40fe54c 100644 (file)
@@ -79,7 +79,6 @@ static void destruct(struct dc_link *link)
        int i;
 
        if (link->hpd_gpio != NULL) {
-               dal_gpio_close(link->hpd_gpio);
                dal_gpio_destroy_irq(&link->hpd_gpio);
                link->hpd_gpio = NULL;
        }
index 5cb63f0..3b848d4 100644 (file)
@@ -117,13 +117,13 @@ struct dc_caps {
        struct dc_plane_cap planes[MAX_PLANES];
 };
 
-#if defined(CONFIG_DRM_AMD_DC_DCN2_0)
 struct dc_bug_wa {
+#if defined(CONFIG_DRM_AMD_DC_DCN2_0)
        bool no_connect_phy_config;
        bool dedcn20_305_wa;
+#endif
        bool skip_clock_update;
 };
-#endif
 
 struct dc_dcc_surface_param {
        struct dc_size surface_size;
@@ -463,9 +463,7 @@ struct dc {
        struct dc_config config;
        struct dc_debug_options debug;
        struct dc_bounding_box_overrides bb_overrides;
-#if defined(CONFIG_DRM_AMD_DC_DCN2_0)
        struct dc_bug_wa work_arounds;
-#endif
        struct dc_context *ctx;
 #ifdef CONFIG_DRM_AMD_DC_DCN2_0
        struct dc_phy_addr_space_config vm_pa_config;
index e2d9e11..3c061d4 100644 (file)
@@ -232,6 +232,8 @@ struct dc_stream_state {
        union stream_update_flags update_flags;
 };
 
+#define ABM_LEVEL_IMMEDIATE_DISABLE 0xFFFFFFFF
+
 struct dc_stream_update {
        struct dc_stream_state *stream;
 
index 58bd131..9edd369 100644 (file)
@@ -489,9 +489,6 @@ void dce_abm_destroy(struct abm **abm)
 {
        struct dce_abm *abm_dce = TO_DCE_ABM(*abm);
 
-       if (abm_dce->base.dmcu_is_running == true)
-               abm_dce->base.funcs->set_abm_immediate_disable(*abm);
-
        kfree(abm_dce);
        *abm = NULL;
 }
index 0b86cee..ba995d3 100644 (file)
@@ -907,9 +907,6 @@ void dce_dmcu_destroy(struct dmcu **dmcu)
 {
        struct dce_dmcu *dmcu_dce = TO_DCE_DMCU(*dmcu);
 
-       if (dmcu_dce->base.dmcu_state == DMCU_RUNNING)
-               dmcu_dce->base.funcs->set_psr_enable(*dmcu, false, true);
-
        kfree(dmcu_dce);
        *dmcu = NULL;
 }
index f8f8549..f67c183 100644 (file)
@@ -321,8 +321,6 @@ void dal_gpio_destroy(
                return;
        }
 
-       dal_gpio_close(*gpio);
-
        switch ((*gpio)->id) {
        case GPIO_ID_DDC_DATA:
                kfree((*gpio)->hw_container.ddc);
index d03165e..92280cc 100644 (file)
@@ -169,7 +169,6 @@ void dal_gpio_destroy_generic_mux(
                return;
        }
 
-       dal_gpio_close(*mux);
        dal_gpio_destroy(mux);
        kfree(*mux);
 
@@ -460,7 +459,6 @@ void dal_gpio_destroy_irq(
                return;
        }
 
-       dal_gpio_close(*irq);
        dal_gpio_destroy(irq);
        kfree(*irq);