netdev.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
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 10/15] bnxt_en: Add bnxt_fw_reset_timeout() helper.
Date: Mon, 25 Jan 2021 02:08:16 -0500	[thread overview]
Message-ID: <1611558501-11022-11-git-send-email-michael.chan@broadcom.com> (raw)
In-Reply-To: <1611558501-11022-1-git-send-email-michael.chan@broadcom.com>

This code to check if we have reached the maximum wait time after
firmware reset is used multiple times.  Add a helper function to
do this.

Reviewed-by: Edwin Peer <edwin.peer@broadcom.com>
Signed-off-by: Michael Chan <michael.chan@broadcom.com>
---
 drivers/net/ethernet/broadcom/bnxt/bnxt.c | 15 +++++++++------
 1 file changed, 9 insertions(+), 6 deletions(-)

diff --git a/drivers/net/ethernet/broadcom/bnxt/bnxt.c b/drivers/net/ethernet/broadcom/bnxt/bnxt.c
index c35a5d497c1e..98caac9fbdee 100644
--- a/drivers/net/ethernet/broadcom/bnxt/bnxt.c
+++ b/drivers/net/ethernet/broadcom/bnxt/bnxt.c
@@ -11503,6 +11503,12 @@ static void bnxt_reset_all(struct bnxt *bp)
 	bp->fw_reset_timestamp = jiffies;
 }
 
+static bool bnxt_fw_reset_timeout(struct bnxt *bp)
+{
+	return time_after(jiffies, bp->fw_reset_timestamp +
+			  (bp->fw_reset_max_dsecs * HZ / 10));
+}
+
 static void bnxt_fw_reset_task(struct work_struct *work)
 {
 	struct bnxt *bp = container_of(work, struct bnxt, fw_reset_task.work);
@@ -11524,8 +11530,7 @@ static void bnxt_fw_reset_task(struct work_struct *work)
 				   bp->fw_reset_timestamp));
 			goto fw_reset_abort;
 		} else if (n > 0) {
-			if (time_after(jiffies, bp->fw_reset_timestamp +
-				       (bp->fw_reset_max_dsecs * HZ / 10))) {
+			if (bnxt_fw_reset_timeout(bp)) {
 				clear_bit(BNXT_STATE_IN_FW_RESET, &bp->state);
 				bp->fw_reset_state = 0;
 				netdev_err(bp->dev, "Firmware reset aborted, bnxt_get_registered_vfs() returns %d\n",
@@ -11554,8 +11559,7 @@ static void bnxt_fw_reset_task(struct work_struct *work)
 
 		val = bnxt_fw_health_readl(bp, BNXT_FW_HEALTH_REG);
 		if (!(val & BNXT_FW_STATUS_SHUTDOWN) &&
-		    !time_after(jiffies, bp->fw_reset_timestamp +
-		    (bp->fw_reset_max_dsecs * HZ / 10))) {
+		    !bnxt_fw_reset_timeout(bp)) {
 			bnxt_queue_fw_reset_work(bp, HZ / 5);
 			return;
 		}
@@ -11597,8 +11601,7 @@ static void bnxt_fw_reset_task(struct work_struct *work)
 		bp->hwrm_cmd_timeout = SHORT_HWRM_CMD_TIMEOUT;
 		rc = __bnxt_hwrm_ver_get(bp, true);
 		if (rc) {
-			if (time_after(jiffies, bp->fw_reset_timestamp +
-				       (bp->fw_reset_max_dsecs * HZ / 10))) {
+			if (bnxt_fw_reset_timeout(bp)) {
 				netdev_err(bp->dev, "Firmware reset aborted\n");
 				goto fw_reset_abort_status;
 			}
-- 
2.18.1


  parent reply	other threads:[~2021-01-25  7:53 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 ` [PATCH net-next 04/15] bnxt_en: Retry sending the first message to firmware if it is under reset Michael Chan
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 ` Michael Chan [this message]
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-11-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).