drivers/gpu/drm/xe/xe_gt_freq.c
Source file repositories/reference/linux-study-clean/drivers/gpu/drm/xe/xe_gt_freq.c
File Facts
- System
- Linux kernel
- Corpus path
drivers/gpu/drm/xe/xe_gt_freq.c- Extension
.c- Size
- 7634 bytes
- Lines
- 298
- 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
xe_gt_freq.hlinux/kobject.hlinux/sysfs.hdrm/drm_managed.hdrm/drm_print.hxe_gt_sysfs.hxe_gt_throttle.hxe_gt_types.hxe_guc_pc.hxe_pm.h
Detected Declarations
function dev_to_pcfunction dev_to_xefunction act_freq_showfunction cur_freq_showfunction rp0_freq_showfunction rpe_freq_showfunction rpa_freq_showfunction rpn_freq_showfunction min_freq_showfunction min_freq_storefunction max_freq_showfunction max_freq_storefunction power_profile_showfunction power_profile_storefunction freq_finifunction xe_gt_freq_init
Annotated Snippet
// SPDX-License-Identifier: MIT
/*
* Copyright © 2023 Intel Corporation
*/
#include "xe_gt_freq.h"
#include <linux/kobject.h>
#include <linux/sysfs.h>
#include <drm/drm_managed.h>
#include <drm/drm_print.h>
#include "xe_gt_sysfs.h"
#include "xe_gt_throttle.h"
#include "xe_gt_types.h"
#include "xe_guc_pc.h"
#include "xe_pm.h"
/**
* DOC: Xe GT Frequency Management
*
* This component is responsible for the raw GT frequency management, including
* the sysfs API.
*
* Underneath, Xe enables GuC SLPC automated frequency management. GuC is then
* allowed to request PCODE any frequency between the Minimum and the Maximum
* selected by this component. Furthermore, it is important to highlight that
* PCODE is the ultimate decision maker of the actual running frequency, based
* on thermal and other running conditions.
*
* Xe's Freq provides a sysfs API for frequency management under
* ``<device>/tile#/gt#/freq0/`` directory.
*
* **Read-only** attributes:
*
* - ``act_freq``: The actual resolved frequency decided by PCODE.
* - ``cur_freq``: The current one requested by GuC PC to the PCODE.
* - ``rpn_freq``: The Render Performance (RP) N level, which is the minimal one.
* - ``rpa_freq``: The Render Performance (RP) A level, which is the achievable one.
* Calculated by PCODE at runtime based on multiple running conditions
* - ``rpe_freq``: The Render Performance (RP) E level, which is the efficient one.
* Calculated by PCODE at runtime based on multiple running conditions
* - ``rp0_freq``: The Render Performance (RP) 0 level, which is the maximum one.
*
* **Read-write** attributes:
*
* - ``min_freq``: Min frequency request.
* - ``max_freq``: Max frequency request.
* If max <= min, then freq_min becomes a fixed frequency
* request.
*/
static struct xe_guc_pc *
dev_to_pc(struct device *dev)
{
return &kobj_to_gt(dev->kobj.parent)->uc.guc.pc;
}
static struct xe_device *
dev_to_xe(struct device *dev)
{
return gt_to_xe(kobj_to_gt(dev->kobj.parent));
}
static ssize_t act_freq_show(struct kobject *kobj,
struct kobj_attribute *attr, char *buf)
{
struct device *dev = kobj_to_dev(kobj);
struct xe_guc_pc *pc = dev_to_pc(dev);
u32 freq;
guard(xe_pm_runtime)(dev_to_xe(dev));
freq = xe_guc_pc_get_act_freq(pc);
return sysfs_emit(buf, "%d\n", freq);
}
static struct kobj_attribute attr_act_freq = __ATTR_RO(act_freq);
static ssize_t cur_freq_show(struct kobject *kobj,
struct kobj_attribute *attr, char *buf)
{
struct device *dev = kobj_to_dev(kobj);
struct xe_guc_pc *pc = dev_to_pc(dev);
u32 freq;
ssize_t ret;
guard(xe_pm_runtime)(dev_to_xe(dev));
ret = xe_guc_pc_get_cur_freq(pc, &freq);
if (ret)
Annotation
- Immediate include surface: `xe_gt_freq.h`, `linux/kobject.h`, `linux/sysfs.h`, `drm/drm_managed.h`, `drm/drm_print.h`, `xe_gt_sysfs.h`, `xe_gt_throttle.h`, `xe_gt_types.h`.
- Detected declarations: `function dev_to_pc`, `function dev_to_xe`, `function act_freq_show`, `function cur_freq_show`, `function rp0_freq_show`, `function rpe_freq_show`, `function rpa_freq_show`, `function rpn_freq_show`, `function min_freq_show`, `function min_freq_store`.
- 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.