Received: by 2002:a17:90a:9103:0:0:0:0 with SMTP id k3csp11789064pjo; Thu, 2 Jan 2020 14:18:24 -0800 (PST) X-Google-Smtp-Source: APXvYqwVle/zKSd28yd8zJPP4aihSknUwubECFLypVJuNLr7Cpb/XCZF/yTz324dlsVppv8xRYPm X-Received: by 2002:a9d:588d:: with SMTP id x13mr89568160otg.6.1578003504311; Thu, 02 Jan 2020 14:18:24 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1578003504; cv=none; d=google.com; s=arc-20160816; b=EQZQSa3Ljj4/kzYXotsNkqh0PTi4s2fFdARBaQJVafH9USvKlkB++LHbUOTfoRq1dl bUjeYvj5A7FDDkt7RuD4huueEGvm+YYLS2AQCy0PlLfWQ0lXeRnInNPItX/nXfdeqoP2 sQr3DydSlgyUyyoJqJzq3g7oHR90+WGxXBHQNhrsKZmjYRcq+lflLI7WQ6XoBTSC2igG raZke1Zt1Nwr4zHK/qT9rTIz6BBPyV260Xj0y4aKEMCvLUQSLUQwb4k5Fb1zMYdIk6NR 1dWLTGL9r/XCawgT7mFr8aH1WcBQlv168KUG7B1GF5LdfUfKCUB3UnqFc+wp3W7nxdL0 bCbg== 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=zA+rEfcDtW8NJC6cyBFrITJDIJtmLGtlZCcPX7i2VzA=; b=v3uNYvEj9X0vQSfgCJdVYfcLiyL+3lmAt4iJDff7WrLZ0dLA+f0/w2Iw6844jwC14m gyoyFZkfELQ4kr7qjaadNnKv4djcxEu8MSsdQ2ZW84ffeY07lIMewqDAYOfCG8i0MYY1 C6m+YlsXH5F8tk5ZrR21nSni6nKmemUp7qTcfTPqQpqG3KSGez4GHE0vRreeYM+eynKW dIXWO1Ox0y1vCcQYdLLLex7I213JASt9kQNm4JNoU5uQZD5PgZsZRNPdD5Ir+YGK997c 351Zflzpiiw69aLan/msgIRKEX6fVei/3BCcZcqfcWUpqBjX8+rt2rFAr+w0mp6tGm4N 0wlQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@kernel.org header.s=default header.b=Oh8GEUcr; 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 l131si27638142oig.120.2020.01.02.14.18.12; Thu, 02 Jan 2020 14:18:24 -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=Oh8GEUcr; 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 S1728167AbgABWR3 (ORCPT + 99 others); Thu, 2 Jan 2020 17:17:29 -0500 Received: from mail.kernel.org ([198.145.29.99]:59892 "EHLO mail.kernel.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1728350AbgABWR0 (ORCPT ); Thu, 2 Jan 2020 17:17:26 -0500 Received: from localhost (83-86-89-107.cable.dynamic.v4.ziggo.nl [83.86.89.107]) (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 7D76C21582; Thu, 2 Jan 2020 22:17:24 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=default; t=1578003445; bh=TUF6l8qqFHFTpbCmAeUfedIvNbaM8HwzC82v6RJxrsI=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=Oh8GEUcrWfYnZPNWCVWRiHyugSxk2I56/jXZ2/R9J6Go+7dy9zS4OfbEHbhxmxNeN 5LVyh/p2GqdBVdkdlYE68Cxysnb1taayhsAk0x3cAlLddju8NS0yuTGuX/7lKjUJ3l iTHY8HyY9PI+I7PBhwt9X2HfxRv9pHM6v7QKsUQU= From: Greg Kroah-Hartman To: linux-kernel@vger.kernel.org Cc: Greg Kroah-Hartman , stable@vger.kernel.org, Vasundhara Volam , Michael Chan , "David S. Miller" Subject: [PATCH 5.4 163/191] bnxt_en: Fix the logic that creates the health reporters. Date: Thu, 2 Jan 2020 23:07:25 +0100 Message-Id: <20200102215846.854474500@linuxfoundation.org> X-Mailer: git-send-email 2.24.1 In-Reply-To: <20200102215829.911231638@linuxfoundation.org> References: <20200102215829.911231638@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 937f188c1f4f89b3fa93ba31fc8587dc1fb14a22 ] Fix the logic to properly check the fw capabilities and create the devlink health reporters only when needed. The current code creates the reporters unconditionally as long as bp->fw_health is valid, and that's not correct. Call bnxt_dl_fw_reporters_create() directly from the init and reset code path instead of from bnxt_dl_register(). This allows the reporters to be adjusted when capabilities change. The same applies to bnxt_dl_fw_reporters_destroy(). Fixes: 6763c779c2d8 ("bnxt_en: Add new FW devlink_health_reporter") Signed-off-by: Vasundhara Volam Signed-off-by: Michael Chan Signed-off-by: David S. Miller Signed-off-by: Greg Kroah-Hartman --- drivers/net/ethernet/broadcom/bnxt/bnxt.c | 11 +++ drivers/net/ethernet/broadcom/bnxt/bnxt_devlink.c | 64 +++++++++++++++------- drivers/net/ethernet/broadcom/bnxt/bnxt_devlink.h | 2 3 files changed, 56 insertions(+), 21 deletions(-) --- a/drivers/net/ethernet/broadcom/bnxt/bnxt.c +++ b/drivers/net/ethernet/broadcom/bnxt/bnxt.c @@ -10563,6 +10563,12 @@ static int bnxt_fw_init_one(struct bnxt rc = bnxt_approve_mac(bp, bp->dev->dev_addr, false); if (rc) return rc; + + /* In case fw capabilities have changed, destroy the unneeded + * reporters and create newly capable ones. + */ + bnxt_dl_fw_reporters_destroy(bp, false); + bnxt_dl_fw_reporters_create(bp); bnxt_fw_init_one_p3(bp); return 0; } @@ -11339,6 +11345,7 @@ static void bnxt_remove_one(struct pci_d if (BNXT_PF(bp)) { bnxt_sriov_disable(bp); + bnxt_dl_fw_reporters_destroy(bp, true); bnxt_dl_unregister(bp); } @@ -11837,8 +11844,10 @@ static int bnxt_init_one(struct pci_dev if (rc) goto init_err_cleanup_tc; - if (BNXT_PF(bp)) + if (BNXT_PF(bp)) { bnxt_dl_register(bp); + bnxt_dl_fw_reporters_create(bp); + } netdev_info(dev, "%s found at mem %lx, node addr %pM\n", board_info[ent->driver_data].name, --- a/drivers/net/ethernet/broadcom/bnxt/bnxt_devlink.c +++ b/drivers/net/ethernet/broadcom/bnxt/bnxt_devlink.c @@ -102,21 +102,15 @@ struct devlink_health_reporter_ops bnxt_ .recover = bnxt_fw_fatal_recover, }; -static void bnxt_dl_fw_reporters_create(struct bnxt *bp) +void bnxt_dl_fw_reporters_create(struct bnxt *bp) { struct bnxt_fw_health *health = bp->fw_health; - if (!health) + if (!bp->dl || !health) return; - health->fw_reporter = - devlink_health_reporter_create(bp->dl, &bnxt_dl_fw_reporter_ops, - 0, false, bp); - if (IS_ERR(health->fw_reporter)) { - netdev_warn(bp->dev, "Failed to create FW health reporter, rc = %ld\n", - PTR_ERR(health->fw_reporter)); - health->fw_reporter = NULL; - } + if (!(bp->fw_cap & BNXT_FW_CAP_HOT_RESET) || health->fw_reset_reporter) + goto err_recovery; health->fw_reset_reporter = devlink_health_reporter_create(bp->dl, @@ -126,8 +120,30 @@ static void bnxt_dl_fw_reporters_create( netdev_warn(bp->dev, "Failed to create FW fatal health reporter, rc = %ld\n", PTR_ERR(health->fw_reset_reporter)); health->fw_reset_reporter = NULL; + bp->fw_cap &= ~BNXT_FW_CAP_HOT_RESET; } +err_recovery: + if (!(bp->fw_cap & BNXT_FW_CAP_ERROR_RECOVERY)) + return; + + if (!health->fw_reporter) { + health->fw_reporter = + devlink_health_reporter_create(bp->dl, + &bnxt_dl_fw_reporter_ops, + 0, false, bp); + if (IS_ERR(health->fw_reporter)) { + netdev_warn(bp->dev, "Failed to create FW health reporter, rc = %ld\n", + PTR_ERR(health->fw_reporter)); + health->fw_reporter = NULL; + bp->fw_cap &= ~BNXT_FW_CAP_ERROR_RECOVERY; + return; + } + } + + if (health->fw_fatal_reporter) + return; + health->fw_fatal_reporter = devlink_health_reporter_create(bp->dl, &bnxt_dl_fw_fatal_reporter_ops, @@ -136,24 +152,35 @@ static void bnxt_dl_fw_reporters_create( netdev_warn(bp->dev, "Failed to create FW fatal health reporter, rc = %ld\n", PTR_ERR(health->fw_fatal_reporter)); health->fw_fatal_reporter = NULL; + bp->fw_cap &= ~BNXT_FW_CAP_ERROR_RECOVERY; } } -static void bnxt_dl_fw_reporters_destroy(struct bnxt *bp) +void bnxt_dl_fw_reporters_destroy(struct bnxt *bp, bool all) { struct bnxt_fw_health *health = bp->fw_health; - if (!health) + if (!bp->dl || !health) return; - if (health->fw_reporter) - devlink_health_reporter_destroy(health->fw_reporter); - - if (health->fw_reset_reporter) + if ((all || !(bp->fw_cap & BNXT_FW_CAP_HOT_RESET)) && + health->fw_reset_reporter) { devlink_health_reporter_destroy(health->fw_reset_reporter); + health->fw_reset_reporter = NULL; + } - if (health->fw_fatal_reporter) + if ((bp->fw_cap & BNXT_FW_CAP_ERROR_RECOVERY) && !all) + return; + + if (health->fw_reporter) { + devlink_health_reporter_destroy(health->fw_reporter); + health->fw_reporter = NULL; + } + + if (health->fw_fatal_reporter) { devlink_health_reporter_destroy(health->fw_fatal_reporter); + health->fw_fatal_reporter = NULL; + } } void bnxt_devlink_health_report(struct bnxt *bp, unsigned long event) @@ -458,8 +485,6 @@ int bnxt_dl_register(struct bnxt *bp) devlink_params_publish(dl); - bnxt_dl_fw_reporters_create(bp); - return 0; err_dl_port_unreg: @@ -482,7 +507,6 @@ void bnxt_dl_unregister(struct bnxt *bp) if (!dl) return; - bnxt_dl_fw_reporters_destroy(bp); devlink_port_params_unregister(&bp->dl_port, bnxt_dl_port_params, ARRAY_SIZE(bnxt_dl_port_params)); devlink_port_unregister(&bp->dl_port); --- a/drivers/net/ethernet/broadcom/bnxt/bnxt_devlink.h +++ b/drivers/net/ethernet/broadcom/bnxt/bnxt_devlink.h @@ -57,6 +57,8 @@ struct bnxt_dl_nvm_param { }; void bnxt_devlink_health_report(struct bnxt *bp, unsigned long event); +void bnxt_dl_fw_reporters_create(struct bnxt *bp); +void bnxt_dl_fw_reporters_destroy(struct bnxt *bp, bool all); int bnxt_dl_register(struct bnxt *bp); void bnxt_dl_unregister(struct bnxt *bp);