From patchwork Mon Sep 25 02:38: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: 144363 Return-Path: Delivered-To: ouuuleilei@gmail.com Received: by 2002:a59:cae8:0:b0:403:3b70:6f57 with SMTP id r8csp1110583vqu; Mon, 25 Sep 2023 03:33:43 -0700 (PDT) X-Google-Smtp-Source: AGHT+IGXYquK3bIKFXN9YOKmwfFCAlSoxnsEMon7vTaI7l34bS8vbzQMDLL5X4eV3R8Jaeb5V7JC X-Received: by 2002:a05:6a20:3d83:b0:15e:10e:12f3 with SMTP id s3-20020a056a203d8300b0015e010e12f3mr5054061pzi.0.1695638023006; Mon, 25 Sep 2023 03:33:43 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1695638022; cv=none; d=google.com; s=arc-20160816; b=Y0RJ4VGslibW0AC4X9IsVJYet7GAMM5t7VQG18ImpBqE6ZLDNHoHi2ctgSi+TekoI8 Sq2jIrLOZ8ujQzGezexxLgvhPzuq9+rA8z8NgNzcI3h6atGeGxZXb88K5R7L0JoxQWwc TbgwMUw3V2hmUSkX7WVmXBo6S4WBXUitWsl9nzkdF4ZTaCTCy7M0Deu8H8dgZYHg+4c1 ywxEXTF/MPmQAdBgqlVW3KhRRsSP+NX4ogtUpY7kSL0vQasq5xMS7Iw+otikMbIB1hRy r04PpncUxMFVyzaWQKPPHTtpGQ8nUvggR53nVigV/iXDG81HDccqxo1BXL4KLsl+ZAih C59w== 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=Z7oABG8GRlnRbT04XmpmpwJ56Ah3p3m4LsPwvahxorg=; fh=mnRGXPt9LZUFMl77l/iwSDlgiJFn5IIjkTf+zunlhqQ=; b=iaXGagpswYtYIpHtWX5GEl3Y4YeZ2Lp2erYy2orfZPtYSNFWDNAqvMALwZ6OegXaSI pejWvVEP3DafooUPda0AAlvk9xfv51+WrZggoeC7ogdCh44Rp6AKcjl5zFUoKQHQZzlv 7YuKHf+61rotm47CE63hgofbC1aZrkMJnCKN2wlKge8s28Bt4umOg4h35wQx4lsCEeA4 DPOoqzKG9pmw5pW0oUSWDmaSxij8yZLpGCBfHGvBj8J6Mv9+aM1IJZGAO2966paZqMDL ZAb3DQGNignmLoanh8ps34OGRUCiPr26Pjfh0YPsdyqcMxl7PzwM0glHsLs2w+DvyNyE eb0g== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@intel.com header.s=Intel header.b=EeYRuQgi; 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 f4-20020a170902684400b001befd0512ecsi9104851pln.314.2023.09.25.03.33.42 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 25 Sep 2023 03:33:42 -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=EeYRuQgi; 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 AD38F8028856; Sun, 24 Sep 2023 19:38:45 -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 S231805AbjIYCiq (ORCPT + 30 others); Sun, 24 Sep 2023 22:38:46 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:38130 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S231867AbjIYCik (ORCPT ); Sun, 24 Sep 2023 22:38:40 -0400 Received: from mgamail.intel.com (mgamail.intel.com [192.55.52.136]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 0E047180 for ; Sun, 24 Sep 2023 19:38:31 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=intel.com; i=@intel.com; q=dns/txt; s=Intel; t=1695609511; x=1727145511; h=from:to:cc:subject:date:message-id:in-reply-to: references:mime-version:content-transfer-encoding; bh=7zU7HAWdG3b1dGAPlY5mo7/wqSzMqXmxMMR0zvlmHZU=; b=EeYRuQgiEEGH6NJZA1M+skAi0Fx0U+JXzgD80rcOkl388bC52LPuU8XC w61k1PJnCF/elGD/qgI1AzwR4Um2s+mi36c7nx9OmF7FJuo5W52UfrdiD blOg56C4fbMuGmgrn1++fgKgOYOeW5zGg6vsfQdkofYQcUeWFL1/mivMs i0nG1QdWLptkLNe3bKs38RQTCCOu501eIzQVUqFCF9XOSaeSCln63Pti+ bOxXNlAjNyKbr0Kby3LLgO+IUTn4+ItoZPe/wOKLQqAkXhe7dVLLzw3bK O0Kh/fA2wgc16OD4eKWjqmB4edDTL3UtYJk3kXgfL77UAj/+KkMFb4wX6 A==; X-IronPort-AV: E=McAfee;i="6600,9927,10843"; a="360534577" X-IronPort-AV: E=Sophos;i="6.03,174,1694761200"; d="scan'208";a="360534577" Received: from orsmga008.jf.intel.com ([10.7.209.65]) by fmsmga106.fm.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 24 Sep 2023 19:38:30 -0700 X-ExtLoop1: 1 X-IronPort-AV: E=McAfee;i="6600,9927,10843"; a="777505062" X-IronPort-AV: E=Sophos;i="6.03,174,1694761200"; d="scan'208";a="777505062" Received: from jingxues-mobl1.ccr.corp.intel.com (HELO tinazhan-desk1.intel.com) ([10.254.214.78]) by orsmga008-auth.jf.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 24 Sep 2023 19:38:27 -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 , Jason Gunthorpe Subject: [PATCH v5 1/6] iommu/vt-d: Remove mm->pasid in intel_sva_bind_mm() Date: Mon, 25 Sep 2023 10:38:08 +0800 Message-Id: <20230925023813.575016-2-tina.zhang@intel.com> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20230925023813.575016-1-tina.zhang@intel.com> References: <20230925023813.575016-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, 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]); Sun, 24 Sep 2023 19:38:45 -0700 (PDT) X-getmail-retrieved-from-mailbox: INBOX X-GMAIL-THRID: 1778005335368166627 X-GMAIL-MSGID: 1778005335368166627 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) From patchwork Mon Sep 25 02:38:09 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: "Zhang, Tina" X-Patchwork-Id: 144189 Return-Path: Delivered-To: ouuuleilei@gmail.com Received: by 2002:a59:cae8:0:b0:403:3b70:6f57 with SMTP id r8csp963002vqu; Sun, 24 Sep 2023 20:55:16 -0700 (PDT) X-Google-Smtp-Source: AGHT+IGXtlN3Agw4jFq+jqARrfcvULvKzmNI2D2iBctHsJQt8052pUjdk3g4eoPVQIsQ+/aqehaK X-Received: by 2002:a05:6358:41a3:b0:143:9f18:d71a with SMTP id w35-20020a05635841a300b001439f18d71amr6305196rwc.14.1695614116468; Sun, 24 Sep 2023 20:55:16 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1695614116; cv=none; d=google.com; s=arc-20160816; b=Ag2fuJ/RSD0vlWOrp2yycyjqjHz7swiWUBbNuxJ0wxg97l2z0hqTXi99TqKnwNvCaq x3j1NBCDRDA3BMoLrYTIPD7eejSuqDQzg0zq//rND3e7VXLgiaBuQc/3jkXd2GcaL2id Z/sfVd+WHce+Utb30204PHSPfC+5I5vJuQGPXLbsCpBttCFpZlIJtGqoN4lrb6WAsKTQ wfvmc+ysNkMAf0u2jDG5iKcfh1QhP3tAsjd4Zy+HxyJKprRP7pasj3EoAR415X5Js95Y PixDk6XKk5Q8ChXAthU3RxfCqS+TRtdQ1mTdmbpgaVOnuca8RuwPig9AUeqpyWC+pxT9 I9XQ== 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=jn50gwLRxwc9r2t55Ovfm7sR8dZQ0ZsVgWn2bZS9BjA=; fh=zW1GPeUL3MQGLvvmLmBmaazP2MzqJ1fOEi8He5Dzy3k=; b=wcM+Rnch8FEIk15/xQ81XINjKX6FFv0o4bjrl/BKt2qN8z/8Y5hV+RX84/GIMYhXUn aJlwbH3B4iJJ6MrU8n6bj4mBW4yfLZfDuohbLs1uhgBI/9mDZ0rmf+n9XVkYQgWMclsw JohOn8Hv3rt9KFVmPJAoyXZPYivBOTj71Ktz1hXea0jUtL6cU3GCbVWXgei3Qsvf+liz fPpFLy4ABSkGJqHjkGPlp7QbgnsUnDlyHyrJeQun9xU3QMuPnOo6Y6TLSCOKNvHSXjfd Q/VJXacngWJAQGlz1zO6E1D9A8GssoHZKjvdKjS+GDK/AjI3MRzaH1xi6Ji7JWNUmi7w FtBg== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@intel.com header.s=Intel header.b=IdDxm0dX; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::3:6 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 pete.vger.email (pete.vger.email. [2620:137:e000::3:6]) by mx.google.com with ESMTPS id m1-20020a656a01000000b0056a670ebd73si10249106pgu.498.2023.09.24.20.55.16 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Sun, 24 Sep 2023 20:55:16 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::3:6 as permitted sender) client-ip=2620:137:e000::3:6; Authentication-Results: mx.google.com; dkim=pass header.i=@intel.com header.s=Intel header.b=IdDxm0dX; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::3:6 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 pete.vger.email (Postfix) with ESMTP id 9641B80E6FF8; Sun, 24 Sep 2023 19:39:20 -0700 (PDT) X-Virus-Status: Clean X-Virus-Scanned: clamav-milter 0.103.10 at pete.vger.email Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S231909AbjIYCi7 (ORCPT + 30 others); Sun, 24 Sep 2023 22:38:59 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:38102 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S231854AbjIYCil (ORCPT ); Sun, 24 Sep 2023 22:38:41 -0400 Received: from mgamail.intel.com (mgamail.intel.com [192.55.52.136]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 1FF4FFB for ; Sun, 24 Sep 2023 19:38:34 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=intel.com; i=@intel.com; q=dns/txt; s=Intel; t=1695609514; x=1727145514; h=from:to:cc:subject:date:message-id:in-reply-to: references:mime-version:content-transfer-encoding; bh=Dlf1dxlHWIpaa3k6WU6MZd1gS+MEcmDGRb+EBcE9Ias=; b=IdDxm0dXTplbiwuM89glbs+rvyvOZ1gntYl4xW0eYr3oZWiUWboomM4s uXCYctdLsKeVt7B4t7KUlxWmzwrqu4801qu2bh0a+eqrGkRdQd+HjgEri EnioOUeeJIiJY4j4bRS+LR8MArvWPxe+gmCCVQ6EQN5hlMjQj2RN+vGfV dTjL8sAVMnKJ2akwTvFdC4avJOyRz/wYyhM7CrqfZZfLwXblfVwmEnRMG 2PspV1mvoKsMMNjSi+9g669TjAT4rRrGUMjlHK41ZOkgpngOwJc2w9YPo 13HrzcNUacY8tv+9L2FEfFEbsuQmtHbZMPhqDdmU9SzbUqNyZOv3IZ0z6 g==; X-IronPort-AV: E=McAfee;i="6600,9927,10843"; a="360534591" X-IronPort-AV: E=Sophos;i="6.03,174,1694761200"; d="scan'208";a="360534591" Received: from orsmga008.jf.intel.com ([10.7.209.65]) by fmsmga106.fm.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 24 Sep 2023 19:38:33 -0700 X-ExtLoop1: 1 X-IronPort-AV: E=McAfee;i="6600,9927,10843"; a="777505069" X-IronPort-AV: E=Sophos;i="6.03,174,1694761200"; d="scan'208";a="777505069" Received: from jingxues-mobl1.ccr.corp.intel.com (HELO tinazhan-desk1.intel.com) ([10.254.214.78]) by orsmga008-auth.jf.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 24 Sep 2023 19:38:31 -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 v5 2/6] iommu: Add mm_get_enqcmd_pasid() helper function Date: Mon, 25 Sep 2023 10:38:09 +0800 Message-Id: <20230925023813.575016-3-tina.zhang@intel.com> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20230925023813.575016-1-tina.zhang@intel.com> References: <20230925023813.575016-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 pete.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 (pete.vger.email [0.0.0.0]); Sun, 24 Sep 2023 19:39:20 -0700 (PDT) X-getmail-retrieved-from-mailbox: INBOX X-GMAIL-THRID: 1777980268092910481 X-GMAIL-MSGID: 1777980268092910481 mm_get_enqcmd_pasid() is for getting enqcmd pasid value. The motivation is to replace mm->pasid with an iommu private data structure that is introduced in a later patch. Reviewed-by: Lu Baolu Signed-off-by: Tina Zhang Reviewed-by: Jason Gunthorpe --- Change in v2: - Change mm_get_pasid() to mm_get_enqcmd_pasid() arch/x86/kernel/traps.c | 2 +- include/linux/iommu.h | 8 ++++++++ 2 files changed, 9 insertions(+), 1 deletion(-) diff --git a/arch/x86/kernel/traps.c b/arch/x86/kernel/traps.c index c876f1d36a81..832f4413d96a 100644 --- a/arch/x86/kernel/traps.c +++ b/arch/x86/kernel/traps.c @@ -591,7 +591,7 @@ static bool try_fixup_enqcmd_gp(void) if (!mm_valid_pasid(current->mm)) return false; - pasid = current->mm->pasid; + pasid = mm_get_enqcmd_pasid(current->mm); /* * Did this thread already have its PASID activated? diff --git a/include/linux/iommu.h b/include/linux/iommu.h index c50a769d569a..a4eab6697fe1 100644 --- a/include/linux/iommu.h +++ b/include/linux/iommu.h @@ -1189,6 +1189,10 @@ static inline bool mm_valid_pasid(struct mm_struct *mm) { return mm->pasid != IOMMU_PASID_INVALID; } +static inline u32 mm_get_enqcmd_pasid(struct mm_struct *mm) +{ + return mm->pasid; +} void mm_pasid_drop(struct mm_struct *mm); struct iommu_sva *iommu_sva_bind_device(struct device *dev, struct mm_struct *mm); @@ -1211,6 +1215,10 @@ static inline u32 iommu_sva_get_pasid(struct iommu_sva *handle) } static inline void mm_pasid_init(struct mm_struct *mm) {} static inline bool mm_valid_pasid(struct mm_struct *mm) { return false; } +static inline u32 mm_get_enqcmd_pasid(struct mm_struct *mm) +{ + return IOMMU_PASID_INVALID; +} static inline void mm_pasid_drop(struct mm_struct *mm) {} #endif /* CONFIG_IOMMU_SVA */ From patchwork Mon Sep 25 02:38:10 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: "Zhang, Tina" X-Patchwork-Id: 144211 Return-Path: Delivered-To: ouuuleilei@gmail.com Received: by 2002:a59:cae8:0:b0:403:3b70:6f57 with SMTP id r8csp996820vqu; Sun, 24 Sep 2023 22:45:50 -0700 (PDT) X-Google-Smtp-Source: AGHT+IE1TAchNw2s/BxKE4sAmDHM9aBUm/S/DsJ8wcImowvzD8NOb6izlYbZ/BO9QQaPOMK+/uke X-Received: by 2002:a05:6a20:1587:b0:15d:1646:285a with SMTP id h7-20020a056a20158700b0015d1646285amr8946924pzj.21.1695620750575; Sun, 24 Sep 2023 22:45:50 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1695620750; cv=none; d=google.com; s=arc-20160816; b=UHUropJ+Etjkw830zrnnPABmsp8bUIYMnNvonclW0f0gIlywl3mL7ooDR/A9/sukeZ mK9QeCXAKU5xz6QuF3myZbTLY+tgHtznuudRK2kTGdiwxqOApeLaNS/Tk8x3CxykleSG Kl9frPj3FQUrcM7jVT8D3vhW+PUdIFYJ9G/31WkQDJgw9PATTbMMxpyVQmOrjKToewmD A0FSlAbh6IVOVu4iceELV8GrkYq+bBbpAUt7bScRo8Wd0wez3NrVMg6Yoed91FdnZXWD 4f5j0NBJA9tzqvDEoZp5QVqhgbBfHrOpm1arwS+06nYT74/7MeNFBVAT8V0N1ocPJqJA u0PA== 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=ZbA8WhXdEcBIqwg60as+U63xDyMnBVEcUXFTPPZ6xJQ=; fh=zW1GPeUL3MQGLvvmLmBmaazP2MzqJ1fOEi8He5Dzy3k=; b=Byf4TLvTdQxSTSNz9iYtBfUdGAIm+l8CwJNnJMM/sk1bvhDzfjWxfbr/Rw5fbQARgK gLeBURiXwsbh/kHdT/WE/OEKecIrTpwPQwaMGN/x+2nuD5njg3XdSWkBgifi22w/Sfim 67FNxhg7ChyIY5k9SOBbkkmFew5FMTilPpOwyqqWJPLbNEwbD5Ee0Ryz42xgXlm1QMOo ghdgVUowxVIPtWdv/BadUVmsZxoxN/mTxZrfZKcORPKV3D274u+9lldHhsYK/X/IQu73 P3LH0Joq7AYf8I2a9wvwrudGVOh0REaVaUujStexuWMNwGy8D8k9FjraIrYkBaDtI8dA D2aQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@intel.com header.s=Intel header.b=DIVEzy9P; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::3:6 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 pete.vger.email (pete.vger.email. [2620:137:e000::3:6]) by mx.google.com with ESMTPS id l3-20020a056a00140300b00690d624f294si9566237pfu.322.2023.09.24.22.45.50 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Sun, 24 Sep 2023 22:45:50 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::3:6 as permitted sender) client-ip=2620:137:e000::3:6; Authentication-Results: mx.google.com; dkim=pass header.i=@intel.com header.s=Intel header.b=DIVEzy9P; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::3:6 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 pete.vger.email (Postfix) with ESMTP id 7ECE08118762; Sun, 24 Sep 2023 19:40:09 -0700 (PDT) X-Virus-Status: Clean X-Virus-Scanned: clamav-milter 0.103.10 at pete.vger.email Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S231969AbjIYCjN (ORCPT + 30 others); Sun, 24 Sep 2023 22:39:13 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:38094 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S231951AbjIYCix (ORCPT ); Sun, 24 Sep 2023 22:38:53 -0400 Received: from mgamail.intel.com (mgamail.intel.com [192.55.52.136]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 877CF1A8 for ; Sun, 24 Sep 2023 19:38:37 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=intel.com; i=@intel.com; q=dns/txt; s=Intel; t=1695609517; x=1727145517; h=from:to:cc:subject:date:message-id:in-reply-to: references:mime-version:content-transfer-encoding; bh=1ldnmU9PmpyGsgjUWNtqkNdEBfhFq4iO9fqdPCxVO+A=; b=DIVEzy9PK0/jGRfXqlbUIJxwiSBzfpWgczOu1XwX+VDm5sNgdnekouR9 CZ89FCtL+h5NU4EznKvQsHZouuhfZwN3mzlzrCspSQxUs0vPw6FvbRn5s w6Zjafia4XzX1Vhf71k8Ufl6FM6kXQZ1vpN0CglR0GtK5AOCNnpgXiGga P1/B85xm5a5IRPQkArv/8AO2zVBjx9HiKds+4fkOp09jm1IwUbLaH7FYW N+nW4huDXcQJSKcA7J+E0PvNQqzYY0Cw1MyDjuG2sC/vd2OdpaTRwUpEV 0C/3akOprC70QkV9fV3tHj7W7/aYs0XT+badDHOLLGIt1ObcMpQXLc0Jp w==; X-IronPort-AV: E=McAfee;i="6600,9927,10843"; a="360534601" X-IronPort-AV: E=Sophos;i="6.03,174,1694761200"; d="scan'208";a="360534601" Received: from orsmga008.jf.intel.com ([10.7.209.65]) by fmsmga106.fm.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 24 Sep 2023 19:38:37 -0700 X-ExtLoop1: 1 X-IronPort-AV: E=McAfee;i="6600,9927,10843"; a="777505075" X-IronPort-AV: E=Sophos;i="6.03,174,1694761200"; d="scan'208";a="777505075" Received: from jingxues-mobl1.ccr.corp.intel.com (HELO tinazhan-desk1.intel.com) ([10.254.214.78]) by orsmga008-auth.jf.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 24 Sep 2023 19:38:34 -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 v5 3/6] iommu: Introduce mm_get_pasid() helper function Date: Mon, 25 Sep 2023 10:38:10 +0800 Message-Id: <20230925023813.575016-4-tina.zhang@intel.com> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20230925023813.575016-1-tina.zhang@intel.com> References: <20230925023813.575016-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 pete.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 (pete.vger.email [0.0.0.0]); Sun, 24 Sep 2023 19:40:09 -0700 (PDT) X-getmail-retrieved-from-mailbox: INBOX X-GMAIL-THRID: 1777987224281630457 X-GMAIL-MSGID: 1777987224281630457 Use the helper function mm_get_pasid() to get a mm assigned pasid value. The motivation is to replace mm->pasid with an iommu private data structure that is introduced in a later patch. The mm_get_pasid() is intended for generic usage of mm's pasid. Using mm_get_pasid() for shared virtual addressing (SVA) with enqcmd usage is discouraged. Instead, one should consider using mm_get_enqcmd_pasid(). Reviewed-by: Lu Baolu Signed-off-by: Tina Zhang --- Change in v5: - Update commit message. Change in v4: - Rebase to v6.6-rc1. Changes in v2: - Update commit message. - Let mm_get_enqcmd_pasid() call mm_get_pasid() to get pasid. drivers/iommu/arm/arm-smmu-v3/arm-smmu-v3-sva.c | 12 ++++++------ drivers/iommu/iommu-sva.c | 12 ++++++------ include/linux/iommu.h | 10 +++++++++- 3 files changed, 21 insertions(+), 13 deletions(-) diff --git a/drivers/iommu/arm/arm-smmu-v3/arm-smmu-v3-sva.c b/drivers/iommu/arm/arm-smmu-v3/arm-smmu-v3-sva.c index 4d83edc2be99..dbb3af323ede 100644 --- a/drivers/iommu/arm/arm-smmu-v3/arm-smmu-v3-sva.c +++ b/drivers/iommu/arm/arm-smmu-v3/arm-smmu-v3-sva.c @@ -215,7 +215,7 @@ static void arm_smmu_mm_arch_invalidate_secondary_tlbs(struct mmu_notifier *mn, smmu_domain); } - arm_smmu_atc_inv_domain(smmu_domain, mm->pasid, start, size); + arm_smmu_atc_inv_domain(smmu_domain, mm_get_pasid(mm), start, size); } static void arm_smmu_mm_release(struct mmu_notifier *mn, struct mm_struct *mm) @@ -233,10 +233,10 @@ static void arm_smmu_mm_release(struct mmu_notifier *mn, struct mm_struct *mm) * DMA may still be running. Keep the cd valid to avoid C_BAD_CD events, * but disable translation. */ - arm_smmu_write_ctx_desc(smmu_domain, mm->pasid, &quiet_cd); + arm_smmu_write_ctx_desc(smmu_domain, mm_get_pasid(mm), &quiet_cd); arm_smmu_tlb_inv_asid(smmu_domain->smmu, smmu_mn->cd->asid); - arm_smmu_atc_inv_domain(smmu_domain, mm->pasid, 0, 0); + arm_smmu_atc_inv_domain(smmu_domain, mm_get_pasid(mm), 0, 0); smmu_mn->cleared = true; mutex_unlock(&sva_lock); @@ -290,7 +290,7 @@ arm_smmu_mmu_notifier_get(struct arm_smmu_domain *smmu_domain, goto err_free_cd; } - ret = arm_smmu_write_ctx_desc(smmu_domain, mm->pasid, cd); + ret = arm_smmu_write_ctx_desc(smmu_domain, mm_get_pasid(mm), cd); if (ret) goto err_put_notifier; @@ -315,7 +315,7 @@ static void arm_smmu_mmu_notifier_put(struct arm_smmu_mmu_notifier *smmu_mn) return; list_del(&smmu_mn->list); - arm_smmu_write_ctx_desc(smmu_domain, mm->pasid, NULL); + arm_smmu_write_ctx_desc(smmu_domain, mm_get_pasid(mm), NULL); /* * If we went through clear(), we've already invalidated, and no @@ -323,7 +323,7 @@ static void arm_smmu_mmu_notifier_put(struct arm_smmu_mmu_notifier *smmu_mn) */ if (!smmu_mn->cleared) { arm_smmu_tlb_inv_asid(smmu_domain->smmu, cd->asid); - arm_smmu_atc_inv_domain(smmu_domain, mm->pasid, 0, 0); + arm_smmu_atc_inv_domain(smmu_domain, mm_get_pasid(mm), 0, 0); } /* Frees smmu_mn */ diff --git a/drivers/iommu/iommu-sva.c b/drivers/iommu/iommu-sva.c index b78671a8a914..0f956ecd0c9b 100644 --- a/drivers/iommu/iommu-sva.c +++ b/drivers/iommu/iommu-sva.c @@ -23,7 +23,7 @@ static int iommu_sva_alloc_pasid(struct mm_struct *mm, struct device *dev) mutex_lock(&iommu_sva_lock); /* Is a PASID already associated with this mm? */ if (mm_valid_pasid(mm)) { - if (mm->pasid >= dev->iommu->max_pasids) + if (mm_get_pasid(mm) >= dev->iommu->max_pasids) ret = -EOVERFLOW; goto out; } @@ -73,7 +73,7 @@ struct iommu_sva *iommu_sva_bind_device(struct device *dev, struct mm_struct *mm mutex_lock(&iommu_sva_lock); /* Search for an existing domain. */ - domain = iommu_get_domain_for_dev_pasid(dev, mm->pasid, + domain = iommu_get_domain_for_dev_pasid(dev, mm_get_pasid(mm), IOMMU_DOMAIN_SVA); if (IS_ERR(domain)) { ret = PTR_ERR(domain); @@ -92,7 +92,7 @@ struct iommu_sva *iommu_sva_bind_device(struct device *dev, struct mm_struct *mm goto out_unlock; } - ret = iommu_attach_device_pasid(domain, dev, mm->pasid); + ret = iommu_attach_device_pasid(domain, dev, mm_get_pasid(mm)); if (ret) goto out_free_domain; domain->users = 1; @@ -124,7 +124,7 @@ EXPORT_SYMBOL_GPL(iommu_sva_bind_device); void iommu_sva_unbind_device(struct iommu_sva *handle) { struct iommu_domain *domain = handle->domain; - ioasid_t pasid = domain->mm->pasid; + ioasid_t pasid = mm_get_pasid(domain->mm); struct device *dev = handle->dev; mutex_lock(&iommu_sva_lock); @@ -141,7 +141,7 @@ u32 iommu_sva_get_pasid(struct iommu_sva *handle) { struct iommu_domain *domain = handle->domain; - return domain->mm->pasid; + return mm_get_pasid(domain->mm); } EXPORT_SYMBOL_GPL(iommu_sva_get_pasid); @@ -208,5 +208,5 @@ void mm_pasid_drop(struct mm_struct *mm) if (likely(!mm_valid_pasid(mm))) return; - iommu_free_global_pasid(mm->pasid); + iommu_free_global_pasid(mm_get_pasid(mm)); } diff --git a/include/linux/iommu.h b/include/linux/iommu.h index a4eab6697fe1..db2510da28c1 100644 --- a/include/linux/iommu.h +++ b/include/linux/iommu.h @@ -1189,10 +1189,14 @@ static inline bool mm_valid_pasid(struct mm_struct *mm) { return mm->pasid != IOMMU_PASID_INVALID; } -static inline u32 mm_get_enqcmd_pasid(struct mm_struct *mm) +static inline u32 mm_get_pasid(struct mm_struct *mm) { return mm->pasid; } +static inline u32 mm_get_enqcmd_pasid(struct mm_struct *mm) +{ + return mm_get_pasid(mm); +} void mm_pasid_drop(struct mm_struct *mm); struct iommu_sva *iommu_sva_bind_device(struct device *dev, struct mm_struct *mm); @@ -1215,6 +1219,10 @@ static inline u32 iommu_sva_get_pasid(struct iommu_sva *handle) } static inline void mm_pasid_init(struct mm_struct *mm) {} static inline bool mm_valid_pasid(struct mm_struct *mm) { return false; } +static inline u32 mm_get_pasid(struct mm_struct *mm) +{ + return IOMMU_PASID_INVALID; +} static inline u32 mm_get_enqcmd_pasid(struct mm_struct *mm) { return IOMMU_PASID_INVALID; From patchwork Mon Sep 25 02:38:11 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: "Zhang, Tina" X-Patchwork-Id: 144204 Return-Path: Delivered-To: ouuuleilei@gmail.com Received: by 2002:a59:cae8:0:b0:403:3b70:6f57 with SMTP id r8csp983933vqu; Sun, 24 Sep 2023 22:03:35 -0700 (PDT) X-Google-Smtp-Source: AGHT+IE0tb1Wt5T/8BegTqp9AxYkfy+Abc7VvNJBmEyXhy6oGIv/u9Vzs0kAZWnTZQYpqmlJ1xbi X-Received: by 2002:a05:6a21:99a2:b0:154:edaf:f410 with SMTP id ve34-20020a056a2199a200b00154edaff410mr5161108pzb.58.1695618215091; Sun, 24 Sep 2023 22:03:35 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1695618215; cv=none; d=google.com; s=arc-20160816; b=EnK2x8Qy5HcCymyGJI2uQ+YJKBrrHsf116dQ+ToyKShAC43ECTXeijzu2vCNqoUZgo YagplneXQGbPjnQt+hTZqgrshNppeQmA2NKwwvmRPOB4/YABdr/zPf9SvXcZ9sGQ6YUy 97SWoXJe96f3S5ORxwuGts7HSUYPfMgo8brBu6lBOdIc2x1dUro7NCcuPT2fo21D/lXB rEJrVtfmj/pS6tXkIK3iWrTlJsG+wSTrns5TwYYAtFmezj4svRo7YdkRycbZMCbQy8ms bReLFCAmhJrnZrN1rZwsQdbWuKPS2b/X3KhztpKQSKWKJvsXPfeDNl8WYXYky2R2djtl O9BA== 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=b7kbVyX1303n8eY7Br86BfNpThN3/xEdljOTtUVJ6bg=; fh=zW1GPeUL3MQGLvvmLmBmaazP2MzqJ1fOEi8He5Dzy3k=; b=Zownru8Vz0pLac+zcj9Zc/z9b1s/PVW0SlsYnXSfaCgTDTSQPdcdEHrzBFeVaamOMX Lc3zXI2x5xsAXAtOzG8vwgN2dYXh+gq4kGOUPImGnbXBPmrDK13DizlSGScjqTIS6mCx rn6ByYx3IRnxr89aTPB4mTJcc0DZLXbhccz2E66BfLYqnrGkEfRc2BocZsBr0Uuf0NH3 0Pa4t9ZbMtCBEYj2dl0dh6jBByTAuOc1uw91AYzstcQsmo9vSMMoczpnvOiusodbGw3y fvVZJVLl6H3tbTEE3t7zMXbpGTM554pBjrmzors+wkMUmMvtBY/asm4AmjUWHdlK47Jc 7bpQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@intel.com header.s=Intel header.b=eWEW9zbx; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.35 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. [23.128.96.35]) by mx.google.com with ESMTPS id x4-20020a17090a6c0400b00274b944508fsi11334132pjj.39.2023.09.24.22.03.34 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Sun, 24 Sep 2023 22:03:35 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.35 as permitted sender) client-ip=23.128.96.35; Authentication-Results: mx.google.com; dkim=pass header.i=@intel.com header.s=Intel header.b=eWEW9zbx; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.35 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 9F94C80CFD0D; Sun, 24 Sep 2023 19:39:28 -0700 (PDT) X-Virus-Status: Clean X-Virus-Scanned: clamav-milter 0.103.10 at groat.vger.email Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S231812AbjIYCjQ (ORCPT + 30 others); Sun, 24 Sep 2023 22:39:16 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:38178 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S231911AbjIYCi7 (ORCPT ); Sun, 24 Sep 2023 22:38:59 -0400 Received: from mgamail.intel.com (mgamail.intel.com [192.55.52.136]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id DBCC8CDB for ; Sun, 24 Sep 2023 19:38:40 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=intel.com; i=@intel.com; q=dns/txt; s=Intel; t=1695609520; x=1727145520; h=from:to:cc:subject:date:message-id:in-reply-to: references:mime-version:content-transfer-encoding; bh=rZw7/JQ+5UMBseQ+c8DZ8L7FV4YJqRAF42KGXZ68hoo=; b=eWEW9zbxHPyvRR0GT8kJh8OE0bgFn+nXdztUL3G6NyKDu2iWDOKFezC0 wNfcZTkQlZW9u4rsAn68J1sKCI/EQkIJmr8e6yGYiRyRSzjvxZwDvMa7V 8/33HmdPpMRnMCCIdwxrHX6Ahmk3Psh6AEmeW7TDNX+atAmI6AyosXMXB 3DXK+vH2iR+3G3ip57XmXkjmWruuvQeGXp6LchOCanwvyyL5MLQjsRHZ3 clvDquGzTFlGUnIb72opoYUijMU5m/RNYSrKBU0HgXJPVqN9vVL9i8mye qEE3MjPLWqdtjJ5F5CMGTNIOltYCnodlNlZGCJp1yyOqb+J90JuwBaFdF A==; X-IronPort-AV: E=McAfee;i="6600,9927,10843"; a="360534612" X-IronPort-AV: E=Sophos;i="6.03,174,1694761200"; d="scan'208";a="360534612" Received: from orsmga008.jf.intel.com ([10.7.209.65]) by fmsmga106.fm.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 24 Sep 2023 19:38:40 -0700 X-ExtLoop1: 1 X-IronPort-AV: E=McAfee;i="6600,9927,10843"; a="777505084" X-IronPort-AV: E=Sophos;i="6.03,174,1694761200"; d="scan'208";a="777505084" Received: from jingxues-mobl1.ccr.corp.intel.com (HELO tinazhan-desk1.intel.com) ([10.254.214.78]) by orsmga008-auth.jf.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 24 Sep 2023 19:38:37 -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 v5 4/6] mm: Add structure to keep sva information Date: Mon, 25 Sep 2023 10:38:11 +0800 Message-Id: <20230925023813.575016-5-tina.zhang@intel.com> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20230925023813.575016-1-tina.zhang@intel.com> References: <20230925023813.575016-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 groat.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 (groat.vger.email [0.0.0.0]); Sun, 24 Sep 2023 19:39:28 -0700 (PDT) X-getmail-retrieved-from-mailbox: INBOX X-GMAIL-THRID: 1777984565670770432 X-GMAIL-MSGID: 1777984565670770432 Introduce iommu_mm_data structure to keep sva information (pasid and the related sva domains). Add iommu_mm pointer, pointing to an instance of iommu_mm_data structure, to mm. Reviewed-by: Vasant Hegde Reviewed-by: Lu Baolu Signed-off-by: Tina Zhang Reviewed-by: Jason Gunthorpe --- include/linux/iommu.h | 5 +++++ include/linux/mm_types.h | 2 ++ 2 files changed, 7 insertions(+) diff --git a/include/linux/iommu.h b/include/linux/iommu.h index db2510da28c1..b9c9f14a95cc 100644 --- a/include/linux/iommu.h +++ b/include/linux/iommu.h @@ -670,6 +670,11 @@ struct iommu_sva { struct iommu_domain *domain; }; +struct iommu_mm_data { + u32 pasid; + struct list_head sva_domains; +}; + int iommu_fwspec_init(struct device *dev, struct fwnode_handle *iommu_fwnode, const struct iommu_ops *ops); void iommu_fwspec_free(struct device *dev); diff --git a/include/linux/mm_types.h b/include/linux/mm_types.h index 36c5b43999e6..9f4efed85f74 100644 --- a/include/linux/mm_types.h +++ b/include/linux/mm_types.h @@ -670,6 +670,7 @@ struct mm_cid { #endif struct kioctx_table; +struct iommu_mm_data; struct mm_struct { struct { /* @@ -883,6 +884,7 @@ struct mm_struct { #ifdef CONFIG_IOMMU_SVA u32 pasid; + struct iommu_mm_data *iommu_mm; #endif #ifdef CONFIG_KSM /* From patchwork Mon Sep 25 02:38:12 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: "Zhang, Tina" X-Patchwork-Id: 144308 Return-Path: Delivered-To: ouuuleilei@gmail.com Received: by 2002:a59:cae8:0:b0:403:3b70:6f57 with SMTP id r8csp1067819vqu; Mon, 25 Sep 2023 01:57:10 -0700 (PDT) X-Google-Smtp-Source: AGHT+IFTUb9c43GdVA3pv8NpueYVtQp73ZpN89RqrNPbxX71yJX613tLHIPGAP+tcIp3Kr3Hqfj5 X-Received: by 2002:a05:6102:483:b0:452:6efc:1789 with SMTP id n3-20020a056102048300b004526efc1789mr1976066vsa.32.1695632230034; Mon, 25 Sep 2023 01:57:10 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1695632229; cv=none; d=google.com; s=arc-20160816; b=gxEuXYHeizbOPWZ0FbBUnePIcSLWfGF3Mq7pnwDHIf/CMHtrAdsjN4DylnEgK/rRpj 2ggfc4183QEI2ifzmj/04zpYhZd7135plf2sXkDrZhu3Eii1FchD33/Uzi6mMeck4wZX Q5RubKI1AmMFyhRPg7Ep+hAgL+Zct3uLljnwSMq+zAxZqqh7aZGaEeOlyOn9mxxR+cez aqY96hVrT/vfViGu3CCAv/hMUA+aDpa9FElG3AZ+q0EH6X5VXWXmZYvDzb/IdidKPBcd l5v5gPj5Km1+0rt0i9ichttdE81lBk4uaolOBVvrOvWy3bWx/utm/ejieDhQmMDimDWN 1A6A== 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=SU/vfMGhv/s/7LAVzCVgeMFHT6HHwjCzdAGmXY/e5UQ=; fh=zW1GPeUL3MQGLvvmLmBmaazP2MzqJ1fOEi8He5Dzy3k=; b=Abr0CYgrNbWFXdq8a6DNuhoa+Kg/CvJEsCkenuUF7FKtaimCmnHbTobG7aP2L9GI/m IomvOVo8aK3k1JU9KAqNMsla3/wxVyPbho2yuBfAH/TwY3y24Zr/qPt8OrlOppJmSpn3 gpi1GrKWEYmhw32bDPcgyvpaNPc9DascltBrnhBnBqcGzdK/qqlZKxOzyaSfi4VkMgDy F5RwnG3r+ayK7eE79LCurKwkFsQBLbqL3pxD6/2vXt/v6ZQEjU8j5bDqQ9hTRK17Owt2 Ybw2kdj2VxxT66r/vnWXhh20f7i8Nif5CfcE4VtmG01mg9Z8EUkmtTpC5h0IWjo4Nkt+ WYag== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@intel.com header.s=Intel header.b="CF1/eQbV"; 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 i67-20020a636d46000000b00578fcb85b89si9504000pgc.726.2023.09.25.01.57.09 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 25 Sep 2023 01:57:09 -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="CF1/eQbV"; 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 2306781906AD; Sun, 24 Sep 2023 19:39:34 -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 S232001AbjIYCj0 (ORCPT + 30 others); Sun, 24 Sep 2023 22:39:26 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:54518 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S231826AbjIYCjJ (ORCPT ); Sun, 24 Sep 2023 22:39:09 -0400 Received: from mgamail.intel.com (mgamail.intel.com [192.55.52.136]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 82236199 for ; Sun, 24 Sep 2023 19:38:43 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=intel.com; i=@intel.com; q=dns/txt; s=Intel; t=1695609523; x=1727145523; h=from:to:cc:subject:date:message-id:in-reply-to: references:mime-version:content-transfer-encoding; bh=xt59YPV3UPgR9fnqUhyNXSoK4BasWhrnYxVljgS7h3Q=; b=CF1/eQbVQu0k6YFU1F+EjnxCxf7xew0ntkOSLHtfmMjH9gGjFVa5+ZBV PkhbCQk3NUD9v9WAF38dt/okO2IvCburgorC53JCTB7mtgKVMpxHmjC2v 8NuhNGq9XNErAnQkZBcHPTs3o21fpVS7Fg+nS/F0DUA8YN1jQczdpu/Fa y37XaJL8vsR7aGKL47sEhO9R0/uCyTNw7eZMR+N/b/Mw2RiJFeXirY+6o /cRLyzvhKGRB6yRO0wtrDEFFJG78vUA6k+3Acjz1tQ/ioW+TkCR4KObNO ab2kv6N9y+yugw5mE02d8gJySdPNJGYtQLzcKSmr/HmFfauDQuhrtLHWp Q==; X-IronPort-AV: E=McAfee;i="6600,9927,10843"; a="360534620" X-IronPort-AV: E=Sophos;i="6.03,174,1694761200"; d="scan'208";a="360534620" Received: from orsmga008.jf.intel.com ([10.7.209.65]) by fmsmga106.fm.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 24 Sep 2023 19:38:43 -0700 X-ExtLoop1: 1 X-IronPort-AV: E=McAfee;i="6600,9927,10843"; a="777505090" X-IronPort-AV: E=Sophos;i="6.03,174,1694761200"; d="scan'208";a="777505090" Received: from jingxues-mobl1.ccr.corp.intel.com (HELO tinazhan-desk1.intel.com) ([10.254.214.78]) by orsmga008-auth.jf.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 24 Sep 2023 19:38:40 -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 v5 5/6] iommu: Support mm PASID 1:n with sva domains Date: Mon, 25 Sep 2023 10:38:12 +0800 Message-Id: <20230925023813.575016-6-tina.zhang@intel.com> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20230925023813.575016-1-tina.zhang@intel.com> References: <20230925023813.575016-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]); Sun, 24 Sep 2023 19:39:34 -0700 (PDT) X-getmail-retrieved-from-mailbox: INBOX X-GMAIL-THRID: 1777999261535804229 X-GMAIL-MSGID: 1777999261535804229 Each mm bound to devices gets a PASID and corresponding sva domains allocated in iommu_sva_bind_device(), which are referenced by iommu_mm field of the mm. The PASID is released in __mmdrop(), while a sva domain is released when no one is using it (the reference count is decremented in iommu_sva_unbind_device()). However, although sva domains and their PASID are separate objects such that their own life cycles could be handled independently, an enqcmd use case may require releasing the PASID in releasing the mm (i.e., once a PASID is allocated for a mm, it will be permanently used by the mm and won't be released until the end of mm) and only allows to drop the PASID after the sva domains are released. To this end, mmgrab() is called in iommu_sva_domain_alloc() to increment the mm reference count and mmdrop() is invoked in iommu_domain_free() to decrement the mm reference count. Since the required info of PASID and sva domains is kept in struct iommu_mm_data of a mm, use mm->iommu_mm field instead of the old pasid field in mm struct. The sva domain list is protected by iommu_sva_lock. Besides, this patch removes mm_pasid_init(), as with the introduced iommu_mm structure, initializing mm pasid in mm_init() is unnecessary. Reviewed-by: Lu Baolu Reviewed-by: Vasant Hegde Signed-off-by: Tina Zhang Reviewed-by: Jason Gunthorpe --- Change in v5: - Use smp_store_release() & READ_ONCE() in storing and loading mm's pasid value. Change in v4: - Rebase to v6.6-rc1. drivers/iommu/iommu-sva.c | 40 +++++++++++++++++++++++++++------------ include/linux/iommu.h | 18 +++++++++++------- kernel/fork.c | 1 - 3 files changed, 39 insertions(+), 20 deletions(-) diff --git a/drivers/iommu/iommu-sva.c b/drivers/iommu/iommu-sva.c index 0f956ecd0c9b..b2c1db1ae385 100644 --- a/drivers/iommu/iommu-sva.c +++ b/drivers/iommu/iommu-sva.c @@ -15,6 +15,7 @@ static DEFINE_MUTEX(iommu_sva_lock); static int iommu_sva_alloc_pasid(struct mm_struct *mm, struct device *dev) { ioasid_t pasid; + struct iommu_mm_data *iommu_mm; int ret = 0; if (!arch_pgtable_dma_compat(mm)) @@ -28,12 +29,27 @@ static int iommu_sva_alloc_pasid(struct mm_struct *mm, struct device *dev) goto out; } + iommu_mm = kzalloc(sizeof(struct iommu_mm_data), GFP_KERNEL); + if (!iommu_mm) { + ret = -ENOMEM; + goto out; + } + pasid = iommu_alloc_global_pasid(dev); if (pasid == IOMMU_PASID_INVALID) { + kfree(iommu_mm); ret = -ENOSPC; goto out; } - mm->pasid = pasid; + iommu_mm->pasid = pasid; + INIT_LIST_HEAD(&iommu_mm->sva_domains); + /* + * Make sure the write to mm->iommu_mm is not reordered in front of + * initialization to iommu_mm fields. If it does, readers may see a + * valid iommu_mm with uninitialized values. + */ + smp_store_release(&mm->iommu_mm, iommu_mm); + ret = 0; out: mutex_unlock(&iommu_sva_lock); @@ -73,16 +89,12 @@ struct iommu_sva *iommu_sva_bind_device(struct device *dev, struct mm_struct *mm mutex_lock(&iommu_sva_lock); /* Search for an existing domain. */ - domain = iommu_get_domain_for_dev_pasid(dev, mm_get_pasid(mm), - IOMMU_DOMAIN_SVA); - if (IS_ERR(domain)) { - ret = PTR_ERR(domain); - goto out_unlock; - } - - if (domain) { - domain->users++; - goto out; + list_for_each_entry(domain, &mm->iommu_mm->sva_domains, next) { + ret = iommu_attach_device_pasid(domain, dev, mm_get_pasid(mm)); + if (!ret) { + domain->users++; + goto out; + } } /* Allocate a new domain and set it on device pasid. */ @@ -96,6 +108,8 @@ struct iommu_sva *iommu_sva_bind_device(struct device *dev, struct mm_struct *mm if (ret) goto out_free_domain; domain->users = 1; + list_add(&domain->next, &mm->iommu_mm->sva_domains); + out: mutex_unlock(&iommu_sva_lock); handle->dev = dev; @@ -128,8 +142,9 @@ void iommu_sva_unbind_device(struct iommu_sva *handle) struct device *dev = handle->dev; mutex_lock(&iommu_sva_lock); + iommu_detach_device_pasid(domain, dev, pasid); if (--domain->users == 0) { - iommu_detach_device_pasid(domain, dev, pasid); + list_del(&domain->next); iommu_domain_free(domain); } mutex_unlock(&iommu_sva_lock); @@ -209,4 +224,5 @@ void mm_pasid_drop(struct mm_struct *mm) return; iommu_free_global_pasid(mm_get_pasid(mm)); + kfree(mm->iommu_mm); } diff --git a/include/linux/iommu.h b/include/linux/iommu.h index b9c9f14a95cc..cf8febaa4d80 100644 --- a/include/linux/iommu.h +++ b/include/linux/iommu.h @@ -109,6 +109,11 @@ struct iommu_domain { struct { /* IOMMU_DOMAIN_SVA */ struct mm_struct *mm; int users; + /* + * Next iommu_domain in mm->iommu_mm->sva-domains list + * protected by iommu_sva_lock. + */ + struct list_head next; }; }; }; @@ -1186,17 +1191,17 @@ static inline bool tegra_dev_iommu_get_stream_id(struct device *dev, u32 *stream } #ifdef CONFIG_IOMMU_SVA -static inline void mm_pasid_init(struct mm_struct *mm) -{ - mm->pasid = IOMMU_PASID_INVALID; -} static inline bool mm_valid_pasid(struct mm_struct *mm) { - return mm->pasid != IOMMU_PASID_INVALID; + return READ_ONCE(mm->iommu_mm); } static inline u32 mm_get_pasid(struct mm_struct *mm) { - return mm->pasid; + struct iommu_mm_data *iommu_mm = READ_ONCE(mm->iommu_mm); + + if (!iommu_mm) + return IOMMU_PASID_INVALID; + return iommu_mm->pasid; } static inline u32 mm_get_enqcmd_pasid(struct mm_struct *mm) { @@ -1222,7 +1227,6 @@ static inline u32 iommu_sva_get_pasid(struct iommu_sva *handle) { return IOMMU_PASID_INVALID; } -static inline void mm_pasid_init(struct mm_struct *mm) {} static inline bool mm_valid_pasid(struct mm_struct *mm) { return false; } static inline u32 mm_get_pasid(struct mm_struct *mm) { diff --git a/kernel/fork.c b/kernel/fork.c index 3b6d20dfb9a8..985403a7a747 100644 --- a/kernel/fork.c +++ b/kernel/fork.c @@ -1277,7 +1277,6 @@ static struct mm_struct *mm_init(struct mm_struct *mm, struct task_struct *p, mm_init_cpumask(mm); mm_init_aio(mm); mm_init_owner(mm, p); - mm_pasid_init(mm); RCU_INIT_POINTER(mm->exe_file, NULL); mmu_notifier_subscriptions_init(mm); init_tlb_flush_pending(mm); From patchwork Mon Sep 25 02:38:13 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: "Zhang, Tina" X-Patchwork-Id: 144231 Return-Path: Delivered-To: ouuuleilei@gmail.com Received: by 2002:a59:cae8:0:b0:403:3b70:6f57 with SMTP id r8csp1016562vqu; Sun, 24 Sep 2023 23:41:20 -0700 (PDT) X-Google-Smtp-Source: AGHT+IEEBnkoIpD+FsU4F2wERHAdHmj3mC4BKjjudXxWQzW5cHyxS2nSXTSSfxdfBBDj3q2xQ2f1 X-Received: by 2002:a05:6a00:14c6:b0:690:d4fa:d43d with SMTP id w6-20020a056a0014c600b00690d4fad43dmr4870084pfu.6.1695624080236; Sun, 24 Sep 2023 23:41:20 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1695624080; cv=none; d=google.com; s=arc-20160816; b=eGkeCVKoj2wv2CTot89oTGgsLN+VU6Zu6e6NcUDlkvAg8tRVXrxu4Yt03pNRCMoR+1 PhzwqChppmgYm4f+EvvTdeVk4inGlacyHUWEtXcXwTRpjURr7zFyQoJ9gUNnjTpC9zIo AAioXWgrQcYrY/BgJDGWjIKbCtYA6qJPMTqRZNRWJzNGJeok4pxReffnb0Lduo76lQcl aW5XsneE5Cr+wmQmxA8c7OVj+icIUKTNTU/ydc064bDGG/o/DfOVQtFfBYUlLQYtMR15 5WQcGnTjyZXFzd+s66kz1P81C2JRsjajPqm6HP4veZhIkPSW3w7skB1CSN3qNwIDzJQ4 l11g== 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=f4ued0zf2rysKkOOLLWW3WpexywB8PzbB0mgR2mIrRQ=; fh=zW1GPeUL3MQGLvvmLmBmaazP2MzqJ1fOEi8He5Dzy3k=; b=0uUJykV6ytqQeqG2l8lqgN02Q0K2p1CiXhjMTkolj1IkykWCQpBJhgQtzgZ/q3+/w0 2VIslM6iBdVQlowjbze0rDzDlgvT6jzQt5N4iU0bkXknd+tL0ZkNSJ8M82h4r5zIvsGd QUDs20/FAZXhgyNC1td6/PwBwJWWJHlynbNu6DU2q/sOT7p+FryuQ0nR0B5GihH+4SB4 8c6aQev4TjzkbdWEtjkynFjPzdtsnohNz3HioxA0coLE88MHM8tBdbRyzCEBbbzqCTQ6 q6F05Npldytps/jBmzJYRxdEUOHiZfVyj5Yac/tIqxt/KTZniHoCye/I0ZIhKO0TCYRF Rw5w== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@intel.com header.s=Intel header.b=BRrIDFg5; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::3:3 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 lipwig.vger.email (lipwig.vger.email. [2620:137:e000::3:3]) by mx.google.com with ESMTPS id f20-20020a056a00229400b0068ffe38c5ddsi9807561pfe.223.2023.09.24.23.41.19 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Sun, 24 Sep 2023 23:41:20 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::3:3 as permitted sender) client-ip=2620:137:e000::3:3; Authentication-Results: mx.google.com; dkim=pass header.i=@intel.com header.s=Intel header.b=BRrIDFg5; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::3:3 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 lipwig.vger.email (Postfix) with ESMTP id 067F08148B95; Sun, 24 Sep 2023 19:39:47 -0700 (PDT) X-Virus-Status: Clean X-Virus-Scanned: clamav-milter 0.103.10 at lipwig.vger.email Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S231874AbjIYCjb (ORCPT + 30 others); Sun, 24 Sep 2023 22:39:31 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:35544 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S232019AbjIYCjK (ORCPT ); Sun, 24 Sep 2023 22:39:10 -0400 Received: from mgamail.intel.com (mgamail.intel.com [192.55.52.136]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 426DDE49 for ; Sun, 24 Sep 2023 19:38:46 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=intel.com; i=@intel.com; q=dns/txt; s=Intel; t=1695609526; x=1727145526; h=from:to:cc:subject:date:message-id:in-reply-to: references:mime-version:content-transfer-encoding; bh=sLavevVR2/ebOFF/RgWFP9jTGobd5rMYRFpptbLPi5Y=; b=BRrIDFg58VLaiRi3KRErz4WQficzAVbR1SBq9HG8pj7rpmbpNDGF7izo v2/NBMd3wYKNZcV1yqxpqieo8Yw5sTR+4Ne9tSXMzkUPdSTpkj7kqy951 K02KjbK2SPi8pDPA8rOOBy8uQlH1DZ4VuqjRnhYhgz4FbYfpmczGsdEzb 1ECLccm86rBO9E+Qhu9sug3Y26flP8x0llSDNZRC/ILm8+X+WXd2/a+Kx kRpyq5A3wITFe43gpLlmJ/rR0yFMWk/TlcRa2atWA52ZDqZ9xLga28cqH ae0TYgyrv5lv17Zm6NKmrn57MRQcSo6b6p7U7FW3pneYmthZj3Nq0mJzo Q==; X-IronPort-AV: E=McAfee;i="6600,9927,10843"; a="360534626" X-IronPort-AV: E=Sophos;i="6.03,174,1694761200"; d="scan'208";a="360534626" Received: from orsmga008.jf.intel.com ([10.7.209.65]) by fmsmga106.fm.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 24 Sep 2023 19:38:45 -0700 X-ExtLoop1: 1 X-IronPort-AV: E=McAfee;i="6600,9927,10843"; a="777505094" X-IronPort-AV: E=Sophos;i="6.03,174,1694761200"; d="scan'208";a="777505094" Received: from jingxues-mobl1.ccr.corp.intel.com (HELO tinazhan-desk1.intel.com) ([10.254.214.78]) by orsmga008-auth.jf.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 24 Sep 2023 19:38:43 -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 v5 6/6] mm: Deprecate pasid field Date: Mon, 25 Sep 2023 10:38:13 +0800 Message-Id: <20230925023813.575016-7-tina.zhang@intel.com> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20230925023813.575016-1-tina.zhang@intel.com> References: <20230925023813.575016-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 lipwig.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 (lipwig.vger.email [0.0.0.0]); Sun, 24 Sep 2023 19:39:47 -0700 (PDT) X-getmail-retrieved-from-mailbox: INBOX X-GMAIL-THRID: 1777990715584846431 X-GMAIL-MSGID: 1777990715584846431 Drop the pasid field, as all the information needed for sva domain management has been moved to the newly added iommu_mm field. Reviewed-by: Lu Baolu Reviewed-by: Vasant Hegde Signed-off-by: Tina Zhang Reviewed-by: Jason Gunthorpe --- include/linux/mm_types.h | 1 - mm/init-mm.c | 3 --- 2 files changed, 4 deletions(-) diff --git a/include/linux/mm_types.h b/include/linux/mm_types.h index 9f4efed85f74..37f049c4b059 100644 --- a/include/linux/mm_types.h +++ b/include/linux/mm_types.h @@ -883,7 +883,6 @@ struct mm_struct { struct work_struct async_put_work; #ifdef CONFIG_IOMMU_SVA - u32 pasid; struct iommu_mm_data *iommu_mm; #endif #ifdef CONFIG_KSM diff --git a/mm/init-mm.c b/mm/init-mm.c index cfd367822cdd..24c809379274 100644 --- a/mm/init-mm.c +++ b/mm/init-mm.c @@ -44,9 +44,6 @@ struct mm_struct init_mm = { #endif .user_ns = &init_user_ns, .cpu_bitmap = CPU_BITS_NONE, -#ifdef CONFIG_IOMMU_SVA - .pasid = IOMMU_PASID_INVALID, -#endif INIT_MM_CONTEXT(init_mm) };