From mboxrd@z Thu Jan 1 00:00:00 1970 From: Aaron Plattner Subject: Re: [PATCH] drm: modify pages_to_sg prime helper to create optimized SG table Date: Tue, 29 Jan 2013 09:10:40 -0800 Message-ID: <51080290.9040108@nvidia.com> References: <1359380328-23058-1-git-send-email-rahul.sharma@samsung.com> Mime-Version: 1.0 Content-Type: text/plain; charset="us-ascii"; Format="flowed" Content-Transfer-Encoding: 7bit Return-path: Received: from hqemgate03.nvidia.com (hqemgate03.nvidia.com [216.228.121.140]) by gabe.freedesktop.org (Postfix) with ESMTP id DEDBFE5DC9 for ; Tue, 29 Jan 2013 09:10:43 -0800 (PST) In-Reply-To: <1359380328-23058-1-git-send-email-rahul.sharma@samsung.com> List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Sender: dri-devel-bounces+sf-dri-devel=m.gmane.org@lists.freedesktop.org Errors-To: dri-devel-bounces+sf-dri-devel=m.gmane.org@lists.freedesktop.org To: Rahul Sharma Cc: "joshi@samsung.com" , "dri-devel@lists.freedesktop.org" List-Id: dri-devel@lists.freedesktop.org On 01/28/2013 05:38 AM, Rahul Sharma wrote: > 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 I also verified that this reduces my 2025-entry sg_table to 6 entries, so Tested-by: Aaron Plattner -- Aaron > --- > 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); >