bnxt_en: Do driver unregister cleanup in bnxt_init_one() failure path.
authorVasundhara Volam <vasundhara-v.volam@broadcom.com>
Sun, 24 Nov 2019 03:30:40 +0000 (22:30 -0500)
committerJakub Kicinski <jakub.kicinski@netronome.com>
Sun, 24 Nov 2019 22:48:02 +0000 (14:48 -0800)
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>
Signed-off-by: Jakub Kicinski <jakub.kicinski@netronome.com>
drivers/net/ethernet/broadcom/bnxt/bnxt.c
drivers/net/ethernet/broadcom/bnxt/bnxt.h

index 14b6104513310943586a177af9358fb62f9f2e24..464e8bd143658ccc6fd4b63a0f6b789c78fda024 100644 (file)
@@ -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 @@ init_err_cleanup_tc:
        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);
index e07311e3679204ba07645da02884f1eac2a8012d..a38664eef6143b6fe152fdea51470a9e38438014 100644 (file)
@@ -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;