Message ID | 1622249601-7106-1-git-send-email-michael.chan@broadcom.com |
---|---|
Headers | show |
Series | bnxt_en: Add hardware PTP timestamping support on 575XX devices. | expand |
On Fri, 28 May 2021 20:53:19 -0400 Michael Chan wrote: > + struct bnxt_ptp_cfg *ptp = bp->ptp_cfg; > + u64 time; > + > + if (!ptp) > + return -ENODEV; > + > + time = READ_ONCE(ptp->old_time); READ_ONCE() on a u64? That's not gonna prevent tearing the read on 32 bit architectures, right? > + *ts = (time & BNXT_HI_TIMER_MASK) | pkt_ts; > + if (pkt_ts < (time & BNXT_LO_TIMER_MASK)) > + *ts += BNXT_LO_TIMER_MASK + 1; The stamp is from the MAC, I hope, or otherwise packet which could have been sitting on the ring for some approximation of eternity. You can easily see a packet stamp older than the value stashed in ptp->old_time if you run soon after the refresh.
On Fri, May 28, 2021 at 6:42 PM Jakub Kicinski <kuba@kernel.org> wrote: > > On Fri, 28 May 2021 20:53:17 -0400 Michael Chan wrote: > > +int bnxt_ptp_init(struct bnxt *bp) > > This function never fails. > > > + struct bnxt_ptp_cfg *ptp = bp->ptp_cfg; > > + > > + if (!ptp) > > + return 0; > > + > > + atomic_set(&ptp->tx_avail, BNXT_MAX_TX_TS); > > + > > + memset(&ptp->cc, 0, sizeof(ptp->cc)); > > + ptp->cc.read = bnxt_cc_read; > > + ptp->cc.mask = CYCLECOUNTER_MASK(64); > > + ptp->cc.shift = 0; > > + ptp->cc.mult = 1; > > + > > + timecounter_init(&ptp->tc, &ptp->cc, ktime_to_ns(ktime_get_real())); > > + > > + ptp->ptp_info = bnxt_ptp_caps; > > + ptp->ptp_clock = ptp_clock_register(&ptp->ptp_info, &bp->pdev->dev); > > + if (IS_ERR(ptp->ptp_clock)) > > + ptp->ptp_clock = NULL; > > Why not propagate the error? I thought only NULL should be silently > ignored? I could be confused about the rules, tho :) Yeah, we should propagate the error so the caller can print a warning. > > > + return 0;