* [PATCH] accel/qaic: Use kvcalloc() for slice requests allocation
@ 2025-10-07 12:18 Youssef Samir
2025-10-07 15:15 ` Jeff Hugo
` (2 more replies)
0 siblings, 3 replies; 4+ messages in thread
From: Youssef Samir @ 2025-10-07 12:18 UTC (permalink / raw)
To: jeff.hugo, carl.vanderlip, troy.hanson, zachary.mckevitt
Cc: ogabbay, linux-arm-msm, dri-devel
From: Youssef Samir <quic_yabdulra@quicinc.com>
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.
Signed-off-by: Youssef Samir <quic_yabdulra@quicinc.com>
Signed-off-by: Youssef Samir <youssef.abdulrahman@oss.qualcomm.com>
---
drivers/accel/qaic/qaic_data.c | 6 +++---
1 file changed, 3 insertions(+), 3 deletions(-)
diff --git a/drivers/accel/qaic/qaic_data.c b/drivers/accel/qaic/qaic_data.c
index 797289e9d780..27c24eb351c7 100644
--- a/drivers/accel/qaic/qaic_data.c
+++ b/drivers/accel/qaic/qaic_data.c
@@ -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:
--
2.43.0
^ permalink raw reply related [flat|nested] 4+ messages in thread
* Re: [PATCH] accel/qaic: Use kvcalloc() for slice requests allocation
2025-10-07 12:18 [PATCH] accel/qaic: Use kvcalloc() for slice requests allocation Youssef Samir
@ 2025-10-07 15:15 ` Jeff Hugo
2025-10-13 22:08 ` Carl Vanderlip
2025-10-14 14:39 ` Jeff Hugo
2 siblings, 0 replies; 4+ messages in thread
From: Jeff Hugo @ 2025-10-07 15:15 UTC (permalink / raw)
To: Youssef Samir, carl.vanderlip, troy.hanson, zachary.mckevitt
Cc: ogabbay, linux-arm-msm, dri-devel
On 10/7/2025 6:18 AM, Youssef Samir wrote:
> From: Youssef Samir <quic_yabdulra@quicinc.com>
>
> 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.
>
> Signed-off-by: Youssef Samir <quic_yabdulra@quicinc.com>
> Signed-off-by: Youssef Samir <youssef.abdulrahman@oss.qualcomm.com>
Reviewed-by: Jeff Hugo <jeff.hugo@oss.qualcomm.com>
^ permalink raw reply [flat|nested] 4+ messages in thread
* Re: [PATCH] accel/qaic: Use kvcalloc() for slice requests allocation
2025-10-07 12:18 [PATCH] accel/qaic: Use kvcalloc() for slice requests allocation Youssef Samir
2025-10-07 15:15 ` Jeff Hugo
@ 2025-10-13 22:08 ` Carl Vanderlip
2025-10-14 14:39 ` Jeff Hugo
2 siblings, 0 replies; 4+ messages in thread
From: Carl Vanderlip @ 2025-10-13 22:08 UTC (permalink / raw)
To: Youssef Samir, jeff.hugo, troy.hanson, zachary.mckevitt
Cc: ogabbay, linux-arm-msm, dri-devel
On 10/7/2025 5:18 AM, Youssef Samir wrote:
> From: Youssef Samir <quic_yabdulra@quicinc.com>
>
> 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.
>
> Signed-off-by: Youssef Samir <quic_yabdulra@quicinc.com>
> Signed-off-by: Youssef Samir <youssef.abdulrahman@oss.qualcomm.com>
Reviewed-by: Carl Vanderlip <carl.vanderlip@oss.qualcomm.com>
^ permalink raw reply [flat|nested] 4+ messages in thread
* Re: [PATCH] accel/qaic: Use kvcalloc() for slice requests allocation
2025-10-07 12:18 [PATCH] accel/qaic: Use kvcalloc() for slice requests allocation Youssef Samir
2025-10-07 15:15 ` Jeff Hugo
2025-10-13 22:08 ` Carl Vanderlip
@ 2025-10-14 14:39 ` Jeff Hugo
2 siblings, 0 replies; 4+ messages in thread
From: Jeff Hugo @ 2025-10-14 14:39 UTC (permalink / raw)
To: Youssef Samir, carl.vanderlip, troy.hanson, zachary.mckevitt
Cc: ogabbay, linux-arm-msm, dri-devel
On 10/7/2025 6:18 AM, Youssef Samir wrote:
> From: Youssef Samir <quic_yabdulra@quicinc.com>
>
> 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.
>
> Signed-off-by: Youssef Samir <quic_yabdulra@quicinc.com>
> Signed-off-by: Youssef Samir <youssef.abdulrahman@oss.qualcomm.com>
Pushed to drm-misc-next.
-Jeff
^ permalink raw reply [flat|nested] 4+ messages in thread
end of thread, other threads:[~2025-10-14 14:39 UTC | newest]
Thread overview: 4+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2025-10-07 12:18 [PATCH] accel/qaic: Use kvcalloc() for slice requests allocation Youssef Samir
2025-10-07 15:15 ` Jeff Hugo
2025-10-13 22:08 ` Carl Vanderlip
2025-10-14 14:39 ` Jeff Hugo
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox