[RFC][PATCH] drm/prime: fixed to allocate sg table considering contiguous pages

Seung-Woo Kim sw0312.kim at samsung.com
Fri Apr 26 01:48:43 PDT 2013


Allocating scatter table with sg_alloc_table() does not consider
contiguous pages. Because sg_alloc_table_from_pages() merges
contigous pages into a signle scatter entry, this patch fixes to
allocate scatter table with it from drm_prime_pages_to_sg().

Signed-off-by: Seung-Woo Kim <sw0312.kim at samsung.com>
---
 drivers/gpu/drm/drm_prime.c |    8 ++------
 1 files changed, 2 insertions(+), 6 deletions(-)

diff --git a/drivers/gpu/drm/drm_prime.c b/drivers/gpu/drm/drm_prime.c
index 366910d..8c098a3 100644
--- a/drivers/gpu/drm/drm_prime.c
+++ b/drivers/gpu/drm/drm_prime.c
@@ -401,21 +401,17 @@ int drm_prime_fd_to_handle_ioctl(struct drm_device *dev, void *data,
 struct sg_table *drm_prime_pages_to_sg(struct page **pages, int nr_pages)
 {
 	struct sg_table *sg = NULL;
-	struct scatterlist *iter;
-	int i;
 	int ret;
 
 	sg = kmalloc(sizeof(struct sg_table), GFP_KERNEL);
 	if (!sg)
 		goto out;
 
-	ret = sg_alloc_table(sg, nr_pages, GFP_KERNEL);
+	ret = sg_alloc_table_from_pages(sg, pages, nr_pages,
+			0, PAGE_SIZE * nr_pages, GFP_KERNEL);
 	if (ret)
 		goto out;
 
-	for_each_sg(sg->sgl, iter, nr_pages, i)
-		sg_set_page(iter, pages[i], PAGE_SIZE, 0);
-
 	return sg;
 out:
 	kfree(sg);
-- 
1.7.4.1



More information about the dri-devel mailing list