From patchwork Mon Oct 26 04:18:17 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Michael Chan X-Patchwork-Id: 298612 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-12.7 required=3.0 tests=BAYES_00,DKIMWL_WL_HIGH, DKIM_SIGNED,DKIM_VALID,DKIM_VALID_AU,HEADER_FROM_DIFFERENT_DOMAINS, INCLUDES_PATCH, MAILING_LIST_MULTI, MIME_HEADER_CTYPE_ONLY, SIGNED_OFF_BY, SPF_HELO_NONE, SPF_PASS, T_TVD_MIME_NO_HEADERS, URIBL_BLOCKED, USER_AGENT_GIT autolearn=ham autolearn_force=no version=3.4.0 Received: from mail.kernel.org (mail.kernel.org [198.145.29.99]) by smtp.lore.kernel.org (Postfix) with ESMTP id 4491AC388F9 for ; Mon, 26 Oct 2020 04:18:35 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mail.kernel.org (Postfix) with ESMTP id CBEA120773 for ; Mon, 26 Oct 2020 04:18:34 +0000 (UTC) Authentication-Results: mail.kernel.org; dkim=pass (1024-bit key) header.d=broadcom.com header.i=@broadcom.com header.b="NUlDznmz" Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1420915AbgJZESe (ORCPT ); Mon, 26 Oct 2020 00:18:34 -0400 Received: from mail-pj1-f68.google.com ([209.85.216.68]:51419 "EHLO mail-pj1-f68.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1420823AbgJZESd (ORCPT ); Mon, 26 Oct 2020 00:18:33 -0400 Received: by mail-pj1-f68.google.com with SMTP id a17so2485106pju.1 for ; Sun, 25 Oct 2020 21:18:32 -0700 (PDT) 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=Ia7W+Te5tnERYre+fEhaGeEB9dh9a5vlTs1WxqxQS2Y=; b=NUlDznmz4Moulk1baLU8jYNlpNXicbAEBrlu7Y0dc/RR0ON1mtCGLWHTbv+eQO+Y2h +FoSEu1lX7JVGn4ygjfkXa6fsyq4I045zcVUpk0nQd/Y2C3qlxkfaDIjiemYbUk/pwF1 RYY9mBRZtqchYunH616tTM43V+nD5GbocrTbs= 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:in-reply-to :references; bh=Ia7W+Te5tnERYre+fEhaGeEB9dh9a5vlTs1WxqxQS2Y=; b=ofAeFG5OmQ5X1/lpOBCmPmvUGe+3v4LwgrcCCZYOrBF80ii7I8VekAlY9ozQzC5ddZ CjTIWmrby0tYCd59vziUEC8IRVxScX2b81S7FFGgzevwiL3/XXBpRW5xViL0Ir0ebA94 47HjYAbIIZW127sv7rUjsql/wBaS9EeL+IIeU8oByLbaMZ43yhDWZPZQu8D5VpZiDG8P PPxHZQkegrnk3/Zk8e018WN7rW9X1qcbhkZUrQVWJM0HzM+tPxRNONrc5DhRjhf7Yt0p 0uoL2FlSqFsdXX8QAtan7K+jdfOJ/O4bqrDxm0gZOul6WONIRnOhiRj4wChIw7eRF/ZF TCoA== X-Gm-Message-State: AOAM531296FmSJrbh6jaF3i7Cj66O1Bf5aQsIkFXvOzi0olg9/BZBB3N ZPevs9etfexvbk2MeXMtNm/QiYATbbJxyg== X-Google-Smtp-Source: ABdhPJx4jHybt57I3LuxIJOmma9Fmg1z+nbvmWZSaNKS4Q9QzHow+IUsPqwOLSG4EMxcITJqJpD/uw== X-Received: by 2002:a17:90a:8b0f:: with SMTP id y15mr5206198pjn.194.1603685912169; Sun, 25 Oct 2020 21:18:32 -0700 (PDT) Received: from localhost.swdvt.lab.broadcom.net ([192.19.223.252]) by smtp.gmail.com with ESMTPSA id 10sm11505835pjt.50.2020.10.25.21.18.30 (version=TLS1_2 cipher=ECDHE-ECDSA-AES128-GCM-SHA256 bits=128/128); Sun, 25 Oct 2020 21:18:31 -0700 (PDT) From: Michael Chan To: kuba@kernel.org Cc: netdev@vger.kernel.org, gospo@broadcom.com, Vasundhara Volam Subject: [PATCH net 1/5] bnxt_en: Fix regression in workqueue cleanup logic in bnxt_remove_one(). Date: Mon, 26 Oct 2020 00:18:17 -0400 Message-Id: <1603685901-17917-2-git-send-email-michael.chan@broadcom.com> X-Mailer: git-send-email 1.8.3.1 In-Reply-To: <1603685901-17917-1-git-send-email-michael.chan@broadcom.com> References: <1603685901-17917-1-git-send-email-michael.chan@broadcom.com> Precedence: bulk List-ID: X-Mailing-List: netdev@vger.kernel.org From: Vasundhara Volam A recent patch has moved the workqueue cleanup logic before calling unregister_netdev() in bnxt_remove_one(). This caused a regression because the workqueue can be restarted if the device is still open. Workqueue cleanup must be done after unregister_netdev(). The workqueue will not restart itself after the device is closed. Call bnxt_cancel_sp_work() after unregister_netdev() and call bnxt_dl_fw_reporters_destroy() after that. This fixes the regession and the original NULL ptr dereference issue. Fixes: b16939b59cc0 ("bnxt_en: Fix NULL ptr dereference crash in bnxt_fw_reset_task()") Signed-off-by: Vasundhara Volam Signed-off-by: Michael Chan --- drivers/net/ethernet/broadcom/bnxt/bnxt.c | 9 +++++---- 1 file changed, 5 insertions(+), 4 deletions(-) diff --git a/drivers/net/ethernet/broadcom/bnxt/bnxt.c b/drivers/net/ethernet/broadcom/bnxt/bnxt.c index fa147865e33f..e4e5ea080391 100644 --- a/drivers/net/ethernet/broadcom/bnxt/bnxt.c +++ b/drivers/net/ethernet/broadcom/bnxt/bnxt.c @@ -12108,15 +12108,16 @@ static void bnxt_remove_one(struct pci_dev *pdev) if (BNXT_PF(bp)) bnxt_sriov_disable(bp); + if (BNXT_PF(bp)) + devlink_port_type_clear(&bp->dl_port); + pci_disable_pcie_error_reporting(pdev); + unregister_netdev(dev); clear_bit(BNXT_STATE_IN_FW_RESET, &bp->state); + /* Flush any pending tasks */ bnxt_cancel_sp_work(bp); bp->sp_event = 0; bnxt_dl_fw_reporters_destroy(bp, true); - if (BNXT_PF(bp)) - devlink_port_type_clear(&bp->dl_port); - pci_disable_pcie_error_reporting(pdev); - unregister_netdev(dev); bnxt_dl_unregister(bp); bnxt_shutdown_tc(bp); From patchwork Mon Oct 26 04:18:18 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Michael Chan X-Patchwork-Id: 288122 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-12.7 required=3.0 tests=BAYES_00,DKIMWL_WL_HIGH, DKIM_SIGNED,DKIM_VALID,DKIM_VALID_AU,HEADER_FROM_DIFFERENT_DOMAINS, INCLUDES_PATCH, MAILING_LIST_MULTI, MIME_HEADER_CTYPE_ONLY, SIGNED_OFF_BY, SPF_HELO_NONE, SPF_PASS, T_TVD_MIME_NO_HEADERS, URIBL_BLOCKED, USER_AGENT_GIT autolearn=ham autolearn_force=no version=3.4.0 Received: from mail.kernel.org (mail.kernel.org [198.145.29.99]) by smtp.lore.kernel.org (Postfix) with ESMTP id CDE59C5517A for ; Mon, 26 Oct 2020 04:18:37 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mail.kernel.org (Postfix) with ESMTP id 825342224A for ; Mon, 26 Oct 2020 04:18:37 +0000 (UTC) Authentication-Results: mail.kernel.org; dkim=pass (1024-bit key) header.d=broadcom.com header.i=@broadcom.com header.b="F5k7xKi4" Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1420947AbgJZESh (ORCPT ); Mon, 26 Oct 2020 00:18:37 -0400 Received: from mail-pg1-f196.google.com ([209.85.215.196]:33421 "EHLO mail-pg1-f196.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1419349AbgJZESf (ORCPT ); Mon, 26 Oct 2020 00:18:35 -0400 Received: by mail-pg1-f196.google.com with SMTP id l18so5398036pgg.0 for ; Sun, 25 Oct 2020 21:18:34 -0700 (PDT) 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=uleZ8n+JgcCHc/so3hz6bo8kpeWA7SBxQDQu0n8Nwc0=; b=F5k7xKi46sXA42eD+QkeDYwi4eyl5D3qBZ8tdMa8GikVsTlHGWxwtBhAmTtZgj+zPn NQMk9tNLeSuNaV1w1EzsIo4Iv1sMos4da/R6wdxF0pC7eMx9WOFJyWdZtfdEA9dLI0N2 hiyJkpE+hjrzNp2FSqCi6R1NKxxBCt2k8oIYE= 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:in-reply-to :references; bh=uleZ8n+JgcCHc/so3hz6bo8kpeWA7SBxQDQu0n8Nwc0=; b=fH1NWsOeOi+KcnIZb+8xfFjaLREvTQ9QZ+GISuUkAhG/GFU4aa1GO1CrurVJrJdQGx asUcV1GV6m47SkFCbWx9eeIsZOBtBb6PdZWpiV5VJvbARX4HcqRaupekdflnGIJv/hHx uSAeOg7hcQOTYerycHmo3Ifm97EdfGmX06gxRcslgPeM5p1qR8dAWOExPbvo22fSoQEk WgBb1tN8r1eYdZNic/6OrbFPa9vIXGV14lgLkeiV6TVMulJu3MiuGd61GezwD1t9P1AX fcATrV10jzY41zRq8VNcQFtfxUhktoP1I7Gqqduy1rUydzUCF+lnza3pWrtpvgCj02JS fY3A== X-Gm-Message-State: AOAM533QD68m7wTB2u/+U3RAcOpp73FWbIDOgPrTqvfe9v6XkhC4ag/v XvgPztY2RSsy/D41QHRuRV6kimNymnpjOA== X-Google-Smtp-Source: ABdhPJzwZDWhIWbIU6S4QVMka8wJnqDdokcDMWko8RgWF/pIpy49XMdbKh+/W75CkMgFdjGTcCLcGw== X-Received: by 2002:a63:f343:: with SMTP id t3mr11752446pgj.86.1603685913437; Sun, 25 Oct 2020 21:18:33 -0700 (PDT) Received: from localhost.swdvt.lab.broadcom.net ([192.19.223.252]) by smtp.gmail.com with ESMTPSA id 10sm11505835pjt.50.2020.10.25.21.18.32 (version=TLS1_2 cipher=ECDHE-ECDSA-AES128-GCM-SHA256 bits=128/128); Sun, 25 Oct 2020 21:18:32 -0700 (PDT) From: Michael Chan To: kuba@kernel.org Cc: netdev@vger.kernel.org, gospo@broadcom.com, Vasundhara Volam Subject: [PATCH net 2/5] bnxt_en: Invoke cancel_delayed_work_sync() for PFs also. Date: Mon, 26 Oct 2020 00:18:18 -0400 Message-Id: <1603685901-17917-3-git-send-email-michael.chan@broadcom.com> X-Mailer: git-send-email 1.8.3.1 In-Reply-To: <1603685901-17917-1-git-send-email-michael.chan@broadcom.com> References: <1603685901-17917-1-git-send-email-michael.chan@broadcom.com> Precedence: bulk List-ID: X-Mailing-List: netdev@vger.kernel.org From: Vasundhara Volam As part of the commit b148bb238c02 ("bnxt_en: Fix possible crash in bnxt_fw_reset_task()."), cancel_delayed_work_sync() is called only for VFs to fix a possible crash by cancelling any pending delayed work items. It was assumed by mistake that the flush_workqueue() call on the PF would flush delayed work items as well. As flush_workqueue() does not cancel the delayed workqueue, extend the fix for PFs. This fix will avoid the system crash, if there are any pending delayed work items in fw_reset_task() during driver's .remove() call. Unify the workqueue cleanup logic for both PF and VF by calling cancel_work_sync() and cancel_delayed_work_sync() directly in bnxt_remove_one(). Fixes: b148bb238c02 ("bnxt_en: Fix possible crash in bnxt_fw_reset_task().") Reviewed-by: Pavan Chebbi Reviewed-by: Andy Gospodarek Signed-off-by: Vasundhara Volam Signed-off-by: Michael Chan --- drivers/net/ethernet/broadcom/bnxt/bnxt.c | 13 ++----------- 1 file changed, 2 insertions(+), 11 deletions(-) diff --git a/drivers/net/ethernet/broadcom/bnxt/bnxt.c b/drivers/net/ethernet/broadcom/bnxt/bnxt.c index e4e5ea080391..7be232018015 100644 --- a/drivers/net/ethernet/broadcom/bnxt/bnxt.c +++ b/drivers/net/ethernet/broadcom/bnxt/bnxt.c @@ -1160,16 +1160,6 @@ static void bnxt_queue_sp_work(struct bnxt *bp) schedule_work(&bp->sp_task); } -static void bnxt_cancel_sp_work(struct bnxt *bp) -{ - if (BNXT_PF(bp)) { - flush_workqueue(bnxt_pf_wq); - } else { - cancel_work_sync(&bp->sp_task); - cancel_delayed_work_sync(&bp->fw_reset_task); - } -} - static void bnxt_sched_reset(struct bnxt *bp, struct bnxt_rx_ring_info *rxr) { if (!rxr->bnapi->in_reset) { @@ -12114,7 +12104,8 @@ static void bnxt_remove_one(struct pci_dev *pdev) unregister_netdev(dev); clear_bit(BNXT_STATE_IN_FW_RESET, &bp->state); /* Flush any pending tasks */ - bnxt_cancel_sp_work(bp); + cancel_work_sync(&bp->sp_task); + cancel_delayed_work_sync(&bp->fw_reset_task); bp->sp_event = 0; bnxt_dl_fw_reporters_destroy(bp, true); From patchwork Mon Oct 26 04:18:19 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Michael Chan X-Patchwork-Id: 298611 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-12.7 required=3.0 tests=BAYES_00,DKIMWL_WL_HIGH, DKIM_SIGNED,DKIM_VALID,DKIM_VALID_AU,HEADER_FROM_DIFFERENT_DOMAINS, INCLUDES_PATCH, MAILING_LIST_MULTI, MIME_HEADER_CTYPE_ONLY, SIGNED_OFF_BY, SPF_HELO_NONE, SPF_PASS, T_TVD_MIME_NO_HEADERS, URIBL_BLOCKED, USER_AGENT_GIT autolearn=ham autolearn_force=no version=3.4.0 Received: from mail.kernel.org (mail.kernel.org [198.145.29.99]) by smtp.lore.kernel.org (Postfix) with ESMTP id EFBF4C388F9 for ; Mon, 26 Oct 2020 04:18:38 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mail.kernel.org (Postfix) with ESMTP id 9AB612225C for ; Mon, 26 Oct 2020 04:18:38 +0000 (UTC) Authentication-Results: mail.kernel.org; dkim=pass (1024-bit key) header.d=broadcom.com header.i=@broadcom.com header.b="RrXZpceO" Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1421001AbgJZESi (ORCPT ); Mon, 26 Oct 2020 00:18:38 -0400 Received: from mail-pj1-f43.google.com ([209.85.216.43]:33655 "EHLO mail-pj1-f43.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1420823AbgJZESg (ORCPT ); Mon, 26 Oct 2020 00:18:36 -0400 Received: by mail-pj1-f43.google.com with SMTP id k8so1189565pjd.0 for ; Sun, 25 Oct 2020 21:18:35 -0700 (PDT) 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=AUW8DaQudLFeTlc624ikva6Dlpr0wexoXiqMWFoNacM=; b=RrXZpceOCQX7hJqRQM0MsO22THzjHm1Kj4HrOwfWxy8m3alXblO/ntUXSPU7jDhpeG XhVIN7D6GrdCqdnxhhbgnfeR5UojvKq14drjbNM2O3IatNLtt1yO6xBz/Kc2DxLlrxjN RMSXfvCwFn+yCGtFda1AygIYxpVclpcn7uyKU= 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:in-reply-to :references; bh=AUW8DaQudLFeTlc624ikva6Dlpr0wexoXiqMWFoNacM=; b=aoO36QoB4bFn3qtHiZiJjpnUEastjF/C3XDxhwAehn0+eyHeIEESQz3JXQXv9OYCdc PknWszcySxTj8Z6bbW6k1VZA57/SbefDsop0wp8e/KQsDsrbiHUdvUf527P/qbW3YGp2 aLdy6ASweYIR3Wd6fFZk20EBHuINOAxBiNjKWG/dKQh0175Gk42yKI/h+TL9bCsc6tJj 4/bxndpyINoK0KBUcoYxVHtLQzYvU8TDxgUtKqnikCk381fTC3l+CW1zc9AFYbBr/A08 3AtCJyYOUgssSq78faIcvTkhxLPqPThwNJMONZeTqebDxac3A5+atNw5lWdvYPHD6Kbz Dn1A== X-Gm-Message-State: AOAM532jTN/N0utAsLU8JBhKPKaUwB1ZbtVtOqjXZY1FZDWmWX0y1H/s 7P7EOwWRER91cGwnOLVX5n2/oA== X-Google-Smtp-Source: ABdhPJzjo48rS0+EgiscZ33qCnfhkepuKuu67jFaY8eN2beAbhFDh5Ds4gUR19sXpn8CO1nk+cLTaA== X-Received: by 2002:a17:90a:348e:: with SMTP id p14mr15276150pjb.75.1603685914768; Sun, 25 Oct 2020 21:18:34 -0700 (PDT) Received: from localhost.swdvt.lab.broadcom.net ([192.19.223.252]) by smtp.gmail.com with ESMTPSA id 10sm11505835pjt.50.2020.10.25.21.18.33 (version=TLS1_2 cipher=ECDHE-ECDSA-AES128-GCM-SHA256 bits=128/128); Sun, 25 Oct 2020 21:18:33 -0700 (PDT) From: Michael Chan To: kuba@kernel.org Cc: netdev@vger.kernel.org, gospo@broadcom.com, Vasundhara Volam Subject: [PATCH net 3/5] bnxt_en: Re-write PCI BARs after PCI fatal error. Date: Mon, 26 Oct 2020 00:18:19 -0400 Message-Id: <1603685901-17917-4-git-send-email-michael.chan@broadcom.com> X-Mailer: git-send-email 1.8.3.1 In-Reply-To: <1603685901-17917-1-git-send-email-michael.chan@broadcom.com> References: <1603685901-17917-1-git-send-email-michael.chan@broadcom.com> Precedence: bulk List-ID: X-Mailing-List: netdev@vger.kernel.org From: Vasundhara Volam When a PCIe fatal error occurs, the internal latched BAR addresses in the chip get reset even though the BAR register values in config space are retained. pci_restore_state() will not rewrite the BAR addresses if the BAR address values are valid, causing the chip's internal BAR addresses to stay invalid. So we need to zero the BAR registers during PCIe fatal error to force pci_restore_state() to restore the BAR addresses. These write cycles to the BAR registers will cause the proper BAR addresses to latch internally. Fixes: 6316ea6db93d ("bnxt_en: Enable AER support.") Signed-off-by: Vasundhara Volam Signed-off-by: Michael Chan --- drivers/net/ethernet/broadcom/bnxt/bnxt.c | 19 ++++++++++++++++++- drivers/net/ethernet/broadcom/bnxt/bnxt.h | 1 + 2 files changed, 19 insertions(+), 1 deletion(-) diff --git a/drivers/net/ethernet/broadcom/bnxt/bnxt.c b/drivers/net/ethernet/broadcom/bnxt/bnxt.c index 7be232018015..8012386b4a0f 100644 --- a/drivers/net/ethernet/broadcom/bnxt/bnxt.c +++ b/drivers/net/ethernet/broadcom/bnxt/bnxt.c @@ -12852,6 +12852,9 @@ static pci_ers_result_t bnxt_io_error_detected(struct pci_dev *pdev, return PCI_ERS_RESULT_DISCONNECT; } + if (state == pci_channel_io_frozen) + set_bit(BNXT_STATE_PCI_CHANNEL_IO_FROZEN, &bp->state); + if (netif_running(netdev)) bnxt_close(netdev); @@ -12878,7 +12881,7 @@ static pci_ers_result_t bnxt_io_slot_reset(struct pci_dev *pdev) { struct net_device *netdev = pci_get_drvdata(pdev); struct bnxt *bp = netdev_priv(netdev); - int err = 0; + int err = 0, off; pci_ers_result_t result = PCI_ERS_RESULT_DISCONNECT; netdev_info(bp->dev, "PCI Slot Reset\n"); @@ -12890,6 +12893,20 @@ static pci_ers_result_t bnxt_io_slot_reset(struct pci_dev *pdev) "Cannot re-enable PCI device after reset.\n"); } else { pci_set_master(pdev); + /* Upon fatal error, our device internal logic that latches to + * BAR value is getting reset and will restore only upon + * rewritting the BARs. + * + * As pci_restore_state() does not re-write the BARs if the + * value is same as saved value earlier, driver needs to + * write the BARs to 0 to force restore, in case of fatal error. + */ + if (test_and_clear_bit(BNXT_STATE_PCI_CHANNEL_IO_FROZEN, + &bp->state)) { + for (off = PCI_BASE_ADDRESS_0; + off <= PCI_BASE_ADDRESS_5; off += 4) + pci_write_config_dword(bp->pdev, off, 0); + } pci_restore_state(pdev); pci_save_state(pdev); diff --git a/drivers/net/ethernet/broadcom/bnxt/bnxt.h b/drivers/net/ethernet/broadcom/bnxt/bnxt.h index 21ef1c21f602..47b3c3127879 100644 --- a/drivers/net/ethernet/broadcom/bnxt/bnxt.h +++ b/drivers/net/ethernet/broadcom/bnxt/bnxt.h @@ -1781,6 +1781,7 @@ struct bnxt { #define BNXT_STATE_ABORT_ERR 5 #define BNXT_STATE_FW_FATAL_COND 6 #define BNXT_STATE_DRV_REGISTERED 7 +#define BNXT_STATE_PCI_CHANNEL_IO_FROZEN 8 #define BNXT_NO_FW_ACCESS(bp) \ (test_bit(BNXT_STATE_FW_FATAL_COND, &(bp)->state) || \ From patchwork Mon Oct 26 04:18:20 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Michael Chan X-Patchwork-Id: 298610 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-12.7 required=3.0 tests=BAYES_00,DKIMWL_WL_HIGH, DKIM_SIGNED,DKIM_VALID,DKIM_VALID_AU,HEADER_FROM_DIFFERENT_DOMAINS, INCLUDES_PATCH, MAILING_LIST_MULTI, MIME_HEADER_CTYPE_ONLY, SIGNED_OFF_BY, SPF_HELO_NONE, SPF_PASS, T_TVD_MIME_NO_HEADERS, URIBL_BLOCKED, USER_AGENT_GIT autolearn=ham autolearn_force=no version=3.4.0 Received: from mail.kernel.org (mail.kernel.org [198.145.29.99]) by smtp.lore.kernel.org (Postfix) with ESMTP id 2EE7BC56202 for ; Mon, 26 Oct 2020 04:18:42 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mail.kernel.org (Postfix) with ESMTP id D055522247 for ; Mon, 26 Oct 2020 04:18:41 +0000 (UTC) Authentication-Results: mail.kernel.org; dkim=pass (1024-bit key) header.d=broadcom.com header.i=@broadcom.com header.b="OTt1gOkN" Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1421046AbgJZESk (ORCPT ); Mon, 26 Oct 2020 00:18:40 -0400 Received: from mail-pf1-f193.google.com ([209.85.210.193]:33789 "EHLO mail-pf1-f193.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1420945AbgJZESh (ORCPT ); Mon, 26 Oct 2020 00:18:37 -0400 Received: by mail-pf1-f193.google.com with SMTP id j18so5503933pfa.0 for ; Sun, 25 Oct 2020 21:18:36 -0700 (PDT) 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=vC3xozK2wZN6iUGIbKodyxCftG+54UZ6I8VNlV5QpNE=; b=OTt1gOkNUsoKyD0ZfZZHAvJ/p8nPrK5Nqg9yG9Mg/Bvp2tT7N9oxVrXfi2CAD3x0A4 bpqCH5RdviQyO/PRZqmbeVENOOERtki2gfoeXFMF0wwuGTKLkpJljrFGZwAV817YH2Wy WmfttLYTwWwApFvjDR6hokwnJpvJ5km/EKleg= 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:in-reply-to :references; bh=vC3xozK2wZN6iUGIbKodyxCftG+54UZ6I8VNlV5QpNE=; b=g6w0JRR/qfkUsqL66DePBsCYNnkRqd/cpx1Y16Jvk9uoI8LXoQEVonrktFtwkFJU3c htMhPSKn1bHey91ZpzFlbKOt0DBj4fLcNoVxnln49Kby2By4lVMW/Wjzlr5D/Euir/jc XfWlSdz7+yhZs1Pa/fVdx8cHBeaQwVUoPRhMU7J4jRB6zs4xzEZ2MbsKvd7xY55lLzug B29/e2Pewg2mrx87hjQiiB7yermpbTr0vdYJE5g+saa23SwUOF3FpxIphxqQwoJ6+WEa TkRrdmDGSxoBsp3s67FiSrG8doZIgKDuiZ2FJrKkYc4nnC+LvC0dzau8v2IHLnqqEU8M wJyA== X-Gm-Message-State: AOAM532sMAFGfRbPNIdwiDRt3TlzN2K/9AOVP6+P7b1S9FDxUzLvVHvd cLk9C5i2gkl0mh/1Onc77mWftyFBndaDeg== X-Google-Smtp-Source: ABdhPJyKVoI+AEgt8ExLABJ0ofythjszofAn1ICSxSQD2Iv7ggsSOQhpvGhWQyCWrCoqn/4o/+ZYVg== X-Received: by 2002:a63:9508:: with SMTP id p8mr14376742pgd.189.1603685916043; Sun, 25 Oct 2020 21:18:36 -0700 (PDT) Received: from localhost.swdvt.lab.broadcom.net ([192.19.223.252]) by smtp.gmail.com with ESMTPSA id 10sm11505835pjt.50.2020.10.25.21.18.34 (version=TLS1_2 cipher=ECDHE-ECDSA-AES128-GCM-SHA256 bits=128/128); Sun, 25 Oct 2020 21:18:35 -0700 (PDT) From: Michael Chan To: kuba@kernel.org Cc: netdev@vger.kernel.org, gospo@broadcom.com Subject: [PATCH net 4/5] bnxt_en: Check abort error state in bnxt_open_nic(). Date: Mon, 26 Oct 2020 00:18:20 -0400 Message-Id: <1603685901-17917-5-git-send-email-michael.chan@broadcom.com> X-Mailer: git-send-email 1.8.3.1 In-Reply-To: <1603685901-17917-1-git-send-email-michael.chan@broadcom.com> References: <1603685901-17917-1-git-send-email-michael.chan@broadcom.com> Precedence: bulk List-ID: X-Mailing-List: netdev@vger.kernel.org bnxt_open_nic() is called during configuration changes that require the NIC to be closed and then opened. This call is protected by rtnl_lock. Firmware reset can be happening at the same time. Only critical portions of the entire firmware reset sequence are protected by the rtnl_lock. It is possible that bnxt_open_nic() can be called when the firmware reset sequence is aborting. In that case, bnxt_open_nic() needs to check if the ABORT_ERR flag is set and abort if it is. The configuration change that resulted in the bnxt_open_nic() call will fail but the NIC will be brought to a consistent IF_DOWN state. Without this patch, if bnxt_open_nic() were to continue in this error state, it may crash like this: [ 1648.659736] BUG: unable to handle kernel NULL pointer dereference at (null) [ 1648.659768] IP: [] bnxt_alloc_mem+0x50a/0x1140 [bnxt_en] [ 1648.659796] PGD 101e1b3067 PUD 101e1b2067 PMD 0 [ 1648.659813] Oops: 0000 [#1] SMP [ 1648.659825] Modules linked in: xt_CHECKSUM iptable_mangle ipt_MASQUERADE nf_nat_masquerade_ipv4 iptable_nat nf_nat_ipv4 nf_nat nf_conntrack_ipv4 nf_defrag_ipv4 xt_conntrack nf_conntrack ipt_REJECT nf_reject_ipv4 tun bridge stp llc ebtable_filter ebtables ip6table_filter ip6_tables iptable_filter sunrpc dell_smbios dell_wmi_descriptor dcdbas amd64_edac_mod edac_mce_amd kvm_amd kvm irqbypass crc32_pclmul ghash_clmulni_intel aesni_intel lrw gf128mul glue_helper ablk_helper vfat cryptd fat pcspkr ipmi_ssif sg k10temp i2c_piix4 wmi ipmi_si ipmi_devintf ipmi_msghandler tpm_crb acpi_power_meter sch_fq_codel ip_tables xfs libcrc32c sd_mod crc_t10dif crct10dif_generic mgag200 i2c_algo_bit drm_kms_helper syscopyarea sysfillrect sysimgblt fb_sys_fops ttm ahci drm libahci megaraid_sas crct10dif_pclmul crct10dif_common [ 1648.660063] tg3 libata crc32c_intel bnxt_en(OE) drm_panel_orientation_quirks devlink ptp pps_core dm_mirror dm_region_hash dm_log dm_mod fuse [ 1648.660105] CPU: 13 PID: 3867 Comm: ethtool Kdump: loaded Tainted: G OE ------------ 3.10.0-1152.el7.x86_64 #1 [ 1648.660911] Hardware name: Dell Inc. PowerEdge R7515/0R4CNN, BIOS 1.2.14 01/28/2020 [ 1648.661662] task: ffff94e64cbc9080 ti: ffff94f55df1c000 task.ti: ffff94f55df1c000 [ 1648.662409] RIP: 0010:[] [] bnxt_alloc_mem+0x50a/0x1140 [bnxt_en] [ 1648.663171] RSP: 0018:ffff94f55df1fba8 EFLAGS: 00010202 [ 1648.663927] RAX: 0000000000000000 RBX: ffff94e6827e0000 RCX: 0000000000000000 [ 1648.664684] RDX: 0000000000000000 RSI: 0000000000000000 RDI: ffff94e6827e08c0 [ 1648.665433] RBP: ffff94f55df1fc20 R08: 00000000000001ff R09: 0000000000000008 [ 1648.666184] R10: 0000000000000d53 R11: ffff94f55df1f7ce R12: ffff94e6827e08c0 [ 1648.666940] R13: ffff94e6827e08c0 R14: ffff94e6827e08c0 R15: ffffffffb9115e40 [ 1648.667695] FS: 00007f8aadba5740(0000) GS:ffff94f57eb40000(0000) knlGS:0000000000000000 [ 1648.668447] CS: 0010 DS: 0000 ES: 0000 CR0: 0000000080050033 [ 1648.669202] CR2: 0000000000000000 CR3: 0000001022772000 CR4: 0000000000340fe0 [ 1648.669966] Call Trace: [ 1648.670730] [] ? bnxt_need_reserve_rings+0x9d/0x170 [bnxt_en] [ 1648.671496] [] __bnxt_open_nic+0x8a/0x9a0 [bnxt_en] [ 1648.672263] [] ? bnxt_close_nic+0x59/0x1b0 [bnxt_en] [ 1648.673031] [] bnxt_open_nic+0x1b/0x50 [bnxt_en] [ 1648.673793] [] bnxt_set_ringparam+0x6c/0xa0 [bnxt_en] [ 1648.674550] [] dev_ethtool+0x1334/0x21a0 [ 1648.675306] [] dev_ioctl+0x1ef/0x5f0 [ 1648.676061] [] sock_do_ioctl+0x4d/0x60 [ 1648.676810] [] sock_ioctl+0x1eb/0x2d0 [ 1648.677548] [] do_vfs_ioctl+0x3a0/0x5b0 [ 1648.678282] [] ? __do_page_fault+0x238/0x500 [ 1648.679016] [] SyS_ioctl+0xa1/0xc0 [ 1648.679745] [] system_call_fastpath+0x25/0x2a [ 1648.680461] Code: 9e 60 01 00 00 0f 1f 40 00 45 8b 8e 48 01 00 00 31 c9 45 85 c9 0f 8e 73 01 00 00 66 0f 1f 44 00 00 49 8b 86 a8 00 00 00 48 63 d1 <48> 8b 14 d0 48 85 d2 0f 84 46 01 00 00 41 8b 86 44 01 00 00 c7 [ 1648.681986] RIP [] bnxt_alloc_mem+0x50a/0x1140 [bnxt_en] [ 1648.682724] RSP [ 1648.683451] CR2: 0000000000000000 Fixes: ec5d31e3c15d ("bnxt_en: Handle firmware reset status during IF_UP.") Reviewed-by: Vasundhara Volam Reviewed-by: Pavan Chebbi Signed-off-by: Michael Chan --- drivers/net/ethernet/broadcom/bnxt/bnxt.c | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/drivers/net/ethernet/broadcom/bnxt/bnxt.c b/drivers/net/ethernet/broadcom/bnxt/bnxt.c index 8012386b4a0f..0165f70dba74 100644 --- a/drivers/net/ethernet/broadcom/bnxt/bnxt.c +++ b/drivers/net/ethernet/broadcom/bnxt/bnxt.c @@ -9779,7 +9779,10 @@ int bnxt_open_nic(struct bnxt *bp, bool irq_re_init, bool link_re_init) { int rc = 0; - rc = __bnxt_open_nic(bp, irq_re_init, link_re_init); + if (test_bit(BNXT_STATE_ABORT_ERR, &bp->state)) + rc = -EIO; + if (!rc) + rc = __bnxt_open_nic(bp, irq_re_init, link_re_init); if (rc) { netdev_err(bp->dev, "nic open fail (rc: %x)\n", rc); dev_close(bp->dev); From patchwork Mon Oct 26 04:18:21 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Michael Chan X-Patchwork-Id: 288121 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-12.7 required=3.0 tests=BAYES_00,DKIMWL_WL_HIGH, DKIM_SIGNED,DKIM_VALID,DKIM_VALID_AU,HEADER_FROM_DIFFERENT_DOMAINS, INCLUDES_PATCH, MAILING_LIST_MULTI, MIME_HEADER_CTYPE_ONLY, SIGNED_OFF_BY, SPF_HELO_NONE, SPF_PASS, T_TVD_MIME_NO_HEADERS, URIBL_BLOCKED, USER_AGENT_GIT autolearn=ham autolearn_force=no version=3.4.0 Received: from mail.kernel.org (mail.kernel.org [198.145.29.99]) by smtp.lore.kernel.org (Postfix) with ESMTP id 63B29C56201 for ; Mon, 26 Oct 2020 04:18:40 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mail.kernel.org (Postfix) with ESMTP id 13CDC22247 for ; Mon, 26 Oct 2020 04:18:40 +0000 (UTC) Authentication-Results: mail.kernel.org; dkim=pass (1024-bit key) header.d=broadcom.com header.i=@broadcom.com header.b="CERhcMSP" Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1421018AbgJZESj (ORCPT ); Mon, 26 Oct 2020 00:18:39 -0400 Received: from mail-pl1-f193.google.com ([209.85.214.193]:42268 "EHLO mail-pl1-f193.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1420967AbgJZESi (ORCPT ); Mon, 26 Oct 2020 00:18:38 -0400 Received: by mail-pl1-f193.google.com with SMTP id t22so4115059plr.9 for ; Sun, 25 Oct 2020 21:18:37 -0700 (PDT) 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=kHZxykr3MBtf9fNtmterRp5McBAJfcZeT+TwwHws64w=; b=CERhcMSPoqKwEpCQkGYQVels6Utq+3dAwWapNYphF1hbl8QrAHVuLVa9y46qhjCA+d FrwAiIabegfDMX5jRoWe3mMxMri0snlvlNmfYjnlp+FfKa3EthxMn/H+bPgi9bzgNIMB lqWZBlAjSW1sFA6ck7bcMiB0uFX03LJamHvC8= 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:in-reply-to :references; bh=kHZxykr3MBtf9fNtmterRp5McBAJfcZeT+TwwHws64w=; b=bm+q/PMJwlroFM0YWxaDVt16WvjNglYVn0JZEoEf2SBmr+q9J8yL3rLLHuOnv19SG/ f2cy79qHxX8L/J39xwfTz74gpnBlPDQCzPsXPkfvJI9v78YdCgAB+VldJtnnJ+PGXjO6 pWlJWiifLHHOhP10tR9ZGvwyjhrlNRVNntDy/ESYOaPTUt2ragF5rTS+Daw7yI0mHO1j kejFDSHDAAvdEFMNWEAx9xGpshjfhj9Avz/W99gydkT+RtVMXuvD100yOifjRxTGnaNh LMku4C7cPfOWUDjHnEkIRSfqJGgxTatOc+TiNh+ARoduvNXLgh56FprDLsben3oLCeye RWxg== X-Gm-Message-State: AOAM532BWjWEG8qKtNbaNeF1VOkONPJPBzcSBGtQroorciUO1GS2CtVt tZPjooa71ePze6aQUVDNq1juQg== X-Google-Smtp-Source: ABdhPJwIbiyxDTUbEZfXZB4pCiJ9h9uU8us/tV99Tvz4K7G859oa8HthM3BdN6fGlQHbju+nsTDRgA== X-Received: by 2002:a17:902:8502:b029:d5:b4f4:8555 with SMTP id bj2-20020a1709028502b02900d5b4f48555mr12912230plb.76.1603685917100; Sun, 25 Oct 2020 21:18:37 -0700 (PDT) Received: from localhost.swdvt.lab.broadcom.net ([192.19.223.252]) by smtp.gmail.com with ESMTPSA id 10sm11505835pjt.50.2020.10.25.21.18.36 (version=TLS1_2 cipher=ECDHE-ECDSA-AES128-GCM-SHA256 bits=128/128); Sun, 25 Oct 2020 21:18:36 -0700 (PDT) From: Michael Chan To: kuba@kernel.org Cc: netdev@vger.kernel.org, gospo@broadcom.com, Vasundhara Volam Subject: [PATCH net 5/5] bnxt_en: Send HWRM_FUNC_RESET fw command unconditionally. Date: Mon, 26 Oct 2020 00:18:21 -0400 Message-Id: <1603685901-17917-6-git-send-email-michael.chan@broadcom.com> X-Mailer: git-send-email 1.8.3.1 In-Reply-To: <1603685901-17917-1-git-send-email-michael.chan@broadcom.com> References: <1603685901-17917-1-git-send-email-michael.chan@broadcom.com> Precedence: bulk List-ID: X-Mailing-List: netdev@vger.kernel.org From: Vasundhara Volam In the AER or firmware reset flow, if we are in fatal error state or if pci_channel_offline() is true, we don't send any commands to the firmware because the commands will likely not reach the firmware and most commands don't matter much because the firmware is likely to be reset imminently. However, the HWRM_FUNC_RESET command is different and we should always attempt to send it. In the AER flow for example, the .slot_reset() call will trigger this fw command and we need to try to send it to effect the proper reset. Fixes: b340dc680ed4 ("bnxt_en: Avoid sending firmware messages when AER error is detected.") Reviewed-by: Edwin Peer Signed-off-by: Vasundhara Volam Signed-off-by: Michael Chan --- drivers/net/ethernet/broadcom/bnxt/bnxt.c | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/drivers/net/ethernet/broadcom/bnxt/bnxt.c b/drivers/net/ethernet/broadcom/bnxt/bnxt.c index 0165f70dba74..7975f59735d6 100644 --- a/drivers/net/ethernet/broadcom/bnxt/bnxt.c +++ b/drivers/net/ethernet/broadcom/bnxt/bnxt.c @@ -4352,7 +4352,8 @@ static int bnxt_hwrm_do_send_msg(struct bnxt *bp, void *msg, u32 msg_len, u32 bar_offset = BNXT_GRCPF_REG_CHIMP_COMM; u16 dst = BNXT_HWRM_CHNL_CHIMP; - if (BNXT_NO_FW_ACCESS(bp)) + if (BNXT_NO_FW_ACCESS(bp) && + le16_to_cpu(req->req_type) != HWRM_FUNC_RESET) return -EBUSY; if (msg_len > BNXT_HWRM_MAX_REQ_LEN) {