From patchwork Tue Dec 6 17:09:34 2016 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Michael Chan X-Patchwork-Id: 9462949 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 BA4B460231 for ; Tue, 6 Dec 2016 17:10:38 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id A49AA2843B for ; Tue, 6 Dec 2016 17:10:38 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 997CD28480; Tue, 6 Dec 2016 17:10:38 +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 32EFB2843B for ; Tue, 6 Dec 2016 17:10:38 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1753949AbcLFRKg (ORCPT ); Tue, 6 Dec 2016 12:10:36 -0500 Received: from mail-pg0-f50.google.com ([74.125.83.50]:34975 "EHLO mail-pg0-f50.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1753021AbcLFRKI (ORCPT ); Tue, 6 Dec 2016 12:10:08 -0500 Received: by mail-pg0-f50.google.com with SMTP id p66so151284758pga.2 for ; Tue, 06 Dec 2016 09:10:07 -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=R1HeZ+PX8m5xqeHli5cuQUmRkzVVKDtRaWbmnEPmv14=; b=Bvo/wp4fMBs9fZcmjpu0AdCorlCfQVPF8nh0J+6A3SrXabW+LquPd/ao9y9LCuNmjE FpSykA75yy2nkrPnG7olelZgnbpT4ho9S8pWHAKleWdQWz6zl1XWd7H8ts1cM9fCBDeH 7atP/GwtgvCK5egbIZzCVDCmTG0WFq1n4h7aI= 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=R1HeZ+PX8m5xqeHli5cuQUmRkzVVKDtRaWbmnEPmv14=; b=IGOvDSpyhp9FdGzhKq//MMA6cupoamvlwHHSYiDPvOdHqBjZQ0pb0xilJv9F6qgi/+ xEfS2kGmUItnuukGiDUHEbMsPvwYAXN0eZFNVogxg0UB+XnJyX3okvpyQgNP+tYbQfg8 ph2bRCdLULtYHbPfxG4nXQfdRifvvT1yXg+KbG51bENTiEECmXwe+8gggKkqg9sfzI3E 4QFKNo01bI85ZtkpMP5OhMY7qzWu3tZbefpjzHw6K7QIIbu5wOiToeYtUHx7M9VC74jL Nhymyopruu57KUH21dZYJxv7n2w7kgt8assgw84TltUkdhWt8lWnb3pRe48oXQXk9wJm q4BQ== X-Gm-Message-State: AKaTC03W0vFSpva0bcpymJf0WB3fqcN0hpYKHkiqUe9ZbZEcMkfMASQWCNt/7bGLOUF5tiHQ X-Received: by 10.84.206.37 with SMTP id f34mr138719463ple.127.1481044207053; Tue, 06 Dec 2016 09:10:07 -0800 (PST) Received: from localhost.broadcom.com ([192.19.255.250]) by smtp.gmail.com with ESMTPSA id v77sm36100804pfa.85.2016.12.06.09.10.06 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Tue, 06 Dec 2016 09:10:06 -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 3/7] bnxt_en: Move function reset to bnxt_init_one(). Date: Tue, 6 Dec 2016 12:09:34 -0500 Message-Id: <1481044178-25193-4-git-send-email-michael.chan@broadcom.com> X-Mailer: git-send-email 1.8.3.1 In-Reply-To: <1481044178-25193-1-git-send-email-michael.chan@broadcom.com> References: <1481044178-25193-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 9178bf8..8b00ef4 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;