drivers/dma-buf/udmabuf.c
Source file repositories/reference/linux-study-clean/drivers/dma-buf/udmabuf.c
File Facts
- System
- Linux kernel
- Corpus path
drivers/dma-buf/udmabuf.c- Extension
.c- Size
- 12617 bytes
- Lines
- 551
- Domain
- Driver Families
- Bucket
- drivers/dma-buf
- Inferred role
- Driver Families: operation-table or driver-model contract
- Status
- pattern 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.
- Defines an operation table; this is where Linux turns generic core objects into subsystem-specific behavior.
- 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.
- 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/cred.hlinux/device.hlinux/dma-buf.hlinux/dma-resv.hlinux/highmem.hlinux/init.hlinux/kernel.hlinux/memfd.hlinux/miscdevice.hlinux/module.hlinux/shmem_fs.hlinux/hugetlb.hlinux/slab.hlinux/udmabuf.hlinux/vmalloc.hlinux/iosys-map.h
Detected Declarations
struct udmabuffunction udmabuf_vm_faultfunction mmap_udmabuffunction vmap_udmabuffunction vunmap_udmabuffunction put_sg_tablefunction unmap_udmabuffunction unpin_all_foliosfunction init_udmabuffunction deinit_udmabuffunction release_udmabuffunction begin_cpu_udmabuffunction end_cpu_udmabuffunction check_memfd_sealsfunction udmabuf_pin_foliosfunction udmabuf_createfunction udmabuf_ioctl_createfunction udmabuf_ioctl_create_listfunction udmabuf_ioctlfunction udmabuf_dev_initfunction udmabuf_dev_exitmodule init udmabuf_dev_init
Annotated Snippet
static const struct file_operations udmabuf_fops = {
.owner = THIS_MODULE,
.unlocked_ioctl = udmabuf_ioctl,
#ifdef CONFIG_COMPAT
.compat_ioctl = udmabuf_ioctl,
#endif
};
static struct miscdevice udmabuf_misc = {
.minor = MISC_DYNAMIC_MINOR,
.name = "udmabuf",
.fops = &udmabuf_fops,
};
static int __init udmabuf_dev_init(void)
{
int ret;
ret = misc_register(&udmabuf_misc);
if (ret < 0) {
pr_err("Could not initialize udmabuf device\n");
return ret;
}
ret = dma_coerce_mask_and_coherent(udmabuf_misc.this_device,
DMA_BIT_MASK(64));
if (ret < 0) {
pr_err("Could not setup DMA mask for udmabuf device\n");
misc_deregister(&udmabuf_misc);
return ret;
}
return 0;
}
static void __exit udmabuf_dev_exit(void)
{
misc_deregister(&udmabuf_misc);
}
module_init(udmabuf_dev_init)
module_exit(udmabuf_dev_exit)
MODULE_AUTHOR("Gerd Hoffmann <kraxel@redhat.com>");
Annotation
- Immediate include surface: `linux/cred.h`, `linux/device.h`, `linux/dma-buf.h`, `linux/dma-resv.h`, `linux/highmem.h`, `linux/init.h`, `linux/kernel.h`, `linux/memfd.h`.
- Detected declarations: `struct udmabuf`, `function udmabuf_vm_fault`, `function mmap_udmabuf`, `function vmap_udmabuf`, `function vunmap_udmabuf`, `function put_sg_table`, `function unmap_udmabuf`, `function unpin_all_folios`, `function init_udmabuf`, `function deinit_udmabuf`.
- Atlas domain: Driver Families / drivers/dma-buf.
- Implementation status: pattern 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.