drivers/accel/amdxdna/aie4_ctx.c
Source file repositories/reference/linux-study-clean/drivers/accel/amdxdna/aie4_ctx.c
File Facts
- System
- Linux kernel
- Corpus path
drivers/accel/amdxdna/aie4_ctx.c- Extension
.c- Size
- 8603 bytes
- Lines
- 334
- 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.
- Uses kernel synchronization; read lock ordering, sleepability, and interrupt context assumptions before translating.
- Touches IRQ or DMA behavior; this matters for the representative real-device path.
- 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
drm/amdxdna_accel.hdrm/drm_device.hdrm/drm_gem.hdrm/drm_gem_shmem_helper.hdrm/drm_print.hdrm/gpu_scheduler.hlinux/types.haie.haie4_host_queue.haie4_msg_priv.haie4_pci.hamdxdna_ctx.hamdxdna_gem.hamdxdna_mailbox.hamdxdna_mailbox_helper.hamdxdna_pci_drv.h
Detected Declarations
function Copyrightfunction cert_comp_releasefunction aie4_put_cert_compfunction aie4_msg_destroy_contextfunction aie4_hwctx_createfunction aie4_hwctx_destroyfunction aie4_hwctx_umq_finifunction aie4_hwctx_umq_initfunction aie4_hwctx_initfunction aie4_hwctx_finifunction valid_queue_indexfunction get_read_indexfunction check_cmd_donefunction aie4_cmd_waitfunction aie4_hwctx_valid_doorbell
Annotated Snippet
if (!valid_queue_index(ri, wi, CTX_MAX_CMDS)) {
XDNA_ERR(xdna, "Invalid index after retry, ri %llu, wi %llu", ri, wi);
ri = 0;
}
}
return ri;
}
static inline bool check_cmd_done(struct amdxdna_hwctx *hwctx, u64 seq)
{
u64 read_idx = get_read_index(hwctx);
return read_idx > seq;
}
int aie4_cmd_wait(struct amdxdna_hwctx *hwctx, u64 seq, u32 timeout)
{
unsigned long wait_jifs = MAX_SCHEDULE_TIMEOUT;
struct amdxdna_hwctx_priv *priv = hwctx->priv;
struct cert_comp *cert_comp = priv->cert_comp;
long ret;
if (timeout)
wait_jifs = msecs_to_jiffies(timeout);
ret = wait_event_interruptible_timeout(cert_comp->waitq,
(check_cmd_done(hwctx, seq)),
wait_jifs);
if (!ret)
ret = -ETIME;
return ret <= 0 ? ret : 0;
}
int aie4_hwctx_valid_doorbell(struct amdxdna_client *client, u32 vm_pgoff)
{
struct amdxdna_hwctx *hwctx;
unsigned long hwctx_id;
int idx;
idx = srcu_read_lock(&client->hwctx_srcu);
amdxdna_for_each_hwctx(client, hwctx_id, hwctx) {
if (vm_pgoff == (hwctx->doorbell_offset >> PAGE_SHIFT)) {
srcu_read_unlock(&client->hwctx_srcu, idx);
return 1;
}
}
srcu_read_unlock(&client->hwctx_srcu, idx);
return 0;
}
Annotation
- Immediate include surface: `drm/amdxdna_accel.h`, `drm/drm_device.h`, `drm/drm_gem.h`, `drm/drm_gem_shmem_helper.h`, `drm/drm_print.h`, `drm/gpu_scheduler.h`, `linux/types.h`, `aie.h`.
- Detected declarations: `function Copyright`, `function cert_comp_release`, `function aie4_put_cert_comp`, `function aie4_msg_destroy_context`, `function aie4_hwctx_create`, `function aie4_hwctx_destroy`, `function aie4_hwctx_umq_fini`, `function aie4_hwctx_umq_init`, `function aie4_hwctx_init`, `function aie4_hwctx_fini`.
- Atlas domain: Driver Families / drivers/accel.
- Implementation status: source implementation candidate.
- Synchronization appears in or near this file; preserve lock ordering, sleepability, and interrupt-context constraints.
- 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.