On 10/28/2025 1:07 AM, Karol Wachowski wrote:
@@ -377,7 +379,7 @@ int ivpu_bo_create_ioctl(struct drm_device *dev, void
*data, struct drm_file *fi
ret = drm_gem_handle_create(file, &bo->base.base, &args->handle);
if (ret) {
- ivpu_err(vdev, "Failed to create handle for BO: %pe (ctx %u size
%llu flags 0x%x)",
+ ivpu_err(vdev, "Failed to create handle for BO: %pe ctx %u size %llu
flags 0x%x\n",
bo, file_priv->ctx.id, args->size, args->flags);
This looks like it could be triggered by a user (in an ioctl, and in
this case the user could exhaust the handle space), so this should be
changed to a debug message per the commit text, no?
} else {
args->vpu_addr = bo->vpu_addr;
@@ -406,14 +408,17 @@ ivpu_bo_create(struct ivpu_device *vdev, struct
ivpu_mmu_context *ctx,
bo = ivpu_bo_alloc(vdev, size, flags);
if (IS_ERR(bo)) {
- ivpu_err(vdev, "Failed to allocate BO: %pe (vpu_addr 0x%llx size
%llu flags 0x%x)",
+ ivpu_err(vdev, "Failed to allocate BO: %pe vpu_addr 0x%llx size %llu
flags 0x%x\n",
bo, range->start, size, flags);
Another possible debug message?
return NULL;
}
ret = ivpu_bo_alloc_vpu_addr(bo, ctx, range);
- if (ret)
+ if (ret) {
+ ivpu_err(vdev, "Failed to allocate NPU address for BO: %pe ctx %u
size %llu: %d\n",
+ bo, ctx->id, size, ret);
Another possible debug message?
goto err_put;
+ }
ret = ivpu_bo_bind(bo);
if (ret)
@@ -193,7 +206,7 @@ int ivpu_bo_create_from_userptr_ioctl(struct drm_device
*dev, void *data, struct
ret = drm_gem_handle_create(file, &bo->base.base, &args->handle);
if (ret) {
- ivpu_err(vdev, "Failed to create handle for BO: %pe (ctx %u size
%llu flags 0x%x)",
+ ivpu_err(vdev, "Failed to create handle for BO: %pe ctx %u size %llu
flags 0x%x\n",
bo, file_priv->ctx.id, args->size, args->flags);
Another possible debug message?
} else {
ivpu_dbg(vdev, BO, "Created userptr BO: handle=%u vpu_addr=0x%llx
size=%llu flags=0x%x\n",
@@ -69,12 +71,18 @@ int ivpu_ms_start_ioctl(struct drm_device *dev, void *data,
struct drm_file *fil
if (ret)
goto err_free_ms;
- single_buff_size = sample_size *
- ((u64)args->read_period_samples * MS_READ_PERIOD_MULTIPLIER);
- ms->bo = ivpu_bo_create_global(vdev, PAGE_ALIGN(single_buff_size *
MS_NUM_BUFFERS),
- DRM_IVPU_BO_CACHED |
DRM_IVPU_BO_MAPPABLE);
+ buf_size = PAGE_ALIGN((u64)args->read_period_samples * sample_size *
+ MS_READ_PERIOD_MULTIPLIER * MS_NUM_BUFFERS);
+ if (buf_size > ivpu_hw_range_size(&vdev->hw->ranges.global)) {
+ ivpu_dbg(vdev, IOCTL, "Requested MS buffer size %llu exceeds range
size %llu\n",
+ buf_size,
ivpu_hw_range_size(&vdev->hw->ranges.global));
+ ret = -EINVAL;
+ goto err_free_ms;
+ }
+
+ ms->bo = ivpu_bo_create_global(vdev, buf_size, DRM_IVPU_BO_CACHED |
DRM_IVPU_BO_MAPPABLE);
if (!ms->bo) {
- ivpu_err(vdev, "Failed to allocate MS buffer (size %llu)\n",
single_buff_size);
+ ivpu_err(vdev, "Failed to allocate MS buffer (size %llu)\n",
buf_size);
Another possible debug message?
ret = -ENOMEM;
goto err_free_ms;
}