From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1753341AbbFSCvX (ORCPT ); Thu, 18 Jun 2015 22:51:23 -0400 Received: from regular1.263xmail.com ([211.150.99.135]:34121 "EHLO regular1.263xmail.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1752933AbbFSCvO (ORCPT ); Thu, 18 Jun 2015 22:51:14 -0400 X-263anti-spam: KSV:0; X-MAIL-GRAY: 0 X-MAIL-DELIVERY: 1 X-KSVirus-check: 0 X-ABS-CHECKED: 4 X-ADDR-CHECKED: 0 X-RL-SENDER: mark.yao@rock-chips.com X-FST-TO: linux@arm.linux.org.uk X-SENDER-IP: 58.22.7.114 X-LOGIN-NAME: mark.yao@rock-chips.com X-UNIQUE-TAG: X-ATTACHMENT-NUM: 0 X-DNS-TYPE: 0 Message-ID: <5583838E.7080001@rock-chips.com> Date: Fri, 19 Jun 2015 10:50:54 +0800 From: Mark yao User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:24.0) Gecko/20100101 Thunderbird/24.2.0 MIME-Version: 1.0 To: Russell King - ARM Linux CC: dri-devel@lists.freedesktop.org, zwl@rock-chips.com, Daniel Vetter , David Airlie , linux-kernel@vger.kernel.org, Daniel Kurtz , tfiga@chromium.org, linux-rockchip@lists.infradead.org, Rob Clark , Philipp Zabel , xw@rock-chips.com, dkm@rock-chips.com, sandy.huang@rock-chips.com, linux-arm-kernel@lists.infradead.org, Heiko Stuebner Subject: Re: [PATCH 1/6] drm/rockchip: import dma_buf to gem References: <1434613770-6608-1-git-send-email-mark.yao@rock-chips.com> <1434613770-6608-2-git-send-email-mark.yao@rock-chips.com> <20150618105715.GJ7557@n2100.arm.linux.org.uk> In-Reply-To: <20150618105715.GJ7557@n2100.arm.linux.org.uk> Content-Type: text/plain; charset=UTF-8; format=flowed Content-Transfer-Encoding: 8bit Sender: linux-kernel-owner@vger.kernel.org List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Thanks Russell On 2015年06月18日 18:57, Russell King - ARM Linux wrote: > This is wrong. > > First, if you can only cope with a single scatterlist entry, you need to > enforce that. You can do that in your gem_prime_import_sg_table() method > by checking sgt->nents. I'm confuse that how to get coherent iova address from nocoherent scatterlist with iommu. I saw the arm_iommu_map_sg, it says that: The scatter gather list elements are merged together (if possible) and tagged with the appropriate dma address and length. I guess the map_sg maybe merge scatterlist into coherent iova address, but I don't know how to check the "if possible", and the sgt->nents not be 1 when already map to coherent iova address. checking sgt-nents = 1 can sure that iova is coherent, but when coherent iova address from nocoherent scatterlist, I think sgt->nents maybe greater than 1, is there a method can deal it? All above is my guess, maybe wrong, I only tested it with CMA buffer import. > Secondly, you're mapping an already mapped scatterlist - scatterlists > are mapped by the exporter inside dma_buf_map_attachment() for your > device. Right, found the dma_map_sg on dma_buf_map_attachment(). > > Thirdly, I hate drm_gem_prime_import() being used on ARM... it forces > drivers to do something very buggy: the DMA buffer is mapped for DMA > when the buffer is imported. If the buffer is a write-combine or cached > buffer, writes to the buffer after the import will not become visible to > the display hardware until sometime later (when they're evicted from the > caches and/or pushed out of the bus structure.) The DMA mapping should > be performed as close to the start of DMA as possible. However, this is > a long-standing issue I have with dma_buf itself and is not something you > should be too concerned with in your patch. Just bear it in mind if you > start to see corruption of imported buffers - the answer is not more > dma_map_sg() calls, but to get dma_buf fixed. Yeah, Got it. -- Mark Yao