Lines Matching refs:exynos_gem
20 static int exynos_drm_alloc_buf(struct exynos_drm_gem *exynos_gem) in exynos_drm_alloc_buf() argument
22 struct drm_device *dev = exynos_gem->base.dev; in exynos_drm_alloc_buf()
28 if (exynos_gem->dma_addr) { in exynos_drm_alloc_buf()
33 exynos_gem->dma_attrs = 0; in exynos_drm_alloc_buf()
40 if (!(exynos_gem->flags & EXYNOS_BO_NONCONTIG)) in exynos_drm_alloc_buf()
41 exynos_gem->dma_attrs |= DMA_ATTR_FORCE_CONTIGUOUS; in exynos_drm_alloc_buf()
47 if (exynos_gem->flags & EXYNOS_BO_WC || in exynos_drm_alloc_buf()
48 !(exynos_gem->flags & EXYNOS_BO_CACHABLE)) in exynos_drm_alloc_buf()
53 exynos_gem->dma_attrs |= attr; in exynos_drm_alloc_buf()
54 exynos_gem->dma_attrs |= DMA_ATTR_NO_KERNEL_MAPPING; in exynos_drm_alloc_buf()
56 nr_pages = exynos_gem->size >> PAGE_SHIFT; in exynos_drm_alloc_buf()
58 exynos_gem->pages = kvmalloc_array(nr_pages, sizeof(struct page *), in exynos_drm_alloc_buf()
60 if (!exynos_gem->pages) { in exynos_drm_alloc_buf()
65 exynos_gem->cookie = dma_alloc_attrs(to_dma_dev(dev), exynos_gem->size, in exynos_drm_alloc_buf()
66 &exynos_gem->dma_addr, GFP_KERNEL, in exynos_drm_alloc_buf()
67 exynos_gem->dma_attrs); in exynos_drm_alloc_buf()
68 if (!exynos_gem->cookie) { in exynos_drm_alloc_buf()
73 ret = dma_get_sgtable_attrs(to_dma_dev(dev), &sgt, exynos_gem->cookie, in exynos_drm_alloc_buf()
74 exynos_gem->dma_addr, exynos_gem->size, in exynos_drm_alloc_buf()
75 exynos_gem->dma_attrs); in exynos_drm_alloc_buf()
81 if (drm_prime_sg_to_page_addr_arrays(&sgt, exynos_gem->pages, NULL, in exynos_drm_alloc_buf()
91 (unsigned long)exynos_gem->dma_addr, exynos_gem->size); in exynos_drm_alloc_buf()
98 dma_free_attrs(to_dma_dev(dev), exynos_gem->size, exynos_gem->cookie, in exynos_drm_alloc_buf()
99 exynos_gem->dma_addr, exynos_gem->dma_attrs); in exynos_drm_alloc_buf()
101 kvfree(exynos_gem->pages); in exynos_drm_alloc_buf()
106 static void exynos_drm_free_buf(struct exynos_drm_gem *exynos_gem) in exynos_drm_free_buf() argument
108 struct drm_device *dev = exynos_gem->base.dev; in exynos_drm_free_buf()
110 if (!exynos_gem->dma_addr) { in exynos_drm_free_buf()
116 (unsigned long)exynos_gem->dma_addr, exynos_gem->size); in exynos_drm_free_buf()
118 dma_free_attrs(to_dma_dev(dev), exynos_gem->size, exynos_gem->cookie, in exynos_drm_free_buf()
119 (dma_addr_t)exynos_gem->dma_addr, in exynos_drm_free_buf()
120 exynos_gem->dma_attrs); in exynos_drm_free_buf()
122 kvfree(exynos_gem->pages); in exynos_drm_free_buf()
147 void exynos_drm_gem_destroy(struct exynos_drm_gem *exynos_gem) in exynos_drm_gem_destroy() argument
149 struct drm_gem_object *obj = &exynos_gem->base; in exynos_drm_gem_destroy()
161 drm_prime_gem_destroy(obj, exynos_gem->sgt); in exynos_drm_gem_destroy()
163 exynos_drm_free_buf(exynos_gem); in exynos_drm_gem_destroy()
168 kfree(exynos_gem); in exynos_drm_gem_destroy()
174 struct exynos_drm_gem *exynos_gem; in exynos_drm_gem_init() local
178 exynos_gem = kzalloc(sizeof(*exynos_gem), GFP_KERNEL); in exynos_drm_gem_init()
179 if (!exynos_gem) in exynos_drm_gem_init()
182 exynos_gem->size = size; in exynos_drm_gem_init()
183 obj = &exynos_gem->base; in exynos_drm_gem_init()
188 kfree(exynos_gem); in exynos_drm_gem_init()
195 kfree(exynos_gem); in exynos_drm_gem_init()
201 return exynos_gem; in exynos_drm_gem_init()
208 struct exynos_drm_gem *exynos_gem; in exynos_drm_gem_create() local
224 exynos_gem = exynos_drm_gem_init(dev, size); in exynos_drm_gem_create()
225 if (IS_ERR(exynos_gem)) in exynos_drm_gem_create()
226 return exynos_gem; in exynos_drm_gem_create()
238 exynos_gem->flags = flags; in exynos_drm_gem_create()
240 ret = exynos_drm_alloc_buf(exynos_gem); in exynos_drm_gem_create()
242 drm_gem_object_release(&exynos_gem->base); in exynos_drm_gem_create()
243 kfree(exynos_gem); in exynos_drm_gem_create()
247 return exynos_gem; in exynos_drm_gem_create()
254 struct exynos_drm_gem *exynos_gem; in exynos_drm_gem_create_ioctl() local
257 exynos_gem = exynos_drm_gem_create(dev, args->flags, args->size); in exynos_drm_gem_create_ioctl()
258 if (IS_ERR(exynos_gem)) in exynos_drm_gem_create_ioctl()
259 return PTR_ERR(exynos_gem); in exynos_drm_gem_create_ioctl()
261 ret = exynos_drm_gem_handle_create(&exynos_gem->base, file_priv, in exynos_drm_gem_create_ioctl()
264 exynos_drm_gem_destroy(exynos_gem); in exynos_drm_gem_create_ioctl()
291 static int exynos_drm_gem_mmap_buffer(struct exynos_drm_gem *exynos_gem, in exynos_drm_gem_mmap_buffer() argument
294 struct drm_device *drm_dev = exynos_gem->base.dev; in exynos_drm_gem_mmap_buffer()
304 if (vm_size > exynos_gem->size) in exynos_drm_gem_mmap_buffer()
307 ret = dma_mmap_attrs(to_dma_dev(drm_dev), vma, exynos_gem->cookie, in exynos_drm_gem_mmap_buffer()
308 exynos_gem->dma_addr, exynos_gem->size, in exynos_drm_gem_mmap_buffer()
309 exynos_gem->dma_attrs); in exynos_drm_gem_mmap_buffer()
321 struct exynos_drm_gem *exynos_gem; in exynos_drm_gem_get_ioctl() local
331 exynos_gem = to_exynos_gem(obj); in exynos_drm_gem_get_ioctl()
333 args->flags = exynos_gem->flags; in exynos_drm_gem_get_ioctl()
334 args->size = exynos_gem->size; in exynos_drm_gem_get_ioctl()
350 struct exynos_drm_gem *exynos_gem; in exynos_drm_gem_dumb_create() local
368 exynos_gem = exynos_drm_gem_create(dev, flags, args->size); in exynos_drm_gem_dumb_create()
369 if (IS_ERR(exynos_gem)) { in exynos_drm_gem_dumb_create()
371 return PTR_ERR(exynos_gem); in exynos_drm_gem_dumb_create()
374 ret = exynos_drm_gem_handle_create(&exynos_gem->base, file_priv, in exynos_drm_gem_dumb_create()
377 exynos_drm_gem_destroy(exynos_gem); in exynos_drm_gem_dumb_create()
388 struct exynos_drm_gem *exynos_gem = to_exynos_gem(obj); in exynos_drm_gem_fault() local
394 if (page_offset >= (exynos_gem->size >> PAGE_SHIFT)) { in exynos_drm_gem_fault()
399 pfn = page_to_pfn(exynos_gem->pages[page_offset]); in exynos_drm_gem_fault()
407 struct exynos_drm_gem *exynos_gem = to_exynos_gem(obj); in exynos_drm_gem_mmap_obj() local
411 exynos_gem->flags); in exynos_drm_gem_mmap_obj()
414 if (exynos_gem->flags & EXYNOS_BO_CACHABLE) in exynos_drm_gem_mmap_obj()
416 else if (exynos_gem->flags & EXYNOS_BO_WC) in exynos_drm_gem_mmap_obj()
423 ret = exynos_drm_gem_mmap_buffer(exynos_gem, vma); in exynos_drm_gem_mmap_obj()
464 struct exynos_drm_gem *exynos_gem = to_exynos_gem(obj); in exynos_drm_gem_prime_get_sg_table() local
467 npages = exynos_gem->size >> PAGE_SHIFT; in exynos_drm_gem_prime_get_sg_table()
469 return drm_prime_pages_to_sg(exynos_gem->pages, npages); in exynos_drm_gem_prime_get_sg_table()
477 struct exynos_drm_gem *exynos_gem; in exynos_drm_gem_prime_import_sg_table() local
481 exynos_gem = exynos_drm_gem_init(dev, attach->dmabuf->size); in exynos_drm_gem_prime_import_sg_table()
482 if (IS_ERR(exynos_gem)) { in exynos_drm_gem_prime_import_sg_table()
483 ret = PTR_ERR(exynos_gem); in exynos_drm_gem_prime_import_sg_table()
487 exynos_gem->dma_addr = sg_dma_address(sgt->sgl); in exynos_drm_gem_prime_import_sg_table()
489 npages = exynos_gem->size >> PAGE_SHIFT; in exynos_drm_gem_prime_import_sg_table()
490 exynos_gem->pages = kvmalloc_array(npages, sizeof(struct page *), GFP_KERNEL); in exynos_drm_gem_prime_import_sg_table()
491 if (!exynos_gem->pages) { in exynos_drm_gem_prime_import_sg_table()
496 ret = drm_prime_sg_to_page_addr_arrays(sgt, exynos_gem->pages, NULL, in exynos_drm_gem_prime_import_sg_table()
501 exynos_gem->sgt = sgt; in exynos_drm_gem_prime_import_sg_table()
505 exynos_gem->flags |= EXYNOS_BO_CONTIG; in exynos_drm_gem_prime_import_sg_table()
513 exynos_gem->flags |= EXYNOS_BO_NONCONTIG; in exynos_drm_gem_prime_import_sg_table()
516 return &exynos_gem->base; in exynos_drm_gem_prime_import_sg_table()
519 kvfree(exynos_gem->pages); in exynos_drm_gem_prime_import_sg_table()
521 drm_gem_object_release(&exynos_gem->base); in exynos_drm_gem_prime_import_sg_table()
522 kfree(exynos_gem); in exynos_drm_gem_prime_import_sg_table()