From: Michael Chan <michael.chan@broadcom.com>
To: davem@davemloft.net
Cc: netdev@vger.kernel.org, kuba@kernel.org, gospo@broadcom.com
Subject: [PATCH net-next 04/15] bnxt_en: Retry sending the first message to firmware if it is under reset.
Date: Mon, 25 Jan 2021 02:08:10 -0500 [thread overview]
Message-ID: <1611558501-11022-5-git-send-email-michael.chan@broadcom.com> (raw)
In-Reply-To: <1611558501-11022-1-git-send-email-michael.chan@broadcom.com>
The first HWRM_VER_GET message to firmware during probe may timeout if
firmware is under reset. This can happen during hot-plug for example.
On P5 and newer chips, we can check if firmware is in the boot stage by
reading a status register. Retry 5 times if the status register shows
that firmware is not ready and not in error state.
Reviewed-by: Edwin Peer <edwin.peer@broadcom.com>
Signed-off-by: Michael Chan <michael.chan@broadcom.com>
---
drivers/net/ethernet/broadcom/bnxt/bnxt.c | 42 +++++++++++++++++++----
drivers/net/ethernet/broadcom/bnxt/bnxt.h | 7 ++++
2 files changed, 42 insertions(+), 7 deletions(-)
diff --git a/drivers/net/ethernet/broadcom/bnxt/bnxt.c b/drivers/net/ethernet/broadcom/bnxt/bnxt.c
index c091a1023188..c460dd796c1c 100644
--- a/drivers/net/ethernet/broadcom/bnxt/bnxt.c
+++ b/drivers/net/ethernet/broadcom/bnxt/bnxt.c
@@ -7441,9 +7441,22 @@ static void bnxt_try_map_fw_health_reg(struct bnxt *bp)
sig = readl(hs + offsetof(struct hcomm_status, sig_ver));
if ((sig & HCOMM_STATUS_SIGNATURE_MASK) != HCOMM_STATUS_SIGNATURE_VAL) {
- if (bp->fw_health)
- bp->fw_health->status_reliable = false;
- return;
+ if (!bp->chip_num) {
+ __bnxt_map_fw_health_reg(bp, BNXT_GRC_REG_BASE);
+ bp->chip_num = readl(bp->bar0 +
+ BNXT_FW_HEALTH_WIN_BASE +
+ BNXT_GRC_REG_CHIP_NUM);
+ }
+ if (!BNXT_CHIP_P5(bp)) {
+ if (bp->fw_health)
+ bp->fw_health->status_reliable = false;
+ return;
+ }
+ status_loc = BNXT_GRC_REG_STATUS_P5 |
+ BNXT_FW_HEALTH_REG_TYPE_BAR0;
+ } else {
+ status_loc = readl(hs + offsetof(struct hcomm_status,
+ fw_status_loc));
}
if (__bnxt_alloc_fw_health(bp)) {
@@ -7451,7 +7464,6 @@ static void bnxt_try_map_fw_health_reg(struct bnxt *bp)
return;
}
- status_loc = readl(hs + offsetof(struct hcomm_status, fw_status_loc));
bp->fw_health->regs[BNXT_FW_HEALTH_REG] = status_loc;
reg_type = BNXT_FW_HEALTH_REG_TYPE(status_loc);
if (reg_type == BNXT_FW_HEALTH_REG_TYPE_GRC) {
@@ -9355,14 +9367,30 @@ static int bnxt_fw_reset_via_optee(struct bnxt *bp)
static int bnxt_try_recover_fw(struct bnxt *bp)
{
if (bp->fw_health && bp->fw_health->status_reliable) {
- u32 sts = bnxt_fw_health_readl(bp, BNXT_FW_HEALTH_REG);
+ int retry = 0, rc;
+ u32 sts;
+
+ mutex_lock(&bp->hwrm_cmd_lock);
+ do {
+ rc = __bnxt_hwrm_ver_get(bp, true);
+ sts = bnxt_fw_health_readl(bp, BNXT_FW_HEALTH_REG);
+ if (!sts || !BNXT_FW_IS_BOOTING(sts))
+ break;
+ retry++;
+ } while (rc == -EBUSY && retry < BNXT_FW_RETRY);
+ mutex_unlock(&bp->hwrm_cmd_lock);
- netdev_err(bp->dev, "Firmware not responding, status: 0x%x\n",
- sts);
+ if (!BNXT_FW_IS_HEALTHY(sts)) {
+ netdev_err(bp->dev,
+ "Firmware not responding, status: 0x%x\n",
+ sts);
+ rc = -ENODEV;
+ }
if (sts & FW_STATUS_REG_CRASHED_NO_MASTER) {
netdev_warn(bp->dev, "Firmware recover via OP-TEE requested\n");
return bnxt_fw_reset_via_optee(bp);
}
+ return rc;
}
return -ENODEV;
diff --git a/drivers/net/ethernet/broadcom/bnxt/bnxt.h b/drivers/net/ethernet/broadcom/bnxt/bnxt.h
index a1dd80a0fcf6..867b1d3a134e 100644
--- a/drivers/net/ethernet/broadcom/bnxt/bnxt.h
+++ b/drivers/net/ethernet/broadcom/bnxt/bnxt.h
@@ -1345,9 +1345,14 @@ struct bnxt_test_info {
#define BNXT_CAG_REG_LEGACY_INT_STATUS 0x4014
#define BNXT_CAG_REG_BASE 0x300000
+#define BNXT_GRC_REG_STATUS_P5 0x520
+
#define BNXT_GRCPF_REG_KONG_COMM 0xA00
#define BNXT_GRCPF_REG_KONG_COMM_TRIGGER 0xB00
+#define BNXT_GRC_REG_CHIP_NUM 0x48
+#define BNXT_GRC_REG_BASE 0x260000
+
#define BNXT_GRC_BASE_MASK 0xfffff000
#define BNXT_GRC_OFFSET_MASK 0x00000ffc
@@ -1547,6 +1552,8 @@ struct bnxt_fw_reporter_ctx {
#define BNXT_FW_IS_ERR(sts) (((sts) & BNXT_FW_STATUS_HEALTH_MSK) > \
BNXT_FW_STATUS_HEALTHY)
+#define BNXT_FW_RETRY 5
+
struct bnxt {
void __iomem *bar0;
void __iomem *bar1;
--
2.18.1
next prev parent reply other threads:[~2021-01-25 7:35 UTC|newest]
Thread overview: 19+ messages / expand[flat|nested] mbox.gz Atom feed top
2021-01-25 7:08 [PATCH net-next 00/15] bnxt_en: Error recovery improvements Michael Chan
2021-01-25 7:08 ` [PATCH net-next 01/15] bnxt_en: Update firmware interface to 1.10.2.11 Michael Chan
2021-01-25 7:08 ` [PATCH net-next 02/15] bnxt_en: Define macros for the various health register states Michael Chan
2021-01-25 7:08 ` [PATCH net-next 03/15] bnxt_en: handle CRASH_NO_MASTER during bnxt_open() Michael Chan
2021-01-25 7:08 ` Michael Chan [this message]
2021-01-25 7:08 ` [PATCH net-next 05/15] bnxt_en: Move reading VPD info after successful handshake with fw Michael Chan
2021-01-25 7:08 ` [PATCH net-next 06/15] bnxt_en: Add an upper bound for all firmware command timeouts Michael Chan
2021-01-25 7:08 ` [PATCH net-next 07/15] bnxt_en: log firmware debug notifications Michael Chan
2021-01-25 9:24 ` Joe Perches
2021-01-25 7:08 ` [PATCH net-next 08/15] bnxt_en: attempt to reinitialize after aborted reset Michael Chan
2021-01-25 7:08 ` [PATCH net-next 09/15] bnxt_en: Retry open if firmware is in reset Michael Chan
2021-01-25 7:08 ` [PATCH net-next 10/15] bnxt_en: Add bnxt_fw_reset_timeout() helper Michael Chan
2021-01-25 7:08 ` [PATCH net-next 11/15] bnxt_en: Add a new BNXT_STATE_NAPI_DISABLED flag to keep track of NAPI state Michael Chan
2021-01-25 7:08 ` [PATCH net-next 12/15] bnxt_en: Modify bnxt_disable_int_sync() to be called more than once Michael Chan
2021-01-25 7:08 ` [PATCH net-next 13/15] bnxt_en: Improve firmware fatal error shutdown sequence Michael Chan
2021-01-25 7:08 ` [PATCH net-next 14/15] bnxt_en: Consolidate firmware reset event logging Michael Chan
2021-01-25 7:08 ` [PATCH net-next 15/15] bnxt_en: Do not process completion entries after fatal condition detected Michael Chan
2021-01-26 1:37 ` [PATCH net-next 00/15] bnxt_en: Error recovery improvements Willem de Bruijn
2021-01-26 3:23 ` Jakub Kicinski
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=1611558501-11022-5-git-send-email-michael.chan@broadcom.com \
--to=michael.chan@broadcom.com \
--cc=davem@davemloft.net \
--cc=gospo@broadcom.com \
--cc=kuba@kernel.org \
--cc=netdev@vger.kernel.org \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).