From patchwork Tue Sep 12 12:59:32 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: "Zhang, Tina" X-Patchwork-Id: 138189 Return-Path: Delivered-To: ouuuleilei@gmail.com Received: by 2002:a59:9ecd:0:b0:3f2:4152:657d with SMTP id t13csp414660vqx; Tue, 12 Sep 2023 06:40:31 -0700 (PDT) X-Google-Smtp-Source: AGHT+IE0lv7POWi7i/6bu7iZfqq7Ex2sEc7WKdaTWMgeRFebYPm0c990ZZuPSwJuMTKkYejELgs5 X-Received: by 2002:a17:902:a5c7:b0:1c0:6dcd:453d with SMTP id t7-20020a170902a5c700b001c06dcd453dmr11290553plq.20.1694526031568; Tue, 12 Sep 2023 06:40:31 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1694526031; cv=none; d=google.com; s=arc-20160816; b=emgy01NIVgt/KFFlXHs4YQNuJcuoJ7mFdyf/GhOlnSif1lCAwQK0DqWjNerYczkSib oNW0AYTw2bIEx450/Aq/i7BVtb/v4+9G2oA7p4i5IeiDixh7YNJtoGG+oMhpdId8V5/x XRn3Qh1vNaZKQEyqK16wk+uL2H+QCdopfZ9j2ZC0VZ4VUkUDuv89EB8qe+EalIGfdPxn 1YqpxJT1o8i/XXbuIjrTJ11TcafbFaHcHL/QC8UjwOsOmPrTYiISjg6EzAExMW5TMpfU rE/sEWjzFo5yCMV5bVQvgDpoXVIdOVdAncDFiydQmU3NRkmRAhVBkNC3YfZbnVJ191DS W+EQ== 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=4gjICGx4WCASMpHl4lNwISwav25pnY+x58hru6m066c=; fh=zW1GPeUL3MQGLvvmLmBmaazP2MzqJ1fOEi8He5Dzy3k=; b=trRiGmGJGPJTVsGqGTQgvHLnFsCSP5oj+rRonXbwSUqeyRzzhTAVuAoz+3eUiI1LlD J08Fv7WH45tP7uol2XfhpptrGHJPQki/mi5K1ZLWzsYyKfNBrkpN55PxXp/l9tkiGYs1 LaGR7aLc5pCzUYqdnnwpWpUXkG+AWpg7rfzYHN6qHcBIAvJL1ODItKaRZo5VrL1+zn9m jz3PEL5ImunDwgpQyQn66oTV9+9AAsoPRparqEnQYlxOdPngje3J2+nflDys75KIT0Bf ZgiT5pHbY4epE0BOPaQvT3+fgFvLgp9BspBCd9J9JwiPOUKTVm3+dzO+1hVF1J/qGZdV QjaA== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@intel.com header.s=Intel header.b="ctsn/YQl"; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::3:5 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 groat.vger.email (groat.vger.email. [2620:137:e000::3:5]) by mx.google.com with ESMTPS id y4-20020a17090322c400b001bb42c27496si8418460plg.233.2023.09.12.06.40.31 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 12 Sep 2023 06:40:31 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::3:5 as permitted sender) client-ip=2620:137:e000::3:5; Authentication-Results: mx.google.com; dkim=pass header.i=@intel.com header.s=Intel header.b="ctsn/YQl"; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::3:5 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 groat.vger.email (Postfix) with ESMTP id 9914E826ECBE; Tue, 12 Sep 2023 06:00:15 -0700 (PDT) X-Virus-Status: Clean X-Virus-Scanned: clamav-milter 0.103.8 at groat.vger.email Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S235378AbjILNAF (ORCPT + 37 others); Tue, 12 Sep 2023 09:00:05 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:53548 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S235295AbjILM74 (ORCPT ); Tue, 12 Sep 2023 08:59:56 -0400 Received: from mgamail.intel.com (mgamail.intel.com [192.55.52.115]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 2254510CA for ; Tue, 12 Sep 2023 05:59:53 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=intel.com; i=@intel.com; q=dns/txt; s=Intel; t=1694523593; x=1726059593; h=from:to:cc:subject:date:message-id:in-reply-to: references:mime-version:content-transfer-encoding; bh=KfYy3F3Rl5zG+xoLgJl8yhPbh8RLafKcWQHwtyfaBaA=; b=ctsn/YQlCzuijcKACTjr1fTFFtXC8ktxPlPvxhhyF+YGufmMogWAWiIs F7y+xrlqSmpVs25DThcithpXcl1/kN9vB+DFbdTGK2iqJspbx56fFyYBd gAgscOmnsw6ExakZm6IAhgqx64UKTta00ilkqEtQkOi3h3fikdX4tFC30 1T5Xw+mEhvM0Gp0IEUkHSe1+8J6MvnwQ3fiWo/5yHWyz1LFPyfU1ucCQy QDrecmjuL6miNLhRItLjyOQx3MSdGVLMBze9Gu2RtiShT9l0yoU3nBi9h xf33fS7gIbCCNF0oLlE5Y7PUYdafVGtBeT2rQrpDER+jHK1beOE/KtNrO g==; X-IronPort-AV: E=McAfee;i="6600,9927,10831"; a="378277313" X-IronPort-AV: E=Sophos;i="6.02,139,1688454000"; d="scan'208";a="378277313" Received: from fmsmga002.fm.intel.com ([10.253.24.26]) by fmsmga103.fm.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 12 Sep 2023 05:59:52 -0700 X-ExtLoop1: 1 X-IronPort-AV: E=McAfee;i="6600,9927,10831"; a="858799297" X-IronPort-AV: E=Sophos;i="6.02,139,1688454000"; d="scan'208";a="858799297" Received: from tongshi-mobl.ccr.corp.intel.com (HELO tinazhan-desk1.intel.com) ([10.255.28.214]) by fmsmga002-auth.fm.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 12 Sep 2023 05:59:50 -0700 From: Tina Zhang To: Jason Gunthorpe , Kevin Tian , Lu Baolu Cc: Michael Shavit , Vasant Hegde , iommu@lists.linux.dev, linux-kernel@vger.kernel.org, Tina Zhang Subject: [PATCH v4 2/6] iommu/vt-d: Remove mm->pasid in intel_sva_bind_mm() Date: Tue, 12 Sep 2023 20:59:32 +0800 Message-Id: <20230912125936.722348-3-tina.zhang@intel.com> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20230912125936.722348-1-tina.zhang@intel.com> References: <20230912125936.722348-1-tina.zhang@intel.com> MIME-Version: 1.0 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 (groat.vger.email [0.0.0.0]); Tue, 12 Sep 2023 06:00:15 -0700 (PDT) X-Spam-Status: No, score=-0.9 required=5.0 tests=DKIMWL_WL_HIGH,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,HEADER_FROM_DIFFERENT_DOMAINS, MAILING_LIST_MULTI,SPF_HELO_NONE,SPF_PASS autolearn=unavailable autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on groat.vger.email X-getmail-retrieved-from-mailbox: INBOX X-GMAIL-THRID: 1776839328130475424 X-GMAIL-MSGID: 1776839328130475424 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 Signed-off-by: Tina Zhang Reviewed-by: Lu Baolu Reviewed-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, 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)