Commit cb850f6f authored by Pranjal Ramajor Asha Kanojiya's avatar Pranjal Ramajor Asha Kanojiya Committed by Jeffrey Hugo

accel/qaic: Remove ->size field from struct qaic_bo

->size field in struct qaic_bo stores user requested buffer size for
allocate path or size of the dmabuf(PRIME). Now for allocate path driver
allocates a BO of size which is PAGE_SIZE aligned, this size is already
stored in base BO structure (struct drm_gem_object).

So difference is ->size of struct qaic_bo stores the raw value coming from
user and ->size in struct drm_gem_object stores the PAGE_SZIE aligned size.

Do not use ->size from struct qaic_bo for any validation or operation
instead use ->size from struct drm_gem_object since we already have
allocated that much memory then why not use it. Only validate if user
is trying to use more then the BO size. This make the driver more flexible.

After this change ->size field of struct qaic_bo becomes redundant. Remove
it.
Signed-off-by: default avatarPranjal Ramajor Asha Kanojiya <quic_pkanojiy@quicinc.com>
Reviewed-by: default avatarJeffrey Hugo <quic_jhugo@quicinc.com>
Signed-off-by: default avatarJeffrey Hugo <quic_jhugo@quicinc.com>
Reviewed-by: default avatarStanislaw Gruszka <stanislaw.gruszka@linux.intel.com>
Link: https://patchwork.freedesktop.org/patch/msgid/20230901172247.11410-2-quic_jhugo@quicinc.com
parent a08e0622
...@@ -161,8 +161,6 @@ struct qaic_bo { ...@@ -161,8 +161,6 @@ struct qaic_bo {
struct drm_gem_object base; struct drm_gem_object base;
/* Scatter/gather table for allocate/imported BO */ /* Scatter/gather table for allocate/imported BO */
struct sg_table *sgt; struct sg_table *sgt;
/* BO size requested by user. GEM object might be bigger in size. */
u64 size;
/* Head in list of slices of this BO */ /* Head in list of slices of this BO */
struct list_head slices; struct list_head slices;
/* Total nents, for all slices of this BO */ /* Total nents, for all slices of this BO */
......
...@@ -579,7 +579,7 @@ static void qaic_gem_print_info(struct drm_printer *p, unsigned int indent, ...@@ -579,7 +579,7 @@ static void qaic_gem_print_info(struct drm_printer *p, unsigned int indent,
{ {
struct qaic_bo *bo = to_qaic_bo(obj); struct qaic_bo *bo = to_qaic_bo(obj);
drm_printf_indent(p, indent, "user requested size=%llu\n", bo->size); drm_printf_indent(p, indent, "BO DMA direction %d\n", bo->dir);
} }
static const struct vm_operations_struct drm_vm_ops = { static const struct vm_operations_struct drm_vm_ops = {
...@@ -695,8 +695,6 @@ int qaic_create_bo_ioctl(struct drm_device *dev, void *data, struct drm_file *fi ...@@ -695,8 +695,6 @@ int qaic_create_bo_ioctl(struct drm_device *dev, void *data, struct drm_file *fi
if (ret) if (ret)
goto free_bo; goto free_bo;
bo->size = args->size;
ret = drm_gem_handle_create(file_priv, obj, &args->handle); ret = drm_gem_handle_create(file_priv, obj, &args->handle);
if (ret) if (ret)
goto free_sgt; goto free_sgt;
...@@ -828,7 +826,6 @@ static int qaic_prepare_import_bo(struct qaic_bo *bo, struct qaic_attach_slice_h ...@@ -828,7 +826,6 @@ static int qaic_prepare_import_bo(struct qaic_bo *bo, struct qaic_attach_slice_h
} }
bo->sgt = sgt; bo->sgt = sgt;
bo->size = hdr->size;
return 0; return 0;
} }
...@@ -838,7 +835,7 @@ static int qaic_prepare_export_bo(struct qaic_device *qdev, struct qaic_bo *bo, ...@@ -838,7 +835,7 @@ static int qaic_prepare_export_bo(struct qaic_device *qdev, struct qaic_bo *bo,
{ {
int ret; int ret;
if (bo->size != hdr->size) if (bo->base.size < hdr->size)
return -EINVAL; return -EINVAL;
ret = dma_map_sgtable(&qdev->pdev->dev, bo->sgt, hdr->dir, 0); ret = dma_map_sgtable(&qdev->pdev->dev, bo->sgt, hdr->dir, 0);
...@@ -868,7 +865,6 @@ static void qaic_unprepare_import_bo(struct qaic_bo *bo) ...@@ -868,7 +865,6 @@ static void qaic_unprepare_import_bo(struct qaic_bo *bo)
{ {
dma_buf_unmap_attachment(bo->base.import_attach, bo->sgt, bo->dir); dma_buf_unmap_attachment(bo->base.import_attach, bo->sgt, bo->dir);
bo->sgt = NULL; bo->sgt = NULL;
bo->size = 0;
} }
static void qaic_unprepare_export_bo(struct qaic_device *qdev, struct qaic_bo *bo) static void qaic_unprepare_export_bo(struct qaic_device *qdev, struct qaic_bo *bo)
...@@ -1190,7 +1186,7 @@ static int send_bo_list_to_device(struct qaic_device *qdev, struct drm_file *fil ...@@ -1190,7 +1186,7 @@ static int send_bo_list_to_device(struct qaic_device *qdev, struct drm_file *fil
goto failed_to_send_bo; goto failed_to_send_bo;
} }
if (is_partial && pexec[i].resize > bo->size) { if (is_partial && pexec[i].resize > bo->base.size) {
ret = -EINVAL; ret = -EINVAL;
goto failed_to_send_bo; goto failed_to_send_bo;
} }
......
...@@ -242,12 +242,12 @@ struct qaic_attach_slice_entry { ...@@ -242,12 +242,12 @@ struct qaic_attach_slice_entry {
* @dbc_id: In. Associate the sliced BO with this DBC. * @dbc_id: In. Associate the sliced BO with this DBC.
* @handle: In. GEM handle of the BO to slice. * @handle: In. GEM handle of the BO to slice.
* @dir: In. Direction of data flow. 1 = DMA_TO_DEVICE, 2 = DMA_FROM_DEVICE * @dir: In. Direction of data flow. 1 = DMA_TO_DEVICE, 2 = DMA_FROM_DEVICE
* @size: In. Total length of the BO. * @size: In. Total length of BO being used. This should not exceed base
* If BO is imported (DMABUF/PRIME) then this size * size of BO (struct drm_gem_object.base)
* should not exceed the size of DMABUF provided. * For BOs being allocated using DRM_IOCTL_QAIC_CREATE_BO, size of
* If BO is allocated using DRM_IOCTL_QAIC_CREATE_BO * BO requested is PAGE_SIZE aligned then allocated hence allocated
* then this size should be exactly same as the size * BO size maybe bigger. This size should not exceed the new
* provided during DRM_IOCTL_QAIC_CREATE_BO. * PAGE_SIZE aligned BO size.
* @dev_addr: In. Device address this slice pushes to or pulls from. * @dev_addr: In. Device address this slice pushes to or pulls from.
* @db_addr: In. Address of the doorbell to ring. * @db_addr: In. Address of the doorbell to ring.
* @db_data: In. Data to write to the doorbell. * @db_data: In. Data to write to the doorbell.
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment