Received: by 2002:a25:ad19:0:0:0:0:0 with SMTP id y25csp8141331ybi; Tue, 23 Jul 2019 03:32:11 -0700 (PDT) X-Google-Smtp-Source: APXvYqyfpZ6YlbGA3vEHbv7VW5PyhrLug2UF2Dkrb9gLjNpwu+bsjueEg7nTdA3DegYg1OOULD4T X-Received: by 2002:a63:4404:: with SMTP id r4mr74829590pga.245.1563877930947; Tue, 23 Jul 2019 03:32:10 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1563877930; cv=none; d=google.com; s=arc-20160816; b=kwNck/7WtHChwqFsV/PkfZi0DzVdvpf7Wrb9o+VsPNzbsB4FG2Yiwf29opKsJCZC3I np5L9sA198H+qLu+77qZPjJOYEoferTjVM6kkTPSGqL5i0rFRXmaQwYxiC5qcZrZ3sT3 8m0iYWpIPYA6wqbOTcOw8xxF6XXaTunh7TRTVJXdY+1eTCvQfsPkY58eNlaRQu2NK8YL qjlEd6CuvneBH+6ipUndYLhI/Hod1BFgkXjNZyFzxcxBSBGmRyyYVnnFgD+IZQJZzb/a EOtNjZE2q/a8DD0hhSMNBAqdpTnUc90iThbvSaXvz+6z5KsRDHTkpJVEUu7u+F0wLTYa TNNw== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:subject:content-transfer-encoding :mime-version:references:in-reply-to:message-id:date:cc:to:from; bh=EmlCDkZJMjS8av1zm7KJ0wKNdmlDiGW2UDCKnnQW1hg=; b=QnFfXP/bOBshiKcKXfiLLNIudN3vcWQ7+DdMHH5BYk2t/ht8eQ7XKZ5fnbS4heAsVE 4lHEQMHT1UoWdI408Iz9gAo89hIVhpA4+bCfoDZSz83q/yCs5seSQcsXcN8NVTVfqb3N LZo4VRbLCxNW8J/sgg9q0h43vVFNlnRyTONT+UYwZh2/yIfHl4xLu7x6ErkAr164O/3f hAKs5CeoGZGjYzXaGXhWKtQ49a92IU4ezE6OYnN55JOiMsNA1pcjBX92YHPZnw+eF6fv tAp1m6Chb7JkhLupzzhDm1GNP8bprP9YVskW+MG7iBJzX+WNBdDyA2nPlVXRDoKAqwly iIsQ== ARC-Authentication-Results: i=1; mx.google.com; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id x126si40721986pgx.356.2019.07.23.03.31.55; Tue, 23 Jul 2019 03:32:10 -0700 (PDT) Received-SPF: pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) client-ip=209.132.180.67; Authentication-Results: mx.google.com; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1731941AbfGVXKT (ORCPT + 99 others); Mon, 22 Jul 2019 19:10:19 -0400 Received: from ale.deltatee.com ([207.54.116.67]:40264 "EHLO ale.deltatee.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1733159AbfGVXJM (ORCPT ); Mon, 22 Jul 2019 19:09:12 -0400 Received: from cgy1-donard.priv.deltatee.com ([172.16.1.31]) by ale.deltatee.com with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.89) (envelope-from ) id 1hphQb-0002k0-Dk; Mon, 22 Jul 2019 17:09:11 -0600 Received: from gunthorp by cgy1-donard.priv.deltatee.com with local (Exim 4.89) (envelope-from ) id 1hphQV-0001Qt-MG; Mon, 22 Jul 2019 17:09:03 -0600 From: Logan Gunthorpe To: linux-kernel@vger.kernel.org, linux-pci@vger.kernel.org, linux-nvme@lists.infradead.org, linux-rdma@vger.kernel.org Cc: Bjorn Helgaas , Christoph Hellwig , Christian Koenig , Jason Gunthorpe , Sagi Grimberg , Keith Busch , Jens Axboe , Dan Williams , Eric Pilmore , Stephen Bates , Logan Gunthorpe Date: Mon, 22 Jul 2019 17:08:51 -0600 Message-Id: <20190722230859.5436-7-logang@deltatee.com> X-Mailer: git-send-email 2.20.1 In-Reply-To: <20190722230859.5436-1-logang@deltatee.com> References: <20190722230859.5436-1-logang@deltatee.com> MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-SA-Exim-Connect-IP: 172.16.1.31 X-SA-Exim-Rcpt-To: linux-nvme@lists.infradead.org, linux-kernel@vger.kernel.org, linux-pci@vger.kernel.org, linux-rdma@vger.kernel.org, bhelgaas@google.com, hch@lst.de, Christian.Koenig@amd.com, jgg@mellanox.com, sagi@grimberg.me, kbusch@kernel.org, axboe@fb.com, dan.j.williams@intel.com, epilmore@gigaio.com, sbates@raithlin.com, logang@deltatee.com X-SA-Exim-Mail-From: gunthorp@deltatee.com X-Spam-Checker-Version: SpamAssassin 3.4.2 (2018-09-13) on ale.deltatee.com X-Spam-Level: X-Spam-Status: No, score=-8.7 required=5.0 tests=ALL_TRUSTED,BAYES_00, GREYLIST_ISWHITE,MYRULES_NO_TEXT autolearn=ham autolearn_force=no version=3.4.2 Subject: [PATCH 06/14] PCI/P2PDMA: Add whitelist support for Intel Host Bridges X-SA-Exim-Version: 4.2.1 (built Tue, 02 Aug 2016 21:08:31 +0000) X-SA-Exim-Scanned: Yes (on ale.deltatee.com) Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Intel devices do not have good support for P2P requests that span different host bridges as the transactions will cross the QPI/UPI bus and this does not perform well. Therefore, enable support for these devices only if the host bridges match. Adds the Intel device's that have been tested to work. There are likely many others out there that will need to be tested and added. Signed-off-by: Logan Gunthorpe --- drivers/pci/p2pdma.c | 36 ++++++++++++++++++++++++++++++++---- 1 file changed, 32 insertions(+), 4 deletions(-) diff --git a/drivers/pci/p2pdma.c b/drivers/pci/p2pdma.c index dfb802afc8ca..143e11d2a5c3 100644 --- a/drivers/pci/p2pdma.c +++ b/drivers/pci/p2pdma.c @@ -250,9 +250,28 @@ static void seq_buf_print_bus_devfn(struct seq_buf *buf, struct pci_dev *pdev) seq_buf_printf(buf, "%s;", pci_name(pdev)); } -static bool __host_bridge_whitelist(struct pci_host_bridge *host) +static const struct pci_p2pdma_whitelist_entry { + unsigned short vendor; + unsigned short device; + bool req_same_host_bridge; +} pci_p2pdma_whitelist[] = { + /* AMD ZEN */ + {PCI_VENDOR_ID_AMD, 0x1450, false}, + + /* Intel Xeon E5/Core i7 */ + {PCI_VENDOR_ID_INTEL, 0x3c00, true}, + {PCI_VENDOR_ID_INTEL, 0x3c01, true}, + /* Intel Xeon E7 v3/Xeon E5 v3/Core i7 */ + {PCI_VENDOR_ID_INTEL, 0x2f00, true}, + {PCI_VENDOR_ID_INTEL, 0x2f01, true}, + {} +}; + +static bool __host_bridge_whitelist(struct pci_host_bridge *host, + bool same_host_bridge) { struct pci_dev *root = pci_get_slot(host->bus, PCI_DEVFN(0, 0)); + const struct pci_p2pdma_whitelist_entry *entry; unsigned short vendor, device; if (!root) @@ -262,9 +281,14 @@ static bool __host_bridge_whitelist(struct pci_host_bridge *host) device = root->device; pci_dev_put(root); - /* AMD ZEN host bridges can do peer to peer */ - if (vendor == PCI_VENDOR_ID_AMD && device == 0x1450) + for (entry = pci_p2pdma_whitelist; entry->vendor; entry++) { + if (vendor != entry->vendor || device != entry->device) + continue; + if (entry->req_same_host_bridge && !same_host_bridge) + return false; + return true; + } return false; } @@ -281,7 +305,11 @@ static bool host_bridge_whitelist(struct pci_dev *a, struct pci_dev *b) if (iommu_present(a->dev.bus) || iommu_present(b->dev.bus)) return false; - if (__host_bridge_whitelist(host_a) && __host_bridge_whitelist(host_b)) + if (host_a == host_b) + return __host_bridge_whitelist(host_a, true); + + if (__host_bridge_whitelist(host_a, false) && + __host_bridge_whitelist(host_b, false)) return true; return false; -- 2.20.1