get:
Show a patch.

patch:
Update a patch.

put:
Update a patch.

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

{
    "id": 42925,
    "url": "https://patches.dpdk.org/api/patches/42925/?format=api",
    "web_url": "https://patches.dpdk.org/project/dpdk/patch/20180712011514.45006-4-qi.z.zhang@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": "<20180712011514.45006-4-qi.z.zhang@intel.com>",
    "list_archive_url": "https://inbox.dpdk.org/dev/20180712011514.45006-4-qi.z.zhang@intel.com",
    "date": "2018-07-12T01:14:58",
    "name": "[v13,03/19] bus/pci: enable vfio unmap resource for secondary",
    "commit_ref": null,
    "pull_url": null,
    "state": "superseded",
    "archived": true,
    "hash": "eac4ec3a4392d1e0badaa90f4b06dc617ada1b6a",
    "submitter": {
        "id": 504,
        "url": "https://patches.dpdk.org/api/people/504/?format=api",
        "name": "Qi Zhang",
        "email": "qi.z.zhang@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/20180712011514.45006-4-qi.z.zhang@intel.com/mbox/",
    "series": [
        {
            "id": 534,
            "url": "https://patches.dpdk.org/api/series/534/?format=api",
            "web_url": "https://patches.dpdk.org/project/dpdk/list/?series=534",
            "date": "2018-07-12T01:14:56",
            "name": "[v13,01/19] ethdev: add function to release port in local process",
            "version": 13,
            "mbox": "https://patches.dpdk.org/series/534/mbox/"
        }
    ],
    "comments": "https://patches.dpdk.org/api/patches/42925/comments/",
    "check": "fail",
    "checks": "https://patches.dpdk.org/api/patches/42925/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 4B8911B5E6;\n\tThu, 12 Jul 2018 03:15:23 +0200 (CEST)",
            "from mga03.intel.com (mga03.intel.com [134.134.136.65])\n\tby dpdk.org (Postfix) with ESMTP id D4EAD1B509\n\tfor <dev@dpdk.org>; Thu, 12 Jul 2018 03:14:59 +0200 (CEST)",
            "from fmsmga006.fm.intel.com ([10.253.24.20])\n\tby orsmga103.jf.intel.com with ESMTP/TLS/DHE-RSA-AES256-GCM-SHA384;\n\t11 Jul 2018 18:14:54 -0700",
            "from dpdk51.sh.intel.com ([10.67.110.190])\n\tby fmsmga006.fm.intel.com with ESMTP; 11 Jul 2018 18:14:41 -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,339,1526367600\"; d=\"scan'208\";a=\"244990447\"",
        "From": "Qi Zhang <qi.z.zhang@intel.com>",
        "To": "thomas@monjalon.net,\n\tanatoly.burakov@intel.com",
        "Cc": "konstantin.ananyev@intel.com, dev@dpdk.org, bruce.richardson@intel.com, \n\tferruh.yigit@intel.com, benjamin.h.shelton@intel.com,\n\tnarender.vangati@intel.com, Qi Zhang <qi.z.zhang@intel.com>",
        "Date": "Thu, 12 Jul 2018 09:14:58 +0800",
        "Message-Id": "<20180712011514.45006-4-qi.z.zhang@intel.com>",
        "X-Mailer": "git-send-email 2.13.6",
        "In-Reply-To": "<20180712011514.45006-1-qi.z.zhang@intel.com>",
        "References": "<20180607123849.14439-1-qi.z.zhang@intel.com>\n\t<20180712011514.45006-1-qi.z.zhang@intel.com>",
        "Subject": "[dpdk-dev] [PATCH v13 03/19] bus/pci: enable vfio unmap resource\n\tfor secondary",
        "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>\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 dd25c3542..93f0ac07e 100644\n--- a/drivers/bus/pci/linux/pci_vfio.c\n+++ b/drivers/bus/pci/linux/pci_vfio.c\n@@ -595,6 +595,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@@ -614,22 +617,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 (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@@ -650,13 +689,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 (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@@ -664,30 +700,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": [
        "v13",
        "03/19"
    ]
}