Received: by 10.223.164.202 with SMTP id h10csp1326160wrb; Sat, 11 Nov 2017 04:48:21 -0800 (PST) X-Google-Smtp-Source: AGs4zMZR21ssIrLa24FOzNF7Jw1j2dobLg74GdFQvMUJsPJBy8B5iEXsyN7FYJ+oINSwL8daRSNf X-Received: by 10.84.217.142 with SMTP id p14mr3477555pli.427.1510404501363; Sat, 11 Nov 2017 04:48:21 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1510404501; cv=none; d=google.com; s=arc-20160816; b=u+BDB5e/42hsFHxW9mETd8xRx+uuwoCCxWNXDb3D29rwh/Cas2v9Dk6NwTFNZ8NHht uOg4mSJ0wYUt8lZKan9z9MXjetdbvz+1quRv6qK9JpQ5coxcoPjY6zJmhXvg9PFIGpCg GxB//7ZkLCxQFKAuLGw8KKVcQVlV0kXABi/JdKXm517TulN4qvdbm6gyjqW02P5ztu42 dxRFGtBR3OX+WFyUFPp4WVx6PUEfey5qX3frrt7GIBnfobe5Ek2WhukgpUpFoFK9flWM 8y5h4afGkO5JQtS0UPCZrmC+Nw37rt5KTIjOBshFzZGHJQVjBjX96PM+eK4fQyhoTLuh ZPKw== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:content-transfer-encoding:mime-version :references:in-reply-to:organization:message-id:date:subject:cc:to :from:dkim-signature:arc-authentication-results; bh=li8rjg64tuGnMcO3pypkLlMzbS7h9fOCVSrHmalOQCM=; b=VMG6W/prqkIfJp2HzfnmSdoLVOkatA1SizNpGZBAbf3b1k+q8DdRXBT7nrYxjNBldR imD12UKp9xpwcVNiC+vGnQ8F6ZUmPnwzLWYobg+fGShspoYopsb13RdZbrSjs545Ji06 nxMzuRjE7oGezcitnfplQy/mIS9/hndmJG5QvMdHZcIBHujKTlBqRi6OZ+0iJKl225WL fSJFsTJu0HwxRvl65gqpfx7wvgwxxAnKvz0OlM+ITOd1aAhRNsFEWt0NVMX2Vc9ND14Y TgEiKXlZZlV/IAxG4kp67gkYTlDIE1lwh9qWK7Y8G/eX7wJezwG/v5qU2QrTQ6ijFbmo y2pw== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass (test mode) header.i=@ideasonboard.com header.s=mail header.b=FsTW5yIc; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id z1si10691665pge.647.2017.11.11.04.48.08; Sat, 11 Nov 2017 04:48:21 -0800 (PST) Received-SPF: pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) client-ip=209.132.180.67; Authentication-Results: mx.google.com; dkim=pass (test mode) header.i=@ideasonboard.com header.s=mail header.b=FsTW5yIc; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1753709AbdKKMr3 (ORCPT + 83 others); Sat, 11 Nov 2017 07:47:29 -0500 Received: from galahad.ideasonboard.com ([185.26.127.97]:46988 "EHLO galahad.ideasonboard.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1752484AbdKKMr1 (ORCPT ); Sat, 11 Nov 2017 07:47:27 -0500 Received: from avalon.localnet (unknown [182.232.77.77]) by galahad.ideasonboard.com (Postfix) with ESMTPSA id 630EE2021B; Sat, 11 Nov 2017 13:46:14 +0100 (CET) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=ideasonboard.com; s=mail; t=1510404374; bh=n5cVdNApQLDndVfuxydG2sIpN4xapr9hEmjEl6Udtc8=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=FsTW5yIcn91wqUW+m04eAi0qZmoSsqpLwopzqmQ88OoFB4Ym9q8+5QspScbPtIxYP d240+oykeQj+jsFL8GqyiL7vI52z+1kGOrJVYasx16WIcY8GBHufi7Ggby961ZYQL7 FSqZVf1qjfb1V2+5hUic3NuSWDo8a0HvpLVnaTxE= From: Laurent Pinchart To: Liviu Dudau Cc: Daniel Vetter , Jani Nikula , Sean Paul , David Airlie , Brian Starkey , Mali DP Maintainers , DRI-devel , LKML , intel-gfx@lists.freedesktop.org, Liviu Dudau Subject: Re: [PATCH v2] drm: gem_cma_helper.c: Allow importing of contiguous scatterlists with nents > 1 Date: Sat, 11 Nov 2017 14:47:35 +0200 Message-ID: <26071297.cMn4QuKrlS@avalon> Organization: Ideas on Board Oy In-Reply-To: <20171110133310.1225-1-Liviu.Dudau@arm.com> References: <2213365.Z1vsgl9bDt@avalon> <20171110133310.1225-1-Liviu.Dudau@arm.com> MIME-Version: 1.0 Content-Transfer-Encoding: 7Bit Content-Type: text/plain; charset="us-ascii" Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Hi Liviu, Thank you for the patch. On Friday, 10 November 2017 15:33:10 EET Liviu Dudau wrote: > drm_gem_cma_prime_import_sg_table() will fail if the number of entries > in the sg_table > 1. However, you can have a device that uses an IOMMU > engine and can map a discontiguous buffer with multiple entries that > have consecutive sg_dma_addresses, effectively making it contiguous. > Allow for that scenario by testing the entries in the sg_table for > contiguous coverage. > > Reviewed-by: Laurent Pinchart > Signed-off-by: Liviu Dudau > --- > > Laurent, > > Thanks for the review! I would like to ask for one more favour: if you > are OK with this version, can you pull this patch through the drm-misc tree? I could, but I'd first need to set dim up, and I'm currently abroad with a bad internet connection and a big deadline for the middle of next week (I know, lots of excuses), so it's not very convenient for me at this time. > drivers/gpu/drm/drm_gem_cma_helper.c | 22 ++++++++++++++++++++-- > include/drm/drm_gem_cma_helper.h | 4 +++- > 2 files changed, 23 insertions(+), 3 deletions(-) > > diff --git a/drivers/gpu/drm/drm_gem_cma_helper.c > b/drivers/gpu/drm/drm_gem_cma_helper.c index 020e7668dfaba..43b179212052d > 100644 > --- a/drivers/gpu/drm/drm_gem_cma_helper.c > +++ b/drivers/gpu/drm/drm_gem_cma_helper.c > @@ -482,8 +482,26 @@ drm_gem_cma_prime_import_sg_table(struct drm_device > *dev, { > struct drm_gem_cma_object *cma_obj; > > - if (sgt->nents != 1) > - return ERR_PTR(-EINVAL); > + if (sgt->nents != 1) { > + /* check if the entries in the sg_table are contiguous */ > + dma_addr_t next_addr = sg_dma_address(sgt->sgl); > + struct scatterlist *s; > + unsigned int i; > + > + for_each_sg(sgt->sgl, s, sgt->nents, i) { > + /* > + * sg_dma_address(s) is only valid for entries > + * that have sg_dma_len(s) != 0 > + */ > + if (!sg_dma_len(s)) > + continue; > + > + if (sg_dma_address(s) != next_addr) > + return ERR_PTR(-EINVAL); > + > + next_addr = sg_dma_address(s) + sg_dma_len(s); > + } > + } > > /* Create a CMA GEM buffer. */ > cma_obj = __drm_gem_cma_create(dev, attach->dmabuf->size); > diff --git a/include/drm/drm_gem_cma_helper.h > b/include/drm/drm_gem_cma_helper.h index 58a739bf15f1f..214aa85adc8d5 > 100644 > --- a/include/drm/drm_gem_cma_helper.h > +++ b/include/drm/drm_gem_cma_helper.h > @@ -8,7 +8,9 @@ > * struct drm_gem_cma_object - GEM object backed by CMA memory allocations > * @base: base GEM object > * @paddr: physical address of the backing memory > - * @sgt: scatter/gather table for imported PRIME buffers > + * @sgt: scatter/gather table for imported PRIME buffers. The table can > have + * more than one entry but they are guaranteed to have > contiguous + * DMA addresses. > * @vaddr: kernel virtual address of the backing memory > */ > struct drm_gem_cma_object { -- Regards, Laurent Pinchart From 1583686206982084951@xxx Fri Nov 10 13:34:20 +0000 2017 X-GM-THRID: 1582873431061747190 X-Gmail-Labels: Inbox,Category Forums,HistoricalUnread