get:
Show a patch.

patch:
Update a patch.

put:
Update a patch.

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

{
    "id": 75119,
    "url": "http://patches.dpdk.org/api/patches/75119/?format=api",
    "web_url": "http://patches.dpdk.org/project/dpdk/patch/1596356065-30106-1-git-send-email-xuemingl@mellanox.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": "<1596356065-30106-1-git-send-email-xuemingl@mellanox.com>",
    "list_archive_url": "https://inbox.dpdk.org/dev/1596356065-30106-1-git-send-email-xuemingl@mellanox.com",
    "date": "2020-08-02T08:14:25",
    "name": "vdpa/mlx5: add device configuration lock",
    "commit_ref": null,
    "pull_url": null,
    "state": "superseded",
    "archived": true,
    "hash": "ef2f743387e3adf0576eabc8550d3452e0532f8f",
    "submitter": {
        "id": 814,
        "url": "http://patches.dpdk.org/api/people/814/?format=api",
        "name": "Xueming Li",
        "email": "xuemingl@mellanox.com"
    },
    "delegate": {
        "id": 2642,
        "url": "http://patches.dpdk.org/api/users/2642/?format=api",
        "username": "mcoquelin",
        "first_name": "Maxime",
        "last_name": "Coquelin",
        "email": "maxime.coquelin@redhat.com"
    },
    "mbox": "http://patches.dpdk.org/project/dpdk/patch/1596356065-30106-1-git-send-email-xuemingl@mellanox.com/mbox/",
    "series": [
        {
            "id": 11448,
            "url": "http://patches.dpdk.org/api/series/11448/?format=api",
            "web_url": "http://patches.dpdk.org/project/dpdk/list/?series=11448",
            "date": "2020-08-02T08:14:25",
            "name": "vdpa/mlx5: add device configuration lock",
            "version": 1,
            "mbox": "http://patches.dpdk.org/series/11448/mbox/"
        }
    ],
    "comments": "http://patches.dpdk.org/api/patches/75119/comments/",
    "check": "success",
    "checks": "http://patches.dpdk.org/api/patches/75119/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 7F3F7A0518;\n\tSun,  2 Aug 2020 10:14:32 +0200 (CEST)",
            "from [92.243.14.124] (localhost [127.0.0.1])\n\tby dpdk.org (Postfix) with ESMTP id 056C22E8F;\n\tSun,  2 Aug 2020 10:14:31 +0200 (CEST)",
            "from git-send-mailer.rdmz.labs.mlnx (unknown [94.188.199.2])\n by dpdk.org (Postfix) with ESMTP id 01D722E81\n for <dev@dpdk.org>; Sun,  2 Aug 2020 10:14:29 +0200 (CEST)"
        ],
        "From": "Xueming Li <xuemingl@mellanox.com>",
        "To": "",
        "Cc": "dev@dpdk.org, Asaf@dpdk.org, \"Penso <asafp\"@mellanox.com",
        "Date": "Sun,  2 Aug 2020 08:14:25 +0000",
        "Message-Id": "<1596356065-30106-1-git-send-email-xuemingl@mellanox.com>",
        "X-Mailer": "git-send-email 1.8.3.1",
        "Subject": "[dpdk-dev] [PATCH] vdpa/mlx5: add device configuration lock",
        "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": "Under active traffic, qemu switch vq enable state, there will be segment\nfault.\n\nThe reason is that timer polling thread or channel event thread still\nreferencing resources that being destroyed or partially initialized.\n\nThis patch add per device vq configuration lock and test device ready\nflag in event thread to make sure vq being accessed fully initialized.\n\nRedmine: 2239647\n\nSigned-off-by: Xueming Li <xuemingl@mellanox.com>\n---\n drivers/vdpa/mlx5/mlx5_vdpa.c       | 8 +++++++-\n drivers/vdpa/mlx5/mlx5_vdpa.h       | 1 +\n drivers/vdpa/mlx5/mlx5_vdpa_event.c | 8 ++++++++\n 3 files changed, 16 insertions(+), 1 deletion(-)",
    "diff": "diff --git a/drivers/vdpa/mlx5/mlx5_vdpa.c b/drivers/vdpa/mlx5/mlx5_vdpa.c\nindex c0b87bcc01..a8f3e4b1de 100644\n--- a/drivers/vdpa/mlx5/mlx5_vdpa.c\n+++ b/drivers/vdpa/mlx5/mlx5_vdpa.c\n@@ -133,6 +133,7 @@ mlx5_vdpa_set_vring_state(int vid, int vring, int state)\n \tstruct rte_vdpa_device *vdev = rte_vhost_get_vdpa_device(vid);\n \tstruct mlx5_vdpa_priv *priv =\n \t\tmlx5_vdpa_find_priv_resource_by_vdev(vdev);\n+\tint ret;\n \n \tif (priv == NULL) {\n \t\tDRV_LOG(ERR, \"Invalid vDPA device: %s.\", vdev->device->name);\n@@ -142,7 +143,10 @@ mlx5_vdpa_set_vring_state(int vid, int vring, int state)\n \t\tDRV_LOG(ERR, \"Too big vring id: %d.\", vring);\n \t\treturn -E2BIG;\n \t}\n-\treturn mlx5_vdpa_virtq_enable(priv, vring, state);\n+\tpthread_mutex_lock(&priv->vq_config_lock);\n+\tret = mlx5_vdpa_virtq_enable(priv, vring, state);\n+\tpthread_mutex_unlock(&priv->vq_config_lock);\n+\treturn ret;\n }\n \n static int\n@@ -742,6 +746,7 @@ mlx5_vdpa_pci_probe(struct rte_pci_driver *pci_drv __rte_unused,\n \t}\n \tmlx5_vdpa_config_get(pci_dev->device.devargs, priv);\n \tSLIST_INIT(&priv->mr_list);\n+\tpthread_mutex_init(&priv->vq_config_lock, NULL);\n \tpthread_mutex_lock(&priv_list_lock);\n \tTAILQ_INSERT_TAIL(&priv_list, priv, next);\n \tpthread_mutex_unlock(&priv_list_lock);\n@@ -793,6 +798,7 @@ mlx5_vdpa_pci_remove(struct rte_pci_device *pci_dev)\n \t\t\tpriv->var = NULL;\n \t\t}\n \t\tmlx5_glue->close_device(priv->ctx);\n+\t\tpthread_mutex_destroy(&priv->vq_config_lock);\n \t\trte_free(priv);\n \t}\n \treturn 0;\ndiff --git a/drivers/vdpa/mlx5/mlx5_vdpa.h b/drivers/vdpa/mlx5/mlx5_vdpa.h\nindex 57044d9d33..462805a352 100644\n--- a/drivers/vdpa/mlx5/mlx5_vdpa.h\n+++ b/drivers/vdpa/mlx5/mlx5_vdpa.h\n@@ -120,6 +120,7 @@ enum {\n struct mlx5_vdpa_priv {\n \tTAILQ_ENTRY(mlx5_vdpa_priv) next;\n \tuint8_t configured;\n+\tpthread_mutex_t vq_config_lock;\n \tuint64_t last_traffic_tic;\n \tpthread_t timer_tid;\n \tpthread_mutex_t timer_lock;\ndiff --git a/drivers/vdpa/mlx5/mlx5_vdpa_event.c b/drivers/vdpa/mlx5/mlx5_vdpa_event.c\nindex 7dc1ac0fa9..4a8b7b0bd9 100644\n--- a/drivers/vdpa/mlx5/mlx5_vdpa_event.c\n+++ b/drivers/vdpa/mlx5/mlx5_vdpa_event.c\n@@ -274,6 +274,7 @@ mlx5_vdpa_poll_handle(void *arg)\n \t\t\t\t\t\t\t\t priv->event_us;\n \twhile (1) {\n \t\tmax = 0;\n+\t\tpthread_mutex_lock(&priv->vq_config_lock);\n \t\tfor (i = 0; i < priv->nr_virtqs; i++) {\n \t\t\tcq = &priv->virtqs[i].eqp.cq;\n \t\t\tif (cq->cq && !cq->armed) {\n@@ -298,6 +299,7 @@ mlx5_vdpa_poll_handle(void *arg)\n \t\t\t\t\tpriv->vdev->device->name);\n \t\t\t\tmlx5_vdpa_arm_all_cqs(priv);\n \t\t\t\tpthread_mutex_lock(&priv->timer_lock);\n+\t\t\t\tpthread_mutex_unlock(&priv->vq_config_lock);\n \t\t\t\tpriv->timer_on = 0;\n \t\t\t\twhile (!priv->timer_on)\n \t\t\t\t\tpthread_cond_wait(&priv->timer_cond,\n@@ -312,6 +314,7 @@ mlx5_vdpa_poll_handle(void *arg)\n \t\t} else {\n \t\t\tpriv->last_traffic_tic = current_tic;\n \t\t}\n+\t\tpthread_mutex_unlock(&priv->vq_config_lock);\n \t\tmlx5_vdpa_timer_sleep(priv, max);\n \t}\n \treturn NULL;\n@@ -327,6 +330,7 @@ mlx5_vdpa_interrupt_handler(void *cb_arg)\n \t\tuint8_t buf[sizeof(struct mlx5dv_devx_async_event_hdr) + 128];\n \t} out;\n \n+\tpthread_mutex_lock(&priv->vq_config_lock);\n \twhile (mlx5_glue->devx_get_event(priv->eventc, &out.event_resp,\n \t\t\t\t\t sizeof(out.buf)) >=\n \t\t\t\t       (ssize_t)sizeof(out.event_resp.cookie)) {\n@@ -337,12 +341,15 @@ mlx5_vdpa_interrupt_handler(void *cb_arg)\n \t\tstruct mlx5_vdpa_virtq *virtq = container_of(eqp,\n \t\t\t\t\t\t   struct mlx5_vdpa_virtq, eqp);\n \n+\t\tif (!virtq->enable)\n+\t\t\tcontinue;\n \t\tmlx5_vdpa_cq_poll(cq);\n \t\t/* Notify guest for descs consuming. */\n \t\tif (cq->callfd != -1)\n \t\t\teventfd_write(cq->callfd, (eventfd_t)1);\n \t\tif (priv->event_mode == MLX5_VDPA_EVENT_MODE_ONLY_INTERRUPT) {\n \t\t\tmlx5_vdpa_cq_arm(priv, cq);\n+\t\t\tpthread_mutex_unlock(&priv->vq_config_lock);\n \t\t\treturn;\n \t\t}\n \t\t/* Don't arm again - timer will take control. */\n@@ -363,6 +370,7 @@ mlx5_vdpa_interrupt_handler(void *cb_arg)\n \t\tpthread_cond_signal(&priv->timer_cond);\n \t}\n \tpthread_mutex_unlock(&priv->timer_lock);\n+\tpthread_mutex_unlock(&priv->vq_config_lock);\n }\n \n int\n",
    "prefixes": []
}