get:
Show a patch.

patch:
Update a patch.

put:
Update a patch.

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

{
    "id": 103029,
    "url": "https://patches.dpdk.org/api/patches/103029/?format=api",
    "web_url": "https://patches.dpdk.org/project/dpdk/patch/20211027095538.98512-1-xuan.ding@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": "<20211027095538.98512-1-xuan.ding@intel.com>",
    "list_archive_url": "https://inbox.dpdk.org/dev/20211027095538.98512-1-xuan.ding@intel.com",
    "date": "2021-10-27T09:55:38",
    "name": "vhost: remove async dma map status",
    "commit_ref": null,
    "pull_url": null,
    "state": "superseded",
    "archived": true,
    "hash": "9be2e6645680478bb535f3e33e1df28e67ee3698",
    "submitter": {
        "id": 1401,
        "url": "https://patches.dpdk.org/api/people/1401/?format=api",
        "name": "Ding, Xuan",
        "email": "xuan.ding@intel.com"
    },
    "delegate": null,
    "mbox": "https://patches.dpdk.org/project/dpdk/patch/20211027095538.98512-1-xuan.ding@intel.com/mbox/",
    "series": [
        {
            "id": 20044,
            "url": "https://patches.dpdk.org/api/series/20044/?format=api",
            "web_url": "https://patches.dpdk.org/project/dpdk/list/?series=20044",
            "date": "2021-10-27T09:55:38",
            "name": "vhost: remove async dma map status",
            "version": 1,
            "mbox": "https://patches.dpdk.org/series/20044/mbox/"
        }
    ],
    "comments": "https://patches.dpdk.org/api/patches/103029/comments/",
    "check": "warning",
    "checks": "https://patches.dpdk.org/api/patches/103029/checks/",
    "tags": {},
    "related": [],
    "headers": {
        "Return-Path": "<dev-bounces@dpdk.org>",
        "X-Original-To": "patchwork@inbox.dpdk.org",
        "Delivered-To": "patchwork@inbox.dpdk.org",
        "Received": [
            "from mails.dpdk.org (mails.dpdk.org [217.70.189.124])\n\tby inbox.dpdk.org (Postfix) with ESMTP id 27421A0547;\n\tWed, 27 Oct 2021 12:07:19 +0200 (CEST)",
            "from [217.70.189.124] (localhost [127.0.0.1])\n\tby mails.dpdk.org (Postfix) with ESMTP id 09CB84068C;\n\tWed, 27 Oct 2021 12:07:19 +0200 (CEST)",
            "from mga18.intel.com (mga18.intel.com [134.134.136.126])\n by mails.dpdk.org (Postfix) with ESMTP id 424F34003F\n for <dev@dpdk.org>; Wed, 27 Oct 2021 12:07:17 +0200 (CEST)",
            "from orsmga003.jf.intel.com ([10.7.209.27])\n by orsmga106.jf.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384;\n 27 Oct 2021 03:07:08 -0700",
            "from dpdk-xuanding-dev2.sh.intel.com ([10.67.119.250])\n by orsmga003.jf.intel.com with ESMTP; 27 Oct 2021 03:07:06 -0700"
        ],
        "X-IronPort-AV": [
            "E=McAfee;i=\"6200,9189,10149\"; a=\"217037249\"",
            "E=Sophos;i=\"5.87,186,1631602800\"; d=\"scan'208\";a=\"217037249\"",
            "E=Sophos;i=\"5.87,186,1631602800\"; d=\"scan'208\";a=\"447486344\""
        ],
        "X-ExtLoop1": "1",
        "From": "Xuan Ding <xuan.ding@intel.com>",
        "To": "dev@dpdk.org,\n\tmaxime.coquelin@redhat.com,\n\tchenbo.xia@intel.com",
        "Cc": "jiayu.hu@intel.com, Xuan Ding <xuan.ding@intel.com>,\n anatoly.burakov@intel.com",
        "Date": "Wed, 27 Oct 2021 09:55:38 +0000",
        "Message-Id": "<20211027095538.98512-1-xuan.ding@intel.com>",
        "X-Mailer": "git-send-email 2.17.1",
        "Subject": "[dpdk-dev] [PATCH] vhost: remove async dma map status",
        "X-BeenThere": "dev@dpdk.org",
        "X-Mailman-Version": "2.1.29",
        "Precedence": "list",
        "List-Id": "DPDK patches and discussions <dev.dpdk.org>",
        "List-Unsubscribe": "<https://mails.dpdk.org/options/dev>,\n <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 <mailto:dev-request@dpdk.org?subject=subscribe>",
        "Errors-To": "dev-bounces@dpdk.org",
        "Sender": "\"dev\" <dev-bounces@dpdk.org>"
    },
    "content": "Async dma map status flag was added to prevent the unnecessary unmap\nwhen DMA devices bound to kernel driver. This brings maintenance cost\nfor a lot of code. This patch removes the dma map status by using\nrte_errno instead.\n\nThis patch relies on the following patch to fix a partial\nunmap check in vfio unmaping API.\n[1] https://www.mail-archive.com/dev@dpdk.org/msg226464.html\n\nCc: anatoly.burakov@intel.com\nSigned-off-by: Xuan Ding <xuan.ding@intel.com>\n---\n lib/vhost/vhost.h      |  3 --\n lib/vhost/vhost_user.c | 70 ++++++++----------------------------------\n 2 files changed, 13 insertions(+), 60 deletions(-)",
    "diff": "diff --git a/lib/vhost/vhost.h b/lib/vhost/vhost.h\nindex 6c6a2da2c9..71fddf3592 100644\n--- a/lib/vhost/vhost.h\n+++ b/lib/vhost/vhost.h\n@@ -370,9 +370,6 @@ struct virtio_net {\n \tuint32_t\t\tnr_vring;\n \tint\t\t\tasync_copy;\n \n-\t/* Record the dma map status for each region. */\n-\tbool\t\t\t*async_map_status;\n-\n \tint\t\t\textbuf;\n \tint\t\t\tlinearbuf;\n \tstruct vhost_virtqueue\t*virtqueue[VHOST_MAX_QUEUE_PAIRS * 2];\ndiff --git a/lib/vhost/vhost_user.c b/lib/vhost/vhost_user.c\nindex 720d1c1c9d..9489d03e45 100644\n--- a/lib/vhost/vhost_user.c\n+++ b/lib/vhost/vhost_user.c\n@@ -144,7 +144,7 @@ get_blk_size(int fd)\n }\n \n static int\n-async_dma_map(struct rte_vhost_mem_region *region, bool *dma_map_success, bool do_map)\n+async_dma_map(struct rte_vhost_mem_region *region, bool do_map)\n {\n \tuint64_t host_iova;\n \tint ret = 0;\n@@ -156,8 +156,6 @@ async_dma_map(struct rte_vhost_mem_region *region, bool *dma_map_success, bool d\n \t\t\t\t\t\t region->host_user_addr,\n \t\t\t\t\t\t host_iova,\n \t\t\t\t\t\t region->size);\n-\t\t*dma_map_success = ret == 0;\n-\n \t\tif (ret) {\n \t\t\t/*\n \t\t\t * DMA device may bind with kernel driver, in this case,\n@@ -175,26 +173,24 @@ async_dma_map(struct rte_vhost_mem_region *region, bool *dma_map_success, bool d\n \t\t\t\treturn 0;\n \n \t\t\tVHOST_LOG_CONFIG(ERR, \"DMA engine map failed\\n\");\n-\t\t\treturn ret;\n-\n+\t\t\t/* DMA mapping errors won't stop VHST_USER_SET_MEM_TABLE. */\n+\t\t\treturn 0;\n \t\t}\n \n \t} else {\n-\t\t/* No need to do vfio unmap if the map failed. */\n-\t\tif (!*dma_map_success)\n-\t\t\treturn 0;\n-\n \t\t/* Remove mapped region from the default container of DPDK. */\n \t\tret = rte_vfio_container_dma_unmap(RTE_VFIO_DEFAULT_CONTAINER_FD,\n \t\t\t\t\t\t   region->host_user_addr,\n \t\t\t\t\t\t   host_iova,\n \t\t\t\t\t\t   region->size);\n \t\tif (ret) {\n+\t\t\t/* like DMA map, ignore the kernel driver case when unmap. */\n+\t\t\tif (rte_errno == EINVAL)\n+\t\t\t\treturn 0;\n+\n \t\t\tVHOST_LOG_CONFIG(ERR, \"DMA engine unmap failed\\n\");\n \t\t\treturn ret;\n \t\t}\n-\t\t/* Clear the flag once the unmap succeeds. */\n-\t\t*dma_map_success = 0;\n \t}\n \n \treturn ret;\n@@ -213,7 +209,7 @@ free_mem_region(struct virtio_net *dev)\n \t\treg = &dev->mem->regions[i];\n \t\tif (reg->host_user_addr) {\n \t\t\tif (dev->async_copy && rte_vfio_is_enabled(\"vfio\"))\n-\t\t\t\tasync_dma_map(reg, &dev->async_map_status[i], false);\n+\t\t\t\tasync_dma_map(reg, false);\n \n \t\t\tmunmap(reg->mmap_addr, reg->mmap_size);\n \t\t\tclose(reg->fd);\n@@ -228,11 +224,6 @@ vhost_backend_cleanup(struct virtio_net *dev)\n \t\tfree_mem_region(dev);\n \t\trte_free(dev->mem);\n \t\tdev->mem = NULL;\n-\n-\t\tif (dev->async_map_status) {\n-\t\t\trte_free(dev->async_map_status);\n-\t\t\tdev->async_map_status = NULL;\n-\t\t}\n \t}\n \n \trte_free(dev->guest_pages);\n@@ -688,19 +679,6 @@ numa_realloc(struct virtio_net *dev, int index)\n \t}\n \tdev->mem = mem;\n \n-\tif (dev->async_copy && rte_vfio_is_enabled(\"vfio\")) {\n-\t\tif (dev->async_map_status == NULL) {\n-\t\t\tdev->async_map_status = rte_zmalloc_socket(\"async-dma-map-status\",\n-\t\t\t\t\tsizeof(bool) * dev->mem->nregions, 0, node);\n-\t\t\tif (!dev->async_map_status) {\n-\t\t\t\tVHOST_LOG_CONFIG(ERR,\n-\t\t\t\t\t\"(%d) failed to realloc dma mapping status on node\\n\",\n-\t\t\t\t\tdev->vid);\n-\t\t\t\treturn dev;\n-\t\t\t}\n-\t\t}\n-\t}\n-\n \tgp = rte_realloc_socket(dev->guest_pages, dev->max_guest_pages * sizeof(*gp),\n \t\t\tRTE_CACHE_LINE_SIZE, node);\n \tif (!gp) {\n@@ -1231,7 +1209,6 @@ vhost_user_postcopy_register(struct virtio_net *dev, int main_fd,\n static int\n vhost_user_mmap_region(struct virtio_net *dev,\n \t\tstruct rte_vhost_mem_region *region,\n-\t\tuint32_t region_index,\n \t\tuint64_t mmap_offset)\n {\n \tvoid *mmap_addr;\n@@ -1294,16 +1271,14 @@ vhost_user_mmap_region(struct virtio_net *dev,\n \n \tif (dev->async_copy) {\n \t\tif (add_guest_pages(dev, region, alignment) < 0) {\n-\t\t\tVHOST_LOG_CONFIG(ERR,\n-\t\t\t\t\t\"adding guest pages to region failed.\\n\");\n+\t\t\tVHOST_LOG_CONFIG(ERR, \"adding guest pages to region failed.\\n\");\n \t\t\treturn -1;\n \t\t}\n \n \t\tif (rte_vfio_is_enabled(\"vfio\")) {\n-\t\t\tret = async_dma_map(region, &dev->async_map_status[region_index], true);\n+\t\t\tret = async_dma_map(region, true);\n \t\t\tif (ret) {\n-\t\t\t\tVHOST_LOG_CONFIG(ERR, \"Configure IOMMU for DMA \"\n-\t\t\t\t\t\t\t\"engine failed\\n\");\n+\t\t\t\tVHOST_LOG_CONFIG(ERR, \"Configure IOMMU for DMA engine failed\\n\");\n \t\t\t\treturn -1;\n \t\t\t}\n \t\t}\n@@ -1381,11 +1356,6 @@ vhost_user_set_mem_table(struct virtio_net **pdev, struct VhostUserMsg *msg,\n \t\tfree_mem_region(dev);\n \t\trte_free(dev->mem);\n \t\tdev->mem = NULL;\n-\n-\t\tif (dev->async_map_status) {\n-\t\t\trte_free(dev->async_map_status);\n-\t\t\tdev->async_map_status = NULL;\n-\t\t}\n \t}\n \n \t/* Flush IOTLB cache as previous HVAs are now invalid */\n@@ -1426,17 +1396,6 @@ vhost_user_set_mem_table(struct virtio_net **pdev, struct VhostUserMsg *msg,\n \t\tgoto free_guest_pages;\n \t}\n \n-\tif (dev->async_copy) {\n-\t\tdev->async_map_status = rte_zmalloc_socket(\"async-dma-map-status\",\n-\t\t\t\t\tsizeof(bool) * memory->nregions, 0, numa_node);\n-\t\tif (!dev->async_map_status) {\n-\t\t\tVHOST_LOG_CONFIG(ERR,\n-\t\t\t\t\"(%d) failed to allocate memory for dma mapping status\\n\",\n-\t\t\t\tdev->vid);\n-\t\t\tgoto free_mem_table;\n-\t\t}\n-\t}\n-\n \tfor (i = 0; i < memory->nregions; i++) {\n \t\treg = &dev->mem->regions[i];\n \n@@ -1453,7 +1412,7 @@ vhost_user_set_mem_table(struct virtio_net **pdev, struct VhostUserMsg *msg,\n \n \t\tmmap_offset = memory->regions[i].mmap_offset;\n \n-\t\tif (vhost_user_mmap_region(dev, reg, i, mmap_offset) < 0) {\n+\t\tif (vhost_user_mmap_region(dev, reg, mmap_offset) < 0) {\n \t\t\tVHOST_LOG_CONFIG(ERR, \"Failed to mmap region %u\\n\", i);\n \t\t\tgoto free_mem_table;\n \t\t}\n@@ -1501,10 +1460,7 @@ vhost_user_set_mem_table(struct virtio_net **pdev, struct VhostUserMsg *msg,\n \tfree_mem_region(dev);\n \trte_free(dev->mem);\n \tdev->mem = NULL;\n-\tif (dev->async_map_status) {\n-\t\trte_free(dev->async_map_status);\n-\t\tdev->async_map_status = NULL;\n-\t}\n+\n free_guest_pages:\n \trte_free(dev->guest_pages);\n \tdev->guest_pages = NULL;\n",
    "prefixes": []
}