get:
Show a patch.

patch:
Update a patch.

put:
Update a patch.

GET /api/patches/40538/?format=api
HTTP 200 OK
Allow: GET, PUT, PATCH, HEAD, OPTIONS
Content-Type: application/json
Vary: Accept

{
    "id": 40538,
    "url": "https://patches.dpdk.org/api/patches/40538/?format=api",
    "web_url": "https://patches.dpdk.org/project/dpdk/patch/ca9f07f8d5adcb6cf1a410360e9adc8cf68cae1b.1527764061.git.anatoly.burakov@intel.com/",
    "project": {
        "id": 1,
        "url": "https://patches.dpdk.org/api/projects/1/?format=api",
        "name": "DPDK",
        "link_name": "dpdk",
        "list_id": "dev.dpdk.org",
        "list_email": "dev@dpdk.org",
        "web_url": "http://core.dpdk.org",
        "scm_url": "git://dpdk.org/dpdk",
        "webscm_url": "http://git.dpdk.org/dpdk",
        "list_archive_url": "https://inbox.dpdk.org/dev",
        "list_archive_url_format": "https://inbox.dpdk.org/dev/{}",
        "commit_url_format": ""
    },
    "msgid": "<ca9f07f8d5adcb6cf1a410360e9adc8cf68cae1b.1527764061.git.anatoly.burakov@intel.com>",
    "list_archive_url": "https://inbox.dpdk.org/dev/ca9f07f8d5adcb6cf1a410360e9adc8cf68cae1b.1527764061.git.anatoly.burakov@intel.com",
    "date": "2018-05-31T10:57:50",
    "name": "[dpdk-dev,RFC,3/3] bus/pci: use the new device memory API for BAR mapping",
    "commit_ref": null,
    "pull_url": null,
    "state": "rejected",
    "archived": true,
    "hash": "8bc1f956c61b7d3bb08a931211a700b9dcea56db",
    "submitter": {
        "id": 4,
        "url": "https://patches.dpdk.org/api/people/4/?format=api",
        "name": "Anatoly Burakov",
        "email": "anatoly.burakov@intel.com"
    },
    "delegate": {
        "id": 1,
        "url": "https://patches.dpdk.org/api/users/1/?format=api",
        "username": "tmonjalo",
        "first_name": "Thomas",
        "last_name": "Monjalon",
        "email": "thomas@monjalon.net"
    },
    "mbox": "https://patches.dpdk.org/project/dpdk/patch/ca9f07f8d5adcb6cf1a410360e9adc8cf68cae1b.1527764061.git.anatoly.burakov@intel.com/mbox/",
    "series": [],
    "comments": "https://patches.dpdk.org/api/patches/40538/comments/",
    "check": "fail",
    "checks": "https://patches.dpdk.org/api/patches/40538/checks/",
    "tags": {},
    "related": [],
    "headers": {
        "Return-Path": "<dev-bounces@dpdk.org>",
        "X-Original-To": "patchwork@dpdk.org",
        "Delivered-To": "patchwork@dpdk.org",
        "Received": [
            "from [92.243.14.124] (localhost [127.0.0.1])\n\tby dpdk.org (Postfix) with ESMTP id 93ABB5681;\n\tThu, 31 May 2018 12:58:13 +0200 (CEST)",
            "from mga02.intel.com (mga02.intel.com [134.134.136.20])\n\tby dpdk.org (Postfix) with ESMTP id 093144C74\n\tfor <dev@dpdk.org>; Thu, 31 May 2018 12:58:06 +0200 (CEST)",
            "from orsmga002.jf.intel.com ([10.7.209.21])\n\tby orsmga101.jf.intel.com with ESMTP/TLS/DHE-RSA-AES256-GCM-SHA384;\n\t31 May 2018 03:58:03 -0700",
            "from irvmail001.ir.intel.com ([163.33.26.43])\n\tby orsmga002.jf.intel.com with ESMTP; 31 May 2018 03:58:00 -0700",
            "from sivswdev01.ir.intel.com (sivswdev01.ir.intel.com\n\t[10.237.217.45])\n\tby irvmail001.ir.intel.com (8.14.3/8.13.6/MailSET/Hub) with ESMTP id\n\tw4VAw0gR004135; Thu, 31 May 2018 11:58:00 +0100",
            "from sivswdev01.ir.intel.com (localhost [127.0.0.1])\n\tby sivswdev01.ir.intel.com with ESMTP id w4VAw0Jc002516;\n\tThu, 31 May 2018 11:58:00 +0100",
            "(from aburakov@localhost)\n\tby sivswdev01.ir.intel.com with LOCAL id w4VAw0Rq002512;\n\tThu, 31 May 2018 11:58:00 +0100"
        ],
        "X-Amp-Result": "SKIPPED(no attachment in message)",
        "X-Amp-File-Uploaded": "False",
        "X-ExtLoop1": "1",
        "X-IronPort-AV": "E=Sophos;i=\"5.49,463,1520924400\"; d=\"scan'208\";a=\"63167116\"",
        "From": "Anatoly Burakov <anatoly.burakov@intel.com>",
        "To": "dev@dpdk.org",
        "Cc": "Ferruh Yigit <ferruh.yigit@intel.com>,\n\tGaetan Rivet <gaetan.rivet@6wind.com>, thomas@monjalon.net,\n\themant.agrawal@nxp.com, bruce.richardson@intel.com,\n\tkonstantin.ananyev@intel.com, jerin.jacob@caviumnetworks.com,\n\tolivier.matz@6wind.com, stephen@networkplumber.org,\n\tnhorman@tuxdriver.com, david.marchand@6wind.com,\n\tgowrishankar.m@linux.vnet.ibm.com",
        "Date": "Thu, 31 May 2018 11:57:50 +0100",
        "Message-Id": "<ca9f07f8d5adcb6cf1a410360e9adc8cf68cae1b.1527764061.git.anatoly.burakov@intel.com>",
        "X-Mailer": "git-send-email 1.7.0.7",
        "In-Reply-To": [
            "<cover.1527764061.git.anatoly.burakov@intel.com>",
            "<cover.1527764061.git.anatoly.burakov@intel.com>"
        ],
        "References": [
            "<cover.1527764061.git.anatoly.burakov@intel.com>",
            "<cover.1527764061.git.anatoly.burakov@intel.com>"
        ],
        "Subject": "[dpdk-dev] [RFC 3/3] bus/pci: use the new device memory API for BAR\n\tmapping",
        "X-BeenThere": "dev@dpdk.org",
        "X-Mailman-Version": "2.1.15",
        "Precedence": "list",
        "List-Id": "DPDK patches and discussions <dev.dpdk.org>",
        "List-Unsubscribe": "<https://dpdk.org/ml/options/dev>,\n\t<mailto:dev-request@dpdk.org?subject=unsubscribe>",
        "List-Archive": "<http://dpdk.org/ml/archives/dev/>",
        "List-Post": "<mailto:dev@dpdk.org>",
        "List-Help": "<mailto:dev-request@dpdk.org?subject=help>",
        "List-Subscribe": "<https://dpdk.org/ml/listinfo/dev>,\n\t<mailto:dev-request@dpdk.org?subject=subscribe>",
        "Errors-To": "dev-bounces@dpdk.org",
        "Sender": "\"dev\" <dev-bounces@dpdk.org>"
    },
    "content": "Adjust PCI infrastructure to reserve device memory through the\nnew device memory API. Any hotplug event will reserve memory, any\nhot-unplug event will release memory back to the system.\n\nThis allows for more reliable PCI mappings in secondary processes,\nand will be crucial to support multiprocess hotplug.\n\nSigned-off-by: Anatoly Burakov <anatoly.burakov@intel.com>\n---\n drivers/bus/pci/linux/pci_init.h |  1 -\n drivers/bus/pci/linux/pci_uio.c  | 11 +----------\n drivers/bus/pci/linux/pci_vfio.c | 27 ++++++++++++---------------\n lib/librte_pci/Makefile          |  1 +\n lib/librte_pci/rte_pci.c         | 20 +++++++++++++++++++-\n 5 files changed, 33 insertions(+), 27 deletions(-)",
    "diff": "diff --git a/drivers/bus/pci/linux/pci_init.h b/drivers/bus/pci/linux/pci_init.h\nindex c2e603a37..bc9279c66 100644\n--- a/drivers/bus/pci/linux/pci_init.h\n+++ b/drivers/bus/pci/linux/pci_init.h\n@@ -14,7 +14,6 @@\n /*\n  * Helper function to map PCI resources right after hugepages in virtual memory\n  */\n-extern void *pci_map_addr;\n void *pci_find_max_end_va(void);\n \n /* parse one line of the \"resource\" sysfs file (note that the 'line'\ndiff --git a/drivers/bus/pci/linux/pci_uio.c b/drivers/bus/pci/linux/pci_uio.c\nindex d423e4bb0..dbf108b6f 100644\n--- a/drivers/bus/pci/linux/pci_uio.c\n+++ b/drivers/bus/pci/linux/pci_uio.c\n@@ -26,8 +26,6 @@\n #include \"eal_filesystem.h\"\n #include \"pci_init.h\"\n \n-void *pci_map_addr = NULL;\n-\n #define OFF_MAX              ((uint64_t)(off_t)-1)\n \n int\n@@ -316,19 +314,12 @@ pci_uio_map_resource_by_index(struct rte_pci_device *dev, int res_idx,\n \t\tgoto error;\n \t}\n \n-\t/* try mapping somewhere close to the end of hugepages */\n-\tif (pci_map_addr == NULL)\n-\t\tpci_map_addr = pci_find_max_end_va();\n-\n-\tmapaddr = pci_map_resource(pci_map_addr, fd, 0,\n+\tmapaddr = pci_map_resource(NULL, fd, 0,\n \t\t\t(size_t)dev->mem_resource[res_idx].len, 0);\n \tclose(fd);\n \tif (mapaddr == MAP_FAILED)\n \t\tgoto error;\n \n-\tpci_map_addr = RTE_PTR_ADD(mapaddr,\n-\t\t\t(size_t)dev->mem_resource[res_idx].len);\n-\n \tmaps[map_idx].phaddr = dev->mem_resource[res_idx].phys_addr;\n \tmaps[map_idx].size = dev->mem_resource[res_idx].len;\n \tmaps[map_idx].addr = mapaddr;\ndiff --git a/drivers/bus/pci/linux/pci_vfio.c b/drivers/bus/pci/linux/pci_vfio.c\nindex aeeaa9ed8..f390ea37a 100644\n--- a/drivers/bus/pci/linux/pci_vfio.c\n+++ b/drivers/bus/pci/linux/pci_vfio.c\n@@ -324,7 +324,7 @@ pci_rte_vfio_setup_device(struct rte_pci_device *dev, int vfio_dev_fd)\n \n static int\n pci_vfio_mmap_bar(int vfio_dev_fd, struct mapped_pci_resource *vfio_res,\n-\t\tint bar_index, int additional_flags)\n+\t\tint bar_index)\n {\n \tstruct memreg {\n \t\tunsigned long offset, size;\n@@ -371,9 +371,14 @@ pci_vfio_mmap_bar(int vfio_dev_fd, struct mapped_pci_resource *vfio_res,\n \t\tmemreg[0].size = bar->size;\n \t}\n \n-\t/* reserve the address using an inaccessible mapping */\n-\tbar_addr = mmap(bar->addr, bar->size, 0, MAP_PRIVATE |\n-\t\t\tMAP_ANONYMOUS | additional_flags, -1, 0);\n+\tif (bar->addr == NULL) {\n+\t\tbar_addr = rte_mem_dev_memory_alloc(bar->size, 0);\n+\t\tif (bar_addr == NULL) {\n+\t\t\tRTE_LOG(ERR, EAL, \"%s(): cannot reserve space for device\\n\",\n+\t\t\t\t__func__);\n+\t\t\treturn -1;\n+\t\t}\n+\t}\n \tif (bar_addr != MAP_FAILED) {\n \t\tvoid *map_addr = NULL;\n \t\tif (memreg[0].size) {\n@@ -469,7 +474,6 @@ pci_vfio_map_resource_primary(struct rte_pci_device *dev)\n \n \tfor (i = 0; i < (int) vfio_res->nb_maps; i++) {\n \t\tstruct vfio_region_info reg = { .argsz = sizeof(reg) };\n-\t\tvoid *bar_addr;\n \n \t\treg.index = i;\n \n@@ -494,19 +498,12 @@ pci_vfio_map_resource_primary(struct rte_pci_device *dev)\n \t\tif ((reg.flags & VFIO_REGION_INFO_FLAG_MMAP) == 0)\n \t\t\tcontinue;\n \n-\t\t/* try mapping somewhere close to the end of hugepages */\n-\t\tif (pci_map_addr == NULL)\n-\t\t\tpci_map_addr = pci_find_max_end_va();\n-\n-\t\tbar_addr = pci_map_addr;\n-\t\tpci_map_addr = RTE_PTR_ADD(bar_addr, (size_t) reg.size);\n-\n-\t\tmaps[i].addr = bar_addr;\n+\t\tmaps[i].addr = NULL;\n \t\tmaps[i].offset = reg.offset;\n \t\tmaps[i].size = reg.size;\n \t\tmaps[i].path = NULL; /* vfio doesn't have per-resource paths */\n \n-\t\tret = pci_vfio_mmap_bar(vfio_dev_fd, vfio_res, i, 0);\n+\t\tret = pci_vfio_mmap_bar(vfio_dev_fd, vfio_res, i);\n \t\tif (ret < 0) {\n \t\t\tRTE_LOG(ERR, EAL, \"  %s mapping BAR%i failed: %s\\n\",\n \t\t\t\t\tpci_addr, i, strerror(errno));\n@@ -574,7 +571,7 @@ pci_vfio_map_resource_secondary(struct rte_pci_device *dev)\n \tmaps = vfio_res->maps;\n \n \tfor (i = 0; i < (int) vfio_res->nb_maps; i++) {\n-\t\tret = pci_vfio_mmap_bar(vfio_dev_fd, vfio_res, i, MAP_FIXED);\n+\t\tret = pci_vfio_mmap_bar(vfio_dev_fd, vfio_res, i);\n \t\tif (ret < 0) {\n \t\t\tRTE_LOG(ERR, EAL, \"  %s mapping BAR%i failed: %s\\n\",\n \t\t\t\t\tpci_addr, i, strerror(errno));\ndiff --git a/lib/librte_pci/Makefile b/lib/librte_pci/Makefile\nindex 94a632670..f996fe33c 100644\n--- a/lib/librte_pci/Makefile\n+++ b/lib/librte_pci/Makefile\n@@ -8,6 +8,7 @@ LIB = librte_pci.a\n \n CFLAGS := -I$(SRCDIR) $(CFLAGS)\n CFLAGS += $(WERROR_FLAGS) -O3\n+CFLAGS += -DALLOW_EXPERIMENTAL_API\n LDLIBS += -lrte_eal\n \n EXPORT_MAP := rte_pci_version.map\ndiff --git a/lib/librte_pci/rte_pci.c b/lib/librte_pci/rte_pci.c\nindex 530738dbd..c425a624e 100644\n--- a/lib/librte_pci/rte_pci.c\n+++ b/lib/librte_pci/rte_pci.c\n@@ -151,6 +151,16 @@ pci_map_resource(void *requested_addr, int fd, off_t offset, size_t size,\n {\n \tvoid *mapaddr;\n \n+\tif (requested_addr == NULL) {\n+\t\trequested_addr = rte_mem_dev_memory_alloc(size, 0);\n+\t\tif (requested_addr == NULL) {\n+\t\t\tRTE_LOG(ERR, EAL, \"%s(): cannot reserve space for device\\n\",\n+\t\t\t\t__func__);\n+\t\t\treturn MAP_FAILED;\n+\t\t}\n+\t}\n+\tadditional_flags |= MAP_FIXED;\n+\n \t/* Map the PCI memory resource of device */\n \tmapaddr = mmap(requested_addr, size, PROT_READ | PROT_WRITE,\n \t\t\tMAP_SHARED | additional_flags, fd, offset);\n@@ -170,15 +180,23 @@ pci_map_resource(void *requested_addr, int fd, off_t offset, size_t size,\n void\n pci_unmap_resource(void *requested_addr, size_t size)\n {\n+\tvoid *mapped;\n \tif (requested_addr == NULL)\n \t\treturn;\n \n+\tmapped = mmap(requested_addr, size, PROT_READ,\n+\t\t\tMAP_PRIVATE | MAP_ANONYMOUS, -1, 0);\n+\n \t/* Unmap the PCI memory resource of device */\n-\tif (munmap(requested_addr, size)) {\n+\tif (mapped == MAP_FAILED) {\n \t\tRTE_LOG(ERR, EAL, \"%s(): cannot munmap(%p, %#zx): %s\\n\",\n \t\t\t__func__, requested_addr, size,\n \t\t\tstrerror(errno));\n \t} else\n \t\tRTE_LOG(DEBUG, EAL, \"  PCI memory unmapped at %p\\n\",\n \t\t\t\trequested_addr);\n+\tif (rte_mem_dev_memory_free(requested_addr, size))\n+\t\tRTE_LOG(ERR, EAL, \"%s(): cannot mark %p-%p as free\\n\",\n+\t\t\t__func__, requested_addr,\n+\t\t\tRTE_PTR_ADD(requested_addr, size));\n }\n",
    "prefixes": [
        "dpdk-dev",
        "RFC",
        "3/3"
    ]
}