Received: by 2002:a05:6358:11c7:b0:104:8066:f915 with SMTP id i7csp3558184rwl; Mon, 27 Mar 2023 16:19:19 -0700 (PDT) X-Google-Smtp-Source: AK7set8GD4S1cpqWZIrxIeJzX7rvBNF0FUDaKP8Kl3pjAC/bE+DG9VB4PrerYIw9Cg6qX/StfWux X-Received: by 2002:a05:6a20:669f:b0:d7:380b:660 with SMTP id o31-20020a056a20669f00b000d7380b0660mr11530170pzh.3.1679959159391; Mon, 27 Mar 2023 16:19:19 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1679959159; cv=none; d=google.com; s=arc-20160816; b=wTDZYW2z1xQemQ2ydsRNRT83aaJrbK8+rgGb5h0UZfA0cJaHFIefHh++DSsAHOT0AT 9qRpCg2srRV7B1Y3dhJfw0DeoD8RcG9IU4wwG+cBFQZjye5l79Rx+QqMvtuUu5AvsbRA Pt1khmWyP3O5ITzRTFtYJ0Ml3J2b6kefUHGvlw7C+EqkKWWqzGYduNdhLxzp0v5dLUx+ iYPE2IcLP/TKo+T+vGc8YZ8xuRpcW6ES1Mv8tj41aTw10lf/zidyZ3Gm/cgSfUANN6vI Li41Euzvd6ylhsJ9vFONw1UF0f76S5oke22EJxdfSC5lw/SfLcStUciA4MgmIHjDOeUW FxMQ== 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=XlhWLoCDBmLxzGn3m+KuxDqRc301UfP2a1U4EQElnMU=; b=mwjICvdvV1Yh4PYErWQbIc/h0TrLfxy1ZrQq5dXETTn0O805LDCue67CUtw3jgAfrV /zF4TNGcLX+34L2sZr1ZBGZl1EiJ+nuYuJG1lCxLzpt37D0Fz7nU8m8OMR+Pjj+11shh sftxwTDCy2urdlcy7xqtP59qgmj5KEQOKPyHxDxVj+Z2/0sEa0PRJcHV8Sbu5c0e6ZXQ Wbd64mYuxvFk9Vfc8mzWGP1WQsEbhH9x1fM3d0voRU1Y9JfqC/9eFUxLtS3QorTFk2FM FSzt/GuJcqCd8fqSC06Jz6pEbUouxEkUOLOK2I82LdDOyEY49S/mvW8JbQ/on44diMGN vyKQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@intel.com header.s=Intel header.b=X+Apg11E; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 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 out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id o17-20020a056a00215100b00627f017391csi21862523pfk.273.2023.03.27.16.19.07; Mon, 27 Mar 2023 16:19:19 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) client-ip=2620:137:e000::1:20; Authentication-Results: mx.google.com; dkim=pass header.i=@intel.com header.s=Intel header.b=X+Apg11E; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=intel.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S232132AbjC0XRz (ORCPT + 99 others); Mon, 27 Mar 2023 19:17:55 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:55170 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S229456AbjC0XRl (ORCPT ); Mon, 27 Mar 2023 19:17:41 -0400 Received: from mga17.intel.com (mga17.intel.com [192.55.52.151]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id A15162681; Mon, 27 Mar 2023 16:17: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=1679959060; x=1711495060; h=from:to:cc:subject:date:message-id:in-reply-to: references:mime-version:content-transfer-encoding; bh=qgUzvbGBHIHc0aGK2Q/F/EqhcZ8UqxtTsN6J1Ti6Lks=; b=X+Apg11EhmatgR6ORNmBFGw9AHnYpgK/dS5AhQ/tRtxHpuer2QpGUj2c +tleWJT9yPbYeeMCs1Re5pLd1xmonHxzklExmhr8V0iO96VOlVrI5kMdl XcCd7OPHGWT/jZ/SKVVnQt9KNJUA+KX7FjFFp+1hnJolS2aP49Eqx2YRo tvYPmawpO9M3cHZp7FlNaWGs/NcC500dnCU4tcXRIiNYpqhVG+8nFdsTf 2Cx+0JfnKmOVKIAsC3kogL54Y/jtQv0etvrEe0W9XC7f6ZSMR5OcnsBKL VQeGl3JyuIeKMKtaDxDaBh1g2CykrH10El3+LJ0jN5wLvktz4K4EFPVN9 w==; X-IronPort-AV: E=McAfee;i="6600,9927,10662"; a="320817319" X-IronPort-AV: E=Sophos;i="5.98,295,1673942400"; d="scan'208";a="320817319" Received: from fmsmga007.fm.intel.com ([10.253.24.52]) by fmsmga107.fm.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 27 Mar 2023 16:17:39 -0700 X-ExtLoop1: 1 X-IronPort-AV: E=McAfee;i="6600,9927,10662"; a="686144729" X-IronPort-AV: E=Sophos;i="5.98,295,1673942400"; d="scan'208";a="686144729" Received: from srinivas-otcpl-7600.jf.intel.com (HELO jacob-builder.jf.intel.com) ([10.54.39.106]) by fmsmga007.fm.intel.com with ESMTP; 27 Mar 2023 16:17:38 -0700 From: Jacob Pan To: LKML , iommu@lists.linux.dev, Jason Gunthorpe , "Lu Baolu" , Joerg Roedel , dmaengine@vger.kernel.org, vkoul@kernel.org Cc: "Robin Murphy" , "Will Deacon" , David Woodhouse , Raj Ashok , "Tian, Kevin" , Yi Liu , "Yu, Fenghua" , Dave Jiang , Tony Luck , "Zanussi, Tom" , Jacob Pan Subject: [PATCH v2 4/8] iommu/vt-d: Reserve RID_PASID from global SVA PASID space Date: Mon, 27 Mar 2023 16:21:34 -0700 Message-Id: <20230327232138.1490712-5-jacob.jun.pan@linux.intel.com> X-Mailer: git-send-email 2.25.1 In-Reply-To: <20230327232138.1490712-1-jacob.jun.pan@linux.intel.com> References: <20230327232138.1490712-1-jacob.jun.pan@linux.intel.com> MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Spam-Status: No, score=-2.4 required=5.0 tests=DKIMWL_WL_HIGH,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_EF,RCVD_IN_DNSWL_MED,SPF_HELO_NONE,SPF_NONE autolearn=unavailable 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 On VT-d platforms, RID_PASID is used for DMA request without PASID. We should not treat RID_PASID special instead let it be allocated from the global SVA PASID number space. Consequently, for devices also do DMA with PASID, drivers will not worry about conflicts when it comes to allocating PASIDs for in-kernel DMA. Signed-off-by: Jacob Pan --- drivers/iommu/intel/iommu.c | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/drivers/iommu/intel/iommu.c b/drivers/iommu/intel/iommu.c index 9f737ef55463..61c06f7ad8f7 100644 --- a/drivers/iommu/intel/iommu.c +++ b/drivers/iommu/intel/iommu.c @@ -3956,6 +3956,10 @@ int __init intel_iommu_init(void) intel_iommu_enabled = 1; +#ifdef CONFIG_INTEL_IOMMU_SVM + /* Reserved RID_PASID from the global namespace for legacy DMA */ + iommu_sva_reserve_pasid(PASID_RID2PASID, PASID_RID2PASID); +#endif return 0; out_free_dmar: -- 2.25.1