Received: by 2002:a25:1506:0:0:0:0:0 with SMTP id 6csp3695638ybv; Mon, 10 Feb 2020 04:52:57 -0800 (PST) X-Google-Smtp-Source: APXvYqxBZ2rmGe9m3pQvAOsafc6DlGaclulzm96IH2DXZvhXDfsnONAYQVo9xA0wXbfboNuzabwd X-Received: by 2002:a54:4195:: with SMTP id 21mr700124oiy.92.1581339177709; Mon, 10 Feb 2020 04:52:57 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1581339177; cv=none; d=google.com; s=arc-20160816; b=vJK2L47nW8p2hUGwp5UtZrhvnn1FRxX0Kb3Fi3gf/GC9z/IDMSfzKxovhXJjn2zpAh eI4PdgFij8Fvvm1oThFkF0FC/9jR1RXI3zQl0GCpV/sMazvC5bmzYer/XcbxIbBP41rI x8PakJiKA9ysKR/7EEgs9+C+LiAgaEcnszynamwgh1bgQPMO+N9XE/x5w3AmG/micCJ1 GwahFLjsmn/WOBpCyhzTNznkeC/iEmNJ+TIn9e8rC5YO65Inx57Afcf//PwUYEk05rNR 6W7n0hy6N6t6LuXJwjU2DQnQ8P1tq/uwp11B1sYlZol6gGjWMu8xDw2Lfn/KVrivK3my RRWA== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:content-transfer-encoding:mime-version :user-agent:references:in-reply-to:message-id:date:subject:cc:to :from:dkim-signature; bh=pzXTbfxn+ldIC0Adcvf4HgFMHTFNthNizvHa2oX2BBo=; b=sZ+6pnCxISxwJx0tBfAXPa1OOKpWRnoe++wz0UhxoUE0fTb9pWt2cvZfxdto9YLG5V McSw3bUh/SB59wCzDa12e8J4MxCO+nrPYZO4UJH103CGjV0mc8nKWQALyR22nQgcPqly vP/lt5QNEalRkV8GzthFc1cNNlsWwzphvesAZj2F5oeEwBhPOkKKBylibV9NI6h12U1/ IBeSkTDmxwtrC2gIUwj5aHcveVMK903GSDMGHk+JalNSClbhQ3rgQUqCFvCPeLZK6qzy YJdohDR+uKOQOvZ6TS5vF2COn7ggGfxA9Jm0nQvtt7KDNzVX3GVaCcNo8y2Rj6iw957d q4DQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@kernel.org header.s=default header.b=zY6dMksg; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id i124si127637oif.214.2020.02.10.04.52.46; Mon, 10 Feb 2020 04:52:57 -0800 (PST) Received-SPF: pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) client-ip=209.132.180.67; Authentication-Results: mx.google.com; dkim=pass header.i=@kernel.org header.s=default header.b=zY6dMksg; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1730316AbgBJMms (ORCPT + 99 others); Mon, 10 Feb 2020 07:42:48 -0500 Received: from mail.kernel.org ([198.145.29.99]:37544 "EHLO mail.kernel.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1729432AbgBJMjd (ORCPT ); Mon, 10 Feb 2020 07:39:33 -0500 Received: from localhost (unknown [209.37.97.194]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mail.kernel.org (Postfix) with ESMTPSA id 1251620842; Mon, 10 Feb 2020 12:39:32 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=default; t=1581338372; bh=jPoE6XcnEbE2KOaQgoztjLf0DwFZSq5ltPR9Xwbho0k=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=zY6dMksgqH3PA3W0WUjjr95WStdQ1mxu3I0exCpV29l3Oj6RO/PfG6tmtNEiGb0yR JmDwMg6g+GLUoddXOVjmcbDZu43FEgA1/t6a/3KAjyhTQzk3BCsHX9j9WwreQ7queZ 5+qKzkjQUyRAVEhqTYScNeSGNHzId6POBO7nmd5U= From: Greg Kroah-Hartman To: linux-kernel@vger.kernel.org Cc: Greg Kroah-Hartman , stable@vger.kernel.org, Vasundhara Volam , Michael Chan , Jakub Kicinski Subject: [PATCH 5.5 026/367] bnxt_en: Fix logic that disables Bus Master during firmware reset. Date: Mon, 10 Feb 2020 04:28:59 -0800 Message-Id: <20200210122426.308964111@linuxfoundation.org> X-Mailer: git-send-email 2.25.0 In-Reply-To: <20200210122423.695146547@linuxfoundation.org> References: <20200210122423.695146547@linuxfoundation.org> User-Agent: quilt/0.66 MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org From: Vasundhara Volam [ Upstream commit d407302895d3f3ca3a333c711744a95e0b1b0150 ] The current logic that calls pci_disable_device() in __bnxt_close_nic() during firmware reset is flawed. If firmware is still alive, we're disabling the device too early, causing some firmware commands to not reach the firmware. Fix it by moving the logic to bnxt_reset_close(). If firmware is in fatal condition, we call pci_disable_device() before we free any of the rings to prevent DMA corruption of the freed rings. If firmware is still alive, we call pci_disable_device() after the last firmware message has been sent. Fixes: 3bc7d4a352ef ("bnxt_en: Add BNXT_STATE_IN_FW_RESET state.") Signed-off-by: Vasundhara Volam Signed-off-by: Michael Chan Signed-off-by: Jakub Kicinski Signed-off-by: Greg Kroah-Hartman --- drivers/net/ethernet/broadcom/bnxt/bnxt.c | 11 +++++++---- 1 file changed, 7 insertions(+), 4 deletions(-) --- a/drivers/net/ethernet/broadcom/bnxt/bnxt.c +++ b/drivers/net/ethernet/broadcom/bnxt/bnxt.c @@ -9312,10 +9312,6 @@ static void __bnxt_close_nic(struct bnxt bnxt_debug_dev_exit(bp); bnxt_disable_napi(bp); del_timer_sync(&bp->timer); - if (test_bit(BNXT_STATE_IN_FW_RESET, &bp->state) && - pci_is_enabled(bp->pdev)) - pci_disable_device(bp->pdev); - bnxt_free_skbs(bp); /* Save ring stats before shutdown */ @@ -10093,9 +10089,16 @@ static void bnxt_reset(struct bnxt *bp, static void bnxt_fw_reset_close(struct bnxt *bp) { bnxt_ulp_stop(bp); + /* When firmware is fatal state, disable PCI device to prevent + * any potential bad DMAs before freeing kernel memory. + */ + if (test_bit(BNXT_STATE_FW_FATAL_COND, &bp->state)) + pci_disable_device(bp->pdev); __bnxt_close_nic(bp, true, false); bnxt_clear_int_mode(bp); bnxt_hwrm_func_drv_unrgtr(bp); + if (pci_is_enabled(bp->pdev)) + pci_disable_device(bp->pdev); bnxt_free_ctx_mem(bp); kfree(bp->ctx); bp->ctx = NULL;