drivers/staging/media/atomisp/pci/hmm/hmm_bo.c
Source file repositories/reference/linux-study-clean/drivers/staging/media/atomisp/pci/hmm/hmm_bo.c
File Facts
- System
- Linux kernel
- Corpus path
drivers/staging/media/atomisp/pci/hmm/hmm_bo.c- Extension
.c- Size
- 25647 bytes
- Lines
- 1083
- Domain
- Driver Families
- Bucket
- drivers/staging
- 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
linux/kernel.hlinux/types.hlinux/gfp.hlinux/mm.hlinux/mm_types.hlinux/hugetlb.hlinux/highmem.hlinux/slab.hlinux/module.hlinux/moduleparam.hlinux/string.hlinux/list.hlinux/errno.hlinux/io.hasm/current.hlinux/sched/signal.hlinux/file.hasm/set_memory.hatomisp_internal.hhmm/hmm_common.hhmm/hmm_bo.h
Detected Declarations
function Copyrightfunction __bo_insert_to_free_rbtreefunction __bo_insert_to_alloc_rbtreefunction __bo_take_off_handlingfunction hmm_bo_device_initfunction hmm_bo_releasefunction hmm_bo_device_exitfunction hmm_bo_device_initedfunction hmm_bo_allocatedfunction free_pages_bulk_arrayfunction free_private_bo_pagesfunction alloc_private_pagesfunction alloc_pages_bulkfunction alloc_vmalloc_pagesfunction hmm_bo_alloc_pagesfunction hmm_bo_free_pagesfunction hmm_bo_page_allocatedfunction hmm_bo_bindfunction hmm_bo_unbindfunction hmm_bo_bindedfunction hmm_bo_flush_vmapfunction hmm_bo_vunmapfunction hmm_bo_reffunction kref_hmm_bo_releasefunction hmm_bo_unreffunction hmm_bo_vm_openfunction hmm_bo_vm_closefunction hmm_bo_mmap
Annotated Snippet
if (this->pgnr < pgnr) {
if (!this->node.rb_right)
return NULL;
ret_bo = __bo_search_and_remove_from_free_rbtree(
this->node.rb_right, pgnr);
} else {
ret_bo = __bo_search_and_remove_from_free_rbtree(
this->node.rb_left, pgnr);
}
if (!ret_bo) {
if (this->pgnr > pgnr)
goto remove_bo_and_return;
else
return NULL;
}
return ret_bo;
}
remove_bo_and_return:
/* NOTE: All nodes on free rbtree have a 'prev' that points to NULL.
* 1. check if 'this->next' is NULL:
* yes: erase 'this' node and rebalance rbtree, return 'this'.
*/
if (!this->next) {
rb_erase(&this->node, &this->bdev->free_rbtree);
return this;
}
/* NOTE: if 'this->next' is not NULL, always return 'this->next' bo.
* 2. check if 'this->next->next' is NULL:
* yes: change the related 'next/prev' pointer,
* return 'this->next' but the rbtree stays unchanged.
*/
temp_bo = this->next;
this->next = temp_bo->next;
if (temp_bo->next)
temp_bo->next->prev = this;
temp_bo->next = NULL;
temp_bo->prev = NULL;
return temp_bo;
}
static struct hmm_buffer_object *__bo_search_by_addr(struct rb_root *root,
ia_css_ptr start)
{
struct rb_node *n = root->rb_node;
struct hmm_buffer_object *bo;
do {
bo = rb_entry(n, struct hmm_buffer_object, node);
if (bo->start > start) {
if (!n->rb_left)
return NULL;
n = n->rb_left;
} else if (bo->start < start) {
if (!n->rb_right)
return NULL;
n = n->rb_right;
} else {
return bo;
}
} while (n);
return NULL;
}
static struct hmm_buffer_object *__bo_search_by_addr_in_range(
struct rb_root *root, unsigned int start)
{
struct rb_node *n = root->rb_node;
struct hmm_buffer_object *bo;
do {
bo = rb_entry(n, struct hmm_buffer_object, node);
if (bo->start > start) {
if (!n->rb_left)
return NULL;
n = n->rb_left;
} else {
if (bo->end > start)
return bo;
if (!n->rb_right)
return NULL;
n = n->rb_right;
}
} while (n);
return NULL;
}
Annotation
- Immediate include surface: `linux/kernel.h`, `linux/types.h`, `linux/gfp.h`, `linux/mm.h`, `linux/mm_types.h`, `linux/hugetlb.h`, `linux/highmem.h`, `linux/slab.h`.
- Detected declarations: `function Copyright`, `function __bo_insert_to_free_rbtree`, `function __bo_insert_to_alloc_rbtree`, `function __bo_take_off_handling`, `function hmm_bo_device_init`, `function hmm_bo_release`, `function hmm_bo_device_exit`, `function hmm_bo_device_inited`, `function hmm_bo_allocated`, `function free_pages_bulk_array`.
- Atlas domain: Driver Families / drivers/staging.
- 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.