Commit 94245412 authored by Wesley W. Terpstra's avatar Wesley W. Terpstra Committed by Grzegorz Daniluk

rxts_calibrator: fix incorrect t24p phase resulting in rare track failures

t24p calibration finds the rising&falling edges in
dev/rxts_calibrator.c:rxts_calibration_update.  It then computes the
"transition" as (falling+rising)/2.  That is, ttrans points 25% past the
dangerous transition.  Now that value arrives in one of the three copies of
ptpd_netif_linearize_rx_timestamp (depending on build).  In this method
ttrans has +-1/4 period added to it to compute trip_lo and trip_hi.  The
intent as described by the comment (and common sense) is to avoid the rising
edge when the phase is within +-1/4 period.  Unfortunately, this code
assumes that ttrans IS the rising edge, when in fact it is the rising
edge+25%. Thus, the code ACTUALLY tests phase within 0-50%.
parent 995c4ddd
......@@ -147,21 +147,25 @@ int rxts_calibration_update(uint32_t *t24p_value)
return -1;
if (det_rising.trans_phase > det_falling.trans_phase)
det_falling.trans_phase += REF_CLOCK_PERIOD_PS;
uint32_t ttrans =
(det_falling.trans_phase + det_rising.trans_phase) / 2;
/* normalize */
if (ttrans < 0)
else if (ttrans >= REF_CLOCK_PERIOD_PS)
while (det_falling.trans_phase >= REF_CLOCK_PERIOD_PS)
det_falling.trans_phase -= REF_CLOCK_PERIOD_PS;
while (det_rising.trans_phase >= REF_CLOCK_PERIOD_PS)
det_rising.trans_phase -= REF_CLOCK_PERIOD_PS;
/* Use falling edge as second sample of rising edge */
uint32_t ttrans = det_falling.trans_phase;
ttrans += REF_CLOCK_PERIOD_PS/2;
if (ttrans >= REF_CLOCK_PERIOD_PS)
ttrans += det_rising.trans_phase;
ttrans /= 2;
TRACE_DEV("RXTS calibration: R@%dps, F@%dps, transition@%dps\n",
det_rising.trans_phase, det_falling.trans_phase,
*t24p_value = ttrans;
return 1;
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment