In the refclock initialization, if the driver provides a poll()
function and 2^(poll-dpoll) is smaller than the configured length of the
median filter (64 by default), the filter is shortened to 2^(poll-dpoll)
samples, assuming the driver provides samples only in the poll()
function and at most one per call, to avoid wasting memory and before
commit
12237bf28393 ("refclock: stop requiring 4 samples in median
filter") also simplify configuration (for polling drivers only)
But this assumption is not always correct. The PHC driver can read
external PPS timestamps independently from the driver polling and the
RTC driver can timestamp interrupts. If the dpoll was too large to cover
the sample rate, some samples would be lost.
Drop the adjustment of the filter length to avoid this unexpected impact
on filtering and make it work as documented.
}
if (inst->driver->poll) {
- int max_samples;
-
if (inst->driver_poll > inst->poll)
inst->driver_poll = inst->poll;
-
- /* Adjust the filter length to save memory if the expected number
- of samples is smaller */
- max_samples = 1 << (inst->poll - inst->driver_poll);
- if (max_samples < params->filter_length) {
- params->filter_length = max_samples;
- }
}
if (inst->driver->init && !inst->driver->init(inst))