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 522B5C7EE23 for ; Thu, 1 Jun 2023 18:26: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-Type: Content-Transfer-Encoding:List-Subscribe:List-Help:List-Post:List-Archive: List-Unsubscribe:List-Id:In-Reply-To:From:References:Cc:To:Subject: MIME-Version:Date:Message-ID:Reply-To:Content-ID:Content-Description: Resent-Date:Resent-From:Resent-Sender:Resent-To:Resent-Cc:Resent-Message-ID: List-Owner; bh=ORCN3TR/G1S6T+oNMALNBAbeIamxKBiY2TGhtHrPFIQ=; b=aTCjWnNY19/W8i Izaeveq0m+BGS5Jf36bjxZIwGfp+TzeE8V3iuWpikFIl5fYx2wH8ShBsyRMrxdTfeoc2A8fGgxZzx kGxUqIuR4su+1NEdpi15EeF1rcoQ7w7fpS9icO02Gr7rN/S53qTU05gG3eG5D1oiITN+YfbVw2p1W nDXvFHPE68zPl8vlcBQAPsPZnWqFKeMb+Npy8+JMyfljz0Y3CZ4RWT2Z+zljV9XyhTCvAsTK9RYV8 iBMfKo8Kesfhea5zIHFfUBYdhkcxNDfxZOZOSRmzzT33bXQAvyTJqMHRhdIw+wAz8cOwHZJjkTUP/ JS+13pCyZZqQz0mtJgQA==; Received: from localhost ([::1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.96 #2 (Red Hat Linux)) id 1q4mzj-004aEQ-05; Thu, 01 Jun 2023 18:25:55 +0000 Received: from foss.arm.com ([217.140.110.172]) by bombadil.infradead.org with esmtp (Exim 4.96 #2 (Red Hat Linux)) id 1q4mzg-004aCl-0y; Thu, 01 Jun 2023 18:25:54 +0000 Received: from usa-sjc-imap-foss1.foss.arm.com (unknown [10.121.207.14]) by usa-sjc-mx-foss1.foss.arm.com (Postfix) with ESMTP id 4B9511063; Thu, 1 Jun 2023 11:26:31 -0700 (PDT) Received: from [10.57.84.85] (unknown [10.57.84.85]) by usa-sjc-imap-foss1.foss.arm.com (Postfix) with ESMTPSA id B053E3F663; Thu, 1 Jun 2023 11:25:38 -0700 (PDT) Message-ID: <914124dd-c319-15c5-cc03-c5db0e4002f4@arm.com> Date: Thu, 1 Jun 2023 19:25:32 +0100 MIME-Version: 1.0 User-Agent: Mozilla/5.0 (Windows NT 10.0; rv:102.0) Gecko/20100101 Thunderbird/102.11.2 Subject: Re: [PATCH v2 04/25] iommu: Add IOMMU_DOMAIN_PLATFORM for S390 Content-Language: en-GB To: Jason Gunthorpe , Andy Gross , Alim Akhtar , Bjorn Andersson , AngeloGioacchino Del Regno , Baolin Wang , Christophe Leroy , Gerald Schaefer , Heiko Stuebner , iommu@lists.linux.dev, Jernej Skrabec , Jonathan Hunter , Joerg Roedel , Kevin Tian , Konrad Dybcio , Krzysztof Kozlowski , linux-arm-kernel@lists.infradead.org, linux-arm-msm@vger.kernel.org, linux-mediatek@lists.infradead.org, linux-rockchip@lists.infradead.org, linux-s390@vger.kernel.org, linux-samsung-soc@vger.kernel.org, linux-sunxi@lists.linux.dev, linux-tegra@vger.kernel.org, Russell King , linuxppc-dev@lists.ozlabs.org, Marek Szyprowski , Matthias Brugger , Matthew Rosato , Michael Ellerman , Nicholas Piggin , Orson Zhai , Rob Clark , Samuel Holland , Thierry Reding , Krishna Reddy , Chen-Yu Tsai , Will Deacon , Yong Wu , Chunyan Zhang Cc: Lu Baolu , Dmitry Osipenko , Nicolin Chen , Niklas Schnelle , Steven Price , Thierry Reding References: <4-v2-8d1dc464eac9+10f-iommu_all_defdom_jgg@nvidia.com> From: Robin Murphy In-Reply-To: <4-v2-8d1dc464eac9+10f-iommu_all_defdom_jgg@nvidia.com> X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20230601_112552_433889_FF687C3C X-CRM114-Status: GOOD ( 29.83 ) 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-Transfer-Encoding: 7bit Content-Type: text/plain; charset="us-ascii"; Format="flowed" Sender: "linux-arm-kernel" Errors-To: linux-arm-kernel-bounces+linux-arm-kernel=archiver.kernel.org@lists.infradead.org On 2023-05-16 01:00, Jason Gunthorpe wrote: > The PLATFORM domain will be set as the default domain and attached as > normal during probe. The driver will ignore the initial attach from a NULL > domain to the PLATFORM domain. > > After this, the PLATFORM domain's attach_dev will be called whenever we > detach from an UNMANAGED domain (eg for VFIO). This is the same time the > original design would have called op->detach_dev(). > > This is temporary until the S390 dma-iommu.c conversion is merged. If we do need a stopgap here, can we please just call the current situation an identity domain? It's true enough in the sense that the IOMMU API is not offering any translation or guarantee of isolation, so the semantics of an identity domain - from the point of view of anything inside the IOMMU API that would be looking - are no weaker or less useful than a "platform" domain whose semantics are intentionally unknown. Then similarly for patch #3 - since we already know s390 is temporary, it seems an anathema to introduce a whole domain type with its own weird ops->default_domain mechanism solely for POWER to not actually use domains with. In terms of reasoning, I don't see that IOMMU_DOMAIN_PLATFORM is any more useful than a NULL default domain, it just renames the problem, and gives us more code to maintain for the privilege. As I say, though, we don't actually need to juggle the semantic of a "we don't know what's happening here" domain around any further, since it works out that a "we're not influencing anything here" domain actually suffices for what we want to reason about, and those are already well-defined. Sure, the platform DMA ops *might* be doing more, but that's beyond the scope of the IOMMU API either way. At that point, lo and behold, s390 and POWER now look just like ARM and the core code only needs a single special case for arch-specific default identity domains, lovely! Thanks, Robin. > Tested-by: Heiko Stuebner > Tested-by: Niklas Schnelle > Signed-off-by: Jason Gunthorpe > --- > drivers/iommu/s390-iommu.c | 21 +++++++++++++++++++-- > 1 file changed, 19 insertions(+), 2 deletions(-) > > diff --git a/drivers/iommu/s390-iommu.c b/drivers/iommu/s390-iommu.c > index fbf59a8db29b11..f0c867c57a5b9b 100644 > --- a/drivers/iommu/s390-iommu.c > +++ b/drivers/iommu/s390-iommu.c > @@ -142,14 +142,31 @@ static int s390_iommu_attach_device(struct iommu_domain *domain, > return 0; > } > > -static void s390_iommu_set_platform_dma(struct device *dev) > +/* > + * Switch control over the IOMMU to S390's internal dma_api ops > + */ > +static int s390_iommu_platform_attach(struct iommu_domain *platform_domain, > + struct device *dev) > { > struct zpci_dev *zdev = to_zpci_dev(dev); > > + if (!zdev->s390_domain) > + return 0; > + > __s390_iommu_detach_device(zdev); > zpci_dma_init_device(zdev); > + return 0; > } > > +static struct iommu_domain_ops s390_iommu_platform_ops = { > + .attach_dev = s390_iommu_platform_attach, > +}; > + > +static struct iommu_domain s390_iommu_platform_domain = { > + .type = IOMMU_DOMAIN_PLATFORM, > + .ops = &s390_iommu_platform_ops, > +}; > + > static void s390_iommu_get_resv_regions(struct device *dev, > struct list_head *list) > { > @@ -428,12 +445,12 @@ void zpci_destroy_iommu(struct zpci_dev *zdev) > } > > static const struct iommu_ops s390_iommu_ops = { > + .default_domain = &s390_iommu_platform_domain, > .capable = s390_iommu_capable, > .domain_alloc = s390_domain_alloc, > .probe_device = s390_iommu_probe_device, > .release_device = s390_iommu_release_device, > .device_group = generic_device_group, > - .set_platform_dma_ops = s390_iommu_set_platform_dma, > .pgsize_bitmap = SZ_4K, > .get_resv_regions = s390_iommu_get_resv_regions, > .default_domain_ops = &(const struct iommu_domain_ops) { _______________________________________________ linux-arm-kernel mailing list linux-arm-kernel@lists.infradead.org http://lists.infradead.org/mailman/listinfo/linux-arm-kernel