drm/amdgpu: Use virtual alloc during coredump
Subsystems (2)
A message that is not in the archive (sent off-list or not yet received): [email protected]
Zhang, Hawking
Reviewed-byAMD General
Regards,
Hawking
-----Original Message-----
From: amd-gfx <[email protected]> On Behalf Of Lijo Lazar
Sent: Wednesday, July 29, 2026 3:50 PM
To: [email protected]
Cc: Zhang, Hawking <[email protected]>; Deucher, Alexander <[email protected]>; Pelloux-Prayer, Pierre-Eric <[email protected]>
Subject: [PATCH] drm/amdgpu: Use virtual alloc during coredump
The number of rings with outstanding fences can be large, requiring a bigger allocation. Such allocations don't need to be physically contiguous, so use kvzalloc/kvcalloc which fall back to vmalloc when contiguous memory isn't available. This also matches the existing kvfree used to free these allocations.
Also guard the allocation with ring_count to avoid passing 0 size to allocation routines.
--- drivers/gpu/drm/amd/amdgpu/amdgpu_dev_coredump.c | 10 +++++++--- 1 file changed, 7 insertions(+), 3 deletions(-)
drivers/gpu/drm/amd/amdgpu/amdgpu_dev_coredump.c +7 -3
@@ -554,7 +554,7 @@ void amdgpu_coredump(struct amdgpu_device *adev, bool skip_vram_check,if (job && job->pasid) size +=sizeof (struct amdgpu_coredump_ib_info ) * job->num_ibs; - coredump =kzalloc (size,GFP_NOWAIT ); + coredump =kvzalloc (size,GFP_NOWAIT );if (!coredump)return ;
@@ -597,8 +597,12 @@ void amdgpu_coredump(struct amdgpu_device *adev, bool skip_vram_check, total_ring_size += ring->ring_size; ring_count++; } - coredump->rings_dw =kzalloc (total_ring_size,GFP_NOWAIT ); - coredump->rings =kcalloc (ring_count,sizeof (struct amdgpu_coredump_ring ),GFP_NOWAIT ); +if (ring_count) { + coredump->rings_dw =kvzalloc (total_ring_size,GFP_NOWAIT ); + coredump->rings =kvcalloc (ring_count, +sizeof (struct amdgpu_coredump_ring ), +GFP_NOWAIT ); + }if (coredump->rings && coredump->rings_dw) {for (i =0 , off =0 , idx =0 ; i < adev->num_rings && idx < ring_count; i++) { ring = adev->rings[i];
--
2.49.0
Please ignore this. This is a followup patch to
"drm/amdgpu: Use virtual alloc during coredump".
Have sent both together for better context.
Thanks,
Lijo
Quoted 44 lines · Lijo Lazar
The number of rings with outstanding fences can be large, requiring a bigger allocation. Such allocations don't need to be physically contiguous, so use kvzalloc/kvcalloc which fall back to vmalloc when contiguous memory isn't available. This also matches the existing kvfree used to free these allocations.
Also guard the allocation with
ring_countto avoid passing 0 size to allocation routines.Fixes eea85914d15b ("drm/amdgpu: save ring content before resetting the device")Signed-off-by Lijo Lazar <[email protected]>--- drivers/gpu/drm/amd/amdgpu/amdgpu_dev_coredump.c | 10 +++++++--- 1 file changed, 7 insertions(+), 3 deletions(-)drivers/gpu/drm/amd/amdgpu/amdgpu_dev_coredump.c +7
-3@@ -554,7 +554,7 @@ void amdgpu_coredump(struct amdgpu_device *adev, bool skip_vram_check,if (job && job->pasid) size +=sizeof (struct amdgpu_coredump_ib_info ) * job->num_ibs; - coredump =kzalloc (size,GFP_NOWAIT ); + coredump =kvzalloc (size,GFP_NOWAIT );if (!coredump)return ;@@ -597,8 +597,12 @@ void amdgpu_coredump(struct amdgpu_device *adev, bool skip_vram_check, total_ring_size += ring->ring_size; ring_count++; } - coredump->rings_dw =kzalloc (total_ring_size,GFP_NOWAIT ); - coredump->rings =kcalloc (ring_count,sizeof (struct amdgpu_coredump_ring ),GFP_NOWAIT ); +if (ring_count) { + coredump->rings_dw =kvzalloc (total_ring_size,GFP_NOWAIT ); + coredump->rings =kvcalloc (ring_count, +sizeof (struct amdgpu_coredump_ring ), +GFP_NOWAIT ); + }if (coredump->rings && coredump->rings_dw) {for (i =0 , off =0 , idx =0 ; i < adev->num_rings && idx < ring_count; i++) { ring = adev->rings[i];