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,
	Vasundhara Volam <vasundhara-v.volam@broadcom.com>
Subject: [PATCH net-next 03/15] bnxt_en: Do driver unregister cleanup in bnxt_init_one() failure path.
Date: Sat, 23 Nov 2019 03:25:58 -0500	[thread overview]
Message-ID: <1574497570-22102-4-git-send-email-michael.chan@broadcom.com> (raw)
In-Reply-To: <1574497570-22102-1-git-send-email-michael.chan@broadcom.com>

From: Vasundhara Volam <vasundhara-v.volam@broadcom.com>

In the bnxt_init_one() failure path, if the driver has already called
firmware to register the driver, it is not undoing the driver
registration.  Add this missing step to unregister for correctness,
so that the firmware knows that the driver has unloaded.

Signed-off-by: Vasundhara Volam <vasundhara-v.volam@broadcom.com>
Signed-off-by: Michael Chan <michael.chan@broadcom.com>
---
 drivers/net/ethernet/broadcom/bnxt/bnxt.c | 13 ++++++++++---
 drivers/net/ethernet/broadcom/bnxt/bnxt.h |  1 +
 2 files changed, 11 insertions(+), 3 deletions(-)

diff --git a/drivers/net/ethernet/broadcom/bnxt/bnxt.c b/drivers/net/ethernet/broadcom/bnxt/bnxt.c
index 14b6104..464e8bd 100644
--- a/drivers/net/ethernet/broadcom/bnxt/bnxt.c
+++ b/drivers/net/ethernet/broadcom/bnxt/bnxt.c
@@ -4483,9 +4483,12 @@ static int bnxt_hwrm_func_drv_rgtr(struct bnxt *bp)
 
 	mutex_lock(&bp->hwrm_cmd_lock);
 	rc = _hwrm_send_message(bp, &req, sizeof(req), HWRM_CMD_TIMEOUT);
-	if (!rc && (resp->flags &
-		    cpu_to_le32(FUNC_DRV_RGTR_RESP_FLAGS_IF_CHANGE_SUPPORTED)))
-		bp->fw_cap |= BNXT_FW_CAP_IF_CHANGE;
+	if (!rc) {
+		set_bit(BNXT_STATE_DRV_REGISTERED, &bp->state);
+		if (resp->flags &
+		    cpu_to_le32(FUNC_DRV_RGTR_RESP_FLAGS_IF_CHANGE_SUPPORTED))
+			bp->fw_cap |= BNXT_FW_CAP_IF_CHANGE;
+	}
 	mutex_unlock(&bp->hwrm_cmd_lock);
 	return rc;
 }
@@ -4494,6 +4497,9 @@ static int bnxt_hwrm_func_drv_unrgtr(struct bnxt *bp)
 {
 	struct hwrm_func_drv_unrgtr_input req = {0};
 
+	if (!test_and_clear_bit(BNXT_STATE_DRV_REGISTERED, &bp->state))
+		return 0;
+
 	bnxt_hwrm_cmd_hdr_init(bp, &req, HWRM_FUNC_DRV_UNRGTR, -1, -1);
 	return hwrm_send_message(bp, &req, sizeof(req), HWRM_CMD_TIMEOUT);
 }
@@ -11864,6 +11870,7 @@ static int bnxt_init_one(struct pci_dev *pdev, const struct pci_device_id *ent)
 	bnxt_clear_int_mode(bp);
 
 init_err_pci_clean:
+	bnxt_hwrm_func_drv_unrgtr(bp);
 	bnxt_free_hwrm_short_cmd_req(bp);
 	bnxt_free_hwrm_resources(bp);
 	bnxt_free_ctx_mem(bp);
diff --git a/drivers/net/ethernet/broadcom/bnxt/bnxt.h b/drivers/net/ethernet/broadcom/bnxt/bnxt.h
index e07311e..a38664eef 100644
--- a/drivers/net/ethernet/broadcom/bnxt/bnxt.h
+++ b/drivers/net/ethernet/broadcom/bnxt/bnxt.h
@@ -1646,6 +1646,7 @@ struct bnxt {
 #define BNXT_STATE_IN_FW_RESET	4
 #define BNXT_STATE_ABORT_ERR	5
 #define BNXT_STATE_FW_FATAL_COND	6
+#define BNXT_STATE_DRV_REGISTERED	7
 
 	struct bnxt_irq	*irq_tbl;
 	int			total_irqs;
-- 
2.5.1


  parent reply	other threads:[~2019-11-23  8:26 UTC|newest]

Thread overview: 19+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2019-11-23  8:25 [PATCH net-next 00/15] bnxt_en: Updates Michael Chan
2019-11-23  8:25 ` [PATCH net-next 01/15] bnxt_en: Add chip IDs for 57452 and 57454 chips Michael Chan
2019-11-23  8:25 ` [PATCH net-next 02/15] bnxt_en: Disable/enable Bus master during suspend/resume Michael Chan
2019-11-23  8:25 ` Michael Chan [this message]
2019-11-23  8:25 ` [PATCH net-next 04/15] bnxt_en: Combine 2 functions calling the same HWRM_DRV_RGTR fw command Michael Chan
2019-11-23  8:26 ` [PATCH net-next 05/15] bnxt_en: Send FUNC_RESOURCE_QCAPS command in bnxt_resume() Michael Chan
2019-11-23  8:26 ` [PATCH net-next 06/15] bnxt_en: Fix suspend/resume path on 57500 chips Michael Chan
2019-11-23  8:26 ` [PATCH net-next 07/15] bnxt_en: Initialize context memory to the value specified by firmware Michael Chan
2019-11-23  8:26 ` [PATCH net-next 08/15] bnxt_en: Assign more RSS context resources to the VFs Michael Chan
2019-11-23  8:26 ` [PATCH net-next 09/15] bnxt_en: Skip disabling autoneg before PHY loopback when appropriate Michael Chan
2019-11-23  8:26 ` [PATCH net-next 10/15] bnxt_en: Refactor the initialization of the ethtool link settings Michael Chan
2019-11-23  8:26 ` [PATCH net-next 11/15] bnxt_en: Add async. event logic for PHY configuration changes Michael Chan
2019-11-23  8:26 ` [PATCH net-next 12/15] bnxt_en: Allow PHY settings on multi-function or NPAR PFs if allowed by FW Michael Chan
2019-11-23  8:26 ` [PATCH net-next 13/15] bnxt_en: Add support for flashing the device via devlink Michael Chan
2019-11-23  8:26 ` [PATCH net-next 14/15] bnxt_en: Rename switch_id to dsn Michael Chan
2019-11-23  8:26 ` [PATCH net-next 15/15] bnxt_en: Add support for devlink info command Michael Chan
2019-11-23 19:55   ` Jakub Kicinski
2019-11-23 20:15     ` Michael Chan
2019-11-24  0:09       ` 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=1574497570-22102-4-git-send-email-michael.chan@broadcom.com \
    --to=michael.chan@broadcom.com \
    --cc=davem@davemloft.net \
    --cc=netdev@vger.kernel.org \
    --cc=vasundhara-v.volam@broadcom.com \
    /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).