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 88CA0C4167B for ; Tue, 12 Dec 2023 13:27:25 +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=cdJ4JmcZB6ZVllbHJy5malFU3pdXEID/agst3wYnBrg=; b=wtj2jxyNMe4Gvt wymVjikIMk3CD0aQ4tbNgOKDrXgZigjgEXZk7hRAspWcjX+3DcT60gbYVRSh0BSrlm5kAKZtOXnId QqiL8D13TlBOSaexI1ksGhZBHW3LkVMc8AlqBiSKHT5D+pPjqHRICE3kW5m+QqetR6lh63JF1GIxV FoaQArYgvzWUV2KtAJfZmSfgNVc/C3jI1GkR6RtCbj9EIHyYv380+T9td4TxTZIObzSebBlagwOTB K8InAKb2c32aL+lrUFBa5BbI0JYxK2lzMK9wXtGDC6UVPzP5XH3fzxpFh5iIbjQyZWMmK+0ngp+aP FkxCNygqLMFvj/t9mEVw==; Received: from localhost ([::1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.96 #2 (Red Hat Linux)) id 1rD2mp-00BnX2-2g; Tue, 12 Dec 2023 13:26:59 +0000 Received: from dfw.source.kernel.org ([139.178.84.217]) by bombadil.infradead.org with esmtps (Exim 4.96 #2 (Red Hat Linux)) id 1rD2mn-00BnWJ-2R for linux-arm-kernel@lists.infradead.org; Tue, 12 Dec 2023 13:26:59 +0000 Received: from smtp.kernel.org (transwarp.subspace.kernel.org [100.75.92.58]) by dfw.source.kernel.org (Postfix) with ESMTP id 32077614AB; Tue, 12 Dec 2023 13:26:57 +0000 (UTC) Received: by smtp.kernel.org (Postfix) with ESMTPSA id 95214C433C9; Tue, 12 Dec 2023 13:26:55 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1702387616; bh=MTJA9nOqanOoR/ftnPdykQUlIJ/hV7qeVCff8ipL5ys=; h=Date:From:To:Cc:Subject:References:In-Reply-To:From; b=KuDnY4sE50WXsmAzi4nARfS/uzdyeK9fUQyJ05WnrhkjWwNHattF/XVuABlEFzOco H9hdrrEd52kGu+mGHYcays1JUy/+V2JUp2/uXpoduhSqnQj9VM9p858uQrQDo29JDF kKycwjmQGTjPd4ldAJxnu0/zwBrwrC1Aq5p+YjG9b/DWYFjeHZBe8Iak9u+3yEnOhN PHrn9ippavR6jP4C80p3Nohwfqenu1MvJvu1zxynqNtL4/rG9o/Yih3Z+KuA/MoT0F lrE+50B48x0/upyFIe7zxY6riCZpkrk9T6CXyGn1v7b29bJE51bzAqKlr/WVNrrj6o rNDf9E/DXt2OQ== Date: Tue, 12 Dec 2023 13:26:51 +0000 From: Will Deacon To: Jason Gunthorpe Cc: iommu@lists.linux.dev, Joerg Roedel , linux-arm-kernel@lists.infradead.org, Robin Murphy , Nicolin Chen Subject: Re: [PATCH v2 5/5] iommu/arm-smmu: Convert to domain_alloc_paging() Message-ID: <20231212132651.GA29569@willie-the-truck> References: <0-v2-c86cc8c2230e+160bb-smmu_newapi_jgg@nvidia.com> <5-v2-c86cc8c2230e+160bb-smmu_newapi_jgg@nvidia.com> MIME-Version: 1.0 Content-Disposition: inline In-Reply-To: <5-v2-c86cc8c2230e+160bb-smmu_newapi_jgg@nvidia.com> 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-20231212_052657_837287_CF0282FB X-CRM114-Status: GOOD ( 24.46 ) 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 On Tue, Oct 17, 2023 at 03:11:44PM -0300, Jason Gunthorpe wrote: > Now that the BLOCKED and IDENTITY behaviors are managed with their own > domains change to the domain_alloc_paging() op. > > The check for using_legacy_binding is now redundant, > arm_smmu_def_domain_type() always returns IOMMU_DOMAIN_IDENTITY for this > mode, so the core code will never attempt to create a DMA domain in the > first place. > > Since commit a4fdd9762272 ("iommu: Use flush queue capability") the core > code only passes in IDENTITY/BLOCKED/UNMANAGED/DMA domain types. It will > not pass in IDENTITY or BLOCKED if the global statics exist, so the test > for DMA is also redundant now too. > > Call arm_smmu_init_domain_context() early if a dev is available. > > Signed-off-by: Jason Gunthorpe > --- > drivers/iommu/arm/arm-smmu/arm-smmu.c | 21 +++++++++++++++------ > 1 file changed, 15 insertions(+), 6 deletions(-) > > diff --git a/drivers/iommu/arm/arm-smmu/arm-smmu.c b/drivers/iommu/arm/arm-smmu/arm-smmu.c > index 6340ee8ab7c482..cea25afe9e49db 100644 > --- a/drivers/iommu/arm/arm-smmu/arm-smmu.c > +++ b/drivers/iommu/arm/arm-smmu/arm-smmu.c > @@ -842,14 +842,11 @@ static void arm_smmu_destroy_domain_context(struct arm_smmu_domain *smmu_domain) > arm_smmu_rpm_put(smmu); > } > > -static struct iommu_domain *arm_smmu_domain_alloc(unsigned type) > +static struct iommu_domain *arm_smmu_domain_alloc_paging(struct device *dev) > { > + struct arm_smmu_master_cfg *cfg = NULL; > struct arm_smmu_domain *smmu_domain; > > - if (type != IOMMU_DOMAIN_UNMANAGED) { > - if (using_legacy_binding || type != IOMMU_DOMAIN_DMA) > - return NULL; > - } > /* > * Allocate the domain and initialise some of its data structures. > * We can't really do anything meaningful until we've added a > @@ -862,6 +859,18 @@ static struct iommu_domain *arm_smmu_domain_alloc(unsigned type) > mutex_init(&smmu_domain->init_mutex); > spin_lock_init(&smmu_domain->cb_lock); > > + if (dev) > + cfg = dev_iommu_priv_get(dev); > + if (cfg) { > + int ret; > + > + ret = arm_smmu_init_domain_context(smmu_domain, cfg->smmu, dev); > + if (ret) { > + kfree(smmu_domain); > + return NULL; If we're just returning NULL, can we drop 'ret'? > + } > + } > + > return &smmu_domain->domain; Why do we need to handle the 'dev && !cfg' case here, instead of just returning NULL? Will _______________________________________________ linux-arm-kernel mailing list linux-arm-kernel@lists.infradead.org http://lists.infradead.org/mailman/listinfo/linux-arm-kernel