Commit 916ee470 authored by Satyanarayana K V P's avatar Satyanarayana K V P Committed by Matthew Brost
Browse files

drm/xe/vf: Register CCS read/write contexts with Guc



Register read write contexts with newly added flags with GUC and
enable the context immediately after registration.
Re-register the context with Guc when resuming from runtime suspend as
soft reset is applied to Guc during xe_pm_runtime_resume().
Make Ring head=tail while unbinding device to avoid issues with VF pause
after device is unbinded.

Signed-off-by: default avatarSatyanarayana K V P <satyanarayana.k.v.p@intel.com>
Cc: Michal Wajdeczko <michal.wajdeczko@intel.com>
Cc: Matthew Brost <matthew.brost@intel.com>
Cc: Maarten Lankhorst <maarten.lankhorst@linux.intel.com>
Reviewed-by: default avatarMatthew Brost <matthew.brost@intel.com>
Signed-off-by: default avatarMatthew Brost <matthew.brost@intel.com>
Link: https://lore.kernel.org/r/20250722120506.6483-4-satyanarayana.k.v.p@intel.com
parent 864690cf
Loading
Loading
Loading
Loading
+5 −0
Original line number Diff line number Diff line
@@ -45,6 +45,11 @@
#define GUC_MAX_ENGINE_CLASSES		16
#define GUC_MAX_INSTANCES_PER_CLASS	32

#define GUC_CONTEXT_NORMAL			0
#define GUC_CONTEXT_COMPRESSION_SAVE		1
#define GUC_CONTEXT_COMPRESSION_RESTORE	2
#define GUC_CONTEXT_COUNT			(GUC_CONTEXT_COMPRESSION_RESTORE + 1)

/* Helper for context registration H2G */
struct guc_ctxt_registration_info {
	u32 flags;
+32 −2
Original line number Diff line number Diff line
@@ -542,7 +542,7 @@ static void __register_exec_queue(struct xe_guc *guc,
	xe_guc_ct_send(&guc->ct, action, ARRAY_SIZE(action), 0, 0);
}

static void register_exec_queue(struct xe_exec_queue *q)
static void register_exec_queue(struct xe_exec_queue *q, int ctx_type)
{
	struct xe_guc *guc = exec_queue_to_guc(q);
	struct xe_device *xe = guc_to_xe(guc);
@@ -550,6 +550,7 @@ static void register_exec_queue(struct xe_exec_queue *q)
	struct guc_ctxt_registration_info info;

	xe_gt_assert(guc_to_gt(guc), !exec_queue_registered(q));
	xe_gt_assert(guc_to_gt(guc), ctx_type < GUC_CONTEXT_COUNT);

	memset(&info, 0, sizeof(info));
	info.context_idx = q->guc->id;
@@ -559,6 +560,9 @@ static void register_exec_queue(struct xe_exec_queue *q)
	info.hwlrca_hi = upper_32_bits(xe_lrc_descriptor(lrc));
	info.flags = CONTEXT_REGISTRATION_FLAG_KMD;

	if (ctx_type != GUC_CONTEXT_NORMAL)
		info.flags |= BIT(ctx_type);

	if (xe_exec_queue_is_parallel(q)) {
		u64 ggtt_addr = xe_lrc_parallel_ggtt_addr(lrc);
		struct iosys_map map = xe_lrc_parallel_map(lrc);
@@ -761,7 +765,7 @@ guc_exec_queue_run_job(struct drm_sched_job *drm_job)

	if (!exec_queue_killed_or_banned_or_wedged(q) && !xe_sched_job_is_error(job)) {
		if (!exec_queue_registered(q))
			register_exec_queue(q);
			register_exec_queue(q, GUC_CONTEXT_NORMAL);
		if (!lr)	/* LR jobs are emitted in the exec IOCTL */
			q->ring_ops->emit_job(job);
		submit_exec_queue(q);
@@ -2383,6 +2387,32 @@ static void guc_exec_queue_print(struct xe_exec_queue *q, struct drm_printer *p)
	xe_guc_exec_queue_snapshot_free(snapshot);
}

/**
 * xe_guc_register_exec_queue - Register exec queue for a given context type.
 * @q: Execution queue
 * @ctx_type: Type of the context
 *
 * This function registers the execution queue with the guc. Special context
 * types like GUC_CONTEXT_COMPRESSION_SAVE and GUC_CONTEXT_COMPRESSION_RESTORE
 * are only applicable for IGPU and in the VF.
 * Submits the execution queue to GUC after registering it.
 *
 * Returns - None.
 */
void xe_guc_register_exec_queue(struct xe_exec_queue *q, int ctx_type)
{
	struct xe_guc *guc = exec_queue_to_guc(q);
	struct xe_device *xe = guc_to_xe(guc);

	xe_assert(xe, IS_SRIOV_VF(xe));
	xe_assert(xe, !IS_DGFX(xe));
	xe_assert(xe, (ctx_type > GUC_CONTEXT_NORMAL &&
		       ctx_type < GUC_CONTEXT_COUNT));

	register_exec_queue(q, ctx_type);
	enable_scheduling(q);
}

/**
 * xe_guc_submit_print - GuC Submit Print.
 * @guc: GuC.
+1 −0
Original line number Diff line number Diff line
@@ -39,5 +39,6 @@ xe_guc_exec_queue_snapshot_print(struct xe_guc_submit_exec_queue_snapshot *snaps
void
xe_guc_exec_queue_snapshot_free(struct xe_guc_submit_exec_queue_snapshot *snapshot);
void xe_guc_submit_print(struct xe_guc *guc, struct drm_printer *p);
void xe_guc_register_exec_queue(struct xe_exec_queue *q, int ctx_type);

#endif
+11 −13
Original line number Diff line number Diff line
@@ -86,19 +86,6 @@ struct xe_migrate {
 */
#define MAX_PTE_PER_SDI 0x1FEU

/**
 * xe_tile_migrate_exec_queue() - Get this tile's migrate exec queue.
 * @tile: The tile.
 *
 * Returns the default migrate exec queue of this tile.
 *
 * Return: The default migrate exec queue
 */
struct xe_exec_queue *xe_tile_migrate_exec_queue(struct xe_tile *tile)
{
	return tile->migrate->q;
}

static void xe_migrate_fini(void *arg)
{
	struct xe_migrate *m = arg;
@@ -1102,6 +1089,17 @@ int xe_migrate_ccs_rw_copy(struct xe_migrate *m,
	return err;
}

/**
 * xe_get_migrate_exec_queue() - Get the execution queue from migrate context.
 * @migrate: Migrate context.
 *
 * Return: Pointer to execution queue on success, error on failure
 */
struct xe_exec_queue *xe_migrate_exec_queue(struct xe_migrate *migrate)
{
	return migrate->q;
}

static void emit_clear_link_copy(struct xe_gt *gt, struct xe_bb *bb, u64 src_ofs,
				 u32 size, u32 pitch)
{
+1 −2
Original line number Diff line number Diff line
@@ -120,6 +120,7 @@ int xe_migrate_ccs_rw_copy(struct xe_migrate *m,
			   enum xe_sriov_vf_ccs_rw_ctxs read_write);

struct xe_lrc *xe_migrate_lrc(struct xe_migrate *migrate);
struct xe_exec_queue *xe_migrate_exec_queue(struct xe_migrate *migrate);
int xe_migrate_access_memory(struct xe_migrate *m, struct xe_bo *bo,
			     unsigned long offset, void *buf, int len,
			     int write);
@@ -140,6 +141,4 @@ xe_migrate_update_pgtables(struct xe_migrate *m,
			   struct xe_migrate_pt_update *pt_update);

void xe_migrate_wait(struct xe_migrate *m);

struct xe_exec_queue *xe_tile_migrate_exec_queue(struct xe_tile *tile);
#endif
Loading