drivers/gpu/drm/xe/xe_device_sysfs.c
Source file repositories/reference/linux-study-clean/drivers/gpu/drm/xe/xe_device_sysfs.c
File Facts
- System
- Linux kernel
- Corpus path
drivers/gpu/drm/xe/xe_device_sysfs.c- Extension
.c- Size
- 9046 bytes
- Lines
- 290
- 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
linux/device.hlinux/kobject.hlinux/pci.hlinux/sysfs.hxe_device.hxe_device_sysfs.hxe_mmio.hxe_pcode_api.hxe_pcode.hxe_pm.h
Detected Declarations
function vram_d3cold_threshold_showfunction vram_d3cold_threshold_storefunction lb_fan_control_version_showfunction lb_voltage_regulator_version_showfunction late_bind_attr_is_visiblefunction trainingfunction auto_link_downgrade_status_showfunction xe_device_sysfs_init
Annotated Snippet
// SPDX-License-Identifier: MIT
/*
* Copyright © 2023 Intel Corporation
*/
#include <linux/device.h>
#include <linux/kobject.h>
#include <linux/pci.h>
#include <linux/sysfs.h>
#include "xe_device.h"
#include "xe_device_sysfs.h"
#include "xe_mmio.h"
#include "xe_pcode_api.h"
#include "xe_pcode.h"
#include "xe_pm.h"
/**
* DOC: Xe device sysfs
* Xe driver requires exposing certain tunable knobs controlled by user space for
* each graphics device. Considering this, we need to add sysfs attributes at device
* level granularity.
* These sysfs attributes will be available under pci device kobj directory.
*
* vram_d3cold_threshold - Report/change vram used threshold(in MB) below
* which vram save/restore is permissible during runtime D3cold entry/exit.
*
* lb_fan_control_version - Fan control version provisioned by late binding.
* Exposed only if supported by the device.
*
* lb_voltage_regulator_version - Voltage regulator version provisioned by late
* binding. Exposed only if supported by the device.
*/
static ssize_t
vram_d3cold_threshold_show(struct device *dev,
struct device_attribute *attr, char *buf)
{
struct pci_dev *pdev = to_pci_dev(dev);
struct xe_device *xe = pdev_to_xe_device(pdev);
return sysfs_emit(buf, "%d\n", xe->d3cold.vram_threshold);
}
static ssize_t
vram_d3cold_threshold_store(struct device *dev, struct device_attribute *attr,
const char *buff, size_t count)
{
struct pci_dev *pdev = to_pci_dev(dev);
struct xe_device *xe = pdev_to_xe_device(pdev);
u32 vram_d3cold_threshold;
int ret;
ret = kstrtou32(buff, 0, &vram_d3cold_threshold);
if (ret)
return ret;
drm_dbg(&xe->drm, "vram_d3cold_threshold: %u\n", vram_d3cold_threshold);
guard(xe_pm_runtime)(xe);
ret = xe_pm_set_vram_threshold(xe, vram_d3cold_threshold);
return ret ?: count;
}
static DEVICE_ATTR_RW(vram_d3cold_threshold);
static struct attribute *vram_attrs[] = {
&dev_attr_vram_d3cold_threshold.attr,
NULL
};
static const struct attribute_group vram_attr_group = {
.attrs = vram_attrs,
};
static ssize_t
lb_fan_control_version_show(struct device *dev, struct device_attribute *attr, char *buf)
{
struct xe_device *xe = pdev_to_xe_device(to_pci_dev(dev));
struct xe_tile *root = xe_device_get_root_tile(xe);
u32 cap = 0, ver_low = FAN_TABLE, ver_high = FAN_TABLE;
u16 major = 0, minor = 0, hotfix = 0, build = 0;
int ret;
guard(xe_pm_runtime)(xe);
ret = xe_pcode_read(root, PCODE_MBOX(PCODE_LATE_BINDING, GET_CAPABILITY_STATUS, 0),
&cap, NULL);
if (ret)
Annotation
- Immediate include surface: `linux/device.h`, `linux/kobject.h`, `linux/pci.h`, `linux/sysfs.h`, `xe_device.h`, `xe_device_sysfs.h`, `xe_mmio.h`, `xe_pcode_api.h`.
- Detected declarations: `function vram_d3cold_threshold_show`, `function vram_d3cold_threshold_store`, `function lb_fan_control_version_show`, `function lb_voltage_regulator_version_show`, `function late_bind_attr_is_visible`, `function training`, `function auto_link_downgrade_status_show`, `function xe_device_sysfs_init`.
- 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.