Received: by 2002:a05:6a10:f347:0:0:0:0 with SMTP id d7csp766139pxu; Wed, 6 Jan 2021 03:58:39 -0800 (PST) X-Google-Smtp-Source: ABdhPJwiALqiiLJtNccBLmxpKK1HxmfaILATqt2pXViFdfsLUrffrSdTE2cW+o1J9JTt2CymCnz8 X-Received: by 2002:a17:906:4d52:: with SMTP id b18mr2463264ejv.405.1609934319413; Wed, 06 Jan 2021 03:58:39 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1609934319; cv=none; d=google.com; s=arc-20160816; b=Wj1f0i9nNJvzQCua9uVI1zMr7QWU4mSwLXLdsyR/Ww7JEpJqPrxDXopKsIRVvTz+P8 T8GLFZJj7ZF17XSAaqdGIjyMkJVT1Pm5KUUiPUpaDZmWPeUSdF3oqChioYpI5MH1K3yc ohkcJkSjYTALPLi8vfYcn2WX1X+oFRiv8uwidCXoiXI0T9+ByUREd1Fr/G+xCKsEJxXu fS8LaJwX3UpHDEAuEJlGNMG8spQ+2zau0p0T/Jv9ry7Lz5pnjxpQgUzYCZYjxQXn1wvK em7oENQUg/y3+m+TQFdYoB2HtauoYoNlDAtQE/ATgs6auW9+ncrJG1R6CkbQ0MVra9zF ZRBA== 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=U5vkQWN48wW7IyYx4WRnL/Ky/aMYPeVgypf4gwLGbTw=; b=mBXS95+Ma3OCEV9hlgUhB2PSESQloRTLKht9HnxbiCZtU8rY1Y5IcM3ByKIVUdxVIs vNZULfmjj442baNSU/9Z66fIQ5yHpuwJjNZyHmXLoC3ZMC09nhU6xAwT/Ks4AlMIL5GI jeg17SpvsoYDe4DqZRi/VbRKoA51VdSK5mqn5oV9uAZP6XkFQmegU4DbEBzUWyEKiFU1 gtVIMj8li4SLuIOFSv95md35QapoAj1kMSSsJ40ow/YwzdueZWu+3k/E3vhSvtSwg7vA YsBsVM9DqACgjCGafcvOQzG04Qv4zKeExtbTh9jRUd+SVd313xxeUzSXMr6Ecjy8gUZc NJlQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@kernel.org header.s=k20201202 header.b=ZRA5wz6F; 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 e17si801938ejx.663.2021.01.06.03.58.15; Wed, 06 Jan 2021 03:58:39 -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=@kernel.org header.s=k20201202 header.b=ZRA5wz6F; 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 S1726143AbhAFL5F (ORCPT + 99 others); Wed, 6 Jan 2021 06:57:05 -0500 Received: from mail.kernel.org ([198.145.29.99]:55266 "EHLO mail.kernel.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1725788AbhAFL5F (ORCPT ); Wed, 6 Jan 2021 06:57:05 -0500 Received: by mail.kernel.org (Postfix) with ESMTPSA id E2EA323110; Wed, 6 Jan 2021 11:56:21 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1609934184; bh=HZYnJAIuD9MMbAMSmu3ejZVLAS6WiLfiiShHiiBv4YU=; h=Date:From:To:Cc:Subject:References:In-Reply-To:From; b=ZRA5wz6FMI5xfUbwYHZUwrrupsOg72i/wc8QiogubLx3JKzJGP+x4AsDTPYMRWZm9 woKVVXY4n/oWYpj8n7NKPHpTUxnlXvkLQLUuRoRi52QQ1FLkYRj3IoRieZqvEDtAGy OPYJeQIPGPrcb4y+QFkbiBkvBPr4xyckxiic5aBMz3Dd3f1Uv6JSRX2iMbVDS9KXS3 kqoWF/ZGIdVVu1X3nl+gk6qqKYSHvYcOYJixCW1leh3g4Sch3qFhbSuIgcQ7nKjd1r m48UxmDVDgIXhwMksWwKlLA+eudExTiJYZs7wTkcBUSfCE09RRZQ2g79ipJ1gGsLWi JdBBXRm8J1S4g== Date: Wed, 6 Jan 2021 11:56:16 +0000 From: Will Deacon To: Sai Prakash Ranjan Cc: Robin Murphy , Joerg Roedel , iommu@lists.linux-foundation.org, linux-arm-kernel@lists.infradead.org, linux-kernel@vger.kernel.org, linux-arm-msm@vger.kernel.org, Jordan Crouse , Rob Clark , Akhil P Oommen Subject: Re: [PATCH] iommu/io-pgtable-arm: Allow non-coherent masters to use system cache Message-ID: <20210106115615.GA1763@willie-the-truck> References: <20201224064007.2339-1-saiprakash.ranjan@codeaurora.org> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <20201224064007.2339-1-saiprakash.ranjan@codeaurora.org> User-Agent: Mutt/1.10.1 (2018-07-13) Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On Thu, Dec 24, 2020 at 12:10:07PM +0530, Sai Prakash Ranjan wrote: > commit ecd7274fb4cd ("iommu: Remove unused IOMMU_SYS_CACHE_ONLY flag") > removed unused IOMMU_SYS_CACHE_ONLY prot flag and along with it went > the memory type setting required for the non-coherent masters to use > system cache. Now that system cache support for GPU is added, we will > need to mark the memory as normal sys-cached for GPU to use system cache. > Without this, the system cache lines are not allocated for GPU. We use > the IO_PGTABLE_QUIRK_ARM_OUTER_WBWA quirk instead of a page protection > flag as the flag cannot be exposed via DMA api because of no in-tree > users. > > Signed-off-by: Sai Prakash Ranjan > --- > drivers/iommu/io-pgtable-arm.c | 3 +++ > 1 file changed, 3 insertions(+) > > diff --git a/drivers/iommu/io-pgtable-arm.c b/drivers/iommu/io-pgtable-arm.c > index 7c9ea9d7874a..3fb7de8304a2 100644 > --- a/drivers/iommu/io-pgtable-arm.c > +++ b/drivers/iommu/io-pgtable-arm.c > @@ -415,6 +415,9 @@ static arm_lpae_iopte arm_lpae_prot_to_pte(struct arm_lpae_io_pgtable *data, > else if (prot & IOMMU_CACHE) > pte |= (ARM_LPAE_MAIR_ATTR_IDX_CACHE > << ARM_LPAE_PTE_ATTRINDX_SHIFT); > + else if (data->iop.cfg.quirks & IO_PGTABLE_QUIRK_ARM_OUTER_WBWA) > + pte |= (ARM_LPAE_MAIR_ATTR_IDX_INC_OCACHE > + << ARM_LPAE_PTE_ATTRINDX_SHIFT); > } drivers/iommu/io-pgtable.c currently documents this quirk as applying only to the page-table walker. Given that we only have one user at the moment, I think it's ok to change that, but please update the comment. We also need to decide on whether we want to allow the quirk to be passed if the coherency of the page-table walker differs from the DMA device, since we have these combinations: Coherent walker? IOMMU_CACHE IO_PGTABLE_QUIRK_ARM_OUTER_WBWA 0: N 0 0 1: N 0 1 2: N 1 0 3: N 1 1 4: Y 0 0 5: Y 0 1 6: Y 1 0 7: Y 1 1 Some of them are obviously bogus, such as (7), but I don't know what to do about cases such as (3) and (5). Will