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 vger.kernel.org (vger.kernel.org [23.128.96.18]) by smtp.lore.kernel.org (Postfix) with ESMTP id 090CCCCA47F for ; Mon, 20 Jun 2022 10:11:14 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S240631AbiFTKLN (ORCPT ); Mon, 20 Jun 2022 06:11:13 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:42538 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S234353AbiFTKLM (ORCPT ); Mon, 20 Jun 2022 06:11:12 -0400 Received: from foss.arm.com (foss.arm.com [217.140.110.172]) by lindbergh.monkeyblade.net (Postfix) with ESMTP id 4210F958E; Mon, 20 Jun 2022 03:11:11 -0700 (PDT) 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 C40DE113E; Mon, 20 Jun 2022 03:11:10 -0700 (PDT) Received: from [10.57.84.159] (unknown [10.57.84.159]) by usa-sjc-imap-foss1.foss.arm.com (Postfix) with ESMTPSA id 162D83F7D7; Mon, 20 Jun 2022 03:11:05 -0700 (PDT) Message-ID: <55e352d5-3fea-7e46-0530-b41d323b6fcf@arm.com> Date: Mon, 20 Jun 2022 11:11:01 +0100 MIME-Version: 1.0 User-Agent: Mozilla/5.0 (Windows NT 10.0; rv:91.0) Gecko/20100101 Thunderbird/91.10.0 Subject: Re: [PATCH v2 5/5] vfio/iommu_type1: Simplify group attachment Content-Language: en-GB To: "Tian, Kevin" , Nicolin Chen Cc: "cohuck@redhat.com" , "kvm@vger.kernel.org" , "jordan@cosmicpenguin.net" , "linux-tegra@vger.kernel.org" , "thierry.reding@gmail.com" , "will@kernel.org" , "alyssa@rosenzweig.io" , "jean-philippe@linaro.org" , "saiprakash.ranjan@codeaurora.org" , "zhang.lyra@gmail.com" , "iommu@lists.linux-foundation.org" , "jonathanh@nvidia.com" , "jgg@nvidia.com" , "yangyingliang@huawei.com" , "orsonzhai@gmail.com" , "gerald.schaefer@linux.ibm.com" , "linux-s390@vger.kernel.org" , "linux-arm-msm@vger.kernel.org" , "alex.williamson@redhat.com" , "christophe.jaillet@wanadoo.fr" , "matthias.bgg@gmail.com" , "tglx@linutronix.de" , "virtualization@lists.linux-foundation.org" , "linux-arm-kernel@lists.infradead.org" , "isaacm@codeaurora.org" , "dwmw2@infradead.org" , "marcan@marcan.st" , "linux-kernel@vger.kernel.org" , "baolin.wang7@gmail.com" , "linux-mediatek@lists.infradead.org" References: <20220616000304.23890-1-nicolinc@nvidia.com> <20220616000304.23890-6-nicolinc@nvidia.com> From: Robin Murphy In-Reply-To: Content-Type: text/plain; charset=UTF-8; format=flowed Content-Transfer-Encoding: 7bit Precedence: bulk List-ID: X-Mailing-List: linux-s390@vger.kernel.org On 2022-06-17 03:53, Tian, Kevin wrote: >> From: Nicolin Chen >> Sent: Friday, June 17, 2022 6:41 AM >> >>> ... >>>> - if (resv_msi) { >>>> + if (resv_msi && !domain->msi_cookie) { >>>> ret = iommu_get_msi_cookie(domain->domain, >>>> resv_msi_base); >>>> if (ret && ret != -ENODEV) >>>> goto out_detach; >>>> + domain->msi_cookie = true; >>>> } >>> >>> why not moving to alloc_attach_domain() then no need for the new >>> domain field? It's required only when a new domain is allocated. >> >> When reusing an existing domain that doesn't have an msi_cookie, >> we can do iommu_get_msi_cookie() if resv_msi is found. So it is >> not limited to a new domain. > > Looks msi_cookie requirement is per platform (currently only > for smmu. see arm_smmu_get_resv_regions()). If there is > no mixed case then above check is not required. > > But let's hear whether Robin has a different thought here. Yes, the cookie should logically be tied to the lifetime of the domain itself. In the relevant context, "an existing domain that doesn't have an msi_cookie" should never exist. Thanks, Robin.