]> www.infradead.org Git - users/dwmw2/linux.git/commitdiff
accel/qaic: Create a function to initialize BO
authorPranjal Ramajor Asha Kanojiya <quic_pkanojiy@quicinc.com>
Fri, 1 Sep 2023 17:22:46 +0000 (11:22 -0600)
committerJeffrey Hugo <quic_jhugo@quicinc.com>
Fri, 22 Sep 2023 15:58:13 +0000 (09:58 -0600)
This makes sure that we have a single place to initialize and
re-initialize BO.

Use this new API to cleanup release_dbc()

We will need this for next patch to detach slicing to a BO.

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-7-quic_jhugo@quicinc.com
drivers/accel/qaic/qaic_data.c

index 6e44e00937af0cdd739d750b93e2c922f6138ea3..2acb9dbac88be1680dadfc7d022f2a3f910c5cdc 100644 (file)
@@ -635,6 +635,18 @@ static const struct drm_gem_object_funcs qaic_gem_funcs = {
        .vm_ops = &drm_vm_ops,
 };
 
+static void qaic_init_bo(struct qaic_bo *bo, bool reinit)
+{
+       if (reinit) {
+               bo->sliced = false;
+               reinit_completion(&bo->xfer_done);
+       } else {
+               init_completion(&bo->xfer_done);
+       }
+       complete_all(&bo->xfer_done);
+       INIT_LIST_HEAD(&bo->slices);
+}
+
 static struct qaic_bo *qaic_alloc_init_bo(void)
 {
        struct qaic_bo *bo;
@@ -643,9 +655,7 @@ static struct qaic_bo *qaic_alloc_init_bo(void)
        if (!bo)
                return ERR_PTR(-ENOMEM);
 
-       INIT_LIST_HEAD(&bo->slices);
-       init_completion(&bo->xfer_done);
-       complete_all(&bo->xfer_done);
+       qaic_init_bo(bo, false);
 
        return bo;
 }
@@ -1880,9 +1890,7 @@ void release_dbc(struct qaic_device *qdev, u32 dbc_id)
        list_for_each_entry_safe(bo, bo_temp, &dbc->bo_lists, bo_list) {
                qaic_free_slices_bo(bo);
                qaic_unprepare_bo(qdev, bo);
-               bo->sliced = false;
-               INIT_LIST_HEAD(&bo->slices);
-               init_completion(&bo->xfer_done);
+               qaic_init_bo(bo, true);
                list_del(&bo->bo_list);
        }