drivers/gpu/drm/i915/gt/intel_gt_sysfs_pm.c
Source file repositories/reference/linux-study-clean/drivers/gpu/drm/i915/gt/intel_gt_sysfs_pm.c
File Facts
- System
- Linux kernel
- Corpus path
drivers/gpu/drm/i915/gt/intel_gt_sysfs_pm.c- Extension
.c- Size
- 26574 bytes
- Lines
- 933
- 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_device.hlinux/sysfs.hlinux/printk.hdrm/intel/intel_pcode_regs.hi915_drv.hi915_reg.hi915_sysfs.hintel_gt.hintel_gt_print.hintel_gt_regs.hintel_gt_sysfs.hintel_gt_sysfs_pm.hintel_pcode.hintel_rc6.hintel_rps.h
Detected Declarations
struct intel_gt_bool_throttle_attrenum intel_gt_sysfs_opfunction sysfs_gt_attribute_w_funcfunction for_each_gtfunction sysfs_gt_attribute_r_funcfunction for_each_gtfunction get_residencyfunction rc6_enable_showfunction rc6_enable_dev_showfunction __rc6_residency_ms_showfunction __rc6p_residency_ms_showfunction __rc6pp_residency_ms_showfunction __media_rc6_residency_ms_showfunction __intel_gt_sysfs_create_groupfunction intel_sysfs_rc6_initfunction is_visiblefunction __act_freq_mhz_showfunction __cur_freq_mhz_showfunction __boost_freq_mhz_showfunction __boost_freq_mhz_storefunction __RP0_freq_mhz_showfunction __RPn_freq_mhz_showfunction __RP1_freq_mhz_showfunction __max_freq_mhz_showfunction __set_max_freqfunction __min_freq_mhz_showfunction __set_min_freqfunction __vlv_rpe_freq_mhz_showfunction punit_req_freq_mhz_showfunction slpc_ignore_eff_freq_showfunction slpc_ignore_eff_freq_storefunction slpc_power_profile_showfunction slpc_power_profile_storefunction throttle_reason_bool_showfunction multipliersfunction media_ratio_mode_to_factorfunction media_freq_factor_showfunction media_freq_factor_storefunction media_RP0_freq_mhz_showfunction media_RPn_freq_mhz_showfunction rps_up_threshold_pct_showfunction rps_up_threshold_pct_storefunction rps_down_threshold_pct_showfunction rps_down_threshold_pct_storefunction default_min_freq_mhz_showfunction default_max_freq_mhz_showfunction default_rps_up_threshold_pct_showfunction default_rps_down_threshold_pct_show
Annotated Snippet
struct intel_gt_bool_throttle_attr {
struct attribute attr;
ssize_t (*show)(struct kobject *kobj, struct kobj_attribute *attr,
char *buf);
i915_reg_t (*reg32)(struct intel_gt *gt);
u32 mask;
};
static ssize_t throttle_reason_bool_show(struct kobject *kobj,
struct kobj_attribute *attr,
char *buff)
{
struct intel_gt *gt = intel_gt_sysfs_get_drvdata(kobj, attr->attr.name);
struct intel_gt_bool_throttle_attr *t_attr =
(struct intel_gt_bool_throttle_attr *) attr;
bool val = rps_read_mask_mmio(>->rps, t_attr->reg32(gt), t_attr->mask);
return sysfs_emit(buff, "%u\n", val);
}
#define INTEL_GT_RPS_BOOL_ATTR_RO(sysfs_func__, mask__) \
struct intel_gt_bool_throttle_attr attr_##sysfs_func__ = { \
.attr = { .name = __stringify(sysfs_func__), .mode = 0444 }, \
.show = throttle_reason_bool_show, \
.reg32 = intel_gt_perf_limit_reasons_reg, \
.mask = mask__, \
}
INTEL_GT_ATTR_RO(punit_req_freq_mhz);
static INTEL_GT_RPS_BOOL_ATTR_RO(throttle_reason_status, GT0_PERF_LIMIT_REASONS_MASK);
static INTEL_GT_RPS_BOOL_ATTR_RO(throttle_reason_pl1, POWER_LIMIT_1_MASK);
static INTEL_GT_RPS_BOOL_ATTR_RO(throttle_reason_pl2, POWER_LIMIT_2_MASK);
static INTEL_GT_RPS_BOOL_ATTR_RO(throttle_reason_pl4, POWER_LIMIT_4_MASK);
static INTEL_GT_RPS_BOOL_ATTR_RO(throttle_reason_thermal, THERMAL_LIMIT_MASK);
static INTEL_GT_RPS_BOOL_ATTR_RO(throttle_reason_prochot, PROCHOT_MASK);
static INTEL_GT_RPS_BOOL_ATTR_RO(throttle_reason_ratl, RATL_MASK);
static INTEL_GT_RPS_BOOL_ATTR_RO(throttle_reason_vr_thermalert, VR_THERMALERT_MASK);
static INTEL_GT_RPS_BOOL_ATTR_RO(throttle_reason_vr_tdc, VR_TDC_MASK);
static const struct attribute *throttle_reason_attrs[] = {
&attr_throttle_reason_status.attr,
&attr_throttle_reason_pl1.attr,
&attr_throttle_reason_pl2.attr,
&attr_throttle_reason_pl4.attr,
&attr_throttle_reason_thermal.attr,
&attr_throttle_reason_prochot.attr,
&attr_throttle_reason_ratl.attr,
&attr_throttle_reason_vr_thermalert.attr,
&attr_throttle_reason_vr_tdc.attr,
NULL
};
/*
* Scaling for multipliers (aka frequency factors).
* The format of the value in the register is u8.8.
*
* The presentation to userspace is inspired by the perf event framework.
* See:
* Documentation/ABI/testing/sysfs-bus-event_source-devices-events
* for description of:
* /sys/bus/event_source/devices/<pmu>/events/<event>.scale
*
* Summary: Expose two sysfs files for each multiplier.
*
* 1. File <attr> contains a raw hardware value.
* 2. File <attr>.scale contains the multiplicative scale factor to be
* used by userspace to compute the actual value.
*
* So userspace knows that to get the frequency_factor it multiplies the
* provided value by the specified scale factor and vice-versa.
*
* That way there is no precision loss in the kernel interface and API
* is future proof should one day the hardware register change to u16.u16,
* on some platform. (Or any other fixed point representation.)
*
* Example:
* File <attr> contains the value 2.5, represented as u8.8 0x0280, which
* is comprised of:
* - an integer part of 2
* - a fractional part of 0x80 (representing 0x80 / 2^8 == 0x80 / 256).
* File <attr>.scale contains a string representation of floating point
* value 0.00390625 (which is (1 / 256)).
* Userspace computes the actual value:
* 0x0280 * 0.00390625 -> 2.5
* or converts an actual value to the value to be written into <attr>:
* 2.5 / 0.00390625 -> 0x0280
*/
#define U8_8_VAL_MASK 0xffff
#define U8_8_SCALE_TO_VALUE "0.00390625"
Annotation
- Immediate include surface: `drm/drm_device.h`, `linux/sysfs.h`, `linux/printk.h`, `drm/intel/intel_pcode_regs.h`, `i915_drv.h`, `i915_reg.h`, `i915_sysfs.h`, `intel_gt.h`.
- Detected declarations: `struct intel_gt_bool_throttle_attr`, `enum intel_gt_sysfs_op`, `function sysfs_gt_attribute_w_func`, `function for_each_gt`, `function sysfs_gt_attribute_r_func`, `function for_each_gt`, `function get_residency`, `function rc6_enable_show`, `function rc6_enable_dev_show`, `function __rc6_residency_ms_show`.
- 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.