From patchwork Sat Sep 16 16:00:00 2017 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Vincenzo Maffione X-Patchwork-Id: 815044 X-Patchwork-Delegate: jeffrey.t.kirsher@intel.com Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@bilbo.ozlabs.org Authentication-Results: ozlabs.org; spf=pass (mailfrom) smtp.mailfrom=osuosl.org (client-ip=140.211.166.136; helo=silver.osuosl.org; envelope-from=intel-wired-lan-bounces@osuosl.org; receiver=) Authentication-Results: ozlabs.org; dkim=fail reason="signature verification failed" (2048-bit key; unprotected) header.d=gmail.com header.i=@gmail.com header.b="dmHJKNlm"; dkim-atps=neutral Received: from silver.osuosl.org (smtp3.osuosl.org [140.211.166.136]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by ozlabs.org (Postfix) with ESMTPS id 3xwsrj0Qpdz9s7M for ; Tue, 19 Sep 2017 03:07:48 +1000 (AEST) Received: from localhost (localhost [127.0.0.1]) by silver.osuosl.org (Postfix) with ESMTP id 82C4930B11; Mon, 18 Sep 2017 17:07:47 +0000 (UTC) X-Virus-Scanned: amavisd-new at osuosl.org Received: from silver.osuosl.org ([127.0.0.1]) by localhost (.osuosl.org [127.0.0.1]) (amavisd-new, port 10024) with ESMTP id 1cm2GpXHvHHe; Mon, 18 Sep 2017 17:07:46 +0000 (UTC) Received: from ash.osuosl.org (ash.osuosl.org [140.211.166.34]) by silver.osuosl.org (Postfix) with ESMTP id C74942C899; Mon, 18 Sep 2017 17:07:46 +0000 (UTC) X-Original-To: intel-wired-lan@lists.osuosl.org Delivered-To: intel-wired-lan@lists.osuosl.org Received: from silver.osuosl.org (smtp3.osuosl.org [140.211.166.136]) by ash.osuosl.org (Postfix) with ESMTP id A08621C290F for ; Sat, 16 Sep 2017 16:01:55 +0000 (UTC) Received: from localhost (localhost [127.0.0.1]) by silver.osuosl.org (Postfix) with ESMTP id 91EDF2F666 for ; Sat, 16 Sep 2017 16:01:55 +0000 (UTC) X-Virus-Scanned: amavisd-new at osuosl.org Received: from silver.osuosl.org ([127.0.0.1]) by localhost (.osuosl.org [127.0.0.1]) (amavisd-new, port 10024) with ESMTP id pQdb9+qLGaMV for ; Sat, 16 Sep 2017 16:01:55 +0000 (UTC) X-Greylist: domain auto-whitelisted by SQLgrey-1.7.6 Received: from mail-pg0-f67.google.com (mail-pg0-f67.google.com [74.125.83.67]) by silver.osuosl.org (Postfix) with ESMTPS id 19BD82DA6F for ; Sat, 16 Sep 2017 16:01:55 +0000 (UTC) Received: by mail-pg0-f67.google.com with SMTP id i130so2885653pgc.0 for ; Sat, 16 Sep 2017 09:01:55 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=from:to:cc:subject:date:message-id; bh=W3gDp0I6NXsvnMFsnhz+3MizJpqyXb7gHzdKxuzCwfQ=; b=dmHJKNlmxS2GnDmSRsbYA4Ut9vCZC38lbV21kKOXkLU6Fqd/jkUG8xQHbxQAmwCc8W 9uOMipOhWs+it90XENAWaUOtt+UqBUFPf3DvJhZQSgIg1o4jBCHpQBBHMYsic+kCYWyJ +7pCkjicSMwDklNYG4JUvwPtg4t6XZGqSI/KjjrsXCyiIXLyUmq1LLsCROexVOyEOEYc EPtHIwgWzAUEKBpXdtwKBUjLHN14XqWm046x7zjJF6uvU6VFLNSeK2mzo21EOx0hT2FA 3XrbJ6Yv/C/I6uI89oYEjYqBkdipx8H090+pNcOoc3J9uxwIHD0SQXyZgqSzDy72SqS0 1FBA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:cc:subject:date:message-id; bh=W3gDp0I6NXsvnMFsnhz+3MizJpqyXb7gHzdKxuzCwfQ=; b=eQl4jWTXjIkUCi+I9VnhtX3AEImMRQ6+OVl7FHH8pgS8RznCE+MIcihLlKNk3zefrh gkbwgztwb0mlm4a+E2Z+QAtBbRGIJf/unOhbxQqHC4zEowL0EMKqBrwnKGkfoyvNckpn Qi5UlqKORu1MFZwTiazqjC0KLmyQz1OmEsdlFtsMiK58hk359uuw90XhVMF1aTTRxeYv pOV3qjTgmgYrwjt3puqtKXFycjyW7jcLE7S8RIevhJqv9gfXQbNFra3sNrOhe9QvVkyd HAaRrzHXrOKfkHToGSwyFX0zoPClajaD/AGK3Y/cJC32QTjJMXtYvZkDmXokmuiHTndh LkmQ== X-Gm-Message-State: AHPjjUgGZ5nBt/k5MFgBNRwqjJjiMNMtrKv6hRVAYmiw18UTDNfhIbR3 Uhl3ZkgwP7zfKQ== X-Google-Smtp-Source: ADKCNb6xtVre3cez3xF13rUVwZaaRY7AkDmPXRnumdYGZ7WNGV0mqlM/7OHVBhFxFTB98PZEuPUCzQ== X-Received: by 10.99.109.142 with SMTP id i136mr27362974pgc.353.1505577714579; Sat, 16 Sep 2017 09:01:54 -0700 (PDT) Received: from hadron.hsd1.ca.comcast.net (c-73-71-190-26.hsd1.ca.comcast.net. [73.71.190.26]) by smtp.gmail.com with ESMTPSA id x28sm7640070pgc.91.2017.09.16.09.01.52 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Sat, 16 Sep 2017 09:01:53 -0700 (PDT) From: Vincenzo Maffione To: jeffrey.t.kirsher@intel.com Date: Sat, 16 Sep 2017 18:00:00 +0200 Message-Id: <20170916160000.3560-1-v.maffione@gmail.com> X-Mailer: git-send-email 2.14.1 X-Mailman-Approved-At: Mon, 18 Sep 2017 17:07:45 +0000 Cc: netdev@vger.kernel.org, intel-wired-lan@lists.osuosl.org, linux-kernel@vger.kernel.org, Vincenzo Maffione Subject: [Intel-wired-lan] [PATCH net] driver: e1000: fix race condition between e1000_down() and e1000_watchdog 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 List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , MIME-Version: 1.0 Errors-To: intel-wired-lan-bounces@osuosl.org Sender: "Intel-wired-lan" This patch fixes a race condition that can result into the interface being up and carrier on, but with transmits disabled in the hardware. The bug may show up by repeatedly IFF_DOWN+IFF_UP the interface, which allows e1000_watchdog() interleave with e1000_down(). CPU x CPU y -------------------------------------------------------------------- e1000_down(): netif_carrier_off() e1000_watchdog(): if (carrier == off) { netif_carrier_on(); enable_hw_transmit(); } disable_hw_transmit(); e1000_watchdog(): /* carrier on, do nothing */ Signed-off-by: Vincenzo Maffione Tested-by: Aaron Brown --- drivers/net/ethernet/intel/e1000/e1000_main.c | 11 +++++++++-- 1 file changed, 9 insertions(+), 2 deletions(-) diff --git a/drivers/net/ethernet/intel/e1000/e1000_main.c b/drivers/net/ethernet/intel/e1000/e1000_main.c index 98375e1e1185..1982f7917a8d 100644 --- a/drivers/net/ethernet/intel/e1000/e1000_main.c +++ b/drivers/net/ethernet/intel/e1000/e1000_main.c @@ -520,8 +520,6 @@ void e1000_down(struct e1000_adapter *adapter) struct net_device *netdev = adapter->netdev; u32 rctl, tctl; - netif_carrier_off(netdev); - /* disable receives in the hardware */ rctl = er32(RCTL); ew32(RCTL, rctl & ~E1000_RCTL_EN); @@ -537,6 +535,15 @@ void e1000_down(struct e1000_adapter *adapter) E1000_WRITE_FLUSH(); msleep(10); + /* Set the carrier off after transmits have been disabled in the + * hardware, to avoid race conditions with e1000_watchdog() (which + * may be running concurrently to us, checking for the carrier + * bit to decide whether it should enable transmits again). Such + * a race condition would result into transmission being disabled + * in the hardware until the next IFF_DOWN+IFF_UP cycle. + */ + netif_carrier_off(netdev); + napi_disable(&adapter->napi); e1000_irq_disable(adapter);