All of lore.kernel.org
 help / color / mirror / Atom feed
* [PATCH net] bnxt_en: Add missing periodic PHC overflow check
@ 2021-07-23 21:53 Michael Chan
  2021-07-24 12:16 ` Richard Cochran
  2021-07-24 19:00 ` patchwork-bot+netdevbpf
  0 siblings, 2 replies; 3+ messages in thread
From: Michael Chan @ 2021-07-23 21:53 UTC (permalink / raw)
  To: davem; +Cc: netdev, kuba, gospo, richardcochran, pavan.chebbi

[-- Attachment #1: Type: text/plain, Size: 2123 bytes --]

We use the timecounter APIs for the 48-bit PHC and packet timestamps.
We must periodically update the timecounter at roughly half the
overflow interval.  The overflow interval is about 78 hours, so
update it every 19 hours (1/4 interval) for some extra margins.

Fixes: 390862f45c85 ("bnxt_en: Get the full 48-bit hardware timestamp periodically")
Reviewed-by: Pavan Chebbi <pavan.chebbi@broadcom.com>
Signed-off-by: Michael Chan <michael.chan@broadcom.com>
---
 drivers/net/ethernet/broadcom/bnxt/bnxt_ptp.c | 7 +++++++
 drivers/net/ethernet/broadcom/bnxt/bnxt_ptp.h | 4 ++++
 2 files changed, 11 insertions(+)

diff --git a/drivers/net/ethernet/broadcom/bnxt/bnxt_ptp.c b/drivers/net/ethernet/broadcom/bnxt/bnxt_ptp.c
index 9089e7f3fbd4..ec381c2423b8 100644
--- a/drivers/net/ethernet/broadcom/bnxt/bnxt_ptp.c
+++ b/drivers/net/ethernet/broadcom/bnxt/bnxt_ptp.c
@@ -353,6 +353,12 @@ static long bnxt_ptp_ts_aux_work(struct ptp_clock_info *ptp_info)
 
 	bnxt_ptp_get_current_time(bp);
 	ptp->next_period = now + HZ;
+	if (time_after_eq(now, ptp->next_overflow_check)) {
+		spin_lock_bh(&ptp->ptp_lock);
+		timecounter_read(&ptp->tc);
+		spin_unlock_bh(&ptp->ptp_lock);
+		ptp->next_overflow_check = now + BNXT_PHC_OVERFLOW_PERIOD;
+	}
 	return HZ;
 }
 
@@ -423,6 +429,7 @@ int bnxt_ptp_init(struct bnxt *bp)
 	ptp->cc.shift = 0;
 	ptp->cc.mult = 1;
 
+	ptp->next_overflow_check = jiffies + BNXT_PHC_OVERFLOW_PERIOD;
 	timecounter_init(&ptp->tc, &ptp->cc, ktime_to_ns(ktime_get_real()));
 
 	ptp->ptp_info = bnxt_ptp_caps;
diff --git a/drivers/net/ethernet/broadcom/bnxt/bnxt_ptp.h b/drivers/net/ethernet/broadcom/bnxt/bnxt_ptp.h
index 4135ea3ec788..254ba7bc0f99 100644
--- a/drivers/net/ethernet/broadcom/bnxt/bnxt_ptp.h
+++ b/drivers/net/ethernet/broadcom/bnxt/bnxt_ptp.h
@@ -32,6 +32,10 @@ struct bnxt_ptp_cfg {
 	u64			current_time;
 	u64			old_time;
 	unsigned long		next_period;
+	unsigned long		next_overflow_check;
+	/* 48-bit PHC overflows in 78 hours.  Check overflow every 19 hours. */
+	#define BNXT_PHC_OVERFLOW_PERIOD	(19 * 3600 * HZ)
+
 	u16			tx_seqid;
 	struct bnxt		*bp;
 	atomic_t		tx_avail;
-- 
2.18.1


[-- Attachment #2: S/MIME Cryptographic Signature --]
[-- Type: application/pkcs7-signature, Size: 4209 bytes --]

^ permalink raw reply related	[flat|nested] 3+ messages in thread

* Re: [PATCH net] bnxt_en: Add missing periodic PHC overflow check
  2021-07-23 21:53 [PATCH net] bnxt_en: Add missing periodic PHC overflow check Michael Chan
@ 2021-07-24 12:16 ` Richard Cochran
  2021-07-24 19:00 ` patchwork-bot+netdevbpf
  1 sibling, 0 replies; 3+ messages in thread
From: Richard Cochran @ 2021-07-24 12:16 UTC (permalink / raw)
  To: Michael Chan; +Cc: davem, netdev, kuba, gospo, pavan.chebbi

On Fri, Jul 23, 2021 at 05:53:48PM -0400, Michael Chan wrote:
> We use the timecounter APIs for the 48-bit PHC and packet timestamps.
> We must periodically update the timecounter at roughly half the
> overflow interval.  The overflow interval is about 78 hours, so
> update it every 19 hours (1/4 interval) for some extra margins.
> 
> Fixes: 390862f45c85 ("bnxt_en: Get the full 48-bit hardware timestamp periodically")
> Reviewed-by: Pavan Chebbi <pavan.chebbi@broadcom.com>
> Signed-off-by: Michael Chan <michael.chan@broadcom.com>

Acked-by: Richard Cochran <richardcochran@gmail.com>

^ permalink raw reply	[flat|nested] 3+ messages in thread

* Re: [PATCH net] bnxt_en: Add missing periodic PHC overflow check
  2021-07-23 21:53 [PATCH net] bnxt_en: Add missing periodic PHC overflow check Michael Chan
  2021-07-24 12:16 ` Richard Cochran
@ 2021-07-24 19:00 ` patchwork-bot+netdevbpf
  1 sibling, 0 replies; 3+ messages in thread
From: patchwork-bot+netdevbpf @ 2021-07-24 19:00 UTC (permalink / raw)
  To: Michael Chan; +Cc: davem, netdev, kuba, gospo, richardcochran, pavan.chebbi

Hello:

This patch was applied to netdev/net.git (refs/heads/master):

On Fri, 23 Jul 2021 17:53:48 -0400 you wrote:
> We use the timecounter APIs for the 48-bit PHC and packet timestamps.
> We must periodically update the timecounter at roughly half the
> overflow interval.  The overflow interval is about 78 hours, so
> update it every 19 hours (1/4 interval) for some extra margins.
> 
> Fixes: 390862f45c85 ("bnxt_en: Get the full 48-bit hardware timestamp periodically")
> Reviewed-by: Pavan Chebbi <pavan.chebbi@broadcom.com>
> Signed-off-by: Michael Chan <michael.chan@broadcom.com>
> 
> [...]

Here is the summary with links:
  - [net] bnxt_en: Add missing periodic PHC overflow check
    https://git.kernel.org/netdev/net/c/89bc7f456cd4

You are awesome, thank you!
--
Deet-doot-dot, I am a bot.
https://korg.docs.kernel.org/patchwork/pwbot.html



^ permalink raw reply	[flat|nested] 3+ messages in thread

end of thread, other threads:[~2021-07-24 19:00 UTC | newest]

Thread overview: 3+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2021-07-23 21:53 [PATCH net] bnxt_en: Add missing periodic PHC overflow check Michael Chan
2021-07-24 12:16 ` Richard Cochran
2021-07-24 19:00 ` patchwork-bot+netdevbpf

This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.