drm/exynos: update codes related with gem
Subsystems (4)
cover drm/exynos: update codes related with gem
Hi,
This patchset is about gem codes update of exynos-drm.
The first and second patches are cleanup to remove useless codes. The rest is to support cachable gem allocation.
The exynos-drm uses DMA mapping API to allocate/mmap buffer of gem. If it is cachable, does it with DMA_ATTR_NON_CONSISTENT attribute, but DMA_ATTR_NON_CONSISTENT isn't supported in DMA mapping API of ARM, so it doesn't give any effects.
This patchset introduces new buffer allocation to use drm_gem_get/put_pages() instead of DMA mapping API. It will be used for the rest except allocation of physically continuous buffer on non-iommu, then exynos-drm can support cachable buffer of gem. Also it can support physically non-continuous buffer on non-iommu.
EXYNOS_BO_CONTIG flag on iommu is ambiguous because it doesn't care whether buffer is continuous physically if iommu is supported. This patchset always will use EXYNOS_BO_CONTIG flag on iommu and then can mean that the buffer is continuous for device.
There is no user API to control cache coherence for the cpu and device about cachable buffer. This patchset introduces two ioctls for cpu access of gem object from user. It will be synced properly in order for the cpu and device if buffer of gem object is cachable.
Thanks.
Joonyoung Shim (9):
drm/exynos: eliminate useless codes of exynos_drm_gem.h drm/exynos: use directly DMA mapping APIs on g2d drm/exynos: remove using non-consistent DMA attribute drm/exynos: split buffer allocation using DMA mapping API on non-iommu drm/exynos: introduce buffer allocation using drm_gem_get/put_pages() drm/exynos: switch to new buffer allocation
drm/exynos: always use EXYNOS_BO_CONTIG flag on iommu drm/exynos: use DMA_ERROR_CODE
drm/exynos: add ioctls for cpu access of gem object from user
drivers/gpu/drm/exynos/exynos_drm_drv.c | 4 + drivers/gpu/drm/exynos/exynos_drm_fb.c | 32 +--- drivers/gpu/drm/exynos/exynos_drm_fbdev.c | 14 +- drivers/gpu/drm/exynos/exynos_drm_g2d.c | 10 +- drivers/gpu/drm/exynos/exynos_drm_gem.c | 288 ++++++++++++++++++------------ drivers/gpu/drm/exynos/exynos_drm_gem.h | 56 ++---- include/uapi/drm/exynos_drm.h | 23 ++- 7 files changed, 225 insertions(+), 202 deletions(-)
Signature · 6 lines
1.9.1 _______________________________________________ dri-devel mailing list [email protected] http://lists.freedesktop.org/mailman/listinfo/dri-devel
PATCH 1/9 drm/exynos: eliminate useless codes of exynos_drm_gem.h
This eliminates declaration of functions that is removed by the commit 63540f01917c ("[media] drm/exynos: Convert g2d_userptr_get_dma_addr() to use get_vaddr_frames()") and eliminate vma_is_io() that isn't used anywhere now.
Also remove exynos_gem_get_pages() and exynos_drm_gem_userptr_ioctl(), there is no body for them.
--- drivers/gpu/drm/exynos/exynos_drm_gem.h | 28 ---------------------------- 1 file changed, 28 deletions(-)
drivers/gpu/drm/exynos/exynos_drm_gem.h +0 -28
@@ -55,8 +55,6 @@ struct exynos_drm_gem {struct sg_table *sgt; }; -struct page **exynos_gem_get_pages (struct drm_gem_object *obj,gfp_t gfpmask); -/* destroy a buffer with gem object */ void exynos_drm_gem_destroy (struct exynos_drm_gem *exynos_gem);
@@ -95,10 +93,6 @@ void exynos_drm_gem_put_dma_addr(struct drm_device *dev,unsigned int gem_handle, struct drm_file *filp); -/* map user space allocated by malloc to pages. */ -int exynos_drm_gem_userptr_ioctl (struct drm_device *dev,void *data, -struct drm_file *file_priv); -/* get buffer information to memory region allocated by gem. */ int exynos_drm_gem_get_ioctl (struct drm_device *dev,void *data,struct drm_file *file_priv);
@@ -127,28 +121,6 @@ int exynos_drm_gem_fault(struct vm_area_struct *vma, struct vm_fault *vmf);/* set vm_flags and we can change the vm attribute to other one at here. */ int exynos_drm_gem_mmap (struct file *filp,struct vm_area_struct *vma); -static inline int vma_is_io (struct vm_area_struct *vma) -{ -return !!(vma->vm_flags & (VM_IO |VM_PFNMAP )); -} - -/* get a copy of a virtual memory region. */ -struct vm_area_struct *exynos_gem_get_vma (struct vm_area_struct *vma); - -/* release a userspace virtual memory area. */ -void exynos_gem_put_vma (struct vm_area_struct *vma); - -/* get pages from user space. */ -int exynos_gem_get_pages_from_userptr (unsigned long start, -unsigned int npages, -struct page **pages, -struct vm_area_struct *vma); - -/* drop the reference to pages. */ -void exynos_gem_put_pages_to_userptr (struct page **pages, -unsigned int npages, -struct vm_area_struct *vma); -/* map sgt with dma region. */ int exynos_gem_map_sgt_with_dma(struct drm_device *drm_dev, struct sg_table *sgt,
Signature · 6 lines
1.9.1 _______________________________________________ dri-devel mailing list [email protected] http://lists.freedesktop.org/mailman/listinfo/dri-devel
PATCH 2/9 drm/exynos: use directly DMA mapping APIs on g2d
In reply to Joonyoung ShimThere is no reason to be wapper functions to use DMA mapping APIs. We can use directly DMA mapping APIs without locking and remove the wapper functions.
--- drivers/gpu/drm/exynos/exynos_drm_g2d.c | 10 +++++----- drivers/gpu/drm/exynos/exynos_drm_gem.c | 26 -------------------------- drivers/gpu/drm/exynos/exynos_drm_gem.h | 10 ---------- 3 files changed, 5 insertions(+), 41 deletions(-)
drivers/gpu/drm/exynos/exynos_drm_g2d.c +5 -5
@@ -365,6 +365,7 @@ static void g2d_userptr_put_dma_addr(struct drm_device *drm_dev, {struct g2d_cmdlist_userptr *g2d_userptr = (struct g2d_cmdlist_userptr *)obj; +struct sg_table *sgt;struct page **pages;if (!obj)
@@ -382,8 +383,8 @@ static void g2d_userptr_put_dma_addr(struct drm_device *drm_dev,return ; out: -exynos_gem_unmap_sgt_from_dma (drm_dev, g2d_userptr->sgt, -DMA_BIDIRECTIONAL ); + sgt = g2d_userptr->sgt; +dma_unmap_sg (drm_dev->dev, sgt->sgl, sgt->nents,DMA_BIDIRECTIONAL ); pages =frame_vector_pages (g2d_userptr->vec);if (!IS_ERR (pages)) {
@@ -500,9 +501,8 @@ static dma_addr_t *g2d_userptr_get_dma_addr(struct drm_device *drm_dev, g2d_userptr->sgt = sgt; - ret =exynos_gem_map_sgt_with_dma (drm_dev, g2d_userptr->sgt, -DMA_BIDIRECTIONAL ); -if (ret <0 ) { +if (!dma_map_sg (drm_dev->dev, sgt->sgl, sgt->nents, +DMA_BIDIRECTIONAL )) {DRM_ERROR ("failed to map sgt with dma region.\n" ); goto err_sg_free_table; }
drivers/gpu/drm/exynos/exynos_drm_gem.c +0 -26
@@ -373,32 +373,6 @@ int exynos_drm_gem_get_ioctl(struct drm_device *dev, void *data,return 0 ; } -int exynos_gem_map_sgt_with_dma (struct drm_device *drm_dev, -struct sg_table *sgt, -enum dma_data_direction dir) -{ -int nents; - -mutex_lock (&drm_dev->struct_mutex); - - nents =dma_map_sg (drm_dev->dev, sgt->sgl, sgt->nents, dir); -if (!nents) { -DRM_ERROR ("failed to map sgl with dma.\n" ); -mutex_unlock (&drm_dev->struct_mutex); -return nents; - } - -mutex_unlock (&drm_dev->struct_mutex); -return 0 ; -} - -void exynos_gem_unmap_sgt_from_dma (struct drm_device *drm_dev, -struct sg_table *sgt, -enum dma_data_direction dir) -{ -dma_unmap_sg (drm_dev->dev, sgt->sgl, sgt->nents, dir); -} -void exynos_drm_gem_free_object (struct drm_gem_object *obj) {exynos_drm_gem_destroy (to_exynos_gem (obj));
drivers/gpu/drm/exynos/exynos_drm_gem.h +0 -10
@@ -121,16 +121,6 @@ int exynos_drm_gem_fault(struct vm_area_struct *vma, struct vm_fault *vmf);/* set vm_flags and we can change the vm attribute to other one at here. */ int exynos_drm_gem_mmap (struct file *filp,struct vm_area_struct *vma); -/* map sgt with dma region. */ -int exynos_gem_map_sgt_with_dma (struct drm_device *drm_dev, -struct sg_table *sgt, -enum dma_data_direction dir); - -/* unmap sgt from dma region. */ -void exynos_gem_unmap_sgt_from_dma (struct drm_device *drm_dev, -struct sg_table *sgt, -enum dma_data_direction dir); -/* low-level interface prime helpers */ struct sg_table *exynos_drm_gem_prime_get_sg_table (struct drm_gem_object *obj); struct drm_gem_object *
Signature · 6 lines
1.9.1 _______________________________________________ dri-devel mailing list [email protected] http://lists.freedesktop.org/mailman/listinfo/dri-devel
PATCH 3/9 drm/exynos: remove using non-consistent DMA attribute
In reply to Joonyoung ShimDMA_ATTR_NON_CONSISTENT isn't supported in DMA mapping API of ARM, so it doesn't give any effects to use non-consistent DMA attribute.
--- drivers/gpu/drm/exynos/exynos_drm_gem.c | 7 +------ 1 file changed, 1 insertion(+), 6 deletions(-)
drivers/gpu/drm/exynos/exynos_drm_gem.c +1 -6
@@ -41,15 +41,10 @@ static int exynos_drm_alloc_buf(struct exynos_drm_gem *exynos_gem)if (!(exynos_gem->flags &EXYNOS_BO_NONCONTIG ))dma_set_attr (DMA_ATTR_FORCE_CONTIGUOUS , &exynos_gem->dma_attrs); -/* -* if EXYNOS_BO_WC or EXYNOS_BO_NONCACHABLE, writecombine mapping -* else cachable mapping. -*/ +/* if EXYNOS_BO_WC or EXYNOS_BO_NONCACHABLE, writecombine mapping */ if (exynos_gem->flags &EXYNOS_BO_WC || !(exynos_gem->flags &EXYNOS_BO_CACHABLE )) attr =DMA_ATTR_WRITE_COMBINE ; -else - attr =DMA_ATTR_NON_CONSISTENT ;dma_set_attr (attr, &exynos_gem->dma_attrs);dma_set_attr (DMA_ATTR_NO_KERNEL_MAPPING , &exynos_gem->dma_attrs);
Signature · 6 lines
1.9.1 _______________________________________________ dri-devel mailing list [email protected] http://lists.freedesktop.org/mailman/listinfo/dri-devel
PATCH 4/9 drm/exynos: split buffer allocation using DMA mapping API on non-iommu
In reply to Joonyoung ShimThis introduces new functions to allocate/free buffer using DMA mapping API. Now already exynos-drm uses DMA mapping API to allocate/free buffer but it is used on both iommu and non-iommu, so split it. It will be added new buffer allocation not to use DMA mapping API later.
--- drivers/gpu/drm/exynos/exynos_drm_gem.c | 90 +++++++++++++++++++++++---------- 1 file changed, 64 insertions(+), 26 deletions(-)
drivers/gpu/drm/exynos/exynos_drm_gem.c +64 -26
@@ -20,6 +20,63 @@#include "exynos_drm_gem.h" #include "exynos_drm_iommu.h" +static int exynos_drm_alloc_dma (struct exynos_drm_gem *exynos_gem) +{ +struct drm_device *dev = exynos_gem->base.dev; +unsigned int nr_pages; +unsigned int i; +dma_addr_t addr; + +init_dma_attrs (&exynos_gem->dma_attrs); + +if (exynos_gem->flags &EXYNOS_BO_WC || + !(exynos_gem->flags &EXYNOS_BO_CACHABLE )) +dma_set_attr (DMA_ATTR_WRITE_COMBINE , &exynos_gem->dma_attrs); + +dma_set_attr (DMA_ATTR_NO_KERNEL_MAPPING , &exynos_gem->dma_attrs); + + nr_pages = exynos_gem->size >>PAGE_SHIFT ; + + exynos_gem->pages =drm_calloc_large (nr_pages,sizeof (struct page *)); +if (!exynos_gem->pages) { +DRM_ERROR ("failed to allocate pages\n" ); +return -ENOMEM ; + } + + exynos_gem->cookie =dma_alloc_attrs (dev->dev, exynos_gem->size, + &exynos_gem->dma_addr,GFP_KERNEL , + &exynos_gem->dma_attrs); +if (!exynos_gem->cookie) { +DRM_ERROR ("failed to allocate buffer\n" ); +drm_free_large (exynos_gem->pages); +return -ENOMEM ; + } + + addr = exynos_gem->dma_addr; +for (i =0 ; i < nr_pages; i++) { + exynos_gem->pages[i] = +pfn_to_page (dma_to_pfn (dev->dev, addr)); + addr +=PAGE_SIZE ; + } + +DRM_DEBUG_KMS ("dma_addr(0x%lx), size(0x%lx)\n" , + (unsigned long )exynos_gem->dma_addr, exynos_gem->size); + +return 0 ; +} + +static void exynos_drm_free_dma (struct exynos_drm_gem *exynos_gem) +{ +struct drm_device *dev = exynos_gem->base.dev; + +DRM_DEBUG_KMS ("dma_addr(0x%lx), size(0x%lx)\n" , + (unsigned long )exynos_gem->dma_addr, exynos_gem->size); + +dma_free_attrs (dev->dev, exynos_gem->size, exynos_gem->cookie, + exynos_gem->dma_addr, &exynos_gem->dma_attrs); +drm_free_large (exynos_gem->pages); +} +static int exynos_drm_alloc_buf (struct exynos_drm_gem *exynos_gem) {struct drm_device *dev = exynos_gem->base.dev;
@@ -31,6 +88,9 @@ static int exynos_drm_alloc_buf(struct exynos_drm_gem *exynos_gem)return 0 ; } +if (!is_drm_iommu_supported (dev)) +return exynos_drm_alloc_dma (exynos_gem); +init_dma_attrs (&exynos_gem->dma_attrs);/*
@@ -51,15 +111,6 @@ static int exynos_drm_alloc_buf(struct exynos_drm_gem *exynos_gem) nr_pages = exynos_gem->size >>PAGE_SHIFT ; -if (!is_drm_iommu_supported (dev)) { - exynos_gem->pages =drm_calloc_large (nr_pages, -sizeof (struct page *)); -if (!exynos_gem->pages) { -DRM_ERROR ("failed to allocate pages.\n" ); -return -ENOMEM ; - } - } - exynos_gem->cookie =dma_alloc_attrs (dev->dev, exynos_gem->size, &exynos_gem->dma_addr,GFP_KERNEL , &exynos_gem->dma_attrs);
@@ -70,20 +121,7 @@ static int exynos_drm_alloc_buf(struct exynos_drm_gem *exynos_gem)return -ENOMEM ; } -if (exynos_gem->pages) { -dma_addr_t start_addr; -unsigned int i =0 ; - - start_addr = exynos_gem->dma_addr; -while (i < nr_pages) { - exynos_gem->pages[i] = -pfn_to_page (dma_to_pfn (dev->dev, start_addr)); - start_addr +=PAGE_SIZE ; - i++; - } - }else { - exynos_gem->pages = exynos_gem->cookie; - } + exynos_gem->pages = exynos_gem->cookie;DRM_DEBUG_KMS ("dma_addr(0x%lx), size(0x%lx)\n" , (unsigned long )exynos_gem->dma_addr, exynos_gem->size);
@@ -100,15 +138,15 @@ static void exynos_drm_free_buf(struct exynos_drm_gem *exynos_gem)return ; } +if (!is_drm_iommu_supported (dev)) +return exynos_drm_free_dma (exynos_gem); +DRM_DEBUG_KMS ("dma_addr(0x%lx), size(0x%lx)\n" , (unsigned long )exynos_gem->dma_addr, exynos_gem->size);dma_free_attrs (dev->dev, exynos_gem->size, exynos_gem->cookie, (dma_addr_t )exynos_gem->dma_addr, &exynos_gem->dma_attrs); - -if (!is_drm_iommu_supported (dev)) -drm_free_large (exynos_gem->pages); } static int exynos_drm_gem_handle_create(struct drm_gem_object *obj,
Signature · 6 lines
1.9.1 _______________________________________________ dri-devel mailing list [email protected] http://lists.freedesktop.org/mailman/listinfo/dri-devel
PATCH 5/9 drm/exynos: introduce buffer allocation using drm_gem_get/put_pages()
In reply to Joonyoung ShimThis introduces new functions to allocate/free buffer using drm_gem_get/put_pages() instead of DMA mapping API. They also use sg list to manage pages.
--- drivers/gpu/drm/exynos/exynos_drm_gem.c | 48 +++++++++++++++++++++++++++++++++ drivers/gpu/drm/exynos/exynos_drm_gem.h | 2 +- 2 files changed, 49 insertions(+), 1 deletion(-)
drivers/gpu/drm/exynos/exynos_drm_gem.c +48 -0
@@ -20,6 +20,54 @@#include "exynos_drm_gem.h" #include "exynos_drm_iommu.h" +static int exynos_drm_get_pages (struct exynos_drm_gem *exynos_gem) +{ +struct drm_device *dev = exynos_gem->base.dev; +struct page **pages; +struct sg_table *sgt; +int ret; + + pages =drm_gem_get_pages (&exynos_gem->base); +if (IS_ERR (pages)) +return PTR_ERR (pages); + + sgt =drm_prime_pages_to_sg (pages, exynos_gem->size >>PAGE_SHIFT ); +if (IS_ERR (sgt)) { + ret =PTR_ERR (sgt); + goto err; + } + +if (!dma_map_sg (dev->dev, sgt->sgl, sgt->nents,DMA_BIDIRECTIONAL )) { +sg_free_table (sgt); +kfree (sgt); + ret = -ENOMEM ; + goto err; + } + + exynos_gem->dma_addr =sg_dma_address (sgt->sgl); + exynos_gem->sgt = sgt; + exynos_gem->pages = pages; + +return 0 ; + +err: +drm_gem_put_pages (&exynos_gem->base, pages, false, false); +return ret; +} + +static void exynos_drm_put_pages (struct exynos_drm_gem *exynos_gem) +{ +struct drm_device *dev = exynos_gem->base.dev; +struct sg_table *sgt = exynos_gem->sgt; + +dma_unmap_sg (dev->dev, sgt->sgl, sgt->nents,DMA_BIDIRECTIONAL ); + +sg_free_table (sgt); +kfree (sgt); + +drm_gem_put_pages (&exynos_gem->base, exynos_gem->pages, false, false); +} +static int exynos_drm_alloc_dma (struct exynos_drm_gem *exynos_gem) {struct drm_device *dev = exynos_gem->base.dev;
drivers/gpu/drm/exynos/exynos_drm_gem.h +1 -1
@@ -38,7 +38,7 @@* - this address could be physical address without IOMMU and * device address with IOMMU. * @pages: Array of backing pages. -* @sgt: Imported sg_table. +* @sgt: Converted sg_table of pages or imported sg_table. * * P.S. this object would be transferred to user as kms_bo.handle so * user can access the buffer through kms_bo.handle.
Signature · 6 lines
1.9.1 _______________________________________________ dri-devel mailing list [email protected] http://lists.freedesktop.org/mailman/listinfo/dri-devel
PATCH 6/9 drm/exynos: switch to new buffer allocation
In reply to Joonyoung ShimThe buffer allocation using DMA mapping API can't support non-continuous buffer on non-iommu and cachable buffer, so switch to new buffer allocation using drm_gem_get/put_pages() and doesn't use DMA mapping API for mmap except allocation of physically continuous buffer on non-iommu.
--- drivers/gpu/drm/exynos/exynos_drm_gem.c | 90 +++++++++++---------------------- 1 file changed, 29 insertions(+), 61 deletions(-)
drivers/gpu/drm/exynos/exynos_drm_gem.c +29 -61
@@ -77,10 +77,7 @@ static int exynos_drm_alloc_dma(struct exynos_drm_gem *exynos_gem)init_dma_attrs (&exynos_gem->dma_attrs); -if (exynos_gem->flags &EXYNOS_BO_WC || - !(exynos_gem->flags &EXYNOS_BO_CACHABLE )) -dma_set_attr (DMA_ATTR_WRITE_COMBINE , &exynos_gem->dma_attrs); - +dma_set_attr (DMA_ATTR_WRITE_COMBINE , &exynos_gem->dma_attrs);dma_set_attr (DMA_ATTR_NO_KERNEL_MAPPING , &exynos_gem->dma_attrs); nr_pages = exynos_gem->size >>PAGE_SHIFT ;
@@ -128,51 +125,21 @@ static void exynos_drm_free_dma(struct exynos_drm_gem *exynos_gem)static int exynos_drm_alloc_buf (struct exynos_drm_gem *exynos_gem) {struct drm_device *dev = exynos_gem->base.dev; -enum dma_attr attr; -unsigned int nr_pages; +int ret;if (exynos_gem->dma_addr) {DRM_DEBUG_KMS ("already allocated.\n" );return 0 ; } -if (!is_drm_iommu_supported (dev)) -return exynos_drm_alloc_dma (exynos_gem); - -init_dma_attrs (&exynos_gem->dma_attrs); - -/* -* if EXYNOS_BO_CONTIG, fully physically contiguous memory -* region will be allocated else physically contiguous -* as possible. -*/ -if (!(exynos_gem->flags &EXYNOS_BO_NONCONTIG )) -dma_set_attr (DMA_ATTR_FORCE_CONTIGUOUS , &exynos_gem->dma_attrs); - -/* if EXYNOS_BO_WC or EXYNOS_BO_NONCACHABLE, writecombine mapping */ -if (exynos_gem->flags &EXYNOS_BO_WC || - !(exynos_gem->flags &EXYNOS_BO_CACHABLE )) - attr =DMA_ATTR_WRITE_COMBINE ; - -dma_set_attr (attr, &exynos_gem->dma_attrs); -dma_set_attr (DMA_ATTR_NO_KERNEL_MAPPING , &exynos_gem->dma_attrs); - - nr_pages = exynos_gem->size >>PAGE_SHIFT ; - - exynos_gem->cookie =dma_alloc_attrs (dev->dev, exynos_gem->size, - &exynos_gem->dma_addr,GFP_KERNEL , - &exynos_gem->dma_attrs); -if (!exynos_gem->cookie) { -DRM_ERROR ("failed to allocate buffer.\n" ); -if (exynos_gem->pages) -drm_free_large (exynos_gem->pages); -return -ENOMEM ; +if (!is_drm_iommu_supported (dev)) { +if (!(exynos_gem->flags &EXYNOS_BO_NONCONTIG )) +return exynos_drm_alloc_dma (exynos_gem); } - exynos_gem->pages = exynos_gem->cookie; - -DRM_DEBUG_KMS ("dma_addr(0x%lx), size(0x%lx)\n" , - (unsigned long )exynos_gem->dma_addr, exynos_gem->size); + ret =exynos_drm_get_pages (exynos_gem); +if (ret <0 ) +return ret;return 0 ; }
@@ -186,15 +153,12 @@ static void exynos_drm_free_buf(struct exynos_drm_gem *exynos_gem)return ; } -if (!is_drm_iommu_supported (dev)) -return exynos_drm_free_dma (exynos_gem); - -DRM_DEBUG_KMS ("dma_addr(0x%lx), size(0x%lx)\n" , - (unsigned long )exynos_gem->dma_addr, exynos_gem->size); +if (!is_drm_iommu_supported (dev)) { +if (!(exynos_gem->flags &EXYNOS_BO_NONCONTIG )) +return exynos_drm_free_dma (exynos_gem); + } -dma_free_attrs (dev->dev, exynos_gem->size, exynos_gem->cookie, - (dma_addr_t )exynos_gem->dma_addr, - &exynos_gem->dma_attrs); +exynos_drm_put_pages (exynos_gem); } static int exynos_drm_gem_handle_create(struct drm_gem_object *obj,
@@ -400,8 +364,8 @@ void exynos_drm_gem_put_dma_addr(struct drm_device *dev,drm_gem_object_unreference_unlocked (obj); } -static int exynos_drm_gem_mmap_buffer (struct exynos_drm_gem *exynos_gem, -struct vm_area_struct *vma) +static int exynos_drm_gem_mmap_dma (struct exynos_drm_gem *exynos_gem, +struct vm_area_struct *vma) {struct drm_device *drm_dev = exynos_gem->base.dev;unsigned long vm_size;
@@ -579,6 +543,19 @@ int exynos_drm_gem_mmap(struct file *filp, struct vm_area_struct *vma)DRM_DEBUG_KMS ("flags = 0x%x\n" , exynos_gem->flags); +if (!is_drm_iommu_supported (obj->dev)) { +if (!(exynos_gem->flags &EXYNOS_BO_NONCONTIG )) { + ret =exynos_drm_gem_mmap_dma (exynos_gem, vma); +if (ret <0 ) +drm_gem_vm_close (vma); + +return ret; + } + } + + vma->vm_flags &= ~VM_PFNMAP ; + vma->vm_flags |=VM_MIXEDMAP ; +/* non-cachable as default. */ if (exynos_gem->flags &EXYNOS_BO_CACHABLE ) vma->vm_page_prot =vm_get_page_prot (vma->vm_flags);
@@ -589,16 +566,7 @@ int exynos_drm_gem_mmap(struct file *filp, struct vm_area_struct *vma) vma->vm_page_prot =pgprot_noncached (vm_get_page_prot (vma->vm_flags)); - ret =exynos_drm_gem_mmap_buffer (exynos_gem, vma); -if (ret) - goto err_close_vm; - -return ret; - -err_close_vm: -drm_gem_vm_close (vma); - -return ret; +return 0 ; }/* low-level interface prime helpers */
Signature · 6 lines
1.9.1 _______________________________________________ dri-devel mailing list [email protected] http://lists.freedesktop.org/mailman/listinfo/dri-devel
Inki Dae
maintainerRe: [PATCH 6/9] drm/exynos: switch to new buffer allocation
Hi,
How about combining patch 5 and 6?
Patch 5 just introduces new internal API but these API aren't used anywhere in patch 5.
Thanks,
Inki Dae
2015년 10월 13일 16:00에 Joonyoung Shim 이(가) 쓴 글:
Quoted 146 lines
The buffer allocation using DMA mapping API can't support non-continuous buffer on non-iommu and cachable buffer, so switch to new buffer allocation using drm_gem_get/put_pages() and doesn't use DMA mapping API for mmap except allocation of physically continuous buffer on non-iommu.
Signed-off-by Joonyoung Shim <[email protected]>--- drivers/gpu/drm/exynos/exynos_drm_gem.c | 90 +++++++++++---------------------- 1 file changed, 29 insertions(+), 61 deletions(-)drivers/gpu/drm/exynos/exynos_drm_gem.c +28
-55@@ -77,10 +77,7 @@ static int exynos_drm_alloc_dma(struct exynos_drm_gem *exynos_gem)init_dma_attrs (&exynos_gem->dma_attrs); -if (exynos_gem->flags &EXYNOS_BO_WC || - !(exynos_gem->flags &EXYNOS_BO_CACHABLE )) -dma_set_attr (DMA_ATTR_WRITE_COMBINE , &exynos_gem->dma_attrs); - +dma_set_attr (DMA_ATTR_WRITE_COMBINE , &exynos_gem->dma_attrs);dma_set_attr (DMA_ATTR_NO_KERNEL_MAPPING , &exynos_gem->dma_attrs); nr_pages = exynos_gem->size >>PAGE_SHIFT ;@@ -128,51 +125,21 @@ static void exynos_drm_free_dma(struct exynos_drm_gem *exynos_gem)static int exynos_drm_alloc_buf (struct exynos_drm_gem *exynos_gem) {struct drm_device *dev = exynos_gem->base.dev; -enum dma_attr attr; -unsigned int nr_pages; +int ret;if (exynos_gem->dma_addr) {DRM_DEBUG_KMS ("already allocated.\n" );return 0 ; } -if (!is_drm_iommu_supported (dev)) -return exynos_drm_alloc_dma (exynos_gem); - -init_dma_attrs (&exynos_gem->dma_attrs); - -/* -* if EXYNOS_BO_CONTIG, fully physically contiguous memory -* region will be allocated else physically contiguous -* as possible. -*/ -if (!(exynos_gem->flags &EXYNOS_BO_NONCONTIG )) -dma_set_attr (DMA_ATTR_FORCE_CONTIGUOUS , &exynos_gem->dma_attrs); - -/* if EXYNOS_BO_WC or EXYNOS_BO_NONCACHABLE, writecombine mapping */ -if (exynos_gem->flags &EXYNOS_BO_WC || - !(exynos_gem->flags &EXYNOS_BO_CACHABLE )) - attr =DMA_ATTR_WRITE_COMBINE ; - -dma_set_attr (attr, &exynos_gem->dma_attrs); -dma_set_attr (DMA_ATTR_NO_KERNEL_MAPPING , &exynos_gem->dma_attrs); - - nr_pages = exynos_gem->size >>PAGE_SHIFT ; - - exynos_gem->cookie =dma_alloc_attrs (dev->dev, exynos_gem->size, - &exynos_gem->dma_addr,GFP_KERNEL , - &exynos_gem->dma_attrs); -if (!exynos_gem->cookie) { -DRM_ERROR ("failed to allocate buffer.\n" ); -if (exynos_gem->pages) -drm_free_large (exynos_gem->pages); -return -ENOMEM ; +if (!is_drm_iommu_supported (dev)) { +if (!(exynos_gem->flags &EXYNOS_BO_NONCONTIG )) +return exynos_drm_alloc_dma (exynos_gem); } - exynos_gem->pages = exynos_gem->cookie; - -DRM_DEBUG_KMS ("dma_addr(0x%lx), size(0x%lx)\n" , - (unsigned long )exynos_gem->dma_addr, exynos_gem->size); + ret =exynos_drm_get_pages (exynos_gem); +if (ret <0 ) +return ret;return 0 ; }@@ -186,15 +153,12 @@ static void exynos_drm_free_buf(struct exynos_drm_gem *exynos_gem)return ; } -if (!is_drm_iommu_supported (dev)) -return exynos_drm_free_dma (exynos_gem); - -DRM_DEBUG_KMS ("dma_addr(0x%lx), size(0x%lx)\n" , - (unsigned long )exynos_gem->dma_addr, exynos_gem->size); +if (!is_drm_iommu_supported (dev)) { +if (!(exynos_gem->flags &EXYNOS_BO_NONCONTIG )) +return exynos_drm_free_dma (exynos_gem); + } -dma_free_attrs (dev->dev, exynos_gem->size, exynos_gem->cookie, - (dma_addr_t )exynos_gem->dma_addr, - &exynos_gem->dma_attrs); +exynos_drm_put_pages (exynos_gem); } static int exynos_drm_gem_handle_create(struct drm_gem_object *obj,@@ -400,8 +364,8 @@ void exynos_drm_gem_put_dma_addr(struct drm_device *dev,drm_gem_object_unreference_unlocked (obj); } -static int exynos_drm_gem_mmap_buffer (struct exynos_drm_gem *exynos_gem, -struct vm_area_struct *vma) +static int exynos_drm_gem_mmap_dma (struct exynos_drm_gem *exynos_gem, +struct vm_area_struct *vma) {struct drm_device *drm_dev = exynos_gem->base.dev;unsigned long vm_size;@@ -579,6 +543,19 @@ int exynos_drm_gem_mmap(struct file *filp, struct vm_area_struct *vma)DRM_DEBUG_KMS ("flags = 0x%x\n" , exynos_gem->flags); +if (!is_drm_iommu_supported (obj->dev)) { +if (!(exynos_gem->flags &EXYNOS_BO_NONCONTIG )) { + ret =exynos_drm_gem_mmap_dma (exynos_gem, vma); +if (ret <0 ) +drm_gem_vm_close (vma); + +return ret; + } + } + + vma->vm_flags &= ~VM_PFNMAP ; + vma->vm_flags |=VM_MIXEDMAP ; +/* non-cachable as default. */ if (exynos_gem->flags &EXYNOS_BO_CACHABLE ) vma->vm_page_prot =vm_get_page_prot (vma->vm_flags);@@ -589,16 +566,7 @@ int exynos_drm_gem_mmap(struct file *filp, struct vm_area_struct *vma) vma->vm_page_prot =pgprot_noncached (vm_get_page_prot (vma->vm_flags)); - ret =exynos_drm_gem_mmap_buffer (exynos_gem, vma); -if (ret) - goto err_close_vm; -
drivers/gpu/drm/exynos/exynos_drm_gem.c int exynos_drm_gem_mmap(struct file *filp, struct vm_area_struct *vma) · line 572
Quoted 10 lines
drivers/gpu/drm/exynos/exynos_drm_gem.c +1
-6-return ret; - -err_close_vm: -drm_gem_vm_close (vma); - -return ret; +return 0 ; }/* low-level interface prime helpers */
_______________________________________________
dri-devel mailing list
[email protected]
http://lists.freedesktop.org/mailman/listinfo/dri-devel
Re: [PATCH 6/9] drm/exynos: switch to new buffer allocation
Quoted 6 lines · Inki Dae
Hi,
How about combining patch 5 and 6?
Patch 5 just introduces new internal API but these API aren't used anywhere in patch 5.
I split it to be easy to understand changes of codes on patch file. It's no matter to me to combine them.
Anyway, because this patchset introduces new userspace interfaces and there is no real userspace to use them yet, i'm not sure it's better whether i keep going this patchset or without the patch to introduce new userspace interfaces.
Thanks.
_______________________________________________
dri-devel mailing list
[email protected]
http://lists.freedesktop.org/mailman/listinfo/dri-devel
PATCH 7/9 drm/exynos: always use EXYNOS_BO_CONTIG flag on iommu
In reply to Joonyoung ShimIt doesn't care whether memory is continuous physically if iommu is supported but we will always use EXYNOS_BO_CONTIG flag on iommu, so it can mean that the memory is continuous memory for device.
--- drivers/gpu/drm/exynos/exynos_drm_fb.c | 32 ++++--------------------------- drivers/gpu/drm/exynos/exynos_drm_fbdev.c | 14 +------------- drivers/gpu/drm/exynos/exynos_drm_gem.c | 31 ++++++++++++++---------------- drivers/gpu/drm/exynos/exynos_drm_gem.h | 2 -- include/uapi/drm/exynos_drm.h | 5 ++++- 5 files changed, 23 insertions(+), 61 deletions(-)
drivers/gpu/drm/exynos/exynos_drm_fb.c +4 -28
@@ -39,32 +39,6 @@ struct exynos_drm_fb {struct exynos_drm_gem *exynos_gem[MAX_FB_BUFFER ]; }; -static int check_fb_gem_memory_type (struct drm_device *drm_dev, -struct exynos_drm_gem *exynos_gem) -{ -unsigned int flags; - -/* -* if exynos drm driver supports iommu then framebuffer can use -* all the buffer types. -*/ -if (is_drm_iommu_supported (drm_dev)) -return 0 ; - - flags = exynos_gem->flags; - -/* -* without iommu support, not support physically non-continuous memory -* for framebuffer. -*/ -if (IS_NONCONTIG_BUFFER (flags)) { -DRM_ERROR ("cannot use this gem memory type for fb.\n" ); -return -EINVAL ; - } - -return 0 ; -} -static void exynos_drm_fb_destroy (struct drm_framebuffer *fb) {struct exynos_drm_fb *exynos_fb =to_exynos_fb (fb);
@@ -130,9 +104,11 @@ exynos_drm_framebuffer_init(struct drm_device *dev,return ERR_PTR (-ENOMEM );for (i =0 ; i < count; i++) { - ret =check_fb_gem_memory_type (dev, exynos_gem[i]); -if (ret <0 ) +/* Not support physically non-continuous memory for FB */ +if (exynos_gem[i]->flags &EXYNOS_BO_NONCONTIG ) { + ret = -EINVAL ; goto err; + } exynos_fb->exynos_gem[i] = exynos_gem[i]; }
drivers/gpu/drm/exynos/exynos_drm_fbdev.c +1 -13
@@ -124,7 +124,6 @@ static int exynos_drm_fbdev_create(struct drm_fb_helper *helper,struct exynos_drm_gem *exynos_gem;struct drm_device *dev = helper->dev;struct drm_mode_fb_cmd2 mode_cmd = {0 }; -struct platform_device *pdev = dev->platformdev;unsigned long size;int ret;
@@ -142,18 +141,7 @@ static int exynos_drm_fbdev_create(struct drm_fb_helper *helper, size = mode_cmd.pitches[0 ] * mode_cmd.height; - exynos_gem =exynos_drm_gem_create (dev,EXYNOS_BO_CONTIG , size); -/* -* If physically contiguous memory allocation fails and if IOMMU is -* supported then try to get buffer from non physically contiguous -* memory area. -*/ -if (IS_ERR (exynos_gem) &&is_drm_iommu_supported (dev)) { -dev_warn (&pdev->dev,"contiguous FB allocation failed, falling back to non-contiguous\n" ); - exynos_gem =exynos_drm_gem_create (dev,EXYNOS_BO_NONCONTIG , - size); - } - + exynos_gem =exynos_drm_gem_create (dev,0 , size);if (IS_ERR (exynos_gem)) { ret =PTR_ERR (exynos_gem); goto out;
drivers/gpu/drm/exynos/exynos_drm_gem.c +14 -17
@@ -135,6 +135,8 @@ static int exynos_drm_alloc_buf(struct exynos_drm_gem *exynos_gem)if (!is_drm_iommu_supported (dev)) {if (!(exynos_gem->flags &EXYNOS_BO_NONCONTIG ))return exynos_drm_alloc_dma (exynos_gem); + }else { + exynos_gem->flags &= ~EXYNOS_BO_NONCONTIG ; } ret =exynos_drm_get_pages (exynos_gem);
@@ -440,10 +442,7 @@ int exynos_drm_gem_dumb_create(struct drm_file *file_priv, args->pitch = args->width * ((args->bpp +7 ) /8 ); args->size = args->pitch * args->height; -if (is_drm_iommu_supported (dev)) - flags =EXYNOS_BO_NONCONTIG |EXYNOS_BO_WC ; -else - flags =EXYNOS_BO_CONTIG |EXYNOS_BO_WC ; + flags =EXYNOS_BO_WC ; exynos_gem =exynos_drm_gem_create (dev, flags, args->size);if (IS_ERR (exynos_gem)) {
@@ -597,6 +596,17 @@ exynos_drm_gem_prime_import_sg_table(struct drm_device *dev, exynos_gem->dma_addr =sg_dma_address (sgt->sgl); +/* +* Always physically continuous memory if sgt->nents is 1. It +* doesn't care if IOMMU is supported but EXYNOS_BO_NONCONTIG +* flag will be cleared. It will mean the memory is continuous +* for device. EXYNOS_BO_NONCONTIG flag will be set if not both. +*/ +if (sgt->nents ==1 ||is_drm_iommu_supported (dev)) + exynos_gem->flags &= ~EXYNOS_BO_NONCONTIG ; +else + exynos_gem->flags |=EXYNOS_BO_NONCONTIG ; + npages = exynos_gem->size >>PAGE_SHIFT ; exynos_gem->pages =drm_malloc_ab (npages,sizeof (struct page *));if (!exynos_gem->pages) {
@@ -611,19 +621,6 @@ exynos_drm_gem_prime_import_sg_table(struct drm_device *dev, exynos_gem->sgt = sgt; -if (sgt->nents ==1 ) { -/* always physically continuous memory if sgt->nents is 1. */ - exynos_gem->flags |=EXYNOS_BO_CONTIG ; - }else { -/* -* this case could be CONTIG or NONCONTIG type but for now -* sets NONCONTIG. -* TODO. we have to find a way that exporter can notify -* the type of its own buffer to importer. -*/ - exynos_gem->flags |=EXYNOS_BO_NONCONTIG ; - } -return &exynos_gem->base; err_free_large:
drivers/gpu/drm/exynos/exynos_drm_gem.h +0 -2
@@ -16,8 +16,6 @@#define to_exynos_gem (x) container_of(x, struct exynos_drm_gem, base) -#define IS_NONCONTIG_BUFFER (f) (f & EXYNOS_BO_NONCONTIG) -/* * exynos drm buffer structure. *
include/uapi/drm/exynos_drm.h +4 -1
@@ -76,7 +76,10 @@ struct drm_exynos_vidi_connection {/* memory type definitions. */ enum e_drm_exynos_gem_mem_type { -/* Physically Continuous memory and used as default. */ +/* +* Physically Continuous memory or Continuous memory for device +* on IOMMU. Used as default. +*/ EXYNOS_BO_CONTIG =0 <<0 ,/* Physically Non-Continuous memory. */ EXYNOS_BO_NONCONTIG =1 <<0 ,
Signature · 6 lines
1.9.1 _______________________________________________ dri-devel mailing list [email protected] http://lists.freedesktop.org/mailman/listinfo/dri-devel
PATCH 8/9 drm/exynos: use DMA_ERROR_CODE
In reply to Joonyoung ShimThe dma_addr of gem will be DMA_ERROR_CODE if gem is created and will keep DMA_ERROR_CODE if gem has EXYNOS_BO_NONCONTIG flag on non-iommu.
--- drivers/gpu/drm/exynos/exynos_drm_gem.c | 24 +++++++++--------------- 1 file changed, 9 insertions(+), 15 deletions(-)
drivers/gpu/drm/exynos/exynos_drm_gem.c +9 -15
@@ -44,7 +44,9 @@ static int exynos_drm_get_pages(struct exynos_drm_gem *exynos_gem) goto err; } - exynos_gem->dma_addr =sg_dma_address (sgt->sgl); +if (is_drm_iommu_supported (dev)) + exynos_gem->dma_addr =sg_dma_address (sgt->sgl); + exynos_gem->sgt = sgt; exynos_gem->pages = pages;
@@ -127,11 +129,6 @@ static int exynos_drm_alloc_buf(struct exynos_drm_gem *exynos_gem)struct drm_device *dev = exynos_gem->base.dev;int ret; -if (exynos_gem->dma_addr) { -DRM_DEBUG_KMS ("already allocated.\n" ); -return 0 ; - } -if (!is_drm_iommu_supported (dev)) {if (!(exynos_gem->flags &EXYNOS_BO_NONCONTIG ))return exynos_drm_alloc_dma (exynos_gem);
@@ -150,11 +147,6 @@ static void exynos_drm_free_buf(struct exynos_drm_gem *exynos_gem) {struct drm_device *dev = exynos_gem->base.dev; -if (!exynos_gem->dma_addr) { -DRM_DEBUG_KMS ("dma_addr is invalid.\n" ); -return ; - } -if (!is_drm_iommu_supported (dev)) {if (!(exynos_gem->flags &EXYNOS_BO_NONCONTIG ))return exynos_drm_free_dma (exynos_gem);
@@ -256,6 +248,8 @@ static struct exynos_drm_gem *exynos_drm_gem_init(struct drm_device *dev,return ERR_PTR (ret); } + exynos_gem->dma_addr =DMA_ERROR_CODE ; +DRM_DEBUG_KMS ("created file object = 0x%x\n" , (unsigned int )obj->filp);return exynos_gem;
@@ -594,18 +588,18 @@ exynos_drm_gem_prime_import_sg_table(struct drm_device *dev,return ERR_PTR (ret); } - exynos_gem->dma_addr =sg_dma_address (sgt->sgl); -/* * Always physically continuous memory if sgt->nents is 1. It * doesn't care if IOMMU is supported but EXYNOS_BO_NONCONTIG * flag will be cleared. It will mean the memory is continuous * for device. EXYNOS_BO_NONCONTIG flag will be set if not both. */ -if (sgt->nents ==1 ||is_drm_iommu_supported (dev)) +if (sgt->nents ==1 ||is_drm_iommu_supported (dev)) { exynos_gem->flags &= ~EXYNOS_BO_NONCONTIG ; -else + exynos_gem->dma_addr =sg_dma_address (sgt->sgl); + }else { exynos_gem->flags |=EXYNOS_BO_NONCONTIG ; + } npages = exynos_gem->size >>PAGE_SHIFT ; exynos_gem->pages =drm_malloc_ab (npages,sizeof (struct page *));
Signature · 6 lines
1.9.1 _______________________________________________ dri-devel mailing list [email protected] http://lists.freedesktop.org/mailman/listinfo/dri-devel
PATCH 9/9 drm/exynos: add ioctls for cpu access of gem object from user
In reply to Joonyoung ShimThis adds necessary two ioctls for cpu access of gem object from user. It needs to be synced properly in order for the cpu and device if the buffer of gem object is cachable.
- DRM_IOCTL_EXYNOS_GEM_CPU_PREP
Should be used explicitly before it will be cpu access of gem object from user.
- DRM_IOCTL_EXYNOS_GEM_CPU_FINI
Should be used explicitly after it is finished cpu access of gem object from user.
---
This is based on patch of Daniel dropping DRM_UNLOCKED flag on each drivers[1] and patch that is droped DRM_UNLOCKED flag from my posted patch[2].
[1] http://lists.freedesktop.org/archives/intel-gfx/2015-September/075368.html
[2] http://www.spinics.net/lists/dri-devel/msg91465.html
drivers/gpu/drm/exynos/exynos_drm_drv.c | 4 +++ drivers/gpu/drm/exynos/exynos_drm_gem.c | 48 +++++++++++++++++++++++++++++++++ drivers/gpu/drm/exynos/exynos_drm_gem.h | 14 ++++++++++ include/uapi/drm/exynos_drm.h | 18 ++++++++++++- 4 files changed, 83 insertions(+), 1 deletion(-)
drivers/gpu/drm/exynos/exynos_drm_drv.c +4 -0
@@ -408,6 +408,10 @@ static const struct drm_ioctl_desc exynos_ioctls[] = { DRM_AUTH | DRM_RENDER_ALLOW),DRM_IOCTL_DEF_DRV (EXYNOS_GEM_MAP , exynos_drm_gem_map_ioctl,DRM_AUTH |DRM_RENDER_ALLOW ), +DRM_IOCTL_DEF_DRV (EXYNOS_GEM_CPU_PREP , exynos_drm_gem_cpu_prep_ioctl, +DRM_AUTH |DRM_RENDER_ALLOW ), +DRM_IOCTL_DEF_DRV (EXYNOS_GEM_CPU_FINI , exynos_drm_gem_cpu_fini_ioctl, +DRM_AUTH |DRM_RENDER_ALLOW ),DRM_IOCTL_DEF_DRV (EXYNOS_GEM_GET , exynos_drm_gem_get_ioctl,DRM_RENDER_ALLOW ), DRM_IOCTL_DEF_DRV(EXYNOS_VIDI_CONNECTION, vidi_connection_ioctl,
drivers/gpu/drm/exynos/exynos_drm_gem.c +48 -0
54 lines not on this page · raw message
drivers/gpu/drm/exynos/exynos_drm_gem.h +14 -0
@@ -74,6 +74,20 @@ int exynos_drm_gem_map_ioctl(struct drm_device *dev, void *data, struct drm_file *file_priv);/* +* Should be used explicitly before it will be cpu access of gem object +* from user. +*/ +int exynos_drm_gem_cpu_prep_ioctl (struct drm_device *dev,void *data, +struct drm_file *file_priv); + +/* +* Should be used explicitly after it is finished cpu access of gem +* object from user. +*/ +int exynos_drm_gem_cpu_fini_ioctl (struct drm_device *dev,void *data, +struct drm_file *file_priv); + +/* * get dma address from gem handle and this function could be used for * other drivers such as 2d/3d acceleration drivers. * with this function call, gem object reference count would be increased.
include/uapi/drm/exynos_drm.h +17 -1
@@ -46,6 +46,16 @@ struct drm_exynos_gem_map { };/** +* A structure for cpu access of gem object from user. +* +* @handle: handle of gem object. +*/ +struct drm_exynos_gem_cpu_access { +__u32 handle; +__u32 reserved; +}; + +/** * A structure to gem information. * * @handle: a handle to gem object created.
@@ -301,8 +311,10 @@ struct drm_exynos_ipp_cmd_ctrl {#define DRM_EXYNOS_GEM_CREATE 0x00#define DRM_EXYNOS_GEM_MAP 0x01 -/* Reserved 0x03 ~ 0x05 for exynos specific gem ioctl */ +#define DRM_EXYNOS_GEM_CPU_PREP 0x02 +#define DRM_EXYNOS_GEM_CPU_FINI 0x03#define DRM_EXYNOS_GEM_GET 0x04 +/* Reserved 0x05 ~ 0x06 for exynos specific gem ioctl */ #define DRM_EXYNOS_VIDI_CONNECTION 0x07/* G2D */
@@ -320,6 +332,10 @@ struct drm_exynos_ipp_cmd_ctrl { DRM_EXYNOS_GEM_CREATE, struct drm_exynos_gem_create)#define DRM_IOCTL_EXYNOS_GEM_MAP DRM_IOWR(DRM_COMMAND_BASE + \ DRM_EXYNOS_GEM_MAP, struct drm_exynos_gem_map) +#define DRM_IOCTL_EXYNOS_GEM_CPU_PREP DRM_IOWR(DRM_COMMAND_BASE + \ + DRM_EXYNOS_GEM_CPU_PREP, struct drm_exynos_gem_cpu_access) +#define DRM_IOCTL_EXYNOS_GEM_CPU_FINI DRM_IOWR(DRM_COMMAND_BASE + \ + DRM_EXYNOS_GEM_CPU_FINI, struct drm_exynos_gem_cpu_access)#define DRM_IOCTL_EXYNOS_GEM_GET DRM_IOWR(DRM_COMMAND_BASE + \ DRM_EXYNOS_GEM_GET, struct drm_exynos_gem_info)
Signature · 6 lines
1.9.1 _______________________________________________ dri-devel mailing list [email protected] http://lists.freedesktop.org/mailman/listinfo/dri-devel
Quoted 23 lines · Joonyoung Shim
Hi,
This patchset is about gem codes update of exynos-drm.
The first and second patches are cleanup to remove useless codes. The rest is to support cachable gem allocation.
The exynos-drm uses DMA mapping API to allocate/mmap buffer of gem. If it is cachable, does it with
DMA_ATTR_NON_CONSISTENTattribute, butDMA_ATTR_NON_CONSISTENTisn't supported in DMA mapping API of ARM, so it doesn't give any effects.This patchset introduces new buffer allocation to use drm_gem_get/put_pages() instead of DMA mapping API. It will be used for the rest except allocation of physically continuous buffer on non-iommu, then exynos-drm can support cachable buffer of gem. Also it can support physically non-continuous buffer on non-iommu.
EXYNOS_BO_CONTIGflag on iommu is ambiguous because it doesn't care whether buffer is continuous physically if iommu is supported. This patchset always will useEXYNOS_BO_CONTIGflag on iommu and then can mean that the buffer is continuous for device.
Quoted 4 lines
There is no user API to control cache coherence for the cpu and device about cachable buffer. This patchset introduces two ioctls for cpu access of gem object from user. It will be synced properly in order for the cpu and device if buffer of gem object is cachable.
Out of curiosity, where's the userspace part for this work? Usually kernel abi extensions come with a link to the relevant branch for easier review. -Daniel
Quoted 30 lines
Thanks.
Joonyoung Shim (9):
drm/exynos: eliminate useless codes ofexynos_drm_gem.hdrm/exynos: use directly DMA mapping APIs on g2d drm/exynos: remove using non-consistent DMA attribute drm/exynos: split buffer allocation using DMA mapping API on non-iommu drm/exynos: introduce buffer allocation using drm_gem_get/put_pages() drm/exynos: switch to new buffer allocation
drm/exynos: always useEXYNOS_BO_CONTIGflag on iommu drm/exynos: useDMA_ERROR_CODE
drm/exynos: add ioctls for cpu access of gem object from userdrivers/gpu/drm/exynos/exynos_drm_drv.c | 4 + drivers/gpu/drm/exynos/exynos_drm_fb.c | 32 +--- drivers/gpu/drm/exynos/exynos_drm_fbdev.c | 14 +- drivers/gpu/drm/exynos/exynos_drm_g2d.c | 10 +- drivers/gpu/drm/exynos/exynos_drm_gem.c | 288 ++++++++++++++++++------------ drivers/gpu/drm/exynos/exynos_drm_gem.h | 56 ++---- include/uapi/drm/exynos_drm.h | 23 ++- 7 files changed, 225 insertions(+), 202 deletions(-)Signature · 6 lines
1.9.1 _______________________________________________ dri-devel mailing list [email protected] http://lists.freedesktop.org/mailman/listinfo/dri-devel
Signature · 7 lines
Daniel Vetter Software Engineer, Intel Corporation http://blog.ffwll.ch _______________________________________________ dri-devel mailing list [email protected] http://lists.freedesktop.org/mailman/listinfo/dri-devel
Quoted 24 lines · Daniel Vetter
Quoted 23 lines · Joonyoung Shim
Hi,
This patchset is about gem codes update of exynos-drm.
The first and second patches are cleanup to remove useless codes. The rest is to support cachable gem allocation.
The exynos-drm uses DMA mapping API to allocate/mmap buffer of gem. If it is cachable, does it with
DMA_ATTR_NON_CONSISTENTattribute, butDMA_ATTR_NON_CONSISTENTisn't supported in DMA mapping API of ARM, so it doesn't give any effects.This patchset introduces new buffer allocation to use drm_gem_get/put_pages() instead of DMA mapping API. It will be used for the rest except allocation of physically continuous buffer on non-iommu, then exynos-drm can support cachable buffer of gem. Also it can support physically non-continuous buffer on non-iommu.
EXYNOS_BO_CONTIGflag on iommu is ambiguous because it doesn't care whether buffer is continuous physically if iommu is supported. This patchset always will useEXYNOS_BO_CONTIGflag on iommu and then can mean that the buffer is continuous for device.
Quoted 9 lines
Quoted 4 lines
There is no user API to control cache coherence for the cpu and device about cachable buffer. This patchset introduces two ioctls for cpu access of gem object from user. It will be synced properly in order for the cpu and device if buffer of gem object is cachable.
Out of curiosity, where's the userspace part for this work? Usually kernel abi extensions come with a link to the relevant branch for easier review. -Daniel
Right, thanks for point.
I just modified a little bit exynos_fimg2d_test and exynos parts of libdrm to test them as workaround. I will expose it.
Thanks.
Quoted 23 lines
Quoted 23 lines
Thanks.
Joonyoung Shim (9):
drm/exynos: eliminate useless codes ofexynos_drm_gem.hdrm/exynos: use directly DMA mapping APIs on g2d drm/exynos: remove using non-consistent DMA attribute drm/exynos: split buffer allocation using DMA mapping API on non-iommu drm/exynos: introduce buffer allocation using drm_gem_get/put_pages() drm/exynos: switch to new buffer allocation
drm/exynos: always useEXYNOS_BO_CONTIGflag on iommu drm/exynos: useDMA_ERROR_CODE
drm/exynos: add ioctls for cpu access of gem object from userdrivers/gpu/drm/exynos/exynos_drm_drv.c | 4 + drivers/gpu/drm/exynos/exynos_drm_fb.c | 32 +--- drivers/gpu/drm/exynos/exynos_drm_fbdev.c | 14 +- drivers/gpu/drm/exynos/exynos_drm_g2d.c | 10 +- drivers/gpu/drm/exynos/exynos_drm_gem.c | 288 ++++++++++++++++++------------ drivers/gpu/drm/exynos/exynos_drm_gem.h | 56 ++---- include/uapi/drm/exynos_drm.h | 23 ++- 7 files changed, 225 insertions(+), 202 deletions(-)
Quoted 8 lines
Quoted 7 lines
Signature · 6 lines
1.9.1 _______________________________________________ dri-devel mailing list [email protected] http://lists.freedesktop.org/mailman/listinfo/dri-devel
_______________________________________________
dri-devel mailing list
[email protected]
http://lists.freedesktop.org/mailman/listinfo/dri-devel
Quoted 35 lines · Joonyoung Shim
Quoted 24 lines · Daniel Vetter
Quoted 23 lines · Joonyoung Shim
Hi,
This patchset is about gem codes update of exynos-drm.
The first and second patches are cleanup to remove useless codes. The rest is to support cachable gem allocation.
The exynos-drm uses DMA mapping API to allocate/mmap buffer of gem. If it is cachable, does it with
DMA_ATTR_NON_CONSISTENTattribute, butDMA_ATTR_NON_CONSISTENTisn't supported in DMA mapping API of ARM, so it doesn't give any effects.This patchset introduces new buffer allocation to use drm_gem_get/put_pages() instead of DMA mapping API. It will be used for the rest except allocation of physically continuous buffer on non-iommu, then exynos-drm can support cachable buffer of gem. Also it can support physically non-continuous buffer on non-iommu.
EXYNOS_BO_CONTIGflag on iommu is ambiguous because it doesn't care whether buffer is continuous physically if iommu is supported. This patchset always will useEXYNOS_BO_CONTIGflag on iommu and then can mean that the buffer is continuous for device.Quoted 9 lines
Quoted 4 lines
There is no user API to control cache coherence for the cpu and device about cachable buffer. This patchset introduces two ioctls for cpu access of gem object from user. It will be synced properly in order for the cpu and device if buffer of gem object is cachable.
Out of curiosity, where's the userspace part for this work? Usually kernel abi extensions come with a link to the relevant branch for easier review. -Daniel
Quoted 5 lines
Right, thanks for point.
I just modified a little bit
exynos_fimg2d_testand exynos parts of libdrm to test them as workaround. I will expose it.
Please refer follows.
https://github.com/dofmind/libdrm/commits/exynos
If fimd2d test program uses cachable gem, it will show cache coherency problem, so it adds to use new ioctls to keep cache coherency.
Thanks.
Quoted 34 lines
Thanks.
Quoted 23 lines
Quoted 23 lines
Thanks.
Joonyoung Shim (9):
drm/exynos: eliminate useless codes ofexynos_drm_gem.hdrm/exynos: use directly DMA mapping APIs on g2d drm/exynos: remove using non-consistent DMA attribute drm/exynos: split buffer allocation using DMA mapping API on non-iommu drm/exynos: introduce buffer allocation using drm_gem_get/put_pages() drm/exynos: switch to new buffer allocation
drm/exynos: always useEXYNOS_BO_CONTIGflag on iommu drm/exynos: useDMA_ERROR_CODE
drm/exynos: add ioctls for cpu access of gem object from userdrivers/gpu/drm/exynos/exynos_drm_drv.c | 4 + drivers/gpu/drm/exynos/exynos_drm_fb.c | 32 +--- drivers/gpu/drm/exynos/exynos_drm_fbdev.c | 14 +- drivers/gpu/drm/exynos/exynos_drm_g2d.c | 10 +- drivers/gpu/drm/exynos/exynos_drm_gem.c | 288 ++++++++++++++++++------------ drivers/gpu/drm/exynos/exynos_drm_gem.h | 56 ++---- include/uapi/drm/exynos_drm.h | 23 ++- 7 files changed, 225 insertions(+), 202 deletions(-)Quoted 8 lines
Quoted 7 lines
Signature · 6 lines
1.9.1 _______________________________________________ dri-devel mailing list [email protected] http://lists.freedesktop.org/mailman/listinfo/dri-devel
Quoted 5 lines
_______________________________________________
dri-devel mailing list
[email protected]
http://lists.freedesktop.org/mailman/listinfo/dri-devel
_______________________________________________
dri-devel mailing list
[email protected]
http://lists.freedesktop.org/mailman/listinfo/dri-devel
Quoted 42 lines · Joonyoung Shim
Quoted 35 lines · Joonyoung Shim
Quoted 24 lines · Daniel Vetter
Quoted 23 lines · Joonyoung Shim
Hi,
This patchset is about gem codes update of exynos-drm.
The first and second patches are cleanup to remove useless codes. The rest is to support cachable gem allocation.
The exynos-drm uses DMA mapping API to allocate/mmap buffer of gem. If it is cachable, does it with
DMA_ATTR_NON_CONSISTENTattribute, butDMA_ATTR_NON_CONSISTENTisn't supported in DMA mapping API of ARM, so it doesn't give any effects.This patchset introduces new buffer allocation to use drm_gem_get/put_pages() instead of DMA mapping API. It will be used for the rest except allocation of physically continuous buffer on non-iommu, then exynos-drm can support cachable buffer of gem. Also it can support physically non-continuous buffer on non-iommu.
EXYNOS_BO_CONTIGflag on iommu is ambiguous because it doesn't care whether buffer is continuous physically if iommu is supported. This patchset always will useEXYNOS_BO_CONTIGflag on iommu and then can mean that the buffer is continuous for device.Quoted 9 lines
Quoted 4 lines
There is no user API to control cache coherence for the cpu and device about cachable buffer. This patchset introduces two ioctls for cpu access of gem object from user. It will be synced properly in order for the cpu and device if buffer of gem object is cachable.
Out of curiosity, where's the userspace part for this work? Usually kernel abi extensions come with a link to the relevant branch for easier review. -Daniel
Quoted 5 lines
Right, thanks for point.
I just modified a little bit
exynos_fimg2d_testand exynos parts of libdrm to test them as workaround. I will expose it.
Quoted 5 lines
Please refer follows.
https://github.com/dofmind/libdrm/commits/exynosIf fimd2d test program uses cachable gem, it will show cache coherency problem, so it adds to use new ioctls to keep cache coherency.
Is there some real userspace too, not just a test/demo app? -Daniel
Signature · 7 lines
Daniel Vetter Software Engineer, Intel Corporation http://blog.ffwll.ch _______________________________________________ dri-devel mailing list [email protected] http://lists.freedesktop.org/mailman/listinfo/dri-devel
Quoted 43 lines · Daniel Vetter
Quoted 42 lines · Joonyoung Shim
Quoted 40 lines · Joonyoung Shim
Quoted 24 lines · Daniel Vetter
Quoted 23 lines · Joonyoung Shim
Hi,
This patchset is about gem codes update of exynos-drm.
The first and second patches are cleanup to remove useless codes. The rest is to support cachable gem allocation.
The exynos-drm uses DMA mapping API to allocate/mmap buffer of gem. If it is cachable, does it with
DMA_ATTR_NON_CONSISTENTattribute, butDMA_ATTR_NON_CONSISTENTisn't supported in DMA mapping API of ARM, so it doesn't give any effects.This patchset introduces new buffer allocation to use drm_gem_get/put_pages() instead of DMA mapping API. It will be used for the rest except allocation of physically continuous buffer on non-iommu, then exynos-drm can support cachable buffer of gem. Also it can support physically non-continuous buffer on non-iommu.
EXYNOS_BO_CONTIGflag on iommu is ambiguous because it doesn't care whether buffer is continuous physically if iommu is supported. This patchset always will useEXYNOS_BO_CONTIGflag on iommu and then can mean that the buffer is continuous for device.Quoted 9 lines
Quoted 4 lines
There is no user API to control cache coherence for the cpu and device about cachable buffer. This patchset introduces two ioctls for cpu access of gem object from user. It will be synced properly in order for the cpu and device if buffer of gem object is cachable.
Out of curiosity, where's the userspace part for this work? Usually kernel abi extensions come with a link to the relevant branch for easier review. -Daniel
Right, thanks for point.
I just modified a little bit
exynos_fimg2d_testand exynos parts of libdrm to test them as workaround. I will expose it.
Quoted 7 lines
Quoted 5 lines
Please refer follows.
https://github.com/dofmind/libdrm/commits/exynosIf fimd2d test program uses cachable gem, it will show cache coherency problem, so it adds to use new ioctls to keep cache coherency.
Is there some real userspace too, not just a test/demo app?
Unfortunately not yet, i hope it can be used on real userspace.
Thanks.
_______________________________________________
dri-devel mailing list
[email protected]
http://lists.freedesktop.org/mailman/listinfo/dri-devel
Quoted 47 lines · Joonyoung Shim
Quoted 46 lines · Daniel Vetter
Quoted 45 lines · Joonyoung Shim
Quoted 35 lines · Joonyoung Shim
Quoted 24 lines · Daniel Vetter
Quoted 23 lines · Joonyoung Shim
Hi,
This patchset is about gem codes update of exynos-drm.
The first and second patches are cleanup to remove useless codes. The rest is to support cachable gem allocation.
The exynos-drm uses DMA mapping API to allocate/mmap buffer of gem. If it is cachable, does it with
DMA_ATTR_NON_CONSISTENTattribute, butDMA_ATTR_NON_CONSISTENTisn't supported in DMA mapping API of ARM, so it doesn't give any effects.This patchset introduces new buffer allocation to use drm_gem_get/put_pages() instead of DMA mapping API. It will be used for the rest except allocation of physically continuous buffer on non-iommu, then exynos-drm can support cachable buffer of gem. Also it can support physically non-continuous buffer on non-iommu.
EXYNOS_BO_CONTIGflag on iommu is ambiguous because it doesn't care whether buffer is continuous physically if iommu is supported. This patchset always will useEXYNOS_BO_CONTIGflag on iommu and then can mean that the buffer is continuous for device.Quoted 9 lines
Quoted 4 lines
There is no user API to control cache coherence for the cpu and device about cachable buffer. This patchset introduces two ioctls for cpu access of gem object from user. It will be synced properly in order for the cpu and device if buffer of gem object is cachable.
Out of curiosity, where's the userspace part for this work? Usually kernel abi extensions come with a link to the relevant branch for easier review. -Daniel
Quoted 5 lines
Right, thanks for point.
I just modified a little bit
exynos_fimg2d_testand exynos parts of libdrm to test them as workaround. I will expose it.Please refer follows.
https://github.com/dofmind/libdrm/commits/exynos
Quoted 6 lines
Quoted 4 lines
Quoted 2 lines
If fimd2d test program uses cachable gem, it will show cache coherency problem, so it adds to use new ioctls to keep cache coherency.
Is there some real userspace too, not just a test/demo app?
Unfortunately not yet, i hope it can be used on real userspace.
In general we wait with merging new userspace ABI until that's really ready, since very often there's some corner cases that you just didn't think about in your toy demo compared to the real thing. Like how to manage buffer caches/reuse for apps that essentially run forever (like X server or a compositor).
-Daniel
Signature · 7 lines
Daniel Vetter Software Engineer, Intel Corporation http://blog.ffwll.ch _______________________________________________ dri-devel mailing list [email protected] http://lists.freedesktop.org/mailman/listinfo/dri-devel