Received: by 2002:ac0:a581:0:0:0:0:0 with SMTP id m1-v6csp6747873imm; Wed, 27 Jun 2018 12:39:37 -0700 (PDT) X-Google-Smtp-Source: AAOMgpf8LrVymgrZJsGhinOU1zGK6Dhw1ak98vpQr0/rybL4110IyWAuKh9HZn6TdIxvqjz8O/l4 X-Received: by 2002:a65:510c:: with SMTP id f12-v6mr6217620pgq.288.1530128377092; Wed, 27 Jun 2018 12:39:37 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1530128377; cv=none; d=google.com; s=arc-20160816; b=qtB6sHpzsB+cepwNp8mVG8HtT+YvR0NYK45Ab+ATgDjs2vjMaM/6vPHIl1/p/n4J2u P5BJsgjsYCfEJUvbfc6Kt/f+dqROPYgbeHxxjJb9oAwZpmnfgTiQ0Xmp3THDVorjmtRc 0DSBSh3gem9E0au5iEcFUe6Y3zCnpe3zn+HNs9zYOM8xYnKHfhJ41foAYNz2BPyWB/sA ThRcqkzsJWjlJQB9At3e3w8BT/9nz4Cp+uDtDQuTyURqIKefHIkZRIDLXevZulbzhgMO s9vXIfQrUbjKJk1/aGTOC+SQvpuICJJKNyJd2CWrmtTNbvXjhK4xU6fEJ9YRXN/oEDMn ETog== 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:arc-authentication-results; bh=N8WYTHWWyNbVY0hiaQh4bxBAIIJOKordXD5o7E5SVNw=; b=ahwl5RegJClqCIEEkS/B3/qcYQU6Lw/n8Uhmfi1x39yLeLiQ4SobWnjCgll4epthbh c1k6/JpS7mIZsaK4imBsfUUoOu7vJpkGLA5xnM9lhP2DG2YlejUGQANAFtgwA674pV/0 rS11HgfXMTsnMEtXQBbtFsfPRxOi8eirrhJus87PzloLRv5DAq+y4hSCXqjIkWtl4M/I tvpWBhzglh2AcKxaUdbexaOIr3oKk3a5uWtxX6DIeRpFu38rQk8ksHD5BtYCoFDmaerK O8fWYh0ewQgar0K1znYQTg7aT3pjxeFwgdGCqPk/a4pn5oSl1HhAKTXwH/SvnDLYxOt8 t3BQ== 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 c13-v6si4024519pgq.316.2018.06.27.12.39.22; Wed, 27 Jun 2018 12:39:37 -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 S1754963AbeF0QhO (ORCPT + 99 others); Wed, 27 Jun 2018 12:37:14 -0400 Received: from foss.arm.com ([217.140.101.70]:34280 "EHLO foss.arm.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1753490AbeF0QhN (ORCPT ); Wed, 27 Jun 2018 12:37:13 -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 A12B218A; Wed, 27 Jun 2018 09:37:12 -0700 (PDT) Received: from edgewater-inn.cambridge.arm.com (usa-sjc-imap-foss1.foss.arm.com [10.72.51.249]) by usa-sjc-imap-foss1.foss.arm.com (Postfix) with ESMTPA id 72F3A3F318; Wed, 27 Jun 2018 09:37:12 -0700 (PDT) Received: by edgewater-inn.cambridge.arm.com (Postfix, from userid 1000) id 5C8701AE3692; Wed, 27 Jun 2018 17:37:50 +0100 (BST) Date: Wed, 27 Jun 2018 17:37:50 +0100 From: Will Deacon To: Vivek Gautam Cc: Robin Murphy , "list@263.net:IOMMU DRIVERS , Joerg Roedel ," , linux-arm-kernel@lists.infradead.org, "list@263.net:IOMMU DRIVERS , Joerg Roedel ," , open list , linux-arm-msm , pdaly@codeaurora.org Subject: Re: [PATCH 1/1] iommu/arm-smmu: Add support to use Last level cache Message-ID: <20180627163749.GA8729@arm.com> References: <20180615105329.26800-1-vivek.gautam@codeaurora.org> <20180615165232.GE2202@arm.com> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: User-Agent: Mutt/1.5.23 (2014-03-12) Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Hi Vivek, 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? 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. Currently, we support three types of mapping in the SMMU: 1. DMA non-coherent (e.g. "dma-coherent" is not set on the device) Normal, Inner Shareable, Inner/Outer Non-Cacheable 2. DMA coherent (e.g. "dma-coherent" is set on the device) [IOMMU_CACHE] Normal, Inner Shareable, Inner/Outer Cacheable, Inner/Outer Write-back, Non-transient Read/Write-allocate 3. MMIO (e.g. MSI doorbell) [IOMMU_MMIO] Device-nGnRE (Outer Shareable) So either you override one of these types (I was suggesting (1)) or you need to create a new memory type, along with the infrastructure for it to be recognised on a per-device basis and used by the DMA API so that we don't get mismatched aliases on the CPU. Will