Lines Matching refs:gntdev_dmabuf

28 struct gntdev_dmabuf {
60 struct gntdev_dmabuf *gntdev_dmabuf;
94 struct gntdev_dmabuf *gntdev_dmabuf)
103 obj->gntdev_dmabuf = gntdev_dmabuf;
107 /* Put our reference and wait for gntdev_dmabuf's release to fire. */
108 kref_put(&gntdev_dmabuf->u.exp.refcount, dmabuf_exp_release);
133 struct gntdev_dmabuf *gntdev_dmabuf)
138 if (obj->gntdev_dmabuf == gntdev_dmabuf) {
139 pr_debug("Found gntdev_dmabuf in the wait list, wake\n");
145 static struct gntdev_dmabuf *
148 struct gntdev_dmabuf *gntdev_dmabuf, *ret = ERR_PTR(-ENOENT);
151 list_for_each_entry(gntdev_dmabuf, &priv->exp_list, next)
152 if (gntdev_dmabuf->fd == fd) {
153 pr_debug("Found gntdev_dmabuf in the wait list\n");
154 kref_get(&gntdev_dmabuf->u.exp.refcount);
155 ret = gntdev_dmabuf;
165 struct gntdev_dmabuf *gntdev_dmabuf;
175 gntdev_dmabuf = dmabuf_exp_wait_obj_get_dmabuf(priv, fd);
176 if (IS_ERR(gntdev_dmabuf))
177 return PTR_ERR(gntdev_dmabuf);
180 * gntdev_dmabuf still exists and is reference count locked by us now,
184 obj = dmabuf_exp_wait_obj_new(priv, gntdev_dmabuf);
262 struct gntdev_dmabuf *gntdev_dmabuf = attach->dmabuf->priv;
265 pr_debug("Mapping %d pages for dev %p\n", gntdev_dmabuf->nr_pages,
282 sgt = dmabuf_pages_to_sgt(gntdev_dmabuf->pages,
283 gntdev_dmabuf->nr_pages);
309 struct gntdev_dmabuf *gntdev_dmabuf =
310 container_of(kref, struct gntdev_dmabuf, u.exp.refcount);
312 dmabuf_exp_wait_obj_signal(gntdev_dmabuf->priv, gntdev_dmabuf);
313 list_del(&gntdev_dmabuf->next);
314 fput(gntdev_dmabuf->priv->filp);
315 kfree(gntdev_dmabuf);
329 struct gntdev_dmabuf *gntdev_dmabuf = dma_buf->priv;
330 struct gntdev_dmabuf_priv *priv = gntdev_dmabuf->priv;
332 dmabuf_exp_remove_map(gntdev_dmabuf->u.exp.priv,
333 gntdev_dmabuf->u.exp.map);
335 kref_put(&gntdev_dmabuf->u.exp.refcount, dmabuf_exp_release);
360 struct gntdev_dmabuf *gntdev_dmabuf;
363 gntdev_dmabuf = kzalloc(sizeof(*gntdev_dmabuf), GFP_KERNEL);
364 if (!gntdev_dmabuf)
367 kref_init(&gntdev_dmabuf->u.exp.refcount);
369 gntdev_dmabuf->priv = args->dmabuf_priv;
370 gntdev_dmabuf->nr_pages = args->count;
371 gntdev_dmabuf->pages = args->pages;
372 gntdev_dmabuf->u.exp.priv = args->priv;
373 gntdev_dmabuf->u.exp.map = args->map;
383 exp_info.priv = gntdev_dmabuf;
385 gntdev_dmabuf->dmabuf = dma_buf_export(&exp_info);
386 if (IS_ERR(gntdev_dmabuf->dmabuf)) {
387 ret = PTR_ERR(gntdev_dmabuf->dmabuf);
388 gntdev_dmabuf->dmabuf = NULL;
392 ret = dma_buf_fd(gntdev_dmabuf->dmabuf, O_CLOEXEC);
396 gntdev_dmabuf->fd = ret;
402 list_add(&gntdev_dmabuf->next, &args->dmabuf_priv->exp_list);
404 get_file(gntdev_dmabuf->priv->filp);
408 if (gntdev_dmabuf->dmabuf)
409 dma_buf_put(gntdev_dmabuf->dmabuf);
410 kfree(gntdev_dmabuf);
531 static void dmabuf_imp_free_storage(struct gntdev_dmabuf *gntdev_dmabuf)
533 kfree(gntdev_dmabuf->u.imp.refs);
534 kfree(gntdev_dmabuf);
537 static struct gntdev_dmabuf *dmabuf_imp_alloc_storage(int count)
539 struct gntdev_dmabuf *gntdev_dmabuf;
542 gntdev_dmabuf = kzalloc(sizeof(*gntdev_dmabuf), GFP_KERNEL);
543 if (!gntdev_dmabuf)
546 gntdev_dmabuf->u.imp.refs = kcalloc(count,
547 sizeof(gntdev_dmabuf->u.imp.refs[0]),
549 if (!gntdev_dmabuf->u.imp.refs)
552 gntdev_dmabuf->nr_pages = count;
555 gntdev_dmabuf->u.imp.refs[i] = INVALID_GRANT_REF;
557 return gntdev_dmabuf;
560 dmabuf_imp_free_storage(gntdev_dmabuf);
565 static struct gntdev_dmabuf *
569 struct gntdev_dmabuf *gntdev_dmabuf, *ret;
581 gntdev_dmabuf = dmabuf_imp_alloc_storage(count);
582 if (IS_ERR(gntdev_dmabuf)) {
583 ret = gntdev_dmabuf;
587 gntdev_dmabuf->priv = priv;
588 gntdev_dmabuf->fd = fd;
596 gntdev_dmabuf->u.imp.attach = attach;
613 if (attach->dmabuf->size != gntdev_dmabuf->nr_pages << PAGE_SHIFT) {
616 attach->dmabuf->size, gntdev_dmabuf->nr_pages);
620 gntdev_dmabuf->u.imp.sgt = sgt;
644 gntdev_dmabuf->u.imp.refs,
653 list_add(&gntdev_dmabuf->next, &priv->imp_list);
656 return gntdev_dmabuf;
659 dmabuf_imp_end_foreign_access(gntdev_dmabuf->u.imp.refs, count);
665 dmabuf_imp_free_storage(gntdev_dmabuf);
675 static struct gntdev_dmabuf *
678 struct gntdev_dmabuf *q, *gntdev_dmabuf, *ret = ERR_PTR(-ENOENT);
681 list_for_each_entry_safe(gntdev_dmabuf, q, &priv->imp_list, next) {
682 if (gntdev_dmabuf->fd == fd) {
683 pr_debug("Found gntdev_dmabuf in the import list\n");
684 ret = gntdev_dmabuf;
685 list_del(&gntdev_dmabuf->next);
695 struct gntdev_dmabuf *gntdev_dmabuf;
699 gntdev_dmabuf = dmabuf_imp_find_unlink(priv, fd);
700 if (IS_ERR(gntdev_dmabuf))
701 return PTR_ERR(gntdev_dmabuf);
705 dmabuf_imp_end_foreign_access(gntdev_dmabuf->u.imp.refs,
706 gntdev_dmabuf->nr_pages);
708 attach = gntdev_dmabuf->u.imp.attach;
710 if (gntdev_dmabuf->u.imp.sgt)
711 dma_buf_unmap_attachment_unlocked(attach, gntdev_dmabuf->u.imp.sgt,
717 dmabuf_imp_free_storage(gntdev_dmabuf);
723 struct gntdev_dmabuf *q, *gntdev_dmabuf;
725 list_for_each_entry_safe(gntdev_dmabuf, q, &priv->imp_list, next)
726 dmabuf_imp_release(priv, gntdev_dmabuf->fd);
788 struct gntdev_dmabuf *gntdev_dmabuf;
797 gntdev_dmabuf = dmabuf_imp_to_refs(priv->dmabuf_priv,
800 if (IS_ERR(gntdev_dmabuf))
801 return PTR_ERR(gntdev_dmabuf);
803 if (copy_to_user(u->refs, gntdev_dmabuf->u.imp.refs,