drivers/accel/habanalabs/common/memory_mgr.c
Source file repositories/reference/linux-study-clean/drivers/accel/habanalabs/common/memory_mgr.c
File Facts
- System
- Linux kernel
- Corpus path
drivers/accel/habanalabs/common/memory_mgr.c- Extension
.c- Size
- 9766 bytes
- Lines
- 388
- 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.
- 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
habanalabs.h
Detected Declarations
function usefunction hl_mmap_mem_buf_releasefunction hl_mmap_mem_buf_remove_idr_lockedfunction hl_mmap_mem_buf_putfunction hl_mmap_mem_buf_put_handlefunction hl_mmap_mem_buf_allocfunction hl_mmap_mem_buf_vm_closefunction hl_mem_mgr_mmapfunction hl_mem_mgr_initfunction hl_mem_mgr_fini_stats_resetfunction hl_mem_mgr_fini_stats_incfunction hl_mem_mgr_finifunction idr_for_each_entryfunction hl_mem_mgr_idr_destroy
Annotated Snippet
if (hl_mmap_mem_buf_put(buf) != 1) {
dev_err(mmg->dev,
"%s: Buff handle %u for CTX is still alive\n",
topic, id);
hl_mem_mgr_fini_stats_inc(mem_id, stats);
}
}
}
/**
* hl_mem_mgr_idr_destroy() - destroy memory manager IDR.
* @mmg: parent unified memory manager
*
* Destroy the memory manager IDR.
* Shall be called when IDR is empty and no memory buffers are in use.
*/
void hl_mem_mgr_idr_destroy(struct hl_mem_mgr *mmg)
{
if (!idr_is_empty(&mmg->handles))
dev_crit(mmg->dev, "memory manager IDR is destroyed while it is not empty!\n");
idr_destroy(&mmg->handles);
}
Annotation
- Immediate include surface: `habanalabs.h`.
- Detected declarations: `function use`, `function hl_mmap_mem_buf_release`, `function hl_mmap_mem_buf_remove_idr_locked`, `function hl_mmap_mem_buf_put`, `function hl_mmap_mem_buf_put_handle`, `function hl_mmap_mem_buf_alloc`, `function hl_mmap_mem_buf_vm_close`, `function hl_mem_mgr_mmap`, `function hl_mem_mgr_init`, `function hl_mem_mgr_fini_stats_reset`.
- 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.
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.