Received: by 2002:ac0:a5a6:0:0:0:0:0 with SMTP id m35-v6csp755508imm; Fri, 28 Sep 2018 06:22:22 -0700 (PDT) X-Google-Smtp-Source: ACcGV602h+c1uHgeTeBsoiuVx/dl9KqNkLQcSooL3BavxmRoTprOz+flS0dInaxmZyDUZiTZvYYV X-Received: by 2002:a63:ff46:: with SMTP id s6-v6mr14723276pgk.241.1538140941951; Fri, 28 Sep 2018 06:22:21 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1538140941; cv=none; d=google.com; s=arc-20160816; b=VaNejfr3jbEfaGWEgmFXfBU7emmOpS+fZIu4EcgQyzekECUiOSy3wmlsRNJuxpDxFp 6+TYZqyn6w4dvjd3oGor/34zf00R3BsrgXz/uaUe4MpW2kVZrD+zvVfNFrpB99tU5fpE oxr9whOTmPRjyLxnrwvSobL/PLzYE+mbl+iIzPdh1loJgxqj8lGyXU7NNPucSHDYNVM0 vpW8Rymg0gSmuoogko89wtclgzQaiPmuy/RwHctPOmMbOGCpR299p/V+ZIplxwhcKNdA 417qD4Jfm623v36UIYfUIFYUPyZIrhH3NfaWaMyNJMCJ+xePjIRDWPj38Z4YK8UzUVxp 6LDg== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:user-agent:in-reply-to :content-disposition:mime-version:references:message-id:subject:cc :to:from:date; bh=zU6gef3iDUeTaJQ7xLog/xhlDj6TVCVqCcYPLqOdTls=; b=bT3qCf+Fhki6C+EG2tFlhYmzHV7PFqPTHpDPj+rDcTljyoP7JIMTiwXGk1+fgQlo6+ pEcWhY7G7td39FC5xWBsFSOQpxmGrvjO1y0REmR66fscW/OEC2U5h/ChfG6ii4O92s61 y7DZb++RqcNe4dO0NsY3Du6zVjxM5LgQkUUfM0C/kbon2Fbb229nD4adwl4zerqzAuGM V2jO6VNWXSYO2ft+h9zp/XDPQALhkcth3LC2ZwE3TygE54QnVsemKKEgk0sNn7G1l+Td /v1PsWAKUdjpWJF/QS5ZQ9gr/k0kOIGB3Xv4KsT2RJtb4MFoEZcB/HDK95V2jvimOQzi 0fOA== ARC-Authentication-Results: i=1; mx.google.com; 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 n7-v6si1614611plp.43.2018.09.28.06.22.04; Fri, 28 Sep 2018 06:22:21 -0700 (PDT) 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; 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 S1729146AbeI1Tn0 (ORCPT + 99 others); Fri, 28 Sep 2018 15:43:26 -0400 Received: from usa-sjc-mx-foss1.foss.arm.com ([217.140.101.70]:49572 "EHLO foss.arm.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1726586AbeI1Tn0 (ORCPT ); Fri, 28 Sep 2018 15:43:26 -0400 Received: from usa-sjc-imap-foss1.foss.arm.com (unknown [10.72.51.249]) by usa-sjc-mx-foss1.foss.arm.com (Postfix) with ESMTP id 3F0F8ED1; Fri, 28 Sep 2018 06:19:41 -0700 (PDT) Received: from brain-police (usa-sjc-mx-foss1.foss.arm.com [217.140.101.70]) by usa-sjc-imap-foss1.foss.arm.com (Postfix) with ESMTPSA id 28B933F5D3; Fri, 28 Sep 2018 06:19:38 -0700 (PDT) Date: Fri, 28 Sep 2018 14:19:35 +0100 From: Will Deacon To: Vivek Gautam Cc: pdaly@codeaurora.org, linux-arm-msm , open list , "list@263.net:IOMMU DRIVERS , Joerg Roedel ," , Linux ARM , Jordan Crouse , pratikp@codeaurora.org Subject: Re: [PATCH 1/1] iommu/arm-smmu: Add support to use Last level cache Message-ID: <20180928131935.GE1577@brain-police> References: <20180615105329.26800-1-vivek.gautam@codeaurora.org> <20180615165232.GE2202@arm.com> <20180627163749.GA8729@arm.com> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: User-Agent: Mutt/1.9.4 (2018-02-28) Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Hi Vivek, On Thu, Sep 20, 2018 at 05:11:53PM +0530, Vivek Gautam wrote: > On Wed, Jun 27, 2018 at 10:07 PM Will Deacon wrote: > > On Tue, Jun 19, 2018 at 02:04:44PM +0530, Vivek Gautam wrote: > > > On Fri, Jun 15, 2018 at 10:22 PM, Will Deacon wrote: > > > > On Fri, Jun 15, 2018 at 04:23:29PM +0530, Vivek Gautam wrote: > > > >> Qualcomm SoCs have an additional level of cache called as > > > >> System cache or Last level cache[1]. This cache sits right > > > >> before the DDR, and is tightly coupled with the memory > > > >> controller. > > > >> The cache is available to all the clients present in the > > > >> SoC system. The clients request their slices from this system > > > >> cache, make it active, and can then start using it. For these > > > >> clients with smmu, to start using the system cache for > > > >> dma buffers and related page tables [2], few of the memory > > > >> attributes need to be set accordingly. > > > >> This change makes the related memory Outer-Shareable, and > > > >> updates the MAIR with necessary protection. > > > >> > > > >> The MAIR attribute requirements are: > > > >> Inner Cacheablity = 0 > > > >> Outer Cacheablity = 1, Write-Back Write Allocate > > > >> Outer Shareablity = 1 > > > > > > > > Hmm, so is this cache coherent with the CPU or not? > > > > > > Thanks for reviewing. > > > Yes, this LLC is cache coherent with CPU, so we mark for Outer-cacheable. > > > The different masters such as GPU as able to allocated and activate a slice > > > in this Last Level Cache. > > > > What I mean is, for example, if the CPU writes some data using Normal, Inner > > Shareable, Inner/Outer Cacheable, Inner/Outer Write-back, Non-transient > > Read/Write-allocate and a device reads that data using your MAIR encoding > > above, is the device guaranteed to see the CPU writes after the CPU has > > executed a DSB instruction? > > No, these MAIR configurations don't guarantee that devices will have > coherent view > of what CPU writes. Not all devices can snoop into CPU caches (only IO-Coherent > devices can). > So a normal cached memory configuration in CPU MMU tables, and SMMU page tables > is valid only for few devices that are IO-coherent. > > Moreover, CPU can lookup in system cache, and so do all devices; > allocation will depend on h/w configurations and memory attributes. > So anything that CPU caches in system cache will be coherently visible > to devices. > > > > > I don't think so, because the ARM ARM would say that there's a mismatch on > > the Inner Cacheability attribute. > > > > > > Why don't normal > > > > non-cacheable mappings allocated in the LLC by default? > > > > > > Sorry, I couldn't fully understand your question here. > > > Few of the masters on qcom socs are not io-coherent, so for them > > > the IC has to be marked as 0. > > > > By IC you mean Inner Cacheability? In your MAIR encoding above, it is zero > > so I don't understand the problem. What goes wrong if non-coherent devices > > use your MAIR encoding for their DMA buffers? > > > > > But they are able to use the LLC with OC marked as 1. > > > > The issue here is that whatever attributes we put in the SMMU need to align > > with the attributes used by the CPU in order to avoid introducing mismatched > > aliases. > > Not really, right? > Devices can use Inner non-Cacheable, Outer-cacheable (IC=0, OC=1) to allocate > into the system cache (as these devices don't want to allocate in > their inner caches), > and the CPU will have a coherent view of these buffers/page-tables. > This should be > a normal cached non-IO-Coherent memory. > > But anything that CPU writes using Normal, Inner Shareable, > Inner/Outer Cacheable, > Inner/Outer Write-back, Non-transient Read/Write-allocate, may not be visible > to the device. > > Also added Jordan, and Pratik to this thread. Sorry, but I'm still completely confused. If you only end up with mismatched memory attributes in the non-coherent case, then why can't you just follow my suggestion to override the attributes for non-coherent mappings on your SoC? Will