platsupport,imx: Return ETIME when time in past The epit and ltimer implementations for imx need to return an error when asked to set a timeout not far enough into the future that it either rounds down to 0 or underflows. Signed-off-by: Kent McLeod <kent@kry10.com>
diff --git a/libplatsupport/src/mach/imx/epit/epit.c b/libplatsupport/src/mach/imx/epit/epit.c index f38fea9..21c64e9 100644 --- a/libplatsupport/src/mach/imx/epit/epit.c +++ b/libplatsupport/src/mach/imx/epit/epit.c
@@ -143,6 +143,9 @@ /* Set counter modulus - this effectively sets the timeouts to us but doesn't * overflow as fast. */ uint64_t counterValue = (uint64_t)(IPG_FREQ / (epit->prescaler + 1)) * (ns / 1000ULL); + if (counterValue == 0) { + return ETIME; + } return epit_set_timeout_ticks(epit, counterValue, periodic); }
diff --git a/libplatsupport/src/mach/imx/ltimer.c b/libplatsupport/src/mach/imx/ltimer.c index 5d672a7..588be1b 100644 --- a/libplatsupport/src/mach/imx/ltimer.c +++ b/libplatsupport/src/mach/imx/ltimer.c
@@ -46,6 +46,9 @@ if (type == TIMEOUT_ABSOLUTE) { uint64_t current_time = imx_get_time(&imx_ltimer->timers); + if (ns < current_time) { + return ETIME; + } ns -= current_time; }