From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1755918AbcEWNfH (ORCPT ); Mon, 23 May 2016 09:35:07 -0400 Received: from foss.arm.com ([217.140.101.70]:51245 "EHLO foss.arm.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1753986AbcEWNfF (ORCPT ); Mon, 23 May 2016 09:35:05 -0400 Date: Mon, 23 May 2016 14:35:00 +0100 From: Catalin Marinas To: Robin Murphy Cc: Shunqian Zheng , joro@8bytes.org, heiko@sntech.de, Mark Rutland , linux-rockchip@lists.infradead.org, iommu@lists.linux-foundation.org, linux-kernel@vger.kernel.org, Simon Subject: Re: [PATCH 4/5] iommu/rockchip: add ARM64 cache flush operation for iommu Message-ID: <20160523133500.GF4892@e104818-lin.cambridge.arm.com> References: <1463967439-13354-1-git-send-email-zhengsq@rock-chips.com> <1463967439-13354-5-git-send-email-zhengsq@rock-chips.com> <5742DEFE.1040902@arm.com> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <5742DEFE.1040902@arm.com> User-Agent: Mutt/1.5.23 (2014-03-12) Sender: linux-kernel-owner@vger.kernel.org List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On Mon, May 23, 2016 at 11:44:14AM +0100, Robin Murphy wrote: > On 23/05/16 02:37, Shunqian Zheng wrote: > >From: Simon > > > >Signed-off-by: Simon > >--- > > drivers/iommu/rockchip-iommu.c | 4 ++++ > > 1 file changed, 4 insertions(+) > > > >diff --git a/drivers/iommu/rockchip-iommu.c b/drivers/iommu/rockchip-iommu.c > >index 043d18c..1741b65 100644 > >--- a/drivers/iommu/rockchip-iommu.c > >+++ b/drivers/iommu/rockchip-iommu.c > >@@ -95,12 +95,16 @@ struct rk_iommu { > > > > static inline void rk_table_flush(u32 *va, unsigned int count) > > { > >+#if defined(CONFIG_ARM) > > phys_addr_t pa_start = virt_to_phys(va); > > phys_addr_t pa_end = virt_to_phys(va + count); > > size_t size = pa_end - pa_start; > > > > __cpuc_flush_dcache_area(va, size); > > outer_flush_range(pa_start, pa_end); > >+#elif defined(CONFIG_ARM64) > >+ __dma_flush_range(va, va + count); > >+#endif > > Ugh, please don't use arch-private cache maintenance functions directly from > a driver. Allocating/mapping page tables to be read by the IOMMU is still > DMA, so using the DMA APIs is the correct way to manage them, *especially* > if it needs to work across multiple architectures. I fully agree, these functions should not be used in drivers. -- Catalin