From nobody Thu Apr 9 13:26:19 2026 Received: from mgamail.intel.com (mgamail.intel.com [192.198.163.18]) (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 BD94434EF0E for ; Mon, 9 Mar 2026 06:10:02 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=192.198.163.18 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1773036604; cv=none; b=UpBF9yUSDMZhUCJnZWLldU2N+e91dtVDyTdCctFwhmOn2eYuJsJYun0wky3vy3j08y0hpFRKWL1X0Do0eshvto/z6KVoWrpuelIcC/4RAG/zx89hcJjYuHAqyVzyBfS+OhUhklWnEbBO6GqBWSCfZflk/HTdu5x5H4kSg0DF2vY= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1773036604; c=relaxed/simple; bh=Ai3mLIr1aMxlF434+33AGSEqNokSCKdS5uiESmB7DFg=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=KZs/aUfZD4tYYqpKMDmhjowCFKPrJ01lb/uJ6WGGpFJypo41QLh8yjo41CmaaudmVPbxZmcqXF3AD1QY3OHSlMlQvGbKOj9HcEGvyv7mdPQ+j+UKCj83c3L97JaNl7Lhttis2ry3Zd1lDGDNVRKEO+RLokYJs0w9sKc740f0mU0= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=linux.intel.com; spf=pass smtp.mailfrom=linux.intel.com; dkim=pass (2048-bit key) header.d=intel.com header.i=@intel.com header.b=W4mb3AQV; arc=none smtp.client-ip=192.198.163.18 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=linux.intel.com Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=linux.intel.com Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=intel.com header.i=@intel.com header.b="W4mb3AQV" DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=intel.com; i=@intel.com; q=dns/txt; s=Intel; t=1773036603; x=1804572603; h=from:to:cc:subject:date:message-id:in-reply-to: references:mime-version:content-transfer-encoding; bh=Ai3mLIr1aMxlF434+33AGSEqNokSCKdS5uiESmB7DFg=; b=W4mb3AQV/3XAau/e3jzA03080I6IfOChb404yIhSt5JgaNjwK7/EDvFA glSb+hXrp+TT4UMMW2u+uYBJG5fkj58gY5GyXt6TBGkT009Sdew+cdWKs mTp7tSWeiLOALsMYNFUFAcYREignbZ9VGMICWZMdwxWCsoNFMjGIHyhsW vMrrEQQGX6dtXMe+pUQ0WiNnfimwpC2L4rBs0VaVGK+BvMbLXglHfB2aA BXHlhHEvNVr8PLB5vNplzlw8YdrSWpw/MMRVNNhS8ElbqHpcCosNJCJ7x 5F8SWd9O5Vbh22QsNcT5RRqiJS0sOztNMiTbRz2si0J6NCcIinzihmXRJ g==; X-CSE-ConnectionGUID: EMI5qigIRT6p/gODKBvhCA== X-CSE-MsgGUID: weaS5mOOTa+jwIoaPmUErA== X-IronPort-AV: E=McAfee;i="6800,10657,11723"; a="73248314" X-IronPort-AV: E=Sophos;i="6.23,109,1770624000"; d="scan'208";a="73248314" Received: from fmviesa001.fm.intel.com ([10.60.135.141]) by fmvoesa112.fm.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 08 Mar 2026 23:10:02 -0700 X-CSE-ConnectionGUID: nJm8H1PtToOSmPMBSvrzFQ== X-CSE-MsgGUID: U1YReGvGR7Wjaas/4vYOEg== X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="6.23,109,1770624000"; d="scan'208";a="245669183" Received: from allen-box.sh.intel.com ([10.239.159.52]) by fmviesa001.fm.intel.com with ESMTP; 08 Mar 2026 23:10:00 -0700 From: Lu Baolu To: Joerg Roedel , Will Deacon , Robin Murphy , Kevin Tian , Jason Gunthorpe Cc: Dmytro Maluka , Samiullah Khawaja , iommu@lists.linux.dev, linux-kernel@vger.kernel.org, Lu Baolu Subject: [PATCH 8/8] iommu/vt-d: Use intel_pasid_write() for nested setup Date: Mon, 9 Mar 2026 14:06:48 +0800 Message-ID: <20260309060648.276762-9-baolu.lu@linux.intel.com> X-Mailer: git-send-email 2.43.0 In-Reply-To: <20260309060648.276762-1-baolu.lu@linux.intel.com> References: <20260309060648.276762-1-baolu.lu@linux.intel.com> Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable Content-Type: text/plain; charset="utf-8" Refactor intel_pasid_setup_nested() to utilize the intel_pasid_write() helper. Move the implementation to the entry_sync infrastructure, where the nested PASID entry is constructed in a local buffer and committed via the centralized intel_pasid_write() wrapper. Signed-off-by: Lu Baolu --- drivers/iommu/intel/nested.c | 13 +------------ drivers/iommu/intel/pasid.c | 27 +++++---------------------- 2 files changed, 6 insertions(+), 34 deletions(-) diff --git a/drivers/iommu/intel/nested.c b/drivers/iommu/intel/nested.c index 2b979bec56ce..1cebc1232f70 100644 --- a/drivers/iommu/intel/nested.c +++ b/drivers/iommu/intel/nested.c @@ -131,17 +131,6 @@ static int intel_nested_cache_invalidate_user(struct i= ommu_domain *domain, return ret; } =20 -static int domain_setup_nested(struct intel_iommu *iommu, - struct dmar_domain *domain, - struct device *dev, ioasid_t pasid, - struct iommu_domain *old) -{ - if (old) - intel_pasid_tear_down_entry(iommu, dev, pasid, false); - - return intel_pasid_setup_nested(iommu, dev, pasid, domain); -} - static int intel_nested_set_dev_pasid(struct iommu_domain *domain, struct device *dev, ioasid_t pasid, struct iommu_domain *old) @@ -170,7 +159,7 @@ static int intel_nested_set_dev_pasid(struct iommu_doma= in *domain, if (ret) goto out_remove_dev_pasid; =20 - ret =3D domain_setup_nested(iommu, dmar_domain, dev, pasid, old); + ret =3D intel_pasid_setup_nested(iommu, dev, pasid, dmar_domain); if (ret) goto out_unwind_iopf; =20 diff --git a/drivers/iommu/intel/pasid.c b/drivers/iommu/intel/pasid.c index cb55ff422d7d..5e0548dd8388 100644 --- a/drivers/iommu/intel/pasid.c +++ b/drivers/iommu/intel/pasid.c @@ -754,12 +754,8 @@ static void pasid_pte_config_nestd(struct intel_iommu = *iommu, { struct pt_iommu_vtdss_hw_info pt_info; =20 - lockdep_assert_held(&iommu->lock); - pt_iommu_vtdss_hw_info(&s2_domain->sspt, &pt_info); =20 - pasid_clear_entry(pte); - if (s1_cfg->addr_width =3D=3D ADDR_WIDTH_5LEVEL) pasid_set_flpm(pte, 1); =20 @@ -806,7 +802,9 @@ int intel_pasid_setup_nested(struct intel_iommu *iommu,= struct device *dev, struct iommu_hwpt_vtd_s1 *s1_cfg =3D &domain->s1_cfg; struct dmar_domain *s2_domain =3D domain->s2_domain; u16 did =3D domain_id_iommu(domain, iommu); - struct pasid_entry *pte; + struct pasid_entry new_pte =3D {0}; + + iommu_group_mutex_assert(dev); =20 /* Address width should match the address width supported by hardware */ switch (s1_cfg->addr_width) { @@ -837,23 +835,8 @@ int intel_pasid_setup_nested(struct intel_iommu *iommu= , struct device *dev, return -EINVAL; } =20 - spin_lock(&iommu->lock); - pte =3D intel_pasid_get_entry(dev, pasid); - if (!pte) { - spin_unlock(&iommu->lock); - return -ENODEV; - } - if (pasid_pte_is_present(pte)) { - spin_unlock(&iommu->lock); - return -EBUSY; - } - - pasid_pte_config_nestd(iommu, pte, s1_cfg, s2_domain, did); - spin_unlock(&iommu->lock); - - pasid_flush_caches(iommu, pte, pasid, did); - - return 0; + pasid_pte_config_nestd(iommu, &new_pte, s1_cfg, s2_domain, did); + return intel_pasid_write(iommu, dev, pasid, (u128 *)&new_pte); } =20 /* --=20 2.43.0