get:
Show a patch.

patch:
Update a patch.

put:
Update a patch.

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

{
    "id": 631861,
    "url": "http://patchwork.ozlabs.org/api/patches/631861/?format=api",
    "web_url": "http://patchwork.ozlabs.org/project/intel-wired-lan/patch/20160607230902.5457-8-jacob.e.keller@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": "<20160607230902.5457-8-jacob.e.keller@intel.com>",
    "list_archive_url": null,
    "date": "2016-06-07T23:08:51",
    "name": "[v2,07/18] fm10k: wait for queues to drain if stop_hw() fails once",
    "commit_ref": null,
    "pull_url": null,
    "state": "accepted",
    "archived": false,
    "hash": "94d67344618fd9f966f8bf6097910ebd6e4d2af4",
    "submitter": {
        "id": 9784,
        "url": "http://patchwork.ozlabs.org/api/people/9784/?format=api",
        "name": "Jacob Keller",
        "email": "jacob.e.keller@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/20160607230902.5457-8-jacob.e.keller@intel.com/mbox/",
    "series": [],
    "comments": "http://patchwork.ozlabs.org/api/patches/631861/comments/",
    "check": "pending",
    "checks": "http://patchwork.ozlabs.org/api/patches/631861/checks/",
    "tags": {},
    "related": [],
    "headers": {
        "Return-Path": "<intel-wired-lan-bounces@lists.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"
        ],
        "Received": [
            "from whitealder.osuosl.org (smtp1.osuosl.org [140.211.166.138])\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 3rPS1z5SgZz9sC3\n\tfor <incoming@patchwork.ozlabs.org>;\n\tWed,  8 Jun 2016 09:09:27 +1000 (AEST)",
            "from localhost (localhost [127.0.0.1])\n\tby whitealder.osuosl.org (Postfix) with ESMTP id 1E1C98A884;\n\tTue,  7 Jun 2016 23:09:26 +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 AtO1Qva-G+CN; Tue,  7 Jun 2016 23:09:23 +0000 (UTC)",
            "from ash.osuosl.org (ash.osuosl.org [140.211.166.34])\n\tby whitealder.osuosl.org (Postfix) with ESMTP id 1C5738AA20;\n\tTue,  7 Jun 2016 23:09:17 +0000 (UTC)",
            "from fraxinus.osuosl.org (smtp4.osuosl.org [140.211.166.137])\n\tby ash.osuosl.org (Postfix) with ESMTP id 32FF61C127A\n\tfor <intel-wired-lan@lists.osuosl.org>;\n\tTue,  7 Jun 2016 23:09:12 +0000 (UTC)",
            "from localhost (localhost [127.0.0.1])\n\tby fraxinus.osuosl.org (Postfix) with ESMTP id 2FDF1856E3\n\tfor <intel-wired-lan@lists.osuosl.org>;\n\tTue,  7 Jun 2016 23:09:12 +0000 (UTC)",
            "from fraxinus.osuosl.org ([127.0.0.1])\n\tby localhost (.osuosl.org [127.0.0.1]) (amavisd-new, port 10024)\n\twith ESMTP id frytwrDDpe8k for <intel-wired-lan@lists.osuosl.org>;\n\tTue,  7 Jun 2016 23:09:06 +0000 (UTC)",
            "from mga04.intel.com (mga04.intel.com [192.55.52.120])\n\tby fraxinus.osuosl.org (Postfix) with ESMTP id 3001E85A1D\n\tfor <intel-wired-lan@lists.osuosl.org>;\n\tTue,  7 Jun 2016 23:09:06 +0000 (UTC)",
            "from fmsmga003.fm.intel.com ([10.253.24.29])\n\tby fmsmga104.fm.intel.com with ESMTP; 07 Jun 2016 16:09:05 -0700",
            "from jekeller-desk.amr.corp.intel.com (HELO\n\tjekeller-desk.jekeller.internal) ([134.134.3.116])\n\tby FMSMGA003.fm.intel.com with ESMTP; 07 Jun 2016 16:09:05 -0700"
        ],
        "X-Virus-Scanned": [
            "amavisd-new at osuosl.org",
            "amavisd-new at osuosl.org"
        ],
        "X-Greylist": "domain auto-whitelisted by SQLgrey-1.7.6",
        "X-ExtLoop1": "1",
        "X-IronPort-AV": "E=Sophos;i=\"5.26,436,1459839600\"; d=\"scan'208\";a=\"715507162\"",
        "From": "Jacob Keller <jacob.e.keller@intel.com>",
        "To": "Intel Wired LAN <intel-wired-lan@lists.osuosl.org>",
        "Date": "Tue,  7 Jun 2016 16:08:51 -0700",
        "Message-Id": "<20160607230902.5457-8-jacob.e.keller@intel.com>",
        "X-Mailer": "git-send-email 2.9.0.rc1.405.g81f467e",
        "In-Reply-To": "<20160607230902.5457-1-jacob.e.keller@intel.com>",
        "References": "<20160607230902.5457-1-jacob.e.keller@intel.com>",
        "Subject": "[Intel-wired-lan] [PATCH v2 07/18] fm10k: wait for queues to drain\n\tif stop_hw() fails once",
        "X-BeenThere": "intel-wired-lan@lists.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.lists.osuosl.org>",
        "List-Unsubscribe": "<http://lists.osuosl.org/mailman/options/intel-wired-lan>, \n\t<mailto:intel-wired-lan-request@lists.osuosl.org?subject=unsubscribe>",
        "List-Archive": "<http://lists.osuosl.org/pipermail/intel-wired-lan/>",
        "List-Post": "<mailto:intel-wired-lan@lists.osuosl.org>",
        "List-Help": "<mailto:intel-wired-lan-request@lists.osuosl.org?subject=help>",
        "List-Subscribe": "<http://lists.osuosl.org/mailman/listinfo/intel-wired-lan>, \n\t<mailto:intel-wired-lan-request@lists.osuosl.org?subject=subscribe>",
        "MIME-Version": "1.0",
        "Content-Type": "text/plain; charset=\"us-ascii\"",
        "Content-Transfer-Encoding": "7bit",
        "Errors-To": "intel-wired-lan-bounces@lists.osuosl.org",
        "Sender": "\"Intel-wired-lan\" <intel-wired-lan-bounces@lists.osuosl.org>"
    },
    "content": "It turns out that sometimes during a reset the Tx queues will be\ntemporarily stuck longer than .stop_hw() expects. Work around this issue\nby attempting to .stop_hw() first. If it tails, wait a number of\nattempts until the Tx queues appear to be drained. After this, attempt\nstop_hw() again. This ensures that we avoid waiting if we don't need to,\nsuch as during the first initialization of a VF, and give the proper\namount of time necessary to recover from most situations. It is possible\nthat the hardware is actually stuck. For PFs, this is usually fixed by\na datapath reset. Unfortunately the VF cannot request a similar reset\nfor itself.\n\nSigned-off-by: Jacob Keller <jacob.e.keller@intel.com>\n---\n drivers/net/ethernet/intel/fm10k/fm10k.h      |  1 +\n drivers/net/ethernet/intel/fm10k/fm10k_main.c |  2 +-\n drivers/net/ethernet/intel/fm10k/fm10k_pci.c  | 44 +++++++++++++++++++++++----\n 3 files changed, 40 insertions(+), 7 deletions(-)",
    "diff": "diff --git a/drivers/net/ethernet/intel/fm10k/fm10k.h b/drivers/net/ethernet/intel/fm10k/fm10k.h\nindex c8d0817766bf..c4cf08dcf5af 100644\n--- a/drivers/net/ethernet/intel/fm10k/fm10k.h\n+++ b/drivers/net/ethernet/intel/fm10k/fm10k.h\n@@ -458,6 +458,7 @@ __be16 fm10k_tx_encap_offload(struct sk_buff *skb);\n netdev_tx_t fm10k_xmit_frame_ring(struct sk_buff *skb,\n \t\t\t\t  struct fm10k_ring *tx_ring);\n void fm10k_tx_timeout_reset(struct fm10k_intfc *interface);\n+u64 fm10k_get_tx_pending(struct fm10k_ring *ring);\n bool fm10k_check_tx_hang(struct fm10k_ring *tx_ring);\n void fm10k_alloc_rx_buffers(struct fm10k_ring *rx_ring, u16 cleaned_count);\n \ndiff --git a/drivers/net/ethernet/intel/fm10k/fm10k_main.c b/drivers/net/ethernet/intel/fm10k/fm10k_main.c\nindex c6a464551577..c85fc98945fa 100644\n--- a/drivers/net/ethernet/intel/fm10k/fm10k_main.c\n+++ b/drivers/net/ethernet/intel/fm10k/fm10k_main.c\n@@ -1128,7 +1128,7 @@ static u64 fm10k_get_tx_completed(struct fm10k_ring *ring)\n \treturn ring->stats.packets;\n }\n \n-static u64 fm10k_get_tx_pending(struct fm10k_ring *ring)\n+u64 fm10k_get_tx_pending(struct fm10k_ring *ring)\n {\n \tstruct fm10k_intfc *interface = ring->q_vector->interface;\n \tstruct fm10k_hw *hw = &interface->hw;\ndiff --git a/drivers/net/ethernet/intel/fm10k/fm10k_pci.c b/drivers/net/ethernet/intel/fm10k/fm10k_pci.c\nindex 4dfd1284a8de..7c9b20c6b6c1 100644\n--- a/drivers/net/ethernet/intel/fm10k/fm10k_pci.c\n+++ b/drivers/net/ethernet/intel/fm10k/fm10k_pci.c\n@@ -1613,7 +1613,7 @@ void fm10k_down(struct fm10k_intfc *interface)\n {\n \tstruct net_device *netdev = interface->netdev;\n \tstruct fm10k_hw *hw = &interface->hw;\n-\tint err;\n+\tint err, i = 0, count = 0;\n \n \t/* signal that we are down to the interrupt handler and service task */\n \tif (test_and_set_bit(__FM10K_DOWN, &interface->state))\n@@ -1629,9 +1629,6 @@ void fm10k_down(struct fm10k_intfc *interface)\n \t/* reset Rx filters */\n \tfm10k_reset_rx_state(interface);\n \n-\t/* allow 10ms for device to quiesce */\n-\tusleep_range(10000, 20000);\n-\n \t/* disable polling routines */\n \tfm10k_napi_disable_all(interface);\n \n@@ -1642,11 +1639,46 @@ void fm10k_down(struct fm10k_intfc *interface)\n \twhile (test_and_set_bit(__FM10K_UPDATING_STATS, &interface->state))\n \t\tusleep_range(1000, 2000);\n \n+\t/* skip waiting for TX DMA if we lost PCIe link */\n+\tif (FM10K_REMOVED(hw->hw_addr))\n+\t\tgoto skip_tx_dma_drain;\n+\n+\t/* In some rare circumstances it can take a while for Tx queues to\n+\t * quiesce and be fully disabled. Attempt to .stop_hw() first, and\n+\t * then if we get ERR_REQUESTS_PENDING, go ahead and wait in a loop\n+\t * until the Tx queues have emptied, or until a number of retries. If\n+\t * we fail to clear within the retry loop, we will issue a warning\n+\t * indicating that Tx DMA is probably hung. Note this means we call\n+\t * .stop_hw() twice but this shouldn't cause any problems.\n+\t */\n+\terr = hw->mac.ops.stop_hw(hw);\n+\tif (err != FM10K_ERR_REQUESTS_PENDING)\n+\t\tgoto skip_tx_dma_drain;\n+\n+#define TX_DMA_DRAIN_RETRIES 25\n+\tfor (count = 0; count < TX_DMA_DRAIN_RETRIES; count++) {\n+\t\tusleep_range(10000, 20000);\n+\n+\t\t/* start checking at the last ring to have pending Tx */\n+\t\tfor (; i < interface->num_tx_queues; i++)\n+\t\t\tif (fm10k_get_tx_pending(interface->tx_ring[i]))\n+\t\t\t\tbreak;\n+\n+\t\t/* if all the queues are drained, we can break now */\n+\t\tif (i == interface->num_tx_queues)\n+\t\t\tbreak;\n+\t}\n+\n+\tif (count >= TX_DMA_DRAIN_RETRIES)\n+\t\tdev_err(&interface->pdev->dev,\n+\t\t\t\"Tx queues failed to drain after %d tries. Tx DMA is probably hung.\\n\",\n+\t\t\tcount);\n+skip_tx_dma_drain:\n \t/* Disable DMA engine for Tx/Rx */\n \terr = hw->mac.ops.stop_hw(hw);\n \tif (err == FM10K_ERR_REQUESTS_PENDING)\n-\t\tdev_info(&interface->pdev->dev,\n-\t\t\t \"due to pending requests hw was not shut down gracefully\\n\");\n+\t\tdev_err(&interface->pdev->dev,\n+\t\t\t\"due to pending requests hw was not shut down gracefully\\n\");\n \telse if (err)\n \t\tdev_err(&interface->pdev->dev, \"stop_hw failed: %d\\n\", err);\n \n",
    "prefixes": [
        "v2",
        "07/18"
    ]
}