drm/amd/display: use vmalloc for struct dc_state
Subsystems (3)
Alex Deucher
maintainerPATCH 1/1 drm/amd/display: use vmalloc for struct dc_state
This is a big structure so use vmalloc as malloc can fail when there is memory pressure.
Signed-off-by Alex Deucher <[email protected]>
--- drivers/gpu/drm/amd/display/amdgpu_dm/amdgpu_dm_mst_types.c | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-)
drivers/gpu/drm/amd/display/amdgpu_dm/amdgpu_dm_mst_types.c +3 -2
@@ -1491,9 +1491,10 @@ int pre_validate_dsc(struct drm_atomic_state *state,* from dm_state->context. */ - local_dc_state =kmemdup (dm_state->context,sizeof (struct dc_state ),GFP_KERNEL ); + local_dc_state =vmalloc (sizeof (struct dc_state ));if (!local_dc_state)return -ENOMEM ; +memcpy (local_dc_state, dm_state->context,sizeof (struct dc_state ));for (i =0 ; i < local_dc_state->stream_count; i++) {struct dc_stream_state *stream = dm_state->context->streams[i];
@@ -1563,7 +1564,7 @@ int pre_validate_dsc(struct drm_atomic_state *state,dc_stream_release (local_dc_state->streams[i]); } -kfree (local_dc_state); +vfree (local_dc_state);return ret; }
Signature · 1 line
2.45.2
Quoted 2 lines · Alex Deucher
This is a big structure so use vmalloc as malloc can fail when there is memory pressure.
vmalloc can be a bit slower, but I think it's fine for this context and better to handle memory pressure more nicely.
Reviewed-by Mario Limonciello <[email protected]>
Quoted 32 lines
Signed-off-by Alex Deucher <[email protected]>--- drivers/gpu/drm/amd/display/amdgpu_dm/amdgpu_dm_mst_types.c | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-)drivers/gpu/drm/amd/display/amdgpu_dm/amdgpu_dm_mst_types.c +3
-2@@ -1491,9 +1491,10 @@ int pre_validate_dsc(struct drm_atomic_state *state,* from dm_state->context. */ - local_dc_state =kmemdup (dm_state->context,sizeof (struct dc_state ),GFP_KERNEL ); + local_dc_state =vmalloc (sizeof (struct dc_state ));if (!local_dc_state)return -ENOMEM ; +memcpy (local_dc_state, dm_state->context,sizeof (struct dc_state ));for (i =0 ; i < local_dc_state->stream_count; i++) {struct dc_stream_state *stream = dm_state->context->streams[i];@@ -1563,7 +1564,7 @@ int pre_validate_dsc(struct drm_atomic_state *state,dc_stream_release (local_dc_state->streams[i]); } -kfree (local_dc_state); +vfree (local_dc_state);return ret; }