]> git.baikalelectronics.ru Git - kernel.git/commitdiff
bnxt_en: Initiallize bp->ptp_lock first before using it
authorMichael Chan <michael.chan@broadcom.com>
Tue, 3 May 2022 01:13:11 +0000 (21:13 -0400)
committerJakub Kicinski <kuba@kernel.org>
Wed, 4 May 2022 00:41:32 +0000 (17:41 -0700)
bnxt_ptp_init() calls bnxt_ptp_init_rtc() which will acquire the ptp_lock
spinlock.  The spinlock is not initialized until later.  Move the
bnxt_ptp_init_rtc() call after the spinlock is initialized.

Fixes: e9c5c7cbd596 ("bnxt_en: Add driver support to use Real Time Counter for PTP")
Reviewed-by: Pavan Chebbi <pavan.chebbi@broadcom.com>
Reviewed-by: Saravanan Vajravel <saravanan.vajravel@broadcom.com>
Reviewed-by: Andy Gospodarek <andrew.gospodarek@broadcom.com>
Reviewed-by: Somnath Kotur <somnath.kotur@broadcom.com>
Reviewed-by: Damodharam Ammepalli <damodharam.ammepalli@broadcom.com>
Signed-off-by: Michael Chan <michael.chan@broadcom.com>
Signed-off-by: Jakub Kicinski <kuba@kernel.org>
drivers/net/ethernet/broadcom/bnxt/bnxt_ptp.c

index 9c2ad5e67a5d894078932c397cb37cf265b7743b..00f2f80c007332911cec143635c7589f474dcfc8 100644 (file)
@@ -846,13 +846,6 @@ int bnxt_ptp_init(struct bnxt *bp, bool phc_cfg)
        if (rc)
                return rc;
 
-       if (bp->fw_cap & BNXT_FW_CAP_PTP_RTC) {
-               bnxt_ptp_timecounter_init(bp, false);
-               rc = bnxt_ptp_init_rtc(bp, phc_cfg);
-               if (rc)
-                       goto out;
-       }
-
        if (ptp->ptp_clock && bnxt_pps_config_ok(bp))
                return 0;
 
@@ -861,8 +854,14 @@ int bnxt_ptp_init(struct bnxt *bp, bool phc_cfg)
        atomic_set(&ptp->tx_avail, BNXT_MAX_TX_TS);
        spin_lock_init(&ptp->ptp_lock);
 
-       if (!(bp->fw_cap & BNXT_FW_CAP_PTP_RTC))
+       if (bp->fw_cap & BNXT_FW_CAP_PTP_RTC) {
+               bnxt_ptp_timecounter_init(bp, false);
+               rc = bnxt_ptp_init_rtc(bp, phc_cfg);
+               if (rc)
+                       goto out;
+       } else {
                bnxt_ptp_timecounter_init(bp, true);
+       }
 
        ptp->ptp_info = bnxt_ptp_caps;
        if ((bp->fw_cap & BNXT_FW_CAP_PTP_PPS)) {