Lines Matching refs:exynos_gem
24 static int exynos_drm_alloc_buf(struct exynos_drm_gem *exynos_gem) in exynos_drm_alloc_buf() argument
26 struct drm_device *dev = exynos_gem->base.dev; in exynos_drm_alloc_buf()
32 if (exynos_gem->dma_addr) { in exynos_drm_alloc_buf()
37 exynos_gem->dma_attrs = 0; in exynos_drm_alloc_buf()
44 if (!(exynos_gem->flags & EXYNOS_BO_NONCONTIG)) in exynos_drm_alloc_buf()
45 exynos_gem->dma_attrs |= DMA_ATTR_FORCE_CONTIGUOUS; in exynos_drm_alloc_buf()
51 if (exynos_gem->flags & EXYNOS_BO_WC || in exynos_drm_alloc_buf()
52 !(exynos_gem->flags & EXYNOS_BO_CACHABLE)) in exynos_drm_alloc_buf()
57 exynos_gem->dma_attrs |= attr; in exynos_drm_alloc_buf()
58 exynos_gem->dma_attrs |= DMA_ATTR_NO_KERNEL_MAPPING; in exynos_drm_alloc_buf()
60 nr_pages = exynos_gem->size >> PAGE_SHIFT; in exynos_drm_alloc_buf()
62 exynos_gem->pages = kvmalloc_array(nr_pages, sizeof(struct page *), in exynos_drm_alloc_buf()
64 if (!exynos_gem->pages) { in exynos_drm_alloc_buf()
69 exynos_gem->cookie = dma_alloc_attrs(to_dma_dev(dev), exynos_gem->size, in exynos_drm_alloc_buf()
70 &exynos_gem->dma_addr, GFP_KERNEL, in exynos_drm_alloc_buf()
71 exynos_gem->dma_attrs); in exynos_drm_alloc_buf()
72 if (!exynos_gem->cookie) { in exynos_drm_alloc_buf()
77 ret = dma_get_sgtable_attrs(to_dma_dev(dev), &sgt, exynos_gem->cookie, in exynos_drm_alloc_buf()
78 exynos_gem->dma_addr, exynos_gem->size, in exynos_drm_alloc_buf()
79 exynos_gem->dma_attrs); in exynos_drm_alloc_buf()
85 if (drm_prime_sg_to_page_addr_arrays(&sgt, exynos_gem->pages, NULL, in exynos_drm_alloc_buf()
95 (unsigned long)exynos_gem->dma_addr, exynos_gem->size); in exynos_drm_alloc_buf()
102 dma_free_attrs(to_dma_dev(dev), exynos_gem->size, exynos_gem->cookie, in exynos_drm_alloc_buf()
103 exynos_gem->dma_addr, exynos_gem->dma_attrs); in exynos_drm_alloc_buf()
105 kvfree(exynos_gem->pages); in exynos_drm_alloc_buf()
110 static void exynos_drm_free_buf(struct exynos_drm_gem *exynos_gem) in exynos_drm_free_buf() argument
112 struct drm_device *dev = exynos_gem->base.dev; in exynos_drm_free_buf()
114 if (!exynos_gem->dma_addr) { in exynos_drm_free_buf()
120 (unsigned long)exynos_gem->dma_addr, exynos_gem->size); in exynos_drm_free_buf()
122 dma_free_attrs(to_dma_dev(dev), exynos_gem->size, exynos_gem->cookie, in exynos_drm_free_buf()
123 (dma_addr_t)exynos_gem->dma_addr, in exynos_drm_free_buf()
124 exynos_gem->dma_attrs); in exynos_drm_free_buf()
126 kvfree(exynos_gem->pages); in exynos_drm_free_buf()
151 void exynos_drm_gem_destroy(struct exynos_drm_gem *exynos_gem) in exynos_drm_gem_destroy() argument
153 struct drm_gem_object *obj = &exynos_gem->base; in exynos_drm_gem_destroy()
164 drm_prime_gem_destroy(obj, exynos_gem->sgt); in exynos_drm_gem_destroy()
166 exynos_drm_free_buf(exynos_gem); in exynos_drm_gem_destroy()
171 kfree(exynos_gem); in exynos_drm_gem_destroy()
177 struct exynos_drm_gem *exynos_gem; in exynos_drm_gem_init() local
181 exynos_gem = kzalloc(sizeof(*exynos_gem), GFP_KERNEL); in exynos_drm_gem_init()
182 if (!exynos_gem) in exynos_drm_gem_init()
185 exynos_gem->size = size; in exynos_drm_gem_init()
186 obj = &exynos_gem->base; in exynos_drm_gem_init()
191 kfree(exynos_gem); in exynos_drm_gem_init()
198 kfree(exynos_gem); in exynos_drm_gem_init()
204 return exynos_gem; in exynos_drm_gem_init()
211 struct exynos_drm_gem *exynos_gem; in exynos_drm_gem_create() local
226 exynos_gem = exynos_drm_gem_init(dev, size); in exynos_drm_gem_create()
227 if (IS_ERR(exynos_gem)) in exynos_drm_gem_create()
228 return exynos_gem; in exynos_drm_gem_create()
240 exynos_gem->flags = flags; in exynos_drm_gem_create()
242 ret = exynos_drm_alloc_buf(exynos_gem); in exynos_drm_gem_create()
244 drm_gem_object_release(&exynos_gem->base); in exynos_drm_gem_create()
245 kfree(exynos_gem); in exynos_drm_gem_create()
249 return exynos_gem; in exynos_drm_gem_create()
256 struct exynos_drm_gem *exynos_gem; in exynos_drm_gem_create_ioctl() local
259 exynos_gem = exynos_drm_gem_create(dev, args->flags, args->size); in exynos_drm_gem_create_ioctl()
260 if (IS_ERR(exynos_gem)) in exynos_drm_gem_create_ioctl()
261 return PTR_ERR(exynos_gem); in exynos_drm_gem_create_ioctl()
263 ret = exynos_drm_gem_handle_create(&exynos_gem->base, file_priv, in exynos_drm_gem_create_ioctl()
266 exynos_drm_gem_destroy(exynos_gem); in exynos_drm_gem_create_ioctl()
293 static int exynos_drm_gem_mmap_buffer(struct exynos_drm_gem *exynos_gem, in exynos_drm_gem_mmap_buffer() argument
296 struct drm_device *drm_dev = exynos_gem->base.dev; in exynos_drm_gem_mmap_buffer()
306 if (vm_size > exynos_gem->size) in exynos_drm_gem_mmap_buffer()
309 ret = dma_mmap_attrs(to_dma_dev(drm_dev), vma, exynos_gem->cookie, in exynos_drm_gem_mmap_buffer()
310 exynos_gem->dma_addr, exynos_gem->size, in exynos_drm_gem_mmap_buffer()
311 exynos_gem->dma_attrs); in exynos_drm_gem_mmap_buffer()
323 struct exynos_drm_gem *exynos_gem; in exynos_drm_gem_get_ioctl() local
333 exynos_gem = to_exynos_gem(obj); in exynos_drm_gem_get_ioctl()
335 args->flags = exynos_gem->flags; in exynos_drm_gem_get_ioctl()
336 args->size = exynos_gem->size; in exynos_drm_gem_get_ioctl()
352 struct exynos_drm_gem *exynos_gem; in exynos_drm_gem_dumb_create() local
370 exynos_gem = exynos_drm_gem_create(dev, flags, args->size); in exynos_drm_gem_dumb_create()
371 if (IS_ERR(exynos_gem)) { in exynos_drm_gem_dumb_create()
373 return PTR_ERR(exynos_gem); in exynos_drm_gem_dumb_create()
376 ret = exynos_drm_gem_handle_create(&exynos_gem->base, file_priv, in exynos_drm_gem_dumb_create()
379 exynos_drm_gem_destroy(exynos_gem); in exynos_drm_gem_dumb_create()
390 struct exynos_drm_gem *exynos_gem = to_exynos_gem(obj); in exynos_drm_gem_fault() local
396 if (page_offset >= (exynos_gem->size >> PAGE_SHIFT)) { in exynos_drm_gem_fault()
401 pfn = page_to_pfn(exynos_gem->pages[page_offset]); in exynos_drm_gem_fault()
409 struct exynos_drm_gem *exynos_gem = to_exynos_gem(obj); in exynos_drm_gem_mmap_obj() local
412 DRM_DEBUG_KMS("flags = 0x%x\n", exynos_gem->flags); in exynos_drm_gem_mmap_obj()
415 if (exynos_gem->flags & EXYNOS_BO_CACHABLE) in exynos_drm_gem_mmap_obj()
417 else if (exynos_gem->flags & EXYNOS_BO_WC) in exynos_drm_gem_mmap_obj()
424 ret = exynos_drm_gem_mmap_buffer(exynos_gem, vma); in exynos_drm_gem_mmap_obj()
465 struct exynos_drm_gem *exynos_gem = to_exynos_gem(obj); in exynos_drm_gem_prime_get_sg_table() local
468 npages = exynos_gem->size >> PAGE_SHIFT; in exynos_drm_gem_prime_get_sg_table()
470 return drm_prime_pages_to_sg(exynos_gem->pages, npages); in exynos_drm_gem_prime_get_sg_table()
478 struct exynos_drm_gem *exynos_gem; in exynos_drm_gem_prime_import_sg_table() local
482 exynos_gem = exynos_drm_gem_init(dev, attach->dmabuf->size); in exynos_drm_gem_prime_import_sg_table()
483 if (IS_ERR(exynos_gem)) { in exynos_drm_gem_prime_import_sg_table()
484 ret = PTR_ERR(exynos_gem); in exynos_drm_gem_prime_import_sg_table()
488 exynos_gem->dma_addr = sg_dma_address(sgt->sgl); in exynos_drm_gem_prime_import_sg_table()
490 npages = exynos_gem->size >> PAGE_SHIFT; in exynos_drm_gem_prime_import_sg_table()
491 exynos_gem->pages = kvmalloc_array(npages, sizeof(struct page *), GFP_KERNEL); in exynos_drm_gem_prime_import_sg_table()
492 if (!exynos_gem->pages) { in exynos_drm_gem_prime_import_sg_table()
497 ret = drm_prime_sg_to_page_addr_arrays(sgt, exynos_gem->pages, NULL, in exynos_drm_gem_prime_import_sg_table()
502 exynos_gem->sgt = sgt; in exynos_drm_gem_prime_import_sg_table()
506 exynos_gem->flags |= EXYNOS_BO_CONTIG; in exynos_drm_gem_prime_import_sg_table()
514 exynos_gem->flags |= EXYNOS_BO_NONCONTIG; in exynos_drm_gem_prime_import_sg_table()
517 return &exynos_gem->base; in exynos_drm_gem_prime_import_sg_table()
520 kvfree(exynos_gem->pages); in exynos_drm_gem_prime_import_sg_table()
522 drm_gem_object_release(&exynos_gem->base); in exynos_drm_gem_prime_import_sg_table()
523 kfree(exynos_gem); in exynos_drm_gem_prime_import_sg_table()