From patchwork Thu Dec 28 21:30:19 2017 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: "Belgazal, Netanel" X-Patchwork-Id: 853570 X-Patchwork-Delegate: davem@davemloft.net Return-Path: X-Original-To: patchwork-incoming@ozlabs.org Delivered-To: patchwork-incoming@ozlabs.org Authentication-Results: ozlabs.org; spf=none (mailfrom) smtp.mailfrom=vger.kernel.org (client-ip=209.132.180.67; helo=vger.kernel.org; envelope-from=netdev-owner@vger.kernel.org; receiver=) Authentication-Results: ozlabs.org; dkim=pass (1024-bit key; unprotected) header.d=amazon.com header.i=@amazon.com header.b="VXa0FtfA"; dkim-atps=neutral Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by ozlabs.org (Postfix) with ESMTP id 3z72vS2fw8z9sBW for ; Fri, 29 Dec 2017 08:30:44 +1100 (AEDT) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1754485AbdL1Val (ORCPT ); Thu, 28 Dec 2017 16:30:41 -0500 Received: from smtp-fw-33001.amazon.com ([207.171.190.10]:15942 "EHLO smtp-fw-33001.amazon.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1754239AbdL1Vaj (ORCPT ); Thu, 28 Dec 2017 16:30:39 -0500 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=amazon.com; i=@amazon.com; q=dns/txt; s=amazon201209; t=1514496639; x=1546032639; h=from:to:cc:subject:date:message-id:in-reply-to: references:mime-version; bh=qDZ+jkLu/2YaPqHstV8HZqfi23XJDKUt9u3cKnCnCLY=; b=VXa0FtfAMtDjMd3A/jpcZuHpdJwSQ9cPpWWTwsKg4SkDiFzfRn2HKeJS jmwcEf7blwBH2eiotzOGR4OHVg/scYYt4x1YgdKEz58E3wY3VNhI4uD/X GirXHNps2QfA07fVv65KAvJHbMn4OKoZnwmBiPpk6VA8t4QK6SYDvplPw Y=; X-IronPort-AV: E=Sophos;i="5.45,472,1508803200"; d="scan'208";a="712277844" Received: from sea3-co-svc-lb6-vlan2.sea.amazon.com (HELO email-inbound-relay-2b-5bdc5131.us-west-2.amazon.com) ([10.47.22.34]) by smtp-border-fw-out-33001.sea14.amazon.com with ESMTP/TLS/DHE-RSA-AES256-SHA; 28 Dec 2017 21:30:39 +0000 Received: from EX13MTAUWB001.ant.amazon.com (pdx1-ws-svc-p6-lb9-vlan2.pdx.amazon.com [10.236.137.194]) by email-inbound-relay-2b-5bdc5131.us-west-2.amazon.com (8.14.7/8.14.7) with ESMTP id vBSLUcW9019296 (version=TLSv1/SSLv3 cipher=AES256-SHA bits=256 verify=FAIL); Thu, 28 Dec 2017 21:30:39 GMT Received: from EX13D10UWB002.ant.amazon.com (10.43.161.130) by EX13MTAUWB001.ant.amazon.com (10.43.161.249) with Microsoft SMTP Server (TLS) id 15.0.1236.3; Thu, 28 Dec 2017 21:30:36 +0000 Received: from EX13MTAUWB001.ant.amazon.com (10.43.161.207) by EX13D10UWB002.ant.amazon.com (10.43.161.130) with Microsoft SMTP Server (TLS) id 15.0.1236.3; Thu, 28 Dec 2017 21:30:36 +0000 Received: from dev-dsk-netanel-1a-9f923ce6.eu-west-1.amazon.com (10.15.81.133) by mail-relay.amazon.com (10.43.161.249) with Microsoft SMTP Server id 15.0.1236.3 via Frontend Transport; Thu, 28 Dec 2017 21:30:34 +0000 From: To: , CC: Netanel Belgazal , , , , , , , , , Subject: [PATCH net 2/3] net: ena: fix error handling in ena_down() sequence Date: Thu, 28 Dec 2017 21:30:19 +0000 Message-ID: <1514496620-69953-3-git-send-email-netanel@amazon.com> X-Mailer: git-send-email 2.7.3.AMZN In-Reply-To: <1514496620-69953-1-git-send-email-netanel@amazon.com> References: <1514496620-69953-1-git-send-email-netanel@amazon.com> MIME-Version: 1.0 Sender: netdev-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: netdev@vger.kernel.org From: Netanel Belgazal ENA admin command queue errors are not handled as part of ena_down(). As a result, in case of error admin queue transitions to non-running state and aborts all subsequent commands including those coming from ena_up(). Reset scheduled by the driver from the timer service context would not proceed due to sharing rtnl with ena_up()/ena_down() Signed-off-by: Netanel Belgazal --- drivers/net/ethernet/amazon/ena/ena_netdev.c | 19 +++++++++++++++++-- 1 file changed, 17 insertions(+), 2 deletions(-) diff --git a/drivers/net/ethernet/amazon/ena/ena_netdev.c b/drivers/net/ethernet/amazon/ena/ena_netdev.c index 6fb28fd43eb3..fbe21a817bd8 100644 --- a/drivers/net/ethernet/amazon/ena/ena_netdev.c +++ b/drivers/net/ethernet/amazon/ena/ena_netdev.c @@ -75,6 +75,9 @@ static struct workqueue_struct *ena_wq; MODULE_DEVICE_TABLE(pci, ena_pci_tbl); static int ena_rss_init_default(struct ena_adapter *adapter); +static void check_for_admin_com_state(struct ena_adapter *adapter); +static void ena_destroy_device(struct ena_adapter *adapter); +static int ena_restore_device(struct ena_adapter *adapter); static void ena_tx_timeout(struct net_device *dev) { @@ -1884,6 +1887,17 @@ static int ena_close(struct net_device *netdev) if (test_bit(ENA_FLAG_DEV_UP, &adapter->flags)) ena_down(adapter); + /* Check for device status and issue reset if needed*/ + check_for_admin_com_state(adapter); + if (unlikely(test_bit(ENA_FLAG_TRIGGER_RESET, &adapter->flags))) { + netif_err(adapter, ifdown, adapter->netdev, + "Destroy failure, restarting device\n"); + ena_dump_stats_to_dmesg(adapter); + /* rtnl lock already obtained in dev_ioctl() layer */ + ena_destroy_device(adapter); + ena_restore_device(adapter); + } + return 0; } @@ -2544,11 +2558,12 @@ static void ena_destroy_device(struct ena_adapter *adapter) ena_com_set_admin_running_state(ena_dev, false); - ena_close(netdev); + if (test_bit(ENA_FLAG_DEV_UP, &adapter->flags)) + ena_down(adapter); /* Before releasing the ENA resources, a device reset is required. * (to prevent the device from accessing them). - * In case the reset flag is set and the device is up, ena_close + * In case the reset flag is set and the device is up, ena_down() * already perform the reset, so it can be skipped. */ if (!(test_bit(ENA_FLAG_TRIGGER_RESET, &adapter->flags) && dev_up))