<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);">
Thanks for the heads up!</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 id="Signature" style="color: inherit;">
<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> Mahfooz, Hamza <Hamza.Mahfooz@amd.com><br>
<b>Sent:</b> Tuesday, June 4, 2024 1:50 PM<br>
<b>To:</b> Pillai, Aurabindo <Aurabindo.Pillai@amd.com>; amd-gfx@lists.freedesktop.org <amd-gfx@lists.freedesktop.org><br>
<b>Cc:</b> arnd@arndb.de <arnd@arndb.de>; Deucher, Alexander <Alexander.Deucher@amd.com>; Wentland, Harry <Harry.Wentland@amd.com>; Siqueira, Rodrigo <Rodrigo.Siqueira@amd.com>; Zuo, Jerry <Jerry.Zuo@amd.com><br>
<b>Subject:</b> Re: [PATCH] Revert "drm/amd/display: avoid large on-stack structures"</font>
<div> </div>
</div>
<div class="BodyFragment"><font size="2"><span style="font-size:11pt;">
<div class="PlainText">On 6/4/24 13:45, Aurabindo Pillai wrote:<br>
> This reverts commit 44069f0f9b1fe577c5d4f05fa9eb02db8c618adc since<br>
> the code path is called from FPU context, and triggers error like:<br>
> <br>
> [ 26.924055] BUG: sleeping function called from invalid context at include/linux/sched/mm.h:306<br>
> [ 26.924060] in_atomic(): 1, irqs_disabled(): 0, non_block: 0, pid: 1022, name: modprobe<br>
> [ 26.924063] preempt_count: 2, expected: 0<br>
> [ 26.924064] RCU nest depth: 0, expected: 0<br>
> [ 26.924066] Preemption disabled at:<br>
> [ 26.924067] [<ffffffffc089e5e0>] dc_fpu_begin+0x30/0xd0 [amdgpu]<br>
> [ 26.924322] CPU: 9 PID: 1022 Comm: modprobe Not tainted 6.8.0+ #20<br>
> [ 26.924325] Hardware name: System manufacturer System Product Name/CROSSHAIR VI HERO, BIOS 6302 10/23/2018<br>
> [ 26.924326] Call Trace:<br>
> [ 26.924327] <TASK><br>
> [ 26.924329] dump_stack_lvl+0x37/0x50<br>
> [ 26.924333] ? dc_fpu_begin+0x30/0xd0 [amdgpu]<br>
> [ 26.924589] dump_stack+0x10/0x20<br>
> [ 26.924592] __might_resched+0x16a/0x1c0<br>
> [ 26.924596] __might_sleep+0x42/0x70<br>
> [ 26.924598] __kmalloc_node_track_caller+0x2ad/0x4b0<br>
> [ 26.924601] ? dm_helpers_allocate_gpu_mem+0x12/0x20 [amdgpu]<br>
> [ 26.924855] ? dcn401_update_bw_bounding_box+0x2a/0xf0 [amdgpu]<br>
> [ 26.925122] kmemdup+0x20/0x50<br>
> [ 26.925124] ? kernel_fpu_begin_mask+0x6b/0xe0<br>
> [ 26.925127] ? kmemdup+0x20/0x50<br>
> [ 26.925129] dcn401_update_bw_bounding_box+0x2a/0xf0 [amdgpu]<br>
> [ 26.925393] dc_create+0x311/0x670 [amdgpu]<br>
> [ 26.925649] amdgpu_dm_init+0x2aa/0x1fa0 [amdgpu]<br>
> [ 26.925903] ? irq_work_queue+0x38/0x50<br>
> [ 26.925907] ? vprintk_emit+0x1e7/0x270<br>
> [ 26.925910] ? dev_printk_emit+0x83/0xb0<br>
> [ 26.925914] ? amdgpu_device_rreg+0x17/0x20 [amdgpu]<br>
> [ 26.926133] dm_hw_init+0x14/0x30 [amdgpu]<br>
> ---<br>
> drivers/gpu/drm/amd/display/dc/core/dc_state.c | 16 +++++-----------<br>
> .../display/dc/resource/dcn401/dcn401_resource.c | 16 +++++-----------<br>
> 2 files changed, 10 insertions(+), 22 deletions(-)<br>
<br>
You probably want something like<br>
<a href="https://patchwork.freedesktop.org/patch/597044/">https://patchwork.freedesktop.org/patch/597044/</a> instead.<br>
<br>
> <br>
> diff --git a/drivers/gpu/drm/amd/display/dc/core/dc_state.c b/drivers/gpu/drm/amd/display/dc/core/dc_state.c<br>
> index 8ea9391c60b7..70928223b642 100644<br>
> --- a/drivers/gpu/drm/amd/display/dc/core/dc_state.c<br>
> +++ b/drivers/gpu/drm/amd/display/dc/core/dc_state.c<br>
> @@ -193,11 +193,7 @@ static void init_state(struct dc *dc, struct dc_state *state)<br>
> struct dc_state *dc_state_create(struct dc *dc, struct dc_state_create_params *params)<br>
> {<br>
> #ifdef CONFIG_DRM_AMD_DC_FP<br>
> - struct dml2_configuration_options *dml2_opt;<br>
> -<br>
> - dml2_opt = kmemdup(&dc->dml2_options, sizeof(*dml2_opt), GFP_KERNEL);<br>
> - if (!dml2_opt)<br>
> - return NULL;<br>
> + struct dml2_configuration_options dml2_opt = dc->dml2_options;<br>
> #endif<br>
> struct dc_state *state = kvzalloc(sizeof(struct dc_state),<br>
> GFP_KERNEL);<br>
> @@ -211,14 +207,12 @@ struct dc_state *dc_state_create(struct dc *dc, struct dc_state_create_params *p<br>
> <br>
> #ifdef CONFIG_DRM_AMD_DC_FP<br>
> if (dc->debug.using_dml2) {<br>
> - dml2_opt->use_clock_dc_limits = false;<br>
> - dml2_create(dc, dml2_opt, &state->bw_ctx.dml2);<br>
> + dml2_opt.use_clock_dc_limits = false;<br>
> + dml2_create(dc, &dml2_opt, &state->bw_ctx.dml2);<br>
> <br>
> - dml2_opt->use_clock_dc_limits = true;<br>
> - dml2_create(dc, dml2_opt, &state->bw_ctx.dml2_dc_power_source);<br>
> + dml2_opt.use_clock_dc_limits = true;<br>
> + dml2_create(dc, &dml2_opt, &state->bw_ctx.dml2_dc_power_source);<br>
> }<br>
> -<br>
> - kfree(dml2_opt);<br>
> #endif<br>
> <br>
> kref_init(&state->refcount);<br>
> diff --git a/drivers/gpu/drm/amd/display/dc/resource/dcn401/dcn401_resource.c b/drivers/gpu/drm/amd/display/dc/resource/dcn401/dcn401_resource.c<br>
> index 8dfb0a3d21cb..247bac177d1b 100644<br>
> --- a/drivers/gpu/drm/amd/display/dc/resource/dcn401/dcn401_resource.c<br>
> +++ b/drivers/gpu/drm/amd/display/dc/resource/dcn401/dcn401_resource.c<br>
> @@ -1581,27 +1581,21 @@ static struct dc_cap_funcs cap_funcs = {<br>
> <br>
> static void dcn401_update_bw_bounding_box(struct dc *dc, struct clk_bw_params *bw_params)<br>
> {<br>
> - struct dml2_configuration_options *dml2_opt;<br>
> -<br>
> - dml2_opt = kmemdup(&dc->dml2_options, sizeof(*dml2_opt), GFP_KERNEL);<br>
> - if (!dml2_opt)<br>
> - return;<br>
> + struct dml2_configuration_options dml2_opt = dc->dml2_options;<br>
> <br>
> DC_FP_START();<br>
> <br>
> dcn401_update_bw_bounding_box_fpu(dc, bw_params);<br>
> <br>
> - dml2_opt->use_clock_dc_limits = false;<br>
> + dml2_opt.use_clock_dc_limits = false;<br>
> if (dc->debug.using_dml2 && dc->current_state && dc->current_state->bw_ctx.dml2)<br>
> - dml2_reinit(dc, dml2_opt, &dc->current_state->bw_ctx.dml2);<br>
> + dml2_reinit(dc, &dml2_opt, &dc->current_state->bw_ctx.dml2);<br>
> <br>
> - dml2_opt->use_clock_dc_limits = true;<br>
> + dml2_opt.use_clock_dc_limits = true;<br>
> if (dc->debug.using_dml2 && dc->current_state && dc->current_state->bw_ctx.dml2_dc_power_source)<br>
> - dml2_reinit(dc, dml2_opt, &dc->current_state->bw_ctx.dml2_dc_power_source);<br>
> + dml2_reinit(dc, &dml2_opt, &dc->current_state->bw_ctx.dml2_dc_power_source);<br>
> <br>
> DC_FP_END();<br>
> -<br>
> - kfree(dml2_opt);<br>
> }<br>
> <br>
> enum dc_status dcn401_patch_unknown_plane_state(struct dc_plane_state *plane_state)<br>
-- <br>
Hamza<br>
<br>
</div>
</span></font></div>
</div>
</body>
</html>