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.
- 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.
- Uses kernel synchronization; read lock ordering, sleepability, and interrupt context assumptions before translating.
- Defines or uses C structs; map object ownership, embedded links, reference counts, and lock ownership.
Dependency Surface
drm/drm_managed.habi/guc_actions_sriov_abi.hxe_gt.hxe_gt_sriov_pf_config.hxe_gt_sriov_pf_helpers.hxe_gt_sriov_pf_policy.hxe_gt_sriov_printk.hxe_guc.hxe_guc_buf.hxe_guc_ct.hxe_guc_klv_helpers.hxe_guc_submit.h
Detected Declarations
function guc_action_update_vgt_policyfunction pf_send_policy_klvsfunction pf_push_policy_buf_klvsfunction pf_push_policy_klvsfunction pf_push_policy_u32function pf_push_policy_payloadfunction pf_update_policy_boolfunction pf_update_policy_u32function pf_provision_sched_if_idlefunction pf_reprovision_sched_if_idlefunction pf_sanitize_sched_if_idlefunction xe_gt_sriov_pf_policy_set_sched_if_idle_lockedfunction xe_gt_sriov_pf_policy_set_sched_if_idlefunction xe_gt_sriov_pf_policy_get_sched_if_idle_lockedfunction xe_gt_sriov_pf_policy_get_sched_if_idlefunction pf_provision_reset_enginefunction pf_reprovision_reset_enginefunction pf_sanitize_reset_enginefunction xe_gt_sriov_pf_policy_set_reset_enginefunction xe_gt_sriov_pf_policy_get_reset_enginefunction pf_provision_sample_periodfunction pf_reprovision_sample_periodfunction pf_sanitize_sample_periodfunction xe_gt_sriov_pf_policy_set_sample_periodfunction xe_gt_sriov_pf_policy_get_sample_periodfunction pf_sched_group_media_slicesfunction for_each_hw_enginefunction xe_sriov_gt_pf_policy_has_sched_groups_supportfunction pf_init_sched_groupsfunction xe_sriov_gt_pf_policy_has_multi_group_modesfunction xe_sriov_gt_pf_policy_has_sched_group_modefunction __pf_provision_sched_groupsfunction pf_provision_sched_groupsfunction xe_guc_has_registered_mlrc_queuesfunction pf_reprovision_sched_groupsfunction pf_sanitize_sched_groupsfunction xe_gt_sriov_pf_policy_set_sched_groups_modefunction xe_gt_sriov_pf_policy_sched_groups_enabledfunction pf_sanitize_guc_policiesfunction xe_gt_sriov_pf_policy_sanitizefunction xe_gt_sriov_pf_policy_restartfunction xe_gt_sriov_pf_policy_initfunction print_guc_policiesfunction xe_gt_sriov_pf_policy_print
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(>->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 = >->sriov.pf.policy.guc.sched_groups.modes[m].num_groups;
struct guc_sched_group **groups =
>->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
- Immediate include surface: `drm/drm_managed.h`, `abi/guc_actions_sriov_abi.h`, `xe_gt.h`, `xe_gt_sriov_pf_config.h`, `xe_gt_sriov_pf_helpers.h`, `xe_gt_sriov_pf_policy.h`, `xe_gt_sriov_printk.h`, `xe_guc.h`.
- Detected declarations: `function guc_action_update_vgt_policy`, `function pf_send_policy_klvs`, `function pf_push_policy_buf_klvs`, `function pf_push_policy_klvs`, `function pf_push_policy_u32`, `function pf_push_policy_payload`, `function pf_update_policy_bool`, `function pf_update_policy_u32`, `function pf_provision_sched_if_idle`, `function pf_reprovision_sched_if_idle`.
- Atlas domain: Driver Families / drivers/gpu.
- Implementation status: source implementation candidate.
- Synchronization appears in or near this file; preserve lock ordering, sleepability, and interrupt-context constraints.
Implementation Notes
- This generated page is the file-by-file coverage layer; curated subsystem chapters should link here when they synthesize a multi-file control flow.
- Core OS pages should be promoted from atlas-only to deep-reviewed when they explain data structures, invariants, locking, lifecycle, and C implementation snippets.
- Driver-family pages are intentionally pattern-oriented unless they are part of the selected PCIe/NVMe representative device path.