drm/amd/display: Move the memory allocation out of dcn21_validate_bandwidth_fp().
authorSebastian Andrzej Siewior <bigeasy@linutronix.de>
Thu, 21 Sep 2023 14:15:15 +0000 (16:15 +0200)
committerAlex Deucher <alexander.deucher@amd.com>
Mon, 9 Oct 2023 20:47:59 +0000 (16:47 -0400)
dcn21_validate_bandwidth_fp() is invoked while FPU access has been
enabled. FPU access requires disabling preemption even on PREEMPT_RT.
It is not possible to allocate memory with disabled preemption even with
GFP_ATOMIC on PREEMPT_RT.

Move the memory allocation before FPU access is enabled.

Link: https://bugzilla.kernel.org/show_bug.cgi?id=217928
Acked-by: Harry Wentland <harry.wentland@amd.com>
Reviewed-by: Rodrigo Siqueira <Rodrigo.Siqueira@amd.com>
Signed-off-by: Sebastian Andrzej Siewior <bigeasy@linutronix.de>
Signed-off-by: Hamza Mahfooz <hamza.mahfooz@amd.com>
Signed-off-by: Alex Deucher <alexander.deucher@amd.com>
drivers/gpu/drm/amd/display/dc/dcn21/dcn21_resource.c
drivers/gpu/drm/amd/display/dc/dml/dcn20/dcn20_fpu.c
drivers/gpu/drm/amd/display/dc/dml/dcn20/dcn20_fpu.h

index 71e82692dd7c9d995604f1637d8946fe4cbfb07e..d8d77dd8a6dd08c1c7dd1c2d36db60b8b5170d63 100644 (file)
@@ -953,9 +953,17 @@ static bool dcn21_validate_bandwidth(struct dc *dc, struct dc_state *context,
                bool fast_validate)
 {
        bool voltage_supported;
+       display_e2e_pipe_params_st *pipes;
+
+       pipes = kcalloc(dc->res_pool->pipe_count, sizeof(display_e2e_pipe_params_st), GFP_KERNEL);
+       if (!pipes)
+               return false;
+
        DC_FP_START();
-       voltage_supported = dcn21_validate_bandwidth_fp(dc, context, fast_validate);
+       voltage_supported = dcn21_validate_bandwidth_fp(dc, context, fast_validate, pipes);
        DC_FP_END();
+
+       kfree(pipes);
        return voltage_supported;
 }
 
index abd8169daf30d92fe754baa01df99f2d79f59cc2..e77a88db777a46cc21d9791d2fbf5a89c66d7d32 100644 (file)
@@ -2218,9 +2218,8 @@ static void dcn21_calculate_wm(struct dc *dc, struct dc_state *context,
                                                &context->bw_ctx.dml, pipes, pipe_cnt);
 }
 
-bool dcn21_validate_bandwidth_fp(struct dc *dc,
-                                struct dc_state *context,
-                                bool fast_validate)
+bool dcn21_validate_bandwidth_fp(struct dc *dc, struct dc_state *context,
+                                bool fast_validate, display_e2e_pipe_params_st *pipes)
 {
        bool out = false;
 
@@ -2229,7 +2228,6 @@ bool dcn21_validate_bandwidth_fp(struct dc *dc,
        int vlevel = 0;
        int pipe_split_from[MAX_PIPES];
        int pipe_cnt = 0;
-       display_e2e_pipe_params_st *pipes = kzalloc(dc->res_pool->pipe_count * sizeof(display_e2e_pipe_params_st), GFP_ATOMIC);
        DC_LOGGER_INIT(dc->ctx->logger);
 
        BW_VAL_TRACE_COUNT();
@@ -2269,7 +2267,6 @@ validate_fail:
        out = false;
 
 validate_out:
-       kfree(pipes);
 
        BW_VAL_TRACE_FINISH();
 
index c51badf7b68a9201da048f824ded2817c7a0a68d..a81a0b9e688420861424a87a9b4124fcb0d79b45 100644 (file)
@@ -77,9 +77,8 @@ int dcn21_populate_dml_pipes_from_context(struct dc *dc,
                                          struct dc_state *context,
                                          display_e2e_pipe_params_st *pipes,
                                          bool fast_validate);
-bool dcn21_validate_bandwidth_fp(struct dc *dc,
-                                struct dc_state *context,
-                                bool fast_validate);
+bool dcn21_validate_bandwidth_fp(struct dc *dc, struct dc_state *context, bool
+                                fast_validate, display_e2e_pipe_params_st *pipes);
 void dcn21_update_bw_bounding_box(struct dc *dc, struct clk_bw_params *bw_params);
 
 void dcn21_clk_mgr_set_bw_params_wm_table(struct clk_bw_params *bw_params);