drivers/timers/arch_alarm.c: Remove ndelay_accurate

Using ONESHOT_CURRENT retrieves the tick number multiplied by tick time; thus
it doesn't give the accurate monotonic time - it is quantized by
the tick time. This cannot be used as a ndelay timer, it would always loop
at least to the end of the ongoing tick.

Revert the up_udelay to use the original "coarse" looping. The "accurate" udelay,
if such is needed, should either be done under arch specific code, or there should be
a function for getting the accurate time that is available for all the platforms.

Signed-off-by: Jukka Laitinen <jukkax@ssrc.tii.ae>
This commit is contained in:
Jukka Laitinen
2024-10-22 14:57:15 +03:00
committed by Xiang Xiao
parent 877f42cde5
commit 1a267dc62d
+1 -24
View File
@@ -50,22 +50,6 @@ static clock_t g_current_tick;
* Private Functions
****************************************************************************/
static void ndelay_accurate(unsigned long nanoseconds)
{
struct timespec now;
struct timespec end;
struct timespec delta;
ONESHOT_CURRENT(g_oneshot_lower, &now);
clock_nsec2time(&delta, nanoseconds);
clock_timespec_add(&now, &delta, &end);
while (clock_timespec_compare(&now, &end) < 0)
{
ONESHOT_CURRENT(g_oneshot_lower, &now);
}
}
static void udelay_coarse(useconds_t microseconds)
{
volatile int i;
@@ -442,12 +426,5 @@ void weak_function up_udelay(useconds_t microseconds)
void weak_function up_ndelay(unsigned long nanoseconds)
{
if (g_oneshot_lower != NULL)
{
ndelay_accurate(nanoseconds);
}
else /* Oneshot timer hasn't been initialized yet */
{
udelay_coarse((nanoseconds + NSEC_PER_USEC - 1) / NSEC_PER_USEC);
}
udelay_coarse((nanoseconds + NSEC_PER_USEC - 1) / NSEC_PER_USEC);
}