Lines Matching +full:poll +full:- +full:retry +full:- +full:count
1 // SPDX-License-Identifier: GPL-2.0-only
8 * Many thanks to linaro-mm-sig list, and specially
16 #include <linux/dma-buf.h>
17 #include <linux/dma-fence.h>
23 #include <linux/poll.h>
24 #include <linux/dma-resv.h>
29 #include <uapi/linux/dma-buf.h>
47 dmabuf = dentry->d_fsdata; in dmabuffs_dname()
48 spin_lock(&dmabuf->name_lock); in dmabuffs_dname()
49 if (dmabuf->name) in dmabuffs_dname()
50 ret = strlcpy(name, dmabuf->name, DMA_BUF_NAME_LEN); in dmabuffs_dname()
51 spin_unlock(&dmabuf->name_lock); in dmabuffs_dname()
54 dentry->d_name.name, ret > 0 ? name : ""); in dmabuffs_dname()
61 dmabuf = dentry->d_fsdata; in dma_buf_release()
65 BUG_ON(dmabuf->vmapping_counter); in dma_buf_release()
68 * Any fences that a dma-buf poll can wait on should be signaled in dma_buf_release()
69 * before releasing dma-buf. This is the responsibility of each in dma_buf_release()
73 * dma-buf while still having pending operation to the buffer. in dma_buf_release()
75 BUG_ON(dmabuf->cb_shared.active || dmabuf->cb_excl.active); in dma_buf_release()
77 dmabuf->ops->release(dmabuf); in dma_buf_release()
80 list_del(&dmabuf->list_node); in dma_buf_release()
83 if (dmabuf->resv == (struct dma_resv *)&dmabuf[1]) in dma_buf_release()
84 dma_resv_fini(dmabuf->resv); in dma_buf_release()
86 module_put(dmabuf->owner); in dma_buf_release()
87 kfree(dmabuf->name); in dma_buf_release()
104 return -ENOMEM; in dma_buf_fs_init_context()
105 ctx->dops = &dma_buf_dentry_ops; in dma_buf_fs_init_context()
120 return -EINVAL; in dma_buf_mmap_internal()
122 dmabuf = file->private_data; in dma_buf_mmap_internal()
125 if (!dmabuf->ops->mmap) in dma_buf_mmap_internal()
126 return -EINVAL; in dma_buf_mmap_internal()
129 if (vma->vm_pgoff + vma_pages(vma) > in dma_buf_mmap_internal()
130 dmabuf->size >> PAGE_SHIFT) in dma_buf_mmap_internal()
131 return -EINVAL; in dma_buf_mmap_internal()
133 return dmabuf->ops->mmap(dmabuf, vma); in dma_buf_mmap_internal()
142 return -EBADF; in dma_buf_llseek()
144 dmabuf = file->private_data; in dma_buf_llseek()
150 base = dmabuf->size; in dma_buf_llseek()
154 return -EINVAL; in dma_buf_llseek()
157 return -EINVAL; in dma_buf_llseek()
165 * To support cross-device and cross-driver synchronization of buffer access
170 * Userspace can query the state of these implicitly tracked fences using poll()
173 * - Checking for EPOLLIN, i.e. read access, can be use to query the state of the
176 * - Checking for EPOLLOUT, i.e. write access, can be used to query the state of
189 spin_lock_irqsave(&dcb->poll->lock, flags); in dma_buf_poll_cb()
190 wake_up_locked_poll(dcb->poll, dcb->active); in dma_buf_poll_cb()
191 dcb->active = 0; in dma_buf_poll_cb()
192 spin_unlock_irqrestore(&dcb->poll->lock, flags); in dma_buf_poll_cb()
195 static __poll_t dma_buf_poll(struct file *file, poll_table *poll) in dma_buf_poll() argument
204 dmabuf = file->private_data; in dma_buf_poll()
205 if (!dmabuf || !dmabuf->resv) in dma_buf_poll()
208 resv = dmabuf->resv; in dma_buf_poll()
210 poll_wait(file, &dmabuf->poll, poll); in dma_buf_poll()
212 events = poll_requested_events(poll) & (EPOLLIN | EPOLLOUT); in dma_buf_poll()
216 retry: in dma_buf_poll()
217 seq = read_seqcount_begin(&resv->seq); in dma_buf_poll()
220 fobj = rcu_dereference(resv->fence); in dma_buf_poll()
222 shared_count = fobj->shared_count; in dma_buf_poll()
225 fence_excl = rcu_dereference(resv->fence_excl); in dma_buf_poll()
226 if (read_seqcount_retry(&resv->seq, seq)) { in dma_buf_poll()
228 goto retry; in dma_buf_poll()
232 struct dma_buf_poll_cb_t *dcb = &dmabuf->cb_excl; in dma_buf_poll()
238 spin_lock_irq(&dmabuf->poll.lock); in dma_buf_poll()
239 if (dcb->active) { in dma_buf_poll()
240 dcb->active |= pevents; in dma_buf_poll()
243 dcb->active = pevents; in dma_buf_poll()
244 spin_unlock_irq(&dmabuf->poll.lock); in dma_buf_poll()
250 dma_buf_poll_cb(NULL, &dcb->cb); in dma_buf_poll()
251 } else if (!dma_fence_add_callback(fence_excl, &dcb->cb, in dma_buf_poll()
261 dma_buf_poll_cb(NULL, &dcb->cb); in dma_buf_poll()
267 struct dma_buf_poll_cb_t *dcb = &dmabuf->cb_shared; in dma_buf_poll()
271 spin_lock_irq(&dmabuf->poll.lock); in dma_buf_poll()
272 if (dcb->active) in dma_buf_poll()
275 dcb->active = EPOLLOUT; in dma_buf_poll()
276 spin_unlock_irq(&dmabuf->poll.lock); in dma_buf_poll()
282 struct dma_fence *fence = rcu_dereference(fobj->shared[i]); in dma_buf_poll()
292 dma_buf_poll_cb(NULL, &dcb->cb); in dma_buf_poll()
295 if (!dma_fence_add_callback(fence, &dcb->cb, in dma_buf_poll()
306 dma_buf_poll_cb(NULL, &dcb->cb); in dma_buf_poll()
315 * dma_buf_set_name - Set a name to a specific dma_buf to track the usage.
316 * The name of the dma-buf buffer can only be set when the dma-buf is not
318 * name of the dma-buf if the same piece of memory is used for multiple
323 * the dma-buf.
325 * Returns 0 on success. If the dma-buf buffer is already attached to
326 * devices, return -EBUSY.
337 dma_resv_lock(dmabuf->resv, NULL); in dma_buf_set_name()
338 if (!list_empty(&dmabuf->attachments)) { in dma_buf_set_name()
339 ret = -EBUSY; in dma_buf_set_name()
343 spin_lock(&dmabuf->name_lock); in dma_buf_set_name()
344 kfree(dmabuf->name); in dma_buf_set_name()
345 dmabuf->name = name; in dma_buf_set_name()
346 spin_unlock(&dmabuf->name_lock); in dma_buf_set_name()
349 dma_resv_unlock(dmabuf->resv); in dma_buf_set_name()
361 dmabuf = file->private_data; in dma_buf_ioctl()
366 return -EFAULT; in dma_buf_ioctl()
369 return -EINVAL; in dma_buf_ioctl()
382 return -EINVAL; in dma_buf_ioctl()
397 return -ENOTTY; in dma_buf_ioctl()
403 struct dma_buf *dmabuf = file->private_data; in dma_buf_show_fdinfo()
405 seq_printf(m, "size:\t%zu\n", dmabuf->size); in dma_buf_show_fdinfo()
406 /* Don't count the temporary reference taken inside procfs seq_show */ in dma_buf_show_fdinfo()
407 seq_printf(m, "count:\t%ld\n", file_count(dmabuf->file) - 1); in dma_buf_show_fdinfo()
408 seq_printf(m, "exp_name:\t%s\n", dmabuf->exp_name); in dma_buf_show_fdinfo()
409 spin_lock(&dmabuf->name_lock); in dma_buf_show_fdinfo()
410 if (dmabuf->name) in dma_buf_show_fdinfo()
411 seq_printf(m, "name:\t%s\n", dmabuf->name); in dma_buf_show_fdinfo()
412 spin_unlock(&dmabuf->name_lock); in dma_buf_show_fdinfo()
418 .poll = dma_buf_poll,
425 * is_dma_buf_file - Check if struct file* is associated with dma_buf
429 return file->f_op == &dma_buf_fops; in is_dma_buf_file()
435 struct inode *inode = alloc_anon_inode(dma_buf_mnt->mnt_sb); in dma_buf_getfile()
440 inode->i_size = dmabuf->size; in dma_buf_getfile()
441 inode_set_bytes(inode, dmabuf->size); in dma_buf_getfile()
447 file->f_flags = flags & (O_ACCMODE | O_NONBLOCK); in dma_buf_getfile()
448 file->private_data = dmabuf; in dma_buf_getfile()
449 file->f_path.dentry->d_fsdata = dmabuf; in dma_buf_getfile()
469 * 2. Userspace passes this file-descriptors to all drivers it wants this buffer
490 * dma_buf_export - Creates a new dma_buf, and associates an anon file
509 struct dma_resv *resv = exp_info->resv; in dma_buf_export()
514 if (!exp_info->resv) in dma_buf_export()
517 /* prevent &dma_buf[1] == dma_buf->resv */ in dma_buf_export()
520 if (WARN_ON(!exp_info->priv in dma_buf_export()
521 || !exp_info->ops in dma_buf_export()
522 || !exp_info->ops->map_dma_buf in dma_buf_export()
523 || !exp_info->ops->unmap_dma_buf in dma_buf_export()
524 || !exp_info->ops->release)) { in dma_buf_export()
525 return ERR_PTR(-EINVAL); in dma_buf_export()
528 if (WARN_ON(exp_info->ops->cache_sgt_mapping && in dma_buf_export()
529 (exp_info->ops->pin || exp_info->ops->unpin))) in dma_buf_export()
530 return ERR_PTR(-EINVAL); in dma_buf_export()
532 if (WARN_ON(!exp_info->ops->pin != !exp_info->ops->unpin)) in dma_buf_export()
533 return ERR_PTR(-EINVAL); in dma_buf_export()
535 if (!try_module_get(exp_info->owner)) in dma_buf_export()
536 return ERR_PTR(-ENOENT); in dma_buf_export()
540 ret = -ENOMEM; in dma_buf_export()
544 dmabuf->priv = exp_info->priv; in dma_buf_export()
545 dmabuf->ops = exp_info->ops; in dma_buf_export()
546 dmabuf->size = exp_info->size; in dma_buf_export()
547 dmabuf->exp_name = exp_info->exp_name; in dma_buf_export()
548 dmabuf->owner = exp_info->owner; in dma_buf_export()
549 spin_lock_init(&dmabuf->name_lock); in dma_buf_export()
550 init_waitqueue_head(&dmabuf->poll); in dma_buf_export()
551 dmabuf->cb_excl.poll = dmabuf->cb_shared.poll = &dmabuf->poll; in dma_buf_export()
552 dmabuf->cb_excl.active = dmabuf->cb_shared.active = 0; in dma_buf_export()
558 dmabuf->resv = resv; in dma_buf_export()
560 file = dma_buf_getfile(dmabuf, exp_info->flags); in dma_buf_export()
566 file->f_mode |= FMODE_LSEEK; in dma_buf_export()
567 dmabuf->file = file; in dma_buf_export()
569 mutex_init(&dmabuf->lock); in dma_buf_export()
570 INIT_LIST_HEAD(&dmabuf->attachments); in dma_buf_export()
573 list_add(&dmabuf->list_node, &db_list.head); in dma_buf_export()
581 module_put(exp_info->owner); in dma_buf_export()
587 * dma_buf_fd - returns a file descriptor for the given dma_buf
597 if (!dmabuf || !dmabuf->file) in dma_buf_fd()
598 return -EINVAL; in dma_buf_fd()
604 fd_install(fd, dmabuf->file); in dma_buf_fd()
611 * dma_buf_get - returns the dma_buf structure related to an fd
625 return ERR_PTR(-EBADF); in dma_buf_get()
629 return ERR_PTR(-EINVAL); in dma_buf_get()
632 return file->private_data; in dma_buf_get()
637 * dma_buf_put - decreases refcount of the buffer
648 if (WARN_ON(!dmabuf || !dmabuf->file)) in dma_buf_put()
651 fput(dmabuf->file); in dma_buf_put()
656 * dma_buf_dynamic_attach - Add the device to dma_buf's attachments list; optionally,
657 * calls attach() of dma_buf_ops to allow device-specific attach functionality
673 * indicated with the error code -EBUSY.
684 return ERR_PTR(-EINVAL); in dma_buf_dynamic_attach()
686 if (WARN_ON(importer_ops && !importer_ops->move_notify)) in dma_buf_dynamic_attach()
687 return ERR_PTR(-EINVAL); in dma_buf_dynamic_attach()
691 return ERR_PTR(-ENOMEM); in dma_buf_dynamic_attach()
693 attach->dev = dev; in dma_buf_dynamic_attach()
694 attach->dmabuf = dmabuf; in dma_buf_dynamic_attach()
696 attach->peer2peer = importer_ops->allow_peer2peer; in dma_buf_dynamic_attach()
697 attach->importer_ops = importer_ops; in dma_buf_dynamic_attach()
698 attach->importer_priv = importer_priv; in dma_buf_dynamic_attach()
700 if (dmabuf->ops->attach) { in dma_buf_dynamic_attach()
701 ret = dmabuf->ops->attach(dmabuf, attach); in dma_buf_dynamic_attach()
705 dma_resv_lock(dmabuf->resv, NULL); in dma_buf_dynamic_attach()
706 list_add(&attach->node, &dmabuf->attachments); in dma_buf_dynamic_attach()
707 dma_resv_unlock(dmabuf->resv); in dma_buf_dynamic_attach()
717 if (dma_buf_is_dynamic(attach->dmabuf)) { in dma_buf_dynamic_attach()
718 dma_resv_lock(attach->dmabuf->resv, NULL); in dma_buf_dynamic_attach()
724 sgt = dmabuf->ops->map_dma_buf(attach, DMA_BIDIRECTIONAL); in dma_buf_dynamic_attach()
726 sgt = ERR_PTR(-ENOMEM); in dma_buf_dynamic_attach()
731 if (dma_buf_is_dynamic(attach->dmabuf)) in dma_buf_dynamic_attach()
732 dma_resv_unlock(attach->dmabuf->resv); in dma_buf_dynamic_attach()
733 attach->sgt = sgt; in dma_buf_dynamic_attach()
734 attach->dir = DMA_BIDIRECTIONAL; in dma_buf_dynamic_attach()
744 if (dma_buf_is_dynamic(attach->dmabuf)) in dma_buf_dynamic_attach()
748 if (dma_buf_is_dynamic(attach->dmabuf)) in dma_buf_dynamic_attach()
749 dma_resv_unlock(attach->dmabuf->resv); in dma_buf_dynamic_attach()
757 * dma_buf_attach - Wrapper for dma_buf_dynamic_attach
772 * dma_buf_detach - Remove the given attachment from dmabuf's attachments list;
773 * optionally calls detach() of dma_buf_ops for device-specific detach
784 if (attach->sgt) { in dma_buf_detach()
785 if (dma_buf_is_dynamic(attach->dmabuf)) in dma_buf_detach()
786 dma_resv_lock(attach->dmabuf->resv, NULL); in dma_buf_detach()
788 dmabuf->ops->unmap_dma_buf(attach, attach->sgt, attach->dir); in dma_buf_detach()
790 if (dma_buf_is_dynamic(attach->dmabuf)) { in dma_buf_detach()
792 dma_resv_unlock(attach->dmabuf->resv); in dma_buf_detach()
796 dma_resv_lock(dmabuf->resv, NULL); in dma_buf_detach()
797 list_del(&attach->node); in dma_buf_detach()
798 dma_resv_unlock(dmabuf->resv); in dma_buf_detach()
799 if (dmabuf->ops->detach) in dma_buf_detach()
800 dmabuf->ops->detach(dmabuf, attach); in dma_buf_detach()
807 * dma_buf_pin - Lock down the DMA-buf
816 struct dma_buf *dmabuf = attach->dmabuf; in dma_buf_pin()
819 dma_resv_assert_held(dmabuf->resv); in dma_buf_pin()
821 if (dmabuf->ops->pin) in dma_buf_pin()
822 ret = dmabuf->ops->pin(attach); in dma_buf_pin()
829 * dma_buf_unpin - Remove lock from DMA-buf
835 struct dma_buf *dmabuf = attach->dmabuf; in dma_buf_unpin()
837 dma_resv_assert_held(dmabuf->resv); in dma_buf_unpin()
839 if (dmabuf->ops->unpin) in dma_buf_unpin()
840 dmabuf->ops->unpin(attach); in dma_buf_unpin()
845 * dma_buf_map_attachment - Returns the scatterlist table of the attachment;
852 * on error. May return -EINTR if it is interrupted by a signal.
867 if (WARN_ON(!attach || !attach->dmabuf)) in dma_buf_map_attachment()
868 return ERR_PTR(-EINVAL); in dma_buf_map_attachment()
871 dma_resv_assert_held(attach->dmabuf->resv); in dma_buf_map_attachment()
873 if (attach->sgt) { in dma_buf_map_attachment()
878 if (attach->dir != direction && in dma_buf_map_attachment()
879 attach->dir != DMA_BIDIRECTIONAL) in dma_buf_map_attachment()
880 return ERR_PTR(-EBUSY); in dma_buf_map_attachment()
882 return attach->sgt; in dma_buf_map_attachment()
885 if (dma_buf_is_dynamic(attach->dmabuf)) { in dma_buf_map_attachment()
886 dma_resv_assert_held(attach->dmabuf->resv); in dma_buf_map_attachment()
894 sg_table = attach->dmabuf->ops->map_dma_buf(attach, direction); in dma_buf_map_attachment()
896 sg_table = ERR_PTR(-ENOMEM); in dma_buf_map_attachment()
898 if (IS_ERR(sg_table) && dma_buf_is_dynamic(attach->dmabuf) && in dma_buf_map_attachment()
902 if (!IS_ERR(sg_table) && attach->dmabuf->ops->cache_sgt_mapping) { in dma_buf_map_attachment()
903 attach->sgt = sg_table; in dma_buf_map_attachment()
904 attach->dir = direction; in dma_buf_map_attachment()
912 * dma_buf_unmap_attachment - unmaps and decreases usecount of the buffer;might
927 if (WARN_ON(!attach || !attach->dmabuf || !sg_table)) in dma_buf_unmap_attachment()
931 dma_resv_assert_held(attach->dmabuf->resv); in dma_buf_unmap_attachment()
933 if (attach->sgt == sg_table) in dma_buf_unmap_attachment()
936 if (dma_buf_is_dynamic(attach->dmabuf)) in dma_buf_unmap_attachment()
937 dma_resv_assert_held(attach->dmabuf->resv); in dma_buf_unmap_attachment()
939 attach->dmabuf->ops->unmap_dma_buf(attach, sg_table, direction); in dma_buf_unmap_attachment()
941 if (dma_buf_is_dynamic(attach->dmabuf) && in dma_buf_unmap_attachment()
948 * dma_buf_move_notify - notify attachments that DMA-buf is moving
959 dma_resv_assert_held(dmabuf->resv); in dma_buf_move_notify()
961 list_for_each_entry(attach, &dmabuf->attachments, node) in dma_buf_move_notify()
962 if (attach->importer_ops) in dma_buf_move_notify()
963 attach->importer_ops->move_notify(attach); in dma_buf_move_notify()
972 * - Fallback operations in the kernel, for example when a device is connected
978 * Since for most kernel internal dma-buf accesses need the entire buffer, a
979 * vmap interface is introduced. Note that on very old 32-bit architectures
988 * that the dma-buf layer keeps a reference count for all vmap access and
991 * provided by taking the dma_buf->lock mutex.
993 * - For full compatibility on the importer side with existing userspace
1000 * There is no special interfaces, userspace simply calls mmap on the dma-buf
1003 * DMA_BUF_IOCTL_SYNC can fail with -EAGAIN or -EINTR, in which case it must
1007 * CPU and GPU domains are being accessed through dma-buf at the same time.
1009 * forward directly to existing dma-buf device drivers vfunc hooks. Userspace
1013 * - mmap dma-buf fd
1014 * - for each drawing/upload cycle in CPU 1. SYNC_START ioctl, 2. read/write
1018 * - munmap once you don't need the buffer any more
1025 * - And as a CPU fallback in userspace processing pipelines.
1029 * interfaces with a imported dma-buf buffer object as with a native buffer
1034 * The assumption in the current dma-buf interfaces is that redirecting the
1046 * If the importing subsystem simply provides a special-purpose mmap call to
1047 * set up a mapping in userspace, calling do_mmap with dma_buf->file will
1048 * equally achieve that for a dma-buf object.
1056 struct dma_resv *resv = dmabuf->resv; in __dma_buf_begin_cpu_access()
1069 * dma_buf_begin_cpu_access - Must be called before accessing a dma_buf from the
1070 * cpu in the kernel context. Calls begin_cpu_access to allow exporter-specific
1088 return -EINVAL; in dma_buf_begin_cpu_access()
1090 if (dmabuf->ops->begin_cpu_access) in dma_buf_begin_cpu_access()
1091 ret = dmabuf->ops->begin_cpu_access(dmabuf, direction); in dma_buf_begin_cpu_access()
1093 /* Ensure that all fences are waited upon - but we first allow in dma_buf_begin_cpu_access()
1095 * chooses. A double invocation here will be reasonably cheap no-op. in dma_buf_begin_cpu_access()
1105 * dma_buf_end_cpu_access - Must be called after accessing a dma_buf from the
1106 * cpu in the kernel context. Calls end_cpu_access to allow exporter-specific
1123 if (dmabuf->ops->end_cpu_access) in dma_buf_end_cpu_access()
1124 ret = dmabuf->ops->end_cpu_access(dmabuf, direction); in dma_buf_end_cpu_access()
1132 * dma_buf_mmap - Setup up a userspace mmap with the given vma
1136 * dma-buf buffer.
1152 return -EINVAL; in dma_buf_mmap()
1155 if (!dmabuf->ops->mmap) in dma_buf_mmap()
1156 return -EINVAL; in dma_buf_mmap()
1160 return -EOVERFLOW; in dma_buf_mmap()
1164 dmabuf->size >> PAGE_SHIFT) in dma_buf_mmap()
1165 return -EINVAL; in dma_buf_mmap()
1168 get_file(dmabuf->file); in dma_buf_mmap()
1169 oldfile = vma->vm_file; in dma_buf_mmap()
1170 vma->vm_file = dmabuf->file; in dma_buf_mmap()
1171 vma->vm_pgoff = pgoff; in dma_buf_mmap()
1173 ret = dmabuf->ops->mmap(dmabuf, vma); in dma_buf_mmap()
1176 vma->vm_file = oldfile; in dma_buf_mmap()
1177 fput(dmabuf->file); in dma_buf_mmap()
1188 * dma_buf_vmap - Create virtual mapping for the buffer object into kernel
1206 if (!dmabuf->ops->vmap) in dma_buf_vmap()
1209 mutex_lock(&dmabuf->lock); in dma_buf_vmap()
1210 if (dmabuf->vmapping_counter) { in dma_buf_vmap()
1211 dmabuf->vmapping_counter++; in dma_buf_vmap()
1212 BUG_ON(!dmabuf->vmap_ptr); in dma_buf_vmap()
1213 ptr = dmabuf->vmap_ptr; in dma_buf_vmap()
1217 BUG_ON(dmabuf->vmap_ptr); in dma_buf_vmap()
1219 ptr = dmabuf->ops->vmap(dmabuf); in dma_buf_vmap()
1225 dmabuf->vmap_ptr = ptr; in dma_buf_vmap()
1226 dmabuf->vmapping_counter = 1; in dma_buf_vmap()
1229 mutex_unlock(&dmabuf->lock); in dma_buf_vmap()
1235 * dma_buf_vunmap - Unmap a vmap obtained by dma_buf_vmap.
1244 BUG_ON(!dmabuf->vmap_ptr); in dma_buf_vunmap()
1245 BUG_ON(dmabuf->vmapping_counter == 0); in dma_buf_vunmap()
1246 BUG_ON(dmabuf->vmap_ptr != vaddr); in dma_buf_vunmap()
1248 mutex_lock(&dmabuf->lock); in dma_buf_vunmap()
1249 if (--dmabuf->vmapping_counter == 0) { in dma_buf_vunmap()
1250 if (dmabuf->ops->vunmap) in dma_buf_vunmap()
1251 dmabuf->ops->vunmap(dmabuf, vaddr); in dma_buf_vunmap()
1252 dmabuf->vmap_ptr = NULL; in dma_buf_vunmap()
1254 mutex_unlock(&dmabuf->lock); in dma_buf_vunmap()
1268 int count = 0, attach_count, shared_count, i; in dma_buf_debug_show() local
1276 seq_puts(s, "\nDma-buf Objects:\n"); in dma_buf_debug_show()
1277 seq_printf(s, "%-8s\t%-8s\t%-8s\t%-8s\texp_name\t%-8s\n", in dma_buf_debug_show()
1278 "size", "flags", "mode", "count", "ino"); in dma_buf_debug_show()
1282 ret = dma_resv_lock_interruptible(buf_obj->resv, NULL); in dma_buf_debug_show()
1287 buf_obj->size, in dma_buf_debug_show()
1288 buf_obj->file->f_flags, buf_obj->file->f_mode, in dma_buf_debug_show()
1289 file_count(buf_obj->file), in dma_buf_debug_show()
1290 buf_obj->exp_name, in dma_buf_debug_show()
1291 file_inode(buf_obj->file)->i_ino, in dma_buf_debug_show()
1292 buf_obj->name ?: ""); in dma_buf_debug_show()
1294 robj = buf_obj->resv; in dma_buf_debug_show()
1296 seq = read_seqcount_begin(&robj->seq); in dma_buf_debug_show()
1298 fobj = rcu_dereference(robj->fence); in dma_buf_debug_show()
1299 shared_count = fobj ? fobj->shared_count : 0; in dma_buf_debug_show()
1300 fence = rcu_dereference(robj->fence_excl); in dma_buf_debug_show()
1301 if (!read_seqcount_retry(&robj->seq, seq)) in dma_buf_debug_show()
1308 fence->ops->get_driver_name(fence), in dma_buf_debug_show()
1309 fence->ops->get_timeline_name(fence), in dma_buf_debug_show()
1312 fence = rcu_dereference(fobj->shared[i]); in dma_buf_debug_show()
1316 fence->ops->get_driver_name(fence), in dma_buf_debug_show()
1317 fence->ops->get_timeline_name(fence), in dma_buf_debug_show()
1326 list_for_each_entry(attach_obj, &buf_obj->attachments, node) { in dma_buf_debug_show()
1327 seq_printf(s, "\t%s\n", dev_name(attach_obj->dev)); in dma_buf_debug_show()
1330 dma_resv_unlock(buf_obj->resv); in dma_buf_debug_show()
1335 count++; in dma_buf_debug_show()
1336 size += buf_obj->size; in dma_buf_debug_show()
1339 seq_printf(s, "\nTotal %d objects, %zu bytes\n", count, size); in dma_buf_debug_show()