Lines Matching refs:buf
41 struct vb2_vmalloc_buf *buf; in vb2_vmalloc_alloc() local
43 buf = kzalloc(sizeof(*buf), GFP_KERNEL | gfp_flags); in vb2_vmalloc_alloc()
44 if (!buf) in vb2_vmalloc_alloc()
47 buf->size = size; in vb2_vmalloc_alloc()
48 buf->vaddr = vmalloc_user(buf->size); in vb2_vmalloc_alloc()
49 if (!buf->vaddr) { in vb2_vmalloc_alloc()
50 pr_debug("vmalloc of size %ld failed\n", buf->size); in vb2_vmalloc_alloc()
51 kfree(buf); in vb2_vmalloc_alloc()
55 buf->dma_dir = dma_dir; in vb2_vmalloc_alloc()
56 buf->handler.refcount = &buf->refcount; in vb2_vmalloc_alloc()
57 buf->handler.put = vb2_vmalloc_put; in vb2_vmalloc_alloc()
58 buf->handler.arg = buf; in vb2_vmalloc_alloc()
60 refcount_set(&buf->refcount, 1); in vb2_vmalloc_alloc()
61 return buf; in vb2_vmalloc_alloc()
66 struct vb2_vmalloc_buf *buf = buf_priv; in vb2_vmalloc_put() local
68 if (refcount_dec_and_test(&buf->refcount)) { in vb2_vmalloc_put()
69 vfree(buf->vaddr); in vb2_vmalloc_put()
70 kfree(buf); in vb2_vmalloc_put()
78 struct vb2_vmalloc_buf *buf; in vb2_vmalloc_get_userptr() local
83 buf = kzalloc(sizeof(*buf), GFP_KERNEL); in vb2_vmalloc_get_userptr()
84 if (!buf) in vb2_vmalloc_get_userptr()
87 buf->dma_dir = dma_dir; in vb2_vmalloc_get_userptr()
89 buf->size = size; in vb2_vmalloc_get_userptr()
95 buf->vec = vec; in vb2_vmalloc_get_userptr()
107 buf->vaddr = (__force void *) in vb2_vmalloc_get_userptr()
110 buf->vaddr = vm_map_ram(frame_vector_pages(vec), n_pages, -1); in vb2_vmalloc_get_userptr()
113 if (!buf->vaddr) in vb2_vmalloc_get_userptr()
115 buf->vaddr += offset; in vb2_vmalloc_get_userptr()
116 return buf; in vb2_vmalloc_get_userptr()
121 kfree(buf); in vb2_vmalloc_get_userptr()
128 struct vb2_vmalloc_buf *buf = buf_priv; in vb2_vmalloc_put_userptr() local
129 unsigned long vaddr = (unsigned long)buf->vaddr & PAGE_MASK; in vb2_vmalloc_put_userptr()
134 if (!buf->vec->is_pfns) { in vb2_vmalloc_put_userptr()
135 n_pages = frame_vector_count(buf->vec); in vb2_vmalloc_put_userptr()
136 pages = frame_vector_pages(buf->vec); in vb2_vmalloc_put_userptr()
139 if (buf->dma_dir == DMA_FROM_DEVICE || in vb2_vmalloc_put_userptr()
140 buf->dma_dir == DMA_BIDIRECTIONAL) in vb2_vmalloc_put_userptr()
144 iounmap((__force void __iomem *)buf->vaddr); in vb2_vmalloc_put_userptr()
146 vb2_destroy_framevec(buf->vec); in vb2_vmalloc_put_userptr()
147 kfree(buf); in vb2_vmalloc_put_userptr()
152 struct vb2_vmalloc_buf *buf = buf_priv; in vb2_vmalloc_vaddr() local
154 if (!buf->vaddr) { in vb2_vmalloc_vaddr()
159 return buf->vaddr; in vb2_vmalloc_vaddr()
164 struct vb2_vmalloc_buf *buf = buf_priv; in vb2_vmalloc_num_users() local
165 return refcount_read(&buf->refcount); in vb2_vmalloc_num_users()
170 struct vb2_vmalloc_buf *buf = buf_priv; in vb2_vmalloc_mmap() local
173 if (!buf) { in vb2_vmalloc_mmap()
178 ret = remap_vmalloc_range(vma, buf->vaddr, 0); in vb2_vmalloc_mmap()
192 vma->vm_private_data = &buf->handler; in vb2_vmalloc_mmap()
214 struct vb2_vmalloc_buf *buf = dbuf->priv; in vb2_vmalloc_dmabuf_ops_attach() local
215 int num_pages = PAGE_ALIGN(buf->size) / PAGE_SIZE; in vb2_vmalloc_dmabuf_ops_attach()
218 void *vaddr = buf->vaddr; in vb2_vmalloc_dmabuf_ops_attach()
319 struct vb2_vmalloc_buf *buf = dbuf->priv; in vb2_vmalloc_dmabuf_ops_vmap() local
321 return buf->vaddr; in vb2_vmalloc_dmabuf_ops_vmap()
342 struct vb2_vmalloc_buf *buf = buf_priv; in vb2_vmalloc_get_dmabuf() local
347 exp_info.size = buf->size; in vb2_vmalloc_get_dmabuf()
349 exp_info.priv = buf; in vb2_vmalloc_get_dmabuf()
351 if (WARN_ON(!buf->vaddr)) in vb2_vmalloc_get_dmabuf()
359 refcount_inc(&buf->refcount); in vb2_vmalloc_get_dmabuf()
372 struct vb2_vmalloc_buf *buf = mem_priv; in vb2_vmalloc_map_dmabuf() local
374 buf->vaddr = dma_buf_vmap(buf->dbuf); in vb2_vmalloc_map_dmabuf()
376 return buf->vaddr ? 0 : -EFAULT; in vb2_vmalloc_map_dmabuf()
381 struct vb2_vmalloc_buf *buf = mem_priv; in vb2_vmalloc_unmap_dmabuf() local
383 dma_buf_vunmap(buf->dbuf, buf->vaddr); in vb2_vmalloc_unmap_dmabuf()
384 buf->vaddr = NULL; in vb2_vmalloc_unmap_dmabuf()
389 struct vb2_vmalloc_buf *buf = mem_priv; in vb2_vmalloc_detach_dmabuf() local
391 if (buf->vaddr) in vb2_vmalloc_detach_dmabuf()
392 dma_buf_vunmap(buf->dbuf, buf->vaddr); in vb2_vmalloc_detach_dmabuf()
394 kfree(buf); in vb2_vmalloc_detach_dmabuf()
400 struct vb2_vmalloc_buf *buf; in vb2_vmalloc_attach_dmabuf() local
405 buf = kzalloc(sizeof(*buf), GFP_KERNEL); in vb2_vmalloc_attach_dmabuf()
406 if (!buf) in vb2_vmalloc_attach_dmabuf()
409 buf->dbuf = dbuf; in vb2_vmalloc_attach_dmabuf()
410 buf->dma_dir = dma_dir; in vb2_vmalloc_attach_dmabuf()
411 buf->size = size; in vb2_vmalloc_attach_dmabuf()
413 return buf; in vb2_vmalloc_attach_dmabuf()