drivers/gpu/drm/xe/xe_sriov_vf_ccs.c

Source file repositories/reference/linux-study-clean/drivers/gpu/drm/xe/xe_sriov_vf_ccs.c

File Facts

System
Linux kernel
Corpus path
drivers/gpu/drm/xe/xe_sriov_vf_ccs.c
Extension
.c
Size
17692 bytes
Lines
496
Domain
Driver Families
Bucket
drivers/gpu
Inferred role
Driver Families: implementation source
Status
source implementation candidate

Why This File Exists

Repeatable hardware-adapter layer. Deep compatibility for every driver is out of scope; this atlas records patterns, probe lifecycles, bus glue, IRQ/DMA usage, and links back to core abstractions.

Dependency Surface

Detected Declarations

Annotated Snippet

if (IS_ERR(q)) {
			err = PTR_ERR(q);
			goto err_ret;
		}
		ctx->mig_q = q;

		err = alloc_bb_pool(tile, ctx);
		if (err)
			goto err_free_queue;

		ccs_rw_update_ring(ctx);

		err = register_save_restore_context(ctx);
		if (err)
			goto err_free_queue;

		err = devm_add_action_or_reset(xe->drm.dev,
					       xe_sriov_vf_ccs_fini,
					       ctx);
		if (err)
			goto err_ret;
	}

	xe->sriov.vf.ccs.initialized = 1;

	return 0;

err_free_queue:
	xe_exec_queue_put(q);

err_ret:
	return err;
}

#define XE_SRIOV_VF_CCS_RW_BB_ADDR_OFFSET	(2 * sizeof(u32))
void xe_sriov_vf_ccs_rw_update_bb_addr(struct xe_sriov_vf_ccs_ctx *ctx)
{
	u64 addr = xe_mem_pool_gpu_addr(ctx->mem.ccs_bb_pool);
	struct xe_lrc *lrc = xe_exec_queue_lrc(ctx->mig_q);
	struct xe_device *xe = gt_to_xe(ctx->mig_q->gt);

	xe_device_wmb(xe);
	xe_map_wr(xe, &lrc->bo->vmap, XE_SRIOV_VF_CCS_RW_BB_ADDR_OFFSET, u32, addr);
	xe_device_wmb(xe);
}

/**
 * xe_sriov_vf_ccs_attach_bo - Insert CCS read write commands in the BO.
 * @bo: the &buffer object to which batch buffer commands will be added.
 *
 * This function shall be called only by VF. It inserts the PTEs and copy
 * command instructions in the BO by calling xe_migrate_ccs_rw_copy()
 * function.
 *
 * Returns: 0 if successful, negative error code on failure.
 */
int xe_sriov_vf_ccs_attach_bo(struct xe_bo *bo)
{
	struct xe_device *xe = xe_bo_device(bo);
	enum xe_sriov_vf_ccs_rw_ctxs ctx_id;
	struct xe_sriov_vf_ccs_ctx *ctx;
	struct xe_mem_pool_node *bb;
	struct xe_tile *tile;
	int err = 0;

	xe_assert(xe, IS_VF_CCS_READY(xe));

	tile = xe_device_get_root_tile(xe);

	for_each_ccs_rw_ctx(ctx_id) {
		bb = bo->bb_ccs[ctx_id];
		/* bb should be NULL here. Assert if not NULL */
		xe_assert(xe, !bb);

		ctx = &xe->sriov.vf.ccs.contexts[ctx_id];
		err = xe_migrate_ccs_rw_copy(tile, ctx->mig_q, bo, ctx_id);
	}
	return err;
}

/**
 * xe_sriov_vf_ccs_detach_bo - Remove CCS read write commands from the BO.
 * @bo: the &buffer object from which batch buffer commands will be removed.
 *
 * This function shall be called only by VF. It removes the PTEs and copy
 * command instructions from the BO. Make sure to update the BB with MI_NOOP
 * before freeing.
 *
 * Returns: 0 if successful.
 */

Annotation

Implementation Notes