Skip to content

Commit 76d42aa

Browse files
Pranjal Ramajor Asha Kanojiyaquic-jhugo
authored andcommitted
accel/qaic: Update BO metadata in a central location
Update/Clean up BO metadata in a central location, this will help maintain the code and looks cleaner. Use qaic_unprepare_bo() to cleanup release_dbc() Next few patches will be implementing detach IOCTL which will leverage this patch. Signed-off-by: Pranjal Ramajor Asha Kanojiya <quic_pkanojiy@quicinc.com> Reviewed-by: Jeffrey Hugo <quic_jhugo@quicinc.com> Signed-off-by: Jeffrey Hugo <quic_jhugo@quicinc.com> Reviewed-by: Stanislaw Gruszka <stanislaw.gruszka@linux.intel.com> Link: https://patchwork.freedesktop.org/patch/msgid/20230901172247.11410-3-quic_jhugo@quicinc.com
1 parent cb850f6 commit 76d42aa

1 file changed

Lines changed: 8 additions & 10 deletions

File tree

drivers/accel/qaic/qaic_data.c

Lines changed: 8 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -854,9 +854,9 @@ static int qaic_prepare_bo(struct qaic_device *qdev, struct qaic_bo *bo,
854854
ret = qaic_prepare_import_bo(bo, hdr);
855855
else
856856
ret = qaic_prepare_export_bo(qdev, bo, hdr);
857-
858-
if (ret == 0)
859-
bo->dir = hdr->dir;
857+
bo->dir = hdr->dir;
858+
bo->dbc = &qdev->dbc[hdr->dbc_id];
859+
bo->nr_slice = hdr->count;
860860

861861
return ret;
862862
}
@@ -880,6 +880,8 @@ static void qaic_unprepare_bo(struct qaic_device *qdev, struct qaic_bo *bo)
880880
qaic_unprepare_export_bo(qdev, bo);
881881

882882
bo->dir = 0;
883+
bo->dbc = NULL;
884+
bo->nr_slice = 0;
883885
}
884886

885887
static void qaic_free_slices_bo(struct qaic_bo *bo)
@@ -904,14 +906,13 @@ static int qaic_attach_slicing_bo(struct qaic_device *qdev, struct qaic_bo *bo,
904906
}
905907
}
906908

907-
if (bo->total_slice_nents > qdev->dbc[hdr->dbc_id].nelem) {
909+
if (bo->total_slice_nents > bo->dbc->nelem) {
908910
qaic_free_slices_bo(bo);
909911
return -ENOSPC;
910912
}
911913

912914
bo->sliced = true;
913-
bo->nr_slice = hdr->count;
914-
list_add_tail(&bo->bo_list, &qdev->dbc[hdr->dbc_id].bo_lists);
915+
list_add_tail(&bo->bo_list, &bo->dbc->bo_lists);
915916

916917
return 0;
917918
}
@@ -1014,7 +1015,6 @@ int qaic_attach_slice_bo_ioctl(struct drm_device *dev, void *data, struct drm_fi
10141015
if (args->hdr.dir == DMA_TO_DEVICE)
10151016
dma_sync_sgtable_for_cpu(&qdev->pdev->dev, bo->sgt, args->hdr.dir);
10161017

1017-
bo->dbc = dbc;
10181018
srcu_read_unlock(&dbc->ch_lock, rcu_id);
10191019
drm_gem_object_put(obj);
10201020
srcu_read_unlock(&qdev->dev_lock, qdev_rcu_id);
@@ -1870,14 +1870,12 @@ void release_dbc(struct qaic_device *qdev, u32 dbc_id)
18701870
dbc->usr = NULL;
18711871

18721872
list_for_each_entry_safe(bo, bo_temp, &dbc->bo_lists, bo_list) {
1873+
qaic_unprepare_bo(qdev, bo);
18731874
list_for_each_entry_safe(slice, slice_temp, &bo->slices, slice)
18741875
kref_put(&slice->ref_count, free_slice);
18751876
bo->sliced = false;
18761877
INIT_LIST_HEAD(&bo->slices);
18771878
bo->total_slice_nents = 0;
1878-
bo->dir = 0;
1879-
bo->dbc = NULL;
1880-
bo->nr_slice = 0;
18811879
bo->nr_slice_xfer_done = 0;
18821880
bo->queued = false;
18831881
bo->req_id = 0;

0 commit comments

Comments
 (0)