Patch Detail
get:
Show a patch.
patch:
Update a patch.
put:
Update a patch.
GET /api/patches/964068/?format=api
{ "id": 964068, "url": "http://patchwork.ozlabs.org/api/patches/964068/?format=api", "web_url": "http://patchwork.ozlabs.org/project/linux-pci/patch/20180830185352.3369-2-logang@deltatee.com/", "project": { "id": 28, "url": "http://patchwork.ozlabs.org/api/projects/28/?format=api", "name": "Linux PCI development", "link_name": "linux-pci", "list_id": "linux-pci.vger.kernel.org", "list_email": "linux-pci@vger.kernel.org", "web_url": null, "scm_url": null, "webscm_url": null, "list_archive_url": "", "list_archive_url_format": "", "commit_url_format": "" }, "msgid": "<20180830185352.3369-2-logang@deltatee.com>", "list_archive_url": null, "date": "2018-08-30T18:53:40", "name": "[v5,01/13] PCI/P2PDMA: Support peer-to-peer memory", "commit_ref": null, "pull_url": null, "state": "changes-requested", "archived": false, "hash": "165d74da4c4c4f03b183f0980183769caabe4274", "submitter": { "id": 70191, "url": "http://patchwork.ozlabs.org/api/people/70191/?format=api", "name": "Logan Gunthorpe", "email": "logang@deltatee.com" }, "delegate": { "id": 6763, "url": "http://patchwork.ozlabs.org/api/users/6763/?format=api", "username": "bhelgaas", "first_name": "Bjorn", "last_name": "Helgaas", "email": "bhelgaas@google.com" }, "mbox": "http://patchwork.ozlabs.org/project/linux-pci/patch/20180830185352.3369-2-logang@deltatee.com/mbox/", "series": [ { "id": 63352, "url": "http://patchwork.ozlabs.org/api/series/63352/?format=api", "web_url": "http://patchwork.ozlabs.org/project/linux-pci/list/?series=63352", "date": "2018-08-30T18:53:41", "name": "Copy Offload in NVMe Fabrics with P2P PCI Memory", "version": 5, "mbox": "http://patchwork.ozlabs.org/series/63352/mbox/" } ], "comments": "http://patchwork.ozlabs.org/api/patches/964068/comments/", "check": "pending", "checks": "http://patchwork.ozlabs.org/api/patches/964068/checks/", "tags": {}, "related": [], "headers": { "Return-Path": "<linux-pci-owner@vger.kernel.org>", "X-Original-To": "incoming@patchwork.ozlabs.org", "Delivered-To": "patchwork-incoming@bilbo.ozlabs.org", "Authentication-Results": [ "ozlabs.org;\n\tspf=none (mailfrom) smtp.mailfrom=vger.kernel.org\n\t(client-ip=209.132.180.67; helo=vger.kernel.org;\n\tenvelope-from=linux-pci-owner@vger.kernel.org;\n\treceiver=<UNKNOWN>)", "ozlabs.org; dmarc=none (p=none dis=none)\n\theader.from=deltatee.com" ], "Received": [ "from vger.kernel.org (vger.kernel.org [209.132.180.67])\n\tby ozlabs.org (Postfix) with ESMTP id 421Wqk3Z5rz9s1x\n\tfor <incoming@patchwork.ozlabs.org>;\n\tFri, 31 Aug 2018 04:54:10 +1000 (AEST)", "(majordomo@vger.kernel.org) by vger.kernel.org via listexpand\n\tid S1727833AbeH3W5m (ORCPT <rfc822;incoming@patchwork.ozlabs.org>);\n\tThu, 30 Aug 2018 18:57:42 -0400", "from ale.deltatee.com ([207.54.116.67]:40064 \"EHLO\n\tale.deltatee.com\"\n\trhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP\n\tid S1727345AbeH3W5l (ORCPT <rfc822;linux-pci@vger.kernel.org>);\n\tThu, 30 Aug 2018 18:57:41 -0400", "from cgy1-donard.priv.deltatee.com ([172.16.1.31])\n\tby ale.deltatee.com with esmtps\n\t(TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.89)\n\t(envelope-from <gunthorp@deltatee.com>)\n\tid 1fvS4t-0006Og-Nd; Thu, 30 Aug 2018 12:54:04 -0600", "from gunthorp by cgy1-donard.priv.deltatee.com with local (Exim\n\t4.89) (envelope-from <gunthorp@deltatee.com>)\n\tid 1fvS4o-0000tH-3t; Thu, 30 Aug 2018 12:53:54 -0600" ], "From": "Logan Gunthorpe <logang@deltatee.com>", "To": "linux-kernel@vger.kernel.org, linux-pci@vger.kernel.org,\n\tlinux-nvme@lists.infradead.org, linux-rdma@vger.kernel.org,\n\tlinux-nvdimm@lists.01.org, linux-block@vger.kernel.org", "Cc": "Stephen Bates <sbates@raithlin.com>, Christoph Hellwig <hch@lst.de>,\n\tKeith Busch <keith.busch@intel.com>, Sagi Grimberg <sagi@grimberg.me>,\n\tBjorn Helgaas <bhelgaas@google.com>, Jason Gunthorpe <jgg@mellanox.com>, \n\tMax Gurtovoy <maxg@mellanox.com>,\n\tDan Williams <dan.j.williams@intel.com>, =?utf-8?b?SsOpcsO0bWUgR2xp?=\n\t=?utf-8?q?sse?= <jglisse@redhat.com>,\n\tBenjamin Herrenschmidt <benh@kernel.crashing.org>, Alex Williamson\n\t<alex.williamson@redhat.com>, =?utf-8?q?Christian_K=C3=B6nig?=\n\t<christian.koenig@amd.com>, Logan Gunthorpe <logang@deltatee.com>", "Date": "Thu, 30 Aug 2018 12:53:40 -0600", "Message-Id": "<20180830185352.3369-2-logang@deltatee.com>", "X-Mailer": "git-send-email 2.11.0", "In-Reply-To": "<20180830185352.3369-1-logang@deltatee.com>", "References": "<20180830185352.3369-1-logang@deltatee.com>", "MIME-Version": "1.0", "Content-Type": "text/plain; charset=UTF-8", "Content-Transfer-Encoding": "8bit", "X-SA-Exim-Connect-IP": "172.16.1.31", "X-SA-Exim-Rcpt-To": "linux-nvme@lists.infradead.org, linux-nvdimm@lists.01.org,\n\tlinux-kernel@vger.kernel.org, linux-pci@vger.kernel.org,\n\tlinux-rdma@vger.kernel.org, linux-block@vger.kernel.org,\n\tsbates@raithlin.com, hch@lst.de, sagi@grimberg.me,\n\tbhelgaas@google.com, jgg@mellanox.com, maxg@mellanox.com,\n\tkeith.busch@intel.com, dan.j.williams@intel.com,\n\tbenh@kernel.crashing.org, jglisse@redhat.com,\n\talex.williamson@redhat.com, christian.koenig@amd.com,\n\tlogang@deltatee.com", "X-SA-Exim-Mail-From": "gunthorp@deltatee.com", "X-Spam-Checker-Version": "SpamAssassin 3.4.1 (2015-04-28) on ale.deltatee.com", "X-Spam-Level": "", "X-Spam-Status": "No, score=-6.7 required=5.0 tests=ALL_TRUSTED,BAYES_00,\n\tMYRULES_FREE autolearn=no autolearn_force=no version=3.4.1", "Subject": "[PATCH v5 01/13] PCI/P2PDMA: Support peer-to-peer memory", "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-pci-owner@vger.kernel.org", "Precedence": "bulk", "List-ID": "<linux-pci.vger.kernel.org>", "X-Mailing-List": "linux-pci@vger.kernel.org" }, "content": "Some PCI devices may have memory mapped in a BAR space that's\nintended for use in peer-to-peer transactions. In order to enable\nsuch transactions the memory must be registered with ZONE_DEVICE pages\nso it can be used by DMA interfaces in existing drivers.\n\nAdd an interface for other subsystems to find and allocate chunks of P2P\nmemory as necessary to facilitate transfers between two PCI peers:\n\nint pci_p2pdma_add_client();\nstruct pci_dev *pci_p2pmem_find();\nvoid *pci_alloc_p2pmem();\n\nThe new interface requires a driver to collect a list of client devices\ninvolved in the transaction with the pci_p2pmem_add_client*() functions\nthen call pci_p2pmem_find() to obtain any suitable P2P memory. Once\nthis is done the list is bound to the memory and the calling driver is\nfree to add and remove clients as necessary (adding incompatible clients\nwill fail). With a suitable p2pmem device, memory can then be\nallocated with pci_alloc_p2pmem() for use in DMA transactions.\n\nDepending on hardware, using peer-to-peer memory may reduce the bandwidth\nof the transfer but can significantly reduce pressure on system memory.\nThis may be desirable in many cases: for example a system could be designed\nwith a small CPU connected to a PCIe switch by a small number of lanes\nwhich would maximize the number of lanes available to connect to NVMe\ndevices.\n\nThe code is designed to only utilize the p2pmem device if all the devices\ninvolved in a transfer are behind the same PCI bridge. This is because we\nhave no way of knowing whether peer-to-peer routing between PCIe Root Ports\nis supported (PCIe r4.0, sec 1.3.1). Additionally, the benefits of P2P\ntransfers that go through the RC is limited to only reducing DRAM usage\nand, in some cases, coding convenience. The PCI-SIG may be exploring\nadding a new capability bit to advertise whether this is possible for\nfuture hardware.\n\nThis commit includes significant rework and feedback from Christoph\nHellwig.\n\nSigned-off-by: Christoph Hellwig <hch@lst.de>\nSigned-off-by: Logan Gunthorpe <logang@deltatee.com>\n---\n drivers/pci/Kconfig | 17 +\n drivers/pci/Makefile | 1 +\n drivers/pci/p2pdma.c | 761 +++++++++++++++++++++++++++++++++++++++++++++\n include/linux/memremap.h | 5 +\n include/linux/mm.h | 18 ++\n include/linux/pci-p2pdma.h | 102 ++++++\n include/linux/pci.h | 4 +\n 7 files changed, 908 insertions(+)\n create mode 100644 drivers/pci/p2pdma.c\n create mode 100644 include/linux/pci-p2pdma.h", "diff": "diff --git a/drivers/pci/Kconfig b/drivers/pci/Kconfig\nindex 56ff8f6d31fc..deb68be4fdac 100644\n--- a/drivers/pci/Kconfig\n+++ b/drivers/pci/Kconfig\n@@ -132,6 +132,23 @@ config PCI_PASID\n \n \t If unsure, say N.\n \n+config PCI_P2PDMA\n+\tbool \"PCI peer-to-peer transfer support\"\n+\tdepends on PCI && ZONE_DEVICE\n+\tselect GENERIC_ALLOCATOR\n+\thelp\n+\t Enableѕ drivers to do PCI peer-to-peer transactions to and from\n+\t BARs that are exposed in other devices that are the part of\n+\t the hierarchy where peer-to-peer DMA is guaranteed by the PCI\n+\t specification to work (ie. anything below a single PCI bridge).\n+\n+\t Many PCIe root complexes do not support P2P transactions and\n+\t it's hard to tell which support it at all, so at this time,\n+\t P2P DMA transations must be between devices behind the same root\n+\t port.\n+\n+\t If unsure, say N.\n+\n config PCI_LABEL\n \tdef_bool y if (DMI || ACPI)\n \tdepends on PCI\ndiff --git a/drivers/pci/Makefile b/drivers/pci/Makefile\nindex 1b2cfe51e8d7..85f4a703b2be 100644\n--- a/drivers/pci/Makefile\n+++ b/drivers/pci/Makefile\n@@ -26,6 +26,7 @@ obj-$(CONFIG_PCI_SYSCALL)\t+= syscall.o\n obj-$(CONFIG_PCI_STUB)\t\t+= pci-stub.o\n obj-$(CONFIG_PCI_PF_STUB)\t+= pci-pf-stub.o\n obj-$(CONFIG_PCI_ECAM)\t\t+= ecam.o\n+obj-$(CONFIG_PCI_P2PDMA)\t+= p2pdma.o\n obj-$(CONFIG_XEN_PCIDEV_FRONTEND) += xen-pcifront.o\n \n # Endpoint library must be initialized before its users\ndiff --git a/drivers/pci/p2pdma.c b/drivers/pci/p2pdma.c\nnew file mode 100644\nindex 000000000000..88aaec5351cd\n--- /dev/null\n+++ b/drivers/pci/p2pdma.c\n@@ -0,0 +1,761 @@\n+// SPDX-License-Identifier: GPL-2.0\n+/*\n+ * PCI Peer 2 Peer DMA support.\n+ *\n+ * Copyright (c) 2016-2018, Logan Gunthorpe\n+ * Copyright (c) 2016-2017, Microsemi Corporation\n+ * Copyright (c) 2017, Christoph Hellwig\n+ * Copyright (c) 2018, Eideticom Inc.\n+ */\n+\n+#define pr_fmt(fmt) \"pci-p2pdma: \" fmt\n+#include <linux/pci-p2pdma.h>\n+#include <linux/module.h>\n+#include <linux/slab.h>\n+#include <linux/genalloc.h>\n+#include <linux/memremap.h>\n+#include <linux/percpu-refcount.h>\n+#include <linux/random.h>\n+#include <linux/seq_buf.h>\n+\n+struct pci_p2pdma {\n+\tstruct percpu_ref devmap_ref;\n+\tstruct completion devmap_ref_done;\n+\tstruct gen_pool *pool;\n+\tbool p2pmem_published;\n+};\n+\n+static void pci_p2pdma_percpu_release(struct percpu_ref *ref)\n+{\n+\tstruct pci_p2pdma *p2p =\n+\t\tcontainer_of(ref, struct pci_p2pdma, devmap_ref);\n+\n+\tcomplete_all(&p2p->devmap_ref_done);\n+}\n+\n+static void pci_p2pdma_percpu_kill(void *data)\n+{\n+\tstruct percpu_ref *ref = data;\n+\n+\tif (percpu_ref_is_dying(ref))\n+\t\treturn;\n+\n+\tpercpu_ref_kill(ref);\n+}\n+\n+static void pci_p2pdma_release(void *data)\n+{\n+\tstruct pci_dev *pdev = data;\n+\n+\tif (!pdev->p2pdma)\n+\t\treturn;\n+\n+\twait_for_completion(&pdev->p2pdma->devmap_ref_done);\n+\tpercpu_ref_exit(&pdev->p2pdma->devmap_ref);\n+\n+\tgen_pool_destroy(pdev->p2pdma->pool);\n+\tpdev->p2pdma = NULL;\n+}\n+\n+static int pci_p2pdma_setup(struct pci_dev *pdev)\n+{\n+\tint error = -ENOMEM;\n+\tstruct pci_p2pdma *p2p;\n+\n+\tp2p = devm_kzalloc(&pdev->dev, sizeof(*p2p), GFP_KERNEL);\n+\tif (!p2p)\n+\t\treturn -ENOMEM;\n+\n+\tp2p->pool = gen_pool_create(PAGE_SHIFT, dev_to_node(&pdev->dev));\n+\tif (!p2p->pool)\n+\t\tgoto out;\n+\n+\tinit_completion(&p2p->devmap_ref_done);\n+\terror = percpu_ref_init(&p2p->devmap_ref,\n+\t\t\tpci_p2pdma_percpu_release, 0, GFP_KERNEL);\n+\tif (error)\n+\t\tgoto out_pool_destroy;\n+\n+\tpercpu_ref_switch_to_atomic_sync(&p2p->devmap_ref);\n+\n+\terror = devm_add_action_or_reset(&pdev->dev, pci_p2pdma_release, pdev);\n+\tif (error)\n+\t\tgoto out_pool_destroy;\n+\n+\tpdev->p2pdma = p2p;\n+\n+\treturn 0;\n+\n+out_pool_destroy:\n+\tgen_pool_destroy(p2p->pool);\n+out:\n+\tdevm_kfree(&pdev->dev, p2p);\n+\treturn error;\n+}\n+\n+/**\n+ * pci_p2pdma_add_resource - add memory for use as p2p memory\n+ * @pdev: the device to add the memory to\n+ * @bar: PCI BAR to add\n+ * @size: size of the memory to add, may be zero to use the whole BAR\n+ * @offset: offset into the PCI BAR\n+ *\n+ * The memory will be given ZONE_DEVICE struct pages so that it may\n+ * be used with any DMA request.\n+ */\n+int pci_p2pdma_add_resource(struct pci_dev *pdev, int bar, size_t size,\n+\t\t\t u64 offset)\n+{\n+\tstruct dev_pagemap *pgmap;\n+\tvoid *addr;\n+\tint error;\n+\n+\tif (!(pci_resource_flags(pdev, bar) & IORESOURCE_MEM))\n+\t\treturn -EINVAL;\n+\n+\tif (offset >= pci_resource_len(pdev, bar))\n+\t\treturn -EINVAL;\n+\n+\tif (!size)\n+\t\tsize = pci_resource_len(pdev, bar) - offset;\n+\n+\tif (size + offset > pci_resource_len(pdev, bar))\n+\t\treturn -EINVAL;\n+\n+\tif (!pdev->p2pdma) {\n+\t\terror = pci_p2pdma_setup(pdev);\n+\t\tif (error)\n+\t\t\treturn error;\n+\t}\n+\n+\tpgmap = devm_kzalloc(&pdev->dev, sizeof(*pgmap), GFP_KERNEL);\n+\tif (!pgmap)\n+\t\treturn -ENOMEM;\n+\n+\tpgmap->res.start = pci_resource_start(pdev, bar) + offset;\n+\tpgmap->res.end = pgmap->res.start + size - 1;\n+\tpgmap->res.flags = pci_resource_flags(pdev, bar);\n+\tpgmap->ref = &pdev->p2pdma->devmap_ref;\n+\tpgmap->type = MEMORY_DEVICE_PCI_P2PDMA;\n+\n+\taddr = devm_memremap_pages(&pdev->dev, pgmap);\n+\tif (IS_ERR(addr)) {\n+\t\terror = PTR_ERR(addr);\n+\t\tgoto pgmap_free;\n+\t}\n+\n+\terror = gen_pool_add_virt(pdev->p2pdma->pool, (unsigned long)addr,\n+\t\t\tpci_bus_address(pdev, bar) + offset,\n+\t\t\tresource_size(&pgmap->res), dev_to_node(&pdev->dev));\n+\tif (error)\n+\t\tgoto pgmap_free;\n+\n+\terror = devm_add_action_or_reset(&pdev->dev, pci_p2pdma_percpu_kill,\n+\t\t\t\t\t &pdev->p2pdma->devmap_ref);\n+\tif (error)\n+\t\tgoto pgmap_free;\n+\n+\tpci_info(pdev, \"added peer-to-peer DMA memory %pR\\n\",\n+\t\t &pgmap->res);\n+\n+\treturn 0;\n+\n+pgmap_free:\n+\tdevres_free(pgmap);\n+\treturn error;\n+}\n+EXPORT_SYMBOL_GPL(pci_p2pdma_add_resource);\n+\n+static struct pci_dev *find_parent_pci_dev(struct device *dev)\n+{\n+\tstruct device *parent;\n+\n+\tdev = get_device(dev);\n+\n+\twhile (dev) {\n+\t\tif (dev_is_pci(dev))\n+\t\t\treturn to_pci_dev(dev);\n+\n+\t\tparent = get_device(dev->parent);\n+\t\tput_device(dev);\n+\t\tdev = parent;\n+\t}\n+\n+\treturn NULL;\n+}\n+\n+/*\n+ * Check if a PCI bridge has it's ACS redirection bits set to redirect P2P\n+ * TLPs upstream via ACS. Returns 1 if the packets will be redirected\n+ * upstream, 0 otherwise.\n+ */\n+static int pci_bridge_has_acs_redir(struct pci_dev *dev)\n+{\n+\tint pos;\n+\tu16 ctrl;\n+\n+\tpos = pci_find_ext_capability(dev, PCI_EXT_CAP_ID_ACS);\n+\tif (!pos)\n+\t\treturn 0;\n+\n+\tpci_read_config_word(dev, pos + PCI_ACS_CTRL, &ctrl);\n+\n+\tif (ctrl & (PCI_ACS_RR | PCI_ACS_CR | PCI_ACS_EC))\n+\t\treturn 1;\n+\n+\treturn 0;\n+}\n+\n+static void seq_buf_print_bus_devfn(struct seq_buf *buf, struct pci_dev *dev)\n+{\n+\tif (!buf)\n+\t\treturn;\n+\n+\tseq_buf_printf(buf, \"%04x:%02x:%02x.%x;\", pci_domain_nr(dev->bus),\n+\t\t dev->bus->number, PCI_SLOT(dev->devfn),\n+\t\t PCI_FUNC(dev->devfn));\n+}\n+\n+/*\n+ * Find the distance through the nearest common upstream bridge between\n+ * two PCI devices.\n+ *\n+ * If the two devices are the same device then 0 will be returned.\n+ *\n+ * If there are two virtual functions of the same device behind the same\n+ * bridge port then 2 will be returned (one step down to the PCIe switch,\n+ * then one step back to the same device).\n+ *\n+ * In the case where two devices are connected to the same PCIe switch, the\n+ * value 4 will be returned. This corresponds to the following PCI tree:\n+ *\n+ * -+ Root Port\n+ * \\+ Switch Upstream Port\n+ * +-+ Switch Downstream Port\n+ * + \\- Device A\n+ * \\-+ Switch Downstream Port\n+ * \\- Device B\n+ *\n+ * The distance is 4 because we traverse from Device A through the downstream\n+ * port of the switch, to the common upstream port, back up to the second\n+ * downstream port and then to Device B.\n+ *\n+ * Any two devices that don't have a common upstream bridge will return -1.\n+ * In this way devices on separate PCIe root ports will be rejected, which\n+ * is what we want for peer-to-peer seeing each PCIe root port defines a\n+ * separate hierarchy domain and there's no way to determine whether the root\n+ * complex supports forwarding between them.\n+ *\n+ * In the case where two devices are connected to different PCIe switches,\n+ * this function will still return a positive distance as long as both\n+ * switches evenutally have a common upstream bridge. Note this covers\n+ * the case of using multiple PCIe switches to achieve a desired level of\n+ * fan-out from a root port. The exact distance will be a function of the\n+ * number of switches between Device A and Device B.\n+ *\n+ * If a bridge which has any ACS redirection bits set is in the path\n+ * then this functions will return -2. This is so we reject any\n+ * cases where the TLPs are forwarded up into the root complex.\n+ * In this case, a list of all infringing bridge addresses will be\n+ * populated in acs_list (assuming it's non-null) for printk purposes.\n+ */\n+static int upstream_bridge_distance(struct pci_dev *a,\n+\t\t\t\t struct pci_dev *b,\n+\t\t\t\t struct seq_buf *acs_list)\n+{\n+\tint dist_a = 0;\n+\tint dist_b = 0;\n+\tstruct pci_dev *bb = NULL;\n+\tint acs_cnt = 0;\n+\n+\t/*\n+\t * Note, we don't need to take references to devices returned by\n+\t * pci_upstream_bridge() seeing we hold a reference to a child\n+\t * device which will already hold a reference to the upstream bridge.\n+\t */\n+\n+\twhile (a) {\n+\t\tdist_b = 0;\n+\n+\t\tif (pci_bridge_has_acs_redir(a)) {\n+\t\t\tseq_buf_print_bus_devfn(acs_list, a);\n+\t\t\tacs_cnt++;\n+\t\t}\n+\n+\t\tbb = b;\n+\n+\t\twhile (bb) {\n+\t\t\tif (a == bb)\n+\t\t\t\tgoto check_b_path_acs;\n+\n+\t\t\tbb = pci_upstream_bridge(bb);\n+\t\t\tdist_b++;\n+\t\t}\n+\n+\t\ta = pci_upstream_bridge(a);\n+\t\tdist_a++;\n+\t}\n+\n+\treturn -1;\n+\n+check_b_path_acs:\n+\tbb = b;\n+\n+\twhile (bb) {\n+\t\tif (a == bb)\n+\t\t\tbreak;\n+\n+\t\tif (pci_bridge_has_acs_redir(bb)) {\n+\t\t\tseq_buf_print_bus_devfn(acs_list, bb);\n+\t\t\tacs_cnt++;\n+\t\t}\n+\n+\t\tbb = pci_upstream_bridge(bb);\n+\t}\n+\n+\tif (acs_cnt)\n+\t\treturn -2;\n+\n+\treturn dist_a + dist_b;\n+}\n+\n+static int upstream_bridge_distance_warn(struct pci_dev *provider,\n+\t\t\t\t\t struct pci_dev *client)\n+{\n+\tstruct seq_buf acs_list;\n+\tint ret;\n+\n+\tseq_buf_init(&acs_list, kmalloc(PAGE_SIZE, GFP_KERNEL), PAGE_SIZE);\n+\n+\tret = upstream_bridge_distance(provider, client, &acs_list);\n+\tif (ret == -2) {\n+\t\tpci_warn(client, \"cannot be used for peer-to-peer DMA as ACS redirect is set between the client and provider\\n\");\n+\t\t/* Drop final semicolon */\n+\t\tacs_list.buffer[acs_list.len-1] = 0;\n+\t\tpci_warn(client, \"to disable ACS redirect for this path, add the kernel parameter: pci=disable_acs_redir=%s\\n\",\n+\t\t\t acs_list.buffer);\n+\n+\t} else if (ret < 0) {\n+\t\tpci_warn(client, \"cannot be used for peer-to-peer DMA as the client and provider do not share an upstream bridge\\n\");\n+\t}\n+\n+\tkfree(acs_list.buffer);\n+\n+\treturn ret;\n+}\n+\n+struct pci_p2pdma_client {\n+\tstruct list_head list;\n+\tstruct pci_dev *client;\n+\tstruct pci_dev *provider;\n+};\n+\n+/**\n+ * pci_p2pdma_add_client - allocate a new element in a client device list\n+ * @head: list head of p2pdma clients\n+ * @dev: device to add to the list\n+ *\n+ * This adds @dev to a list of clients used by a p2pdma device.\n+ * This list should be passed to pci_p2pmem_find(). Once pci_p2pmem_find() has\n+ * been called successfully, the list will be bound to a specific p2pdma\n+ * device and new clients can only be added to the list if they are\n+ * supported by that p2pdma device.\n+ *\n+ * The caller is expected to have a lock which protects @head as necessary\n+ * so that none of the pci_p2p functions can be called concurrently\n+ * on that list.\n+ *\n+ * Returns 0 if the client was successfully added.\n+ */\n+int pci_p2pdma_add_client(struct list_head *head, struct device *dev)\n+{\n+\tstruct pci_p2pdma_client *item, *new_item;\n+\tstruct pci_dev *provider = NULL;\n+\tstruct pci_dev *client;\n+\tint ret;\n+\n+\tif (IS_ENABLED(CONFIG_DMA_VIRT_OPS) && dev->dma_ops == &dma_virt_ops) {\n+\t\tdev_warn(dev, \"cannot be used for peer-to-peer DMA because the driver makes use of dma_virt_ops\\n\");\n+\t\treturn -ENODEV;\n+\t}\n+\n+\tclient = find_parent_pci_dev(dev);\n+\tif (!client) {\n+\t\tdev_warn(dev, \"cannot be used for peer-to-peer DMA as it is not a PCI device\\n\");\n+\t\treturn -ENODEV;\n+\t}\n+\n+\titem = list_first_entry_or_null(head, struct pci_p2pdma_client, list);\n+\tif (item && item->provider) {\n+\t\tprovider = item->provider;\n+\n+\t\tret = upstream_bridge_distance_warn(provider, client);\n+\t\tif (ret < 0) {\n+\t\t\tret = -EXDEV;\n+\t\t\tgoto put_client;\n+\t\t}\n+\t}\n+\n+\tnew_item = kzalloc(sizeof(*new_item), GFP_KERNEL);\n+\tif (!new_item) {\n+\t\tret = -ENOMEM;\n+\t\tgoto put_client;\n+\t}\n+\n+\tnew_item->client = client;\n+\tnew_item->provider = pci_dev_get(provider);\n+\n+\tlist_add_tail(&new_item->list, head);\n+\n+\treturn 0;\n+\n+put_client:\n+\tpci_dev_put(client);\n+\treturn ret;\n+}\n+EXPORT_SYMBOL_GPL(pci_p2pdma_add_client);\n+\n+static void pci_p2pdma_client_free(struct pci_p2pdma_client *item)\n+{\n+\tlist_del(&item->list);\n+\tpci_dev_put(item->client);\n+\tpci_dev_put(item->provider);\n+\tkfree(item);\n+}\n+\n+/**\n+ * pci_p2pdma_remove_client - remove and free a p2pdma client\n+ * @head: list head of p2pdma clients\n+ * @dev: device to remove from the list\n+ *\n+ * This removes @dev from a list of clients used by a p2pdma device.\n+ * The caller is expected to have a lock which protects @head as necessary\n+ * so that none of the pci_p2p functions can be called concurrently\n+ * on that list.\n+ */\n+void pci_p2pdma_remove_client(struct list_head *head, struct device *dev)\n+{\n+\tstruct pci_p2pdma_client *pos, *tmp;\n+\tstruct pci_dev *pdev;\n+\n+\tpdev = find_parent_pci_dev(dev);\n+\tif (!pdev)\n+\t\treturn;\n+\n+\tlist_for_each_entry_safe(pos, tmp, head, list) {\n+\t\tif (pos->client != pdev)\n+\t\t\tcontinue;\n+\n+\t\tpci_p2pdma_client_free(pos);\n+\t}\n+\n+\tpci_dev_put(pdev);\n+}\n+EXPORT_SYMBOL_GPL(pci_p2pdma_remove_client);\n+\n+/**\n+ * pci_p2pdma_client_list_free - free an entire list of p2pdma clients\n+ * @head: list head of p2pdma clients\n+ *\n+ * This removes all devices in a list of clients used by a p2pdma device.\n+ * The caller is expected to have a lock which protects @head as necessary\n+ * so that none of the pci_p2pdma functions can be called concurrently\n+ * on that list.\n+ */\n+void pci_p2pdma_client_list_free(struct list_head *head)\n+{\n+\tstruct pci_p2pdma_client *pos, *tmp;\n+\n+\tlist_for_each_entry_safe(pos, tmp, head, list)\n+\t\tpci_p2pdma_client_free(pos);\n+}\n+EXPORT_SYMBOL_GPL(pci_p2pdma_client_list_free);\n+\n+/**\n+ * pci_p2pdma_distance - Determive the cumulative distance between\n+ *\ta p2pdma provider and the clients in use.\n+ * @provider: p2pdma provider to check against the client list\n+ * @clients: list of devices to check (NULL-terminated)\n+ * @verbose: if true, print warnings for devices when we return -1\n+ *\n+ * Returns -1 if any of the clients are not compatible (behind the same\n+ * root port as the provider), otherwise returns a positive number where\n+ * the lower number is the preferrable choice. (If there's one client\n+ * that's the same as the provider it will return 0, which is best choice).\n+ *\n+ * For now, \"compatible\" means the provider and the clients are all behind\n+ * the same PCI root port. This cuts out cases that may work but is safest\n+ * for the user. Future work can expand this to white-list root complexes that\n+ * can safely forward between each ports.\n+ */\n+int pci_p2pdma_distance(struct pci_dev *provider, struct list_head *clients,\n+\t\t\tbool verbose)\n+{\n+\tstruct pci_p2pdma_client *pos;\n+\tint ret;\n+\tint distance = 0;\n+\tbool not_supported = false;\n+\n+\tif (list_empty(clients))\n+\t\treturn -1;\n+\n+\tlist_for_each_entry(pos, clients, list) {\n+\t\tif (verbose)\n+\t\t\tret = upstream_bridge_distance_warn(provider,\n+\t\t\t\t\t\t\t pos->client);\n+\t\telse\n+\t\t\tret = upstream_bridge_distance(provider, pos->client,\n+\t\t\t\t\t\t NULL);\n+\n+\t\tif (ret < 0)\n+\t\t\tnot_supported = true;\n+\n+\t\tif (not_supported && !verbose)\n+\t\t\tbreak;\n+\n+\t\tdistance += ret;\n+\t}\n+\n+\tif (not_supported)\n+\t\treturn -1;\n+\n+\treturn distance;\n+}\n+EXPORT_SYMBOL_GPL(pci_p2pdma_distance);\n+\n+/**\n+ * pci_p2pdma_assign_provider - Check compatibily (as per pci_p2pdma_distance)\n+ *\tand assign a provider to a list of clients\n+ * @provider: p2pdma provider to assign to the client list\n+ * @clients: list of devices to check (NULL-terminated)\n+ *\n+ * Returns false if any of the clients are not compatible, true if the\n+ * provider was successfully assigned to the clients.\n+ */\n+bool pci_p2pdma_assign_provider(struct pci_dev *provider,\n+\t\t\t\tstruct list_head *clients)\n+{\n+\tstruct pci_p2pdma_client *pos;\n+\n+\tif (pci_p2pdma_distance(provider, clients, true) < 0)\n+\t\treturn false;\n+\n+\tlist_for_each_entry(pos, clients, list)\n+\t\tpos->provider = provider;\n+\n+\treturn true;\n+}\n+EXPORT_SYMBOL_GPL(pci_p2pdma_assign_provider);\n+\n+/**\n+ * pci_has_p2pmem - check if a given PCI device has published any p2pmem\n+ * @pdev: PCI device to check\n+ */\n+bool pci_has_p2pmem(struct pci_dev *pdev)\n+{\n+\treturn pdev->p2pdma && pdev->p2pdma->p2pmem_published;\n+}\n+EXPORT_SYMBOL_GPL(pci_has_p2pmem);\n+\n+/**\n+ * pci_p2pmem_find - find a peer-to-peer DMA memory device compatible with\n+ *\tthe specified list of clients and shortest distance (as determined\n+ *\tby pci_p2pmem_dma())\n+ * @clients: list of devices to check (NULL-terminated)\n+ *\n+ * If multiple devices are behind the same switch, the one \"closest\" to the\n+ * client devices in use will be chosen first. (So if one of the providers are\n+ * the same as one of the clients, that provider will be used ahead of any\n+ * other providers that are unrelated). If multiple providers are an equal\n+ * distance away, one will be chosen at random.\n+ *\n+ * Returns a pointer to the PCI device with a reference taken (use pci_dev_put\n+ * to return the reference) or NULL if no compatible device is found. The\n+ * found provider will also be assigned to the client list.\n+ */\n+struct pci_dev *pci_p2pmem_find(struct list_head *clients)\n+{\n+\tstruct pci_dev *pdev = NULL;\n+\tstruct pci_p2pdma_client *pos;\n+\tint distance;\n+\tint closest_distance = INT_MAX;\n+\tstruct pci_dev **closest_pdevs;\n+\tint dev_cnt = 0;\n+\tconst int max_devs = PAGE_SIZE / sizeof(*closest_pdevs);\n+\tint i;\n+\n+\tclosest_pdevs = kmalloc(PAGE_SIZE, GFP_KERNEL);\n+\n+\twhile ((pdev = pci_get_device(PCI_ANY_ID, PCI_ANY_ID, pdev))) {\n+\t\tif (!pci_has_p2pmem(pdev))\n+\t\t\tcontinue;\n+\n+\t\tdistance = pci_p2pdma_distance(pdev, clients, false);\n+\t\tif (distance < 0 || distance > closest_distance)\n+\t\t\tcontinue;\n+\n+\t\tif (distance == closest_distance && dev_cnt >= max_devs)\n+\t\t\tcontinue;\n+\n+\t\tif (distance < closest_distance) {\n+\t\t\tfor (i = 0; i < dev_cnt; i++)\n+\t\t\t\tpci_dev_put(closest_pdevs[i]);\n+\n+\t\t\tdev_cnt = 0;\n+\t\t\tclosest_distance = distance;\n+\t\t}\n+\n+\t\tclosest_pdevs[dev_cnt++] = pci_dev_get(pdev);\n+\t}\n+\n+\tif (dev_cnt)\n+\t\tpdev = pci_dev_get(closest_pdevs[prandom_u32_max(dev_cnt)]);\n+\n+\tfor (i = 0; i < dev_cnt; i++)\n+\t\tpci_dev_put(closest_pdevs[i]);\n+\n+\tif (pdev)\n+\t\tlist_for_each_entry(pos, clients, list)\n+\t\t\tpos->provider = pdev;\n+\n+\tkfree(closest_pdevs);\n+\treturn pdev;\n+}\n+EXPORT_SYMBOL_GPL(pci_p2pmem_find);\n+\n+/**\n+ * pci_alloc_p2p_mem - allocate peer-to-peer DMA memory\n+ * @pdev: the device to allocate memory from\n+ * @size: number of bytes to allocate\n+ *\n+ * Returns the allocated memory or NULL on error.\n+ */\n+void *pci_alloc_p2pmem(struct pci_dev *pdev, size_t size)\n+{\n+\tvoid *ret;\n+\n+\tif (unlikely(!pdev->p2pdma))\n+\t\treturn NULL;\n+\n+\tif (unlikely(!percpu_ref_tryget_live(&pdev->p2pdma->devmap_ref)))\n+\t\treturn NULL;\n+\n+\tret = (void *)gen_pool_alloc(pdev->p2pdma->pool, size);\n+\n+\tif (unlikely(!ret))\n+\t\tpercpu_ref_put(&pdev->p2pdma->devmap_ref);\n+\n+\treturn ret;\n+}\n+EXPORT_SYMBOL_GPL(pci_alloc_p2pmem);\n+\n+/**\n+ * pci_free_p2pmem - allocate peer-to-peer DMA memory\n+ * @pdev: the device the memory was allocated from\n+ * @addr: address of the memory that was allocated\n+ * @size: number of bytes that was allocated\n+ */\n+void pci_free_p2pmem(struct pci_dev *pdev, void *addr, size_t size)\n+{\n+\tgen_pool_free(pdev->p2pdma->pool, (uintptr_t)addr, size);\n+\tpercpu_ref_put(&pdev->p2pdma->devmap_ref);\n+}\n+EXPORT_SYMBOL_GPL(pci_free_p2pmem);\n+\n+/**\n+ * pci_virt_to_bus - return the PCI bus address for a given virtual\n+ *\taddress obtained with pci_alloc_p2pmem()\n+ * @pdev: the device the memory was allocated from\n+ * @addr: address of the memory that was allocated\n+ */\n+pci_bus_addr_t pci_p2pmem_virt_to_bus(struct pci_dev *pdev, void *addr)\n+{\n+\tif (!addr)\n+\t\treturn 0;\n+\tif (!pdev->p2pdma)\n+\t\treturn 0;\n+\n+\t/*\n+\t * Note: when we added the memory to the pool we used the PCI\n+\t * bus address as the physical address. So gen_pool_virt_to_phys()\n+\t * actually returns the bus address despite the misleading name.\n+\t */\n+\treturn gen_pool_virt_to_phys(pdev->p2pdma->pool, (unsigned long)addr);\n+}\n+EXPORT_SYMBOL_GPL(pci_p2pmem_virt_to_bus);\n+\n+/**\n+ * pci_p2pmem_alloc_sgl - allocate peer-to-peer DMA memory in a scatterlist\n+ * @pdev: the device to allocate memory from\n+ * @sgl: the allocated scatterlist\n+ * @nents: the number of SG entries in the list\n+ * @length: number of bytes to allocate\n+ *\n+ * Returns 0 on success\n+ */\n+struct scatterlist *pci_p2pmem_alloc_sgl(struct pci_dev *pdev,\n+\t\t\t\t\t unsigned int *nents, u32 length)\n+{\n+\tstruct scatterlist *sg;\n+\tvoid *addr;\n+\n+\tsg = kzalloc(sizeof(*sg), GFP_KERNEL);\n+\tif (!sg)\n+\t\treturn NULL;\n+\n+\tsg_init_table(sg, 1);\n+\n+\taddr = pci_alloc_p2pmem(pdev, length);\n+\tif (!addr)\n+\t\tgoto out_free_sg;\n+\n+\tsg_set_buf(sg, addr, length);\n+\t*nents = 1;\n+\treturn sg;\n+\n+out_free_sg:\n+\tkfree(sg);\n+\treturn NULL;\n+}\n+EXPORT_SYMBOL_GPL(pci_p2pmem_alloc_sgl);\n+\n+/**\n+ * pci_p2pmem_free_sgl - free a scatterlist allocated by pci_p2pmem_alloc_sgl()\n+ * @pdev: the device to allocate memory from\n+ * @sgl: the allocated scatterlist\n+ * @nents: the number of SG entries in the list\n+ */\n+void pci_p2pmem_free_sgl(struct pci_dev *pdev, struct scatterlist *sgl)\n+{\n+\tstruct scatterlist *sg;\n+\tint count;\n+\n+\tfor_each_sg(sgl, sg, INT_MAX, count) {\n+\t\tif (!sg)\n+\t\t\tbreak;\n+\n+\t\tpci_free_p2pmem(pdev, sg_virt(sg), sg->length);\n+\t}\n+\tkfree(sgl);\n+}\n+EXPORT_SYMBOL_GPL(pci_p2pmem_free_sgl);\n+\n+/**\n+ * pci_p2pmem_publish - publish the peer-to-peer DMA memory for use by\n+ *\tother devices with pci_p2pmem_find()\n+ * @pdev: the device with peer-to-peer DMA memory to publish\n+ * @publish: set to true to publish the memory, false to unpublish it\n+ *\n+ * Published memory can be used by other PCI device drivers for\n+ * peer-2-peer DMA operations. Non-published memory is reserved for\n+ * exlusive use of the device driver that registers the peer-to-peer\n+ * memory.\n+ */\n+void pci_p2pmem_publish(struct pci_dev *pdev, bool publish)\n+{\n+\tif (publish && !pdev->p2pdma)\n+\t\treturn;\n+\n+\tpdev->p2pdma->p2pmem_published = publish;\n+}\n+EXPORT_SYMBOL_GPL(pci_p2pmem_publish);\ndiff --git a/include/linux/memremap.h b/include/linux/memremap.h\nindex f91f9e763557..9553370ebdad 100644\n--- a/include/linux/memremap.h\n+++ b/include/linux/memremap.h\n@@ -53,11 +53,16 @@ struct vmem_altmap {\n * wakeup event whenever a page is unpinned and becomes idle. This\n * wakeup is used to coordinate physical address space management (ex:\n * fs truncate/hole punch) vs pinned pages (ex: device dma).\n+ *\n+ * MEMORY_DEVICE_PCI_P2PDMA:\n+ * Device memory residing in a PCI BAR intended for use with Peer-to-Peer\n+ * transactions.\n */\n enum memory_type {\n \tMEMORY_DEVICE_PRIVATE = 1,\n \tMEMORY_DEVICE_PUBLIC,\n \tMEMORY_DEVICE_FS_DAX,\n+\tMEMORY_DEVICE_PCI_P2PDMA,\n };\n \n /*\ndiff --git a/include/linux/mm.h b/include/linux/mm.h\nindex a61ebe8ad4ca..2055df412a77 100644\n--- a/include/linux/mm.h\n+++ b/include/linux/mm.h\n@@ -890,6 +890,19 @@ static inline bool is_device_public_page(const struct page *page)\n \t\tpage->pgmap->type == MEMORY_DEVICE_PUBLIC;\n }\n \n+#ifdef CONFIG_PCI_P2PDMA\n+static inline bool is_pci_p2pdma_page(const struct page *page)\n+{\n+\treturn is_zone_device_page(page) &&\n+\t\tpage->pgmap->type == MEMORY_DEVICE_PCI_P2PDMA;\n+}\n+#else /* CONFIG_PCI_P2PDMA */\n+static inline bool is_pci_p2pdma_page(const struct page *page)\n+{\n+\treturn false;\n+}\n+#endif /* CONFIG_PCI_P2PDMA */\n+\n #else /* CONFIG_DEV_PAGEMAP_OPS */\n static inline void dev_pagemap_get_ops(void)\n {\n@@ -913,6 +926,11 @@ static inline bool is_device_public_page(const struct page *page)\n {\n \treturn false;\n }\n+\n+static inline bool is_pci_p2pdma_page(const struct page *page)\n+{\n+\treturn false;\n+}\n #endif /* CONFIG_DEV_PAGEMAP_OPS */\n \n static inline void get_page(struct page *page)\ndiff --git a/include/linux/pci-p2pdma.h b/include/linux/pci-p2pdma.h\nnew file mode 100644\nindex 000000000000..7b2b0f547528\n--- /dev/null\n+++ b/include/linux/pci-p2pdma.h\n@@ -0,0 +1,102 @@\n+/* SPDX-License-Identifier: GPL-2.0 */\n+/*\n+ * PCI Peer 2 Peer DMA support.\n+ *\n+ * Copyright (c) 2016-2018, Logan Gunthorpe\n+ * Copyright (c) 2016-2017, Microsemi Corporation\n+ * Copyright (c) 2017, Christoph Hellwig\n+ * Copyright (c) 2018, Eideticom Inc.\n+ *\n+ */\n+\n+#ifndef _LINUX_PCI_P2PDMA_H\n+#define _LINUX_PCI_P2PDMA_H\n+\n+#include <linux/pci.h>\n+\n+struct block_device;\n+struct scatterlist;\n+\n+#ifdef CONFIG_PCI_P2PDMA\n+int pci_p2pdma_add_resource(struct pci_dev *pdev, int bar, size_t size,\n+\t\tu64 offset);\n+int pci_p2pdma_add_client(struct list_head *head, struct device *dev);\n+void pci_p2pdma_remove_client(struct list_head *head, struct device *dev);\n+void pci_p2pdma_client_list_free(struct list_head *head);\n+int pci_p2pdma_distance(struct pci_dev *provider, struct list_head *clients,\n+\t\t\tbool verbose);\n+bool pci_p2pdma_assign_provider(struct pci_dev *provider,\n+\t\t\t\tstruct list_head *clients);\n+bool pci_has_p2pmem(struct pci_dev *pdev);\n+struct pci_dev *pci_p2pmem_find(struct list_head *clients);\n+void *pci_alloc_p2pmem(struct pci_dev *pdev, size_t size);\n+void pci_free_p2pmem(struct pci_dev *pdev, void *addr, size_t size);\n+pci_bus_addr_t pci_p2pmem_virt_to_bus(struct pci_dev *pdev, void *addr);\n+struct scatterlist *pci_p2pmem_alloc_sgl(struct pci_dev *pdev,\n+\t\t\t\t\t unsigned int *nents, u32 length);\n+void pci_p2pmem_free_sgl(struct pci_dev *pdev, struct scatterlist *sgl);\n+void pci_p2pmem_publish(struct pci_dev *pdev, bool publish);\n+#else /* CONFIG_PCI_P2PDMA */\n+static inline int pci_p2pdma_add_resource(struct pci_dev *pdev, int bar,\n+\t\tsize_t size, u64 offset)\n+{\n+\treturn -EOPNOTSUPP;\n+}\n+static inline int pci_p2pdma_add_client(struct list_head *head,\n+\t\tstruct device *dev)\n+{\n+\treturn 0;\n+}\n+static inline void pci_p2pdma_remove_client(struct list_head *head,\n+\t\tstruct device *dev)\n+{\n+}\n+static inline void pci_p2pdma_client_list_free(struct list_head *head)\n+{\n+}\n+static inline int pci_p2pdma_distance(struct pci_dev *provider,\n+\t\t\t\t struct list_head *clients,\n+\t\t\t\t bool verbose)\n+{\n+\treturn -1;\n+}\n+static inline bool pci_p2pdma_assign_provider(struct pci_dev *provider,\n+\t\t\t\t\t struct list_head *clients)\n+{\n+\treturn false;\n+}\n+static inline bool pci_has_p2pmem(struct pci_dev *pdev)\n+{\n+\treturn false;\n+}\n+static inline struct pci_dev *pci_p2pmem_find(struct list_head *clients)\n+{\n+\treturn NULL;\n+}\n+static inline void *pci_alloc_p2pmem(struct pci_dev *pdev, size_t size)\n+{\n+\treturn NULL;\n+}\n+static inline void pci_free_p2pmem(struct pci_dev *pdev, void *addr,\n+\t\tsize_t size)\n+{\n+}\n+static inline pci_bus_addr_t pci_p2pmem_virt_to_bus(struct pci_dev *pdev,\n+\t\t\t\t\t\t void *addr)\n+{\n+\treturn 0;\n+}\n+static inline struct scatterlist *pci_p2pmem_alloc_sgl(struct pci_dev *pdev,\n+\t\tunsigned int *nents, u32 length)\n+{\n+\treturn NULL;\n+}\n+static inline void pci_p2pmem_free_sgl(struct pci_dev *pdev,\n+\t\tstruct scatterlist *sgl)\n+{\n+}\n+static inline void pci_p2pmem_publish(struct pci_dev *pdev, bool publish)\n+{\n+}\n+#endif /* CONFIG_PCI_P2PDMA */\n+#endif /* _LINUX_PCI_P2P_H */\ndiff --git a/include/linux/pci.h b/include/linux/pci.h\nindex e72ca8dd6241..5d95dbf21f4a 100644\n--- a/include/linux/pci.h\n+++ b/include/linux/pci.h\n@@ -281,6 +281,7 @@ struct pcie_link_state;\n struct pci_vpd;\n struct pci_sriov;\n struct pci_ats;\n+struct pci_p2pdma;\n \n /* The pci_dev structure describes PCI devices */\n struct pci_dev {\n@@ -439,6 +440,9 @@ struct pci_dev {\n #ifdef CONFIG_PCI_PASID\n \tu16\t\tpasid_features;\n #endif\n+#ifdef CONFIG_PCI_P2PDMA\n+\tstruct pci_p2pdma *p2pdma;\n+#endif\n \tphys_addr_t\trom;\t\t/* Physical address if not from BAR */\n \tsize_t\t\tromlen;\t\t/* Length if not from BAR */\n \tchar\t\t*driver_override; /* Driver name to force a match */\n", "prefixes": [ "v5", "01/13" ] }