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 6CDC2E7E65A for ; Tue, 26 Sep 2023 19:05:44 +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=ecZ1+KMxAXNuB5yzPtiOSoRhLkmEsjQhfIj4253pLqs=; b=lSnvIOBM9ak5hp 58TQ5TFRU+/kJCnkw66ttMLtbFM61XUNISPYZYy7jZb8oETsk/IU7JyEGDwKbVj8Fk8ZBQKq7RI/p jwOEeSaj8U5V0CQvk3UhOzMBdpaOE9x5TL4qYD9MrawLuPIWG/9F+DXYPAkwOMV/Q0xuu6O+6YEyv INy+8Euj17iSpddmLAVk1ALfncrmB1g3dTAst6GA4tQSGx0JSwq7+tjs7oWv02AAwKE2J2Fs7OFud RZMhhSLlHRON/nzHCBBCadVutuJSpHJHliMxaQ58Qzw7be50gnA1N4ieJKbjlcmUWaOfWZRcz9VW+ M+gaODyBMZnz5RRbhcow==; Received: from localhost ([::1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.96 #2 (Red Hat Linux)) id 1qlDN0-00Gu6Z-2q; Tue, 26 Sep 2023 19:05:18 +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 1qlDMx-00Gu5s-07 for linux-arm-kernel@lists.infradead.org; Tue, 26 Sep 2023 19:05:16 +0000 Received: from compute5.internal (compute5.nyi.internal [10.202.2.45]) by mailnew.west.internal (Postfix) with ESMTP id C5FB42B00139; Tue, 26 Sep 2023 15:05:12 -0400 (EDT) Received: from mailfrontend1 ([10.202.2.162]) by compute5.internal (MEProxy); Tue, 26 Sep 2023 15:05:14 -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=1695755112; x=1695758712; bh=J7 exHnsQYRJBdZItKfcOQx1NZselfQyXQouqmOrn0xs=; b=p7lUbVcIVde+aCTFxF MXrRvMzhb72YSlrsH0UEZmx96IucjYqoiUcTDgVEIm7HrdQnDCqsPxaGg5BXaAxA AbfvXlJLsm8jjR3OF8eowUHLUvehu3cMGh9YrHsoNcDFLjjrtlbF0BIBo3ZDVZv0 vRNZxAmwP+6BbbiXyWlt6NzsIlEcxfB2vymqEJjW+bk1JQi1Rk3x4aK+1rAZXTRt yd3vJzXU5EMBUta43wstc4SbHfLb3/zqsLVcfQH1WtnM4f7BGF9s0vkbz+82lSwL rar3skmax3L50u5b2OOKj9mh8s/nmzmOPu2x8J4bM8n21VG2ibcPga7ug1hEtNEa 53oA== 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=i47b949f6.fm2; t=1695755112; x=1695758712; bh=J7e xHnsQYRJBdZItKfcOQx1NZselfQyXQouqmOrn0xs=; b=n6zMX99nghX3F9xryXH Yle+J77pYkaPpUQ9LWyXGG7ttU4OteqUOrOTsR58wKHeqBK6MaF0MXka82mq2KRm NoH80lD7MTFHzqtoXnuGaRYe+U0a10N6UAONP3EesFZipqy4pmpic7YRioUVjEWY xLSd3aJaQoh6ZVX03n5u2mbRPLVu6GifXo9JT+/ODBX2HInnRHF9u3i+gBptCptb juFETw7TanVCqhOkC787gKnY6X8XC6fJ3ZqHDknX32LLJSoctFF8wqiRRkGMc3pf gb8CJ05LVFxLjIK4clV107IDCZK7dTPKdO4CxVCcpdEWM4fYF99QPe+a5HYJ9UA1 vhQ== X-ME-Sender: X-ME-Received: X-ME-Proxy-Cause: gggruggvucftvghtrhhoucdtuddrgedvjedrtddtgddutdefucetufdoteggodetrfdotf fvucfrrhhofhhilhgvmecuhfgrshhtofgrihhlpdfqfgfvpdfurfetoffkrfgpnffqhgen uceurghilhhouhhtmecufedttdenucesvcftvggtihhpihgvnhhtshculddquddttddmne cujfgurhepfffhvfevuffkfhggtggujgesthdtredttddtjeenucfhrhhomheplfgrnhhn vgcuifhruhhnrghuuceojhesjhgrnhhnrghurdhnvghtqeenucggtffrrghtthgvrhhnpe fgvdffveelgedujeeffeehheekheelheefgfejffeftedugeethfeuudefheefteenucev lhhushhtvghrufhiiigvpedtnecurfgrrhgrmhepmhgrihhlfhhrohhmpehjrghnnhgvse hjrghnnhgruhdrnhgvth X-ME-Proxy: Feedback-ID: i47b949f6:Fastmail Received: by mail.messagingengine.com (Postfix) with ESMTPA; Tue, 26 Sep 2023 15:05:09 -0400 (EDT) Date: Tue, 26 Sep 2023 21:05:08 +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 6/8] iommu/dart: Move the blocked domain support to a global static Message-ID: References: <0-v1-8060f06462cc+c0a39-dart_paging_jgg@nvidia.com> <6-v1-8060f06462cc+c0a39-dart_paging_jgg@nvidia.com> MIME-Version: 1.0 Content-Disposition: inline In-Reply-To: <6-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_120515_345233_FD10FF35 X-CRM114-Status: GOOD ( 25.90 ) 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:57PM -0300, Jason Gunthorpe wrote: > Move to the new static global for blocked domains. Move the blocked > specific code to apple_dart_attach_dev_blocked(). > > Signed-off-by: Jason Gunthorpe > --- > drivers/iommu/apple-dart.c | 36 ++++++++++++++++++++++++++---------- > 1 file changed, 26 insertions(+), 10 deletions(-) > > diff --git a/drivers/iommu/apple-dart.c b/drivers/iommu/apple-dart.c > index 424f779ccc34df..376f4c5461e8f7 100644 > --- a/drivers/iommu/apple-dart.c > +++ b/drivers/iommu/apple-dart.c > @@ -675,10 +675,6 @@ static int apple_dart_attach_dev(struct iommu_domain *domain, > for_each_stream_map(i, cfg, stream_map) > apple_dart_setup_translation(dart_domain, stream_map); > break; > - case IOMMU_DOMAIN_BLOCKED: > - for_each_stream_map(i, cfg, stream_map) > - apple_dart_hw_disable_dma(stream_map); > - break; > default: > return -EINVAL; > } > @@ -710,6 +706,30 @@ static struct iommu_domain apple_dart_identity_domain = { > .ops = &apple_dart_identity_ops, > }; > > +static int apple_dart_attach_dev_blocked(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->force_bypass) > + return -EINVAL; unrelated to this change as this keeps the current behavior but I think force_bypass should not override IOMMU_DOMAIN_BLOCKED. It is set if the CPU page size is smaller than dart's page size. Obviously dart can't translate in that situation but it should be still possible to block it completely. How do we manage this? I can write a patch either to the current state or based on this series. > + > + for_each_stream_map(i, cfg, stream_map) > + apple_dart_hw_disable_dma(stream_map); > + return 0; > +} > + > +static const struct iommu_domain_ops apple_dart_blocked_ops = { > + .attach_dev = apple_dart_attach_dev_blocked, > +}; > + > +static struct iommu_domain apple_dart_blocked_domain = { > + .type = IOMMU_DOMAIN_BLOCKED, > + .ops = &apple_dart_blocked_ops, > +}; > + > static struct iommu_device *apple_dart_probe_device(struct device *dev) > { > struct apple_dart_master_cfg *cfg = dev_iommu_priv_get(dev); > @@ -739,8 +759,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_BLOCKED) > + if (type != IOMMU_DOMAIN_DMA && type != IOMMU_DOMAIN_UNMANAGED) > return NULL; > > dart_domain = kzalloc(sizeof(*dart_domain), GFP_KERNEL); > @@ -749,10 +768,6 @@ 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_BLOCKED) > - dart_domain->finalized = true; > - > return &dart_domain->domain; > } > > @@ -966,6 +981,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, > + .blocked_domain = &apple_dart_blocked_domain, > .domain_alloc = apple_dart_domain_alloc, > .probe_device = apple_dart_probe_device, > .release_device = apple_dart_release_device, > -- > 2.42.0 Reviewed-by: Janne Grunau best regards Janne ps: I sent the reply to [Patch 4/8] accidentally with an incorrect from address but the correct Reviewed-by:. I can resend if necessary. _______________________________________________ linux-arm-kernel mailing list linux-arm-kernel@lists.infradead.org http://lists.infradead.org/mailman/listinfo/linux-arm-kernel