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 B91DEC001E0 for ; Thu, 10 Aug 2023 14:39:06 +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=RnA7kjiXuq7ROXsuGBuhVk/qFb3PwAhXzNSE3Km8mCs=; b=DohLtLNtGypICe goBMsMcBHHQhQEpQ8FhpngMZ4jw3+sUUDigrIe3ygT1CgeAiftDoEnB4NdqovltuH5+PgEcL7woWr 8M69zCahwf6qOs1H8DCqZ3GY03oVfRSozJzMIS1NWm3eEVnGP2ZhHHnPei/r4CxMXcpNIWRukb4mB deRjsv5wnX72LS0qKTL3wlIhRc4g2oBhjhWFp+NO/HKkTp1kAqX+lk9QQ7BzKE+iDNENJBfqmBZXS 7ejhOJZ2rAHvfMh+UAxHrU88LLwNfH9lxtoiJ1umCwse7rS67hS+ygJ5VKeXM9FC0EUBV3BIIvhtT g45UGn8uXHQNexsQzTIw==; Received: from localhost ([::1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.96 #2 (Red Hat Linux)) id 1qU6oB-007t6A-0G; Thu, 10 Aug 2023 14:38:39 +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 1qU6o7-007t50-2s for linux-arm-kernel@lists.infradead.org; Thu, 10 Aug 2023 14:38:37 +0000 Received: from smtp.kernel.org (relay.kernel.org [52.25.139.140]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (2048 bits)) (No client certificate requested) by dfw.source.kernel.org (Postfix) with ESMTPS id 62F1B65E17; Thu, 10 Aug 2023 14:38:35 +0000 (UTC) Received: by smtp.kernel.org (Postfix) with ESMTPSA id 4187EC433C8; Thu, 10 Aug 2023 14:38:33 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1691678314; bh=wPlT1kTX+LJbVgI71KW4aFe+lchw8z+KNrjLkFIDmUE=; h=Date:From:To:Cc:Subject:References:In-Reply-To:From; b=B+GZx5jwV0YuOSBiNzPZ9Ylu3xHqnFx0Zj48w/baa8eZEFkKn3xnD9pUeqDPQQi1c rkQLPKm015E8nUfBFnbwMGFjseLRBpEjJ7+DT1rVU2Xpcsn9CPnpiyJ92M1ZZKJSPc +FsLzTy93/H25XnFhH7RoelRif42lEGXMyF3DXSgAjoy8r/wjdaSmO7EBhTDB80hw6 Qxr17zn0f5l9y3fz3vYRWRCxaT6YjvA7aU785/KKOw20to8FeNI+IZeiQCqEnJSnqC oDunMAPUDX4xcD81E0wQp59pIK9q7wqIjSHnpcF2DylKO5SLhAWeEgy9kTqBlFcObp x781MZAwcr6zA== Date: Thu, 10 Aug 2023 15:38:29 +0100 From: Will Deacon To: Michael Shavit Cc: iommu@lists.linux.dev, linux-arm-kernel@lists.infradead.org, linux-kernel@vger.kernel.org, robin.murphy@arm.com, nicolinc@nvidia.com, jgg@nvidia.com, jean-philippe@linaro.org Subject: Re: [PATCH v5 6/9] iommu/arm-smmu-v3: Move CD table to arm_smmu_master Message-ID: <20230810143829.GC5795@willie-the-truck> References: <20230808171446.2187795-1-mshavit@google.com> <20230809011204.v5.6.Ice063dcf87d1b777a72e008d9e3406d2bcf6d876@changeid> <20230809135024.GD4226@willie-the-truck> 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-20230810_073836_011324_24657015 X-CRM114-Status: GOOD ( 21.61 ) 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 Thu, Aug 10, 2023 at 05:23:37PM +0800, Michael Shavit wrote: > > > > > @@ -2465,6 +2450,22 @@ static int arm_smmu_attach_dev(struct iommu_domain *domain, struct device *dev) > > > if (smmu_domain->stage != ARM_SMMU_DOMAIN_BYPASS) > > > master->ats_enabled = arm_smmu_ats_supported(master); > > > > > > + if (smmu_domain->stage == ARM_SMMU_DOMAIN_S1) { > > > + if (!master->cd_table.cdtab) { > > > + ret = arm_smmu_alloc_cd_tables(master); > > > + if (ret) { > > > + master->domain = NULL; > > > + return ret; > > > + } > > > + } > > > + > > > + ret = arm_smmu_write_ctx_desc(master, 0, &smmu_domain->cd); > > > + if (ret) { > > > + master->domain = NULL; > > > + return ret; > > > > Can you leak the cd tables here if you just allocated them? > > The CD table is only de-allocated when the SMMU device is released, so > this isn't "leaked" anymore than on a successful attachment. In a > previous version of this patch, this CD table was even pre-allocated > at probe time but is deferred to first attach following this > discussion: https://lore.kernel.org/lkml/ZMOzs1%2FxoEPX2+vA@nvidia.com/ Thanks, that makes sense. > > > @@ -2472,10 +2473,7 @@ static int arm_smmu_attach_dev(struct iommu_domain *domain, struct device *dev) > > > spin_unlock_irqrestore(&smmu_domain->devices_lock, flags); > > > > > > arm_smmu_enable_ats(master); > > > - > > > -out_unlock: > > > - mutex_unlock(&smmu_domain->init_mutex); > > > - return ret; > > > + return 0; > > > } > > > > > > static int arm_smmu_map_pages(struct iommu_domain *domain, unsigned long iova, > > > @@ -2719,6 +2717,8 @@ static void arm_smmu_release_device(struct device *dev) > > > arm_smmu_detach_dev(master); > > > arm_smmu_disable_pasid(master); > > > arm_smmu_remove_master(master); > > > + if (master->cd_table.cdtab_dma) > > > > Why are you checking 'cdtab_dma' here instead of just 'cdtab'? > > cd_table is statically allocated as part of the arm_smmu_master > struct. I suppose it could be allocated by arm_smmu_alloc_cd_tables() > instead? I just mean you could check 'master->cd_table.cdtab' like you do in other places. The DMA pointer is supposed to be opaque. Will _______________________________________________ linux-arm-kernel mailing list linux-arm-kernel@lists.infradead.org http://lists.infradead.org/mailman/listinfo/linux-arm-kernel