drm/amd/display: use pre-allocated temp structure for bounding box
Subsystems (3)
Alex Deucher
maintainerPATCH 1/1 drm/amd/display: use pre-allocated temp structure for bounding box
This mirrors what the driver does for older DCN generations.
Should fix:
BUG: sleeping function called from invalid context at include/linux/sched/mm.h:306
in_atomic(): 1, irqs_disabled(): 0, non_block: 0, pid: 449, name: kworker/u64:8preempt_count: 2, expected: 0
RCU nest depth: 0, expected: 0
Preemption disabled at:ffffffffc0ce1580>] dc_fpu_begin+0x30/0xd0 [amdgpu]
CPU: 5 PID: 449 Comm: kworker/u64:8 Tainted: G W 6.8.0+ #35 Hardware name: System manufacturer System Product Name/ROG STRIX X570-E GAMING WIFI II, BIOS 4204 02/24/2022 Workqueue: events_unbound async_run_entry_fn
--- drivers/gpu/drm/amd/display/dc/dc.h | 1 + .../drm/amd/display/dc/resource/dcn32/dcn32_resource.c | 8 +++----- .../drm/amd/display/dc/resource/dcn321/dcn321_resource.c | 8 +++----- 3 files changed, 7 insertions(+), 10 deletions(-)
drivers/gpu/drm/amd/display/dc/dc.h +1 -0
@@ -1444,6 +1444,7 @@ struct dc { } scratch;struct dml2_configuration_options dml2_options; +struct dml2_configuration_options dml2_tmp;enum dc_acpi_cm_power_state power_state; };
drivers/gpu/drm/amd/display/dc/resource/dcn32/dcn32_resource.c +3 -5
@@ -2007,11 +2007,9 @@ void dcn32_calculate_wm_and_dlg(struct dc *dc, struct dc_state *context,static void dcn32_update_bw_bounding_box (struct dc *dc,struct clk_bw_params *bw_params) { -struct dml2_configuration_options *dml2_opt; +struct dml2_configuration_options *dml2_opt = &dc->dml2_tmp; - dml2_opt =kmemdup (&dc->dml2_options,sizeof (dc->dml2_options),GFP_KERNEL ); -if (!dml2_opt) -return ; +memcpy (dml2_opt, &dc->dml2_options,sizeof (dc->dml2_options));DC_FP_START ();
@@ -2027,7 +2025,7 @@ static void dcn32_update_bw_bounding_box(struct dc *dc, struct clk_bw_params *bwDC_FP_END (); -kfree (dml2_opt); +memcpy (&dc->dml2_options, dml2_opt,sizeof (dc->dml2_options)); }static struct resource_funcs dcn32_res_pool_funcs = {
drivers/gpu/drm/amd/display/dc/resource/dcn321/dcn321_resource.c +3 -5
@@ -1581,11 +1581,9 @@ static struct dc_cap_funcs cap_funcs = {static void dcn321_update_bw_bounding_box (struct dc *dc,struct clk_bw_params *bw_params) { -struct dml2_configuration_options *dml2_opt; +struct dml2_configuration_options *dml2_opt = &dc->dml2_tmp; - dml2_opt =kmemdup (&dc->dml2_options,sizeof (dc->dml2_options),GFP_KERNEL ); -if (!dml2_opt) -return ; +memcpy (dml2_opt, &dc->dml2_options,sizeof (dc->dml2_options));DC_FP_START ();
@@ -1601,7 +1599,7 @@ static void dcn321_update_bw_bounding_box(struct dc *dc, struct clk_bw_params *bDC_FP_END (); -kfree (dml2_opt); +memcpy (&dc->dml2_options, dml2_opt,sizeof (dc->dml2_options)); }static struct resource_funcs dcn321_res_pool_funcs = {
Signature · 1 line
2.45.1
[AMD Official Use Only - AMD Internal Distribution Only]
Thanks,
George
-----Original Message-----
From: Deucher, Alexander <[email protected]>
Sent: Tuesday, June 4, 2024 11:50 AM
To: [email protected]
Cc: Deucher, Alexander <[email protected]>; Mahfooz, Hamza <[email protected]>; Zhang, George <[email protected]>; Arnd Bergmann <[email protected]>; Wentland, Harry <[email protected]>; Li, Sun peng (Leo) <[email protected]>; Siqueira, Rodrigo <[email protected]>
Subject: [PATCH] drm/amd/display: use pre-allocated temp structure for bounding box
This mirrors what the driver does for older DCN generations.
Should fix:
BUG: sleeping function called from invalid context at include/linux/sched/mm.h:306
in_atomic(): 1, irqs_disabled(): 0, non_block: 0, pid: 449, name: kworker/u64:8preempt_count: 2, expected: 0
RCU nest depth: 0, expected: 0
Preemption disabled at:ffffffffc0ce1580>] dc_fpu_begin+0x30/0xd0 [amdgpu]
CPU: 5 PID: 449 Comm: kworker/u64:8 Tainted: G W 6.8.0+ #35 Hardware name: System manufacturer System Product Name/ROG STRIX X570-E GAMING WIFI II, BIOS 4204 02/24/2022 Workqueue: events_unbound async_run_entry_fn
--- drivers/gpu/drm/amd/display/dc/dc.h | 1 + .../drm/amd/display/dc/resource/dcn32/dcn32_resource.c | 8 +++----- .../drm/amd/display/dc/resource/dcn321/dcn321_resource.c | 8 +++----- 3 files changed, 7 insertions(+), 10 deletions(-)
drivers/gpu/drm/amd/display/dc/dc.h +1 -0
@@ -1444,6 +1444,7 @@ struct dc { } scratch;struct dml2_configuration_options dml2_options; +struct dml2_configuration_options dml2_tmp;enum dc_acpi_cm_power_state power_state; };
drivers/gpu/drm/amd/display/dc/resource/dcn32/dcn32_resource.c +3 -5
@@ -2007,11 +2007,9 @@ void dcn32_calculate_wm_and_dlg(struct dc *dc, struct dc_state *context,static void dcn32_update_bw_bounding_box (struct dc *dc,struct clk_bw_params *bw_params) { -struct dml2_configuration_options *dml2_opt; +struct dml2_configuration_options *dml2_opt = &dc->dml2_tmp; - dml2_opt =kmemdup (&dc->dml2_options,sizeof (dc->dml2_options),GFP_KERNEL ); -if (!dml2_opt) -return ; +memcpy (dml2_opt, &dc->dml2_options,sizeof (dc->dml2_options));DC_FP_START ();
@@ -2027,7 +2025,7 @@ static void dcn32_update_bw_bounding_box(struct dc *dc, struct clk_bw_params *bwDC_FP_END (); -kfree (dml2_opt); +memcpy (&dc->dml2_options, dml2_opt,sizeof (dc->dml2_options)); }static struct resource_funcs dcn32_res_pool_funcs = {
drivers/gpu/drm/amd/display/dc/resource/dcn321/dcn321_resource.c +3 -5
@@ -1581,11 +1581,9 @@ static struct dc_cap_funcs cap_funcs = {static void dcn321_update_bw_bounding_box (struct dc *dc,struct clk_bw_params *bw_params) { -struct dml2_configuration_options *dml2_opt; +struct dml2_configuration_options *dml2_opt = &dc->dml2_tmp; - dml2_opt =kmemdup (&dc->dml2_options,sizeof (dc->dml2_options),GFP_KERNEL ); -if (!dml2_opt) -return ; +memcpy (dml2_opt, &dc->dml2_options,sizeof (dc->dml2_options));DC_FP_START ();
@@ -1601,7 +1599,7 @@ static void dcn321_update_bw_bounding_box(struct dc *dc, struct clk_bw_params *bDC_FP_END (); -kfree (dml2_opt); +memcpy (&dc->dml2_options, dml2_opt,sizeof (dc->dml2_options)); }static struct resource_funcs dcn321_res_pool_funcs = {
--
2.45.1
[AMD Official Use Only - AMD Internal Distribution Only]
[AMD Official Use Only - AMD Internal Distribution Only]
Hi Christian,
Thanks for your comments, the RREG32_SOC15() macro should return the 32bit wide value so it couldn't need the mask. And I will send out v2 patch to modify the commit message and use uint32_t or u32 instead .
Regards,
Bob
-----Original Message-----
From: Koenig, Christian <[email protected]>
Sent: 2024年6月3日 19:11
To: Zhou, Bob <[email protected]>; [email protected]; Huang, Tim <[email protected]>; Zhang, Jesse(Jie) <[email protected]>
Cc: Deucher, Alexander <[email protected]>
Subject: Re: [PATCH] drm/amdgpu: replace int with unsigned int for imu_v12_0.c
Am 03.06.24 um 10:53 schrieb Zhou, Bob:
Quoted 5 lines
[AMD Official Use Only - AMD Internal Distribution Only]
Hi Christian,
It fixes a potential Overflowed constant (
INTEGER_OVERFLOW) warning reported by Coverity.
You need to mention that in the commit message.
And I haven't checked the hardware docs, but it can be that this isn't the right solution for the warning. Instead you should probably use the RREG32_SOC15() macro with a mask which only leaves the valid bits around.
Only when the register is really 32bit wide you need an unsigned datatype and if that is the case I suggest to use either uint32_t or u32 instead.
Regards,
Christian.
Quoted 63 lines
Regards,
Bob-----Original Message-----
From: Koenig, Christian <[email protected]>
Sent: 2024年6月3日 15:56
To: Zhou, Bob <[email protected]>; [email protected]; Huang, Tim <[email protected]>; Zhang, Jesse(Jie) <[email protected]>
Cc: Deucher, Alexander <[email protected]>
Subject: Re: [PATCH] drm/amdgpu: replace int with unsigned int forimu_v12_0.cAm 03.06.24 um 07:59 schrieb Bob Zhou:
Quoted 1 line
The return value of
RREG32_SOC15is unsigned int, so modify variable to unsigned.And why is that an improvement?
Regards,
Christian.Quoted 42 lines
Signed-off-by Bob Zhou <[email protected]>--- drivers/gpu/drm/amd/amdgpu/imu_v12_0.c | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-)drivers/gpu/drm/amd/amdgpu/imu_v12_0.c +1
-1@@ -119,7 +119,7 @@ static int imu_v12_0_load_microcode(struct amdgpu_device *adev)static int imu_v12_0_wait_for_reset_status (struct amdgpu_device *adev) { -int i, imu_reg_val =0 ; +unsigned int i, imu_reg_val =0 ;for (i =0 ; i < adev->usec_timeout; i++) {imu_reg_val = RREG32_SOC15(GC, 0,
regGFX_IMU_GFX_RESET_CTRL); @@
-138,7 +138,7 @@ static intimu_v12_0_wait_for_reset_status(struct amdgpu_device *adev)static void imu_v12_0_setup(struct amdgpu_device *adev) {drivers/gpu/drm/amd/amdgpu/imu_v12_0.c +1
-1-int imu_reg_val; +unsigned int imu_reg_val;WREG32_SOC15 (GC ,0 , regGFX_IMU_C2PMSG_ACCESS_CTRL0,0xffffff );WREG32_SOC15 (GC ,0 , regGFX_IMU_C2PMSG_ACCESS_CTRL1,0xffff );@@
-157,7 +157,7 @@ static voidimu_v12_0_setup(struct amdgpu_device *adev)static int imu_v12_0_start(struct amdgpu_device *adev) {drivers/gpu/drm/amd/amdgpu/imu_v12_0.c +1
-1-int imu_reg_val; +unsigned int imu_reg_val; imu_reg_val =RREG32_SOC15 (GC ,0 , regGFX_IMU_CORE_CTRL); imu_reg_val &=0xfffffffe ;
Pillai, Aurabindo
Tested-by George Zhang[AMD Official Use Only - AMD Internal Distribution Only]
Hi Alex,
I'll a hunk for fixing DCN401 as well to this and resend it later today.
--
Regards,
Jay
________________________________
From: amd-gfx <[email protected]> on behalf of Zhang, George <[email protected]>
Sent: Tuesday, June 4, 2024 12:49 PM
To: Deucher, Alexander <[email protected]>; [email protected] <[email protected]>
Cc: Mahfooz, Hamza <[email protected]>; Arnd Bergmann <[email protected]>; Wentland, Harry <[email protected]>; Li, Sun peng (Leo) <[email protected]>; Siqueira, Rodrigo <[email protected]>
Subject: RE: [PATCH] drm/amd/display: use pre-allocated temp structure for bounding box
[AMD Official Use Only - AMD Internal Distribution Only]
[AMD Official Use Only - AMD Internal Distribution Only]
Thanks,
George
-----Original Message-----
From: Deucher, Alexander <[email protected]>
Sent: Tuesday, June 4, 2024 11:50 AM
To: [email protected]
Cc: Deucher, Alexander <[email protected]>; Mahfooz, Hamza <[email protected]>; Zhang, George <[email protected]>; Arnd Bergmann <[email protected]>; Wentland, Harry <[email protected]>; Li, Sun peng (Leo) <[email protected]>; Siqueira, Rodrigo <[email protected]>
Subject: [PATCH] drm/amd/display: use pre-allocated temp structure for bounding box
This mirrors what the driver does for older DCN generations.
Should fix:
BUG: sleeping function called from invalid context at include/linux/sched/mm.h:306
in_atomic(): 1, irqs_disabled(): 0, non_block: 0, pid: 449, name: kworker/u64:8preempt_count: 2, expected: 0
RCU nest depth: 0, expected: 0
Preemption disabled at:ffffffffc0ce1580>] dc_fpu_begin+0x30/0xd0 [amdgpu]
CPU: 5 PID: 449 Comm: kworker/u64:8 Tainted: G W 6.8.0+ #35 Hardware name: System manufacturer System Product Name/ROG STRIX X570-E GAMING WIFI II, BIOS 4204 02/24/2022 Workqueue: events_unbound async_run_entry_fn
--- drivers/gpu/drm/amd/display/dc/dc.h | 1 + .../drm/amd/display/dc/resource/dcn32/dcn32_resource.c | 8 +++----- .../drm/amd/display/dc/resource/dcn321/dcn321_resource.c | 8 +++----- 3 files changed, 7 insertions(+), 10 deletions(-)
drivers/gpu/drm/amd/display/dc/dc.h +1 -0
@@ -1444,6 +1444,7 @@ struct dc { } scratch;struct dml2_configuration_options dml2_options; +struct dml2_configuration_options dml2_tmp;enum dc_acpi_cm_power_state power_state; };
drivers/gpu/drm/amd/display/dc/resource/dcn32/dcn32_resource.c +3 -5
@@ -2007,11 +2007,9 @@ void dcn32_calculate_wm_and_dlg(struct dc *dc, struct dc_state *context,static void dcn32_update_bw_bounding_box (struct dc *dc,struct clk_bw_params *bw_params) { -struct dml2_configuration_options *dml2_opt; +struct dml2_configuration_options *dml2_opt = &dc->dml2_tmp; - dml2_opt =kmemdup (&dc->dml2_options,sizeof (dc->dml2_options),GFP_KERNEL ); -if (!dml2_opt) -return ; +memcpy (dml2_opt, &dc->dml2_options,sizeof (dc->dml2_options));DC_FP_START ();
@@ -2027,7 +2025,7 @@ static void dcn32_update_bw_bounding_box(struct dc *dc, struct clk_bw_params *bwDC_FP_END (); -kfree (dml2_opt); +memcpy (&dc->dml2_options, dml2_opt,sizeof (dc->dml2_options)); }static struct resource_funcs dcn32_res_pool_funcs = {
drivers/gpu/drm/amd/display/dc/resource/dcn321/dcn321_resource.c +3 -5
@@ -1581,11 +1581,9 @@ static struct dc_cap_funcs cap_funcs = {static void dcn321_update_bw_bounding_box (struct dc *dc,struct clk_bw_params *bw_params) { -struct dml2_configuration_options *dml2_opt; +struct dml2_configuration_options *dml2_opt = &dc->dml2_tmp; - dml2_opt =kmemdup (&dc->dml2_options,sizeof (dc->dml2_options),GFP_KERNEL ); -if (!dml2_opt) -return ; +memcpy (dml2_opt, &dc->dml2_options,sizeof (dc->dml2_options));DC_FP_START ();
@@ -1601,7 +1599,7 @@ static void dcn321_update_bw_bounding_box(struct dc *dc, struct clk_bw_params *bDC_FP_END (); -kfree (dml2_opt); +memcpy (&dc->dml2_options, dml2_opt,sizeof (dc->dml2_options)); }static struct resource_funcs dcn321_res_pool_funcs = {
--
2.45.1
I sent a separate patch for DCN 401.
Quoted 132 lines · Aurabindo
[AMD Official Use Only - AMD Internal Distribution Only]
Hi Alex,
I'll a hunk for fixing DCN401 as well to this and resend it later today.
--
Regards,
Jay
________________________________
From: amd-gfx <[email protected]> on behalf of Zhang, George <[email protected]>
Sent: Tuesday, June 4, 2024 12:49 PM
To: Deucher, Alexander <[email protected]>; [email protected] <[email protected]>
Cc: Mahfooz, Hamza <[email protected]>; Arnd Bergmann <[email protected]>; Wentland, Harry <[email protected]>; Li, Sun peng (Leo) <[email protected]>; Siqueira, Rodrigo <[email protected]>
Subject: RE: [PATCH] drm/amd/display: use pre-allocated temp structure for bounding box[AMD Official Use Only - AMD Internal Distribution Only]
[AMD Official Use Only - AMD Internal Distribution Only]
Tested-by George Zhang <[email protected]>Thanks,
George
-----Original Message-----
From: Deucher, Alexander <[email protected]>
Sent: Tuesday, June 4, 2024 11:50 AM
To: [email protected]
Cc: Deucher, Alexander <[email protected]>; Mahfooz, Hamza <[email protected]>; Zhang, George <[email protected]>; Arnd Bergmann <[email protected]>; Wentland, Harry <[email protected]>; Li, Sun peng (Leo) <[email protected]>; Siqueira, Rodrigo <[email protected]>
Subject: [PATCH] drm/amd/display: use pre-allocated temp structure for bounding boxThis mirrors what the driver does for older DCN generations.
Should fix:
BUG: sleeping function called from invalid context at include/linux/sched/mm.h:306
in_atomic(): 1,irqs_disabled(): 0,non_block: 0, pid: 449, name: kworker/u64:8preempt_count: 2, expected: 0
RCU nest depth: 0, expected: 0
Preemption disabled at:ffffffffc0ce1580>]dc_fpu_begin+0x30/0xd0[amdgpu]CPU: 5 PID: 449 Comm: kworker/u64:8 Tainted: G W 6.8.0+ #35 Hardware name: System manufacturer System Product Name/ROG STRIX X570-E GAMING WIFI II, BIOS 4204 02/24/2022 Workqueue: events_unbound async_run_entry_fnFixes 88c61827cedc ("drm/amd/display: dynamically allocate dml2_configuration_options structures")Suggested-by Hamza Mahfooz <[email protected]>Signed-off-by Alex Deucher <[email protected]>Cc George Zhang <[email protected]>Cc Arnd Bergmann <[email protected]>--- drivers/gpu/drm/amd/display/dc/dc.h | 1 + .../drm/amd/display/dc/resource/dcn32/dcn32_resource.c | 8 +++----- .../drm/amd/display/dc/resource/dcn321/dcn321_resource.c | 8 +++----- 3 files changed, 7 insertions(+), 10 deletions(-)drivers/gpu/drm/amd/display/dc/dc.h +1
-0@@ -1444,6 +1444,7 @@ struct dc { } scratch;struct dml2_configuration_options dml2_options; +struct dml2_configuration_options dml2_tmp;enum dc_acpi_cm_power_state power_state; };drivers/gpu/drm/amd/display/dc/resource/dcn32/dcn32_resource.c +3
-5@@ -2007,11 +2007,9 @@ void dcn32_calculate_wm_and_dlg(struct dc *dc, struct dc_state *context,static void dcn32_update_bw_bounding_box (struct dc *dc,struct clk_bw_params *bw_params) { -struct dml2_configuration_options *dml2_opt; +struct dml2_configuration_options *dml2_opt = &dc->dml2_tmp; - dml2_opt =kmemdup (&dc->dml2_options,sizeof (dc->dml2_options),GFP_KERNEL ); -if (!dml2_opt) -return ; +memcpy (dml2_opt, &dc->dml2_options,sizeof (dc->dml2_options));DC_FP_START ();@@ -2027,7 +2025,7 @@ static void dcn32_update_bw_bounding_box(struct dc *dc, struct clk_bw_params *bwDC_FP_END (); -kfree (dml2_opt); +memcpy (&dc->dml2_options, dml2_opt,sizeof (dc->dml2_options)); }static struct resource_funcs dcn32_res_pool_funcs = {drivers/gpu/drm/amd/display/dc/resource/dcn321/dcn321_resource.c +3
-6@@ -1581,11 +1581,9 @@ static struct dc_cap_funcs cap_funcs = {static void dcn321_update_bw_bounding_box (struct dc *dc,struct clk_bw_params *bw_params) { -struct dml2_configuration_options *dml2_opt; +struct dml2_configuration_options *dml2_opt = &dc->dml2_tmp; - dml2_opt =kmemdup (&dc->dml2_options,sizeof (dc->dml2_options),GFP_KERNEL ); -if (!dml2_opt) -return ; +memcpy (dml2_opt, &dc->dml2_options,sizeof (dc->dml2_options));DC_FP_START ();@@ -1601,7 +1599,7 @@ static void dcn321_update_bw_bounding_box(struct dc *dc, struct clk_bw_params *bDC_FP_END (); -kfree (dml2_opt); +memcpy (&dc->dml2_options, dml2_opt,sizeof (dc->dml2_options)); }static struct resource_funcs dcn321_res_pool_funcs = { --2.45.1
Am 04.06.24 um 17:50 schrieb Alex Deucher:
Quoted 14 lines
This mirrors what the driver does for older DCN generations.
Should fix:
BUG: sleeping function called from invalid context at include/linux/sched/mm.h:306
in_atomic(): 1,irqs_disabled(): 0,non_block: 0, pid: 449, name: kworker/u64:8preempt_count: 2, expected: 0
RCU nest depth: 0, expected: 0
Preemption disabled at:ffffffffc0ce1580>]dc_fpu_begin+0x30/0xd0[amdgpu]CPU: 5 PID: 449 Comm: kworker/u64:8 Tainted: G W 6.8.0+ #35 Hardware name: System manufacturer System Product Name/ROG STRIX X570-E GAMING WIFI II, BIOS 4204 02/24/2022 Workqueue: events_unbound async_run_entry_fn
Quoted 8 lines
Fixes 88c61827cedc ("drm/amd/display: dynamically allocate dml2_configuration_options structures")Suggested-by Hamza Mahfooz <[email protected]>Signed-off-by Alex Deucher <[email protected]>Cc George Zhang <[email protected]>Cc Arnd Bergmann <[email protected]>
Quoted 72 lines
--- drivers/gpu/drm/amd/display/dc/dc.h | 1 + .../drm/amd/display/dc/resource/dcn32/dcn32_resource.c | 8 +++----- .../drm/amd/display/dc/resource/dcn321/dcn321_resource.c | 8 +++----- 3 files changed, 7 insertions(+), 10 deletions(-)drivers/gpu/drm/amd/display/dc/dc.h +1
-0@@ -1444,6 +1444,7 @@ struct dc { } scratch;struct dml2_configuration_options dml2_options; +struct dml2_configuration_options dml2_tmp;enum dc_acpi_cm_power_state power_state; };drivers/gpu/drm/amd/display/dc/resource/dcn32/dcn32_resource.c +3
-5@@ -2007,11 +2007,9 @@ void dcn32_calculate_wm_and_dlg(struct dc *dc, struct dc_state *context,static void dcn32_update_bw_bounding_box (struct dc *dc,struct clk_bw_params *bw_params) { -struct dml2_configuration_options *dml2_opt; +struct dml2_configuration_options *dml2_opt = &dc->dml2_tmp; - dml2_opt =kmemdup (&dc->dml2_options,sizeof (dc->dml2_options),GFP_KERNEL ); -if (!dml2_opt) -return ; +memcpy (dml2_opt, &dc->dml2_options,sizeof (dc->dml2_options));DC_FP_START ();@@ -2027,7 +2025,7 @@ static void dcn32_update_bw_bounding_box(struct dc *dc, struct clk_bw_params *bwDC_FP_END (); -kfree (dml2_opt); +memcpy (&dc->dml2_options, dml2_opt,sizeof (dc->dml2_options)); }static struct resource_funcs dcn32_res_pool_funcs = {drivers/gpu/drm/amd/display/dc/resource/dcn321/dcn321_resource.c +3
-5@@ -1581,11 +1581,9 @@ static struct dc_cap_funcs cap_funcs = {static void dcn321_update_bw_bounding_box (struct dc *dc,struct clk_bw_params *bw_params) { -struct dml2_configuration_options *dml2_opt; +struct dml2_configuration_options *dml2_opt = &dc->dml2_tmp; - dml2_opt =kmemdup (&dc->dml2_options,sizeof (dc->dml2_options),GFP_KERNEL ); -if (!dml2_opt) -return ; +memcpy (dml2_opt, &dc->dml2_options,sizeof (dc->dml2_options));DC_FP_START ();@@ -1601,7 +1599,7 @@ static void dcn321_update_bw_bounding_box(struct dc *dc, struct clk_bw_params *bDC_FP_END (); -kfree (dml2_opt); +memcpy (&dc->dml2_options, dml2_opt,sizeof (dc->dml2_options)); }static struct resource_funcs dcn321_res_pool_funcs = {
Quoted 14 lines · Alex Deucher
This mirrors what the driver does for older DCN generations.
Should fix:
BUG: sleeping function called from invalid context at include/linux/sched/mm.h:306
in_atomic(): 1,irqs_disabled(): 0,non_block: 0, pid: 449, name: kworker/u64:8preempt_count: 2, expected: 0
RCU nest depth: 0, expected: 0
Preemption disabled at:ffffffffc0ce1580>]dc_fpu_begin+0x30/0xd0[amdgpu]CPU: 5 PID: 449 Comm: kworker/u64:8 Tainted: G W 6.8.0+ #35 Hardware name: System manufacturer System Product Name/ROG STRIX X570-E GAMING WIFI II, BIOS 4204 02/24/2022 Workqueue: events_unbound async_run_entry_fn
Quoted 8 lines
Fixes 88c61827cedc ("drm/amd/display: dynamically allocate dml2_configuration_options structures")Suggested-by Hamza Mahfooz <[email protected]>Signed-off-by Alex Deucher <[email protected]>Cc George Zhang <[email protected]>Cc Arnd Bergmann <[email protected]>
Harry
Quoted 72 lines
--- drivers/gpu/drm/amd/display/dc/dc.h | 1 + .../drm/amd/display/dc/resource/dcn32/dcn32_resource.c | 8 +++----- .../drm/amd/display/dc/resource/dcn321/dcn321_resource.c | 8 +++----- 3 files changed, 7 insertions(+), 10 deletions(-)drivers/gpu/drm/amd/display/dc/dc.h +1
-0@@ -1444,6 +1444,7 @@ struct dc { } scratch;struct dml2_configuration_options dml2_options; +struct dml2_configuration_options dml2_tmp;enum dc_acpi_cm_power_state power_state; };drivers/gpu/drm/amd/display/dc/resource/dcn32/dcn32_resource.c +3
-5@@ -2007,11 +2007,9 @@ void dcn32_calculate_wm_and_dlg(struct dc *dc, struct dc_state *context,static void dcn32_update_bw_bounding_box (struct dc *dc,struct clk_bw_params *bw_params) { -struct dml2_configuration_options *dml2_opt; +struct dml2_configuration_options *dml2_opt = &dc->dml2_tmp; - dml2_opt =kmemdup (&dc->dml2_options,sizeof (dc->dml2_options),GFP_KERNEL ); -if (!dml2_opt) -return ; +memcpy (dml2_opt, &dc->dml2_options,sizeof (dc->dml2_options));DC_FP_START ();@@ -2027,7 +2025,7 @@ static void dcn32_update_bw_bounding_box(struct dc *dc, struct clk_bw_params *bwDC_FP_END (); -kfree (dml2_opt); +memcpy (&dc->dml2_options, dml2_opt,sizeof (dc->dml2_options)); }static struct resource_funcs dcn32_res_pool_funcs = {drivers/gpu/drm/amd/display/dc/resource/dcn321/dcn321_resource.c +3
-5@@ -1581,11 +1581,9 @@ static struct dc_cap_funcs cap_funcs = {static void dcn321_update_bw_bounding_box (struct dc *dc,struct clk_bw_params *bw_params) { -struct dml2_configuration_options *dml2_opt; +struct dml2_configuration_options *dml2_opt = &dc->dml2_tmp; - dml2_opt =kmemdup (&dc->dml2_options,sizeof (dc->dml2_options),GFP_KERNEL ); -if (!dml2_opt) -return ; +memcpy (dml2_opt, &dc->dml2_options,sizeof (dc->dml2_options));DC_FP_START ();@@ -1601,7 +1599,7 @@ static void dcn321_update_bw_bounding_box(struct dc *dc, struct clk_bw_params *bDC_FP_END (); -kfree (dml2_opt); +memcpy (&dc->dml2_options, dml2_opt,sizeof (dc->dml2_options)); }static struct resource_funcs dcn321_res_pool_funcs = {
Quoted 27 lines · Harry Wentland
Quoted 14 lines · Alex Deucher
This mirrors what the driver does for older DCN generations.
Should fix:
BUG: sleeping function called from invalid context at include/linux/sched/mm.h:306
in_atomic(): 1,irqs_disabled(): 0,non_block: 0, pid: 449, name: kworker/u64:8preempt_count: 2, expected: 0
RCU nest depth: 0, expected: 0
Preemption disabled at:ffffffffc0ce1580>]dc_fpu_begin+0x30/0xd0[amdgpu]CPU: 5 PID: 449 Comm: kworker/u64:8 Tainted: G W 6.8.0+ #35 Hardware name: System manufacturer System Product Name/ROG STRIX X570-E GAMING WIFI II, BIOS 4204 02/24/2022 Workqueue: events_unbound async_run_entry_fnQuoted 8 lines
Fixes 88c61827cedc ("drm/amd/display: dynamically allocate dml2_configuration_options structures")Suggested-by Hamza Mahfooz <[email protected]>Signed-off-by Alex Deucher <[email protected]>Cc George Zhang <[email protected]>Cc Arnd Bergmann <[email protected]>
Quoted 2 lines
Reviewed-by Harry Wentland <[email protected]>
Please review v2 of the patches. There was an extra memcpy in the originals.
Alex
Quoted 75 lines
Harry
Quoted 72 lines
--- drivers/gpu/drm/amd/display/dc/dc.h | 1 + .../drm/amd/display/dc/resource/dcn32/dcn32_resource.c | 8 +++----- .../drm/amd/display/dc/resource/dcn321/dcn321_resource.c | 8 +++----- 3 files changed, 7 insertions(+), 10 deletions(-)drivers/gpu/drm/amd/display/dc/dc.h +1
-0@@ -1444,6 +1444,7 @@ struct dc { } scratch;struct dml2_configuration_options dml2_options; +struct dml2_configuration_options dml2_tmp;enum dc_acpi_cm_power_state power_state; };drivers/gpu/drm/amd/display/dc/resource/dcn32/dcn32_resource.c +3
-5@@ -2007,11 +2007,9 @@ void dcn32_calculate_wm_and_dlg(struct dc *dc, struct dc_state *context,static void dcn32_update_bw_bounding_box (struct dc *dc,struct clk_bw_params *bw_params) { -struct dml2_configuration_options *dml2_opt; +struct dml2_configuration_options *dml2_opt = &dc->dml2_tmp; - dml2_opt =kmemdup (&dc->dml2_options,sizeof (dc->dml2_options),GFP_KERNEL ); -if (!dml2_opt) -return ; +memcpy (dml2_opt, &dc->dml2_options,sizeof (dc->dml2_options));DC_FP_START ();@@ -2027,7 +2025,7 @@ static void dcn32_update_bw_bounding_box(struct dc *dc, struct clk_bw_params *bwDC_FP_END (); -kfree (dml2_opt); +memcpy (&dc->dml2_options, dml2_opt,sizeof (dc->dml2_options)); }static struct resource_funcs dcn32_res_pool_funcs = {drivers/gpu/drm/amd/display/dc/resource/dcn321/dcn321_resource.c +3
-5@@ -1581,11 +1581,9 @@ static struct dc_cap_funcs cap_funcs = {static void dcn321_update_bw_bounding_box (struct dc *dc,struct clk_bw_params *bw_params) { -struct dml2_configuration_options *dml2_opt; +struct dml2_configuration_options *dml2_opt = &dc->dml2_tmp; - dml2_opt =kmemdup (&dc->dml2_options,sizeof (dc->dml2_options),GFP_KERNEL ); -if (!dml2_opt) -return ; +memcpy (dml2_opt, &dc->dml2_options,sizeof (dc->dml2_options));DC_FP_START ();@@ -1601,7 +1599,7 @@ static void dcn321_update_bw_bounding_box(struct dc *dc, struct clk_bw_params *bDC_FP_END (); -kfree (dml2_opt); +memcpy (&dc->dml2_options, dml2_opt,sizeof (dc->dml2_options)); }static struct resource_funcs dcn321_res_pool_funcs = {