get:
Show a patch.

patch:
Update a patch.

put:
Update a patch.

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

{
    "id": 1291762,
    "url": "http://patchwork.ozlabs.org/api/patches/1291762/?format=api",
    "web_url": "http://patchwork.ozlabs.org/project/intel-wired-lan/patch/20200516004226.4795-6-anthony.l.nguyen@intel.com/",
    "project": {
        "id": 46,
        "url": "http://patchwork.ozlabs.org/api/projects/46/?format=api",
        "name": "Intel Wired Ethernet development",
        "link_name": "intel-wired-lan",
        "list_id": "intel-wired-lan.osuosl.org",
        "list_email": "intel-wired-lan@osuosl.org",
        "web_url": "",
        "scm_url": "",
        "webscm_url": "",
        "list_archive_url": "",
        "list_archive_url_format": "",
        "commit_url_format": ""
    },
    "msgid": "<20200516004226.4795-6-anthony.l.nguyen@intel.com>",
    "list_archive_url": null,
    "date": "2020-05-16T00:42:18",
    "name": "[S44,06/14] ice: avoid undefined behavior",
    "commit_ref": null,
    "pull_url": null,
    "state": "accepted",
    "archived": false,
    "hash": "b631c5d71add3fbf8a2295dc311bcce888eaa770",
    "submitter": {
        "id": 68875,
        "url": "http://patchwork.ozlabs.org/api/people/68875/?format=api",
        "name": "Tony Nguyen",
        "email": "anthony.l.nguyen@intel.com"
    },
    "delegate": {
        "id": 68,
        "url": "http://patchwork.ozlabs.org/api/users/68/?format=api",
        "username": "jtkirshe",
        "first_name": "Jeff",
        "last_name": "Kirsher",
        "email": "jeffrey.t.kirsher@intel.com"
    },
    "mbox": "http://patchwork.ozlabs.org/project/intel-wired-lan/patch/20200516004226.4795-6-anthony.l.nguyen@intel.com/mbox/",
    "series": [
        {
            "id": 177328,
            "url": "http://patchwork.ozlabs.org/api/series/177328/?format=api",
            "web_url": "http://patchwork.ozlabs.org/project/intel-wired-lan/list/?series=177328",
            "date": "2020-05-16T00:42:13",
            "name": "[S44,01/14] ice: Don't allow VLAN stripping change when pvid set",
            "version": 1,
            "mbox": "http://patchwork.ozlabs.org/series/177328/mbox/"
        }
    ],
    "comments": "http://patchwork.ozlabs.org/api/patches/1291762/comments/",
    "check": "pending",
    "checks": "http://patchwork.ozlabs.org/api/patches/1291762/checks/",
    "tags": {},
    "related": [],
    "headers": {
        "Return-Path": "<intel-wired-lan-bounces@osuosl.org>",
        "X-Original-To": [
            "incoming@patchwork.ozlabs.org",
            "intel-wired-lan@lists.osuosl.org"
        ],
        "Delivered-To": [
            "patchwork-incoming@bilbo.ozlabs.org",
            "intel-wired-lan@lists.osuosl.org"
        ],
        "Authentication-Results": [
            "ozlabs.org;\n spf=pass (sender SPF authorized) smtp.mailfrom=osuosl.org\n (client-ip=140.211.166.136; helo=silver.osuosl.org;\n envelope-from=intel-wired-lan-bounces@osuosl.org; receiver=<UNKNOWN>)",
            "ozlabs.org;\n dmarc=fail (p=none dis=none) header.from=intel.com"
        ],
        "Received": [
            "from silver.osuosl.org (smtp3.osuosl.org [140.211.166.136])\n\t(using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits))\n\t(No client certificate requested)\n\tby ozlabs.org (Postfix) with ESMTPS id 49P64j5HWlz9sTC\n\tfor <incoming@patchwork.ozlabs.org>; Sat, 16 May 2020 10:45:09 +1000 (AEST)",
            "from localhost (localhost [127.0.0.1])\n\tby silver.osuosl.org (Postfix) with ESMTP id CB140227FF;\n\tSat, 16 May 2020 00:45:06 +0000 (UTC)",
            "from silver.osuosl.org ([127.0.0.1])\n\tby localhost (.osuosl.org [127.0.0.1]) (amavisd-new, port 10024)\n\twith ESMTP id xiC4KNW7MoVr; Sat, 16 May 2020 00:45:03 +0000 (UTC)",
            "from ash.osuosl.org (ash.osuosl.org [140.211.166.34])\n\tby silver.osuosl.org (Postfix) with ESMTP id 8B2AB2202E;\n\tSat, 16 May 2020 00:45:03 +0000 (UTC)",
            "from fraxinus.osuosl.org (smtp4.osuosl.org [140.211.166.137])\n by ash.osuosl.org (Postfix) with ESMTP id 169A11BF9C8\n for <intel-wired-lan@lists.osuosl.org>; Sat, 16 May 2020 00:45:02 +0000 (UTC)",
            "from localhost (localhost [127.0.0.1])\n by fraxinus.osuosl.org (Postfix) with ESMTP id 0C7F2881C1\n for <intel-wired-lan@lists.osuosl.org>; Sat, 16 May 2020 00:45:02 +0000 (UTC)",
            "from fraxinus.osuosl.org ([127.0.0.1])\n by localhost (.osuosl.org [127.0.0.1]) (amavisd-new, port 10024)\n with ESMTP id ArZYokgvATf0 for <intel-wired-lan@lists.osuosl.org>;\n Sat, 16 May 2020 00:45:01 +0000 (UTC)",
            "from mga02.intel.com (mga02.intel.com [134.134.136.20])\n by fraxinus.osuosl.org (Postfix) with ESMTPS id 482CE87F5F\n for <intel-wired-lan@lists.osuosl.org>; Sat, 16 May 2020 00:45:01 +0000 (UTC)",
            "from fmsmga004.fm.intel.com ([10.253.24.48])\n by orsmga101.jf.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384;\n 15 May 2020 17:45:00 -0700",
            "from unknown (HELO localhost.jf.intel.com) ([10.166.241.65])\n by fmsmga004.fm.intel.com with ESMTP; 15 May 2020 17:45:00 -0700"
        ],
        "X-Virus-Scanned": [
            "amavisd-new at osuosl.org",
            "amavisd-new at osuosl.org"
        ],
        "X-Greylist": "domain auto-whitelisted by SQLgrey-1.7.6",
        "IronPort-SDR": [
            "\n hYGL8Mi7FCxqf5t50mqNtj8McbO6/dC17u2G01oAapxX9TP+eHPzx7tz+PBD4jPjMdl8Cjo5F3\n gcBy72t5InSg==",
            "\n KlguEmZ+2+pfihVaRbCJzGCBqaXIGLDDLZVA2e4/Qiv3Cd55YXCC1g7EBdu8z6BTGm9DtDtawj\n LbDJv5FPjMCA=="
        ],
        "X-Amp-Result": "SKIPPED(no attachment in message)",
        "X-Amp-File-Uploaded": "False",
        "X-ExtLoop1": "1",
        "X-IronPort-AV": "E=Sophos;i=\"5.73,397,1583222400\"; d=\"scan'208\";a=\"287960349\"",
        "From": "Tony Nguyen <anthony.l.nguyen@intel.com>",
        "To": "intel-wired-lan@lists.osuosl.org",
        "Date": "Fri, 15 May 2020 17:42:18 -0700",
        "Message-Id": "<20200516004226.4795-6-anthony.l.nguyen@intel.com>",
        "X-Mailer": "git-send-email 2.20.1",
        "In-Reply-To": "<20200516004226.4795-1-anthony.l.nguyen@intel.com>",
        "References": "<20200516004226.4795-1-anthony.l.nguyen@intel.com>",
        "MIME-Version": "1.0",
        "Subject": "[Intel-wired-lan] [PATCH S44 06/14] ice: avoid undefined behavior",
        "X-BeenThere": "intel-wired-lan@osuosl.org",
        "X-Mailman-Version": "2.1.29",
        "Precedence": "list",
        "List-Id": "Intel Wired Ethernet Linux Kernel Driver Development\n <intel-wired-lan.osuosl.org>",
        "List-Unsubscribe": "<https://lists.osuosl.org/mailman/options/intel-wired-lan>,\n <mailto:intel-wired-lan-request@osuosl.org?subject=unsubscribe>",
        "List-Archive": "<http://lists.osuosl.org/pipermail/intel-wired-lan/>",
        "List-Post": "<mailto:intel-wired-lan@osuosl.org>",
        "List-Help": "<mailto:intel-wired-lan-request@osuosl.org?subject=help>",
        "List-Subscribe": "<https://lists.osuosl.org/mailman/listinfo/intel-wired-lan>,\n <mailto:intel-wired-lan-request@osuosl.org?subject=subscribe>",
        "Content-Type": "text/plain; charset=\"us-ascii\"",
        "Content-Transfer-Encoding": "7bit",
        "Errors-To": "intel-wired-lan-bounces@osuosl.org",
        "Sender": "\"Intel-wired-lan\" <intel-wired-lan-bounces@osuosl.org>"
    },
    "content": "From: Bruce Allan <bruce.w.allan@intel.com>\n\nWhen writing the driver's struct ice_tlan_ctx structure, do not write the\n8-bit element int_q_state with the associated internal-to-hardware field\nwhich is 122-bits, otherwise the helper function ice_write_byte() will use\nundefined behavior when setting the mask used for that write.  This should\nnot cause any functional change and will avoid use of undefined behavior.\nAlso, update a comment to highlight this structure element is not written.\n\nSigned-off-by: Bruce Allan <bruce.w.allan@intel.com>\nSigned-off-by: Tony Nguyen <anthony.l.nguyen@intel.com>\n---\n drivers/net/ethernet/intel/ice/ice_base.c      |  5 +++--\n drivers/net/ethernet/intel/ice/ice_common.c    | 12 ++++++++++--\n drivers/net/ethernet/intel/ice/ice_common.h    |  3 ++-\n drivers/net/ethernet/intel/ice/ice_lan_tx_rx.h |  2 +-\n 4 files changed, 16 insertions(+), 6 deletions(-)",
    "diff": "diff --git a/drivers/net/ethernet/intel/ice/ice_base.c b/drivers/net/ethernet/intel/ice/ice_base.c\nindex ff6a5cf8e06f..a964f5055f37 100644\n--- a/drivers/net/ethernet/intel/ice/ice_base.c\n+++ b/drivers/net/ethernet/intel/ice/ice_base.c\n@@ -638,6 +638,7 @@ ice_vsi_cfg_txq(struct ice_vsi *vsi, struct ice_ring *ring,\n \tstruct ice_aqc_add_txqs_perq *txq;\n \tstruct ice_pf *pf = vsi->back;\n \tu8 buf_len = sizeof(*qg_buf);\n+\tstruct ice_hw *hw = &pf->hw;\n \tenum ice_status status;\n \tu16 pf_q;\n \tu8 tc;\n@@ -646,13 +647,13 @@ ice_vsi_cfg_txq(struct ice_vsi *vsi, struct ice_ring *ring,\n \tice_setup_tx_ctx(ring, &tlan_ctx, pf_q);\n \t/* copy context contents into the qg_buf */\n \tqg_buf->txqs[0].txq_id = cpu_to_le16(pf_q);\n-\tice_set_ctx((u8 *)&tlan_ctx, qg_buf->txqs[0].txq_ctx,\n+\tice_set_ctx(hw, (u8 *)&tlan_ctx, qg_buf->txqs[0].txq_ctx,\n \t\t    ice_tlan_ctx_info);\n \n \t/* init queue specific tail reg. It is referred as\n \t * transmit comm scheduler queue doorbell.\n \t */\n-\tring->tail = pf->hw.hw_addr + QTX_COMM_DBELL(pf_q);\n+\tring->tail = hw->hw_addr + QTX_COMM_DBELL(pf_q);\n \n \tif (IS_ENABLED(CONFIG_DCB))\n \t\ttc = ring->dcb_tc;\ndiff --git a/drivers/net/ethernet/intel/ice/ice_common.c b/drivers/net/ethernet/intel/ice/ice_common.c\nindex b0bbba8e6f6c..8eccec1fa9e7 100644\n--- a/drivers/net/ethernet/intel/ice/ice_common.c\n+++ b/drivers/net/ethernet/intel/ice/ice_common.c\n@@ -1099,7 +1099,7 @@ ice_write_rxq_ctx(struct ice_hw *hw, struct ice_rlan_ctx *rlan_ctx,\n \n \trlan_ctx->prefena = 1;\n \n-\tice_set_ctx((u8 *)rlan_ctx, ctx_buf, ice_rlan_ctx_info);\n+\tice_set_ctx(hw, (u8 *)rlan_ctx, ctx_buf, ice_rlan_ctx_info);\n \treturn ice_copy_rxq_ctx_to_hw(hw, ctx_buf, rxq_index);\n }\n \n@@ -3268,12 +3268,14 @@ ice_write_qword(u8 *src_ctx, u8 *dest_ctx, const struct ice_ctx_ele *ce_info)\n \n /**\n  * ice_set_ctx - set context bits in packed structure\n+ * @hw: pointer to the hardware structure\n  * @src_ctx:  pointer to a generic non-packed context structure\n  * @dest_ctx: pointer to memory for the packed structure\n  * @ce_info:  a description of the structure to be transformed\n  */\n enum ice_status\n-ice_set_ctx(u8 *src_ctx, u8 *dest_ctx, const struct ice_ctx_ele *ce_info)\n+ice_set_ctx(struct ice_hw *hw, u8 *src_ctx, u8 *dest_ctx,\n+\t    const struct ice_ctx_ele *ce_info)\n {\n \tint f;\n \n@@ -3282,6 +3284,12 @@ ice_set_ctx(u8 *src_ctx, u8 *dest_ctx, const struct ice_ctx_ele *ce_info)\n \t\t * using the correct size so that we are correct regardless\n \t\t * of the endianness of the machine.\n \t\t */\n+\t\tif (ce_info[f].width > (ce_info[f].size_of * BITS_PER_BYTE)) {\n+\t\t\tice_debug(hw, ICE_DBG_QCTX,\n+\t\t\t\t  \"Field %d width of %d bits larger than size of %d byte(s) ... skipping write\\n\",\n+\t\t\t\t  f, ce_info[f].width, ce_info[f].size_of);\n+\t\t\tcontinue;\n+\t\t}\n \t\tswitch (ce_info[f].size_of) {\n \t\tcase sizeof(u8):\n \t\t\tice_write_byte(src_ctx, dest_ctx, &ce_info[f]);\ndiff --git a/drivers/net/ethernet/intel/ice/ice_common.h b/drivers/net/ethernet/intel/ice/ice_common.h\nindex 9bac3e46da33..2cfd684061e5 100644\n--- a/drivers/net/ethernet/intel/ice/ice_common.h\n+++ b/drivers/net/ethernet/intel/ice/ice_common.h\n@@ -70,7 +70,8 @@ enum ice_status ice_aq_q_shutdown(struct ice_hw *hw, bool unloading);\n void ice_fill_dflt_direct_cmd_desc(struct ice_aq_desc *desc, u16 opcode);\n extern const struct ice_ctx_ele ice_tlan_ctx_info[];\n enum ice_status\n-ice_set_ctx(u8 *src_ctx, u8 *dest_ctx, const struct ice_ctx_ele *ce_info);\n+ice_set_ctx(struct ice_hw *hw, u8 *src_ctx, u8 *dest_ctx,\n+\t    const struct ice_ctx_ele *ce_info);\n \n extern struct mutex ice_global_cfg_lock_sw;\n \ndiff --git a/drivers/net/ethernet/intel/ice/ice_lan_tx_rx.h b/drivers/net/ethernet/intel/ice/ice_lan_tx_rx.h\nindex bd2cd3435768..14dfbbc1b2cf 100644\n--- a/drivers/net/ethernet/intel/ice/ice_lan_tx_rx.h\n+++ b/drivers/net/ethernet/intel/ice/ice_lan_tx_rx.h\n@@ -581,7 +581,7 @@ struct ice_tlan_ctx {\n \tu8 drop_ena;\n \tu8 cache_prof_idx;\n \tu8 pkt_shaper_prof_idx;\n-\tu8 int_q_state;\t/* width not needed - internal do not write */\n+\tu8 int_q_state;\t/* width not needed - internal - DO NOT WRITE!!! */\n };\n \n /* macro to make the table lines short */\n",
    "prefixes": [
        "S44",
        "06/14"
    ]
}