Lines Matching refs:buf

40 	struct vb2_vmalloc_buf *buf;  in vb2_vmalloc_alloc()  local
42 buf = kzalloc(sizeof(*buf), GFP_KERNEL | vb->vb2_queue->gfp_flags); in vb2_vmalloc_alloc()
43 if (!buf) in vb2_vmalloc_alloc()
46 buf->size = size; in vb2_vmalloc_alloc()
47 buf->vaddr = vmalloc_user(buf->size); in vb2_vmalloc_alloc()
48 if (!buf->vaddr) { in vb2_vmalloc_alloc()
49 pr_debug("vmalloc of size %ld failed\n", buf->size); in vb2_vmalloc_alloc()
50 kfree(buf); in vb2_vmalloc_alloc()
54 buf->dma_dir = vb->vb2_queue->dma_dir; in vb2_vmalloc_alloc()
55 buf->handler.refcount = &buf->refcount; in vb2_vmalloc_alloc()
56 buf->handler.put = vb2_vmalloc_put; in vb2_vmalloc_alloc()
57 buf->handler.arg = buf; in vb2_vmalloc_alloc()
59 refcount_set(&buf->refcount, 1); in vb2_vmalloc_alloc()
60 return buf; in vb2_vmalloc_alloc()
65 struct vb2_vmalloc_buf *buf = buf_priv; in vb2_vmalloc_put() local
67 if (refcount_dec_and_test(&buf->refcount)) { in vb2_vmalloc_put()
68 vfree(buf->vaddr); in vb2_vmalloc_put()
69 kfree(buf); in vb2_vmalloc_put()
76 struct vb2_vmalloc_buf *buf; in vb2_vmalloc_get_userptr() local
81 buf = kzalloc(sizeof(*buf), GFP_KERNEL); in vb2_vmalloc_get_userptr()
82 if (!buf) in vb2_vmalloc_get_userptr()
85 buf->dma_dir = vb->vb2_queue->dma_dir; in vb2_vmalloc_get_userptr()
87 buf->size = size; in vb2_vmalloc_get_userptr()
93 buf->vec = vec; in vb2_vmalloc_get_userptr()
105 buf->vaddr = (__force void *) in vb2_vmalloc_get_userptr()
108 buf->vaddr = vm_map_ram(frame_vector_pages(vec), n_pages, -1); in vb2_vmalloc_get_userptr()
111 if (!buf->vaddr) in vb2_vmalloc_get_userptr()
113 buf->vaddr += offset; in vb2_vmalloc_get_userptr()
114 return buf; in vb2_vmalloc_get_userptr()
119 kfree(buf); in vb2_vmalloc_get_userptr()
126 struct vb2_vmalloc_buf *buf = buf_priv; in vb2_vmalloc_put_userptr() local
127 unsigned long vaddr = (unsigned long)buf->vaddr & PAGE_MASK; in vb2_vmalloc_put_userptr()
132 if (!buf->vec->is_pfns) { in vb2_vmalloc_put_userptr()
133 n_pages = frame_vector_count(buf->vec); in vb2_vmalloc_put_userptr()
134 pages = frame_vector_pages(buf->vec); in vb2_vmalloc_put_userptr()
137 if (buf->dma_dir == DMA_FROM_DEVICE || in vb2_vmalloc_put_userptr()
138 buf->dma_dir == DMA_BIDIRECTIONAL) in vb2_vmalloc_put_userptr()
142 iounmap((__force void __iomem *)buf->vaddr); in vb2_vmalloc_put_userptr()
144 vb2_destroy_framevec(buf->vec); in vb2_vmalloc_put_userptr()
145 kfree(buf); in vb2_vmalloc_put_userptr()
150 struct vb2_vmalloc_buf *buf = buf_priv; in vb2_vmalloc_vaddr() local
152 if (!buf->vaddr) { in vb2_vmalloc_vaddr()
157 return buf->vaddr; in vb2_vmalloc_vaddr()
162 struct vb2_vmalloc_buf *buf = buf_priv; in vb2_vmalloc_num_users() local
163 return refcount_read(&buf->refcount); in vb2_vmalloc_num_users()
168 struct vb2_vmalloc_buf *buf = buf_priv; in vb2_vmalloc_mmap() local
171 if (!buf) { in vb2_vmalloc_mmap()
176 ret = remap_vmalloc_range(vma, buf->vaddr, 0); in vb2_vmalloc_mmap()
190 vma->vm_private_data = &buf->handler; in vb2_vmalloc_mmap()
212 struct vb2_vmalloc_buf *buf = dbuf->priv; in vb2_vmalloc_dmabuf_ops_attach() local
213 int num_pages = PAGE_ALIGN(buf->size) / PAGE_SIZE; in vb2_vmalloc_dmabuf_ops_attach()
216 void *vaddr = buf->vaddr; in vb2_vmalloc_dmabuf_ops_attach()
318 struct vb2_vmalloc_buf *buf = dbuf->priv; in vb2_vmalloc_dmabuf_ops_vmap() local
320 iosys_map_set_vaddr(map, buf->vaddr); in vb2_vmalloc_dmabuf_ops_vmap()
345 struct vb2_vmalloc_buf *buf = buf_priv; in vb2_vmalloc_get_dmabuf() local
350 exp_info.size = buf->size; in vb2_vmalloc_get_dmabuf()
352 exp_info.priv = buf; in vb2_vmalloc_get_dmabuf()
354 if (WARN_ON(!buf->vaddr)) in vb2_vmalloc_get_dmabuf()
362 refcount_inc(&buf->refcount); in vb2_vmalloc_get_dmabuf()
375 struct vb2_vmalloc_buf *buf = mem_priv; in vb2_vmalloc_map_dmabuf() local
379 ret = dma_buf_vmap(buf->dbuf, &map); in vb2_vmalloc_map_dmabuf()
382 buf->vaddr = map.vaddr; in vb2_vmalloc_map_dmabuf()
389 struct vb2_vmalloc_buf *buf = mem_priv; in vb2_vmalloc_unmap_dmabuf() local
390 struct iosys_map map = IOSYS_MAP_INIT_VADDR(buf->vaddr); in vb2_vmalloc_unmap_dmabuf()
392 dma_buf_vunmap(buf->dbuf, &map); in vb2_vmalloc_unmap_dmabuf()
393 buf->vaddr = NULL; in vb2_vmalloc_unmap_dmabuf()
398 struct vb2_vmalloc_buf *buf = mem_priv; in vb2_vmalloc_detach_dmabuf() local
399 struct iosys_map map = IOSYS_MAP_INIT_VADDR(buf->vaddr); in vb2_vmalloc_detach_dmabuf()
401 if (buf->vaddr) in vb2_vmalloc_detach_dmabuf()
402 dma_buf_vunmap(buf->dbuf, &map); in vb2_vmalloc_detach_dmabuf()
404 kfree(buf); in vb2_vmalloc_detach_dmabuf()
412 struct vb2_vmalloc_buf *buf; in vb2_vmalloc_attach_dmabuf() local
417 buf = kzalloc(sizeof(*buf), GFP_KERNEL); in vb2_vmalloc_attach_dmabuf()
418 if (!buf) in vb2_vmalloc_attach_dmabuf()
421 buf->dbuf = dbuf; in vb2_vmalloc_attach_dmabuf()
422 buf->dma_dir = vb->vb2_queue->dma_dir; in vb2_vmalloc_attach_dmabuf()
423 buf->size = size; in vb2_vmalloc_attach_dmabuf()
425 return buf; in vb2_vmalloc_attach_dmabuf()