From patchwork Wed Oct 18 05:06:36 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: "Zhang, Tina" X-Patchwork-Id: 154655 Return-Path: Delivered-To: ouuuleilei@gmail.com Received: by 2002:a05:612c:2908:b0:403:3b70:6f57 with SMTP id ib8csp4570671vqb; Tue, 17 Oct 2023 22:07:17 -0700 (PDT) X-Google-Smtp-Source: AGHT+IEJwiG+xratoKotTDEWjFq3oOvNIMIWPTM9HIYOh6rmO91R+V+Q+ndBvLL+yh16zwqDFeE6 X-Received: by 2002:a05:6a00:1c92:b0:690:d0d4:6fb0 with SMTP id y18-20020a056a001c9200b00690d0d46fb0mr4340640pfw.3.1697605637222; Tue, 17 Oct 2023 22:07:17 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1697605637; cv=none; d=google.com; s=arc-20160816; b=mY2ZoMGU9luSrCnywd4ooZTXe1HeOY8LBcbbA6QGO0gpPQudSfGEqebhvqOMEYv4JU A/gNPZx3iQWh8L3PPTqP7YZrl10ubPVn24x3Ho0xcT8TXGdv5pGpZZgg3L20vodp1K9M ni+evL8jBg3XP3FMXv3BY78PWSaJ8M0CMZIthu0Oom5x7hv7LRSvhPZ3tIDxh+ugGxcc oH/VwR2wdiu9n4RyvoEURzhmQsDNwCufg4l8nVYg8m4MVpk25kvhJwtEUdL6NS5zeK2V BBB1NTghdntshVQBA91piKgooV63rCnfMYledQ/MHueLGDAMZ/nFGn46ILJgfHKJrIfC M6mQ== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:content-transfer-encoding:mime-version :references:in-reply-to:message-id:date:subject:cc:to:from :dkim-signature; bh=XmOXFJayGzWJ026VhE5olz7mMJo0A9jH97oIEDDGY/I=; fh=dJBxdn+RXcUABM1aUIOqfrsndRxIHilofn8/gNUoPfs=; b=g0DEXPw2Xn9QhYhGupzUVa3L4lQxFKPoxHMRRjRL8M9A9eV71sSzLoVwGIvtoxAvNx AaftfF+ru0fTXX3FEzldji/NOtK3hWTWHcRP9bgvLjqRI/Q7EDECYJrJQ7yilXhUS32n Yq9Lrl2JwaFaD/7INVeZQHHHQSY7RkSI/moJCNDNzXko5Ka3zlT9qrQXm5OgTITgKsVe kOZb2o+s7uwzalv5Qe9owx8d+4CpWEh+SvgQoPqzoaVZ2PYKu8yHZArk3Yi0GvAMRnDX DOLZtxi3SUYT6qxP6tISAbTy0JnzC9/lUMC6OyBrxB08imSyGIxjiS+vbUUeccCrMGcV RBTQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@intel.com header.s=Intel header.b=kaNNT6Ex; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::3:7 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=intel.com Received: from snail.vger.email (snail.vger.email. [2620:137:e000::3:7]) by mx.google.com with ESMTPS id j3-20020a056a00174300b00690ffbb46e6si3252563pfc.261.2023.10.17.22.07.16 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 17 Oct 2023 22:07:17 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::3:7 as permitted sender) client-ip=2620:137:e000::3:7; Authentication-Results: mx.google.com; dkim=pass header.i=@intel.com header.s=Intel header.b=kaNNT6Ex; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::3:7 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=intel.com Received: from out1.vger.email (depot.vger.email [IPv6:2620:137:e000::3:0]) by snail.vger.email (Postfix) with ESMTP id 70EC18116E50; Tue, 17 Oct 2023 22:07:16 -0700 (PDT) X-Virus-Status: Clean X-Virus-Scanned: clamav-milter 0.103.10 at snail.vger.email Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S229552AbjJRFHJ (ORCPT + 23 others); Wed, 18 Oct 2023 01:07:09 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:40012 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S229453AbjJRFHF (ORCPT ); Wed, 18 Oct 2023 01:07:05 -0400 Received: from mgamail.intel.com (mgamail.intel.com [134.134.136.24]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 66C9EA2 for ; Tue, 17 Oct 2023 22:07:04 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=intel.com; i=@intel.com; q=dns/txt; s=Intel; t=1697605624; x=1729141624; h=from:to:cc:subject:date:message-id:in-reply-to: references:mime-version:content-transfer-encoding; bh=Dc0MbEJ8iTAniu2BvDRHDAZHMXmQyjjI1WBQvNDPIaM=; b=kaNNT6Ex4zDQv/1Y4EKPCiCoc1fAg2mAYSNl3i43/NamOYw4N2a3h3BE /KWf0INiy5sddqHgI+B2xOPqEnIjLvYVrFq/3qCor1v5yxIVqvLLUVCWO FzFgCtw9aZ5X6YRbDSdXwbfyzDcn8/Kh5XdId+fWAyt7SbIFvmhKkEgi6 JNKJLvWoHUq8ZxeA4KeDd7qJzLBW+/YlXO8Vsm64IzAxAJQCwoKUrMreP uHFnvzAtS0WhDjwog+vViB3A3dId0mRR9PgFdO6yYnBV1Efo8pr+hBCOj PZO5lUxdbdUsrmB2YkpizBvmU0cGJOubS4hu06I+zXhmT+V+6eh4ePqxF Q==; X-IronPort-AV: E=McAfee;i="6600,9927,10866"; a="388802386" X-IronPort-AV: E=Sophos;i="6.03,234,1694761200"; d="scan'208";a="388802386" Received: from fmsmga008.fm.intel.com ([10.253.24.58]) by orsmga102.jf.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 17 Oct 2023 22:07:04 -0700 X-ExtLoop1: 1 X-IronPort-AV: E=McAfee;i="6600,9927,10866"; a="822288643" X-IronPort-AV: E=Sophos;i="6.03,234,1694761200"; d="scan'208";a="822288643" Received: from sqa-gate.sh.intel.com (HELO spr-2s5.tsp.org) ([10.239.48.212]) by fmsmga008.fm.intel.com with ESMTP; 17 Oct 2023 22:07:00 -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 v9 1/5] iommu/vt-d: Remove mm->pasid in intel_sva_bind_mm() Date: Wed, 18 Oct 2023 13:06:36 +0800 Message-Id: <20231018050640.24936-2-tina.zhang@intel.com> X-Mailer: git-send-email 2.39.3 In-Reply-To: <20231018050640.24936-1-tina.zhang@intel.com> References: <20231018050640.24936-1-tina.zhang@intel.com> MIME-Version: 1.0 X-Spam-Status: No, score=-4.4 required=5.0 tests=BAYES_00,DKIMWL_WL_HIGH, DKIM_SIGNED,DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,RCVD_IN_DNSWL_MED, RCVD_IN_MSPIKE_H3,RCVD_IN_MSPIKE_WL,SPF_HELO_NONE,SPF_NONE autolearn=ham autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on lindbergh.monkeyblade.net Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org X-Greylist: Sender passed SPF test, not delayed by milter-greylist-4.6.4 (snail.vger.email [0.0.0.0]); Tue, 17 Oct 2023 22:07:16 -0700 (PDT) X-getmail-retrieved-from-mailbox: INBOX X-GMAIL-THRID: 1780068528655627014 X-GMAIL-MSGID: 1780068528655627014 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 --- 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, unsigned int pasid, } 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 = dev_iommu_priv_get(dev); + struct mm_struct *mm = domain->mm; struct intel_svm_dev *sdev; struct intel_svm *svm; unsigned long sflags; int ret = 0; - svm = pasid_private_find(mm->pasid); + svm = pasid_private_find(pasid); if (!svm) { svm = kzalloc(sizeof(*svm), GFP_KERNEL); if (!svm) return -ENOMEM; - svm->pasid = mm->pasid; + svm->pasid = pasid; svm->mm = mm; INIT_LIST_HEAD_RCU(&svm->devs); @@ -342,7 +343,7 @@ static int intel_svm_bind_mm(struct intel_iommu *iommu, struct device *dev, /* Setup the pasid table: */ sflags = cpu_feature_enabled(X86_FEATURE_LA57) ? PASID_FLAG_FL5LP : 0; - ret = intel_pasid_setup_first_level(iommu, dev, mm->pgd, mm->pasid, + ret = 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); } @@ -796,9 +797,8 @@ static int intel_svm_set_dev_pasid(struct iommu_domain *domain, { struct device_domain_info *info = dev_iommu_priv_get(dev); struct intel_iommu *iommu = info->iommu; - struct mm_struct *mm = domain->mm; - return intel_svm_bind_mm(iommu, dev, mm); + return intel_svm_bind_mm(iommu, dev, domain, pasid); } static void intel_svm_domain_free(struct iommu_domain *domain)