get:
Show a patch.

patch:
Update a patch.

put:
Update a patch.

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

{
    "id": 122823,
    "url": "http://patches.dpdk.org/api/patches/122823/?format=api",
    "web_url": "http://patches.dpdk.org/project/dpdk/patch/20230201092310.23252-20-syalavarthi@marvell.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": "<20230201092310.23252-20-syalavarthi@marvell.com>",
    "list_archive_url": "https://inbox.dpdk.org/dev/20230201092310.23252-20-syalavarthi@marvell.com",
    "date": "2023-02-01T09:22:50",
    "name": "[v4,19/39] ml/cnxk: enable support to stop an ML models",
    "commit_ref": null,
    "pull_url": null,
    "state": "superseded",
    "archived": true,
    "hash": "87bcd4e5a860f482ece0a2ac407da0de3ae681d3",
    "submitter": {
        "id": 2480,
        "url": "http://patches.dpdk.org/api/people/2480/?format=api",
        "name": "Srikanth Yalavarthi",
        "email": "syalavarthi@marvell.com"
    },
    "delegate": {
        "id": 1,
        "url": "http://patches.dpdk.org/api/users/1/?format=api",
        "username": "tmonjalo",
        "first_name": "Thomas",
        "last_name": "Monjalon",
        "email": "thomas@monjalon.net"
    },
    "mbox": "http://patches.dpdk.org/project/dpdk/patch/20230201092310.23252-20-syalavarthi@marvell.com/mbox/",
    "series": [
        {
            "id": 26732,
            "url": "http://patches.dpdk.org/api/series/26732/?format=api",
            "web_url": "http://patches.dpdk.org/project/dpdk/list/?series=26732",
            "date": "2023-02-01T09:22:31",
            "name": "Implementation of ML CNXK driver",
            "version": 4,
            "mbox": "http://patches.dpdk.org/series/26732/mbox/"
        }
    ],
    "comments": "http://patches.dpdk.org/api/patches/122823/comments/",
    "check": "success",
    "checks": "http://patches.dpdk.org/api/patches/122823/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 8483F41B9D;\n\tWed,  1 Feb 2023 10:24:57 +0100 (CET)",
            "from mails.dpdk.org (localhost [127.0.0.1])\n\tby mails.dpdk.org (Postfix) with ESMTP id BE77642DC2;\n\tWed,  1 Feb 2023 10:23:34 +0100 (CET)",
            "from mx0b-0016f401.pphosted.com (mx0a-0016f401.pphosted.com\n [67.231.148.174])\n by mails.dpdk.org (Postfix) with ESMTP id 4663942D49\n for <dev@dpdk.org>; Wed,  1 Feb 2023 10:23:22 +0100 (CET)",
            "from pps.filterd (m0045849.ppops.net [127.0.0.1])\n by mx0a-0016f401.pphosted.com (8.17.1.19/8.17.1.19) with ESMTP id\n 3116LRXt024189 for <dev@dpdk.org>; Wed, 1 Feb 2023 01:23:21 -0800",
            "from dc5-exch01.marvell.com ([199.233.59.181])\n by mx0a-0016f401.pphosted.com (PPS) with ESMTPS id 3nfjr8rgv5-3\n (version=TLSv1.2 cipher=ECDHE-RSA-AES256-SHA384 bits=256 verify=NOT)\n for <dev@dpdk.org>; Wed, 01 Feb 2023 01:23:21 -0800",
            "from DC5-EXCH01.marvell.com (10.69.176.38) by DC5-EXCH01.marvell.com\n (10.69.176.38) with Microsoft SMTP Server (TLS) id 15.0.1497.42;\n Wed, 1 Feb 2023 01:23:20 -0800",
            "from maili.marvell.com (10.69.176.80) by DC5-EXCH01.marvell.com\n (10.69.176.38) with Microsoft SMTP Server id 15.0.1497.42 via Frontend\n Transport; Wed, 1 Feb 2023 01:23:20 -0800",
            "from ml-host-33.caveonetworks.com (unknown [10.110.143.233])\n by maili.marvell.com (Postfix) with ESMTP id CEFAB3F704C;\n Wed,  1 Feb 2023 01:23:18 -0800 (PST)"
        ],
        "DKIM-Signature": "v=1; a=rsa-sha256; c=relaxed/relaxed; d=marvell.com;\n h=from : to : cc :\n subject : date : message-id : in-reply-to : references : mime-version :\n content-type; s=pfpt0220; bh=Cs/ellgBWJ9MwxQyT6DF2fzX0tVfNNVEtY9JzRG+LvY=;\n b=LDDgkFKtvyVpd/evHg3/jpgZ+4NGN8Ybv2zK5S31T9bO9GYXzC/+IvIg556vWdkBKqEF\n hN3MgwOXdld+OKMXiM3coC+mtoyTnjTxRycm2FGKbbcxu/sZ8PfboWkerrpor37H60hz\n LxIxPkJfeo2DswQzYJKz0xRniqNArmseb1NFGE/KDMYn1wCQ4rS6Fi9177Gs0htdYmTG\n UZk3lPnxl64/VQhi5CDkHyx4Ff9e+x79yuBzIr/qDWAp2T3tRyDYNIQDArM4GQVekZtn\n 86JPrag1/XQQz3c4CiGE9aOSIfW38oa2Ti/azzIVOmzJ6ZUHII8jb+jVRMGfmJo6M5mx gA==",
        "From": "Srikanth Yalavarthi <syalavarthi@marvell.com>",
        "To": "Srikanth Yalavarthi <syalavarthi@marvell.com>",
        "CC": "<dev@dpdk.org>, <sshankarnara@marvell.com>, <jerinj@marvell.com>,\n <aprabhu@marvell.com>",
        "Subject": "[PATCH v4 19/39] ml/cnxk: enable support to stop an ML models",
        "Date": "Wed, 1 Feb 2023 01:22:50 -0800",
        "Message-ID": "<20230201092310.23252-20-syalavarthi@marvell.com>",
        "X-Mailer": "git-send-email 2.17.1",
        "In-Reply-To": "<20230201092310.23252-1-syalavarthi@marvell.com>",
        "References": "<20221208200220.20267-1-syalavarthi@marvell.com>\n <20230201092310.23252-1-syalavarthi@marvell.com>",
        "MIME-Version": "1.0",
        "Content-Type": "text/plain",
        "X-Proofpoint-GUID": "AzUqTEBYdatZa5vxEFXqh49XsKlyBIAV",
        "X-Proofpoint-ORIG-GUID": "AzUqTEBYdatZa5vxEFXqh49XsKlyBIAV",
        "X-Proofpoint-Virus-Version": "vendor=baseguard\n engine=ICAP:2.0.219,Aquarius:18.0.930,Hydra:6.0.562,FMLib:17.11.122.1\n definitions=2023-02-01_03,2023-01-31_01,2022-06-22_01",
        "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"
    },
    "content": "Implemented model stop driver function. A model stop job is\nenqueued through scratch registers and is checked for\ncompletion through polling in a synchronous mode. OCM pages\nare released after model stop completion.\n\nSigned-off-by: Srikanth Yalavarthi <syalavarthi@marvell.com>\n---\n drivers/ml/cnxk/cn10k_ml_ops.c | 115 ++++++++++++++++++++++++++++++++-\n drivers/ml/cnxk/cn10k_ml_ops.h |   1 +\n 2 files changed, 114 insertions(+), 2 deletions(-)",
    "diff": "diff --git a/drivers/ml/cnxk/cn10k_ml_ops.c b/drivers/ml/cnxk/cn10k_ml_ops.c\nindex 65f69ba8fb..295b7794ec 100644\n--- a/drivers/ml/cnxk/cn10k_ml_ops.c\n+++ b/drivers/ml/cnxk/cn10k_ml_ops.c\n@@ -295,10 +295,14 @@ cn10k_ml_dev_configure(struct rte_ml_dev *dev, const struct rte_ml_dev_config *c\n \t\t/* Re-configure */\n \t\tvoid **models;\n \n-\t\t/* Unload all models */\n+\t\t/* Stop and unload all models */\n \t\tfor (model_id = 0; model_id < dev->data->nb_models; model_id++) {\n \t\t\tmodel = dev->data->models[model_id];\n \t\t\tif (model != NULL) {\n+\t\t\t\tif (model->state == ML_CN10K_MODEL_STATE_STARTED) {\n+\t\t\t\t\tif (cn10k_ml_model_stop(dev, model_id) != 0)\n+\t\t\t\t\t\tplt_err(\"Could not stop model %d\", model_id);\n+\t\t\t\t}\n \t\t\t\tif (model->state == ML_CN10K_MODEL_STATE_LOADED) {\n \t\t\t\t\tif (cn10k_ml_model_unload(dev, model_id) != 0)\n \t\t\t\t\t\tplt_err(\"Could not unload model %d\", model_id);\n@@ -362,10 +366,14 @@ cn10k_ml_dev_close(struct rte_ml_dev *dev)\n \n \tmldev = dev->data->dev_private;\n \n-\t/* Unload all models */\n+\t/* Stop and unload all models */\n \tfor (model_id = 0; model_id < dev->data->nb_models; model_id++) {\n \t\tmodel = dev->data->models[model_id];\n \t\tif (model != NULL) {\n+\t\t\tif (model->state == ML_CN10K_MODEL_STATE_STARTED) {\n+\t\t\t\tif (cn10k_ml_model_stop(dev, model_id) != 0)\n+\t\t\t\t\tplt_err(\"Could not stop model %d\", model_id);\n+\t\t\t}\n \t\t\tif (model->state == ML_CN10K_MODEL_STATE_LOADED) {\n \t\t\t\tif (cn10k_ml_model_unload(dev, model_id) != 0)\n \t\t\t\t\tplt_err(\"Could not unload model %d\", model_id);\n@@ -767,6 +775,108 @@ cn10k_ml_model_start(struct rte_ml_dev *dev, int16_t model_id)\n \treturn ret;\n }\n \n+int\n+cn10k_ml_model_stop(struct rte_ml_dev *dev, int16_t model_id)\n+{\n+\tstruct cn10k_ml_model *model;\n+\tstruct cn10k_ml_dev *mldev;\n+\tstruct cn10k_ml_ocm *ocm;\n+\tstruct cn10k_ml_req *req;\n+\n+\tbool job_enqueued;\n+\tbool job_dequeued;\n+\tbool locked;\n+\tint ret = 0;\n+\n+\tmldev = dev->data->dev_private;\n+\tocm = &mldev->ocm;\n+\tmodel = dev->data->models[model_id];\n+\n+\tif (model == NULL) {\n+\t\tplt_err(\"Invalid model_id = %d\", model_id);\n+\t\treturn -EINVAL;\n+\t}\n+\n+\t/* Prepare JD */\n+\treq = model->req;\n+\tcn10k_ml_prep_sp_job_descriptor(mldev, model, req, ML_CN10K_JOB_TYPE_MODEL_STOP);\n+\treq->result.error_code = 0x0;\n+\treq->result.user_ptr = NULL;\n+\n+\tplt_write64(ML_CN10K_POLL_JOB_START, &req->status);\n+\tplt_wmb();\n+\n+\tlocked = false;\n+\twhile (!locked) {\n+\t\tif (plt_spinlock_trylock(&model->lock) != 0) {\n+\t\t\tif (model->state == ML_CN10K_MODEL_STATE_LOADED) {\n+\t\t\t\tplt_ml_dbg(\"Model not started, model = 0x%016lx\",\n+\t\t\t\t\t   PLT_U64_CAST(model));\n+\t\t\t\tplt_spinlock_unlock(&model->lock);\n+\t\t\t\treturn 1;\n+\t\t\t}\n+\n+\t\t\tif (model->state == ML_CN10K_MODEL_STATE_JOB_ACTIVE) {\n+\t\t\t\tplt_err(\"A slow-path job is active for the model = 0x%016lx\",\n+\t\t\t\t\tPLT_U64_CAST(model));\n+\t\t\t\tplt_spinlock_unlock(&model->lock);\n+\t\t\t\treturn -EBUSY;\n+\t\t\t}\n+\n+\t\t\tmodel->state = ML_CN10K_MODEL_STATE_JOB_ACTIVE;\n+\t\t\tplt_spinlock_unlock(&model->lock);\n+\t\t\tlocked = true;\n+\t\t}\n+\t}\n+\n+\twhile (model->model_mem_map.ocm_reserved) {\n+\t\tif (plt_spinlock_trylock(&ocm->lock) != 0) {\n+\t\t\tcn10k_ml_ocm_free_pages(dev, model->model_id);\n+\t\t\tmodel->model_mem_map.ocm_reserved = false;\n+\t\t\tmodel->model_mem_map.tilemask = 0x0;\n+\t\t\tplt_spinlock_unlock(&ocm->lock);\n+\t\t}\n+\t}\n+\n+\tjob_enqueued = false;\n+\tjob_dequeued = false;\n+\tdo {\n+\t\tif (!job_enqueued) {\n+\t\t\treq->timeout = plt_tsc_cycles() + ML_CN10K_CMD_TIMEOUT * plt_tsc_hz();\n+\t\t\tjob_enqueued = roc_ml_scratch_enqueue(&mldev->roc, &req->jd);\n+\t\t}\n+\n+\t\tif (job_enqueued && !job_dequeued)\n+\t\t\tjob_dequeued = roc_ml_scratch_dequeue(&mldev->roc, &req->jd);\n+\n+\t\tif (job_dequeued)\n+\t\t\tbreak;\n+\t} while (plt_tsc_cycles() < req->timeout);\n+\n+\tif (job_dequeued) {\n+\t\tif (plt_read64(&req->status) == ML_CN10K_POLL_JOB_FINISH) {\n+\t\t\tif (req->result.error_code == 0x0)\n+\t\t\t\tret = 0;\n+\t\t\telse\n+\t\t\t\tret = -1;\n+\t\t}\n+\t} else {\n+\t\troc_ml_scratch_queue_reset(&mldev->roc);\n+\t\tret = -ETIME;\n+\t}\n+\n+\tlocked = false;\n+\twhile (!locked) {\n+\t\tif (plt_spinlock_trylock(&model->lock) != 0) {\n+\t\t\tmodel->state = ML_CN10K_MODEL_STATE_LOADED;\n+\t\t\tplt_spinlock_unlock(&model->lock);\n+\t\t\tlocked = true;\n+\t\t}\n+\t}\n+\n+\treturn ret;\n+}\n+\n struct rte_ml_dev_ops cn10k_ml_ops = {\n \t/* Device control ops */\n \t.dev_info_get = cn10k_ml_dev_info_get,\n@@ -783,4 +893,5 @@ struct rte_ml_dev_ops cn10k_ml_ops = {\n \t.model_load = cn10k_ml_model_load,\n \t.model_unload = cn10k_ml_model_unload,\n \t.model_start = cn10k_ml_model_start,\n+\t.model_stop = cn10k_ml_model_stop,\n };\ndiff --git a/drivers/ml/cnxk/cn10k_ml_ops.h b/drivers/ml/cnxk/cn10k_ml_ops.h\nindex af2ea19dce..3143c9054c 100644\n--- a/drivers/ml/cnxk/cn10k_ml_ops.h\n+++ b/drivers/ml/cnxk/cn10k_ml_ops.h\n@@ -65,5 +65,6 @@ int cn10k_ml_model_load(struct rte_ml_dev *dev, struct rte_ml_model_params *para\n \t\t\tint16_t *model_id);\n int cn10k_ml_model_unload(struct rte_ml_dev *dev, int16_t model_id);\n int cn10k_ml_model_start(struct rte_ml_dev *dev, int16_t model_id);\n+int cn10k_ml_model_stop(struct rte_ml_dev *dev, int16_t model_id);\n \n #endif /* _CN10K_ML_OPS_H_ */\n",
    "prefixes": [
        "v4",
        "19/39"
    ]
}