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 47f529ce280ae19db1ebdddfc50d15eacb1ec3fa..5b3d36d418228cd7fa1d76831e15abe21357f173 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 bd39f100a8a74f6b166725c801ec17f05d4ccdcc..d54f5b956809abb56202829eb1860417941fc277 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 1ef23398244870d8375e90a6e08ef6ef5ca925be..40fe54c6087994b9bd3b656652b0bdaf30fa25c4 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 5cb63f0de989b23556e9717bdb948d62765b281e..3b848d4aca8cad92da551bacc0249dddc27e324b 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 e2d9e11be4b0e10a58bef7fb6eedaccc16018171..3c061d4f214fee776315e8ef17e494516850f9b2 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 58bd131d5b4849bc70f0bc29f4448d6d44d38daf..9edd369c122068f42db9a7b2e49000ea377a7ce6 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 0b86cee4876f46986f58bd32c0937d9d956d27ed..ba995d3f23182438b70e4e42a9053ad7698f44b1 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 f8f85490e77e20d8494e9356a6e4133cbaedf7ca..f67c18375bfdb7ae63adce970a42cfebf969a19a 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 d03165e71dc651764e37ff1dcfbef441bda33670..92280cc05e2dbe083a2165ae8042db0771146730 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);