drivers/accel/amdxdna/aie.c
Source file repositories/reference/linux-study-clean/drivers/accel/amdxdna/aie.c
File Facts
- System
- Linux kernel
- Corpus path
drivers/accel/amdxdna/aie.c- Extension
.c- Size
- 4192 bytes
- Lines
- 168
- Domain
- Driver Families
- Bucket
- drivers/accel
- 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.
- Touches user memory; correctness depends on fault-safe copying and privilege boundary handling.
- Touches IRQ or DMA behavior; this matters for the representative real-device path.
- Defines or uses C structs; map object ownership, embedded links, reference counts, and lock ownership.
Dependency Surface
linux/errno.haie.hamdxdna_mailbox_helper.hamdxdna_mailbox.hamdxdna_pci_drv.h
Detected Declarations
function Copyrightfunction aie_destroy_channfunction aie_send_mgmt_msg_waitfunction aie_check_protocolfunction amdxdna_update_vbnvfunction amdxdna_vbnv_initfunction amdxdna_get_metadatafunction amdxdna_free_msg_buffer
Annotated Snippet
if (tbl[i].revision == rev) {
xdna->vbnv = tbl[i].vbnv;
break;
}
}
}
void amdxdna_vbnv_init(struct amdxdna_dev *xdna)
{
const struct amdxdna_dev_info *info = xdna->dev_info;
u32 rev;
xdna->vbnv = info->default_vbnv;
if (!info->ops->get_dev_revision || !info->rev_vbnv_tbl)
return;
if (info->ops->get_dev_revision(xdna, &rev))
return;
amdxdna_update_vbnv(xdna, info->rev_vbnv_tbl, rev);
}
int amdxdna_get_metadata(struct aie_device *aie,
struct amdxdna_client *client,
struct amdxdna_drm_get_info *args)
{
int ret = 0;
u32 buf_sz;
buf_sz = min(args->buffer_size, sizeof(aie->metadata));
if (copy_to_user(u64_to_user_ptr(args->buffer), &aie->metadata, buf_sz))
ret = -EFAULT;
return ret;
}
void *amdxdna_alloc_msg_buffer(struct amdxdna_dev *xdna, u32 *size,
dma_addr_t *dma_addr)
{
void *vaddr;
int order;
*size = max_t(u32, *size, SZ_8K);
order = get_order(*size);
if (order > MAX_PAGE_ORDER)
return ERR_PTR(-EINVAL);
*size = PAGE_SIZE << order;
if (amdxdna_iova_on(xdna))
return amdxdna_iommu_alloc(xdna, *size, dma_addr);
vaddr = dma_alloc_noncoherent(xdna->ddev.dev, *size, dma_addr,
DMA_FROM_DEVICE, GFP_KERNEL);
if (!vaddr)
return ERR_PTR(-ENOMEM);
return vaddr;
}
void amdxdna_free_msg_buffer(struct amdxdna_dev *xdna, size_t size,
void *cpu_addr, dma_addr_t dma_addr)
{
if (amdxdna_iova_on(xdna)) {
amdxdna_iommu_free(xdna, size, cpu_addr, dma_addr);
return;
}
dma_free_noncoherent(xdna->ddev.dev, size, cpu_addr, dma_addr, DMA_FROM_DEVICE);
}
Annotation
- Immediate include surface: `linux/errno.h`, `aie.h`, `amdxdna_mailbox_helper.h`, `amdxdna_mailbox.h`, `amdxdna_pci_drv.h`.
- Detected declarations: `function Copyright`, `function aie_destroy_chann`, `function aie_send_mgmt_msg_wait`, `function aie_check_protocol`, `function amdxdna_update_vbnv`, `function amdxdna_vbnv_init`, `function amdxdna_get_metadata`, `function amdxdna_free_msg_buffer`.
- Atlas domain: Driver Families / drivers/accel.
- Implementation status: source implementation candidate.
- This snippet crosses the user/kernel memory boundary; validate fault handling and access checks before translating the pattern.
- IRQ or DMA behavior appears here, which is relevant to the selected PCIe/NVMe device path.
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.