get:
Show a patch.

patch:
Update a patch.

put:
Update a patch.

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

{
    "id": 90229,
    "url": "http://patchwork.dpdk.org/api/patches/90229/?format=api",
    "web_url": "http://patchwork.dpdk.org/project/dpdk/patch/1617184904-55349-3-git-send-email-humin29@huawei.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": "<1617184904-55349-3-git-send-email-humin29@huawei.com>",
    "list_archive_url": "https://inbox.dpdk.org/dev/1617184904-55349-3-git-send-email-humin29@huawei.com",
    "date": "2021-03-31T10:01:36",
    "name": "[02/10] net/hns3: fix set default MAC addr fail in bonding of VF",
    "commit_ref": null,
    "pull_url": null,
    "state": "accepted",
    "archived": true,
    "hash": "fbf09dc7fadd26d239726e17a9c38de1a3d2153a",
    "submitter": {
        "id": 1944,
        "url": "http://patchwork.dpdk.org/api/people/1944/?format=api",
        "name": "humin (Q)",
        "email": "humin29@huawei.com"
    },
    "delegate": {
        "id": 319,
        "url": "http://patchwork.dpdk.org/api/users/319/?format=api",
        "username": "fyigit",
        "first_name": "Ferruh",
        "last_name": "Yigit",
        "email": "ferruh.yigit@amd.com"
    },
    "mbox": "http://patchwork.dpdk.org/project/dpdk/patch/1617184904-55349-3-git-send-email-humin29@huawei.com/mbox/",
    "series": [
        {
            "id": 16009,
            "url": "http://patchwork.dpdk.org/api/series/16009/?format=api",
            "web_url": "http://patchwork.dpdk.org/project/dpdk/list/?series=16009",
            "date": "2021-03-31T10:01:38",
            "name": "some bugfixes for hns3 PMD",
            "version": 1,
            "mbox": "http://patchwork.dpdk.org/series/16009/mbox/"
        }
    ],
    "comments": "http://patchwork.dpdk.org/api/patches/90229/comments/",
    "check": "warning",
    "checks": "http://patchwork.dpdk.org/api/patches/90229/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 B6BFBA034F;\n\tWed, 31 Mar 2021 12:02:23 +0200 (CEST)",
            "from [217.70.189.124] (localhost [127.0.0.1])\n\tby mails.dpdk.org (Postfix) with ESMTP id 84CA6140EBA;\n\tWed, 31 Mar 2021 12:01:39 +0200 (CEST)",
            "from szxga07-in.huawei.com (szxga07-in.huawei.com [45.249.212.35])\n by mails.dpdk.org (Postfix) with ESMTP id D43F5140E4B\n for <dev@dpdk.org>; Wed, 31 Mar 2021 12:01:26 +0200 (CEST)",
            "from DGGEMS403-HUB.china.huawei.com (unknown [172.30.72.60])\n by szxga07-in.huawei.com (SkyGuard) with ESMTP id 4F9MGt1XPHz9v4b\n for <dev@dpdk.org>; Wed, 31 Mar 2021 17:59:18 +0800 (CST)",
            "from localhost.localdomain (10.69.192.56) by\n DGGEMS403-HUB.china.huawei.com (10.3.19.203) with Microsoft SMTP Server id\n 14.3.498.0; Wed, 31 Mar 2021 18:01:18 +0800"
        ],
        "From": "\"Min Hu (Connor)\" <humin29@huawei.com>",
        "To": "<dev@dpdk.org>",
        "CC": "<ferruh.yigit@intel.com>",
        "Date": "Wed, 31 Mar 2021 18:01:36 +0800",
        "Message-ID": "<1617184904-55349-3-git-send-email-humin29@huawei.com>",
        "X-Mailer": "git-send-email 2.7.4",
        "In-Reply-To": "<1617184904-55349-1-git-send-email-humin29@huawei.com>",
        "References": "<1617184904-55349-1-git-send-email-humin29@huawei.com>",
        "MIME-Version": "1.0",
        "Content-Type": "text/plain",
        "X-Originating-IP": "[10.69.192.56]",
        "X-CFilter-Loop": "Reflected",
        "Subject": "[dpdk-dev] [PATCH 02/10] net/hns3: fix set default MAC addr fail in\n bonding of VF",
        "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",
        "Sender": "\"dev\" <dev-bounces@dpdk.org>"
    },
    "content": "From: Chengwen Feng <fengchengwen@huawei.com>\n\nWhen start testpmd with two hns3 VFs(0000:bd:01.0, 0000:bd:01.7), and\nthen execute the following commands:\n\ttestpmd> create bonded device 1 0\n\ttestpmd> set bonding mac_addr 2 3c:12:34:56:78:9a\n\ttestpmd> add bonding slave 0 2\n\ttestpmd> add bonding slave 1 2\n\ttestpmd> set portmask 0x4\n\ttestpmd> port start 2\n\nIt will occurs the following error in a low probability:\n\t0000:bd:01.0 hns3_get_mbx_resp(): VF could not get mbx(3,0)\n\t\thead(16) tail(15) lost(1) from PF in_irq:0\n\t0000:bd:01.0 hns3vf_set_default_mac_addr(): Failed to set mac\n\t\taddr(3C:**:**:**:78:9A) for vf: -62\n\tmac_address_slaves_update(1541) - Failed to update port Id 0\n\t\tMAC address\n\nThe problem replay:\n1. the 'port start 2' command will start slave ports and then set\nslave mac address, the function call flow: bond_ethdev_start ->\nmac_address_slaves_update.\n2. there are also a monitor task which running in intr thread will\ncheck slave ports link status and update slave ports mac address, the\nfunction call flow: bond_ethdev_slave_link_status_change_monitor ->\nbond_ethdev_lsc_event_callback -> mac_address_slaves_update.\n3. because the above step1&2 running on different threads, they may\nboth call drivers ops mac_addr_set which is\nhns3vf_set_default_mac_addr.\n4. hns3vf_set_default_mac_addr will first acquire hw.lock and then\nsend mailbox to PF and wait PF's response message.\nNote: the PF's response is an independent message which will received\nin hw.cmq.crq, the receiving operation can only performed in intr\nthread.\n5. so if the step1 operation hold the hw.lock and try get response\nmessage, and step2 operation try acquire the hw.lock and so it can't\nprocess the response message, this will lead to step1 fail.\n\nThe solution:\n1. make all threads could process the mailbox response message, which\nprotected by the hw.cmq.crq.lock.\n2. use the following rules to avoid deadlock:\n2.1. ensure use the correct locking sequence: hw.lock >\nhw.mbx_resp.lock > hw.cmq.crq.lock.\n2.2. make sure don't acquire such as hw.lock & hw.mbx_resp.lock again\nwhen process mailbox response message.\n\nFixes: 463e748964f5 (\"net/hns3: support mailbox\")\nCc: stable@dpdk.org\n\nSigned-off-by: Chengwen Feng <fengchengwen@huawei.com>\nSigned-off-by: Min Hu (Connor) <humin29@huawei.com>\n---\n drivers/net/hns3/hns3_ethdev.h    |  1 -\n drivers/net/hns3/hns3_ethdev_vf.c |  3 ---\n drivers/net/hns3/hns3_mbx.c       | 51 +++++++++++----------------------------\n 3 files changed, 14 insertions(+), 41 deletions(-)",
    "diff": "diff --git a/drivers/net/hns3/hns3_ethdev.h b/drivers/net/hns3/hns3_ethdev.h\nindex ac255a3..b11457b 100644\n--- a/drivers/net/hns3/hns3_ethdev.h\n+++ b/drivers/net/hns3/hns3_ethdev.h\n@@ -439,7 +439,6 @@ struct hns3_hw {\n \tstruct hns3_cmq cmq;\n \tstruct hns3_mbx_resp_status mbx_resp; /* mailbox response */\n \tstruct hns3_mbx_arq_ring arq;         /* mailbox async rx queue */\n-\tpthread_t irq_thread_id;\n \tstruct hns3_mac mac;\n \tunsigned int secondary_cnt; /* Number of secondary processes init'd. */\n \tstruct hns3_tqp_stats tqp_stats;\ndiff --git a/drivers/net/hns3/hns3_ethdev_vf.c b/drivers/net/hns3/hns3_ethdev_vf.c\nindex 6c3ddcc..f70106d 100644\n--- a/drivers/net/hns3/hns3_ethdev_vf.c\n+++ b/drivers/net/hns3/hns3_ethdev_vf.c\n@@ -1109,9 +1109,6 @@ hns3vf_interrupt_handler(void *param)\n \tenum hns3vf_evt_cause event_cause;\n \tuint32_t clearval;\n \n-\tif (hw->irq_thread_id == 0)\n-\t\thw->irq_thread_id = pthread_self();\n-\n \t/* Disable interrupt */\n \thns3vf_disable_irq0(hw);\n \ndiff --git a/drivers/net/hns3/hns3_mbx.c b/drivers/net/hns3/hns3_mbx.c\nindex 61d1584..ad0b4e6 100644\n--- a/drivers/net/hns3/hns3_mbx.c\n+++ b/drivers/net/hns3/hns3_mbx.c\n@@ -40,36 +40,14 @@ hns3_resp_to_errno(uint16_t resp_code)\n \treturn -EIO;\n }\n \n-static void\n-hns3_poll_all_sync_msg(void)\n-{\n-\tstruct rte_eth_dev *eth_dev;\n-\tstruct hns3_adapter *adapter;\n-\tconst char *name;\n-\tuint16_t port_id;\n-\n-\tRTE_ETH_FOREACH_DEV(port_id) {\n-\t\teth_dev = &rte_eth_devices[port_id];\n-\t\tname = eth_dev->device->driver->name;\n-\t\tif (strcmp(name, \"net_hns3\") && strcmp(name, \"net_hns3_vf\"))\n-\t\t\tcontinue;\n-\t\tadapter = eth_dev->data->dev_private;\n-\t\tif (!adapter || adapter->hw.adapter_state == HNS3_NIC_CLOSED)\n-\t\t\tcontinue;\n-\t\t/* Synchronous msg, the mbx_resp.req_msg_data is non-zero */\n-\t\tif (adapter->hw.mbx_resp.req_msg_data)\n-\t\t\thns3_dev_handle_mbx_msg(&adapter->hw);\n-\t}\n-}\n-\n static int\n hns3_get_mbx_resp(struct hns3_hw *hw, uint16_t code0, uint16_t code1,\n \t\t  uint8_t *resp_data, uint16_t resp_len)\n {\n #define HNS3_MAX_RETRY_MS\t500\n+#define HNS3_WAIT_RESP_US\t100\n \tstruct hns3_adapter *hns = HNS3_DEV_HW_TO_ADAPTER(hw);\n \tstruct hns3_mbx_resp_status *mbx_resp;\n-\tbool in_irq = false;\n \tuint64_t now;\n \tuint64_t end;\n \n@@ -96,26 +74,19 @@ hns3_get_mbx_resp(struct hns3_hw *hw, uint16_t code0, uint16_t code1,\n \t\t\treturn -EIO;\n \t\t}\n \n-\t\t/*\n-\t\t * The mbox response is running on the interrupt thread.\n-\t\t * Sending mbox in the interrupt thread cannot wait for the\n-\t\t * response, so polling the mbox response on the irq thread.\n-\t\t */\n-\t\tif (pthread_equal(hw->irq_thread_id, pthread_self())) {\n-\t\t\tin_irq = true;\n-\t\t\thns3_poll_all_sync_msg();\n-\t\t} else {\n-\t\t\trte_delay_ms(HNS3_POLL_RESPONE_MS);\n-\t\t}\n+\t\thns3_dev_handle_mbx_msg(hw);\n+\t\trte_delay_us(HNS3_WAIT_RESP_US);\n+\n \t\tnow = get_timeofday_ms();\n \t}\n \thw->mbx_resp.req_msg_data = 0;\n \tif (now >= end) {\n \t\thw->mbx_resp.lost++;\n \t\thns3_err(hw,\n-\t\t\t \"VF could not get mbx(%u,%u) head(%u) tail(%u) lost(%u) from PF in_irq:%d\",\n+\t\t\t \"VF could not get mbx(%u,%u) head(%u) tail(%u) \"\n+\t\t\t \"lost(%u) from PF\",\n \t\t\t code0, code1, hw->mbx_resp.head, hw->mbx_resp.tail,\n-\t\t\t hw->mbx_resp.lost, in_irq);\n+\t\t\t hw->mbx_resp.lost);\n \t\treturn -ETIME;\n \t}\n \trte_io_rmb();\n@@ -368,9 +339,13 @@ hns3_dev_handle_mbx_msg(struct hns3_hw *hw)\n \tuint8_t *temp;\n \tint i;\n \n+\trte_spinlock_lock(&hw->cmq.crq.lock);\n+\n \twhile (!hns3_cmd_crq_empty(hw)) {\n-\t\tif (__atomic_load_n(&hw->reset.disable_cmd, __ATOMIC_RELAXED))\n+\t\tif (__atomic_load_n(&hw->reset.disable_cmd, __ATOMIC_RELAXED)) {\n+\t\t\trte_spinlock_unlock(&hw->cmq.crq.lock);\n \t\t\treturn;\n+\t\t}\n \n \t\tdesc = &crq->desc[crq->next_to_use];\n \t\treq = (struct hns3_mbx_pf_to_vf_cmd *)desc->data;\n@@ -441,4 +416,6 @@ hns3_dev_handle_mbx_msg(struct hns3_hw *hw)\n \n \t/* Write back CMDQ_RQ header pointer, IMP need this pointer */\n \thns3_write_dev(hw, HNS3_CMDQ_RX_HEAD_REG, crq->next_to_use);\n+\n+\trte_spinlock_unlock(&hw->cmq.crq.lock);\n }\n",
    "prefixes": [
        "02/10"
    ]
}