drivers/gpu/drm/xe/xe_guc_engine_activity.c
Source file repositories/reference/linux-study-clean/drivers/gpu/drm/xe/xe_guc_engine_activity.c
File Facts
- System
- Linux kernel
- Corpus path
drivers/gpu/drm/xe/xe_guc_engine_activity.c- Extension
.c- Size
- 15542 bytes
- Lines
- 522
- 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.
- Defines or uses C structs; map object ownership, embedded links, reference counts, and lock ownership.
Dependency Surface
drm/drm_managed.habi/guc_actions_abi.hregs/xe_gt_regs.hxe_bo.hxe_force_wake.hxe_gt_printk.hxe_guc.hxe_guc_engine_activity.hxe_guc_ct.hxe_hw_engine.hxe_map.hxe_mmio.hxe_sriov_pf_helpers.hxe_trace_guc.h
Detected Declarations
function engine_activity_mapfunction engine_metadata_mapfunction allocate_engine_activity_groupfunction allocate_engine_activity_buffersfunction free_engine_activity_buffersfunction is_engine_activity_supportedfunction cpu_ns_to_guc_tsc_tickfunction get_engine_active_ticksfunction get_engine_total_ticksfunction enable_engine_activity_statsfunction enable_function_engine_activity_statsfunction engine_activity_set_cpu_tsfunction gpm_timestamp_shiftfunction is_function_validfunction engine_activity_disable_function_statsfunction engine_activity_enable_function_statsfunction xe_guc_engine_activity_active_ticksfunction xe_guc_engine_activity_total_ticksfunction versionfunction xe_guc_engine_activity_function_statsfunction xe_guc_engine_activity_enable_statsfunction engine_activity_finifunction xe_guc_engine_activity_init
Annotated Snippet
// SPDX-License-Identifier: MIT
/*
* Copyright © 2025 Intel Corporation
*/
#include <drm/drm_managed.h>
#include "abi/guc_actions_abi.h"
#include "regs/xe_gt_regs.h"
#include "xe_bo.h"
#include "xe_force_wake.h"
#include "xe_gt_printk.h"
#include "xe_guc.h"
#include "xe_guc_engine_activity.h"
#include "xe_guc_ct.h"
#include "xe_hw_engine.h"
#include "xe_map.h"
#include "xe_mmio.h"
#include "xe_sriov_pf_helpers.h"
#include "xe_trace_guc.h"
#define TOTAL_QUANTA 0x8000
static struct iosys_map engine_activity_map(struct xe_guc *guc, struct xe_hw_engine *hwe,
unsigned int index)
{
struct xe_guc_engine_activity *engine_activity = &guc->engine_activity;
struct engine_activity_buffer *buffer;
u16 guc_class = xe_engine_class_to_guc_class(hwe->class);
size_t offset;
if (engine_activity->num_functions) {
buffer = &engine_activity->function_buffer;
offset = sizeof(struct guc_engine_activity_data) * index;
} else {
buffer = &engine_activity->device_buffer;
offset = 0;
}
offset += offsetof(struct guc_engine_activity_data,
engine_activity[guc_class][hwe->logical_instance]);
return IOSYS_MAP_INIT_OFFSET(&buffer->activity_bo->vmap, offset);
}
static struct iosys_map engine_metadata_map(struct xe_guc *guc,
unsigned int index)
{
struct xe_guc_engine_activity *engine_activity = &guc->engine_activity;
struct engine_activity_buffer *buffer;
size_t offset;
if (engine_activity->num_functions) {
buffer = &engine_activity->function_buffer;
offset = sizeof(struct guc_engine_activity_metadata) * index;
} else {
buffer = &engine_activity->device_buffer;
offset = 0;
}
return IOSYS_MAP_INIT_OFFSET(&buffer->metadata_bo->vmap, offset);
}
static int allocate_engine_activity_group(struct xe_guc *guc)
{
struct xe_guc_engine_activity *engine_activity = &guc->engine_activity;
struct xe_device *xe = guc_to_xe(guc);
u32 num_activity_group;
/*
* An additional activity group is allocated for PF
*/
num_activity_group = IS_SRIOV_PF(xe) ? xe_sriov_pf_get_totalvfs(xe) + 1 : 1;
engine_activity->eag = drmm_kcalloc(&xe->drm, num_activity_group,
sizeof(struct engine_activity_group), GFP_KERNEL);
if (!engine_activity->eag)
return -ENOMEM;
engine_activity->num_activity_group = num_activity_group;
return 0;
}
static int allocate_engine_activity_buffers(struct xe_guc *guc,
struct engine_activity_buffer *buffer,
int count)
{
Annotation
- Immediate include surface: `drm/drm_managed.h`, `abi/guc_actions_abi.h`, `regs/xe_gt_regs.h`, `xe_bo.h`, `xe_force_wake.h`, `xe_gt_printk.h`, `xe_guc.h`, `xe_guc_engine_activity.h`.
- Detected declarations: `function engine_activity_map`, `function engine_metadata_map`, `function allocate_engine_activity_group`, `function allocate_engine_activity_buffers`, `function free_engine_activity_buffers`, `function is_engine_activity_supported`, `function cpu_ns_to_guc_tsc_tick`, `function get_engine_active_ticks`, `function get_engine_total_ticks`, `function enable_engine_activity_stats`.
- Atlas domain: Driver Families / drivers/gpu.
- Implementation status: source implementation candidate.
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.