From nobody Thu Sep 11 22:44:34 2025 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 0CFECC25B6E for ; Fri, 27 Oct 2023 00:06:13 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1345063AbjJ0AGM (ORCPT ); Thu, 26 Oct 2023 20:06:12 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:35760 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S231947AbjJ0AGJ (ORCPT ); Thu, 26 Oct 2023 20:06:09 -0400 Received: from mgamail.intel.com (mgamail.intel.com [134.134.136.24]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id E8A821B4 for ; Thu, 26 Oct 2023 17:06:06 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=intel.com; i=@intel.com; q=dns/txt; s=Intel; t=1698365167; x=1729901167; h=from:to:cc:subject:date:message-id:in-reply-to: references:mime-version:content-transfer-encoding; bh=KhGsLPqcLdYBHRjixMBCo4I5kFXzGXLaiyOCHceWDKU=; b=RU+QRvQ+tr/oZbJFbHtABYJ9jBcqMDAUV/Y8FeGqChl7a2KBjnIU30ZN hdJIHUjog8d6jwhwNXK6Ndtr4LFMnnF7YKSUlI3nDF3hcN70LgLYXs8gw 38xvmWmhREI8+6KNR8dbWz3E0//9Pd3eW8ad9ApC+Z7Dbp+XGw2FTMbar oKzIXtcZFvvHFfB/6nwp7j+kmUsFNX1rwdd7Hv8pPQs3+7Lmct5J0Ki+j hjJb63PQWKwDuCqHAetG24P50z6r1EZBnnVJC3N0GlqNHDkfDZg/aPW4H IemoNYUVnuZY2VbKp+RkMdEPRV6zyHKbU18apVxuUL8WpSw6tVKh0xqke w==; X-IronPort-AV: E=McAfee;i="6600,9927,10875"; a="390535941" X-IronPort-AV: E=Sophos;i="6.03,255,1694761200"; d="scan'208";a="390535941" Received: from orsmga004.jf.intel.com ([10.7.209.38]) by orsmga102.jf.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 26 Oct 2023 17:06:06 -0700 X-ExtLoop1: 1 X-IronPort-AV: E=McAfee;i="6600,9927,10875"; a="883017483" X-IronPort-AV: E=Sophos;i="6.03,255,1694761200"; d="scan'208";a="883017483" Received: from sqa-gate.sh.intel.com (HELO spr-2s5.tsp.org) ([10.239.48.212]) by orsmga004.jf.intel.com with ESMTP; 26 Oct 2023 17:06:03 -0700 From: Tina Zhang To: iommu@lists.linux.dev, linux-kernel@vger.kernel.org Cc: David Woodhouse , Lu Baolu , Joerg Roedel , Will Deacon , Robin Murphy , Jason Gunthorpe , Kevin Tian , Nicolin Chen , Michael Shavit , Vasant Hegde , Tina Zhang , Jason Gunthorpe Subject: [PATCH v10 2/6] iommu/vt-d: Remove mm->pasid in intel_sva_bind_mm() Date: Fri, 27 Oct 2023 08:05:21 +0800 Message-Id: <20231027000525.1278806-3-tina.zhang@intel.com> X-Mailer: git-send-email 2.39.3 In-Reply-To: <20231027000525.1278806-1-tina.zhang@intel.com> References: <20231027000525.1278806-1-tina.zhang@intel.com> MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Content-Type: text/plain; charset="utf-8" The pasid is passed in as a parameter through .set_dev_pasid() callback. Thus, intel_sva_bind_mm() can directly use it instead of retrieving the pasid value from mm->pasid. Suggested-by: Lu Baolu Reviewed-by: Lu Baolu Reviewed-by: Jason Gunthorpe Signed-off-by: Tina Zhang Signed-off-by: Jason Gunthorpe --- drivers/iommu/intel/svm.c | 14 +++++++------- 1 file changed, 7 insertions(+), 7 deletions(-) diff --git a/drivers/iommu/intel/svm.c b/drivers/iommu/intel/svm.c index 50a481c895b8..3c531af58658 100644 --- a/drivers/iommu/intel/svm.c +++ b/drivers/iommu/intel/svm.c @@ -290,21 +290,22 @@ static int pasid_to_svm_sdev(struct device *dev, unsi= gned int pasid, } =20 static int intel_svm_bind_mm(struct intel_iommu *iommu, struct device *dev, - struct mm_struct *mm) + struct iommu_domain *domain, ioasid_t pasid) { struct device_domain_info *info =3D dev_iommu_priv_get(dev); + struct mm_struct *mm =3D domain->mm; struct intel_svm_dev *sdev; struct intel_svm *svm; unsigned long sflags; int ret =3D 0; =20 - svm =3D pasid_private_find(mm->pasid); + svm =3D pasid_private_find(pasid); if (!svm) { svm =3D kzalloc(sizeof(*svm), GFP_KERNEL); if (!svm) return -ENOMEM; =20 - svm->pasid =3D mm->pasid; + svm->pasid =3D pasid; svm->mm =3D mm; INIT_LIST_HEAD_RCU(&svm->devs); =20 @@ -342,7 +343,7 @@ static int intel_svm_bind_mm(struct intel_iommu *iommu,= struct device *dev, =20 /* Setup the pasid table: */ sflags =3D cpu_feature_enabled(X86_FEATURE_LA57) ? PASID_FLAG_FL5LP : 0; - ret =3D intel_pasid_setup_first_level(iommu, dev, mm->pgd, mm->pasid, + ret =3D intel_pasid_setup_first_level(iommu, dev, mm->pgd, pasid, FLPT_DEFAULT_DID, sflags); if (ret) goto free_sdev; @@ -356,7 +357,7 @@ static int intel_svm_bind_mm(struct intel_iommu *iommu,= struct device *dev, free_svm: if (list_empty(&svm->devs)) { mmu_notifier_unregister(&svm->notifier, mm); - pasid_private_remove(mm->pasid); + pasid_private_remove(pasid); kfree(svm); } =20 @@ -796,9 +797,8 @@ static int intel_svm_set_dev_pasid(struct iommu_domain = *domain, { struct device_domain_info *info =3D dev_iommu_priv_get(dev); struct intel_iommu *iommu =3D info->iommu; - struct mm_struct *mm =3D domain->mm; =20 - return intel_svm_bind_mm(iommu, dev, mm); + return intel_svm_bind_mm(iommu, dev, domain, pasid); } =20 static void intel_svm_domain_free(struct iommu_domain *domain) --=20 2.39.3