get:
Show a patch.

patch:
Update a patch.

put:
Update a patch.

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

{
    "id": 71240,
    "url": "http://patches.dpdk.org/api/patches/71240/?format=api",
    "web_url": "http://patches.dpdk.org/project/dpdk/patch/20200611084330.18301-2-qi.z.zhang@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": "<20200611084330.18301-2-qi.z.zhang@intel.com>",
    "list_archive_url": "https://inbox.dpdk.org/dev/20200611084330.18301-2-qi.z.zhang@intel.com",
    "date": "2020-06-11T08:43:21",
    "name": "[01/10] net/ice/base: adjust profile id map locks",
    "commit_ref": null,
    "pull_url": null,
    "state": "accepted",
    "archived": true,
    "hash": "17470f7724d7c9cfff7ae810bd4e338a074a6882",
    "submitter": {
        "id": 504,
        "url": "http://patches.dpdk.org/api/people/504/?format=api",
        "name": "Qi Zhang",
        "email": "qi.z.zhang@intel.com"
    },
    "delegate": {
        "id": 31221,
        "url": "http://patches.dpdk.org/api/users/31221/?format=api",
        "username": "yexl",
        "first_name": "xiaolong",
        "last_name": "ye",
        "email": "xiaolong.ye@intel.com"
    },
    "mbox": "http://patches.dpdk.org/project/dpdk/patch/20200611084330.18301-2-qi.z.zhang@intel.com/mbox/",
    "series": [
        {
            "id": 10404,
            "url": "http://patches.dpdk.org/api/series/10404/?format=api",
            "web_url": "http://patches.dpdk.org/project/dpdk/list/?series=10404",
            "date": "2020-06-11T08:43:20",
            "name": "net/ice: base code update for 20.08 batch 2",
            "version": 1,
            "mbox": "http://patches.dpdk.org/series/10404/mbox/"
        }
    ],
    "comments": "http://patches.dpdk.org/api/patches/71240/comments/",
    "check": "success",
    "checks": "http://patches.dpdk.org/api/patches/71240/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 12B35A00C5;\n\tThu, 11 Jun 2020 10:39:45 +0200 (CEST)",
            "from [92.243.14.124] (localhost [127.0.0.1])\n\tby dpdk.org (Postfix) with ESMTP id 4210614581;\n\tThu, 11 Jun 2020 10:39:39 +0200 (CEST)",
            "from mga17.intel.com (mga17.intel.com [192.55.52.151])\n by dpdk.org (Postfix) with ESMTP id 68D0C49E0\n for <dev@dpdk.org>; Thu, 11 Jun 2020 10:39:35 +0200 (CEST)",
            "from orsmga004.jf.intel.com ([10.7.209.38])\n by fmsmga107.fm.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384;\n 11 Jun 2020 01:39:35 -0700",
            "from dpdk51.sh.intel.com ([10.67.111.82])\n by orsmga004.jf.intel.com with ESMTP; 11 Jun 2020 01:39:33 -0700"
        ],
        "IronPort-SDR": [
            "\n 2g0Fy2Uf1f3+hpY5cDrm/1cBC/ocMYRna7+9hAShSa28noZEALemsfKOWjjt/ZzUo1tZ6mgrKn\n 3nvf+D5JmsDw==",
            "\n TxSEnkOiehr/llAdJ8r6SKwRd7BLA6WNlhYcz+GY906iZI9/QUHzNBrr/UNBMe4f+XgvoHZ4vG\n h84zyKORNPeQ=="
        ],
        "X-Amp-Result": "SKIPPED(no attachment in message)",
        "X-Amp-File-Uploaded": "False",
        "X-ExtLoop1": "1",
        "X-IronPort-AV": "E=Sophos;i=\"5.73,499,1583222400\"; d=\"scan'208\";a=\"419039122\"",
        "From": "Qi Zhang <qi.z.zhang@intel.com>",
        "To": "qiming.yang@intel.com",
        "Cc": "dev@dpdk.org, xiaolong.ye@intel.com, Qi Zhang <qi.z.zhang@intel.com>,\n Victor Raj <victor.raj@intel.com>,\n Paul M Stillwell Jr <paul.m.stillwell.jr@intel.com>",
        "Date": "Thu, 11 Jun 2020 16:43:21 +0800",
        "Message-Id": "<20200611084330.18301-2-qi.z.zhang@intel.com>",
        "X-Mailer": "git-send-email 2.13.6",
        "In-Reply-To": "<20200611084330.18301-1-qi.z.zhang@intel.com>",
        "References": "<20200611084330.18301-1-qi.z.zhang@intel.com>",
        "Subject": "[dpdk-dev] [PATCH 01/10] net/ice/base: adjust profile id map locks",
        "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": "The profile id map lock should be held till the caller completes\nall references of that profile entries.\n\nThe current code releases the lock right after the match search.\nThis caused a driver issue when the profile map entries were\nreferenced after it was freed in other thread after the lock was\nreleased earlier.\n\nAlso return type of get/set profile functions were changed to\nreturn the ice status instead of the profile entry pointer.\nThis will prevent the caller referencing the profile fields\noutside the lock.\n\nSigned-off-by: Victor Raj <victor.raj@intel.com>\nSigned-off-by: Paul M Stillwell Jr <paul.m.stillwell.jr@intel.com>\nSigned-off-by: Qi Zhang <qi.z.zhang@intel.com>\n---\n drivers/net/ice/base/ice_flex_pipe.c | 95 ++++++++++++++++++------------------\n drivers/net/ice/base/ice_flow.c      | 16 ++++--\n 2 files changed, 58 insertions(+), 53 deletions(-)",
    "diff": "diff --git a/drivers/net/ice/base/ice_flex_pipe.c b/drivers/net/ice/base/ice_flex_pipe.c\nindex f953d891d..016dc2b39 100644\n--- a/drivers/net/ice/base/ice_flex_pipe.c\n+++ b/drivers/net/ice/base/ice_flex_pipe.c\n@@ -4710,22 +4710,21 @@ ice_add_prof(struct ice_hw *hw, enum ice_block blk, u64 id, u8 ptypes[],\n }\n \n /**\n- * ice_search_prof_id_low - Search for a profile tracking ID low level\n+ * ice_search_prof_id - Search for a profile tracking ID\n  * @hw: pointer to the HW struct\n  * @blk: hardware block\n  * @id: profile tracking ID\n  *\n- * This will search for a profile tracking ID which was previously added. This\n- * version assumes that the caller has already acquired the prof map lock.\n+ * This will search for a profile tracking ID which was previously added.\n+ * The profile map lock should be held before calling this function.\n  */\n-static struct ice_prof_map *\n-ice_search_prof_id_low(struct ice_hw *hw, enum ice_block blk, u64 id)\n+struct ice_prof_map *\n+ice_search_prof_id(struct ice_hw *hw, enum ice_block blk, u64 id)\n {\n \tstruct ice_prof_map *entry = NULL;\n \tstruct ice_prof_map *map;\n \n-\tLIST_FOR_EACH_ENTRY(map, &hw->blk[blk].es.prof_map, ice_prof_map,\n-\t\t\t    list)\n+\tLIST_FOR_EACH_ENTRY(map, &hw->blk[blk].es.prof_map, ice_prof_map, list)\n \t\tif (map->profile_cookie == id) {\n \t\t\tentry = map;\n \t\t\tbreak;\n@@ -4735,26 +4734,6 @@ ice_search_prof_id_low(struct ice_hw *hw, enum ice_block blk, u64 id)\n }\n \n /**\n- * ice_search_prof_id - Search for a profile tracking ID\n- * @hw: pointer to the HW struct\n- * @blk: hardware block\n- * @id: profile tracking ID\n- *\n- * This will search for a profile tracking ID which was previously added.\n- */\n-struct ice_prof_map *\n-ice_search_prof_id(struct ice_hw *hw, enum ice_block blk, u64 id)\n-{\n-\tstruct ice_prof_map *entry;\n-\n-\tice_acquire_lock(&hw->blk[blk].es.prof_map_lock);\n-\tentry = ice_search_prof_id_low(hw, blk, id);\n-\tice_release_lock(&hw->blk[blk].es.prof_map_lock);\n-\n-\treturn entry;\n-}\n-\n-/**\n  * ice_vsig_prof_id_count - count profiles in a VSIG\n  * @hw: pointer to the HW struct\n  * @blk: hardware block\n@@ -4969,7 +4948,7 @@ enum ice_status ice_rem_prof(struct ice_hw *hw, enum ice_block blk, u64 id)\n \n \tice_acquire_lock(&hw->blk[blk].es.prof_map_lock);\n \n-\tpmap = ice_search_prof_id_low(hw, blk, id);\n+\tpmap = ice_search_prof_id(hw, blk, id);\n \tif (!pmap) {\n \t\tstatus = ICE_ERR_DOES_NOT_EXIST;\n \t\tgoto err_ice_rem_prof;\n@@ -5002,21 +4981,27 @@ static enum ice_status\n ice_get_prof(struct ice_hw *hw, enum ice_block blk, u64 hdl,\n \t     struct LIST_HEAD_TYPE *chg)\n {\n+\tenum ice_status status = ICE_SUCCESS;\n \tstruct ice_prof_map *map;\n \tstruct ice_chs_chg *p;\n \tu16 i;\n \n+\tice_acquire_lock(&hw->blk[blk].es.prof_map_lock);\n \t/* Get the details on the profile specified by the handle ID */\n \tmap = ice_search_prof_id(hw, blk, hdl);\n-\tif (!map)\n-\t\treturn ICE_ERR_DOES_NOT_EXIST;\n+\tif (!map) {\n+\t\tstatus = ICE_ERR_DOES_NOT_EXIST;\n+\t\tgoto err_ice_get_prof;\n+\t}\n \n \tfor (i = 0; i < map->ptg_cnt; i++)\n \t\tif (!hw->blk[blk].es.written[map->prof_id]) {\n \t\t\t/* add ES to change list */\n \t\t\tp = (struct ice_chs_chg *)ice_malloc(hw, sizeof(*p));\n-\t\t\tif (!p)\n+\t\t\tif (!p) {\n+\t\t\t\tstatus = ICE_ERR_NO_MEMORY;\n \t\t\t\tgoto err_ice_get_prof;\n+\t\t\t}\n \n \t\t\tp->type = ICE_PTG_ES_ADD;\n \t\t\tp->ptype = 0;\n@@ -5032,11 +5017,10 @@ ice_get_prof(struct ice_hw *hw, enum ice_block blk, u64 hdl,\n \t\t\tLIST_ADD(&p->list_entry, chg);\n \t\t}\n \n-\treturn ICE_SUCCESS;\n-\n err_ice_get_prof:\n+\tice_release_lock(&hw->blk[blk].es.prof_map_lock);\n \t/* let caller clean up the change list */\n-\treturn ICE_ERR_NO_MEMORY;\n+\treturn status;\n }\n \n /**\n@@ -5090,17 +5074,23 @@ static enum ice_status\n ice_add_prof_to_lst(struct ice_hw *hw, enum ice_block blk,\n \t\t    struct LIST_HEAD_TYPE *lst, u64 hdl)\n {\n+\tenum ice_status status = ICE_SUCCESS;\n \tstruct ice_prof_map *map;\n \tstruct ice_vsig_prof *p;\n \tu16 i;\n \n+\tice_acquire_lock(&hw->blk[blk].es.prof_map_lock);\n \tmap = ice_search_prof_id(hw, blk, hdl);\n-\tif (!map)\n-\t\treturn ICE_ERR_DOES_NOT_EXIST;\n+\tif (!map) {\n+\t\tstatus = ICE_ERR_DOES_NOT_EXIST;\n+\t\tgoto err_ice_add_prof_to_lst;\n+\t}\n \n \tp = (struct ice_vsig_prof *)ice_malloc(hw, sizeof(*p));\n-\tif (!p)\n-\t\treturn ICE_ERR_NO_MEMORY;\n+\tif (!p) {\n+\t\tstatus = ICE_ERR_NO_MEMORY;\n+\t\tgoto err_ice_add_prof_to_lst;\n+\t}\n \n \tp->profile_cookie = map->profile_cookie;\n \tp->prof_id = map->prof_id;\n@@ -5115,7 +5105,9 @@ ice_add_prof_to_lst(struct ice_hw *hw, enum ice_block blk,\n \n \tLIST_ADD(&p->list, lst);\n \n-\treturn ICE_SUCCESS;\n+err_ice_add_prof_to_lst:\n+\tice_release_lock(&hw->blk[blk].es.prof_map_lock);\n+\treturn status;\n }\n \n /**\n@@ -5399,16 +5391,12 @@ ice_add_prof_id_vsig(struct ice_hw *hw, enum ice_block blk, u16 vsig, u64 hdl,\n \tu8 vl_msk[ICE_TCAM_KEY_VAL_SZ] = { 0xFF, 0xFF, 0xFF, 0xFF, 0xFF };\n \tu8 dc_msk[ICE_TCAM_KEY_VAL_SZ] = { 0xFF, 0xFF, 0x00, 0x00, 0x00 };\n \tu8 nm_msk[ICE_TCAM_KEY_VAL_SZ] = { 0x00, 0x00, 0x00, 0x00, 0x00 };\n+\tenum ice_status status = ICE_SUCCESS;\n \tstruct ice_prof_map *map;\n \tstruct ice_vsig_prof *t;\n \tstruct ice_chs_chg *p;\n \tu16 vsig_idx, i;\n \n-\t/* Get the details on the profile specified by the handle ID */\n-\tmap = ice_search_prof_id(hw, blk, hdl);\n-\tif (!map)\n-\t\treturn ICE_ERR_DOES_NOT_EXIST;\n-\n \t/* Error, if this VSIG already has this profile */\n \tif (ice_has_prof_vsig(hw, blk, vsig, hdl))\n \t\treturn ICE_ERR_ALREADY_EXISTS;\n@@ -5418,19 +5406,28 @@ ice_add_prof_id_vsig(struct ice_hw *hw, enum ice_block blk, u16 vsig, u64 hdl,\n \tif (!t)\n \t\treturn ICE_ERR_NO_MEMORY;\n \n+\tice_acquire_lock(&hw->blk[blk].es.prof_map_lock);\n+\t/* Get the details on the profile specified by the handle ID */\n+\tmap = ice_search_prof_id(hw, blk, hdl);\n+\tif (!map) {\n+\t\tstatus = ICE_ERR_DOES_NOT_EXIST;\n+\t\tgoto err_ice_add_prof_id_vsig;\n+\t}\n+\n \tt->profile_cookie = map->profile_cookie;\n \tt->prof_id = map->prof_id;\n \tt->tcam_count = map->ptg_cnt;\n \n \t/* create TCAM entries */\n \tfor (i = 0; i < map->ptg_cnt; i++) {\n-\t\tenum ice_status status;\n \t\tu16 tcam_idx;\n \n \t\t/* add TCAM to change list */\n \t\tp = (struct ice_chs_chg *)ice_malloc(hw, sizeof(*p));\n-\t\tif (!p)\n+\t\tif (!p) {\n+\t\t\tstatus = ICE_ERR_NO_MEMORY;\n \t\t\tgoto err_ice_add_prof_id_vsig;\n+\t\t}\n \n \t\t/* allocate the TCAM entry index */\n \t\t/* for entries with empty attribute masks, allocate entry from\n@@ -5484,12 +5481,14 @@ ice_add_prof_id_vsig(struct ice_hw *hw, enum ice_block blk, u16 vsig, u64 hdl,\n \t\tLIST_ADD(&t->list,\n \t\t\t &hw->blk[blk].xlt2.vsig_tbl[vsig_idx].prop_lst);\n \n-\treturn ICE_SUCCESS;\n+\tice_release_lock(&hw->blk[blk].es.prof_map_lock);\n+\treturn status;\n \n err_ice_add_prof_id_vsig:\n+\tice_release_lock(&hw->blk[blk].es.prof_map_lock);\n \t/* let caller clean up the change list */\n \tice_free(hw, t);\n-\treturn ICE_ERR_NO_MEMORY;\n+\treturn status;\n }\n \n /**\ndiff --git a/drivers/net/ice/base/ice_flow.c b/drivers/net/ice/base/ice_flow.c\nindex 1e944bf52..fb0e34e5f 100644\n--- a/drivers/net/ice/base/ice_flow.c\n+++ b/drivers/net/ice/base/ice_flow.c\n@@ -2215,15 +2215,17 @@ enum ice_status\n ice_flow_get_hw_prof(struct ice_hw *hw, enum ice_block blk, u64 prof_id,\n \t\t     u8 *hw_prof_id)\n {\n+\tenum ice_status status = ICE_ERR_DOES_NOT_EXIST;\n \tstruct ice_prof_map *map;\n \n+\tice_acquire_lock(&hw->blk[blk].es.prof_map_lock);\n \tmap = ice_search_prof_id(hw, blk, prof_id);\n \tif (map) {\n \t\t*hw_prof_id = map->prof_id;\n-\t\treturn ICE_SUCCESS;\n+\t\tstatus = ICE_SUCCESS;\n \t}\n-\n-\treturn ICE_ERR_DOES_NOT_EXIST;\n+\tice_release_lock(&hw->blk[blk].es.prof_map_lock);\n+\treturn status;\n }\n \n /**\n@@ -3456,9 +3458,13 @@ ice_rss_update_symm(struct ice_hw *hw,\n \tstruct ice_prof_map *map;\n \tu8 prof_id, m;\n \n+\tice_acquire_lock(&hw->blk[ICE_BLK_RSS].es.prof_map_lock);\n \tmap = ice_search_prof_id(hw, ICE_BLK_RSS, prof->id);\n-\tprof_id = map->prof_id;\n-\n+\tif (map)\n+\t\tprof_id = map->prof_id;\n+\tice_release_lock(&hw->blk[ICE_BLK_RSS].es.prof_map_lock);\n+\tif (!map)\n+\t\treturn;\n \t/* clear to default */\n \tfor (m = 0; m < 6; m++)\n \t\twr32(hw, GLQF_HSYMM(prof_id, m), 0);\n",
    "prefixes": [
        "01/10"
    ]
}