Received: by 2002:a25:d7c1:0:0:0:0:0 with SMTP id o184csp3448029ybg; Mon, 28 Oct 2019 13:01:03 -0700 (PDT) X-Google-Smtp-Source: APXvYqzVIrlo8N9CsJ0h94T5DhC933KzH8aob0O4zuhP1xLq0Nfn7rl27HzuxdoZwxnZBltnGgkC X-Received: by 2002:a05:6402:6cc:: with SMTP id n12mr15347317edy.38.1572292863768; Mon, 28 Oct 2019 13:01:03 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1572292863; cv=none; d=google.com; s=arc-20160816; b=PPNAs1ZTnYlBfPUABUsb2k2RzcBwq3COTEU172+xtOGXqwQ1BjtinY+4I3cmUQTEMg LS82QZ2OnjUsyndLkl/QC5GXssKr/jECEfMUZla6uHUrKADVmABUkSIJS4Hz2zNx8LgH GCJzqqI/jvjOzwnYMA3s5V4SlS8pfI3vj5hXdJ2kzpk/tA1pY/xmdbQCWaFTaVZiA/ll Kwub/oGBP/eIjlbmWn4cNXpZGfYs3Ax9jyQiIelpb0bCvWQJ80aWoWgDr86zevTpJdRu D1x2h8pnklYhxj7z1cITIEVIpqt7T7f3DVB4H+SB+ypvcBcbZGiASwj3fK0OlzckS+ul zx1w== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:content-transfer-encoding :content-language:in-reply-to:mime-version:user-agent:date :message-id:from:references:cc:to:subject; bh=+EVj4YjKZFgBMy1FdbSm8qspL+Mz3/+0E3ABjc9CCz4=; b=kGk87O7JuK0gWP532mytJ2eCH4kgs4PhBoNEg0v+lzxYqkRBbiT1QEXzEY5TstPg8m 9pQco7cEaCJnJBPvNPw5QA9Mf5dYjeCcYcni0MALrCPHW6/zmaZF2SpcHosrgJO3jQfq 2ATwrsAkhbzQF0jW0SgSUUzTDa/sy3y6GeRiumrg/NXPFxcHjfLlETDNFI4afGp0U9JZ Z19rpDAPRwYTQ6XXfN3I4B4j2hJj7s/8DO6TBUPkNiOoPA/pYPK6QgjYOFWEzLYbxn3N lxZ2Kdw+yUVysYKe52Mfl3G40jYLs6XGLX9Eg/R6fHfohf97AejrD41tLGqBwEsPoUv8 oPmQ== 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 m33si2136492edc.126.2019.10.28.13.00.38; Mon, 28 Oct 2019 13:01:03 -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 S2388732AbfJ1L7L (ORCPT + 99 others); Mon, 28 Oct 2019 07:59:11 -0400 Received: from foss.arm.com ([217.140.110.172]:39164 "EHLO foss.arm.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1727479AbfJ1L7K (ORCPT ); Mon, 28 Oct 2019 07:59:10 -0400 Received: from usa-sjc-imap-foss1.foss.arm.com (unknown [10.121.207.14]) by usa-sjc-mx-foss1.foss.arm.com (Postfix) with ESMTP id D77B21F1; Mon, 28 Oct 2019 04:59:09 -0700 (PDT) Received: from [10.1.197.57] (e110467-lin.cambridge.arm.com [10.1.197.57]) by usa-sjc-imap-foss1.foss.arm.com (Postfix) with ESMTPSA id B53003F6C4; Mon, 28 Oct 2019 04:59:08 -0700 (PDT) Subject: Re: [PATCH] iommu/dma: Add support for DMA_ATTR_SYS_CACHE To: Will Deacon , Christoph Hellwig Cc: isaacm@codeaurora.org, iommu@lists.linux-foundation.org, linux-kernel@vger.kernel.org, joro@8bytes.org, m.szyprowski@samsung.com, pratikp@codeaurora.org, lmark@codeaurora.org References: <1572050616-6143-1-git-send-email-isaacm@codeaurora.org> <20191026053026.GA14545@lst.de> <20191028074156.GB20443@lst.de> <20191028112457.GB4122@willie-the-truck> From: Robin Murphy Message-ID: Date: Mon, 28 Oct 2019 11:59:04 +0000 User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:60.0) Gecko/20100101 Thunderbird/60.6.1 MIME-Version: 1.0 In-Reply-To: <20191028112457.GB4122@willie-the-truck> Content-Type: text/plain; charset=utf-8; format=flowed Content-Language: en-GB Content-Transfer-Encoding: 8bit Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On 28/10/2019 11:24, Will Deacon wrote: > Hi Christoph, > > On Mon, Oct 28, 2019 at 08:41:56AM +0100, Christoph Hellwig wrote: >> On Sat, Oct 26, 2019 at 03:12:57AM -0700, isaacm@codeaurora.org wrote: >>> On 2019-10-25 22:30, Christoph Hellwig wrote: >>>> The definition makes very little sense. >>> Can you please clarify what part doesn’t make sense, and why? >> >> It looks like complete garbage to me. That might just be because it >> uses tons of terms I've never heard of of and which aren't used anywhere >> in the DMA API. It also might be because it doesn't explain how the >> flag might actually be practically useful. > > Agreed. The way I /think/ it works is that on many SoCs there is a > system/last-level cache (LLC) which effectively sits in front of memory for > all masters. Even if a device isn't coherent with the CPU caches, we still > want to be able to allocate into the LLC. Why this doesn't happen > automatically is beyond me, but it appears that on these Qualcomm designs > you actually have to set the memory attributes up in the page-table to > ensure that the resulting memory transactions are non-cacheable for the CPU > but cacheable for the LLC. Without any changes, the transactions are > non-cacheable in both of them which assumedly has a performance cost. > > But you can see that I'm piecing things together myself here. Isaac? FWIW, that's pretty much how Pratik and Jordan explained it to me - the LLC sits directly in front of memory and is more or less transparent, although it might treat CPU and device accesses slightly differently (I don't remember exactly how the inner cacheablility attribute interacts). Certain devices don't get much benefit from the LLC, hence the desire for finer-grained control of their outer allocation policy to avoid more thrashing than necessary. Furthermore, for stuff in the video/GPU/display area certain jobs benefit more than others, hence the desire to go even finer-grained than a per-device control in order to maximise LLC effectiveness. Robin. >>> This is >>> really just an extension of this patch that got mainlined, so that clients >>> that use the DMA API can use IOMMU_QCOM_SYS_CACHE as well: >>> https://patchwork.kernel.org/patch/10946099/ >>>> Any without a user in the same series it is a complete no-go anyway. >>> IOMMU_QCOM_SYS_CACHE does not have any current users in the mainline, nor >>> did it have it in the patch series in which it got merged, yet it is still >>> present? Furthermore, there are plans to upstream support for one of our >>> SoCs that may benefit from this, as seen here: >>> https://www.spinics.net/lists/iommu/msg39608.html. >> >> Which means it should have never been merged. As a general policy we do >> not add code to the Linux kernel without actual users. > > Yes, in this case I was hoping a user would materialise via a different > tree, but it didn't happen, hence my post last week about removing this > altogether: > > https://lore.kernel.org/linux-iommu/20191024153832.GA7966@jcrouse1-lnx.qualcomm.com/T/#t > > which I suspect prompted this patch that unfortunately fails to solve the > problem. > > Will >