#include <linux/cred.h>
#include <linux/device.h>
#include <linux/dma-buf.h>
#include <linux/dma-resv.h>
#include <linux/highmem.h>
#include <linux/init.h>
#include <linux/kernel.h>
#include <linux/memfd.h>
#include <linux/miscdevice.h>
#include <linux/module.h>
#include <linux/shmem_fs.h>
#include <linux/hugetlb.h>
#include <linux/slab.h>
#include <linux/udmabuf.h>
#include <linux/vmalloc.h>
#include <linux/iosys-map.h>
static int list_limit = …;
module_param(list_limit, int, 0644);
MODULE_PARM_DESC(…) …;
static int size_limit_mb = …;
module_param(size_limit_mb, int, 0644);
MODULE_PARM_DESC(…) …;
struct udmabuf { … };
struct udmabuf_folio { … };
static vm_fault_t udmabuf_vm_fault(struct vm_fault *vmf)
{ … }
static const struct vm_operations_struct udmabuf_vm_ops = …;
static int mmap_udmabuf(struct dma_buf *buf, struct vm_area_struct *vma)
{ … }
static int vmap_udmabuf(struct dma_buf *buf, struct iosys_map *map)
{ … }
static void vunmap_udmabuf(struct dma_buf *buf, struct iosys_map *map)
{ … }
static struct sg_table *get_sg_table(struct device *dev, struct dma_buf *buf,
enum dma_data_direction direction)
{ … }
static void put_sg_table(struct device *dev, struct sg_table *sg,
enum dma_data_direction direction)
{ … }
static struct sg_table *map_udmabuf(struct dma_buf_attachment *at,
enum dma_data_direction direction)
{ … }
static void unmap_udmabuf(struct dma_buf_attachment *at,
struct sg_table *sg,
enum dma_data_direction direction)
{ … }
static void unpin_all_folios(struct list_head *unpin_list)
{ … }
static int add_to_unpin_list(struct list_head *unpin_list,
struct folio *folio)
{ … }
static void release_udmabuf(struct dma_buf *buf)
{ … }
static int begin_cpu_udmabuf(struct dma_buf *buf,
enum dma_data_direction direction)
{ … }
static int end_cpu_udmabuf(struct dma_buf *buf,
enum dma_data_direction direction)
{ … }
static const struct dma_buf_ops udmabuf_ops = …;
#define SEALS_WANTED …
#define SEALS_DENIED …
static int check_memfd_seals(struct file *memfd)
{ … }
static int export_udmabuf(struct udmabuf *ubuf,
struct miscdevice *device,
u32 flags)
{ … }
static long udmabuf_create(struct miscdevice *device,
struct udmabuf_create_list *head,
struct udmabuf_create_item *list)
{ … }
static long udmabuf_ioctl_create(struct file *filp, unsigned long arg)
{ … }
static long udmabuf_ioctl_create_list(struct file *filp, unsigned long arg)
{ … }
static long udmabuf_ioctl(struct file *filp, unsigned int ioctl,
unsigned long arg)
{ … }
static const struct file_operations udmabuf_fops = …;
static struct miscdevice udmabuf_misc = …;
static int __init udmabuf_dev_init(void)
{ … }
static void __exit udmabuf_dev_exit(void)
{ … }
module_init(…) …
module_exit(…)
MODULE_AUTHOR(…) …;