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 Received: from bombadil.infradead.org (bombadil.infradead.org [198.137.202.133]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.lore.kernel.org (Postfix) with ESMTPS id 3C984E7E65A for ; Tue, 26 Sep 2023 18:50:24 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=lists.infradead.org; s=bombadil.20210309; h=Sender: Content-Transfer-Encoding:Content-Type:List-Subscribe:List-Help:List-Post: List-Archive:List-Unsubscribe:List-Id:In-Reply-To:MIME-Version:References: Message-ID:Subject:Cc: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=uUA7PtmgD7AfGkPS+2xB+JGF40MXQTkXiFKP6xKiZ7A=; b=1AN+NpcHl4h2yG jz9RW6oVvsmlTgRhJlil9LvbfhuUXM7zt1QZevn6Ms2gTKdaoOlm3dmEsXko7b95EKCla9rdmv8oD HWL6iZrvAw3+vFo21neAhTPM2g7m9k6eBYNjAFhBGQMq3LePKy4/ciyy+F9uSGpHZuwLRipuVdDqy jE/+1Bg2K2vzEM7XP6p/uIlhyDA7Xt31p2M91GI0tmIpEdyFtpMGyrbHMyhx9vGdRERCYwfh977Yv /H1NE/QsnuV/wF0eRsJXz+Uq6foDcbADstc7I6SZLOE0UR+CgS62Sr+c1XhqPqWBnjuTEwXFI+ykf gYGAUiSlwWeGoaPWdW+g==; Received: from localhost ([::1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.96 #2 (Red Hat Linux)) id 1qlD87-00GsTx-0q; Tue, 26 Sep 2023 18:49:55 +0000 Received: from wnew4-smtp.messagingengine.com ([64.147.123.18]) by bombadil.infradead.org with esmtps (Exim 4.96 #2 (Red Hat Linux)) id 1qlD84-00GsSs-1M for linux-arm-kernel@lists.infradead.org; Tue, 26 Sep 2023 18:49:54 +0000 Received: from compute1.internal (compute1.nyi.internal [10.202.2.41]) by mailnew.west.internal (Postfix) with ESMTP id CC8572B001CA; Tue, 26 Sep 2023 14:49:46 -0400 (EDT) Received: from mailfrontend1 ([10.202.2.162]) by compute1.internal (MEProxy); Tue, 26 Sep 2023 14:49:48 -0400 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=jannau.net; h=cc :cc:content-type:content-type:date:date:from:from:in-reply-to :in-reply-to:message-id:mime-version:references:reply-to:sender :subject:subject:to:to; s=fm1; t=1695754186; x=1695757786; bh=0L 1PD+J2hFF8IKoDu/MxIMXd7klBa9ifKTbkZPpjaR0=; b=uKO9ejLNJ7Zmi8z7Dg SOqdFdZRPTeaskHX/lo6oOGnDLyHKoDR5D+BQ1F1diF74CmSwwLI1OIyII36Ar37 ZbbJ+DR+0UBN3u8cJpDq1zpSt7FeYDg6Gq8Y3Epz1Xj1wga+hwx6aP0n7TrPQpdm YYvSvjr62MqVtocgvhLNcuOimmgwhwQkFEjbvo5BSkzcbDc4JF0UkCuTFUNfChda 6/vcAREJ/ju+OQyiZ+U6fSz7DtEq0aASSO8gTJNaWN7Bw25a/iAkSodqHF1kt+0t y7aAhLMKgkaotrw/5YBhB34K0NUcLcZbnuwyknXoE8DoNQGa0A4sD/r2gvAwOf3y c+0Q== DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d= messagingengine.com; h=cc:cc:content-type:content-type:date:date :feedback-id:feedback-id:from:from:in-reply-to:in-reply-to :message-id:mime-version:references:reply-to:sender:subject :subject:to:to:x-me-proxy:x-me-proxy:x-me-sender:x-me-sender :x-sasl-enc; s=i449149f6.fm2; t=1695754186; x=1695757786; bh=0L1 PD+J2hFF8IKoDu/MxIMXd7klBa9ifKTbkZPpjaR0=; b=C7gC5alTUJ0K6c73X+E 96mUJAjtwBzBQMMjA0NUEEk4TGRQujJmO8SId3+VLUxTuoXzSlVsl9+A5zzcD7FF ws2CMwJns2nrL0s4hvE95tCVw9YgaWg/QNFPLDwhRodQiGl0II8woXPsCLJILThJ AlX1Dzdq47CQa8nlXsSHdB68f/rE0yuQDJHRW1HPHS7yRYi/WcI2VKBCkq/Jh69E t+DA27tDqb+q3EybpyWc4rbpu5+AuukB3OVknAopMbDuK3f2I8heXk7nASPKLhIa 7H3GOs8ZG/vZeGI+JBDj2tioh07lvTRAjQMkgc5377KjLKNfBHF8dy6SUsa7dl8x 2OQ== X-ME-Sender: X-ME-Received: X-ME-Proxy-Cause: gggruggvucftvghtrhhoucdtuddrgedvjedrtddtgddutdduucetufdoteggodetrfdotf fvucfrrhhofhhilhgvmecuhfgrshhtofgrihhlpdfqfgfvpdfurfetoffkrfgpnffqhgen uceurghilhhouhhtmecufedttdenucesvcftvggtihhpihgvnhhtshculddquddttddmne cujfgurhepfffhvfevuffkfhggtggujgesthdtredttddtjeenucfhrhhomheplfgrnhhn vgcuifhruhhnrghuuceojhgrnhhnvgesjhgrnhhnrghurdhnvghtqeenucggtffrrghtth gvrhhnpeegueegvddtgfehuedutdevieehgeefteejteetvdegueelhfdtieeujeeugeeh udenucevlhhushhtvghrufhiiigvpedtnecurfgrrhgrmhepmhgrihhlfhhrohhmpehjrg hnnhgvsehjrghnnhgruhdrnhgvth X-ME-Proxy: Feedback-ID: i449149f6:Fastmail Received: by mail.messagingengine.com (Postfix) with ESMTPA; Tue, 26 Sep 2023 14:49:43 -0400 (EDT) Date: Tue, 26 Sep 2023 20:49:41 +0200 From: Janne Grunau To: Jason Gunthorpe Cc: Alyssa Rosenzweig , asahi@lists.linux.dev, Lu Baolu , Christophe Leroy , David Woodhouse , iommu@lists.linux.dev, Joerg Roedel , Kevin Tian , linux-arm-kernel@lists.infradead.org, linuxppc-dev@lists.ozlabs.org, Hector Martin , Michael Ellerman , Nicholas Piggin , Robin Murphy , Sven Peter , Will Deacon Subject: Re: [PATCH 5/8] iommu/dart: Use static global identity domains Message-ID: References: <0-v1-8060f06462cc+c0a39-dart_paging_jgg@nvidia.com> <5-v1-8060f06462cc+c0a39-dart_paging_jgg@nvidia.com> MIME-Version: 1.0 Content-Disposition: inline In-Reply-To: <5-v1-8060f06462cc+c0a39-dart_paging_jgg@nvidia.com> X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20230926_114952_812194_823F1460 X-CRM114-Status: GOOD ( 20.58 ) X-BeenThere: linux-arm-kernel@lists.infradead.org X-Mailman-Version: 2.1.34 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , 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 Hej, On Fri, Sep 22, 2023 at 02:07:56PM -0300, Jason Gunthorpe wrote: > Move to the new static global for identity domains. Move the identity > specific code to apple_dart_attach_dev_identity(). > > Signed-off-by: Jason Gunthorpe > --- > drivers/iommu/apple-dart.c | 41 ++++++++++++++++++++++++++++---------- > 1 file changed, 30 insertions(+), 11 deletions(-) > > diff --git a/drivers/iommu/apple-dart.c b/drivers/iommu/apple-dart.c > index 6bc2ad2207c3da..424f779ccc34df 100644 > --- a/drivers/iommu/apple-dart.c > +++ b/drivers/iommu/apple-dart.c > @@ -658,11 +658,7 @@ static int apple_dart_attach_dev(struct iommu_domain *domain, > struct apple_dart_master_cfg *cfg = dev_iommu_priv_get(dev); > struct apple_dart_domain *dart_domain = to_dart_domain(domain); > > - if (cfg->stream_maps[0].dart->force_bypass && > - domain->type != IOMMU_DOMAIN_IDENTITY) > - return -EINVAL; > - if (!cfg->stream_maps[0].dart->supports_bypass && > - domain->type == IOMMU_DOMAIN_IDENTITY) > + if (cfg->stream_maps[0].dart->force_bypass) > return -EINVAL; > > ret = apple_dart_finalize_domain(domain, cfg); > @@ -683,15 +679,37 @@ static int apple_dart_attach_dev(struct iommu_domain *domain, > for_each_stream_map(i, cfg, stream_map) > apple_dart_hw_disable_dma(stream_map); > break; > - case IOMMU_DOMAIN_IDENTITY: > - for_each_stream_map(i, cfg, stream_map) > - apple_dart_hw_enable_bypass(stream_map); > - break; > + default: > + return -EINVAL; > } > > return ret; > } > > +static int apple_dart_attach_dev_identity(struct iommu_domain *domain, > + struct device *dev) > +{ > + struct apple_dart_master_cfg *cfg = dev_iommu_priv_get(dev); > + struct apple_dart_stream_map *stream_map; > + int i; > + > + if (!cfg->stream_maps[0].dart->supports_bypass) > + return -EINVAL; > + > + for_each_stream_map(i, cfg, stream_map) > + apple_dart_hw_enable_bypass(stream_map); > + return 0; > +} > + > +static const struct iommu_domain_ops apple_dart_identity_ops = { > + .attach_dev = apple_dart_attach_dev_identity, > +}; > + > +static struct iommu_domain apple_dart_identity_domain = { > + .type = IOMMU_DOMAIN_IDENTITY, > + .ops = &apple_dart_identity_ops, > +}; > + > static struct iommu_device *apple_dart_probe_device(struct device *dev) > { > struct apple_dart_master_cfg *cfg = dev_iommu_priv_get(dev); > @@ -722,7 +740,7 @@ static struct iommu_domain *apple_dart_domain_alloc(unsigned int type) > struct apple_dart_domain *dart_domain; > > if (type != IOMMU_DOMAIN_DMA && type != IOMMU_DOMAIN_UNMANAGED && > - type != IOMMU_DOMAIN_IDENTITY && type != IOMMU_DOMAIN_BLOCKED) > + type != IOMMU_DOMAIN_BLOCKED) > return NULL; > > dart_domain = kzalloc(sizeof(*dart_domain), GFP_KERNEL); > @@ -732,7 +750,7 @@ static struct iommu_domain *apple_dart_domain_alloc(unsigned int type) > mutex_init(&dart_domain->init_lock); > > /* no need to allocate pgtbl_ops or do any other finalization steps */ > - if (type == IOMMU_DOMAIN_IDENTITY || type == IOMMU_DOMAIN_BLOCKED) > + if (type == IOMMU_DOMAIN_BLOCKED) > dart_domain->finalized = true; > > return &dart_domain->domain; > @@ -947,6 +965,7 @@ static void apple_dart_get_resv_regions(struct device *dev, > } > > static const struct iommu_ops apple_dart_iommu_ops = { > + .identity_domain = &apple_dart_identity_domain, > .domain_alloc = apple_dart_domain_alloc, > .probe_device = apple_dart_probe_device, > .release_device = apple_dart_release_device, Reviewed-by: Janne Grunau best reagrds, Janne _______________________________________________ linux-arm-kernel mailing list linux-arm-kernel@lists.infradead.org http://lists.infradead.org/mailman/listinfo/linux-arm-kernel