drivers/gpu/drm/xe/xe_gt_sriov_pf_policy.c

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

File Facts

System
Linux kernel
Corpus path
drivers/gpu/drm/xe/xe_gt_sriov_pf_policy.c
Extension
.c
Size
22642 bytes
Lines
796
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

switch (hwe->class) {
		case XE_ENGINE_CLASS_VIDEO_DECODE:
			slice = hwe->instance / 2;
			break;
		case XE_ENGINE_CLASS_VIDEO_ENHANCE:
			slice = hwe->instance;
			break;
		case XE_ENGINE_CLASS_OTHER:
			slice = 0;
			break;
		default:
			xe_gt_assert_msg(gt, false,
					 "unknown media gt class %u (%s) during EGS setup\n",
					 hwe->class, hwe->name);
			slice = 0;
		}

		values[slice_to_group[slice]].engines[guc_class] |= BIT(hwe->logical_instance);
	}

	*groups = values;
	*num_groups = group;
}

/**
 * xe_sriov_gt_pf_policy_has_sched_groups_support() - Checks whether scheduler
 * groups are supported.
 * @gt: the &xe_gt
 *
 * This function can only be called on PF.
 *
 * Return: true if scheduler groups are supported, false otherwise.
 */
bool xe_sriov_gt_pf_policy_has_sched_groups_support(struct xe_gt *gt)
{
	xe_gt_assert(gt, IS_SRIOV_PF(gt_to_xe(gt)));

	/*
	 * The GuC supports scheduler groups from v70.53.0, but a fix for it has
	 * been merged in v70.55.1, so we require the latter. The feature is
	 * also only enabled on BMG and newer FW.
	 */
	return GUC_FIRMWARE_VER_AT_LEAST(&gt->uc.guc, 70, 55, 1) &&
	       gt_to_xe(gt)->info.platform >= XE_BATTLEMAGE;
}

static void pf_init_sched_groups(struct xe_gt *gt)
{
	enum xe_sriov_sched_group_modes m;

	if (!xe_sriov_gt_pf_policy_has_sched_groups_support(gt))
		return;

	/*
	 * The GuC interface supports up to 8 groups. However, the GuC only
	 * fully allocates resources for a subset of groups, based on the number
	 * of engines and expected usage. The plan is for this to become
	 * queryable via H2G, but for now GuC FW for all devices supports a
	 * maximum of 2 groups so we can just hardcode that.
	 */
	gt->sriov.pf.policy.guc.sched_groups.max_groups = 2;

	for (m = XE_SRIOV_SCHED_GROUPS_DISABLED + 1; m < XE_SRIOV_SCHED_GROUPS_MODES_COUNT; m++) {
		u32 *num_groups = &gt->sriov.pf.policy.guc.sched_groups.modes[m].num_groups;
		struct guc_sched_group **groups =
			&gt->sriov.pf.policy.guc.sched_groups.modes[m].groups;

		switch (m) {
		case XE_SRIOV_SCHED_GROUPS_MEDIA_SLICES:
			/* this mode only has groups on the media GT */
			if (xe_gt_is_media_type(gt))
				pf_sched_group_media_slices(gt, groups, num_groups);
			break;
		case XE_SRIOV_SCHED_GROUPS_DISABLED:
		case XE_SRIOV_SCHED_GROUPS_MODES_COUNT:
			/*
			 * By defining m of type enum xe_sriov_sched_group_modes
			 * we can get the compiler to automatically flag
			 * missing cases if new enum entries are added. However,
			 * to keep the compiler happy we also need to add the
			 * cases that are excluded from the loop.
			 */
			xe_gt_assert(gt, false);
			break;
		}

		xe_gt_assert(gt, *num_groups < GUC_MAX_SCHED_GROUPS);

		if (*num_groups)
			gt->sriov.pf.policy.guc.sched_groups.supported_modes |= BIT(m);

Annotation

Implementation Notes