Received: by 2002:a05:6358:11c7:b0:104:8066:f915 with SMTP id i7csp1193019rwl; Fri, 7 Apr 2023 11:22:13 -0700 (PDT) X-Google-Smtp-Source: AKy350bxn/sJg0bo4k2ywMH1TZJ+OuahYsTDHR6jYmxNEtP/tC1oYduvrIcOpWNRU2t4m/GuIvgT X-Received: by 2002:a17:906:b053:b0:93e:3127:fc28 with SMTP id bj19-20020a170906b05300b0093e3127fc28mr375220ejb.39.1680891733316; Fri, 07 Apr 2023 11:22:13 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1680891733; cv=none; d=google.com; s=arc-20160816; b=x+B4lwkdo6F1Grl0PNxLXZ0GHkWsVEAkSM+lKL4RUn5JqSi+HY1WQBMF8WQGyJlKZT H2dxrFsFc0mP7AP77t5uehYgNr8sML+j/G/mwmK8pNgufl2NV7FL/CRhHzUT+uGHHQnQ QzkbXEBLuCWEfwOweYgj9vsMxtbzf4fN96h4GEtlY3X6RISxv8zUt5eAQN9b+QlmygO2 GraXMjlRIw4VX3o0a7NxN/ka1bl9pTo4ddLrv3ZrT6wxFw2sshQ5LInUQesb2kUMYJ2r 22YW5DHvUi/VO+svB2qeaygqYBcqpMg/9ItZ5MG+1S+M5Xj4a3tOcOB0R8TYbgzD4mE4 G6dQ== 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=TALuUcF+Se8m9YKDTYovUtJ00j4KUa36Tom28M40lWA=; b=VhykZvaTTNVXWEmEJZoSGMmKjZuhhMwo/ryi7iqX+6IWvr9FRYbLtqH0lhbWOfbflb y/3mHkD81tqGoujUMnQCpJ3QoM+XH6BOCH01WaX5GNppHaWaQQVCn9PmQv7HspjYlnuF XCtAW3lpQtBRTWSs8piKlgRyAmqY+cR63nkeCIrfnOYtzaTqKWTIWThQmqDldAWW5yJ2 2Ty/w9Ld6whuxZ5Tta4IKEJ6kVdDKG2IvzYUfow3o20m65OVBZHEK34EEG8VDwT/x+lH tKMaoP7KkJ3pflkyLTgQh6rD6LfNobrhqoMmYGXVXpKp12WA9Vfleu5OofVV2HpnS5lX p1+g== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@intel.com header.s=Intel header.b=maUfJqyq; 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 a12-20020a17090682cc00b0092be4d3413asi3214145ejy.131.2023.04.07.11.21.46; Fri, 07 Apr 2023 11:22:13 -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=maUfJqyq; 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 S231551AbjDGSCH (ORCPT + 99 others); Fri, 7 Apr 2023 14:02:07 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:43146 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S231360AbjDGSB4 (ORCPT ); Fri, 7 Apr 2023 14:01:56 -0400 Received: from mga14.intel.com (mga14.intel.com [192.55.52.115]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 12D95BB99; Fri, 7 Apr 2023 11:01:55 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=intel.com; i=@intel.com; q=dns/txt; s=Intel; t=1680890515; x=1712426515; h=from:to:cc:subject:date:message-id:in-reply-to: references:mime-version:content-transfer-encoding; bh=86aFWjB5alp/mq4OwyCmhytbhDjYJbntMbdQCEJ84y8=; b=maUfJqyqrLEjcV18bsbpulY5ufImGse0zpfKWJ6/ZMU0QcToLjngMpja RumrcuUvhBo8ngSF5zFmxsguXq5eqiCk9jxQ/Md+IPR0wnBpMeR6PYVx+ aPsKXPKcTPJEUdxbqJ8bhYv8qPnnGNrD1EH3aw7vIXsqDGYspaxu+5uqp QD1Ltl9q4JFn7BpFlQXITSb981tPPHP5Xip2VTGI+lERkpp+Hv6NRdKRW Hs+eUcNMMT+U/dcTv30eoiKNyFewk6etBKEGTRl2P4NdNXsWukuSqSya0 U0rYKv8JXchaae5Ux9YWHgH974rmOekhmQvBjpLHXrBhwYX0BN9h1Xymv A==; X-IronPort-AV: E=McAfee;i="6600,9927,10673"; a="343046491" X-IronPort-AV: E=Sophos;i="5.98,327,1673942400"; d="scan'208";a="343046491" Received: from fmsmga003.fm.intel.com ([10.253.24.29]) by fmsmga103.fm.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 07 Apr 2023 11:01:51 -0700 X-ExtLoop1: 1 X-IronPort-AV: E=McAfee;i="6600,9927,10673"; a="776910068" X-IronPort-AV: E=Sophos;i="5.98,327,1673942400"; d="scan'208";a="776910068" Received: from srinivas-otcpl-7600.jf.intel.com (HELO jacob-builder.jf.intel.com) ([10.54.39.106]) by FMSMGA003.fm.intel.com with ESMTP; 07 Apr 2023 11:01:51 -0700 From: Jacob Pan To: LKML , iommu@lists.linux.dev, "Robin Murphy" , Jason Gunthorpe , "Lu Baolu" , Joerg Roedel , dmaengine@vger.kernel.org, vkoul@kernel.org Cc: "Will Deacon" , David Woodhouse , Raj Ashok , "Tian, Kevin" , Yi Liu , "Yu, Fenghua" , Dave Jiang , Tony Luck , "Zanussi, Tom" , Jacob Pan Subject: [PATCH v4 4/7] iommu/vt-d: Reserve RID_PASID from global PASID space Date: Fri, 7 Apr 2023 11:05:51 -0700 Message-Id: <20230407180554.2784285-5-jacob.jun.pan@linux.intel.com> X-Mailer: git-send-email 2.25.1 In-Reply-To: <20230407180554.2784285-1-jacob.jun.pan@linux.intel.com> References: <20230407180554.2784285-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 PASID number space. Non-zero value can be used in RID_PASID on Intel VT-d. For ARM, AMD and others that _always_ use 0 as RID_PASID, there is no impact in that SVA PASID allocation base is 1. With this change, devices do both DMA with PASID and SVA 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..cbb2670f88ca 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; + /* Reserved RID_PASID from the global namespace for legacy DMA */ + WARN_ON(iommu_alloc_global_pasid(PASID_RID2PASID, PASID_RID2PASID) != + PASID_RID2PASID); + return 0; out_free_dmar: -- 2.25.1