From patchwork Thu Oct 12 03:01:08 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: "Zhang, Tina" X-Patchwork-Id: 151673 Return-Path: Delivered-To: ouuuleilei@gmail.com Received: by 2002:a05:612c:2908:b0:403:3b70:6f57 with SMTP id ib8csp949145vqb; Wed, 11 Oct 2023 20:01:56 -0700 (PDT) X-Google-Smtp-Source: AGHT+IEd6z8WsTOJWZhwWb/Kwdi2zXQih/uNqvlxSVudVrzVdKJW6pB9vU/BdZePTAYV2U25LV3S X-Received: by 2002:a05:6808:6408:b0:3af:6453:2d83 with SMTP id fg8-20020a056808640800b003af64532d83mr21488479oib.2.1697079716185; Wed, 11 Oct 2023 20:01:56 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1697079716; cv=none; d=google.com; s=arc-20160816; b=VEB79vkszpEbmKlzm+DmAY+765gGvzq+y3yWqhVLPBzw4P5UPkzdh7wdl10N5IImvB zgB9t3GhRHTAqoaDS66Lh/Ve+jRg5qV7fzuwKH50CzA+cbL97BvTKCpJ6RhbmDQFXGhZ UswMqhBTzY/1RVeDuaKekIAdRR+bsY8Tul4VH1+GdFIoU7Pb54W/yomQSlS5sFzY/9vs jyglZD3gRSHQZQZENqvXFDofXS/rZyQhzBE6Ux0zGW6aVQsudFA4qwKGzGjcn6ZXNPk8 E7ZJxHJkPjDwl9ryLqK6950eth1Tr3RL2AwjUF0dNdtFyOcfxDTi4Q9UeyukCfGD02Em A3Ag== 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=tFmNgJLrbbprZYS9qbPoRomUA/KrST8LSFRT//HpShk=; b=DNuhAh7Mf6U5YRi4xrzKcKYQwcIjB5Sbh4Q0MwIIjCHDBVnr86X4Xo3NOgB0XfUPWb UsuPr52/XaBXYRwtUeWXoAInkUrimA9GYfgECUiCc8bKdv1hi7XDJmTQPS22A+p7/nXN CYZCAi+iyyPAlsiNRDe3ZtZW5+orXJgO98DsOk69E64BPqeu4ffrxOhXkBhIMJekBiql MyWwUpn0jjNClzBVUq3L0xtPF+Roe0rlh14Lrdqv3ozXD/E4481j4QIiY+arlB1hObqn ZNG1Te2ge2kUdbmq0F8oC2whoEvQBiNafWA5dBPoV8bz307fIsUpkgmUr1pfVdjBlgbt hP2g== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@intel.com header.s=Intel header.b=P4MHNHNV; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.32 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 agentk.vger.email (agentk.vger.email. [23.128.96.32]) by mx.google.com with ESMTPS id n25-20020a635c59000000b00563fac86c55si1180814pgm.134.2023.10.11.20.01.55 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 11 Oct 2023 20:01:56 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.32 as permitted sender) client-ip=23.128.96.32; Authentication-Results: mx.google.com; dkim=pass header.i=@intel.com header.s=Intel header.b=P4MHNHNV; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.32 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 agentk.vger.email (Postfix) with ESMTP id 25CA5801CFFA; Wed, 11 Oct 2023 20:01:53 -0700 (PDT) X-Virus-Status: Clean X-Virus-Scanned: clamav-milter 0.103.10 at agentk.vger.email Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1376775AbjJLDBf (ORCPT + 18 others); Wed, 11 Oct 2023 23:01:35 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:50774 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S234052AbjJLDBc (ORCPT ); Wed, 11 Oct 2023 23:01:32 -0400 Received: from mgamail.intel.com (mgamail.intel.com [192.198.163.7]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 6B52C94 for ; Wed, 11 Oct 2023 20:01:29 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=intel.com; i=@intel.com; q=dns/txt; s=Intel; t=1697079689; x=1728615689; h=from:to:cc:subject:date:message-id:in-reply-to: references:mime-version:content-transfer-encoding; bh=Dc0MbEJ8iTAniu2BvDRHDAZHMXmQyjjI1WBQvNDPIaM=; b=P4MHNHNVBakXTPgiL+u3sSqgtnvzJs40v5V4ztSC7fTMNZKZ2icSQ4by 2pYvOaNXPBO0uf66Mi20UxHxBiDFE0cDrJwA+yNBO0wW4t/3jqkwxAzxH pePLejeiMi3Eb4zMyEz1fGjZAZaHmjy3gAeCcDzn6iUSJw0pGPoqm99iD xTHxTUJagliL+6bMNSp46Tjrf28jjAfkbeckL+3cQlMvzSAxSZXIrzrMz /OvfpyfPKDBycTAgiyUEMEd42nrm45kpmcx4+7TVM2MV65XilqbiBKNFz d/9rx1+O2TlhYheDh3KSqJufitglUrRm8CKeX5jFiB0tu7E+Ctd7SDlpT A==; X-IronPort-AV: E=McAfee;i="6600,9927,10860"; a="6371440" X-IronPort-AV: E=Sophos;i="6.03,217,1694761200"; d="scan'208";a="6371440" Received: from orsmga006.jf.intel.com ([10.7.209.51]) by fmvoesa101.fm.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 11 Oct 2023 20:01:25 -0700 X-ExtLoop1: 1 X-IronPort-AV: E=McAfee;i="6600,9927,10860"; a="730736505" X-IronPort-AV: E=Sophos;i="6.03,217,1694761200"; d="scan'208";a="730736505" Received: from sqa-gate.sh.intel.com (HELO spr-2s5.tsp.org) ([10.239.48.212]) by orsmga006.jf.intel.com with ESMTP; 11 Oct 2023 20:01:22 -0700 From: Tina Zhang To: Jason Gunthorpe , Kevin Tian , Lu Baolu Cc: Michael Shavit , Vasant Hegde , "Nicolin Chen ^C-cc=iommu @ lists . linux . dev" , linux-kernel@vger.kernel.org, Tina Zhang , Jason Gunthorpe Subject: [PATCH v7 1/5] iommu/vt-d: Remove mm->pasid in intel_sva_bind_mm() Date: Thu, 12 Oct 2023 11:01:08 +0800 Message-Id: <20231012030112.82270-2-tina.zhang@intel.com> X-Mailer: git-send-email 2.39.3 In-Reply-To: <20231012030112.82270-1-tina.zhang@intel.com> References: <20231012030112.82270-1-tina.zhang@intel.com> MIME-Version: 1.0 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 agentk.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 (agentk.vger.email [0.0.0.0]); Wed, 11 Oct 2023 20:01:53 -0700 (PDT) X-getmail-retrieved-from-mailbox: INBOX X-GMAIL-THRID: 1779517060495357726 X-GMAIL-MSGID: 1779517060495357726 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)