From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from mga05.intel.com (mga05.intel.com [192.55.52.43]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 8F6D66D19 for ; Wed, 8 Mar 2023 13:46:32 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=intel.com; i=@intel.com; q=dns/txt; s=Intel; t=1678283192; x=1709819192; h=message-id:date:mime-version:cc:subject:to:references: from:in-reply-to:content-transfer-encoding; bh=cLzqhxsSIHp6ZP19aTukTvTx2N71d5JAOG3jNV7+GK4=; b=itCTDGRAA7b0/7DeTpeB3sVXohFtaXzcUkLafIpFiL9Oy4/bBLxKEm2U 2iGJX0MlwSFt49sXSMYHehwJ/cnHijnny/8SX8f4xwevxjyIeMUmsQ0iZ bBWfI2f7WhoxqLP90GnYPhLkFVM0Jh2jZLwJITt6VKS3LeL6AkyC/W5M3 uPO4k8nqsI1WExlUyp3T5bkfRGzv3yqC/7kSJNV1eRmo/JMpWPAnJb9Ry qAjkzsbxuKTs+aqMV5seUIjlcyh3hDyk9fAp71Ci6bUjzsUnaUvZ5FbsF GaW8gfYH7H601djUjDUVzzo8p5nk0+fwkPN54p7Kh/DubIoFttYGuikwO A==; X-IronPort-AV: E=McAfee;i="6500,9779,10642"; a="422423426" X-IronPort-AV: E=Sophos;i="5.98,244,1673942400"; d="scan'208";a="422423426" Received: from orsmga004.jf.intel.com ([10.7.209.38]) by fmsmga105.fm.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 08 Mar 2023 05:46:31 -0800 X-ExtLoop1: 1 X-IronPort-AV: E=McAfee;i="6500,9779,10642"; a="800751524" X-IronPort-AV: E=Sophos;i="5.98,244,1673942400"; d="scan'208";a="800751524" Received: from blu2-mobl.ccr.corp.intel.com (HELO [10.254.208.136]) ([10.254.208.136]) by orsmga004-auth.jf.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 08 Mar 2023 05:46:29 -0800 Message-ID: <61a79971-6dc5-fb03-3fe8-eef1030b5dfb@linux.intel.com> Date: Wed, 8 Mar 2023 21:46:27 +0800 Precedence: bulk X-Mailing-List: iommu@lists.linux.dev List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 User-Agent: Mozilla/5.0 (Windows NT 10.0; Win64; x64; rv:102.0) Gecko/20100101 Thunderbird/102.8.0 Cc: baolu.lu@linux.intel.com, kvm@vger.kernel.org, Nicolin Chen , Yi Liu Subject: Re: [PATCH v2 10/17] iommufd: Reorganize iommufd_device_attach into iommufd_device_change_pt Content-Language: en-US To: Jason Gunthorpe , iommu@lists.linux.dev, Kevin Tian , linux-kselftest@vger.kernel.org References: <10-v2-51b9896e7862+8a8c-iommufd_alloc_jgg@nvidia.com> From: Baolu Lu In-Reply-To: <10-v2-51b9896e7862+8a8c-iommufd_alloc_jgg@nvidia.com> Content-Type: text/plain; charset=UTF-8; format=flowed Content-Transfer-Encoding: 7bit On 2023/3/8 8:35, Jason Gunthorpe wrote: > The code flow for first time attaching a PT and replacing a PT is very > similar except for the lowest do_attach step. > > Reorganize this so that the do_attach step is a function pointer. > > Replace requires destroying the old HWPT once it is replaced. This > destruction cannot be done under all the locks that are held in the > function pointer, so the signature allows returning a HWPT which will be > destroyed by the caller after everything is unlocked. > > Signed-off-by: Jason Gunthorpe Reviewed-by: Lu Baolu Best regards, baolu