gntdev_dmabuf
obj->gntdev_dmabuf = gntdev_dmabuf;
kref_put(&gntdev_dmabuf->u.exp.refcount, dmabuf_exp_release);
struct gntdev_dmabuf *gntdev_dmabuf)
if (obj->gntdev_dmabuf == gntdev_dmabuf) {
static struct gntdev_dmabuf *
struct gntdev_dmabuf *gntdev_dmabuf, *ret = ERR_PTR(-ENOENT);
list_for_each_entry(gntdev_dmabuf, &priv->exp_list, next)
if (gntdev_dmabuf->fd == fd) {
kref_get(&gntdev_dmabuf->u.exp.refcount);
ret = gntdev_dmabuf;
struct gntdev_dmabuf *gntdev_dmabuf;
gntdev_dmabuf = dmabuf_exp_wait_obj_get_dmabuf(priv, fd);
if (IS_ERR(gntdev_dmabuf))
return PTR_ERR(gntdev_dmabuf);
obj = dmabuf_exp_wait_obj_new(priv, gntdev_dmabuf);
struct gntdev_dmabuf *gntdev_dmabuf = attach->dmabuf->priv;
pr_debug("Mapping %d pages for dev %p\n", gntdev_dmabuf->nr_pages,
sgt = dmabuf_pages_to_sgt(gntdev_dmabuf->pages,
gntdev_dmabuf->nr_pages);
struct gntdev_dmabuf *gntdev_dmabuf =
container_of(kref, struct gntdev_dmabuf, u.exp.refcount);
dmabuf_exp_wait_obj_signal(gntdev_dmabuf->priv, gntdev_dmabuf);
list_del(&gntdev_dmabuf->next);
fput(gntdev_dmabuf->priv->filp);
kfree(gntdev_dmabuf);
struct gntdev_dmabuf *gntdev_dmabuf = dma_buf->priv;
struct gntdev_dmabuf_priv *priv = gntdev_dmabuf->priv;
dmabuf_exp_remove_map(gntdev_dmabuf->u.exp.priv,
gntdev_dmabuf->u.exp.map);
kref_put(&gntdev_dmabuf->u.exp.refcount, dmabuf_exp_release);
struct gntdev_dmabuf *gntdev_dmabuf __free(kfree) = NULL;
gntdev_dmabuf = kzalloc_obj(*gntdev_dmabuf);
if (!gntdev_dmabuf)
kref_init(&gntdev_dmabuf->u.exp.refcount);
gntdev_dmabuf->priv = args->dmabuf_priv;
gntdev_dmabuf->nr_pages = args->count;
gntdev_dmabuf->pages = args->pages;
gntdev_dmabuf->u.exp.priv = args->priv;
gntdev_dmabuf->u.exp.map = args->map;
exp_info.priv = gntdev_dmabuf;
gntdev_dmabuf->dmabuf = dma_buf_export(&exp_info);
if (IS_ERR(gntdev_dmabuf->dmabuf))
return PTR_ERR(gntdev_dmabuf->dmabuf);
gntdev_dmabuf->fd = ret;
get_file(gntdev_dmabuf->priv->filp);
list_add(&gntdev_dmabuf->next, &args->dmabuf_priv->exp_list);
fd_install(take_fd(ret), no_free_ptr(gntdev_dmabuf)->dmabuf->file);
static void dmabuf_imp_free_storage(struct gntdev_dmabuf *gntdev_dmabuf)
kfree(gntdev_dmabuf->u.imp.refs);
kfree(gntdev_dmabuf);
static struct gntdev_dmabuf *dmabuf_imp_alloc_storage(int count)
struct gntdev_dmabuf *gntdev_dmabuf;
gntdev_dmabuf = kzalloc_obj(*gntdev_dmabuf);
if (!gntdev_dmabuf)
gntdev_dmabuf->u.imp.refs = kzalloc_objs(gntdev_dmabuf->u.imp.refs[0],
if (!gntdev_dmabuf->u.imp.refs)
gntdev_dmabuf->nr_pages = count;
gntdev_dmabuf->u.imp.refs[i] = INVALID_GRANT_REF;
return gntdev_dmabuf;
dmabuf_imp_free_storage(gntdev_dmabuf);
static struct gntdev_dmabuf *
struct gntdev_dmabuf *gntdev_dmabuf, *ret;
gntdev_dmabuf = dmabuf_imp_alloc_storage(count);
if (IS_ERR(gntdev_dmabuf)) {
ret = gntdev_dmabuf;
gntdev_dmabuf->priv = priv;
gntdev_dmabuf->fd = fd;
gntdev_dmabuf->u.imp.attach = attach;
struct gntdev_dmabuf *gntdev_dmabuf;
if (attach->dmabuf->size != gntdev_dmabuf->nr_pages << PAGE_SHIFT) {
attach->dmabuf->size, gntdev_dmabuf->nr_pages);
gntdev_dmabuf->u.imp.sgt = sgt;
gntdev_dmabuf->u.imp.refs,
list_add(&gntdev_dmabuf->next, &priv->imp_list);
return gntdev_dmabuf;
dmabuf_imp_end_foreign_access(gntdev_dmabuf->u.imp.refs, count);
dmabuf_imp_free_storage(gntdev_dmabuf);
static struct gntdev_dmabuf *
struct gntdev_dmabuf *q, *gntdev_dmabuf, *ret = ERR_PTR(-ENOENT);
list_for_each_entry_safe(gntdev_dmabuf, q, &priv->imp_list, next) {
if (gntdev_dmabuf->fd == fd) {
ret = gntdev_dmabuf;
list_del(&gntdev_dmabuf->next);
struct gntdev_dmabuf *gntdev_dmabuf;
gntdev_dmabuf = dmabuf_imp_find_unlink(priv, fd);
if (IS_ERR(gntdev_dmabuf))
return PTR_ERR(gntdev_dmabuf);
dmabuf_imp_end_foreign_access(gntdev_dmabuf->u.imp.refs,
gntdev_dmabuf->nr_pages);
attach = gntdev_dmabuf->u.imp.attach;
if (gntdev_dmabuf->u.imp.sgt)
dma_buf_unmap_attachment_unlocked(attach, gntdev_dmabuf->u.imp.sgt,
dmabuf_imp_free_storage(gntdev_dmabuf);
struct gntdev_dmabuf *q, *gntdev_dmabuf;
list_for_each_entry_safe(gntdev_dmabuf, q, &priv->imp_list, next)
dmabuf_imp_release(priv, gntdev_dmabuf->fd);
struct gntdev_dmabuf *gntdev_dmabuf;
gntdev_dmabuf = dmabuf_imp_to_refs(priv->dmabuf_priv,
if (IS_ERR(gntdev_dmabuf))
return PTR_ERR(gntdev_dmabuf);
if (copy_to_user(u->refs, gntdev_dmabuf->u.imp.refs,
struct gntdev_dmabuf *gntdev_dmabuf)