From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-11.5 required=3.0 tests=BAYES_00,DKIMWL_WL_HIGH, DKIM_SIGNED,DKIM_VALID,INCLUDES_PATCH,MAILING_LIST_MULTI,SIGNED_OFF_BY, SPF_HELO_NONE,SPF_PASS,URIBL_BLOCKED,USER_AGENT_SANE_1 autolearn=unavailable autolearn_force=no version=3.4.0 Received: from mail.kernel.org (mail.kernel.org [198.145.29.99]) by smtp.lore.kernel.org (Postfix) with ESMTP id 0D300C388F7 for ; Tue, 10 Nov 2020 12:19:26 +0000 (UTC) Received: from merlin.infradead.org (merlin.infradead.org [205.233.59.134]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mail.kernel.org (Postfix) with ESMTPS id 89FFE206B2 for ; Tue, 10 Nov 2020 12:19:25 +0000 (UTC) Authentication-Results: mail.kernel.org; dkim=pass (2048-bit key) header.d=lists.infradead.org header.i=@lists.infradead.org header.b="jMaoopNj"; dkim=fail reason="signature verification failed" (1024-bit key) header.d=kernel.org header.i=@kernel.org header.b="e7W7PrBt" DMARC-Filter: OpenDMARC Filter v1.3.2 mail.kernel.org 89FFE206B2 Authentication-Results: mail.kernel.org; dmarc=fail (p=none dis=none) header.from=kernel.org Authentication-Results: mail.kernel.org; spf=none smtp.mailfrom=linux-arm-kernel-bounces+linux-arm-kernel=archiver.kernel.org@lists.infradead.org DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=lists.infradead.org; s=merlin.20170209; h=Sender:Content-Transfer-Encoding: Content-Type:Cc:List-Subscribe:List-Help:List-Post:List-Archive: List-Unsubscribe:List-Id:In-Reply-To:MIME-Version:References:Message-ID: Subject:To:From:Date:Reply-To:Content-ID:Content-Description:Resent-Date: Resent-From:Resent-Sender:Resent-To:Resent-Cc:Resent-Message-ID:List-Owner; bh=EK1QJddqG+novYgSo9zf1k2BtstEjzxBjoRGoEQ0ge0=; b=jMaoopNjLXEd195EIjjTprcPg 1/n5GJK7cl82/Db2ejRrayRbHB1wQsqYleGUpQIa3XOmf10DgmPB9FbPYQ4fIqG2uVwY3dkMt7UkW HE2GA2f86mMUahrbsXZJUGP+P/rsS4P6k0ULUOJm8Vd+EamVV6Avc6rhD/cE4aaKJl245XPKywJp9 bh4POhvQvAmr9/36KEfwoALe0m7EY6OoD8G+k/scrFf1L41xXeaen5xEzftx5RxXQajFqlCPx3HCD IA+43o6+AIVTpBSed7ERTQpKgUQx/stsnEfTpxflhLOwpLn4BuMqkyqvEpjIZ7+fH0v0BCDsJ56/C P+nxMv32Q==; Received: from localhost ([::1] helo=merlin.infradead.org) by merlin.infradead.org with esmtp (Exim 4.92.3 #3 (Red Hat Linux)) id 1kcSbx-0003Yc-7d; Tue, 10 Nov 2020 12:18:57 +0000 Received: from mail.kernel.org ([198.145.29.99]) by merlin.infradead.org with esmtps (Exim 4.92.3 #3 (Red Hat Linux)) id 1kcSbr-0003Ub-4T for linux-arm-kernel@lists.infradead.org; Tue, 10 Nov 2020 12:18:54 +0000 Received: from willie-the-truck (236.31.169.217.in-addr.arpa [217.169.31.236]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mail.kernel.org (Postfix) with ESMTPSA id ADC6A20665; Tue, 10 Nov 2020 12:18:39 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=default; t=1605010722; bh=9u/fuCTy3omMqwpCGYscej7XEaEZDpXNc0ihGC6cIHA=; h=Date:From:To:Cc:Subject:References:In-Reply-To:From; b=e7W7PrBt90zkfA7At1XrIMxAWzSDOcbSD67WT+a449KuPegLykT3UGrstjziGhED1 fyNkVeEIuk/3wHQMrLMMQI0bvpw0QImz2CGeGD3RedqcQ2m6ut44gahWa5HDcg2Ivj FHvuS/+DzUZStPSglWsflGSxRbFzw0Be9qJhZsoA= Date: Tue, 10 Nov 2020 12:18:35 +0000 From: Will Deacon To: Sai Prakash Ranjan Subject: Re: [PATCHv7 2/7] iommu/arm-smmu: Add domain attribute for system cache Message-ID: <20201110121835.GC16239@willie-the-truck> References: MIME-Version: 1.0 Content-Disposition: inline In-Reply-To: User-Agent: Mutt/1.10.1 (2018-07-13) X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20201110_071851_420267_6B67A4B9 X-CRM114-Status: GOOD ( 23.33 ) X-BeenThere: linux-arm-kernel@lists.infradead.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: freedreno@lists.freedesktop.org, linux-arm-msm@vger.kernel.org, Joerg Roedel , Jordan Crouse , iommu@lists.linux-foundation.org, linux-kernel@vger.kernel.org, Rob Clark , Akhil P Oommen , dri-devel@lists.freedesktop.org, "Kristian H . Kristensen" , Robin Murphy , linux-arm-kernel@lists.infradead.org Content-Type: text/plain; charset="us-ascii" Content-Transfer-Encoding: 7bit Sender: "linux-arm-kernel" Errors-To: linux-arm-kernel-bounces+linux-arm-kernel=archiver.kernel.org@lists.infradead.org On Fri, Oct 30, 2020 at 02:53:09PM +0530, Sai Prakash Ranjan wrote: > Add iommu domain attribute for using system cache aka last level > cache by client drivers like GPU to set right attributes for caching > the hardware pagetables into the system cache. > > Signed-off-by: Sai Prakash Ranjan > --- > drivers/iommu/arm/arm-smmu/arm-smmu.c | 17 +++++++++++++++++ > drivers/iommu/arm/arm-smmu/arm-smmu.h | 1 + > include/linux/iommu.h | 1 + > 3 files changed, 19 insertions(+) > > diff --git a/drivers/iommu/arm/arm-smmu/arm-smmu.c b/drivers/iommu/arm/arm-smmu/arm-smmu.c > index b1cf8f0abc29..070d13f80c7e 100644 > --- a/drivers/iommu/arm/arm-smmu/arm-smmu.c > +++ b/drivers/iommu/arm/arm-smmu/arm-smmu.c > @@ -789,6 +789,9 @@ static int arm_smmu_init_domain_context(struct iommu_domain *domain, > if (smmu_domain->non_strict) > pgtbl_cfg.quirks |= IO_PGTABLE_QUIRK_NON_STRICT; > > + if (smmu_domain->sys_cache) > + pgtbl_cfg.quirks |= IO_PGTABLE_QUIRK_SYS_CACHE; > + > pgtbl_ops = alloc_io_pgtable_ops(fmt, &pgtbl_cfg, smmu_domain); > if (!pgtbl_ops) { > ret = -ENOMEM; > @@ -1520,6 +1523,9 @@ static int arm_smmu_domain_get_attr(struct iommu_domain *domain, > case DOMAIN_ATTR_DMA_USE_FLUSH_QUEUE: > *(int *)data = smmu_domain->non_strict; > return 0; > + case DOMAIN_ATTR_SYS_CACHE: > + *((int *)data) = smmu_domain->sys_cache; > + return 0; > default: > return -ENODEV; > } > @@ -1551,6 +1557,17 @@ static int arm_smmu_domain_set_attr(struct iommu_domain *domain, > else > smmu_domain->stage = ARM_SMMU_DOMAIN_S1; > break; > + case DOMAIN_ATTR_SYS_CACHE: > + if (smmu_domain->smmu) { > + ret = -EPERM; > + goto out_unlock; > + } > + > + if (*((int *)data)) > + smmu_domain->sys_cache = true; > + else > + smmu_domain->sys_cache = false; > + break; > default: > ret = -ENODEV; > } > diff --git a/drivers/iommu/arm/arm-smmu/arm-smmu.h b/drivers/iommu/arm/arm-smmu/arm-smmu.h > index 885840f3bec8..dfc44d806671 100644 > --- a/drivers/iommu/arm/arm-smmu/arm-smmu.h > +++ b/drivers/iommu/arm/arm-smmu/arm-smmu.h > @@ -373,6 +373,7 @@ struct arm_smmu_domain { > struct mutex init_mutex; /* Protects smmu pointer */ > spinlock_t cb_lock; /* Serialises ATS1* ops and TLB syncs */ > struct iommu_domain domain; > + bool sys_cache; > }; > > struct arm_smmu_master_cfg { > diff --git a/include/linux/iommu.h b/include/linux/iommu.h > index b95a6f8db6ff..4f4bb9c6f8f6 100644 > --- a/include/linux/iommu.h > +++ b/include/linux/iommu.h > @@ -118,6 +118,7 @@ enum iommu_attr { > DOMAIN_ATTR_FSL_PAMUV1, > DOMAIN_ATTR_NESTING, /* two stages of translation */ > DOMAIN_ATTR_DMA_USE_FLUSH_QUEUE, > + DOMAIN_ATTR_SYS_CACHE, I think you're trying to make this look generic, but it's really not. If we need to funnel io-pgtable quirks through domain attributes, then I think we should be open about that and add something like DOMAIN_ATTR_IO_PGTABLE_CFG which could take a struct of page-table configuration data for the domain (this could just be quirks initially, but maybe it's worth extending to take ias, oas and page size) Will _______________________________________________ linux-arm-kernel mailing list linux-arm-kernel@lists.infradead.org http://lists.infradead.org/mailman/listinfo/linux-arm-kernel