Received: by 2002:a25:1506:0:0:0:0:0 with SMTP id 6csp3730043ybv; Mon, 10 Feb 2020 05:27:16 -0800 (PST) X-Google-Smtp-Source: APXvYqxAC/wRilQ9uR1NhvElGvVNQFvu6qZyS5cy9CtJABoKw8EbIa29Fa6wbReRJqCpwAOKQo/H X-Received: by 2002:a9d:6a2:: with SMTP id 31mr1010931otx.313.1581341235954; Mon, 10 Feb 2020 05:27:15 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1581341235; cv=none; d=google.com; s=arc-20160816; b=Eg1Gr3vTEhgGyR9mOi6tRkrrAMp+FPQoCLZl9IO4MGEBnJ4Nm01Bq83PYHjZbuoz+K 5omd9VPa53OWd/1z5+YXg1GSClP3GEbTHU07uYbqVEqly/1LYn3cyODNhKDriQXSgfCo M9dznr+LAKshVgYFL5MWN8M+4pBXZ4HLfEsc165UCxi6JSt15cvzZmAgyBhC7EC7n+OM yCgLN9d8MPfue623SToKo8WwHgc+N4ES5b3/S6iH8w4Sg8O59ezKv8wcW6N0hGOCeg5j aPYdNdwLk19j2cFAD41wysuG6Zl2SsU8o2dkF5UDaG+VtsYVtbhS6YBoJf8iyJz0nhwd U4sg== 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=aXNVUyhodngYjpcqocW/zEW8kJ3CRXogwenZq34YGk8=; b=q9FuHwX9fqCYTvlx+RauDb76m2NuKEJWh0D97jUDV5f7AuBxP8DVtsulyvS6/1uKXh o5koYyrlO+pYos7jI20/E7ulRgZZmzd44DNHYOtZ4Hb/J+dN6UHsOUwiXrICT/YLBABt PXsVBah3Jn9EdN5vixofM8FTgKL4imq9366d9osfRf7Xn2Wnc2AAoWzRy/mMUF6Xhxyy PC7RW0dxmQMgclCw1m0Qv7ZEZvWy6R/boMCJzeB1kNnTO5qk1BJgDPnVOHZQ3NZ1TFug pILQsU+nvLwQGd2fSRDLSvFBA7vXXcZJthEElHWcTHpy0h0LEN/6DmHRW+Ejif01dSos 9UPA== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@kernel.org header.s=default header.b=f9IcMdjS; 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 z15si166833otm.168.2020.02.10.05.27.04; Mon, 10 Feb 2020 05:27:15 -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=f9IcMdjS; 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 S1730796AbgBJN0k (ORCPT + 99 others); Mon, 10 Feb 2020 08:26:40 -0500 Received: from mail.kernel.org ([198.145.29.99]:56566 "EHLO mail.kernel.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1728493AbgBJMgo (ORCPT ); Mon, 10 Feb 2020 07:36:44 -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 A35542051A; Mon, 10 Feb 2020 12:36:43 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=default; t=1581338203; bh=pnJ6H7TyYYyp1B+q916+0lMdWSoHfJ/VUKuCSLuQoRY=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=f9IcMdjSp2CuydVzkxrPbPW1EulxfSXoJ1ss4EFnA6pzuzXF4gePB3XB6U/G492Ic yy62+weDZtmAlDtpL7bxVb5sFn+u0ASHzxyU9yk6lMcQbWrrXkqz6d8SWK7FGVYYuG dlahwgoLcAU/j6T6zrAQjJoGmSXLljelfa6MrZmU= 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.4 021/309] bnxt_en: Fix logic that disables Bus Master during firmware reset. Date: Mon, 10 Feb 2020 04:29:37 -0800 Message-Id: <20200210122408.025809959@linuxfoundation.org> X-Mailer: git-send-email 2.25.0 In-Reply-To: <20200210122406.106356946@linuxfoundation.org> References: <20200210122406.106356946@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 @@ -9273,10 +9273,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 */ @@ -10052,8 +10048,15 @@ static void bnxt_fw_reset_close(struct b { __bnxt_close_nic(bp, true, false); bnxt_ulp_irq_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_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;