drivers/gpu/drm/xe/xe_gt_idle.c
Source file repositories/reference/linux-study-clean/drivers/gpu/drm/xe/xe_gt_idle.c
File Facts
- System
- Linux kernel
- Corpus path
drivers/gpu/drm/xe/xe_gt_idle.c- Extension
.c- Size
- 11688 bytes
- Lines
- 434
- 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
linux/time64.hdrm/drm_managed.hgenerated/xe_wa_oob.hxe_force_wake.hxe_device.hxe_gt.hxe_gt_idle.hxe_gt_sysfs.hxe_guc_pc.hregs/xe_gt_regs.hxe_mmio.hxe_pm.hxe_sriov.hxe_wa.h
Detected Declarations
function pc_to_xefunction get_residency_msfunction xe_gt_idle_enable_pgfunction xe_gt_idle_disable_pgfunction force_wake_domains_showfunction xe_gt_idle_pg_printfunction name_showfunction idle_status_showfunction xe_gt_idle_residency_msecfunction idle_residency_ms_showfunction gt_idle_finifunction xe_gt_idle_initfunction xe_gt_idle_enable_c6function xe_gt_idle_disable_c6
Annotated Snippet
// SPDX-License-Identifier: MIT
/*
* Copyright © 2023 Intel Corporation
*/
#include <linux/time64.h>
#include <drm/drm_managed.h>
#include <generated/xe_wa_oob.h>
#include "xe_force_wake.h"
#include "xe_device.h"
#include "xe_gt.h"
#include "xe_gt_idle.h"
#include "xe_gt_sysfs.h"
#include "xe_guc_pc.h"
#include "regs/xe_gt_regs.h"
#include "xe_mmio.h"
#include "xe_pm.h"
#include "xe_sriov.h"
#include "xe_wa.h"
/**
* DOC: Xe GT Idle
*
* Contains functions that init GT idle features like C6
*
* device/gt#/gtidle/name - name of the state
* device/gt#/gtidle/idle_residency_ms - Provides residency of the idle state in ms
* device/gt#/gtidle/idle_status - Provides current idle state
*/
static struct xe_gt_idle *dev_to_gtidle(struct device *dev)
{
struct kobject *kobj = &dev->kobj;
return &kobj_to_gt(kobj->parent)->gtidle;
}
static struct xe_gt *gtidle_to_gt(struct xe_gt_idle *gtidle)
{
return container_of(gtidle, struct xe_gt, gtidle);
}
static struct xe_guc_pc *gtidle_to_pc(struct xe_gt_idle *gtidle)
{
return >idle_to_gt(gtidle)->uc.guc.pc;
}
static struct xe_device *
pc_to_xe(struct xe_guc_pc *pc)
{
struct xe_guc *guc = container_of(pc, struct xe_guc, pc);
struct xe_gt *gt = container_of(guc, struct xe_gt, uc.guc);
return gt_to_xe(gt);
}
static const char *gt_idle_state_to_string(enum xe_gt_idle_state state)
{
switch (state) {
case GT_IDLE_C0:
return "gt-c0";
case GT_IDLE_C6:
return "gt-c6";
default:
return "unknown";
}
}
static u64 get_residency_ms(struct xe_gt_idle *gtidle, u64 cur_residency)
{
u64 delta, overflow_residency, prev_residency;
lockdep_assert_held(>idle->lock);
overflow_residency = BIT_ULL(32);
/*
* Counter wrap handling
* Store previous hw counter values for counter wrap-around handling
* Relying on sufficient frequency of queries otherwise counters can still wrap.
*/
prev_residency = gtidle->prev_residency;
gtidle->prev_residency = cur_residency;
/* delta */
if (cur_residency >= prev_residency)
delta = cur_residency - prev_residency;
else
Annotation
- Immediate include surface: `linux/time64.h`, `drm/drm_managed.h`, `generated/xe_wa_oob.h`, `xe_force_wake.h`, `xe_device.h`, `xe_gt.h`, `xe_gt_idle.h`, `xe_gt_sysfs.h`.
- Detected declarations: `function pc_to_xe`, `function get_residency_ms`, `function xe_gt_idle_enable_pg`, `function xe_gt_idle_disable_pg`, `function force_wake_domains_show`, `function xe_gt_idle_pg_print`, `function name_show`, `function idle_status_show`, `function xe_gt_idle_residency_msec`, `function idle_residency_ms_show`.
- 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.