Commit cfed2306 authored by Alessandro Rubini's avatar Alessandro Rubini

standard servo: bugfix (introduced with pp_time)

If meanPathDelay is calculated negative at the first iteration, we
must zero it immediately, or this will loop forever:

	while (mpd_fltr->y >> (63 - s))
		--s;

The bug only appears with e2e mechanism, where t3 happens long after
t2, if the slave clock when ppsi starts is running much slower than
the master.

Before changing data structures we used abs() in that loop (which was
suboptimal), and I made a mistake in converting it in a check before
the loop itlsef.
Signed-off-by: Alessandro Rubini's avatarAlessandro Rubini <rubini@gnudd.com>
parent ec54c4ce
......@@ -215,8 +215,8 @@ void pp_servo_mpd_fltr(struct pp_instance *ppi, struct pp_avg_fltr *mpd_fltr,
if (mpd_fltr->s_exp < 1) {
/* First time, keep what we have */
mpd_fltr->y = mpd->scaled_nsecs;
if (mpd->scaled_nsecs > 0)
mpd_fltr->y = mpd->scaled_nsecs;
if (mpd->scaled_nsecs < 0)
mpd_fltr->y = 0;
}
/* avoid overflowing filter: calculate number of bits */
s = OPTS(ppi)->s;
......
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