Skip to content

Commit c899593

Browse files
fthaingeertu
authored andcommitted
m68k: mac: Improve clocksource driver commentary
qemu-system-m68k -M q800 has an old bug that causes the kernel to occasionally complain about a soft lockup: watchdog: BUG: soft lockup - CPU#0 stuck for 5107s! There isn't any actual lockup. The via1 clocksource produced a large jump in jiffies, causing the watchdog to detect a stale timestamp. The 32-bit clocksource counter runs at 783360 Hz and its period is about 5482 seconds. Applying the "nanosecond" approximation used in get_timestamp() in kernel/watchdog.c then yields the duration reported in the log message above (always 5107 or 5108 in my tests): 0xffffffff / VIA_CLOCK_FREQ * 10**9 / 2**30 = 5106.209 seconds It is notoriously difficult to correctly emulate a MOS6522 VIA chip. So it seems wise to document the VIA clocksource driver better, especially those hardware behaviours which the kernel relies upon. Cc: Joshua Thompson <[email protected]> Signed-off-by: Finn Thain <[email protected]> Reviewed-by: Geert Uytterhoeven <[email protected]> Link: https://lore.kernel.org/f7b4c02a1c8ed74ccceb5535d7e1e202deada8ce.1750739568.git.fthain@linux-m68k.org Signed-off-by: Geert Uytterhoeven <[email protected]>
1 parent c4958c1 commit c899593

File tree

1 file changed

+16
-0
lines changed

1 file changed

+16
-0
lines changed

arch/m68k/mac/via.c

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -621,6 +621,22 @@ static u64 mac_read_clk(struct clocksource *cs)
621621
* These problems are avoided by ignoring the low byte. Clock accuracy
622622
* is 256 times worse (error can reach 0.327 ms) but CPU overhead is
623623
* reduced by avoiding slow VIA register accesses.
624+
*
625+
* The VIA timer counter observably decrements to 0xFFFF before the
626+
* counter reload interrupt gets raised. That complicates things a bit.
627+
*
628+
* State | vT1CH | VIA_TIMER_1_INT | inference drawn
629+
* ------+------------+-----------------+-----------------------------
630+
* i | FE thru 00 | false | counter is decrementing
631+
* ii | FF | false | counter wrapped
632+
* iii | FF | true | wrapped, interrupt raised
633+
* iv | FF | false | wrapped, interrupt handled
634+
* v | FE thru 00 | true | wrapped, interrupt unhandled
635+
*
636+
* State iv is never observed because handling the interrupt involves
637+
* a 6522 register access and every access consumes a "phi 2" clock
638+
* cycle. So 0xFF implies either state ii or state iii, depending on
639+
* the value of the VIA_TIMER_1_INT bit.
624640
*/
625641

626642
local_irq_save(flags);

0 commit comments

Comments
 (0)