Received: by 2002:a05:6a10:8c0a:0:0:0:0 with SMTP id go10csp768327pxb; Wed, 3 Feb 2021 18:06:13 -0800 (PST) X-Google-Smtp-Source: ABdhPJztEtbNVdx94Kn+kgX/ZQS46XbeNO7KobkKLn7PZQ77lXyNy0vvQblm7gJ5Dh2DEnKzT2BZ X-Received: by 2002:a17:907:94d4:: with SMTP id dn20mr5896334ejc.397.1612404373319; Wed, 03 Feb 2021 18:06:13 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1612404373; cv=none; d=google.com; s=arc-20160816; b=VTqCMveJzLL7mqU8qh79e2LQu/t7m0tlDfNTtmzkZzJGQ8+CiHI4nfDSjnrwVmf6qU ZscQ/XJQBPFMAwSKrZ38yEEyr+MmUXHE1SCXbtNDKPCut0GsGYYxvJPzKBAPH8+yyLrG u7y3kqW5i3+OzdjayRcU1Zb0OpEhkDJkJXARegKGBVukDAHWR7QhzxKKzqjxwIH64WsL rcFf79jR4nrzF8TGN7eRz9+x2RVaeH0SdtFV9wNDNpn+QgR/enEBwpboNZMtpVKKNl8K 8zBMLqGDpDSYOsIQwjgBXSDy31DVAt2G6/sW2o7g+0TAEEeX3eWPlz8buGZ5qkyE7VoP /vvw== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:cc:to:subject:message-id:date:from:in-reply-to :references:mime-version:dkim-signature; bh=DGHGJpRMiCcjJwzqK5MM6WMiK3EoPUFXs3r66DkReec=; b=cd5flKhhEH/29JxZQczLR76/YB8/n2IdSmfFvpUIVNr3SKP5ey0fpNe5XmyClb1cqJ zjc2gF9L1nDKOlewjP8NSF6gLST19Jc2HtduUanoJMV66T7K5IMeqQ8wTDTfD72E9Xvy 1sNC2bOuv76Z0vmMzy67zsTOpDfHdAqyzHZYJOGDdib/bPQG9NlFMvuvcBURaGMoa4hQ RphzpyEVkD1GT2EvI9kzo5uaAtngLsDOVO2Wd4/5pEAoabALSXrlB6xfgYIrEXaHV2eI G2pG6Ox7o8jwQZcuhObG9WP3OiQaabz2IfkK55Ryi5aTZQQvmC7E4+yV7+IWezGWoYv4 Wq7w== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@gmail.com header.s=20161025 header.b=S3MB8seu; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=QUARANTINE dis=NONE) header.from=gmail.com Return-Path: Received: from vger.kernel.org (vger.kernel.org. [23.128.96.18]) by mx.google.com with ESMTP id r25si2941856edc.257.2021.02.03.18.05.49; Wed, 03 Feb 2021 18:06:13 -0800 (PST) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) client-ip=23.128.96.18; Authentication-Results: mx.google.com; dkim=pass header.i=@gmail.com header.s=20161025 header.b=S3MB8seu; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=QUARANTINE dis=NONE) header.from=gmail.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S233035AbhBCWMl (ORCPT + 99 others); Wed, 3 Feb 2021 17:12:41 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:42342 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S229897AbhBCWMa (ORCPT ); Wed, 3 Feb 2021 17:12:30 -0500 Received: from mail-wr1-x436.google.com (mail-wr1-x436.google.com [IPv6:2a00:1450:4864:20::436]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id ADF3AC061573; Wed, 3 Feb 2021 14:11:49 -0800 (PST) Received: by mail-wr1-x436.google.com with SMTP id a1so1092144wrq.6; Wed, 03 Feb 2021 14:11:49 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=mime-version:references:in-reply-to:from:date:message-id:subject:to :cc; bh=DGHGJpRMiCcjJwzqK5MM6WMiK3EoPUFXs3r66DkReec=; b=S3MB8seuCtDvh24s/3erzEhs7gRNbrofohoVTt8xqTqq2yk5aD7eO5BlMRIGi0y4TG Ibrp3gdxwIu+yD/9g7ANHGFfPJYvXG0G6nVM3eygUBaxY+rDmjuWMeiJxN7ZworTUb6c GboKqbA4u0KibkkxLrDRr1tlPgKxxqgtR3EloTsUtqBWNVG+Q8i3yoLaESwf59DphnSw hKj2OflM1Vyf+VcSg5ZX1Q7HFsb5dMf17SJB+WUZpg1gXfAgf8fPU7g1RcVSbg8lEi7H Cnoe3fsqi0LKGjH5e58RhRvFMHVFkYow1Chm6tRBqehXGbYKcDyfXIXz/PTb67hI4Vfk bLCg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:mime-version:references:in-reply-to:from:date :message-id:subject:to:cc; bh=DGHGJpRMiCcjJwzqK5MM6WMiK3EoPUFXs3r66DkReec=; b=DQEtVa/NaNMuXx7YzA0XLsAefW8/0clJmYTC8NE8oFS/6uLjgUKi7iazubCaU/YWKt pQtzPDrflQCeKJsdDdcGVOBNJRVgTx+AZ32FCg8WoWijYK+zTc0gJHg14oIoiJMSs+tf TrwpJewkMEEa5uyjWCxHCRQXYGJwklorYZ0ZKJIT0YcRJ/LIYH90ybS15GHMs5IkaeEV 281RjR293YYzYjDapBz+aTeWpXfyRSyGYKvmA1HXqTyEnEGhRNIHoEGpWhQYwuq+yIjh CWbnprjxmwdIMIEoUmrRJVMybyTwg9n1SWqOCCzWnF2fKT7flKeoNYAz9WKLdJT8M/sX JV6Q== X-Gm-Message-State: AOAM5319BYzQyfuhtjpFDWwWEUeNfO5O5a5ajhZw8QHtiVRjTKXcSnbs 3rHGa1jWaAVIZsr8DnEe61JXFCLv8ZCqCwzoqZ0K4DQt64S9cQ== X-Received: by 2002:adf:f8c8:: with SMTP id f8mr5894743wrq.132.1612390308448; Wed, 03 Feb 2021 14:11:48 -0800 (PST) MIME-Version: 1.0 References: <3f589e7de3f9fa93e84c83420c5270c546a0c368.1610372717.git.saiprakash.ranjan@codeaurora.org> <20210129090516.GB3998@willie-the-truck> <5d23fce629323bcda71594010824aad0@codeaurora.org> <20210201111556.GA7172@willie-the-truck> <20210201182016.GA21629@jcrouse1-lnx.qualcomm.com> <7e9aade14d0b7f69285852ade4a5a9f4@codeaurora.org> <20210203214612.GB19847@willie-the-truck> In-Reply-To: <20210203214612.GB19847@willie-the-truck> From: Rob Clark Date: Wed, 3 Feb 2021 14:14:22 -0800 Message-ID: Subject: Re: [PATCH 2/3] iommu/io-pgtable-arm: Add IOMMU_LLC page protection flag To: Will Deacon Cc: Sai Prakash Ranjan , Robin Murphy , Joerg Roedel , Akhil P Oommen , "Isaac J. Manjarres" , "list@263.net:IOMMU DRIVERS , Joerg Roedel ," , "moderated list:ARM/FREESCALE IMX / MXC ARM ARCHITECTURE" , Linux Kernel Mailing List , linux-arm-msm , freedreno , Kristian H Kristensen , Sean Paul , David Airlie , Daniel Vetter , dri-devel Content-Type: text/plain; charset="UTF-8" Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On Wed, Feb 3, 2021 at 1:46 PM Will Deacon wrote: > > On Tue, Feb 02, 2021 at 11:56:27AM +0530, Sai Prakash Ranjan wrote: > > On 2021-02-01 23:50, Jordan Crouse wrote: > > > On Mon, Feb 01, 2021 at 08:20:44AM -0800, Rob Clark wrote: > > > > On Mon, Feb 1, 2021 at 3:16 AM Will Deacon wrote: > > > > > On Fri, Jan 29, 2021 at 03:12:59PM +0530, Sai Prakash Ranjan wrote: > > > > > > On 2021-01-29 14:35, Will Deacon wrote: > > > > > > > On Mon, Jan 11, 2021 at 07:45:04PM +0530, Sai Prakash Ranjan wrote: > > > > > > > > +#define IOMMU_LLC (1 << 6) > > > > > > > > > > > > > > On reflection, I'm a bit worried about exposing this because I think it > > > > > > > will > > > > > > > introduce a mismatched virtual alias with the CPU (we don't even have a > > > > > > > MAIR > > > > > > > set up for this memory type). Now, we also have that issue for the PTW, > > > > > > > but > > > > > > > since we always use cache maintenance (i.e. the streaming API) for > > > > > > > publishing the page-tables to a non-coheren walker, it works out. > > > > > > > However, > > > > > > > if somebody expects IOMMU_LLC to be coherent with a DMA API coherent > > > > > > > allocation, then they're potentially in for a nasty surprise due to the > > > > > > > mismatched outer-cacheability attributes. > > > > > > > > > > > > > > > > > > > Can't we add the syscached memory type similar to what is done on android? > > > > > > > > > > Maybe. How does the GPU driver map these things on the CPU side? > > > > > > > > Currently we use writecombine mappings for everything, although there > > > > are some cases that we'd like to use cached (but have not merged > > > > patches that would give userspace a way to flush/invalidate) > > > > > > > > > > LLC/system cache doesn't have a relationship with the CPU cache. Its > > > just a > > > little accelerator that sits on the connection from the GPU to DDR and > > > caches > > > accesses. The hint that Sai is suggesting is used to mark the buffers as > > > 'no-write-allocate' to prevent GPU write operations from being cached in > > > the LLC > > > which a) isn't interesting and b) takes up cache space for read > > > operations. > > > > > > Its easiest to think of the LLC as a bonus accelerator that has no cost > > > for > > > us to use outside of the unfortunate per buffer hint. > > > > > > We do have to worry about the CPU cache w.r.t I/O coherency (which is a > > > different hint) and in that case we have all of concerns that Will > > > identified. > > > > > > > For mismatched outer cacheability attributes which Will mentioned, I was > > referring to [1] in android kernel. > > I've lost track of the conversation here :/ > > When the GPU has a buffer mapped with IOMMU_LLC, is the buffer also mapped > into the CPU and with what attributes? Rob said "writecombine for > everything" -- does that mean ioremap_wc() / MEMREMAP_WC? Currently userspace asks for everything WC, so pgprot_writecombine() The kernel doesn't enforce this, but so far provides no UAPI to do anything useful with non-coherent cached mappings (although there is interest to support this) BR, -R > Finally, we need to be careful when we use the word "hint" as "allocation > hint" has a specific meaning in the architecture, and if we only mismatch on > those then we're actually ok. But I think IOMMU_LLC is more than just a > hint, since it actually drives eviction policy (i.e. it enables writeback). > > Sorry for the pedantry, but I just want to make sure we're all talking > about the same things! > > Cheers, > > Will