Re: [RFC PATCH v2 07/14] m68k: atari: Convert to clocksource API
From: Linus Walleij
Date: Tue Nov 20 2018 - 03:10:53 EST
On Mon, Nov 19, 2018 at 2:22 AM Finn Thain <fthain@xxxxxxxxxxxxxxxxxxx> wrote:
> Add a platform clocksource by adapting the existing arch_gettimeoffset
> implementation.
>
> Normally the MFP timer C interrupt flag would be used to check for
> timer counter wrap-around. Unfortunately, that flag gets cleared by the
> MFP itself (due to automatic EOI mode). This means that
> mfp_timer_c_handler() and atari_read_clk() must race when accounting
> for counter wrap-around.
>
> That problem is avoided here by effectively stopping the clock when it
> might otherwise jump backwards. This harms clock accuracy; the result
> is not much better than the jiffies clocksource. Also, clock error is
> no longer uniformly distributed.
>
> Signed-off-by: Finn Thain <fthain@xxxxxxxxxxxxxxxxxxx>
> Acked-by: Linus Walleij <linus.walleij@xxxxxxxxxx>
> ---
> TODO: find a spare counter for the clocksource, rather than hanging
> it off the HZ timer.
Yes you already see the same as I see: this chip MK68901 has
no less than four timers. I bet the kernel is just using one of them,
out of habit.
By just setting another timer as free-running we get a classic
and clean Linux clocksource for the Atari.
This is however a very good start in untangling the mess
(as is the whole patch series).
As with the Amiga, this chip also has an RTC clock that should
go to the RTC subsystem, naturally.
Yours,
Linus Walleij