get:
Show a patch.

patch:
Update a patch.

put:
Update a patch.

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

{
    "id": 77896,
    "url": "http://patchwork.dpdk.org/api/patches/77896/?format=api",
    "web_url": "http://patchwork.dpdk.org/project/dpdk/patch/4275aaf7d248f0e2a05ac21c05d682ce7ea4ad56.1600255570.git.anatoly.burakov@intel.com/",
    "project": {
        "id": 1,
        "url": "http://patchwork.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": "<4275aaf7d248f0e2a05ac21c05d682ce7ea4ad56.1600255570.git.anatoly.burakov@intel.com>",
    "list_archive_url": "https://inbox.dpdk.org/dev/4275aaf7d248f0e2a05ac21c05d682ce7ea4ad56.1600255570.git.anatoly.burakov@intel.com",
    "date": "2020-09-16T11:26:15",
    "name": "[18.11] vfio: map contiguous areas in one go",
    "commit_ref": null,
    "pull_url": null,
    "state": "not-applicable",
    "archived": true,
    "hash": "b3a4dbeeb15a3a0458a73f9edf0267df54b8219a",
    "submitter": {
        "id": 4,
        "url": "http://patchwork.dpdk.org/api/people/4/?format=api",
        "name": "Burakov, Anatoly",
        "email": "anatoly.burakov@intel.com"
    },
    "delegate": null,
    "mbox": "http://patchwork.dpdk.org/project/dpdk/patch/4275aaf7d248f0e2a05ac21c05d682ce7ea4ad56.1600255570.git.anatoly.burakov@intel.com/mbox/",
    "series": [
        {
            "id": 12279,
            "url": "http://patchwork.dpdk.org/api/series/12279/?format=api",
            "web_url": "http://patchwork.dpdk.org/project/dpdk/list/?series=12279",
            "date": "2020-09-16T11:26:15",
            "name": "[18.11] vfio: map contiguous areas in one go",
            "version": 1,
            "mbox": "http://patchwork.dpdk.org/series/12279/mbox/"
        }
    ],
    "comments": "http://patchwork.dpdk.org/api/patches/77896/comments/",
    "check": "fail",
    "checks": "http://patchwork.dpdk.org/api/patches/77896/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 0CCE0A04C7;\n\tWed, 16 Sep 2020 13:26:20 +0200 (CEST)",
            "from [92.243.14.124] (localhost [127.0.0.1])\n\tby dpdk.org (Postfix) with ESMTP id 411F01C115;\n\tWed, 16 Sep 2020 13:26:19 +0200 (CEST)",
            "from mga18.intel.com (mga18.intel.com [134.134.136.126])\n by dpdk.org (Postfix) with ESMTP id 0DABD1C0C9;\n Wed, 16 Sep 2020 13:26:17 +0200 (CEST)",
            "from orsmga007.jf.intel.com ([10.7.209.58])\n by orsmga106.jf.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384;\n 16 Sep 2020 04:26:16 -0700",
            "from silpixa00399498.ir.intel.com (HELO\n silpixa00399498.ger.corp.intel.com) ([10.237.222.52])\n by orsmga007.jf.intel.com with ESMTP; 16 Sep 2020 04:26:16 -0700"
        ],
        "IronPort-SDR": [
            "\n ycAfoD0LYkpDsykPhDbe+tHWAHQPZmiOWN8AFbxgZtKDIg1gQwg4CpM7YV46K9PZyBNQ0NL6Fg\n nYDmJbTUwDlg==",
            "\n ZH2oxq9AsP6/ynyaltEsu09LD/4l/IZVHdRCOoPF/W9Yo7Ca5CvnA3vIly3Eh+HyJubbySsU5S\n nvgX1+rZiftg=="
        ],
        "X-IronPort-AV": [
            "E=McAfee;i=\"6000,8403,9745\"; a=\"147196441\"",
            "E=Sophos;i=\"5.76,432,1592895600\"; d=\"scan'208\";a=\"147196441\"",
            "E=Sophos;i=\"5.76,432,1592895600\"; d=\"scan'208\";a=\"346194579\""
        ],
        "X-Amp-Result": "SKIPPED(no attachment in message)",
        "X-Amp-File-Uploaded": "False",
        "X-ExtLoop1": "1",
        "From": "Anatoly Burakov <anatoly.burakov@intel.com>",
        "To": "dev@dpdk.org",
        "Cc": "stable@dpdk.org",
        "Date": "Wed, 16 Sep 2020 12:26:15 +0100",
        "Message-Id": "\n <4275aaf7d248f0e2a05ac21c05d682ce7ea4ad56.1600255570.git.anatoly.burakov@intel.com>",
        "X-Mailer": "git-send-email 2.17.1",
        "Subject": "[dpdk-dev] [PATCH 18.11] vfio: map contiguous areas in one go",
        "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, when we are creating DMA mappings for memory that's\neither external or is backed by hugepages in IOVA as PA mode, we\nassume that each page is necessarily discontiguous. This may not\nactually be the case, especially for external memory, where the\nuser is able to create their own IOVA table and make it\ncontiguous. This is a problem because VFIO has a limited number\nof DMA mappings, and it does not appear to concatenate them and\ntreats each mapping as separate, even when they cover adjacent\nareas.\n\nFix this so that we always map contiguous memory in a single\nchunk, as opposed to mapping each segment separately.\n\nSigned-off-by: Anatoly Burakov <anatoly.burakov@intel.com>\n---\n\nNotes:\n    Resend for stable as original patch [1] no longer applies\n    \n    [1] http://patches.dpdk.org/patch/66041/\n\n lib/librte_eal/linuxapp/eal/eal_vfio.c | 59 ++++++++++++++++++++++----\n 1 file changed, 51 insertions(+), 8 deletions(-)",
    "diff": "diff --git a/lib/librte_eal/linuxapp/eal/eal_vfio.c b/lib/librte_eal/linuxapp/eal/eal_vfio.c\nindex 2f84e0f215..be969bbaac 100644\n--- a/lib/librte_eal/linuxapp/eal/eal_vfio.c\n+++ b/lib/librte_eal/linuxapp/eal/eal_vfio.c\n@@ -510,9 +510,11 @@ static void\n vfio_mem_event_callback(enum rte_mem_event type, const void *addr, size_t len,\n \t\tvoid *arg __rte_unused)\n {\n+\trte_iova_t iova_start, iova_expected;\n \tstruct rte_memseg_list *msl;\n \tstruct rte_memseg *ms;\n \tsize_t cur_len = 0;\n+\tuint64_t va_start;\n \n \tmsl = rte_mem_virt2memseg_list(addr);\n \n@@ -530,22 +532,63 @@ vfio_mem_event_callback(enum rte_mem_event type, const void *addr, size_t len,\n \n \t/* memsegs are contiguous in memory */\n \tms = rte_mem_virt2memseg(addr, msl);\n+\n+\t/*\n+\t * This memory is not guaranteed to be contiguous, but it still could\n+\t * be, or it could have some small contiguous chunks. Since the number\n+\t * of VFIO mappings is limited, and VFIO appears to not concatenate\n+\t * adjacent mappings, we have to do this ourselves.\n+\t *\n+\t * So, find contiguous chunks, then map them.\n+\t */\n+\tva_start = ms->addr_64;\n+\tiova_start = iova_expected = ms->iova;\n \twhile (cur_len < len) {\n+\t\tbool new_contig_area = ms->iova != iova_expected;\n+\t\tbool last_seg = (len - cur_len) == ms->len;\n+\t\tbool skip_last = false;\n+\n+\t\t/* only do mappings when current contiguous area ends */\n+\t\tif (new_contig_area) {\n+\t\t\tif (type == RTE_MEM_EVENT_ALLOC)\n+\t\t\t\tvfio_dma_mem_map(default_vfio_cfg, va_start,\n+\t\t\t\t\t\tiova_start,\n+\t\t\t\t\t\tiova_expected - iova_start, 1);\n+\t\t\telse\n+\t\t\t\tvfio_dma_mem_map(default_vfio_cfg, va_start,\n+\t\t\t\t\t\tiova_start,\n+\t\t\t\t\t\tiova_expected - iova_start, 0);\n+\t\t\tva_start = ms->addr_64;\n+\t\t\tiova_start = ms->iova;\n+\t\t}\n \t\t/* some memory segments may have invalid IOVA */\n \t\tif (ms->iova == RTE_BAD_IOVA) {\n \t\t\tRTE_LOG(DEBUG, EAL, \"Memory segment at %p has bad IOVA, skipping\\n\",\n \t\t\t\t\tms->addr);\n-\t\t\tgoto next;\n+\t\t\tskip_last = true;\n \t\t}\n-\t\tif (type == RTE_MEM_EVENT_ALLOC)\n-\t\t\tvfio_dma_mem_map(default_vfio_cfg, ms->addr_64,\n-\t\t\t\t\tms->iova, ms->len, 1);\n-\t\telse\n-\t\t\tvfio_dma_mem_map(default_vfio_cfg, ms->addr_64,\n-\t\t\t\t\tms->iova, ms->len, 0);\n-next:\n+\t\tiova_expected = ms->iova + ms->len;\n \t\tcur_len += ms->len;\n \t\t++ms;\n+\n+\t\t/*\n+\t\t * don't count previous segment, and don't attempt to\n+\t\t * dereference a potentially invalid pointer.\n+\t\t */\n+\t\tif (skip_last && !last_seg) {\n+\t\t\tiova_expected = iova_start = ms->iova;\n+\t\t\tva_start = ms->addr_64;\n+\t\t} else if (!skip_last && last_seg) {\n+\t\t\t/* this is the last segment and we're not skipping */\n+\t\t\tif (type == RTE_MEM_EVENT_ALLOC)\n+\t\t\t\tvfio_dma_mem_map(default_vfio_cfg, va_start,\n+\t\t\t\t\t\tiova_start,\n+\t\t\t\t\t\tiova_expected - iova_start, 1);\n+\t\t\telse\n+\t\t\t\tvfio_dma_mem_map(default_vfio_cfg, va_start,\n+\t\t\t\t\t\tiova_start,\n+\t\t\t\t\t\tiova_expected - iova_start, 0);\n+\t\t}\n \t}\n }\n \n",
    "prefixes": [
        "18.11"
    ]
}