drivers/platform/x86/amd/hsmp/acpi.c
Source file repositories/reference/linux-study-clean/drivers/platform/x86/amd/hsmp/acpi.c
File Facts
- System
- Linux kernel
- Corpus path
drivers/platform/x86/amd/hsmp/acpi.c- Extension
.c- Size
- 17489 bytes
- Lines
- 648
- 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.
- Defines or uses C structs; map object ownership, embedded links, reference counts, and lock ownership.
Dependency Surface
asm/amd/hsmp.hlinux/acpi.hlinux/array_size.hlinux/bits.hlinux/bitfield.hlinux/device.hlinux/dev_printk.hlinux/ioport.hlinux/kstrtox.hlinux/module.hlinux/platform_device.hlinux/sysfs.hlinux/topology.hlinux/uuid.huapi/asm-generic/errno-base.hhsmp.h
Detected Declarations
struct hsmp_sys_attrfunction amd_hsmp_acpi_rdwrfunction is_acpi_hsmp_uuidfunction hsmp_get_uidfunction hsmp_resourcefunction hsmp_read_acpi_dsdfunction hsmp_read_acpi_crsfunction hsmp_parse_acpi_tablefunction hsmp_metric_tbl_acpi_readfunction hsmp_is_sock_attr_visiblefunction hsmp_is_sock_dev_attr_visiblefunction hsmp_msg_resp32_showfunction hsmp_ddr_max_bw_showfunction hsmp_ddr_util_bw_showfunction hsmp_ddr_util_bw_perc_showfunction hsmp_msg_fw_ver_showfunction hsmp_fclk_showfunction hsmp_mclk_showfunction hsmp_clk_fmax_showfunction hsmp_clk_fmin_showfunction hsmp_freq_limit_showfunction hsmp_freq_limit_source_showfunction init_acpifunction hsmp_acpi_probefunction hsmp_acpi_remove
Annotated Snippet
struct hsmp_sys_attr {
struct device_attribute dattr;
u32 msg_id;
};
static int amd_hsmp_acpi_rdwr(struct hsmp_socket *sock, u32 offset,
u32 *value, bool write)
{
if (write)
iowrite32(*value, sock->virt_base_addr + offset);
else
*value = ioread32(sock->virt_base_addr + offset);
return 0;
}
/* This is the UUID used for HSMP */
static const guid_t acpi_hsmp_uuid = GUID_INIT(0xb74d619d, 0x5707, 0x48bd,
0xa6, 0x9f, 0x4e, 0xa2,
0x87, 0x1f, 0xc2, 0xf6);
static inline bool is_acpi_hsmp_uuid(union acpi_object *obj)
{
if (obj->type == ACPI_TYPE_BUFFER && obj->buffer.length == UUID_SIZE)
return guid_equal((guid_t *)obj->buffer.pointer, &acpi_hsmp_uuid);
return false;
}
static inline int hsmp_get_uid(struct device *dev, u16 *sock_ind)
{
char *uid;
/*
* UID (ID00, ID01..IDXX) is used for differentiating sockets,
* read it and strip the "ID" part of it and convert the remaining
* bytes to integer.
*/
uid = acpi_device_uid(ACPI_COMPANION(dev));
return kstrtou16(uid + 2, 10, sock_ind);
}
static acpi_status hsmp_resource(struct acpi_resource *res, void *data)
{
struct hsmp_socket *sock = data;
struct resource r;
switch (res->type) {
case ACPI_RESOURCE_TYPE_FIXED_MEMORY32:
if (!acpi_dev_resource_memory(res, &r))
return AE_ERROR;
if (!r.start || r.end < r.start || !(r.flags & IORESOURCE_MEM_WRITEABLE))
return AE_ERROR;
sock->mbinfo.base_addr = r.start;
sock->mbinfo.size = resource_size(&r);
break;
case ACPI_RESOURCE_TYPE_END_TAG:
break;
default:
return AE_ERROR;
}
return AE_OK;
}
static int hsmp_read_acpi_dsd(struct hsmp_socket *sock)
{
struct acpi_buffer buf = { ACPI_ALLOCATE_BUFFER, NULL };
union acpi_object *guid, *mailbox_package;
union acpi_object *dsd;
acpi_status status;
int ret = 0;
int j;
status = acpi_evaluate_object_typed(ACPI_HANDLE(sock->dev), "_DSD", NULL,
&buf, ACPI_TYPE_PACKAGE);
if (ACPI_FAILURE(status)) {
dev_err(sock->dev, "Failed to read mailbox reg offsets from DSD table, err: %s\n",
acpi_format_exception(status));
return -ENODEV;
}
dsd = buf.pointer;
/* HSMP _DSD property should contain 2 objects.
* 1. guid which is an acpi object of type ACPI_TYPE_BUFFER
* 2. mailbox which is an acpi object of type ACPI_TYPE_PACKAGE
* This mailbox object contains 3 more acpi objects of type
* ACPI_TYPE_PACKAGE for holding msgid, msgresp, msgarg offsets
Annotation
- Immediate include surface: `asm/amd/hsmp.h`, `linux/acpi.h`, `linux/array_size.h`, `linux/bits.h`, `linux/bitfield.h`, `linux/device.h`, `linux/dev_printk.h`, `linux/ioport.h`.
- Detected declarations: `struct hsmp_sys_attr`, `function amd_hsmp_acpi_rdwr`, `function is_acpi_hsmp_uuid`, `function hsmp_get_uid`, `function hsmp_resource`, `function hsmp_read_acpi_dsd`, `function hsmp_read_acpi_crs`, `function hsmp_parse_acpi_table`, `function hsmp_metric_tbl_acpi_read`, `function hsmp_is_sock_attr_visible`.
- 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.