From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S965202AbcFMKVs (ORCPT ); Mon, 13 Jun 2016 06:21:48 -0400 Received: from mail-qk0-f175.google.com ([209.85.220.175]:34076 "EHLO mail-qk0-f175.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S964953AbcFMKVq convert rfc822-to-8bit (ORCPT ); Mon, 13 Jun 2016 06:21:46 -0400 MIME-Version: 1.0 In-Reply-To: <575E834C.30305@gmail.com> References: <1465392392-2003-1-git-send-email-zhengsq@rock-chips.com> <1465392392-2003-7-git-send-email-zhengsq@rock-chips.com> <575E834C.30305@gmail.com> From: Tomasz Figa Date: Mon, 13 Jun 2016 19:21:26 +0900 Message-ID: Subject: Re: [PATCH v2 6/7] iommu/rockchip: use DMA API to map, to flush cache To: shunqian.zheng@gmail.com Cc: Shunqian Zheng , Mark Rutland , devicetree@vger.kernel.org, =?UTF-8?Q?Heiko_St=C3=BCbner?= , David Airlie , Joerg Roedel , linux@armlinux.org.uk, dri-devel , "linux-kernel@vger.kernel.org" , "open list:ARM/Rockchip SoC..." , "open list:IOMMU DRIVERS , Rob Herring , simon xue , linux-arm-kernel@lists.infradead.org" Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8BIT Sender: linux-kernel-owner@vger.kernel.org List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On Mon, Jun 13, 2016 at 6:56 PM, Shunqian Zheng wrote: > Hi > > On 2016年06月10日 17:10, Tomasz Figa wrote: >> >> Hi, >> >> On Wed, Jun 8, 2016 at 10:26 PM, Shunqian Zheng >> wrote: >>> >>> Use DMA API instead of architecture internal functions like >>> __cpuc_flush_dcache_area() etc. >>> >>> To support the virtual device like DRM the virtual slave iommu >>> added in the previous patch, attaching to which the DRM can use >>> it own domain->dev for dma_map_*(), dma_sync_*() even VOP is disabled. >>> >>> With this patch, this driver is available for ARM64 like RK3399. >>> >> Could we instead simply allocate coherent memory for page tables using >> dma_alloc_coherent() and skip any flushing on CPU side completely? If >> I'm looking correctly, the driver only reads back the page directory >> when checking if there is a need to allocate new page table, so there >> shouldn't be any significant penalty for disabling the cache. > > I try to use dma_alloc_coherent() to replace the dma_map_single(), > but it doesn't work for me properly. > Because the DRM uses the iommu_dma_ops instead the swiotlb_dma_ops after > attaching > to iommu, so when the iommu domain need to alloc a new page in > rk_iommu_map(), > it would call: > rk_iommu_map() --> dma_alloc_coherent() --> ops->alloc() --> iommu_map() > --> rk_iommu_map() It shouldn't call iommu_map(), because the IOMMU is not behind another IOMMU. Are you sure you called dma_alloc_coherent() on behalf of the IOMMU struct device and not the DRM device? Best regards, Tomasz