get:
Show a patch.

patch:
Update a patch.

put:
Update a patch.

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

{
    "id": 42976,
    "url": "http://patches.dpdk.org/api/patches/42976/?format=api",
    "web_url": "http://patches.dpdk.org/project/dpdk/patch/20180712140144.18146-4-qi.z.zhang@intel.com/",
    "project": {
        "id": 1,
        "url": "http://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": "<20180712140144.18146-4-qi.z.zhang@intel.com>",
    "list_archive_url": "https://inbox.dpdk.org/dev/20180712140144.18146-4-qi.z.zhang@intel.com",
    "date": "2018-07-12T14:01:43",
    "name": "[3/4] bus/pci: enable vfio unmap resource for secondary",
    "commit_ref": null,
    "pull_url": null,
    "state": "accepted",
    "archived": true,
    "hash": "fb412f03153443b7a2aacd63d155a44e78ffb89e",
    "submitter": {
        "id": 504,
        "url": "http://patches.dpdk.org/api/people/504/?format=api",
        "name": "Qi Zhang",
        "email": "qi.z.zhang@intel.com"
    },
    "delegate": {
        "id": 1,
        "url": "http://patches.dpdk.org/api/users/1/?format=api",
        "username": "tmonjalo",
        "first_name": "Thomas",
        "last_name": "Monjalon",
        "email": "thomas@monjalon.net"
    },
    "mbox": "http://patches.dpdk.org/project/dpdk/patch/20180712140144.18146-4-qi.z.zhang@intel.com/mbox/",
    "series": [
        {
            "id": 549,
            "url": "http://patches.dpdk.org/api/series/549/?format=api",
            "web_url": "http://patches.dpdk.org/project/dpdk/list/?series=549",
            "date": "2018-07-12T14:01:40",
            "name": "couple hotplug fix",
            "version": 1,
            "mbox": "http://patches.dpdk.org/series/549/mbox/"
        }
    ],
    "comments": "http://patches.dpdk.org/api/patches/42976/comments/",
    "check": "success",
    "checks": "http://patches.dpdk.org/api/patches/42976/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 EB7381B472;\n\tThu, 12 Jul 2018 16:01:16 +0200 (CEST)",
            "from mga04.intel.com (mga04.intel.com [192.55.52.120])\n\tby dpdk.org (Postfix) with ESMTP id 0C0831B448\n\tfor <dev@dpdk.org>; Thu, 12 Jul 2018 16:01:10 +0200 (CEST)",
            "from orsmga008.jf.intel.com ([10.7.209.65])\n\tby fmsmga104.fm.intel.com with ESMTP/TLS/DHE-RSA-AES256-GCM-SHA384;\n\t12 Jul 2018 07:01:10 -0700",
            "from dpdk51.sh.intel.com ([10.67.110.190])\n\tby orsmga008.jf.intel.com with ESMTP; 12 Jul 2018 07:01:08 -0700"
        ],
        "X-Amp-Result": "SKIPPED(no attachment in message)",
        "X-Amp-File-Uploaded": "False",
        "X-ExtLoop1": "1",
        "X-IronPort-AV": "E=Sophos;i=\"5.51,343,1526367600\"; d=\"scan'208\";a=\"56361081\"",
        "From": "Qi Zhang <qi.z.zhang@intel.com>",
        "To": "thomas@monjalon.net, anatoly.burakov@intel.com, gaetan.rivet@6wind.com",
        "Cc": "dev@dpdk.org,\n\tQi Zhang <qi.z.zhang@intel.com>",
        "Date": "Thu, 12 Jul 2018 22:01:43 +0800",
        "Message-Id": "<20180712140144.18146-4-qi.z.zhang@intel.com>",
        "X-Mailer": "git-send-email 2.13.6",
        "In-Reply-To": "<20180712140144.18146-1-qi.z.zhang@intel.com>",
        "References": "<20180712140144.18146-1-qi.z.zhang@intel.com>",
        "Subject": "[dpdk-dev] [PATCH 3/4] bus/pci: enable vfio unmap resource for\n\tsecondary",
        "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://mails.dpdk.org/options/dev>,\n\t<mailto:dev-request@dpdk.org?subject=unsubscribe>",
        "List-Archive": "<http://mails.dpdk.org/archives/dev/>",
        "List-Post": "<mailto:dev@dpdk.org>",
        "List-Help": "<mailto:dev-request@dpdk.org?subject=help>",
        "List-Subscribe": "<https://mails.dpdk.org/listinfo/dev>,\n\t<mailto:dev-request@dpdk.org?subject=subscribe>",
        "Errors-To": "dev-bounces@dpdk.org",
        "Sender": "\"dev\" <dev-bounces@dpdk.org>"
    },
    "content": "Subroutine to unmap VFIO resource is shared by secondary and\nprimary, and it does not work on the secondary process. Since\nfor secondary process, it is not necessary to close interrupt\nhandler, set pci bus mastering and remove vfio_res from\nvfio_res_list. So, the patch adds a dedicate function to handle\nthe situation when a device is unmapped on a secondary process.\n\nSigned-off-by: Qi Zhang <qi.z.zhang@intel.com>\nReviewed-by: Anatoly Burakov <anatoly.burakov@intel.com>\n---\n drivers/bus/pci/linux/pci_vfio.c | 118 +++++++++++++++++++++++++++++----------\n 1 file changed, 90 insertions(+), 28 deletions(-)",
    "diff": "diff --git a/drivers/bus/pci/linux/pci_vfio.c b/drivers/bus/pci/linux/pci_vfio.c\nindex 933b95540..686386d6a 100644\n--- a/drivers/bus/pci/linux/pci_vfio.c\n+++ b/drivers/bus/pci/linux/pci_vfio.c\n@@ -584,6 +584,9 @@ pci_vfio_map_resource_secondary(struct rte_pci_device *dev)\n \t\tdev->mem_resource[i].addr = maps[i].addr;\n \t}\n \n+\t/* we need save vfio_dev_fd, so it can be used during release */\n+\tdev->intr_handle.vfio_dev_fd = vfio_dev_fd;\n+\n \treturn 0;\n err_vfio_dev_fd:\n \tclose(vfio_dev_fd);\n@@ -603,22 +606,58 @@ pci_vfio_map_resource(struct rte_pci_device *dev)\n \t\treturn pci_vfio_map_resource_secondary(dev);\n }\n \n-int\n-pci_vfio_unmap_resource(struct rte_pci_device *dev)\n+static struct mapped_pci_resource *\n+find_and_unmap_vfio_resource(struct mapped_pci_res_list *vfio_res_list,\n+\t\t\tstruct rte_pci_device *dev,\n+\t\t\tconst char *pci_addr)\n+{\n+\tstruct mapped_pci_resource *vfio_res = NULL;\n+\tstruct pci_map *maps;\n+\tint i;\n+\n+\t/* Get vfio_res */\n+\tTAILQ_FOREACH(vfio_res, vfio_res_list, next) {\n+\t\tif (rte_pci_addr_cmp(&vfio_res->pci_addr, &dev->addr))\n+\t\t\tcontinue;\n+\t\tbreak;\n+\t}\n+\n+\tif  (vfio_res == NULL)\n+\t\treturn vfio_res;\n+\n+\tRTE_LOG(INFO, EAL, \"Releasing pci mapped resource for %s\\n\",\n+\t\tpci_addr);\n+\n+\tmaps = vfio_res->maps;\n+\tfor (i = 0; i < (int) vfio_res->nb_maps; i++) {\n+\n+\t\t/*\n+\t\t * We do not need to be aware of MSI-X table BAR mappings as\n+\t\t * when mapping. Just using current maps array is enough\n+\t\t */\n+\t\tif (maps[i].addr) {\n+\t\t\tRTE_LOG(INFO, EAL, \"Calling pci_unmap_resource for %s at %p\\n\",\n+\t\t\t\tpci_addr, maps[i].addr);\n+\t\t\tpci_unmap_resource(maps[i].addr, maps[i].size);\n+\t\t}\n+\t}\n+\n+\treturn vfio_res;\n+}\n+\n+static int\n+pci_vfio_unmap_resource_primary(struct rte_pci_device *dev)\n {\n \tchar pci_addr[PATH_MAX] = {0};\n \tstruct rte_pci_addr *loc = &dev->addr;\n-\tint i, ret;\n \tstruct mapped_pci_resource *vfio_res = NULL;\n \tstruct mapped_pci_res_list *vfio_res_list;\n-\n-\tstruct pci_map *maps;\n+\tint ret;\n \n \t/* store PCI address string */\n \tsnprintf(pci_addr, sizeof(pci_addr), PCI_PRI_FMT,\n \t\t\tloc->domain, loc->bus, loc->devid, loc->function);\n \n-\n \tif (close(dev->intr_handle.fd) < 0) {\n \t\tRTE_LOG(INFO, EAL, \"Error when closing eventfd file descriptor for %s\\n\",\n \t\t\tpci_addr);\n@@ -639,13 +678,10 @@ pci_vfio_unmap_resource(struct rte_pci_device *dev)\n \t\treturn ret;\n \t}\n \n-\tvfio_res_list = RTE_TAILQ_CAST(rte_vfio_tailq.head, mapped_pci_res_list);\n-\t/* Get vfio_res */\n-\tTAILQ_FOREACH(vfio_res, vfio_res_list, next) {\n-\t\tif (rte_pci_addr_cmp(&vfio_res->pci_addr, &dev->addr))\n-\t\t\tcontinue;\n-\t\tbreak;\n-\t}\n+\tvfio_res_list =\n+\t\tRTE_TAILQ_CAST(rte_vfio_tailq.head, mapped_pci_res_list);\n+\tvfio_res = find_and_unmap_vfio_resource(vfio_res_list, dev, pci_addr);\n+\n \t/* if we haven't found our tailq entry, something's wrong */\n \tif (vfio_res == NULL) {\n \t\tRTE_LOG(ERR, EAL, \"  %s cannot find TAILQ entry for PCI device!\\n\",\n@@ -653,30 +689,56 @@ pci_vfio_unmap_resource(struct rte_pci_device *dev)\n \t\treturn -1;\n \t}\n \n-\t/* unmap BARs */\n-\tmaps = vfio_res->maps;\n+\tTAILQ_REMOVE(vfio_res_list, vfio_res, next);\n \n-\tRTE_LOG(INFO, EAL, \"Releasing pci mapped resource for %s\\n\",\n-\t\tpci_addr);\n-\tfor (i = 0; i < (int) vfio_res->nb_maps; i++) {\n+\treturn 0;\n+}\n \n-\t\t/*\n-\t\t * We do not need to be aware of MSI-X table BAR mappings as\n-\t\t * when mapping. Just using current maps array is enough\n-\t\t */\n-\t\tif (maps[i].addr) {\n-\t\t\tRTE_LOG(INFO, EAL, \"Calling pci_unmap_resource for %s at %p\\n\",\n-\t\t\t\tpci_addr, maps[i].addr);\n-\t\t\tpci_unmap_resource(maps[i].addr, maps[i].size);\n-\t\t}\n+static int\n+pci_vfio_unmap_resource_secondary(struct rte_pci_device *dev)\n+{\n+\tchar pci_addr[PATH_MAX] = {0};\n+\tstruct rte_pci_addr *loc = &dev->addr;\n+\tstruct mapped_pci_resource *vfio_res = NULL;\n+\tstruct mapped_pci_res_list *vfio_res_list;\n+\tint ret;\n+\n+\t/* store PCI address string */\n+\tsnprintf(pci_addr, sizeof(pci_addr), PCI_PRI_FMT,\n+\t\t\tloc->domain, loc->bus, loc->devid, loc->function);\n+\n+\tret = rte_vfio_release_device(rte_pci_get_sysfs_path(), pci_addr,\n+\t\t\t\t  dev->intr_handle.vfio_dev_fd);\n+\tif (ret < 0) {\n+\t\tRTE_LOG(ERR, EAL,\n+\t\t\t\"%s(): cannot release device\\n\", __func__);\n+\t\treturn ret;\n \t}\n \n-\tTAILQ_REMOVE(vfio_res_list, vfio_res, next);\n+\tvfio_res_list =\n+\t\tRTE_TAILQ_CAST(rte_vfio_tailq.head, mapped_pci_res_list);\n+\tvfio_res = find_and_unmap_vfio_resource(vfio_res_list, dev, pci_addr);\n+\n+\t/* if we haven't found our tailq entry, something's wrong */\n+\tif (vfio_res == NULL) {\n+\t\tRTE_LOG(ERR, EAL, \"  %s cannot find TAILQ entry for PCI device!\\n\",\n+\t\t\t\tpci_addr);\n+\t\treturn -1;\n+\t}\n \n \treturn 0;\n }\n \n int\n+pci_vfio_unmap_resource(struct rte_pci_device *dev)\n+{\n+\tif (rte_eal_process_type() == RTE_PROC_PRIMARY)\n+\t\treturn pci_vfio_unmap_resource_primary(dev);\n+\telse\n+\t\treturn pci_vfio_unmap_resource_secondary(dev);\n+}\n+\n+int\n pci_vfio_ioport_map(struct rte_pci_device *dev, int bar,\n \t\t    struct rte_pci_ioport *p)\n {\n",
    "prefixes": [
        "3/4"
    ]
}