14 #include <linux/module.h>
16 #include <linux/sched.h>
17 #include <linux/slab.h>
35 static void vb2_vmalloc_put(
void *buf_priv);
37 static void *vb2_vmalloc_alloc(
void *alloc_ctx,
unsigned long size)
48 buf->
handler.put = vb2_vmalloc_put;
61 static void vb2_vmalloc_put(
void *buf_priv)
71 static void *vb2_vmalloc_get_userptr(
void *alloc_ctx,
unsigned long vaddr,
72 unsigned long size,
int write)
92 goto fail_pages_array_alloc;
96 goto fail_pages_array_alloc;
99 last = (vaddr + size - 1) >> PAGE_SHIFT;
100 buf->
n_pages = last - first + 1;
104 goto fail_pages_array_alloc;
112 goto fail_get_user_pages;
117 goto fail_get_user_pages;
124 pr_debug(
"get_user_pages requested/got: %d/%d]\n", n_pages,
126 while (--n_pages >= 0)
130 fail_pages_array_alloc:
136 static void vb2_vmalloc_put_userptr(
void *buf_priv)
159 static void *vb2_vmalloc_vaddr(
void *buf_priv)
164 pr_err(
"Address of an unallocated plane requested "
165 "or cannot map user pointer\n");
172 static unsigned int vb2_vmalloc_num_users(
void *buf_priv)
178 static int vb2_vmalloc_mmap(
void *buf_priv,
struct vm_area_struct *vma)
184 pr_err(
"No memory to map\n");
190 pr_err(
"Remapping vmalloc memory, error: %d\n", ret);
211 .alloc = vb2_vmalloc_alloc,
212 .put = vb2_vmalloc_put,
213 .get_userptr = vb2_vmalloc_get_userptr,
214 .put_userptr = vb2_vmalloc_put_userptr,
215 .vaddr = vb2_vmalloc_vaddr,
216 .mmap = vb2_vmalloc_mmap,
217 .num_users = vb2_vmalloc_num_users,