drivers/staging/media/atomisp/pci/hmm/hmm.c
Source file repositories/reference/linux-study-clean/drivers/staging/media/atomisp/pci/hmm/hmm.c
File Facts
- System
- Linux kernel
- Corpus path
drivers/staging/media/atomisp/pci/hmm/hmm.c- Extension
.c- Size
- 10260 bytes
- Lines
- 500
- 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.
- 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/mm.hlinux/highmem.hlinux/io.hlinux/sysfs.hhmm/hmm.hhmm/hmm_bo.hatomisp_internal.hasm/cacheflush.hmmu/isp_mmu.hmmu/sh_mmu_mrfld.h
Detected Declarations
function hmm_initfunction hmm_cleanupfunction __hmm_allocfunction hmm_allocfunction hmm_create_from_vmalloc_buffunction hmm_freefunction hmm_check_bofunction load_and_flush_by_kmapfunction load_and_flushfunction hmm_loadfunction hmm_flushfunction hmm_storefunction hmm_setfunction hmm_virt_to_physfunction hmm_mmapfunction hmm_flush_vmapfunction hmm_vunmap
Annotated Snippet
if ((bytes + offset) >= PAGE_SIZE) {
len = PAGE_SIZE - offset;
bytes -= len;
} else {
len = bytes;
bytes = 0;
}
virt += len; /* update virt for next loop */
if (des) {
memcpy(des, src, len);
des += len;
}
clflush_cache_range(src, len);
kunmap_local(src);
}
return 0;
}
/* Read function in ISP memory management */
static int load_and_flush(ia_css_ptr virt, void *data, unsigned int bytes)
{
struct hmm_buffer_object *bo;
int ret;
bo = hmm_bo_device_search_in_range(&bo_device, virt);
ret = hmm_check_bo(bo, virt);
if (ret)
return ret;
if (bo->status & HMM_BO_VMAPED || bo->status & HMM_BO_VMAPED_CACHED) {
void *src = bo->vmap_addr;
src += (virt - bo->start);
memcpy(data, src, bytes);
if (bo->status & HMM_BO_VMAPED_CACHED)
clflush_cache_range(src, bytes);
} else {
void *vptr;
vptr = hmm_bo_vmap(bo, true);
if (!vptr)
return load_and_flush_by_kmap(virt, data, bytes);
else
vptr = vptr + (virt - bo->start);
memcpy(data, vptr, bytes);
clflush_cache_range(vptr, bytes);
hmm_bo_vunmap(bo);
}
return 0;
}
/* Read function in ISP memory management */
int hmm_load(ia_css_ptr virt, void *data, unsigned int bytes)
{
if (!virt) {
dev_warn(atomisp_dev,
"hmm_store: address is NULL\n");
return -EINVAL;
}
if (!data) {
dev_err(atomisp_dev,
"hmm_store: data is a NULL argument\n");
return -EINVAL;
}
return load_and_flush(virt, data, bytes);
}
/* Flush hmm data from the data cache */
int hmm_flush(ia_css_ptr virt, unsigned int bytes)
{
return load_and_flush(virt, NULL, bytes);
}
/* Write function in ISP memory management */
int hmm_store(ia_css_ptr virt, const void *data, unsigned int bytes)
{
struct hmm_buffer_object *bo;
unsigned int idx, offset, len;
char *src, *des;
int ret;
if (!virt) {
dev_warn(atomisp_dev,
Annotation
- Immediate include surface: `linux/kernel.h`, `linux/types.h`, `linux/mm.h`, `linux/highmem.h`, `linux/io.h`, `linux/sysfs.h`, `hmm/hmm.h`, `hmm/hmm_bo.h`.
- Detected declarations: `function hmm_init`, `function hmm_cleanup`, `function __hmm_alloc`, `function hmm_alloc`, `function hmm_create_from_vmalloc_buf`, `function hmm_free`, `function hmm_check_bo`, `function load_and_flush_by_kmap`, `function load_and_flush`, `function hmm_load`.
- Atlas domain: Driver Families / drivers/staging.
- 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.