From patchwork Wed Dec 7 05:26:17 2016 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Michael Chan X-Patchwork-Id: 9463961 Return-Path: Received: from mail.wl.linuxfoundation.org (pdx-wl-mail.web.codeaurora.org [172.30.200.125]) by pdx-korg-patchwork.web.codeaurora.org (Postfix) with ESMTP id 2E4C26075A for ; Wed, 7 Dec 2016 05:27:30 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 22ADD28478 for ; Wed, 7 Dec 2016 05:27:30 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 17DA9284CF; Wed, 7 Dec 2016 05:27:30 +0000 (UTC) X-Spam-Checker-Version: SpamAssassin 3.3.1 (2010-03-16) on pdx-wl-mail.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-6.8 required=2.0 tests=BAYES_00,DKIM_SIGNED, RCVD_IN_DNSWL_HI,T_DKIM_INVALID autolearn=ham version=3.3.1 Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id B1D1F284D5 for ; Wed, 7 Dec 2016 05:27:29 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1752726AbcLGF1Y (ORCPT ); Wed, 7 Dec 2016 00:27:24 -0500 Received: from mail-pf0-f173.google.com ([209.85.192.173]:34348 "EHLO mail-pf0-f173.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1752278AbcLGF04 (ORCPT ); Wed, 7 Dec 2016 00:26:56 -0500 Received: by mail-pf0-f173.google.com with SMTP id c4so75002520pfb.1 for ; Tue, 06 Dec 2016 21:26:56 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=broadcom.com; s=google; h=from:to:cc:subject:date:message-id:in-reply-to:references; bh=b7wXRfBzpYj8BRaJ+qA2MuYM9lnaF1Tkiy41+WornD4=; b=cPYkVHA/CNrn3GOd9vUqPMRSFvPXNJ0MGgxu5W4gdaFQ9mvXCtuPZje0zECP4Nw8CO 4qGVGEJfj6f1eC7OwNXPWyQ7glFBe8U+JhwDlZRglMHSLaEWAPrNiqmEne2AnCkMmJ1u ew00+SOMImPylyhaBQEowJmYhX00x+aCb0LnM= X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20130820; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references; bh=b7wXRfBzpYj8BRaJ+qA2MuYM9lnaF1Tkiy41+WornD4=; b=ZUfiA0Qu/XqB9Gb8Gx6h54pObGqhsU57jbNSYcCWkO527YOj0Mq0tkj2SNuHvod29i CKMMbxaSdScLRZevrQpJWG0WFvNnZ8YUoqaa5eNz0TWkYhl08NZuNwA3PbX/AYfkbK75 tiBz+7fST4XY/qNlo38UYzrN7BZ42IBVpgmTAuP0VahcPJpJ6k04/glxNTqr11bG+dlF VYc5UCAaQMzov6R1wVOM9p6AnCBpBmAUlTZK6YhVWpN3TjN/GAXopzBwIvjlwmqMbrr0 ilFMvlgOB7lAUOUgqML/16Dwa9q4HLmCdYbRH95qkqP3hA8HW+Ntnv8eVusswdPmzuV+ Kabw== X-Gm-Message-State: AKaTC035FFn3AYpkvpTIqLeGO8OOAgdf7+Nbh0n8q+mbDZA56GP9tkTNWpUp+WY7SSpQ3DPV X-Received: by 10.84.218.6 with SMTP id q6mr143788714pli.139.1481088415904; Tue, 06 Dec 2016 21:26:55 -0800 (PST) Received: from localhost.broadcom.com ([192.19.255.250]) by smtp.gmail.com with ESMTPSA id x90sm38605509pfk.73.2016.12.06.21.26.54 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Tue, 06 Dec 2016 21:26:55 -0800 (PST) From: Michael Chan To: davem@davemloft.net Cc: netdev@vger.kernel.org, selvin.xavier@broadcom.com, somnath.kotur@broadcom.com, dledford@redhat.com, linux-rdma@vger.kernel.org Subject: [PATCH net-next v2 3/7] bnxt_en: Move function reset to bnxt_init_one(). Date: Wed, 7 Dec 2016 00:26:17 -0500 Message-Id: <1481088381-30411-4-git-send-email-michael.chan@broadcom.com> X-Mailer: git-send-email 1.8.3.1 In-Reply-To: <1481088381-30411-1-git-send-email-michael.chan@broadcom.com> References: <1481088381-30411-1-git-send-email-michael.chan@broadcom.com> Sender: linux-rdma-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-rdma@vger.kernel.org X-Virus-Scanned: ClamAV using ClamSMTP Now that MSIX is enabled in bnxt_init_one(), resources may be allocated by the RDMA driver before the network device is opened. So we cannot do function reset in bnxt_open() which will clear all the resources. The proper place to do function reset now is in bnxt_init_one(). If we get AER, we'll do function reset as well. Signed-off-by: Somnath Kotur Signed-off-by: Michael Chan --- drivers/net/ethernet/broadcom/bnxt/bnxt.c | 25 ++++++------------------- drivers/net/ethernet/broadcom/bnxt/bnxt.h | 1 - 2 files changed, 6 insertions(+), 20 deletions(-) diff --git a/drivers/net/ethernet/broadcom/bnxt/bnxt.c b/drivers/net/ethernet/broadcom/bnxt/bnxt.c index da302eb..30b482b 100644 --- a/drivers/net/ethernet/broadcom/bnxt/bnxt.c +++ b/drivers/net/ethernet/broadcom/bnxt/bnxt.c @@ -5613,22 +5613,7 @@ int bnxt_open_nic(struct bnxt *bp, bool irq_re_init, bool link_re_init) static int bnxt_open(struct net_device *dev) { struct bnxt *bp = netdev_priv(dev); - int rc = 0; - if (!test_bit(BNXT_STATE_FN_RST_DONE, &bp->state)) { - rc = bnxt_hwrm_func_reset(bp); - if (rc) { - netdev_err(bp->dev, "hwrm chip reset failure rc: %x\n", - rc); - rc = -EBUSY; - return rc; - } - /* Do func_reset during the 1st PF open only to prevent killing - * the VFs when the PF is brought down and up. - */ - if (BNXT_PF(bp)) - set_bit(BNXT_STATE_FN_RST_DONE, &bp->state); - } return __bnxt_open_nic(bp, true, true); } @@ -7028,6 +7013,10 @@ static int bnxt_init_one(struct pci_dev *pdev, const struct pci_device_id *ent) if (rc) goto init_err; + rc = bnxt_hwrm_func_reset(bp); + if (rc) + goto init_err; + rc = bnxt_init_int_mode(bp); if (rc) goto init_err; @@ -7069,7 +7058,6 @@ static pci_ers_result_t bnxt_io_error_detected(struct pci_dev *pdev, pci_channel_state_t state) { struct net_device *netdev = pci_get_drvdata(pdev); - struct bnxt *bp = netdev_priv(netdev); netdev_info(netdev, "PCI I/O error detected\n"); @@ -7084,8 +7072,6 @@ static pci_ers_result_t bnxt_io_error_detected(struct pci_dev *pdev, if (netif_running(netdev)) bnxt_close(netdev); - /* So that func_reset will be done during slot_reset */ - clear_bit(BNXT_STATE_FN_RST_DONE, &bp->state); pci_disable_device(pdev); rtnl_unlock(); @@ -7119,7 +7105,8 @@ static pci_ers_result_t bnxt_io_slot_reset(struct pci_dev *pdev) } else { pci_set_master(pdev); - if (netif_running(netdev)) + err = bnxt_hwrm_func_reset(bp); + if (!err && netif_running(netdev)) err = bnxt_open(netdev); if (!err) diff --git a/drivers/net/ethernet/broadcom/bnxt/bnxt.h b/drivers/net/ethernet/broadcom/bnxt/bnxt.h index 1461355..0ee2cc4 100644 --- a/drivers/net/ethernet/broadcom/bnxt/bnxt.h +++ b/drivers/net/ethernet/broadcom/bnxt/bnxt.h @@ -1021,7 +1021,6 @@ struct bnxt { unsigned long state; #define BNXT_STATE_OPEN 0 #define BNXT_STATE_IN_SP_TASK 1 -#define BNXT_STATE_FN_RST_DONE 2 struct bnxt_irq *irq_tbl; int total_irqs;