<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=us-ascii">
<style type="text/css" style="display:none;"> P {margin-top:0;margin-bottom:0;} </style>
</head>
<body dir="ltr">
<p style="font-family:Calibri;font-size:10pt;color:#0000FF;margin:5pt;font-style:normal;font-weight:normal;text-decoration:none;" align="Left">
[AMD Official Use Only - AMD Internal Distribution Only]<br>
</p>
<br>
<div>
<div class="elementToProof" style="font-family: Aptos, Aptos_EmbeddedFont, Aptos_MSFontService, Calibri, Helvetica, sans-serif; font-size: 12pt; color: rgb(0, 0, 0);">
Reviewed-by: Aurabindo Pillai <aurabindo.pillai@amd.com></div>
<div class="elementToProof" style="font-family: Aptos, Aptos_EmbeddedFont, Aptos_MSFontService, Calibri, Helvetica, sans-serif; font-size: 12pt; color: rgb(0, 0, 0);">
<br>
</div>
<div style="color: inherit;" class="elementToProof" id="Signature">
<div style="font-family: Calibri, Arial, Helvetica, sans-serif; font-size: 12pt; color: rgb(0, 0, 0);">
--</div>
<div style="font-family: Calibri, Arial, Helvetica, sans-serif; font-size: 12pt; color: rgb(0, 0, 0);">
<br>
</div>
<div style="font-family: Calibri, Arial, Helvetica, sans-serif; font-size: 12pt; color: rgb(0, 0, 0);">
Regards,</div>
<div style="font-family: Calibri, Arial, Helvetica, sans-serif; font-size: 12pt; color: rgb(0, 0, 0);">
Jay<br>
</div>
</div>
<div id="appendonsend"></div>
<hr style="display:inline-block;width:98%" tabindex="-1">
<div id="divRplyFwdMsg" dir="ltr"><font face="Calibri, sans-serif" style="font-size:11pt" color="#000000"><b>From:</b> Deucher, Alexander <Alexander.Deucher@amd.com><br>
<b>Sent:</b> Wednesday, April 9, 2025 5:41 PM<br>
<b>To:</b> amd-gfx@lists.freedesktop.org <amd-gfx@lists.freedesktop.org><br>
<b>Cc:</b> Deucher, Alexander <Alexander.Deucher@amd.com>; Pillai, Aurabindo <Aurabindo.Pillai@amd.com><br>
<b>Subject:</b> [PATCH] drm/amd/display/dml2: use vzalloc rather than kzalloc</font>
<div> </div>
</div>
<div class="BodyFragment"><font size="2"><span style="font-size:11pt;">
<div class="PlainText">The structures are large and they do not require continuous<br>
memory so use vzalloc.<br>
<br>
Fixes: 70839da63605 ("drm/amd/display: Add new DCN401 sources")<br>
Closes: <a href="https://gitlab.freedesktop.org/drm/amd/-/issues/4126">https://gitlab.freedesktop.org/drm/amd/-/issues/4126</a><br>
Cc: Aurabindo Pillai <aurabindo.pillai@amd.com><br>
Signed-off-by: Alex Deucher <alexander.deucher@amd.com><br>
---<br>
.../gpu/drm/amd/display/dc/dml2/dml21/dml21_wrapper.c | 11 ++++++-----<br>
drivers/gpu/drm/amd/display/dc/dml2/dml2_wrapper.c | 6 ++++--<br>
2 files changed, 10 insertions(+), 7 deletions(-)<br>
<br>
diff --git a/drivers/gpu/drm/amd/display/dc/dml2/dml21/dml21_wrapper.c b/drivers/gpu/drm/amd/display/dc/dml2/dml21/dml21_wrapper.c<br>
index 94e99e540691c..5d16f36ec95c8 100644<br>
--- a/drivers/gpu/drm/amd/display/dc/dml2/dml21/dml21_wrapper.c<br>
+++ b/drivers/gpu/drm/amd/display/dc/dml2/dml21/dml21_wrapper.c<br>
@@ -2,6 +2,7 @@<br>
//<br>
// Copyright 2024 Advanced Micro Devices, Inc.<br>
<br>
+#include <linux/vmalloc.h><br>
<br>
#include "dml2_internal_types.h"<br>
#include "dml_top.h"<br>
@@ -13,11 +14,11 @@<br>
<br>
static bool dml21_allocate_memory(struct dml2_context **dml_ctx)<br>
{<br>
- *dml_ctx = kzalloc(sizeof(struct dml2_context), GFP_KERNEL);<br>
+ *dml_ctx = vzalloc(sizeof(struct dml2_context));<br>
if (!(*dml_ctx))<br>
return false;<br>
<br>
- (*dml_ctx)->v21.dml_init.dml2_instance = kzalloc(sizeof(struct dml2_instance), GFP_KERNEL);<br>
+ (*dml_ctx)->v21.dml_init.dml2_instance = vzalloc(sizeof(struct dml2_instance));<br>
if (!((*dml_ctx)->v21.dml_init.dml2_instance))<br>
return false;<br>
<br>
@@ -27,7 +28,7 @@ static bool dml21_allocate_memory(struct dml2_context **dml_ctx)<br>
(*dml_ctx)->v21.mode_support.display_config = &(*dml_ctx)->v21.display_config;<br>
(*dml_ctx)->v21.mode_programming.display_config = (*dml_ctx)->v21.mode_support.display_config;<br>
<br>
- (*dml_ctx)->v21.mode_programming.programming = kzalloc(sizeof(struct dml2_display_cfg_programming), GFP_KERNEL);<br>
+ (*dml_ctx)->v21.mode_programming.programming = vzalloc(sizeof(struct dml2_display_cfg_programming));<br>
if (!((*dml_ctx)->v21.mode_programming.programming))<br>
return false;<br>
<br>
@@ -115,8 +116,8 @@ bool dml21_create(const struct dc *in_dc, struct dml2_context **dml_ctx, const s<br>
<br>
void dml21_destroy(struct dml2_context *dml2)<br>
{<br>
- kfree(dml2->v21.dml_init.dml2_instance);<br>
- kfree(dml2->v21.mode_programming.programming);<br>
+ vfree(dml2->v21.dml_init.dml2_instance);<br>
+ vfree(dml2->v21.mode_programming.programming);<br>
}<br>
<br>
static void dml21_calculate_rq_and_dlg_params(const struct dc *dc, struct dc_state *context, struct resource_context *out_new_hw_state,<br>
diff --git a/drivers/gpu/drm/amd/display/dc/dml2/dml2_wrapper.c b/drivers/gpu/drm/amd/display/dc/dml2/dml2_wrapper.c<br>
index 04316d719426a..525b7d04bf84c 100644<br>
--- a/drivers/gpu/drm/amd/display/dc/dml2/dml2_wrapper.c<br>
+++ b/drivers/gpu/drm/amd/display/dc/dml2/dml2_wrapper.c<br>
@@ -24,6 +24,8 @@<br>
*<br>
*/<br>
<br>
+#include <linux/vmalloc.h><br>
+<br>
#include "display_mode_core.h"<br>
#include "dml2_internal_types.h"<br>
#include "dml2_utils.h"<br>
@@ -750,7 +752,7 @@ bool dml2_validate(const struct dc *in_dc, struct dc_state *context, struct dml2<br>
<br>
static inline struct dml2_context *dml2_allocate_memory(void)<br>
{<br>
- return (struct dml2_context *) kzalloc(sizeof(struct dml2_context), GFP_KERNEL);<br>
+ return (struct dml2_context *) vzalloc(sizeof(struct dml2_context));<br>
}<br>
<br>
static void dml2_init(const struct dc *in_dc, const struct dml2_configuration_options *config, struct dml2_context **dml2)<br>
@@ -824,7 +826,7 @@ void dml2_destroy(struct dml2_context *dml2)<br>
<br>
if (dml2->architecture == dml2_architecture_21)<br>
dml21_destroy(dml2);<br>
- kfree(dml2);<br>
+ vfree(dml2);<br>
}<br>
<br>
void dml2_extract_dram_and_fclk_change_support(struct dml2_context *dml2,<br>
-- <br>
2.49.0<br>
<br>
</div>
</span></font></div>
</div>
</body>
</html>