Received: by 2002:a05:6358:45e:b0:b5:b6eb:e1f9 with SMTP id 30csp311723rwe; Fri, 26 Aug 2022 05:37:32 -0700 (PDT) X-Google-Smtp-Source: AA6agR5T7fY76zXvLOchn7UbGYHxWd/IZ1IHceCDP0m9dt7XcswOByBuuVKGMB++vUR86Qkye4xP X-Received: by 2002:a63:8549:0:b0:42a:2ae0:98ce with SMTP id u70-20020a638549000000b0042a2ae098cemr3182009pgd.72.1661517452598; Fri, 26 Aug 2022 05:37:32 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1661517452; cv=none; d=google.com; s=arc-20160816; b=rd8wPdKWXkIoQEwACUq5R7nt43G3D0zp0YsKWBubQsTqS/9+Mw4LXzO4ArIX+YTYl6 kKKFp4Ji4SuwHLet777tHCVFfyNht+gYC6yxqqwBxW5jG697xcQBoB+wZbSuqvsPU5NX 1HUCQLB+dCxtjQS3lExHczYjk9hDc9c0DJMQhWci/vVKV5AkgLd4CqObk3TY6fglvYRG +hetVD0z7JRsd8JviwER/s+XdGsMTaRlQ/LTS2yXz02gGr9J3JpWIj+uNdqtbgLzwOiz e4lSkb0aYoYenbH5cleUlAw3lrOk8vR6f2CyQmfWbw3YSeEu056mZXg9MCFMg2Z6BTkx 8qCQ== 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=oTq0tU8vI7WNS5AXigTx5jhI01GmiNecDNQNtM0dWwY=; b=IGtXG/Y3OVI9BAxb6i/vc7h9IesixhhmgGe3g5TR+j7f/nCU4F4IMw6IFSvMuxIHLq k62vl2eoYRZEGoYFi442I9tSUeb5C1Bnhkp2+0+oj59Srct7zOfDDJOe41ngxS67fEUc RWgN5SCy/200gwnqIUcoURYf131A3oyLWUhkc0hEnbqzC7ex4LZ+tLqIM/KVCKwyvOdj E+tGWnICH//XgIkWfhu+5flb07EAvL4xQ1AdOEoq2diH980/Kf+mu6bO8tczwaFiVQxq MdYI3pYefzOCP4hEbvC+c/I34wvl+ZeMtak99K9w3a4pJgyMpV/SuzrMOKEUDmgjsqEp 4P8g== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@intel.com header.s=Intel header.b=DogRD8zf; 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 b198-20020a6334cf000000b0042b686dde4bsi1665763pga.838.2022.08.26.05.37.21; Fri, 26 Aug 2022 05:37:32 -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=DogRD8zf; 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 S1343804AbiHZMRw (ORCPT + 99 others); Fri, 26 Aug 2022 08:17:52 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:51826 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1343491AbiHZMRr (ORCPT ); Fri, 26 Aug 2022 08:17:47 -0400 Received: from mga11.intel.com (mga11.intel.com [192.55.52.93]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 9D5F7DDAB6; Fri, 26 Aug 2022 05:17: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=1661516263; x=1693052263; h=from:to:cc:subject:date:message-id:in-reply-to: references:mime-version:content-transfer-encoding; bh=NYfZ7WyvsEWFSCcqG1ukcz7wBX70baQUiHICdtwmxwA=; b=DogRD8zfevqpkCvDtH7hU03ewttCYktyKZYJec3RmB0J53cSlN3j/9MC 1kk4swz3bL8m4I/909202WhirHXd2SfR44+J97FoZm3ZNW9AQrGukW1Yn 40HjqXyPNfoKjp0DiI9eQywfoyXNlhjNJLqUvxqKR1JqBs7eYjBeKf6wC S9YH7q0ROIpIWDAb4wzkcLENbaPwk0vRi14K1VdNh7hUPi5wW1X1BvVAy /Ihl/Qd9dek5auhdb1Bgfa84XzBQWPlpvMoh8geOW3OTbVl7qJ0C+SvKT EKI8RLmDmAHNOZfTqkNMYYRo96crAmsrENFhe+34H9iGWBrPNdXBBqsYd A==; X-IronPort-AV: E=McAfee;i="6500,9779,10450"; a="292072082" X-IronPort-AV: E=Sophos;i="5.93,265,1654585200"; d="scan'208";a="292072082" Received: from orsmga007.jf.intel.com ([10.7.209.58]) by fmsmga102.fm.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 26 Aug 2022 05:17:40 -0700 X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="5.93,265,1654585200"; d="scan'208";a="606747576" Received: from allen-box.sh.intel.com ([10.239.159.48]) by orsmga007.jf.intel.com with ESMTP; 26 Aug 2022 05:17:34 -0700 From: Lu Baolu To: Joerg Roedel , Jason Gunthorpe , Christoph Hellwig , Bjorn Helgaas , Kevin Tian , Ashok Raj , Will Deacon , Robin Murphy , Jean-Philippe Brucker , Dave Jiang , Fenghua Yu , Vinod Koul Cc: Eric Auger , Liu Yi L , Jacob jun Pan , Zhangfei Gao , Zhu Tony , iommu@lists.linux.dev, linux-pci@vger.kernel.org, linux-kernel@vger.kernel.org, Lu Baolu Subject: [PATCH v12 04/17] PCI: Enable PASID only when ACS RR & UF enabled on upstream path Date: Fri, 26 Aug 2022 20:11:28 +0800 Message-Id: <20220826121141.50743-5-baolu.lu@linux.intel.com> X-Mailer: git-send-email 2.25.1 In-Reply-To: <20220826121141.50743-1-baolu.lu@linux.intel.com> References: <20220826121141.50743-1-baolu.lu@linux.intel.com> MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Spam-Status: No, score=-7.0 required=5.0 tests=BAYES_00,DKIMWL_WL_HIGH, DKIM_SIGNED,DKIM_VALID,DKIM_VALID_EF,RCVD_IN_DNSWL_HI,SPF_HELO_NONE, SPF_NONE,T_SCC_BODY_TEXT_LINE 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 The Requester ID/Process Address Space ID (PASID) combination identifies an address space distinct from the PCI bus address space, e.g., an address space defined by an IOMMU. But the PCIe fabric routes Memory Requests based on the TLP address, ignoring any PASID (PCIe r6.0, sec 2.2.10.4), so a TLP with PASID that SHOULD go upstream to the IOMMU may instead be routed as a P2P Request if its address falls in a bridge window. To ensure that all Memory Requests with PASID are routed upstream, only enable PASID if ACS P2P Request Redirect and Upstream Forwarding are enabled for the path leading to the device. Suggested-by: Jason Gunthorpe Suggested-by: Kevin Tian Signed-off-by: Lu Baolu Acked-by: Bjorn Helgaas Tested-by: Tony Zhu --- drivers/pci/ats.c | 3 +++ 1 file changed, 3 insertions(+) diff --git a/drivers/pci/ats.c b/drivers/pci/ats.c index c967ad6e2626..f9cc2e10b676 100644 --- a/drivers/pci/ats.c +++ b/drivers/pci/ats.c @@ -382,6 +382,9 @@ int pci_enable_pasid(struct pci_dev *pdev, int features) if (!pasid) return -EINVAL; + if (!pci_acs_path_enabled(pdev, NULL, PCI_ACS_RR | PCI_ACS_UF)) + return -EINVAL; + pci_read_config_word(pdev, pasid + PCI_PASID_CAP, &supported); supported &= PCI_PASID_CAP_EXEC | PCI_PASID_CAP_PRIV; -- 2.25.1