Port-arm archive

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index][Old Index]

Allwinner A64 non-monotonic clock



Hi,

this is nothing new[0], but i tested it to be present here aswell,
while trying to decide whether i should go for pinebook, or not.

workaround for this should land in linux-next today, if not already,
just in case someone here does care.

-Artturi

[0] https://marc.info/?l=openbsd-bugs&m=152671143921366&w=2

ps. you can use this to verify it is indeed broken atm. as is,
and on my pine64 board this does take less than 10mins to trigger.

#include <stdio.h>
#include <stdlib.h>
#include <time.h>

void
ts_abort(struct timespec *ts0, struct timespec *ts1)
{
	printf("ts0=(%lu,%lu)\nts1=(%lu,%lu)\n",
	    ts0->tv_sec, ts0->tv_nsec,
	    ts1->tv_sec, ts1->tv_nsec);
	abort();
}

int
main(int argc, char *argv[])
{
	struct timespec ts0, ts1;

	clock_gettime(CLOCK_MONOTONIC, &ts0);
	for(;;) {
		clock_gettime(CLOCK_MONOTONIC, &ts1);

		if ((ts0.tv_sec < ts1.tv_sec) ||
		    ((ts0.tv_sec == ts1.tv_sec) &&
		     (ts0.tv_nsec < ts1.tv_nsec))) {
			ts0.tv_sec  = ts1.tv_sec;
			ts0.tv_nsec = ts1.tv_nsec;
		} else
			ts_abort(&ts0, &ts1);
	}
}



Home | Main Index | Thread Index | Old Index