drivers/gpu/drm/amd/amdgpu/amdgpu_xcp.c
Source file repositories/reference/linux-study-clean/drivers/gpu/drm/amd/amdgpu/amdgpu_xcp.c
File Facts
- System
- Linux kernel
- Corpus path
drivers/gpu/drm/amd/amdgpu/amdgpu_xcp.c- Extension
.c- Size
- 28161 bytes
- Lines
- 1110
- 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.
- Allocates kernel memory; connect allocation flags and lifetime to context constraints.
- Defines or uses C structs; map object ownership, embedded links, reference counts, and lock ownership.
Dependency Surface
amdgpu.hamdgpu_xcp.hamdgpu_drv.hdrm/drm_drv.h../amdxcp/amdgpu_xcp_drv.h
Detected Declarations
struct amdgpu_xcp_res_sysfs_attributefunction __amdgpu_xcp_runfunction amdgpu_xcp_run_transitionfunction amdgpu_xcp_prepare_suspendfunction amdgpu_xcp_suspendfunction amdgpu_xcp_prepare_resumefunction amdgpu_xcp_resumefunction __amdgpu_xcp_add_blockfunction __amdgpu_xcp_set_unique_idfunction amdgpu_xcp_initfunction __amdgpu_xcp_switch_partition_modefunction amdgpu_xcp_switch_partition_modefunction amdgpu_xcp_restore_partition_modefunction __amdgpu_xcp_is_cached_mode_validfunction amdgpu_xcp_query_partition_modefunction amdgpu_xcp_dev_allocfunction amdgpu_xcp_mgr_initfunction amdgpu_xcp_get_partitionfunction amdgpu_xcp_get_inst_detailsfunction amdgpu_xcp_dev_registerfunction amdgpu_xcp_dev_unplugfunction amdgpu_xcp_open_devicefunction amdgpu_xcp_release_schedfunction amdgpu_xcp_select_schedsfunction amdgpu_set_xcp_idfunction amdgpu_xcp_gpu_sched_updatefunction amdgpu_xcp_sched_list_updatefunction amdgpu_xcp_update_partition_sched_listfunction amdgpu_xcp_update_supported_modesfunction amdgpu_xcp_pre_partition_switchfunction amdgpu_xcp_post_partition_switchfunction xcp_cfg_res_sysfs_attr_showfunction amdgpu_xcp_get_res_infofunction supported_xcp_configs_showfunction for_each_instfunction supported_nps_configs_showfunction for_each_instfunction xcp_config_showfunction xcp_config_storefunction xcp_cfg_sysfs_releasefunction amdgpu_xcp_cfg_sysfs_initfunction amdgpu_xcp_cfg_sysfs_finifunction xcp_metrics_showfunction amdgpu_xcp_attrs_is_visiblefunction amdgpu_xcp_sysfs_entries_finifunction amdgpu_xcp_sysfs_entries_initfunction amdgpu_xcp_sysfs_entries_updatefunction amdgpu_xcp_sysfs_init
Annotated Snippet
struct amdgpu_xcp_res_sysfs_attribute {
struct attribute attr;
ssize_t (*show)(struct amdgpu_xcp_res_details *xcp_res, char *buf);
};
#define XCP_CFG_SYSFS_RES_ATTR(_name) \
struct amdgpu_xcp_res_sysfs_attribute xcp_res_sysfs_attr_##_name = { \
.attr = { .name = __stringify(_name), .mode = 0400 }, \
.show = amdgpu_xcp_res_sysfs_##_name##_show, \
}
XCP_CFG_SYSFS_RES_ATTR_SHOW(num_inst)
XCP_CFG_SYSFS_RES_ATTR(num_inst);
XCP_CFG_SYSFS_RES_ATTR_SHOW(num_shared)
XCP_CFG_SYSFS_RES_ATTR(num_shared);
#define XCP_CFG_SYSFS_RES_ATTR_PTR(_name) xcp_res_sysfs_attr_##_name.attr
static struct attribute *xcp_cfg_res_sysfs_attrs[] = {
&XCP_CFG_SYSFS_RES_ATTR_PTR(num_inst),
&XCP_CFG_SYSFS_RES_ATTR_PTR(num_shared), NULL
};
static const char *xcp_desc[] = {
[AMDGPU_SPX_PARTITION_MODE] = "SPX",
[AMDGPU_DPX_PARTITION_MODE] = "DPX",
[AMDGPU_TPX_PARTITION_MODE] = "TPX",
[AMDGPU_QPX_PARTITION_MODE] = "QPX",
[AMDGPU_CPX_PARTITION_MODE] = "CPX",
};
static const char *nps_desc[] = {
[UNKNOWN_MEMORY_PARTITION_MODE] = "UNKNOWN",
[AMDGPU_NPS1_PARTITION_MODE] = "NPS1",
[AMDGPU_NPS2_PARTITION_MODE] = "NPS2",
[AMDGPU_NPS3_PARTITION_MODE] = "NPS3",
[AMDGPU_NPS4_PARTITION_MODE] = "NPS4",
[AMDGPU_NPS6_PARTITION_MODE] = "NPS6",
[AMDGPU_NPS8_PARTITION_MODE] = "NPS8",
};
ATTRIBUTE_GROUPS(xcp_cfg_res_sysfs);
#define to_xcp_attr(x) \
container_of(x, struct amdgpu_xcp_res_sysfs_attribute, attr)
#define to_xcp_res(x) container_of(x, struct amdgpu_xcp_res_details, kobj)
static ssize_t xcp_cfg_res_sysfs_attr_show(struct kobject *kobj,
struct attribute *attr, char *buf)
{
struct amdgpu_xcp_res_sysfs_attribute *attribute;
struct amdgpu_xcp_res_details *xcp_res;
attribute = to_xcp_attr(attr);
xcp_res = to_xcp_res(kobj);
if (!attribute->show)
return -EIO;
return attribute->show(xcp_res, buf);
}
static const struct sysfs_ops xcp_cfg_res_sysfs_ops = {
.show = xcp_cfg_res_sysfs_attr_show,
};
static const struct kobj_type xcp_cfg_res_sysfs_ktype = {
.sysfs_ops = &xcp_cfg_res_sysfs_ops,
.default_groups = xcp_cfg_res_sysfs_groups,
};
const char *xcp_res_names[] = {
[AMDGPU_XCP_RES_XCC] = "xcc",
[AMDGPU_XCP_RES_DMA] = "dma",
[AMDGPU_XCP_RES_DEC] = "dec",
[AMDGPU_XCP_RES_JPEG] = "jpeg",
};
static int amdgpu_xcp_get_res_info(struct amdgpu_xcp_mgr *xcp_mgr,
int mode,
struct amdgpu_xcp_cfg *xcp_cfg)
{
if (xcp_mgr->funcs && xcp_mgr->funcs->get_xcp_res_info)
return xcp_mgr->funcs->get_xcp_res_info(xcp_mgr, mode, xcp_cfg);
return -EOPNOTSUPP;
}
#define to_xcp_cfg(x) container_of(x, struct amdgpu_xcp_cfg, kobj)
static ssize_t supported_xcp_configs_show(struct kobject *kobj,
Annotation
- Immediate include surface: `amdgpu.h`, `amdgpu_xcp.h`, `amdgpu_drv.h`, `drm/drm_drv.h`, `../amdxcp/amdgpu_xcp_drv.h`.
- Detected declarations: `struct amdgpu_xcp_res_sysfs_attribute`, `function __amdgpu_xcp_run`, `function amdgpu_xcp_run_transition`, `function amdgpu_xcp_prepare_suspend`, `function amdgpu_xcp_suspend`, `function amdgpu_xcp_prepare_resume`, `function amdgpu_xcp_resume`, `function __amdgpu_xcp_add_block`, `function __amdgpu_xcp_set_unique_id`, `function amdgpu_xcp_init`.
- 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.