Lines Matching refs:mtk_gem
42 struct mtk_drm_gem_obj *mtk_gem; in mtk_drm_gem_create() local
46 mtk_gem = mtk_drm_gem_init(dev, size); in mtk_drm_gem_create()
47 if (IS_ERR(mtk_gem)) in mtk_drm_gem_create()
48 return ERR_CAST(mtk_gem); in mtk_drm_gem_create()
50 obj = &mtk_gem->base; in mtk_drm_gem_create()
52 mtk_gem->dma_attrs = DMA_ATTR_WRITE_COMBINE; in mtk_drm_gem_create()
55 mtk_gem->dma_attrs |= DMA_ATTR_NO_KERNEL_MAPPING; in mtk_drm_gem_create()
57 mtk_gem->cookie = dma_alloc_attrs(priv->dma_dev, obj->size, in mtk_drm_gem_create()
58 &mtk_gem->dma_addr, GFP_KERNEL, in mtk_drm_gem_create()
59 mtk_gem->dma_attrs); in mtk_drm_gem_create()
60 if (!mtk_gem->cookie) { in mtk_drm_gem_create()
67 mtk_gem->kvaddr = mtk_gem->cookie; in mtk_drm_gem_create()
70 mtk_gem->cookie, &mtk_gem->dma_addr, in mtk_drm_gem_create()
73 return mtk_gem; in mtk_drm_gem_create()
77 kfree(mtk_gem); in mtk_drm_gem_create()
83 struct mtk_drm_gem_obj *mtk_gem = to_mtk_gem_obj(obj); in mtk_drm_gem_free_object() local
86 if (mtk_gem->sg) in mtk_drm_gem_free_object()
87 drm_prime_gem_destroy(obj, mtk_gem->sg); in mtk_drm_gem_free_object()
89 dma_free_attrs(priv->dma_dev, obj->size, mtk_gem->cookie, in mtk_drm_gem_free_object()
90 mtk_gem->dma_addr, mtk_gem->dma_attrs); in mtk_drm_gem_free_object()
95 kfree(mtk_gem); in mtk_drm_gem_free_object()
101 struct mtk_drm_gem_obj *mtk_gem; in mtk_drm_gem_dumb_create() local
107 mtk_gem = mtk_drm_gem_create(dev, args->size, false); in mtk_drm_gem_dumb_create()
108 if (IS_ERR(mtk_gem)) in mtk_drm_gem_dumb_create()
109 return PTR_ERR(mtk_gem); in mtk_drm_gem_dumb_create()
115 ret = drm_gem_handle_create(file_priv, &mtk_gem->base, &args->handle); in mtk_drm_gem_dumb_create()
120 drm_gem_object_put_unlocked(&mtk_gem->base); in mtk_drm_gem_dumb_create()
125 mtk_drm_gem_free_object(&mtk_gem->base); in mtk_drm_gem_dumb_create()
134 struct mtk_drm_gem_obj *mtk_gem = to_mtk_gem_obj(obj); in mtk_drm_gem_object_mmap() local
143 ret = dma_mmap_attrs(priv->dma_dev, vma, mtk_gem->cookie, in mtk_drm_gem_object_mmap()
144 mtk_gem->dma_addr, obj->size, mtk_gem->dma_attrs); in mtk_drm_gem_object_mmap()
190 struct mtk_drm_gem_obj *mtk_gem = to_mtk_gem_obj(obj); in mtk_gem_prime_get_sg_table() local
199 ret = dma_get_sgtable_attrs(priv->dma_dev, sgt, mtk_gem->cookie, in mtk_gem_prime_get_sg_table()
200 mtk_gem->dma_addr, obj->size, in mtk_gem_prime_get_sg_table()
201 mtk_gem->dma_attrs); in mtk_gem_prime_get_sg_table()
214 struct mtk_drm_gem_obj *mtk_gem; in mtk_gem_prime_import_sg_table() local
220 mtk_gem = mtk_drm_gem_init(dev, attach->dmabuf->size); in mtk_gem_prime_import_sg_table()
222 if (IS_ERR(mtk_gem)) in mtk_gem_prime_import_sg_table()
223 return ERR_CAST(mtk_gem); in mtk_gem_prime_import_sg_table()
235 mtk_gem->dma_addr = sg_dma_address(sg->sgl); in mtk_gem_prime_import_sg_table()
236 mtk_gem->sg = sg; in mtk_gem_prime_import_sg_table()
238 return &mtk_gem->base; in mtk_gem_prime_import_sg_table()
241 kfree(mtk_gem); in mtk_gem_prime_import_sg_table()
247 struct mtk_drm_gem_obj *mtk_gem = to_mtk_gem_obj(obj); in mtk_drm_gem_prime_vmap() local
253 if (mtk_gem->kvaddr) in mtk_drm_gem_prime_vmap()
254 return mtk_gem->kvaddr; in mtk_drm_gem_prime_vmap()
261 mtk_gem->pages = kcalloc(npages, sizeof(*mtk_gem->pages), GFP_KERNEL); in mtk_drm_gem_prime_vmap()
262 if (!mtk_gem->pages) in mtk_drm_gem_prime_vmap()
266 mtk_gem->pages[i++] = sg_page_iter_page(&iter); in mtk_drm_gem_prime_vmap()
270 mtk_gem->kvaddr = vmap(mtk_gem->pages, npages, VM_MAP, in mtk_drm_gem_prime_vmap()
276 return mtk_gem->kvaddr; in mtk_drm_gem_prime_vmap()
281 struct mtk_drm_gem_obj *mtk_gem = to_mtk_gem_obj(obj); in mtk_drm_gem_prime_vunmap() local
283 if (!mtk_gem->pages) in mtk_drm_gem_prime_vunmap()
287 mtk_gem->kvaddr = 0; in mtk_drm_gem_prime_vunmap()
288 kfree((void *)mtk_gem->pages); in mtk_drm_gem_prime_vunmap()