Received: by 2002:a05:7412:d8a:b0:e2:908c:2ebd with SMTP id b10csp620031rdg; Tue, 10 Oct 2023 23:52:44 -0700 (PDT) X-Google-Smtp-Source: AGHT+IGLUygyJn04Cy1qtibXiZ6VuEaKum7f3/2WklCCNNJtGy3igi4glJgDdlqB4nClvGuuG+hr X-Received: by 2002:a17:902:9a8e:b0:1c5:d063:b70e with SMTP id w14-20020a1709029a8e00b001c5d063b70emr15826990plp.53.1697007163757; Tue, 10 Oct 2023 23:52:43 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1697007163; cv=none; d=google.com; s=arc-20160816; b=Chpx37Nt4W0BEqdEcHTGWIQrGX4yE9mdZC6V5clsMjFrWDaZJ1M0L0EIS9Q4YSgJY8 0YuySkYW0d072h5Vdtj+jVt4yE6loz19RmsI75vnvGjpPrJ8WJUg3ESwMfJWc0x0En8c Cvfd/3S1ErtizBblVjAw+an7Gu4lUmC7BAhSalFGmX76HLBIS9B/IazKLtsuQ1LZmaNJ DHPnTuZ0+PS04i2oS4a+bKEWZEovSkpEmemXAWHXrm3se/PhmrC91AtBTQYZSGliij2s 0ucZUw5H3Z1qRPbL2AJnqHGzKBoyy894nzhU1KspJu3mkV3J1MfnObcClZXAoxC9iyx5 1dBA== 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=Q9bD7iFXSnVjlANjxYHEZXjN4iWWH4P/4116xLw/iSk=; b=YROIRU1Dq9hCsj/hWDieIgqOiC2nkA0ptDNKDX03MfP7/YI2aO4+YEhPohXgFC/fu8 avR0P1O+Hf9yah8nIhFIR06HmC1zAZI5jfWOB4Ps+tHRqhUooEEmNrvntw2+k9j5peUQ gAy3GDTuDORytlOGxVqJLfGMjmH5pYOvY7YbaPkAg84SuTVLvrRhV6+mcwYsam/ruSsg KaEADcghQ+vvbccgCXATV9YCKG6BoFHUBTYVhSLxLYLIkIQCPqoaNdV6S/GMUQBq6/AN RnsqlcNmncFSLcO39BZM7jZ4pmR21k8O4BgWCfrAec6nLM5N1jD9Q8+OHWgHuPBm4tVc 8mjw== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@intel.com header.s=Intel header.b=CAXNjpQv; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::3:1 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=intel.com Return-Path: Received: from morse.vger.email (morse.vger.email. [2620:137:e000::3:1]) by mx.google.com with ESMTPS id i15-20020a170902c94f00b001c4248c3f8bsi14155660pla.559.2023.10.10.23.52.43 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 10 Oct 2023 23:52:43 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::3:1 as permitted sender) client-ip=2620:137:e000::3:1; Authentication-Results: mx.google.com; dkim=pass header.i=@intel.com header.s=Intel header.b=CAXNjpQv; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::3:1 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 morse.vger.email (Postfix) with ESMTP id 6FE3A80758D7; Tue, 10 Oct 2023 23:52:10 -0700 (PDT) X-Virus-Status: Clean X-Virus-Scanned: clamav-milter 0.103.10 at morse.vger.email Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1345702AbjJKGvv (ORCPT + 99 others); Wed, 11 Oct 2023 02:51:51 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:51248 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1345542AbjJKGvp (ORCPT ); Wed, 11 Oct 2023 02:51:45 -0400 Received: from mgamail.intel.com (mgamail.intel.com [134.134.136.24]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 76273AC for ; Tue, 10 Oct 2023 23:51:41 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=intel.com; i=@intel.com; q=dns/txt; s=Intel; t=1697007102; x=1728543102; h=from:to:cc:subject:date:message-id:in-reply-to: references:mime-version:content-transfer-encoding; bh=Dc0MbEJ8iTAniu2BvDRHDAZHMXmQyjjI1WBQvNDPIaM=; b=CAXNjpQv2bZmyF0RJCFsklhusGctri+kzmZQR9SMM+twx6lFSOH4iKi2 MopkY+6HN/t+elzkuQm3oXSFVhqD5VZ8VXQWp1SnR+HmScpKPrKkmEYoq VfQaaQ5hL6jGOPRqpaKuX99UxQTN0RnqUFa2v8qd8N54S5FGGfIiISR37 KWI/e80m2PvKwu5owGZBzqECDia6uhAGAYqV6YpH1FjYX99Jp3Dsb84l4 bxp2UM1MQxg3nKyE0uESvommnsVRRW+JoWd+wiBZGaQzZn7DIFXO513jt gr8cYIPpeOa1Aw3/QhIqYIjGUwGE5HQVxyGPd2pdKWbVR/75Ht6D4rCQt g==; X-IronPort-AV: E=McAfee;i="6600,9927,10859"; a="387436954" X-IronPort-AV: E=Sophos;i="6.03,214,1694761200"; d="scan'208";a="387436954" Received: from fmsmga004.fm.intel.com ([10.253.24.48]) by orsmga102.jf.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 10 Oct 2023 23:51:40 -0700 X-ExtLoop1: 1 X-IronPort-AV: E=McAfee;i="6600,9927,10859"; a="824050233" X-IronPort-AV: E=Sophos;i="6.03,214,1694761200"; d="scan'208";a="824050233" Received: from sqa-gate.sh.intel.com (HELO spr-2s5.tsp.org) ([10.239.48.212]) by fmsmga004.fm.intel.com with ESMTP; 10 Oct 2023 23:51:39 -0700 From: Tina Zhang To: Jason Gunthorpe , Kevin Tian , Lu Baolu Cc: iommu@lists.linux.dev, linux-kernel@vger.kernel.org, Tina Zhang , Jason Gunthorpe Subject: [v6 PATCH 1/5] iommu/vt-d: Remove mm->pasid in intel_sva_bind_mm() Date: Wed, 11 Oct 2023 14:51:28 +0800 Message-Id: <20231011065132.102676-2-tina.zhang@intel.com> X-Mailer: git-send-email 2.39.3 In-Reply-To: <20231011065132.102676-1-tina.zhang@intel.com> References: <20231011065132.102676-1-tina.zhang@intel.com> MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Spam-Status: No, score=2.7 required=5.0 tests=DKIMWL_WL_HIGH,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,HEADER_FROM_DIFFERENT_DOMAINS, MAILING_LIST_MULTI,RCVD_IN_SBL_CSS,SPF_HELO_NONE,SPF_PASS autolearn=no autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on morse.vger.email 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 (morse.vger.email [0.0.0.0]); Tue, 10 Oct 2023 23:52:10 -0700 (PDT) X-Spam-Level: ** 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) -- 2.39.3