All of lore.kernel.org
 help / color / mirror / Atom feed
* [PATCH 01/14] drm/exynos: stop using sgtable in page fault handler
@ 2015-07-28  8:53 Joonyoung Shim
  2015-07-28  8:53 ` [PATCH 02/14] drm/exynos: remove function convert_to_vm_err_msg Joonyoung Shim
                   ` (12 more replies)
  0 siblings, 13 replies; 35+ messages in thread
From: Joonyoung Shim @ 2015-07-28  8:53 UTC (permalink / raw)
  To: dri-devel; +Cc: sw0312.kim

Already struct exynos_drm_gem_buf has pages of the buffer when buffer is
created, so just can use pages in page fault handler, we don't have to
make sgtable of the buffer. But this needs to construct pages of the
buffer that is imported from dma-buf prime.

Signed-off-by: Joonyoung Shim <jy0922.shim@samsung.com>
---
 drivers/gpu/drm/exynos/exynos_drm_buf.c    | 16 ----------------
 drivers/gpu/drm/exynos/exynos_drm_dmabuf.c | 18 ++++++++++++++++++
 drivers/gpu/drm/exynos/exynos_drm_gem.c    | 14 +-------------
 3 files changed, 19 insertions(+), 29 deletions(-)

diff --git a/drivers/gpu/drm/exynos/exynos_drm_buf.c b/drivers/gpu/drm/exynos/exynos_drm_buf.c
index 24994ba..9260dfb 100644
--- a/drivers/gpu/drm/exynos/exynos_drm_buf.c
+++ b/drivers/gpu/drm/exynos/exynos_drm_buf.c
@@ -90,23 +90,12 @@ static int lowlevel_buffer_allocate(struct drm_device *dev,
 		}
 	}
 
-	buf->sgt = drm_prime_pages_to_sg(buf->pages, nr_pages);
-	if (IS_ERR(buf->sgt)) {
-		DRM_ERROR("failed to get sg table.\n");
-		ret = PTR_ERR(buf->sgt);
-		goto err_free_attrs;
-	}
-
 	DRM_DEBUG_KMS("dma_addr(0x%lx), size(0x%lx)\n",
 			(unsigned long)buf->dma_addr,
 			buf->size);
 
 	return ret;
 
-err_free_attrs:
-	dma_free_attrs(dev->dev, buf->size, buf->pages,
-			(dma_addr_t)buf->dma_addr, &buf->dma_attrs);
-	buf->dma_addr = (dma_addr_t)NULL;
 err_free:
 	if (!is_drm_iommu_supported(dev))
 		drm_free_large(buf->pages);
@@ -126,11 +115,6 @@ static void lowlevel_buffer_deallocate(struct drm_device *dev,
 			(unsigned long)buf->dma_addr,
 			buf->size);
 
-	sg_free_table(buf->sgt);
-
-	kfree(buf->sgt);
-	buf->sgt = NULL;
-
 	if (!is_drm_iommu_supported(dev)) {
 		dma_free_attrs(dev->dev, buf->size, buf->cookie,
 				(dma_addr_t)buf->dma_addr, &buf->dma_attrs);
diff --git a/drivers/gpu/drm/exynos/exynos_drm_dmabuf.c b/drivers/gpu/drm/exynos/exynos_drm_dmabuf.c
index cd485c0..d10f9b6 100644
--- a/drivers/gpu/drm/exynos/exynos_drm_dmabuf.c
+++ b/drivers/gpu/drm/exynos/exynos_drm_dmabuf.c
@@ -203,6 +203,7 @@ struct drm_gem_object *exynos_dmabuf_prime_import(struct drm_device *drm_dev,
 	struct scatterlist *sgl;
 	struct exynos_drm_gem_obj *exynos_gem_obj;
 	struct exynos_drm_gem_buf *buffer;
+	int npages;
 	int ret;
 
 	/* is this one of own objects? */
@@ -251,6 +252,20 @@ struct drm_gem_object *exynos_dmabuf_prime_import(struct drm_device *drm_dev,
 	buffer->size = dma_buf->size;
 	buffer->dma_addr = sg_dma_address(sgl);
 
+	npages = dma_buf->size >> PAGE_SHIFT;
+	buffer->pages = drm_malloc_ab(npages, sizeof(struct page *));
+	if (!buffer->pages) {
+		ret = -ENOMEM;
+		goto err_free_gem;
+	}
+
+	ret = drm_prime_sg_to_page_addr_arrays(sgt, buffer->pages, NULL,
+			npages);
+	if (ret < 0) {
+		drm_free_large(buffer->pages);
+		goto err_free_gem;
+	}
+
 	if (sgt->nents == 1) {
 		/* always physically continuous memory if sgt->nents is 1. */
 		exynos_gem_obj->flags |= EXYNOS_BO_CONTIG;
@@ -273,6 +288,9 @@ struct drm_gem_object *exynos_dmabuf_prime_import(struct drm_device *drm_dev,
 
 	return &exynos_gem_obj->base;
 
+err_free_gem:
+	drm_gem_object_release(&exynos_gem_obj->base);
+	kfree(exynos_gem_obj);
 err_free_buffer:
 	kfree(buffer);
 	buffer = NULL;
diff --git a/drivers/gpu/drm/exynos/exynos_drm_gem.c b/drivers/gpu/drm/exynos/exynos_drm_gem.c
index 0d5b969..d320acd 100644
--- a/drivers/gpu/drm/exynos/exynos_drm_gem.c
+++ b/drivers/gpu/drm/exynos/exynos_drm_gem.c
@@ -83,26 +83,14 @@ static int exynos_drm_gem_map_buf(struct drm_gem_object *obj,
 {
 	struct exynos_drm_gem_obj *exynos_gem_obj = to_exynos_gem_obj(obj);
 	struct exynos_drm_gem_buf *buf = exynos_gem_obj->buffer;
-	struct scatterlist *sgl;
 	unsigned long pfn;
-	int i;
-
-	if (!buf->sgt)
-		return -EINTR;
 
 	if (page_offset >= (buf->size >> PAGE_SHIFT)) {
 		DRM_ERROR("invalid page offset\n");
 		return -EINVAL;
 	}
 
-	sgl = buf->sgt->sgl;
-	for_each_sg(buf->sgt->sgl, sgl, buf->sgt->nents, i) {
-		if (page_offset < (sgl->length >> PAGE_SHIFT))
-			break;
-		page_offset -=	(sgl->length >> PAGE_SHIFT);
-	}
-
-	pfn = __phys_to_pfn(sg_phys(sgl)) + page_offset;
+	pfn = page_to_pfn(buf->pages[page_offset]);
 
 	return vm_insert_mixed(vma, f_vaddr, pfn);
 }
-- 
1.9.1

_______________________________________________
dri-devel mailing list
dri-devel@lists.freedesktop.org
http://lists.freedesktop.org/mailman/listinfo/dri-devel

^ permalink raw reply related	[flat|nested] 35+ messages in thread

end of thread, other threads:[~2015-11-17  9:42 UTC | newest]

Thread overview: 35+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2015-07-28  8:53 [PATCH 01/14] drm/exynos: stop using sgtable in page fault handler Joonyoung Shim
2015-07-28  8:53 ` [PATCH 02/14] drm/exynos: remove function convert_to_vm_err_msg Joonyoung Shim
2015-08-16  4:39   ` Inki Dae
2015-07-28  8:53 ` [PATCH 03/14] drm/exynos: remove mutex locking in pagefault handler Joonyoung Shim
2015-07-28  8:53 ` [PATCH 04/14] drm/exynos: remove function exynos_drm_gem_map_buf Joonyoung Shim
2015-07-28  8:53 ` [PATCH 05/14] drm/exynos: stop copying sg table Joonyoung Shim
2015-07-28  8:53 ` [PATCH 06/14] drm/exynos: remove unused fields of struct exynos_drm_gem_buf Joonyoung Shim
2015-07-28  8:53 ` [PATCH 07/14] drm/exynos: use ERR_PTR instead of NULL in exynos_drm_gem_init Joonyoung Shim
2015-07-28  8:53 ` [PATCH 08/14] drm/exynos: create a fake mmap offset with gem creation Joonyoung Shim
2015-08-16  4:50   ` Inki Dae
2015-08-17  5:29     ` Joonyoung Shim
2015-08-17  7:39       ` Inki Dae
2015-11-16 16:22   ` Daniel Vetter
2015-11-16 16:23     ` Daniel Vetter
2015-11-17  2:53       ` Inki Dae
2015-11-17  9:42         ` Daniel Vetter
2015-07-28  8:53 ` [PATCH 09/14] drm/exynos: remove call to drm_gem_free_mmap_offset() Joonyoung Shim
2015-08-16  5:07   ` Inki Dae
2015-08-17  5:29     ` Joonyoung Shim
2015-08-17  7:52       ` Inki Dae
2015-08-17  8:17         ` Joonyoung Shim
2015-08-17  9:03           ` Inki Dae
2015-09-24  1:01             ` Joonyoung Shim
2015-09-25  9:15               ` Inki Dae
2015-09-30  5:45                 ` Joonyoung Shim
2015-07-28  8:53 ` [PATCH 10/14] drm/exynos: remove function check_gem_flags Joonyoung Shim
2015-08-06 10:00   ` Daniel Stone
2015-08-11  0:23     ` Joonyoung Shim
2015-08-16  5:14   ` Inki Dae
2015-07-28  8:53 ` [PATCH 11/14] drm/exynos: remove function update_vm_cache_attr Joonyoung Shim
2015-07-28  8:53 ` [PATCH 12/14] drm/exynos: remove function roundup_gem_size Joonyoung Shim
2015-07-28  8:53 ` [PATCH 13/14] drm/exynos: use prime helpers Joonyoung Shim
2015-08-16  5:26   ` Inki Dae
2015-08-16  5:43     ` Inki Dae
2015-07-28  8:53 ` [PATCH 14/14] drm/exynos: merge exynos_drm_buf.c to exynos_drm_gem.c Joonyoung Shim

This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.