{"id":792262,"url":"http://patchwork.ozlabs.org/api/1.2/patches/792262/?format=json","web_url":"http://patchwork.ozlabs.org/project/intel-wired-lan/patch/20170721183627.13373-4-bpoirier@suse.com/","project":{"id":46,"url":"http://patchwork.ozlabs.org/api/1.2/projects/46/?format=json","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":"<20170721183627.13373-4-bpoirier@suse.com>","list_archive_url":null,"date":"2017-07-21T18:36:26","name":"[4/5] e1000e: Separate signaling for link check/link up","commit_ref":null,"pull_url":null,"state":"accepted","archived":false,"hash":"73d8c938b35b25826fe58e6a13e6ad9aa9528008","submitter":{"id":67008,"url":"http://patchwork.ozlabs.org/api/1.2/people/67008/?format=json","name":"Benjamin Poirier","email":"bpoirier@suse.com"},"delegate":{"id":68,"url":"http://patchwork.ozlabs.org/api/1.2/users/68/?format=json","username":"jtkirshe","first_name":"Jeff","last_name":"Kirsher","email":"jeffrey.t.kirsher@intel.com"},"mbox":"http://patchwork.ozlabs.org/project/intel-wired-lan/patch/20170721183627.13373-4-bpoirier@suse.com/mbox/","series":[],"comments":"http://patchwork.ozlabs.org/api/patches/792262/comments/","check":"pending","checks":"http://patchwork.ozlabs.org/api/patches/792262/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.136; helo=silver.osuosl.org;\n\tenvelope-from=intel-wired-lan-bounces@osuosl.org;\n\treceiver=<UNKNOWN>)","Received":["from silver.osuosl.org (smtp3.osuosl.org [140.211.166.136])\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 3xDfdB5zXDz9rvt\n\tfor <incoming@patchwork.ozlabs.org>;\n\tSat, 22 Jul 2017 04:37:18 +1000 (AEST)","from localhost (localhost [127.0.0.1])\n\tby silver.osuosl.org (Postfix) with ESMTP id DC6762F6A1;\n\tFri, 21 Jul 2017 18:37:16 +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 iC1Og-X9rWg9; Fri, 21 Jul 2017 18:37:14 +0000 (UTC)","from ash.osuosl.org (ash.osuosl.org [140.211.166.34])\n\tby silver.osuosl.org (Postfix) with ESMTP id DE20E2F65B;\n\tFri, 21 Jul 2017 18:37:14 +0000 (UTC)","from whitealder.osuosl.org (smtp1.osuosl.org [140.211.166.138])\n\tby ash.osuosl.org (Postfix) with ESMTP id CBFD71C0964\n\tfor <intel-wired-lan@lists.osuosl.org>;\n\tFri, 21 Jul 2017 18:37:12 +0000 (UTC)","from localhost (localhost [127.0.0.1])\n\tby whitealder.osuosl.org (Postfix) with ESMTP id CC82B88B3F\n\tfor <intel-wired-lan@lists.osuosl.org>;\n\tFri, 21 Jul 2017 18:36:58 +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 qqQaqVVQsBoe for <intel-wired-lan@lists.osuosl.org>;\n\tFri, 21 Jul 2017 18:36:58 +0000 (UTC)","from mx1.suse.de (mx2.suse.de [195.135.220.15])\n\tby whitealder.osuosl.org (Postfix) with ESMTPS id EB0DA88991\n\tfor <intel-wired-lan@lists.osuosl.org>;\n\tFri, 21 Jul 2017 18:36:57 +0000 (UTC)","from relay1.suse.de (charybdis-ext.suse.de [195.135.220.254])\n\tby mx1.suse.de (Postfix) with ESMTP id 6EDC7AC03;\n\tFri, 21 Jul 2017 18:36:56 +0000 (UTC)"],"X-Virus-Scanned":["amavisd-new at osuosl.org","amavisd-new at osuosl.org","by amavisd-new at test-mx.suse.de"],"X-Greylist":"domain auto-whitelisted by SQLgrey-1.7.6","From":"Benjamin Poirier <bpoirier@suse.com>","To":"Jeff Kirsher <jeffrey.t.kirsher@intel.com>","Date":"Fri, 21 Jul 2017 11:36:26 -0700","Message-Id":"<20170721183627.13373-4-bpoirier@suse.com>","X-Mailer":"git-send-email 2.13.2","In-Reply-To":"<20170721183627.13373-1-bpoirier@suse.com>","References":"<20170721160937.GA22632@csclub.uwaterloo.ca>\n\t<20170721183627.13373-1-bpoirier@suse.com>","Cc":"netdev@vger.kernel.org, intel-wired-lan@lists.osuosl.org,\n\tlinux-kernel@vger.kernel.org,\n\tLennart Sorensen <lsorense@csclub.uwaterloo.ca>","Subject":"[Intel-wired-lan] [PATCH 4/5] e1000e: Separate signaling for link\n\tcheck/link up","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>","MIME-Version":"1.0","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":"Lennart reported the following race condition:\n\n\\ e1000_watchdog_task\n    \\ e1000e_has_link\n        \\ hw->mac.ops.check_for_link() === e1000e_check_for_copper_link\n            /* link is up */\n            mac->get_link_status = false;\n\n                            /* interrupt */\n                            \\ e1000_msix_other\n                                hw->mac.get_link_status = true;\n\n        link_active = !hw->mac.get_link_status\n        /* link_active is false, wrongly */\n\nThis problem arises because the single flag get_link_status is used to\nsignal two different states: link status needs checking and link status is\ndown.\n\nAvoid the problem by using the return value of .check_for_link to signal\nthe link status to e1000e_has_link().\n\nReported-by: Lennart Sorensen <lsorense@csclub.uwaterloo.ca>\nSigned-off-by: Benjamin Poirier <bpoirier@suse.com>\n---\n drivers/net/ethernet/intel/e1000e/mac.c    | 11 ++++++++---\n drivers/net/ethernet/intel/e1000e/netdev.c |  2 +-\n 2 files changed, 9 insertions(+), 4 deletions(-)","diff":"diff --git a/drivers/net/ethernet/intel/e1000e/mac.c b/drivers/net/ethernet/intel/e1000e/mac.c\nindex b322011ec282..f457c5703d0c 100644\n--- a/drivers/net/ethernet/intel/e1000e/mac.c\n+++ b/drivers/net/ethernet/intel/e1000e/mac.c\n@@ -410,6 +410,9 @@ void e1000e_clear_hw_cntrs_base(struct e1000_hw *hw)\n  *  Checks to see of the link status of the hardware has changed.  If a\n  *  change in link status has been detected, then we read the PHY registers\n  *  to get the current speed/duplex if link exists.\n+ *\n+ *  Returns a negative error code (-E1000_ERR_*) or 0 (link down) or 1 (link\n+ *  up).\n  **/\n s32 e1000e_check_for_copper_link(struct e1000_hw *hw)\n {\n@@ -423,7 +426,7 @@ s32 e1000e_check_for_copper_link(struct e1000_hw *hw)\n \t * Change or Rx Sequence Error interrupt.\n \t */\n \tif (!mac->get_link_status)\n-\t\treturn 0;\n+\t\treturn 1;\n \n \t/* First we want to see if the MII Status Register reports\n \t * link.  If so, then we want to get the current speed/duplex\n@@ -461,10 +464,12 @@ s32 e1000e_check_for_copper_link(struct e1000_hw *hw)\n \t * different link partner.\n \t */\n \tret_val = e1000e_config_fc_after_link_up(hw);\n-\tif (ret_val)\n+\tif (ret_val) {\n \t\te_dbg(\"Error configuring flow control\\n\");\n+\t\treturn ret_val;\n+\t}\n \n-\treturn ret_val;\n+\treturn 1;\n }\n \n /**\ndiff --git a/drivers/net/ethernet/intel/e1000e/netdev.c b/drivers/net/ethernet/intel/e1000e/netdev.c\nindex fc6a1d9999b2..5a8ab1136566 100644\n--- a/drivers/net/ethernet/intel/e1000e/netdev.c\n+++ b/drivers/net/ethernet/intel/e1000e/netdev.c\n@@ -5081,7 +5081,7 @@ static bool e1000e_has_link(struct e1000_adapter *adapter)\n \tcase e1000_media_type_copper:\n \t\tif (hw->mac.get_link_status) {\n \t\t\tret_val = hw->mac.ops.check_for_link(hw);\n-\t\t\tlink_active = !hw->mac.get_link_status;\n+\t\t\tlink_active = ret_val > 0;\n \t\t} else {\n \t\t\tlink_active = true;\n \t\t}\n","prefixes":["4/5"]}