From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1755917AbbDOCVV (ORCPT ); Tue, 14 Apr 2015 22:21:21 -0400 Received: from mail-qk0-f182.google.com ([209.85.220.182]:36082 "EHLO mail-qk0-f182.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1755848AbbDOCVM convert rfc822-to-8bit (ORCPT ); Tue, 14 Apr 2015 22:21:12 -0400 MIME-Version: 1.0 In-Reply-To: <1428993067.13552.14.camel@mhfsdcap03> References: <1425638900-24989-1-git-send-email-yong.wu@mediatek.com> <1425638900-24989-3-git-send-email-yong.wu@mediatek.com> <1426677749.22581.38.camel@mhfsdcap03> <1428993067.13552.14.camel@mhfsdcap03> From: Tomasz Figa Date: Wed, 15 Apr 2015 11:20:51 +0900 Message-ID: Subject: Re: [PATCH 2/5] iommu/mediatek: Add mt8173 IOMMU driver To: Yong Wu Cc: Robin Murphy , Mark Rutland , devicetree@vger.kernel.org, srv_heupstream@mediatek.com, Catalin Marinas , Joerg Roedel , Will Deacon , "linux-kernel@vger.kernel.org" , iommu@lists.linux-foundation.org, Rob Herring , Daniel Kurtz , Sasha Hauer , Matthias Brugger , linux-mediatek@lists.infradead.org, "linux-arm-kernel@lists.infradead.org" , Lucas Stach 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 Tue, Apr 14, 2015 at 3:31 PM, Yong Wu wrote: >> >> >> >> > + >> >> > + piommu->protect_va = devm_kmalloc(piommu->dev, MTK_PROTECT_PA_ALIGN*2, >> >> >> >> style: Operators like * should have space on both sides. >> >> >> >> > + GFP_KERNEL); >> >> >> >> Shouldn't dma_alloc_coherent() be used for this? >> > We don't care the data in it. I think they are the same. Could you >> > help tell me why dma_alloc_coherent may be better. >> >> Can you guarantee that at the time you allocate the memory using >> devm_kmalloc() the memory is not dirty (i.e. some write back data are >> stored in CPU cache) and is not going to be written back in some time, >> overwriting data put there by IOMMU hardware? >> > As I noted in the function "mtk_iommu_hw_init": > > /* protect memory,HW will write here while translation fault */ > protectpa = __virt_to_phys(piommu->protect_va); > > We don’t care the content of this buffer, It is ok even though its > data is dirty. > It seem to be a the protect memory. While a translation fault > happened, The iommu HW will overwrite here instead of writing to the > fault physical address which may be 0 or some random address. > Do you mean that it's just a dummy page for hardware behind the IOMMU to access when the mapping is not available? How would that work with potential on demand paging when the hardware needs to be blocked until the mapping is created? Best regards, Tomasz