drivers/platform/x86/amd/x3d_vcache.c
Source file repositories/reference/linux-study-clean/drivers/platform/x86/amd/x3d_vcache.c
File Facts
- System
- Linux kernel
- Corpus path
drivers/platform/x86/amd/x3d_vcache.c- Extension
.c- Size
- 4158 bytes
- Lines
- 177
- Domain
- Driver Families
- Bucket
- drivers/platform
- 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.
- 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
linux/acpi.hlinux/array_size.hlinux/device.hlinux/errno.hlinux/module.hlinux/mutex.hlinux/platform_device.hlinux/pm.hlinux/sysfs.hlinux/uuid.h
Detected Declarations
struct amd_x3d_devenum amd_x3d_mode_typefunction amd_x3d_get_modefunction amd_x3d_mode_switchfunction amd_x3d_mode_storefunction amd_x3d_mode_showfunction amd_x3d_resume_handlerfunction amd_x3d_probe
Annotated Snippet
struct amd_x3d_dev {
struct device *dev;
acpi_handle ahandle;
/* To protect x3d mode setting */
struct mutex lock;
enum amd_x3d_mode_type curr_mode;
};
static int amd_x3d_get_mode(struct amd_x3d_dev *data)
{
guard(mutex)(&data->lock);
return data->curr_mode;
}
static int amd_x3d_mode_switch(struct amd_x3d_dev *data, int new_state)
{
union acpi_object *out, argv;
guard(mutex)(&data->lock);
argv.type = ACPI_TYPE_INTEGER;
argv.integer.value = new_state;
out = acpi_evaluate_dsm(data->ahandle, &x3d_guid, DSM_REVISION_ID,
DSM_SET_X3D_MODE, &argv);
if (!out) {
dev_err(data->dev, "failed to evaluate _DSM\n");
return -EINVAL;
}
data->curr_mode = new_state;
kfree(out);
return 0;
}
static ssize_t amd_x3d_mode_store(struct device *dev, struct device_attribute *attr,
const char *buf, size_t count)
{
struct amd_x3d_dev *data = dev_get_drvdata(dev);
int ret;
ret = sysfs_match_string(amd_x3d_mode_strings, buf);
if (ret < 0)
return ret;
ret = amd_x3d_mode_switch(data, ret);
if (ret < 0)
return ret;
return count;
}
static ssize_t amd_x3d_mode_show(struct device *dev, struct device_attribute *attr, char *buf)
{
struct amd_x3d_dev *data = dev_get_drvdata(dev);
int mode = amd_x3d_get_mode(data);
return sysfs_emit(buf, "%s\n", amd_x3d_mode_strings[mode]);
}
static DEVICE_ATTR_RW(amd_x3d_mode);
static struct attribute *amd_x3d_attrs[] = {
&dev_attr_amd_x3d_mode.attr,
NULL
};
ATTRIBUTE_GROUPS(amd_x3d);
static int amd_x3d_resume_handler(struct device *dev)
{
struct amd_x3d_dev *data = dev_get_drvdata(dev);
int ret = amd_x3d_get_mode(data);
return amd_x3d_mode_switch(data, ret);
}
static DEFINE_SIMPLE_DEV_PM_OPS(amd_x3d_pm, NULL, amd_x3d_resume_handler);
static const struct acpi_device_id amd_x3d_acpi_ids[] = {
{"AMDI0101"},
{ },
};
MODULE_DEVICE_TABLE(acpi, amd_x3d_acpi_ids);
static int amd_x3d_probe(struct platform_device *pdev)
{
struct amd_x3d_dev *data;
acpi_handle handle;
int ret;
Annotation
- Immediate include surface: `linux/acpi.h`, `linux/array_size.h`, `linux/device.h`, `linux/errno.h`, `linux/module.h`, `linux/mutex.h`, `linux/platform_device.h`, `linux/pm.h`.
- Detected declarations: `struct amd_x3d_dev`, `enum amd_x3d_mode_type`, `function amd_x3d_get_mode`, `function amd_x3d_mode_switch`, `function amd_x3d_mode_store`, `function amd_x3d_mode_show`, `function amd_x3d_resume_handler`, `function amd_x3d_probe`.
- Atlas domain: Driver Families / drivers/platform.
- 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.