Received: by 2002:a05:6a10:9848:0:0:0:0 with SMTP id x8csp640518pxf; Thu, 25 Mar 2021 10:35:13 -0700 (PDT) X-Google-Smtp-Source: ABdhPJwSJi2Cz0X9ag4RmdfkcZCApgxvj0RF5ihBqywk2ci4e6qklOX4fVn8yltwCBWzolZphy5/ X-Received: by 2002:aa7:d3ca:: with SMTP id o10mr10450772edr.374.1616693713661; Thu, 25 Mar 2021 10:35:13 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1616693713; cv=none; d=google.com; s=arc-20160816; b=drjj3bRgTESn/oVVeaJZpsPFbnTD5XQhZWwVAPxiT6P7C9PCGKraWG1jcz+aR4XMbt ZGiEk+5YlWbIngqaZ700mRd0it7iMsqj2A+X4UesW8uywWkxSlg0FKjDzp6RipTWdajD irzkxqhz+J36z9j8UVvPhQIrGY5WwGQlx4fVMgEU2nXWfAKD64GGJEiTDP3nqqPWrkhW 7gT9mdnvM9FYr/W1lcODSoGiWy/MC8Ax/qOHOS6V8puF5+mPlCoFXBUFVztxzNKl4v1j 7SXqQeGbvW1nvLOfKqnhoOw4gswF1519TFTsry2aihojbJhWB3JJ+Y0o7P1hogSNMxL4 LQxg== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:user-agent:in-reply-to:content-disposition :mime-version:references:message-id:subject:cc:to:from:date :dkim-signature; bh=MhV4Y5Wo5p3ir8NDAMUIz/5lvmlc64xFIJxW8S7KZ4M=; b=vYvuYP9qY+W0DFIlMPpdZwA/hU4tKw4cKH/0NPCAzxfl9tRL7oQuGBHQAofB65n72M Mv2BAUzRSd+iJp0JeHAwnJIuIlQzEns78CZnUSm2pCL2hYt3jUoMqSxLZf15S/+ZS1qB 7+u1DiGSOVHoKPHV6vmqY6f4K3gwBRigOckTd6jHzYlWomt5YaMP75D5oijgLd+Gdxgd 8w0mn12dblZ4/DwsGQ7jzQhTRsscU1LriNn37EmbgURyTjIscbShmtaxajUSArPdigX2 NsHzQg4T1VXU35Ilm3qqtJ9fwuKkbHZ7K675QDK3YZy/pJjP6oUOzZjYk3GWCRdor68c FYdQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@kernel.org header.s=k20201202 header.b=OpgdYXmT; 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=NONE dis=NONE) header.from=kernel.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [23.128.96.18]) by mx.google.com with ESMTP id co21si4714202edb.513.2021.03.25.10.34.50; Thu, 25 Mar 2021 10:35:13 -0700 (PDT) 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=@kernel.org header.s=k20201202 header.b=OpgdYXmT; 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=NONE dis=NONE) header.from=kernel.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S229669AbhCYRdu (ORCPT + 99 others); Thu, 25 Mar 2021 13:33:50 -0400 Received: from mail.kernel.org ([198.145.29.99]:44098 "EHLO mail.kernel.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S229581AbhCYRdR (ORCPT ); Thu, 25 Mar 2021 13:33:17 -0400 Received: by mail.kernel.org (Postfix) with ESMTPSA id 0A18261A28; Thu, 25 Mar 2021 17:33:14 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1616693597; bh=qGpX3MaAi6iipXhij0xGuclaojia9d6LXGpZk4lS3FA=; h=Date:From:To:Cc:Subject:References:In-Reply-To:From; b=OpgdYXmTWs8MRabNzxRiFlKzCDpQS5h96vnrJxN9G4TZvg0WRGitBgXLTk+GnnXil f8b5nAYnfp30PmCcOMovoLPgDhNtradrGc8Y6FhFhQ36jubqzqqO6zBwewg68FYuJf Jv7k7kjnmjdLlFV3ePCk4UFG8Vd9Clf1rwUIugVfKpJsBtO7/w+BaxYqHIGJ7eDHwI mCIthIJWR0FmNz1DYmj+Kqua1EmULEJwj1xk8HRopvlZ1bKjcDSPYNKMZbYPYp8xr5 TB9H5N62ZZMc3cBLXsUHr1mLRfZ6+pM2RtMNb99RhaB1IXnJpl6MiGYMIdbKb9KY+r w0OsMID+O3r1w== Date: Thu, 25 Mar 2021 17:33:11 +0000 From: Will Deacon To: Sai Prakash Ranjan Cc: "Isaac J. Manjarres" , freedreno , David Airlie , Linux Kernel Mailing List , "list@263.net:IOMMU DRIVERS , Joerg Roedel , " , dri-devel , Akhil P Oommen , Sean Paul , Kristian H Kristensen , Daniel Vetter , linux-arm-msm , Robin Murphy , linux-arm-kernel@lists.infradead.org Subject: Re: [PATCH 2/3] iommu/io-pgtable-arm: Add IOMMU_LLC page protection flag Message-ID: <20210325173311.GA15504@willie-the-truck> 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> <4988e2ef35f76a0c2f1fe3f66f023a3b@codeaurora.org> <9362873a3bcf37cdd073a6128f29c683@codeaurora.org> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <9362873a3bcf37cdd073a6128f29c683@codeaurora.org> User-Agent: Mutt/1.10.1 (2018-07-13) Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On Tue, Mar 09, 2021 at 12:10:44PM +0530, Sai Prakash Ranjan wrote: > On 2021-02-05 17:38, Sai Prakash Ranjan wrote: > > On 2021-02-04 03:16, 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? > > > > > > > Rob answered this. > > > > > 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! > > > > > > > Sorry for the confusion which probably was caused by my mentioning of > > android, NWA(no write allocate) is an allocation hint which we can > > ignore > > for now as it is not introduced yet in upstream. > > > > Any chance of taking this forward? We do not want to miss out on small fps > gain when the product gets released. Do we have a solution to the mismatched virtual alias? Will