Lines Matching refs:gntdev_dmabuf

34 struct gntdev_dmabuf {
66 struct gntdev_dmabuf *gntdev_dmabuf;
100 struct gntdev_dmabuf *gntdev_dmabuf)
109 obj->gntdev_dmabuf = gntdev_dmabuf;
113 /* Put our reference and wait for gntdev_dmabuf's release to fire. */
114 kref_put(&gntdev_dmabuf->u.exp.refcount, dmabuf_exp_release);
139 struct gntdev_dmabuf *gntdev_dmabuf)
144 if (obj->gntdev_dmabuf == gntdev_dmabuf) {
145 pr_debug("Found gntdev_dmabuf in the wait list, wake\n");
151 static struct gntdev_dmabuf *
154 struct gntdev_dmabuf *gntdev_dmabuf, *ret = ERR_PTR(-ENOENT);
157 list_for_each_entry(gntdev_dmabuf, &priv->exp_list, next)
158 if (gntdev_dmabuf->fd == fd) {
159 pr_debug("Found gntdev_dmabuf in the wait list\n");
160 kref_get(&gntdev_dmabuf->u.exp.refcount);
161 ret = gntdev_dmabuf;
171 struct gntdev_dmabuf *gntdev_dmabuf;
181 gntdev_dmabuf = dmabuf_exp_wait_obj_get_dmabuf(priv, fd);
182 if (IS_ERR(gntdev_dmabuf))
183 return PTR_ERR(gntdev_dmabuf);
186 * gntdev_dmabuf still exists and is reference count locked by us now,
190 obj = dmabuf_exp_wait_obj_new(priv, gntdev_dmabuf);
268 struct gntdev_dmabuf *gntdev_dmabuf = attach->dmabuf->priv;
271 pr_debug("Mapping %d pages for dev %p\n", gntdev_dmabuf->nr_pages,
288 sgt = dmabuf_pages_to_sgt(gntdev_dmabuf->pages,
289 gntdev_dmabuf->nr_pages);
315 struct gntdev_dmabuf *gntdev_dmabuf =
316 container_of(kref, struct gntdev_dmabuf, u.exp.refcount);
318 dmabuf_exp_wait_obj_signal(gntdev_dmabuf->priv, gntdev_dmabuf);
319 list_del(&gntdev_dmabuf->next);
320 fput(gntdev_dmabuf->priv->filp);
321 kfree(gntdev_dmabuf);
335 struct gntdev_dmabuf *gntdev_dmabuf = dma_buf->priv;
336 struct gntdev_dmabuf_priv *priv = gntdev_dmabuf->priv;
338 dmabuf_exp_remove_map(gntdev_dmabuf->u.exp.priv,
339 gntdev_dmabuf->u.exp.map);
341 kref_put(&gntdev_dmabuf->u.exp.refcount, dmabuf_exp_release);
366 struct gntdev_dmabuf *gntdev_dmabuf;
369 gntdev_dmabuf = kzalloc(sizeof(*gntdev_dmabuf), GFP_KERNEL);
370 if (!gntdev_dmabuf)
373 kref_init(&gntdev_dmabuf->u.exp.refcount);
375 gntdev_dmabuf->priv = args->dmabuf_priv;
376 gntdev_dmabuf->nr_pages = args->count;
377 gntdev_dmabuf->pages = args->pages;
378 gntdev_dmabuf->u.exp.priv = args->priv;
379 gntdev_dmabuf->u.exp.map = args->map;
389 exp_info.priv = gntdev_dmabuf;
391 gntdev_dmabuf->dmabuf = dma_buf_export(&exp_info);
392 if (IS_ERR(gntdev_dmabuf->dmabuf)) {
393 ret = PTR_ERR(gntdev_dmabuf->dmabuf);
394 gntdev_dmabuf->dmabuf = NULL;
398 ret = dma_buf_fd(gntdev_dmabuf->dmabuf, O_CLOEXEC);
402 gntdev_dmabuf->fd = ret;
408 list_add(&gntdev_dmabuf->next, &args->dmabuf_priv->exp_list);
410 get_file(gntdev_dmabuf->priv->filp);
414 if (gntdev_dmabuf->dmabuf)
415 dma_buf_put(gntdev_dmabuf->dmabuf);
416 kfree(gntdev_dmabuf);
537 static void dmabuf_imp_free_storage(struct gntdev_dmabuf *gntdev_dmabuf)
539 kfree(gntdev_dmabuf->u.imp.refs);
540 kfree(gntdev_dmabuf);
543 static struct gntdev_dmabuf *dmabuf_imp_alloc_storage(int count)
545 struct gntdev_dmabuf *gntdev_dmabuf;
548 gntdev_dmabuf = kzalloc(sizeof(*gntdev_dmabuf), GFP_KERNEL);
549 if (!gntdev_dmabuf)
552 gntdev_dmabuf->u.imp.refs = kcalloc(count,
553 sizeof(gntdev_dmabuf->u.imp.refs[0]),
555 if (!gntdev_dmabuf->u.imp.refs)
558 gntdev_dmabuf->nr_pages = count;
561 gntdev_dmabuf->u.imp.refs[i] = GRANT_INVALID_REF;
563 return gntdev_dmabuf;
566 dmabuf_imp_free_storage(gntdev_dmabuf);
571 static struct gntdev_dmabuf *
575 struct gntdev_dmabuf *gntdev_dmabuf, *ret;
587 gntdev_dmabuf = dmabuf_imp_alloc_storage(count);
588 if (IS_ERR(gntdev_dmabuf)) {
589 ret = gntdev_dmabuf;
593 gntdev_dmabuf->priv = priv;
594 gntdev_dmabuf->fd = fd;
602 gntdev_dmabuf->u.imp.attach = attach;
619 if (attach->dmabuf->size != gntdev_dmabuf->nr_pages << PAGE_SHIFT) {
622 attach->dmabuf->size, gntdev_dmabuf->nr_pages);
626 gntdev_dmabuf->u.imp.sgt = sgt;
650 gntdev_dmabuf->u.imp.refs,
659 list_add(&gntdev_dmabuf->next, &priv->imp_list);
662 return gntdev_dmabuf;
665 dmabuf_imp_end_foreign_access(gntdev_dmabuf->u.imp.refs, count);
671 dmabuf_imp_free_storage(gntdev_dmabuf);
681 static struct gntdev_dmabuf *
684 struct gntdev_dmabuf *q, *gntdev_dmabuf, *ret = ERR_PTR(-ENOENT);
687 list_for_each_entry_safe(gntdev_dmabuf, q, &priv->imp_list, next) {
688 if (gntdev_dmabuf->fd == fd) {
689 pr_debug("Found gntdev_dmabuf in the import list\n");
690 ret = gntdev_dmabuf;
691 list_del(&gntdev_dmabuf->next);
701 struct gntdev_dmabuf *gntdev_dmabuf;
705 gntdev_dmabuf = dmabuf_imp_find_unlink(priv, fd);
706 if (IS_ERR(gntdev_dmabuf))
707 return PTR_ERR(gntdev_dmabuf);
711 dmabuf_imp_end_foreign_access(gntdev_dmabuf->u.imp.refs,
712 gntdev_dmabuf->nr_pages);
714 attach = gntdev_dmabuf->u.imp.attach;
716 if (gntdev_dmabuf->u.imp.sgt)
717 dma_buf_unmap_attachment(attach, gntdev_dmabuf->u.imp.sgt,
723 dmabuf_imp_free_storage(gntdev_dmabuf);
729 struct gntdev_dmabuf *q, *gntdev_dmabuf;
731 list_for_each_entry_safe(gntdev_dmabuf, q, &priv->imp_list, next)
732 dmabuf_imp_release(priv, gntdev_dmabuf->fd);
794 struct gntdev_dmabuf *gntdev_dmabuf;
803 gntdev_dmabuf = dmabuf_imp_to_refs(priv->dmabuf_priv,
806 if (IS_ERR(gntdev_dmabuf))
807 return PTR_ERR(gntdev_dmabuf);
809 if (copy_to_user(u->refs, gntdev_dmabuf->u.imp.refs,