accel/qaic: Use kvcalloc() for slice requests allocation
Subsystems (3)
PATCH 1/1 accel/qaic: Use kvcalloc() for slice requests allocation
From: Youssef Samir <[email protected]>
When a BO is created, qaic will use the page allocator to request the memory chunks that the BO will be composed of in-memory. The number of chunks increases when memory is segmented. For example, a 16MB BO can be composed of four 4MB chunks or 4096 4KB chunks.
A BO is then sliced into a single or multiple slices to be transferred to the device on the DBC's xfer queue. For that to happen, the slice needs to encode its memory chunks into DBC requests and keep track of them in an array, which is allocated using kcalloc(). Knowing that the BO might be very fragmented, this array can grow so large that the allocation may fail to find contiguous memory for it.
Replace kcalloc() with kvcalloc() to allocate the DBC requests array for a slice.
--- drivers/accel/qaic/qaic_data.c | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-)
drivers/accel/qaic/qaic_data.c +3 -3
@@ -165,7 +165,7 @@ static void free_slice(struct kref *kref)drm_gem_object_put (&slice->bo->base);sg_free_table (slice->sgt);kfree (slice->sgt); -kfree (slice->reqs); +kvfree (slice->reqs);kfree (slice); }
@@ -404,7 +404,7 @@ static int qaic_map_one_slice(struct qaic_device *qdev, struct qaic_bo *bo, goto free_sgt; } - slice->reqs =kcalloc (sgt->nents,sizeof (*slice->reqs),GFP_KERNEL ); + slice->reqs =kvcalloc (sgt->nents,sizeof (*slice->reqs),GFP_KERNEL );if (!slice->reqs) { ret = -ENOMEM ; goto free_slice;
@@ -430,7 +430,7 @@ static int qaic_map_one_slice(struct qaic_device *qdev, struct qaic_bo *bo,return 0 ; free_req: -kfree (slice->reqs); +kvfree (slice->reqs); free_slice:kfree (slice); free_sgt:
Signature · 1 line
2.43.0
Quoted 14 lines · Youssef Samir
From: Youssef Samir <[email protected]>
When a BO is created, qaic will use the page allocator to request the memory chunks that the BO will be composed of in-memory. The number of chunks increases when memory is segmented. For example, a 16MB BO can be composed of four 4MB chunks or 4096 4KB chunks.
A BO is then sliced into a single or multiple slices to be transferred to the device on the DBC's xfer queue. For that to happen, the slice needs to encode its memory chunks into DBC requests and keep track of them in an array, which is allocated using
kcalloc(). Knowing that the BO might be very fragmented, this array can grow so large that the allocation may fail to find contiguous memory for it.
Quoted 5 lines
Replace
kcalloc()withkvcalloc()to allocate the DBC requests array for a slice.Signed-off-by Youssef Samir <[email protected]>Signed-off-by Youssef Samir <[email protected]>
Quoted 14 lines · Youssef Samir
From: Youssef Samir <[email protected]>
When a BO is created, qaic will use the page allocator to request the memory chunks that the BO will be composed of in-memory. The number of chunks increases when memory is segmented. For example, a 16MB BO can be composed of four 4MB chunks or 4096 4KB chunks.
A BO is then sliced into a single or multiple slices to be transferred to the device on the DBC's xfer queue. For that to happen, the slice needs to encode its memory chunks into DBC requests and keep track of them in an array, which is allocated using
kcalloc(). Knowing that the BO might be very fragmented, this array can grow so large that the allocation may fail to find contiguous memory for it.
Quoted 5 lines
Replace
kcalloc()withkvcalloc()to allocate the DBC requests array for a slice.Signed-off-by Youssef Samir <[email protected]>Signed-off-by Youssef Samir <[email protected]>
Quoted 14 lines · Youssef Samir
From: Youssef Samir <[email protected]>
When a BO is created, qaic will use the page allocator to request the memory chunks that the BO will be composed of in-memory. The number of chunks increases when memory is segmented. For example, a 16MB BO can be composed of four 4MB chunks or 4096 4KB chunks.
A BO is then sliced into a single or multiple slices to be transferred to the device on the DBC's xfer queue. For that to happen, the slice needs to encode its memory chunks into DBC requests and keep track of them in an array, which is allocated using
kcalloc(). Knowing that the BO might be very fragmented, this array can grow so large that the allocation may fail to find contiguous memory for it.
Quoted 5 lines
Replace
kcalloc()withkvcalloc()to allocate the DBC requests array for a slice.Signed-off-by Youssef Samir <[email protected]>Signed-off-by Youssef Samir <[email protected]>
Pushed to drm-misc-next.
-Jeff