Received: by 2002:ac0:a5a6:0:0:0:0:0 with SMTP id m35-v6csp1142277imm; Wed, 19 Sep 2018 12:51:19 -0700 (PDT) X-Google-Smtp-Source: ANB0VdbRC0UDAXDC+hMk5079eaB9iks7Oj4rwP2Llhqd2B2TN4wwVXgDjwIrDpcPMH6nUNGBZ/Jw X-Received: by 2002:a17:902:988a:: with SMTP id s10-v6mr35063682plp.200.1537386679574; Wed, 19 Sep 2018 12:51:19 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1537386679; cv=none; d=google.com; s=arc-20160816; b=Dfxcrr3TIjygh99adTbAJCgfBxPI8VRJf0ossKEoUe+dZmH60i+ZYf9kFyk6NQmo19 RCdEAl3CkqSGyBSYOm+nH/YUqPjK+lxt3Lmg1HgL2vxyTsrCDt5eCIzmQL3t3px7/+lL dNKZc5RpFS5jV3LFJbdtQMXSlA8Ul7a2fhrSXXNJ+DxST0uW+hbyAGofzDC1tjv4olUq PGubEckdNiOjb5Lf6Oi55OBDZ06Y48s5BKPgcjzpsIzN3iR1JV8F0U/XLWki0prxZ3SR V/LJQVRgjb9zjgB50blsHYS6rznCuJJ3vzSOnxEBB3u2UWMWjayvOFdKZ3mcJaFWFnLG IVkw== 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:mail-followup-to :message-id:subject:cc:to:from:date:dmarc-filter:dkim-signature :dkim-signature; bh=h09UoBYR4gpwEt1aXgyP9yvHT0ULhXGC5CfagYhYMas=; b=s4bjf/tQir8p/kv7D8HVTC0LzG+QwJpmUvwfSTXXN1ApGA35MsJbGlw8Vflz4hjI0D vJgST9pKShnDks2QdNgAqyLM3tg513xOROIBRDK2WUvfb+drQf6A/1bF4XQ5HypFNOd9 UI2zuFNP9INAldgd3sYvcJG07D6JeZO3ysgikKsvPdaO4eZMEhSDqBJuAYLY2XcpWGhq 8icAmrq9ZdO//Gvwjxkj/gQkv3iEe284W/9ro3OFpZxIhZRSGOIh6GRBvQNQNKWuf7/e MPsKhXdCUUjir5wlG2vK3enw1Rii7Qew5nswiFMvQuV7mZBilnwiSEqzpVZWLjo0/TOW 2j2Q== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@codeaurora.org header.s=default header.b=oKUyY5cX; dkim=pass header.i=@codeaurora.org header.s=default header.b=Ln88VuGa; 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 u26-v6si19591624pge.590.2018.09.19.12.51.03; Wed, 19 Sep 2018 12:51:19 -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; dkim=pass header.i=@codeaurora.org header.s=default header.b=oKUyY5cX; dkim=pass header.i=@codeaurora.org header.s=default header.b=Ln88VuGa; 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 S1732118AbeITBPI (ORCPT + 99 others); Wed, 19 Sep 2018 21:15:08 -0400 Received: from smtp.codeaurora.org ([198.145.29.96]:38872 "EHLO smtp.codeaurora.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1731812AbeITBPH (ORCPT ); Wed, 19 Sep 2018 21:15:07 -0400 Received: by smtp.codeaurora.org (Postfix, from userid 1000) id AFF28607BD; Wed, 19 Sep 2018 19:35:43 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=codeaurora.org; s=default; t=1537385743; bh=2NzT+LzwrGCE0hqlHYzR1gSBaNSFnC9qxSW5NDVsDe8=; h=Date:From:To:Cc:Subject:References:In-Reply-To:From; b=oKUyY5cXrauBPVhxU/5qvKxlTZ5ZEhfwNw+gYDuYwGdlOCk9avTIjo6uj5mesHLa7 hr/+dM5sAc6vU7prhZQ/NqPlztAByO1G1AJmHcXIRmepFZmHtpx025wnkYC4pKibJD S7QuihADBZsQ5nzjUnOk8W2h3Coiv5lmENw4kiZk= X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on pdx-caf-mail.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-2.8 required=2.0 tests=ALL_TRUSTED,BAYES_00, DKIM_SIGNED,T_DKIM_INVALID autolearn=no autolearn_force=no version=3.4.0 Received: from jcrouse-lnx.qualcomm.com (i-global254.qualcomm.com [199.106.103.254]) (using TLSv1.2 with cipher DHE-RSA-AES128-SHA (128/128 bits)) (No client certificate requested) (Authenticated sender: jcrouse@smtp.codeaurora.org) by smtp.codeaurora.org (Postfix) with ESMTPSA id 1BFAD600ED; Wed, 19 Sep 2018 19:35:41 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=codeaurora.org; s=default; t=1537385742; bh=2NzT+LzwrGCE0hqlHYzR1gSBaNSFnC9qxSW5NDVsDe8=; h=Date:From:To:Cc:Subject:References:In-Reply-To:From; b=Ln88VuGaFGPfja59BUQ5SjPo4s41/t6bd+90U8WUFgMLG+5aifRvED0jnpYPG4tTj xjP7OWcLZsLk/9AZJGcfAhCtvOI1gNWaMyVkEA8jBrAN2oD5KFoXgUcCAeiQTNp4TP TDOHZfRwgMQrkgzdamYD6qjrdKW2zkZYZAQ0FSPY= DMARC-Filter: OpenDMARC Filter v1.3.2 smtp.codeaurora.org 1BFAD600ED Authentication-Results: pdx-caf-mail.web.codeaurora.org; dmarc=none (p=none dis=none) header.from=codeaurora.org Authentication-Results: pdx-caf-mail.web.codeaurora.org; spf=none smtp.mailfrom=jcrouse@codeaurora.org Date: Wed, 19 Sep 2018 13:35:39 -0600 From: Jordan Crouse To: Vivek Gautam Cc: Will Deacon , linux-arm-msm , "list@263.net:IOMMU DRIVERS , Joerg Roedel , " , open list , Linux ARM , pdaly@codeaurora.org Subject: Re: [PATCH 1/1] iommu/arm-smmu: Add support to use Last level cache Message-ID: <20180919193539.GB809@jcrouse-lnx.qualcomm.com> Mail-Followup-To: Vivek Gautam , Will Deacon , linux-arm-msm , "list@263.net:IOMMU DRIVERS , Joerg Roedel , " , open list , Linux ARM , pdaly@codeaurora.org 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.5.21 (2010-09-15) Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On Tue, Jul 24, 2018 at 03:13:37PM +0530, Vivek Gautam wrote: > Hi Will, > > > On Wed, Jun 27, 2018 at 10:07 PM, Will Deacon wrote: > > 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. > > My apologies for delay in responding to this thread. > I have been digging and getting in touch with internal tech teams > to get more information on this. I will update as soon as I have enough > details. > Thanks. Hi Vivek. I want to revive this discussion. I believe that Andy has pulled in the base LLCC support so this the remaining dependency we need to implement the LLCC in the GPU driver. Thanks, Jordan -- The Qualcomm Innovation Center, Inc. is a member of Code Aurora Forum, a Linux Foundation Collaborative Project