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 D0AC4C63797 for ; Thu, 2 Feb 2023 10:21:29 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S229755AbjBBKV2 (ORCPT ); Thu, 2 Feb 2023 05:21:28 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:55764 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S231570AbjBBKV0 (ORCPT ); Thu, 2 Feb 2023 05:21:26 -0500 Received: from mga04.intel.com (mga04.intel.com [192.55.52.120]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 45F11199C0; Thu, 2 Feb 2023 02:21:26 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=intel.com; i=@intel.com; q=dns/txt; s=Intel; t=1675333286; x=1706869286; h=message-id:date:mime-version:cc:subject:to:references: from:in-reply-to:content-transfer-encoding; bh=I3BObQyIUsuS842dSFNMbhIiOWbS9ICN9kPUAQN0188=; b=Va5q1OF+YMnzitdPjOTwSx+C2/VtboYZ4Y5uyrxazS2ej7D2biET3KOd 7fauEJTX7coE8SouHc5gSsPO86trDieUk8mbOVzWG2U7h1jHsUN+dzVYY ap+hSIEUV7Bl7vH7wZyO7fnwRctZYDF1udsXI3LKyY5hqHmsOA8dbdqPv v5Q34hE42E8ec+aiPO+wdK/vpVmGHamNbeYptZHBQM48N4wVmnwW3krlO 6Sv5VxLqk+M3U7NMPfWqRba8wariVdq6M+YvrY7EtvHiCDhwUlhalOlNU HNH1lDEe5NMD4ZJ07TAXbE0JSH8/smqaQF4kiNNEU9jRP6vsJQ9fr084f Q==; X-IronPort-AV: E=McAfee;i="6500,9779,10608"; a="327061548" X-IronPort-AV: E=Sophos;i="5.97,267,1669104000"; d="scan'208";a="327061548" Received: from fmsmga008.fm.intel.com ([10.253.24.58]) by fmsmga104.fm.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 02 Feb 2023 02:21:25 -0800 X-IronPort-AV: E=McAfee;i="6500,9779,10608"; a="728809060" X-IronPort-AV: E=Sophos;i="5.97,267,1669104000"; d="scan'208";a="728809060" Received: from blu2-mobl.ccr.corp.intel.com (HELO [10.255.29.248]) ([10.255.29.248]) by fmsmga008-auth.fm.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 02 Feb 2023 02:21:22 -0800 Message-ID: Date: Thu, 2 Feb 2023 18:21:20 +0800 MIME-Version: 1.0 User-Agent: Mozilla/5.0 (Windows NT 10.0; Win64; x64; rv:102.0) Gecko/20100101 Thunderbird/102.6.1 Cc: baolu.lu@linux.intel.com, yi.l.liu@intel.com, linux-kernel@vger.kernel.org, iommu@lists.linux.dev, kvm@vger.kernel.org, linux-kselftest@vger.kernel.org Subject: Re: [PATCH v1 2/8] iommu: Introduce a new iommu_group_replace_domain() API Content-Language: en-US To: Nicolin Chen , jgg@nvidia.com, kevin.tian@intel.com, joro@8bytes.org, will@kernel.org, robin.murphy@arm.com, alex.williamson@redhat.com, shuah@kernel.org References: From: Baolu Lu In-Reply-To: Content-Type: text/plain; charset=UTF-8; format=flowed Content-Transfer-Encoding: 7bit Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On 2023/2/2 15:05, Nicolin Chen wrote: > +/** > + * iommu_group_replace_domain - replace the domain that a group is attached to > + * @new_domain: new IOMMU domain to replace with > + * @group: IOMMU group that will be attached to the new domain > + * > + * This API allows the group to switch domains without being forced to go to > + * the blocking domain in-between. > + * > + * If the attached domain is a core domain (e.g. a default_domain), it will act > + * just like the iommu_attach_group(). I am not following above two lines. Why and how could iommufd set a core domain to an iommu_group? > + */ > +int iommu_group_replace_domain(struct iommu_group *group, > + struct iommu_domain *new_domain) > +{ > + int ret; > + > + if (!new_domain) > + return -EINVAL; > + > + mutex_lock(&group->mutex); > + ret = __iommu_group_set_domain(group, new_domain); > + if (ret) { > + if (__iommu_group_set_domain(group, group->domain)) > + __iommu_group_set_core_domain(group); > + } > + mutex_unlock(&group->mutex); > + return ret; > +} > +EXPORT_SYMBOL_NS_GPL(iommu_group_replace_domain, IOMMUFD_INTERNAL); Best regards, baolu