From patchwork Mon Jan 28 13:38:48 2013 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Rahul Sharma X-Patchwork-Id: 2060591 Return-Path: X-Original-To: patchwork-dri-devel@patchwork.kernel.org Delivered-To: patchwork-process-083081@patchwork1.kernel.org Received: from gabe.freedesktop.org (gabe.freedesktop.org [131.252.210.177]) by patchwork1.kernel.org (Postfix) with ESMTP id CAD6F3FCD5 for ; Tue, 29 Jan 2013 09:34:12 +0000 (UTC) Received: from gabe.freedesktop.org (localhost [127.0.0.1]) by gabe.freedesktop.org (Postfix) with ESMTP id D59A7E5EA5 for ; Tue, 29 Jan 2013 01:34:12 -0800 (PST) X-Original-To: dri-devel@lists.freedesktop.org Delivered-To: dri-devel@lists.freedesktop.org Received: from mailout4.samsung.com (mailout4.samsung.com [203.254.224.34]) by gabe.freedesktop.org (Postfix) with ESMTP id 188D5E5E9C for ; Mon, 28 Jan 2013 05:18:17 -0800 (PST) Received: from epcpsbgm1.samsung.com (epcpsbgm1 [203.254.230.26]) by mailout4.samsung.com (Oracle Communications Messaging Server 7u4-24.01(7.0.4.24.0) 64bit (built Nov 17 2011)) with ESMTP id <0MHC0059W7M5TXB0@mailout4.samsung.com> for dri-devel@lists.freedesktop.org; Mon, 28 Jan 2013 22:18:14 +0900 (KST) Received: from epcpsbgm1.samsung.com ( [172.20.52.125]) by epcpsbgm1.samsung.com (EPCPMTA) with SMTP id AE.C9.03918.69A76015; Mon, 28 Jan 2013 22:18:14 +0900 (KST) X-AuditID: cbfee61a-b7f7d6d000000f4e-6b-51067a9613cb Received: from epmmp2 ( [203.254.227.17]) by epcpsbgm1.samsung.com (EPCPMTA) with SMTP id 2E.C9.03918.69A76015; Mon, 28 Jan 2013 22:18:14 +0900 (KST) Received: from chrome-ubuntu.sisodomain.com ([107.108.73.106]) by mmp2.samsung.com (Oracle Communications Messaging Server 7u4-24.01(7.0.4.24.0) 64bit (built Nov 17 2011)) with ESMTPA id <0MHC005J87KRAR30@mmp2.samsung.com> for dri-devel@lists.freedesktop.org; Mon, 28 Jan 2013 22:18:14 +0900 (KST) From: Rahul Sharma To: dri-devel@lists.freedesktop.org Subject: [PATCH] drm: modify pages_to_sg prime helper to create optimized SG table Date: Mon, 28 Jan 2013 08:38:48 -0500 Message-id: <1359380328-23058-1-git-send-email-rahul.sharma@samsung.com> X-Mailer: git-send-email 1.8.0 X-Brightmail-Tracker: H4sIAAAAAAAAA+NgFrrFLMWRmVeSWpSXmKPExsWyRsSkVndaFVugwcnvZhZXvr5nc2D0uN99 nCmAMYrLJiU1J7MstUjfLoEr48fCfWwF8/krJnz+wdzAeJyni5GTQ0LAROLL6rOMELaYxIV7 69m6GLk4hASWMkosbX/ODlO06O10FhBbSGA6o8TJByoQRRuZJG4uWsIMkmAT0JWYffAZ2CQR AWWJvxNXgdnMAiESq+7/AWrm4BAGsred4QIJswioSkxc1MAKYvMKeEh8vXWMBWKXnMSHPY/Y QeZLCOxgk3jz6Qs7RIOAxLfJh8DmSAjISmw6wAxRLylxcMUNlgmMggsYGVYxiqYWJBcUJ6Xn GuoVJ+YWl+al6yXn525iBIbU6X/PpHYwrmywOMQowMGoxMP7I40lUIg1say4MvcQowQHs5II 7+1itkAh3pTEyqrUovz4otKc1OJDjMlAyycyS4km5wPDPa8k3tDYxNzU2NTSyMjM1JQ0YSVx XsZTTwKEBNITS1KzU1MLUotgtjBxcEo1MG5qf5z3dEOR59vo+EtNKidWbBWL7tjiUBgfmJI+ lWv7kvzqstbqx68OPwjZMqPi0Frrsz/X7iw9EKX6scQxPLlRJaF8b6GQ1NYrxdKlSb/rQha/ Eu8webCI1ZDtb/e7XyGfTi3/viSjaPOaDf/qj71xDE0+6yWyKuvs3pPHd6+eeZjzyoKmzDQl luKMREMt5qLiRACX7m8ubQIAAA== X-Brightmail-Tracker: H4sIAAAAAAAAA+NgFupkkeLIzCtJLcpLzFFi42I5/e+xoO60KrZAg8UzVSyufH3P5sDocb/7 OFMAY1QDo01GamJKapFCal5yfkpmXrqtkndwvHO8qZmBoa6hpYW5kkJeYm6qrZKLT4CuW2YO 0FglhbLEnFKgUEBicbGSvh2mCaEhbroWMI0Rur4hQXA9RgZoIGENY8aPhfvYCubzV0z4/IO5 gfE4TxcjJ4eEgInEorfTWSBsMYkL99azgdhCAtMZJU4+UOli5AKyNzJJ3Fy0hBkkwSagKzH7 4DNGEFtEQFni78RVYDazQIjEqvt/gAZxcAgD2dvOcIGEWQRUJSYuamAFsXkFPCS+3joGtUtO 4sOeR+wTGLkXMDKsYhRNLUguKE5KzzXUK07MLS7NS9dLzs/dxAgO2GdSOxhXNlgcYhTgYFTi 4f2RxhIoxJpYVlyZe4hRgoNZSYT3djFboBBvSmJlVWpRfnxRaU5q8SHGZKDtE5mlRJPzgdGU VxJvaGxibmpsamliYWJmSZqwkjgv46knAUIC6YklqdmpqQWpRTBbmDg4pRoYz5lV7Pr9N/jp u+A/6lp/H2i1bs8xZ/u2wDxdfKvwvMMrzX6yTDjm8THQUcnR1STXbtJLFanjOlq6KRNfN80X CWO3LZqftpz1Ul9ihBant3GakOInl8IdaZZmkn7TTngrWE3tXrwv8u//KdOjr+xnSjzBYvvz NT/3++8Zd6e0pQuZiSycbxyqxFKckWioxVxUnAgA8s8aZZwCAAA= DLP-Filter: Pass X-MTR: 20000000000000000@CPGS X-CFilter-Loop: Reflected X-Mailman-Approved-At: Tue, 29 Jan 2013 01:31:30 -0800 Cc: joshi@samsung.com X-BeenThere: dri-devel@lists.freedesktop.org X-Mailman-Version: 2.1.13 Precedence: list List-Id: Direct Rendering Infrastructure - Development List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , MIME-Version: 1.0 Sender: dri-devel-bounces+patchwork-dri-devel=patchwork.kernel.org@lists.freedesktop.org Errors-To: dri-devel-bounces+patchwork-dri-devel=patchwork.kernel.org@lists.freedesktop.org It fixes the issue arises due to passing 'nr_pages' in place of 'nents' to sg_alloc_table. When ARM_HAS_SG_CHAIN is disabled, it is causing failure in creating SG table for the buffers having more than 204 physical pages i.e. equal to SG_MAX_SINGLE_ALLOC. When using sg_alloc_table_from_pages interface, in place of sg_alloc_table, page list will be passes to get each contiguous section which is represented by a single entry in the table. For a Contiguous Buffer, number of entries should be equal to 1. Following check is causing the failure which is not applicable for Non-Contig buffers: if (WARN_ON_ONCE(nents > max_ents)) return -EINVAL; Above patch is well tested for EXYNOS4 and EXYNOS5 for with/wihtout IOMMU supprot. NOUVEAU and RADEON platforms also depends on drm_prime_pages_to_sg helper function. This set is base on "exynos-drm-fixes" branch at http://git.kernel.org/?p=linux/kernel/git/daeinki/drm-exynos.git Signed-off-by: Rahul Sharma Reviewed-by: Aaron Plattner Tested-by: Aaron Plattner --- drivers/gpu/drm/drm_prime.c | 8 ++------ 1 file changed, 2 insertions(+), 6 deletions(-) diff --git a/drivers/gpu/drm/drm_prime.c b/drivers/gpu/drm/drm_prime.c index 7f12573..072ee08 100644 --- a/drivers/gpu/drm/drm_prime.c +++ b/drivers/gpu/drm/drm_prime.c @@ -217,21 +217,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, + nr_pages << PAGE_SHIFT, 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);