get:
Show a patch.

patch:
Update a patch.

put:
Update a patch.

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

{
    "id": 791684,
    "url": "http://patchwork.ozlabs.org/api/patches/791684/?format=api",
    "web_url": "http://patchwork.ozlabs.org/project/intel-wired-lan/patch/20170720160058.8198-2-gedwards@ddn.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": "<20170720160058.8198-2-gedwards@ddn.com>",
    "list_archive_url": null,
    "date": "2017-07-20T16:00:57",
    "name": "[1/2] igbvf: add lock around mailbox ops",
    "commit_ref": null,
    "pull_url": null,
    "state": "accepted",
    "archived": false,
    "hash": "14932d503e8b04e4468ed15ac2c6c1690d4e34c5",
    "submitter": {
        "id": 71885,
        "url": "http://patchwork.ozlabs.org/api/people/71885/?format=api",
        "name": "Greg Edwards",
        "email": "gedwards@ddn.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/20170720160058.8198-2-gedwards@ddn.com/mbox/",
    "series": [],
    "comments": "http://patchwork.ozlabs.org/api/patches/791684/comments/",
    "check": "pending",
    "checks": "http://patchwork.ozlabs.org/api/patches/791684/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\tspf=pass (mailfrom) smtp.mailfrom=osuosl.org\n\t(client-ip=140.211.166.133; helo=hemlock.osuosl.org;\n\tenvelope-from=intel-wired-lan-bounces@osuosl.org;\n\treceiver=<UNKNOWN>)",
        "Received": [
            "from hemlock.osuosl.org (smtp2.osuosl.org [140.211.166.133])\n\t(using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits))\n\t(No client certificate requested)\n\tby ozlabs.org (Postfix) with ESMTPS id 3xCzDB2DFsz9s74\n\tfor <incoming@patchwork.ozlabs.org>;\n\tFri, 21 Jul 2017 02:01:46 +1000 (AEST)",
            "from localhost (localhost [127.0.0.1])\n\tby hemlock.osuosl.org (Postfix) with ESMTP id 66D928A46D;\n\tThu, 20 Jul 2017 16:01:44 +0000 (UTC)",
            "from hemlock.osuosl.org ([127.0.0.1])\n\tby localhost (.osuosl.org [127.0.0.1]) (amavisd-new, port 10024)\n\twith ESMTP id jssBbcg2Pq8U; Thu, 20 Jul 2017 16:01:43 +0000 (UTC)",
            "from ash.osuosl.org (ash.osuosl.org [140.211.166.34])\n\tby hemlock.osuosl.org (Postfix) with ESMTP id 89BDD8A43D;\n\tThu, 20 Jul 2017 16:01:43 +0000 (UTC)",
            "from whitealder.osuosl.org (smtp1.osuosl.org [140.211.166.138])\n\tby ash.osuosl.org (Postfix) with ESMTP id B5AB61C24DE\n\tfor <intel-wired-lan@lists.osuosl.org>;\n\tThu, 20 Jul 2017 16:01:42 +0000 (UTC)",
            "from localhost (localhost [127.0.0.1])\n\tby whitealder.osuosl.org (Postfix) with ESMTP id A29DD8249A\n\tfor <intel-wired-lan@lists.osuosl.org>;\n\tThu, 20 Jul 2017 16:01:42 +0000 (UTC)",
            "from whitealder.osuosl.org ([127.0.0.1])\n\tby localhost (.osuosl.org [127.0.0.1]) (amavisd-new, port 10024)\n\twith ESMTP id TXKiUw3KJvgh for <intel-wired-lan@lists.osuosl.org>;\n\tThu, 20 Jul 2017 16:01:41 +0000 (UTC)",
            "from legacy.ddn.com (legacy.ddn.com [64.47.133.206])\n\tby whitealder.osuosl.org (Postfix) with ESMTPS id 6ACB7890E1\n\tfor <intel-wired-lan@lists.osuosl.org>;\n\tThu, 20 Jul 2017 16:01:41 +0000 (UTC)",
            "from LAX-EX-CAHT1.datadirect.datadirectnet.com (10.8.103.81) by\n\tLAX-EX-CAHT2.datadirect.datadirectnet.com (10.8.103.82) with\n\tMicrosoft SMTP\n\tServer (TLS) id 14.3.319.2; Thu, 20 Jul 2017 09:01:39 -0700",
            "from psuche.colorado.datadirectnet.com (10.8.30.130) by\n\tLAX-EX-CAHT1.datadirect.datadirectnet.com (10.8.103.81) with\n\tMicrosoft SMTP\n\tServer (TLS) id 14.3.319.2; Thu, 20 Jul 2017 09:01:38 -0700"
        ],
        "X-Virus-Scanned": [
            "amavisd-new at osuosl.org",
            "amavisd-new at osuosl.org"
        ],
        "X-Greylist": "from auto-whitelisted by SQLgrey-1.7.6",
        "From": "Greg Edwards <gedwards@ddn.com>",
        "To": "<intel-wired-lan@lists.osuosl.org>",
        "Date": "Thu, 20 Jul 2017 10:00:57 -0600",
        "Message-ID": "<20170720160058.8198-2-gedwards@ddn.com>",
        "X-Mailer": "git-send-email 2.13.3",
        "In-Reply-To": "<20170720160058.8198-1-gedwards@ddn.com>",
        "References": "<20170720160058.8198-1-gedwards@ddn.com>",
        "MIME-Version": "1.0",
        "X-Originating-IP": "[10.8.30.130]",
        "Cc": "Greg Edwards <gedwards@ddn.com>",
        "Subject": "[Intel-wired-lan] [PATCH 1/2] igbvf: add lock around mailbox ops",
        "X-BeenThere": "intel-wired-lan@osuosl.org",
        "X-Mailman-Version": "2.1.18-1",
        "Precedence": "list",
        "List-Id": "Intel Wired Ethernet Linux Kernel Driver Development\n\t<intel-wired-lan.osuosl.org>",
        "List-Unsubscribe": "<https://lists.osuosl.org/mailman/options/intel-wired-lan>, \n\t<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\t<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": "The PF driver assumes the VF will not send another mailbox message until\nthe PF has written its reply to the previous message.  If the VF does,\nthat message will be silently dropped by the PF before it writes its\nreply to the mailbox.  This results in a VF mailbox timeout for posted\nmessages waiting for an ACK, and the VF is reset by the\nigbvf_watchdog_task in the VM.\n\nAdd a lock around the VF mailbox ops to prevent the VF from sending\nanother message while the PF is still processing the previous one.\n\nSigned-off-by: Greg Edwards <gedwards@ddn.com>\n---\n drivers/net/ethernet/intel/igbvf/ethtool.c |  4 +++\n drivers/net/ethernet/intel/igbvf/mbx.c     |  4 +++\n drivers/net/ethernet/intel/igbvf/netdev.c  | 47 ++++++++++++++++++++++++++++++\n drivers/net/ethernet/intel/igbvf/vf.h      |  1 +\n 4 files changed, 56 insertions(+)",
    "diff": "diff --git a/drivers/net/ethernet/intel/igbvf/ethtool.c b/drivers/net/ethernet/intel/igbvf/ethtool.c\nindex 34faa113a8a0..a127688e83e6 100644\n--- a/drivers/net/ethernet/intel/igbvf/ethtool.c\n+++ b/drivers/net/ethernet/intel/igbvf/ethtool.c\n@@ -296,8 +296,12 @@ static int igbvf_link_test(struct igbvf_adapter *adapter, u64 *data)\n \tstruct e1000_hw *hw = &adapter->hw;\n \t*data = 0;\n \n+\tspin_lock_bh(&hw->mbx_lock);\n+\n \thw->mac.ops.check_for_link(hw);\n \n+\tspin_unlock_bh(&hw->mbx_lock);\n+\n \tif (!(er32(STATUS) & E1000_STATUS_LU))\n \t\t*data = 1;\n \ndiff --git a/drivers/net/ethernet/intel/igbvf/mbx.c b/drivers/net/ethernet/intel/igbvf/mbx.c\nindex 01752f44ace2..c9a441632e9f 100644\n--- a/drivers/net/ethernet/intel/igbvf/mbx.c\n+++ b/drivers/net/ethernet/intel/igbvf/mbx.c\n@@ -264,6 +264,8 @@ static s32 e1000_write_mbx_vf(struct e1000_hw *hw, u32 *msg, u16 size)\n \ts32 err;\n \tu16 i;\n \n+\tWARN_ON_ONCE(!spin_is_locked(&hw->mbx_lock));\n+\n \t/* lock the mailbox to prevent pf/vf race condition */\n \terr = e1000_obtain_mbx_lock_vf(hw);\n \tif (err)\n@@ -300,6 +302,8 @@ static s32 e1000_read_mbx_vf(struct e1000_hw *hw, u32 *msg, u16 size)\n \ts32 err;\n \tu16 i;\n \n+\tWARN_ON_ONCE(!spin_is_locked(&hw->mbx_lock));\n+\n \t/* lock the mailbox to prevent pf/vf race condition */\n \terr = e1000_obtain_mbx_lock_vf(hw);\n \tif (err)\ndiff --git a/drivers/net/ethernet/intel/igbvf/netdev.c b/drivers/net/ethernet/intel/igbvf/netdev.c\nindex 1b9cbbe88f6f..1ed556911b14 100644\n--- a/drivers/net/ethernet/intel/igbvf/netdev.c\n+++ b/drivers/net/ethernet/intel/igbvf/netdev.c\n@@ -1235,7 +1235,12 @@ static void igbvf_set_rlpml(struct igbvf_adapter *adapter)\n \tstruct e1000_hw *hw = &adapter->hw;\n \n \tmax_frame_size = adapter->max_frame_size + VLAN_TAG_SIZE;\n+\n+\tspin_lock_bh(&hw->mbx_lock);\n+\n \te1000_rlpml_set_vf(hw, max_frame_size);\n+\n+\tspin_unlock_bh(&hw->mbx_lock);\n }\n \n static int igbvf_vlan_rx_add_vid(struct net_device *netdev,\n@@ -1244,10 +1249,16 @@ static int igbvf_vlan_rx_add_vid(struct net_device *netdev,\n \tstruct igbvf_adapter *adapter = netdev_priv(netdev);\n \tstruct e1000_hw *hw = &adapter->hw;\n \n+\tspin_lock_bh(&hw->mbx_lock);\n+\n \tif (hw->mac.ops.set_vfta(hw, vid, true)) {\n \t\tdev_err(&adapter->pdev->dev, \"Failed to add vlan id %d\\n\", vid);\n+\t\tspin_unlock_bh(&hw->mbx_lock);\n \t\treturn -EINVAL;\n \t}\n+\n+\tspin_unlock_bh(&hw->mbx_lock);\n+\n \tset_bit(vid, adapter->active_vlans);\n \treturn 0;\n }\n@@ -1258,11 +1269,17 @@ static int igbvf_vlan_rx_kill_vid(struct net_device *netdev,\n \tstruct igbvf_adapter *adapter = netdev_priv(netdev);\n \tstruct e1000_hw *hw = &adapter->hw;\n \n+\tspin_lock_bh(&hw->mbx_lock);\n+\n \tif (hw->mac.ops.set_vfta(hw, vid, false)) {\n \t\tdev_err(&adapter->pdev->dev,\n \t\t\t\"Failed to remove vlan id %d\\n\", vid);\n+\t\tspin_unlock_bh(&hw->mbx_lock);\n \t\treturn -EINVAL;\n \t}\n+\n+\tspin_unlock_bh(&hw->mbx_lock);\n+\n \tclear_bit(vid, adapter->active_vlans);\n \treturn 0;\n }\n@@ -1428,7 +1445,11 @@ static void igbvf_set_multi(struct net_device *netdev)\n \tnetdev_for_each_mc_addr(ha, netdev)\n \t\tmemcpy(mta_list + (i++ * ETH_ALEN), ha->addr, ETH_ALEN);\n \n+\tspin_lock_bh(&hw->mbx_lock);\n+\n \thw->mac.ops.update_mc_addr_list(hw, mta_list, i, 0, 0);\n+\n+\tspin_unlock_bh(&hw->mbx_lock);\n \tkfree(mta_list);\n }\n \n@@ -1449,16 +1470,24 @@ static int igbvf_set_uni(struct net_device *netdev)\n \t\treturn -ENOSPC;\n \t}\n \n+\tspin_lock_bh(&hw->mbx_lock);\n+\n \t/* Clear all unicast MAC filters */\n \thw->mac.ops.set_uc_addr(hw, E1000_VF_MAC_FILTER_CLR, NULL);\n \n+\tspin_unlock_bh(&hw->mbx_lock);\n+\n \tif (!netdev_uc_empty(netdev)) {\n \t\tstruct netdev_hw_addr *ha;\n \n \t\t/* Add MAC filters one by one */\n \t\tnetdev_for_each_uc_addr(ha, netdev) {\n+\t\t\tspin_lock_bh(&hw->mbx_lock);\n+\n \t\t\thw->mac.ops.set_uc_addr(hw, E1000_VF_MAC_FILTER_ADD,\n \t\t\t\t\t\tha->addr);\n+\n+\t\t\tspin_unlock_bh(&hw->mbx_lock);\n \t\t\tudelay(200);\n \t\t}\n \t}\n@@ -1503,12 +1532,16 @@ static void igbvf_reset(struct igbvf_adapter *adapter)\n \tstruct net_device *netdev = adapter->netdev;\n \tstruct e1000_hw *hw = &adapter->hw;\n \n+\tspin_lock_bh(&hw->mbx_lock);\n+\n \t/* Allow time for pending master requests to run */\n \tif (mac->ops.reset_hw(hw))\n \t\tdev_err(&adapter->pdev->dev, \"PF still resetting\\n\");\n \n \tmac->ops.init_hw(hw);\n \n+\tspin_unlock_bh(&hw->mbx_lock);\n+\n \tif (is_valid_ether_addr(adapter->hw.mac.addr)) {\n \t\tmemcpy(netdev->dev_addr, adapter->hw.mac.addr,\n \t\t       netdev->addr_len);\n@@ -1643,6 +1676,7 @@ static int igbvf_sw_init(struct igbvf_adapter *adapter)\n \tigbvf_irq_disable(adapter);\n \n \tspin_lock_init(&adapter->stats_lock);\n+\tspin_lock_init(&adapter->hw.mbx_lock);\n \n \tset_bit(__IGBVF_DOWN, &adapter->state);\n \treturn 0;\n@@ -1786,8 +1820,12 @@ static int igbvf_set_mac(struct net_device *netdev, void *p)\n \n \tmemcpy(hw->mac.addr, addr->sa_data, netdev->addr_len);\n \n+\tspin_lock_bh(&hw->mbx_lock);\n+\n \thw->mac.ops.rar_set(hw, hw->mac.addr, 0);\n \n+\tspin_unlock_bh(&hw->mbx_lock);\n+\n \tif (!ether_addr_equal(addr->sa_data, hw->mac.addr))\n \t\treturn -EADDRNOTAVAIL;\n \n@@ -1858,7 +1896,12 @@ static bool igbvf_has_link(struct igbvf_adapter *adapter)\n \tif (test_bit(__IGBVF_DOWN, &adapter->state))\n \t\treturn false;\n \n+\tspin_lock_bh(&hw->mbx_lock);\n+\n \tret_val = hw->mac.ops.check_for_link(hw);\n+\n+\tspin_unlock_bh(&hw->mbx_lock);\n+\n \tlink_active = !hw->mac.get_link_status;\n \n \t/* if check for link returns error we will need to reset */\n@@ -2808,6 +2851,8 @@ static int igbvf_probe(struct pci_dev *pdev, const struct pci_device_id *ent)\n \tnetdev->min_mtu = ETH_MIN_MTU;\n \tnetdev->max_mtu = MAX_STD_JUMBO_FRAME_SIZE;\n \n+\tspin_lock_bh(&hw->mbx_lock);\n+\n \t/*reset the controller to put the device in a known good state */\n \terr = hw->mac.ops.reset_hw(hw);\n \tif (err) {\n@@ -2824,6 +2869,8 @@ static int igbvf_probe(struct pci_dev *pdev, const struct pci_device_id *ent)\n \t\t       netdev->addr_len);\n \t}\n \n+\tspin_unlock_bh(&hw->mbx_lock);\n+\n \tif (!is_valid_ether_addr(netdev->dev_addr)) {\n \t\tdev_info(&pdev->dev, \"Assigning random MAC address.\\n\");\n \t\teth_hw_addr_random(netdev);\ndiff --git a/drivers/net/ethernet/intel/igbvf/vf.h b/drivers/net/ethernet/intel/igbvf/vf.h\nindex 4cf78b0dec50..d213eefb6169 100644\n--- a/drivers/net/ethernet/intel/igbvf/vf.h\n+++ b/drivers/net/ethernet/intel/igbvf/vf.h\n@@ -245,6 +245,7 @@ struct e1000_hw {\n \n \tstruct e1000_mac_info  mac;\n \tstruct e1000_mbx_info mbx;\n+\tspinlock_t mbx_lock;\t\t/* serializes mailbox ops */\n \n \tunion {\n \t\tstruct e1000_dev_spec_vf vf;\n",
    "prefixes": [
        "1/2"
    ]
}