Skip to content

Commit cd9e6d6

Browse files
committed
drm/amd/display/dml2: use vzalloc rather than kzalloc
The structures are large and they do not require contiguous memory so use vzalloc. Fixes: 70839da ("drm/amd/display: Add new DCN401 sources") Closes: https://gitlab.freedesktop.org/drm/amd/-/issues/4126 Cc: Aurabindo Pillai <aurabindo.pillai@amd.com> Reviewed-by: Aurabindo Pillai <aurabindo.pillai@amd.com> Signed-off-by: Alex Deucher <alexander.deucher@amd.com> (cherry picked from commit 20c50a9) Cc: stable@vger.kernel.org
1 parent 2036be3 commit cd9e6d6

File tree

2 files changed

+10
-7
lines changed

2 files changed

+10
-7
lines changed

drivers/gpu/drm/amd/display/dc/dml2/dml21/dml21_wrapper.c

Lines changed: 6 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,7 @@
22
//
33
// Copyright 2024 Advanced Micro Devices, Inc.
44

5+
#include <linux/vmalloc.h>
56

67
#include "dml2_internal_types.h"
78
#include "dml_top.h"
@@ -13,11 +14,11 @@
1314

1415
static bool dml21_allocate_memory(struct dml2_context **dml_ctx)
1516
{
16-
*dml_ctx = kzalloc(sizeof(struct dml2_context), GFP_KERNEL);
17+
*dml_ctx = vzalloc(sizeof(struct dml2_context));
1718
if (!(*dml_ctx))
1819
return false;
1920

20-
(*dml_ctx)->v21.dml_init.dml2_instance = kzalloc(sizeof(struct dml2_instance), GFP_KERNEL);
21+
(*dml_ctx)->v21.dml_init.dml2_instance = vzalloc(sizeof(struct dml2_instance));
2122
if (!((*dml_ctx)->v21.dml_init.dml2_instance))
2223
return false;
2324

@@ -27,7 +28,7 @@ static bool dml21_allocate_memory(struct dml2_context **dml_ctx)
2728
(*dml_ctx)->v21.mode_support.display_config = &(*dml_ctx)->v21.display_config;
2829
(*dml_ctx)->v21.mode_programming.display_config = (*dml_ctx)->v21.mode_support.display_config;
2930

30-
(*dml_ctx)->v21.mode_programming.programming = kzalloc(sizeof(struct dml2_display_cfg_programming), GFP_KERNEL);
31+
(*dml_ctx)->v21.mode_programming.programming = vzalloc(sizeof(struct dml2_display_cfg_programming));
3132
if (!((*dml_ctx)->v21.mode_programming.programming))
3233
return false;
3334

@@ -115,8 +116,8 @@ bool dml21_create(const struct dc *in_dc, struct dml2_context **dml_ctx, const s
115116

116117
void dml21_destroy(struct dml2_context *dml2)
117118
{
118-
kfree(dml2->v21.dml_init.dml2_instance);
119-
kfree(dml2->v21.mode_programming.programming);
119+
vfree(dml2->v21.dml_init.dml2_instance);
120+
vfree(dml2->v21.mode_programming.programming);
120121
}
121122

122123
static void dml21_calculate_rq_and_dlg_params(const struct dc *dc, struct dc_state *context, struct resource_context *out_new_hw_state,

drivers/gpu/drm/amd/display/dc/dml2/dml2_wrapper.c

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -24,6 +24,8 @@
2424
*
2525
*/
2626

27+
#include <linux/vmalloc.h>
28+
2729
#include "display_mode_core.h"
2830
#include "dml2_internal_types.h"
2931
#include "dml2_utils.h"
@@ -747,7 +749,7 @@ bool dml2_validate(const struct dc *in_dc, struct dc_state *context, struct dml2
747749

748750
static inline struct dml2_context *dml2_allocate_memory(void)
749751
{
750-
return (struct dml2_context *) kzalloc(sizeof(struct dml2_context), GFP_KERNEL);
752+
return (struct dml2_context *) vzalloc(sizeof(struct dml2_context));
751753
}
752754

753755
static void dml2_init(const struct dc *in_dc, const struct dml2_configuration_options *config, struct dml2_context **dml2)
@@ -821,7 +823,7 @@ void dml2_destroy(struct dml2_context *dml2)
821823

822824
if (dml2->architecture == dml2_architecture_21)
823825
dml21_destroy(dml2);
824-
kfree(dml2);
826+
vfree(dml2);
825827
}
826828

827829
void dml2_extract_dram_and_fclk_change_support(struct dml2_context *dml2,

0 commit comments

Comments
 (0)