Skip to contentSkip to conversation

bnxt_en: reset PHC frequency in free-running mode

PATCH In review Vadim Fedorenko 1 participant 2 messages Oct 18, 2023

Subsystems (3)
lore
Share & tools
lore
#0 lore raw

PATCH v4 1/1 bnxt_en: reset PHC frequency in free-running mode

When using a PHC in shared between multiple hosts, the previous frequency value may not be reset and could lead to host being unable to compensate the offset with timecounter adjustments. To avoid such state reset the hardware frequency of PHC to zero on init. Some refactoring is needed to make code readable.

Fixes 85036aee1938 ("bnxt_en: Add a non-real time mode to access NIC clock")
---
 drivers/net/ethernet/broadcom/bnxt/bnxt.c     |  6 +-
 drivers/net/ethernet/broadcom/bnxt/bnxt.h     |  2 +
 drivers/net/ethernet/broadcom/bnxt/bnxt_ptp.c | 56 ++++++++++---------
 3 files changed, 35 insertions(+), 29 deletions(-)
drivers/net/ethernet/broadcom/bnxt/bnxt.c +2 -4
index 808236dc898b..e2e2c986c82b 100644
@@ -6990,11 +6990,9 @@ static int bnxt_hwrm_func_qcfg(struct bnxt *bp)
 		if (flags & FUNC_QCFG_RESP_FLAGS_FW_DCBX_AGENT_ENABLED)
 			bp->fw_cap |= BNXT_FW_CAP_DCBX_AGENT;
 	}
-	if (BNXT_PF(bp) && (flags & FUNC_QCFG_RESP_FLAGS_MULTI_HOST)) {
+	if (BNXT_PF(bp) && (flags & FUNC_QCFG_RESP_FLAGS_MULTI_HOST))
 		bp->flags |= BNXT_FLAG_MULTI_HOST;
-		if (bp->fw_cap & BNXT_FW_CAP_PTP_RTC)
-			bp->fw_cap &= ~BNXT_FW_CAP_PTP_RTC;
-	}
+
 	if (flags & FUNC_QCFG_RESP_FLAGS_RING_MONITOR_ENABLED)
 		bp->fw_cap |= BNXT_FW_CAP_RING_MONITOR;
 
drivers/net/ethernet/broadcom/bnxt/bnxt.h +2 -0
index dcb09fbe4007..c0628ac1b798 100644
@@ -2000,6 +2000,8 @@ struct bnxt {
 	u32			fw_dbg_cap;
 
 #define BNXT_NEW_RM(bp)		((bp)->fw_cap & BNXT_FW_CAP_NEW_RM)
+#define BNXT_PTP_USE_RTC(bp)	(!BNXT_MH(bp) && \
+				 ((bp)->fw_cap & BNXT_FW_CAP_PTP_RTC))
 	u32			hwrm_spec_code;
 	u16			hwrm_cmd_seq;
 	u16                     hwrm_cmd_kong_seq;
drivers/net/ethernet/broadcom/bnxt/bnxt_ptp.c +31 -25

99 lines not on this page · raw message

Signature · 1 line
2.34.1
#1 lore raw

Please, disregard this patch, it was already applied, I sent again by mistake. Sorry for the noise.

________________________________________
From: Vadim Fedorenko <[email protected]>
Sent: 18 October 2023 01:16
To: Martin Lau; Jakub Kicinski; Pavan Chebbi; Andy Gospodarek; Michael Chan
Cc: Vadim Fedorenko; Richard Cochran; Vadim Fedorenko; [email protected]
Subject: [PATCH net v4] bnxt_en: reset PHC frequency in free-running mode

When using a PHC in shared between multiple hosts, the previous frequency value may not be reset and could lead to host being unable to compensate the offset with timecounter adjustments. To avoid such state reset the hardware frequency of PHC to zero on init. Some refactoring is needed to make code readable.

Fixes 85036aee1938 ("bnxt_en: Add a non-real time mode to access NIC clock")
---
 drivers/net/ethernet/broadcom/bnxt/bnxt.c     |  6 +-
 drivers/net/ethernet/broadcom/bnxt/bnxt.h     |  2 +
 drivers/net/ethernet/broadcom/bnxt/bnxt_ptp.c | 56 ++++++++++---------
 3 files changed, 35 insertions(+), 29 deletions(-)
drivers/net/ethernet/broadcom/bnxt/bnxt.c +2 -4
index 808236dc898b..e2e2c986c82b 100644
@@ -6990,11 +6990,9 @@ static int bnxt_hwrm_func_qcfg(struct bnxt *bp)
                if (flags & FUNC_QCFG_RESP_FLAGS_FW_DCBX_AGENT_ENABLED)
                        bp->fw_cap |= BNXT_FW_CAP_DCBX_AGENT;
        }
-       if (BNXT_PF(bp) && (flags & FUNC_QCFG_RESP_FLAGS_MULTI_HOST)) {
+       if (BNXT_PF(bp) && (flags & FUNC_QCFG_RESP_FLAGS_MULTI_HOST))
                bp->flags |= BNXT_FLAG_MULTI_HOST;
-               if (bp->fw_cap & BNXT_FW_CAP_PTP_RTC)
-                       bp->fw_cap &= ~BNXT_FW_CAP_PTP_RTC;
-       }
+
        if (flags & FUNC_QCFG_RESP_FLAGS_RING_MONITOR_ENABLED)
                bp->fw_cap |= BNXT_FW_CAP_RING_MONITOR;
 
drivers/net/ethernet/broadcom/bnxt/bnxt.h +2 -0
index dcb09fbe4007..c0628ac1b798 100644
@@ -2000,6 +2000,8 @@ struct bnxt {
        u32                     fw_dbg_cap;
 
 #define BNXT_NEW_RM(bp)                ((bp)->fw_cap & BNXT_FW_CAP_NEW_RM)
+#define BNXT_PTP_USE_RTC(bp)   (!BNXT_MH(bp) && \
+                                ((bp)->fw_cap & BNXT_FW_CAP_PTP_RTC))
        u32                     hwrm_spec_code;
        u16                     hwrm_cmd_seq;
        u16                     hwrm_cmd_kong_seq;
drivers/net/ethernet/broadcom/bnxt/bnxt_ptp.c +31 -25

99 lines not on this page · raw message

--
2.34.1