]> git.ipfire.org Git - thirdparty/kernel/linux.git/commitdiff
drm/amdgpu: Use virtual alloc during coredump
authorLijo Lazar <lijo.lazar@amd.com>
Wed, 29 Jul 2026 07:30:21 +0000 (13:00 +0530)
committerAlex Deucher <alexander.deucher@amd.com>
Thu, 6 Aug 2026 18:32:44 +0000 (14:32 -0400)
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.

Fixes: eea85914d15b ("drm/amdgpu: save ring content before resetting the device")
Signed-off-by: Lijo Lazar <lijo.lazar@amd.com>
Reviewed-by: Hawking Zhang <Hawking.Zhang@amd.com>
Reviewed-by: Alex Deucher <alexander.deucher@amd.com>
Signed-off-by: Alex Deucher <alexander.deucher@amd.com>
(cherry picked from commit 74d48bd6b7e12eba65de0507475b059966685ad1)
Cc: stable@vger.kernel.org
drivers/gpu/drm/amd/amdgpu/amdgpu_dev_coredump.c

index 6480a344006d31299a7cc9a8aade5ef4eafe16f6..8dafc84f4232172fd7d8e4a08f44531fb4d9be0b 100644 (file)
@@ -553,7 +553,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;
 
@@ -596,8 +596,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];