get:
Show a patch.

patch:
Update a patch.

put:
Update a patch.

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

{
    "id": 62486,
    "url": "http://patches.dpdk.org/api/patches/62486/?format=api",
    "web_url": "http://patches.dpdk.org/project/dpdk/patch/b11cfd686662352931de545be84e9a5b390df05c.1572973899.git.anatoly.burakov@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": "<b11cfd686662352931de545be84e9a5b390df05c.1572973899.git.anatoly.burakov@intel.com>",
    "list_archive_url": "https://inbox.dpdk.org/dev/b11cfd686662352931de545be84e9a5b390df05c.1572973899.git.anatoly.burakov@intel.com",
    "date": "2019-11-05T17:12:57",
    "name": "[18.11] vfio: fix DMA mapping of externally allocated heaps",
    "commit_ref": null,
    "pull_url": null,
    "state": "not-applicable",
    "archived": true,
    "hash": "34ecd70453603ca1b94ac99faa847a9ebc173b46",
    "submitter": {
        "id": 4,
        "url": "http://patches.dpdk.org/api/people/4/?format=api",
        "name": "Anatoly Burakov",
        "email": "anatoly.burakov@intel.com"
    },
    "delegate": {
        "id": 24651,
        "url": "http://patches.dpdk.org/api/users/24651/?format=api",
        "username": "dmarchand",
        "first_name": "David",
        "last_name": "Marchand",
        "email": "david.marchand@redhat.com"
    },
    "mbox": "http://patches.dpdk.org/project/dpdk/patch/b11cfd686662352931de545be84e9a5b390df05c.1572973899.git.anatoly.burakov@intel.com/mbox/",
    "series": [
        {
            "id": 7261,
            "url": "http://patches.dpdk.org/api/series/7261/?format=api",
            "web_url": "http://patches.dpdk.org/project/dpdk/list/?series=7261",
            "date": "2019-11-05T17:12:57",
            "name": "[18.11] vfio: fix DMA mapping of externally allocated heaps",
            "version": 1,
            "mbox": "http://patches.dpdk.org/series/7261/mbox/"
        }
    ],
    "comments": "http://patches.dpdk.org/api/patches/62486/comments/",
    "check": "fail",
    "checks": "http://patches.dpdk.org/api/patches/62486/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 dpdk.org (dpdk.org [92.243.14.124])\n\tby inbox.dpdk.org (Postfix) with ESMTP id 6FA55A04A2;\n\tTue,  5 Nov 2019 18:13:09 +0100 (CET)",
            "from [92.243.14.124] (localhost [127.0.0.1])\n\tby dpdk.org (Postfix) with ESMTP id DBD231BEF7;\n\tTue,  5 Nov 2019 18:13:08 +0100 (CET)",
            "from mga17.intel.com (mga17.intel.com [192.55.52.151])\n by dpdk.org (Postfix) with ESMTP id A1F8F1BEF4;\n Tue,  5 Nov 2019 18:13:06 +0100 (CET)",
            "from orsmga008.jf.intel.com ([10.7.209.65])\n by fmsmga107.fm.intel.com with ESMTP/TLS/DHE-RSA-AES256-GCM-SHA384;\n 05 Nov 2019 09:12:58 -0800",
            "from silpixa00399498.ir.intel.com (HELO\n silpixa00399498.ger.corp.intel.com) ([10.237.223.151])\n by orsmga008.jf.intel.com with ESMTP; 05 Nov 2019 09:12:55 -0800"
        ],
        "X-Amp-Result": "SKIPPED(no attachment in message)",
        "X-Amp-File-Uploaded": "False",
        "X-ExtLoop1": "1",
        "X-IronPort-AV": "E=Sophos;i=\"5.68,271,1569308400\"; d=\"scan'208\";a=\"195886031\"",
        "From": "Anatoly Burakov <anatoly.burakov@intel.com>",
        "To": "dev@dpdk.org",
        "Cc": "rajesh.ravi@broadcom.com, ajit.khaparde@broadcom.com,\n jonathan.richardson@broadcom.com, scott.branden@broadcom.com,\n vikram.prakash@broadcom.com, srinath.mannam@broadcom.com,\n thomas@monjalon.net, david.marchand@redhat.com, stable@dpdk.org",
        "Date": "Tue,  5 Nov 2019 17:12:57 +0000",
        "Message-Id": "\n <b11cfd686662352931de545be84e9a5b390df05c.1572973899.git.anatoly.burakov@intel.com>",
        "X-Mailer": "git-send-email 2.17.1",
        "Subject": "[dpdk-dev] [PATCH 18.11] vfio: fix DMA mapping of externally\n\tallocated heaps",
        "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 <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": "Currently, externally created heaps are supposed to be automatically\nmapped for VFIO DMA by EAL, however they only do so if, at the time of\nheap creation, VFIO is initialized and has at least one device\navailable. If no devices are available at the time of heap creation (or\nif devices were available, but were since hot-unplugged, thus dropping\nall VFIO container mappings), then VFIO mapping code would have skipped\nover externally allocated heaps.\n\nThe fix is to stop skipping external segments unconditionally, and\ninstead check if each segment belongs to an internal or external heap.\nThis way, we still skip over segments that are supposed to be mapped\nthrough the user maps, but we now map all of the heap segments.\n\nFixes: 0f526d674f8e (\"malloc: separate creating memseg list and malloc heap\")\nCc: stable@dpdk.org\n\nSigned-off-by: Anatoly Burakov <anatoly.burakov@intel.com>\n---\n lib/librte_eal/linuxapp/eal/eal_vfio.c | 61 ++++++++++++++++++++++++--\n 1 file changed, 57 insertions(+), 4 deletions(-)",
    "diff": "diff --git a/lib/librte_eal/linuxapp/eal/eal_vfio.c b/lib/librte_eal/linuxapp/eal/eal_vfio.c\nindex 830b320d70..463ed9999a 100644\n--- a/lib/librte_eal/linuxapp/eal/eal_vfio.c\n+++ b/lib/librte_eal/linuxapp/eal/eal_vfio.c\n@@ -87,6 +87,35 @@ static const struct vfio_iommu_type iommu_types[] = {\n \t},\n };\n \n+static bool\n+is_heap_memseg_list(const struct rte_memseg_list *msl)\n+{\n+\tstruct rte_mem_config *mcfg = rte_eal_get_configuration()->mem_config;\n+\tstruct malloc_heap *heap;\n+\tint i;\n+\n+\t/* internal memsegs are always heap memsegs */\n+\tif (!msl->external)\n+\t\treturn true;\n+\n+\tfor (i = 0; i < RTE_MAX_HEAPS; i++) {\n+\t\tint socket_id;\n+\n+\t\theap = &mcfg->malloc_heaps[i];\n+\t\tif (heap->total_size == 0)\n+\t\t\tcontinue;\n+\n+\t\tsocket_id = heap->socket_id;\n+\n+\t\t/* if socket ID of the heap matches that of memseg list, we\n+\t\t * found the heap this segment belongs to.\n+\t\t */\n+\t\tif (msl->socket_id == socket_id)\n+\t\t\treturn true;\n+\t}\n+\treturn false;\n+}\n+\n static int\n is_null_map(const struct user_mem_map *map)\n {\n@@ -1238,6 +1267,7 @@ type1_map_contig(const struct rte_memseg_list *msl, const struct rte_memseg *ms,\n {\n \tint *vfio_container_fd = arg;\n \n+\t/* skip over all externally allocated segments */\n \tif (msl->external)\n \t\treturn 0;\n \n@@ -1251,7 +1281,15 @@ type1_map(const struct rte_memseg_list *msl, const struct rte_memseg *ms,\n {\n \tint *vfio_container_fd = arg;\n \n-\tif (msl->external)\n+\t/* internal memsegs have already been mapped if IOVA as VA mode */\n+\tif (rte_eal_iova_mode() == RTE_IOVA_VA && !msl->external)\n+\t\treturn 0;\n+\n+\tif (!is_heap_memseg_list(msl))\n+\t\treturn 0;\n+\n+\t/* external segments may not have valid IOVA addresses */\n+\tif (ms->iova == RTE_BAD_IOVA)\n \t\treturn 0;\n \n \treturn vfio_type1_dma_mem_map(*vfio_container_fd, ms->addr_64, ms->iova,\n@@ -1302,12 +1340,19 @@ vfio_type1_dma_mem_map(int vfio_container_fd, uint64_t vaddr, uint64_t iova,\n static int\n vfio_type1_dma_map(int vfio_container_fd)\n {\n+\tint ret;\n+\n \tif (rte_eal_iova_mode() == RTE_IOVA_VA) {\n \t\t/* with IOVA as VA mode, we can get away with mapping contiguous\n \t\t * chunks rather than going page-by-page.\n \t\t */\n-\t\treturn rte_memseg_contig_walk(type1_map_contig,\n+\t\tret = rte_memseg_contig_walk(type1_map_contig,\n \t\t\t\t&vfio_container_fd);\n+\t\tif (ret != 0)\n+\t\t\treturn ret;\n+\t\t/* fall through to regular memseg walk because we also need to\n+\t\t * map external heaps.\n+\t\t */\n \t}\n \treturn rte_memseg_walk(type1_map, &vfio_container_fd);\n }\n@@ -1382,7 +1427,11 @@ vfio_spapr_map_walk(const struct rte_memseg_list *msl,\n {\n \tint *vfio_container_fd = arg;\n \n-\tif (msl->external)\n+\tif (!is_heap_memseg_list(msl))\n+\t\treturn 0;\n+\n+\t/* external segments may not have valid IOVA addresses */\n+\tif (ms->iova == RTE_BAD_IOVA)\n \t\treturn 0;\n \n \treturn vfio_spapr_dma_do_map(*vfio_container_fd, ms->addr_64, ms->iova,\n@@ -1400,7 +1449,11 @@ vfio_spapr_window_size_walk(const struct rte_memseg_list *msl,\n \tstruct spapr_walk_param *param = arg;\n \tuint64_t max = ms->iova + ms->len;\n \n-\tif (msl->external)\n+\tif (!is_heap_memseg_list(msl))\n+\t\treturn 0;\n+\n+\t/* external segments may not have valid IOVA addresses */\n+\tif (ms->iova == RTE_BAD_IOVA)\n \t\treturn 0;\n \n \tif (max > param->window_size) {\n",
    "prefixes": [
        "18.11"
    ]
}