Skip to contentSkip to conversation

time: add clocksource driver for Geode SC-1100 Hi-Res Timer

RFC PATCH In review Jim Cromie 1 participant 2 messages Apr 24, 2006

Subsystems (2)
lore
Share & tools
lore

Jim Cromie

author maintainer
#0 lore raw

RFC PATCH 1/1 time: add clocksource driver for Geode SC-1100 Hi-Res Timer

Heres a patch (on 17rc1-mm3 + John Stultz's 4/21 fn-renames) that adds a new GTOD-clocksource driver for the hires timer in the Geode SC-1100. Ive been running it for most of the last 7 days now, and it seems to work well.

GTOD is detecting the SC-1100's bad TSC, de-rating it, and selecting the PIT (w/o patch) or scx200_hrt (with patch, built-in). In a modular build, when I modprobe scx200_hrt, GTOD selects it instead of the PIT. If I put 'idle=poll' on boot-line, the TSC passes the stability test, and is preferred. This all works as hoped.

soekris:~# cat /sys/devices/system/clocksource/clocksource0/*
scx200_hrt jiffies tsc pit
scx200_hrt

Its also keeping NTP lock..

soekris:~# uptime; ntpq -p
12:07:57 up  3:42,  1 user,  load average: 0.00, 0.00, 0.00
    remote           refid      st t when poll reach   delay   offset  jitter
==============================================================================
+harpo           216.82.75.146    3 u  336 1024  377    1.100    7.972   0.742
*ntp1.us.grundcl 204.123.2.72     2 u  568 1024  377   97.151   -1.173   5.991
LOCAL(0)        LOCAL(0)        13 l   63   64  377    0.000    0.000   0.004

I sent this patch to soekris-tech ML on 4/19, asking for testers, but theyre mostly *BSD over there, so Im unsure how much action it'll see (none yet). Id like to see this patch join the other GTOD stuff in -mm-next (for some value of next), to get whatever exposure -mm brings on Geode based systems.

Other tested bits, random notes

- driver also works at 27 mhz

Tested builtin, w scx200_hrt.mhz27=1 on boot-line. Should I make this default, and/or drop the modparam ?

[   31.186358] enabling scx200 high-res timer (27 MHz)

- free-running clock seems to work.

I shut down ntpd immediately after boot, ran ntpdate -q later.

soekris:~# uptime; ntpdate -q harpo
18:54:56 up  5:29,  2 users,  load average: 0.00, 0.00, 0.00
server 192.168.42.1, stratum 3, offset -5.863304, delay 0.02634

So the time offset is growing a little bit. Im unsure if this is the HRT itself, a TOD adjustment/slew thats set up by the initial call to ntpdate, or something else entirely.

- no module-unloading

None of the current GTOD clocksources have a module_exit() routine. I had one for a while, but when I used it, I got oopses and reboots. John Stultz confirmed its not supported currently, and I dont see the need to do so; unused clocksources only waste a tiny bit of memory.

OTOH, perhaps the basic clocksources could be optionally configured out for EMBEDDED configs. And it would be nice if GTOD could remove unused clocksource drivers once the best clocksource is selected.

Heres what I see as my TODOs, TBCs

- fix the Kconfig entries

SCx200HR_TIMER is defined in arch/i386/Kconfig, at the top of Processor type and features. This seemed un-good, but when I tried moving it to a new clocksources/Kconfig, I got this error: Any advice?

[jimc@harpo linux-2.6.17-rc1-mm3-hrt]$ make
scripts/kconfig/conf -s arch/i386/Kconfig
arch/i386/Kconfig:1051:warning: 'select' used by config symbol 'SCx200' refer to undefined symbol 'SCx200HR_TIMER'

- module on builtin (probly not)

scx200_hrt is selected automatically with scx200, and follows its [nmy] setting. This is good, but maybe the setup should allow module on builtin. I dont have a compelling reason tho; its not like you'd want a bad TSC often.

- consider clock tuning (probly not)

The HRT runs off its own crystal (simpler clock-gen ckts?). I could add mod-param to adjust freq to acct for crystal variations, but it seems wizer not to, thats what NTP is for. If you see a value to this, pls also suggest a limit on the correction, forex 100 PPM or +/- 100 counts (easier to code, and user should know how experiment with it).

- consider converting to platform_device

the timer is on an in-the-chip ISA bus, so maybe platform_driver is the right way to do this. Im new at this, so pedagogical feedback is especially welcome (off-list if you prefer)

Lastly, Id like to thank John Stultz for his off-list help & orientation, and Ted Phelps, whose 2.6.12-rc6 patch clarified the problem, and informed the solution.

thanks
Jim Cromie

---

Add new GTOD-clocksource driver for the High Resolution Timer on the Geode SC-1100 and family. Driver is automatically selected per scx200 choice. GTOD chooses scx200_hrt over the unstable and de-rated TSC.

[jimc@harpo hrt-stuff]$ diffstat time-clksrc-scx200_hrt.patch

arch/i386/Kconfig                |   12 ++++
drivers/clocksource/Makefile     |    5 +
drivers/clocksource/scx200_hrt.c |  110 +++++++++++++++++++++++++++++++++++++++

---

arch/i386/Kconfig +0 -0
diff -ruNp -X dontdiff -X exclude-diffs mm3-clk-renames/arch/i386/Kconfig hrt2/arch/i386/Kconfig
@@ -57,6 +57,17 @@ source "init/Kconfig"
 

menu "Processor type and features"

+config SCx200HR_TIMER
+ tristate "NatSemi SCx200 27MHz High-Resolution Timer Support"
+ help

+	  Some of the AMD (formerly National Semiconductor) Geode
+	  processors, notably the SC1100, suffer from a buggy time
+	  stamp counter which causes them to lose time when the
+	  processor is sleeping.  Enable this option to use the
+	  on-board 27Mz high-resolution timer to keep time instead.

+ depends on (SCx200)
+ default n
+
config SMP

	bool "Symmetric multi-processing support"
	---help---

@@ -1048,6 +1059,7 @@ source "drivers/mca/Kconfig"
config SCx200
tristate "NatSemi SCx200 support"
depends on !X86_VOYAGER
+ select SCx200HR_TIMER
help
This provides basic support for the National Semiconductor SCx200 processor. Right now this is just a driver for the GPIO pins.

drivers/clocksource/Makefile +3 -2
diff -ruNp -X dontdiff -X exclude-diffs mm3-clk-renames/drivers/clocksource/Makefile hrt2/drivers/clocksource/Makefile
@@ -1,2 +1,3 @@
-obj-$(CONFIG_X86_CYCLONE_TIMER) += cyclone.o
-obj-$(CONFIG_X86_PM_TIMER) += acpi_pm.o
+obj-$(CONFIG_X86_CYCLONE_TIMER)	+= cyclone.o
+obj-$(CONFIG_X86_PM_TIMER)	+= acpi_pm.o
+obj-$(CONFIG_SCx200HR_TIMER)	+= scx200_hrt.o
drivers/clocksource/scx200_hrt.c +110 -0

110 lines not on this page · raw message

author maintainer
#1 lore raw
Quoted 4 lines · Jim Cromie

Heres a patch (on 17rc1-mm3 + John Stultz's 4/21 fn-renames) that adds a new GTOD-clocksource driver for the hires timer in the Geode SC-1100. Ive been running it for most of the last 7 days now, and it seems to work well.

Ooof. Something is broken, causing kernel to 'lock'
No oops, just nothing.

$ while true; do sleep 30; uptime; done
..
14:25:23 up  1:09,  2 users,  load average: 0.12, 0.08, 0.01
14:25:53 up  1:09,  2 users,  load average: 0.07, 0.07, 0.01
14:26:23 up  1:10,  2 users,  load average: 0.04, 0.06, 0.01
14:26:53 up  1:10,  2 users,  load average: 0.02, 0.05, 0.00
14:27:24 up  1:11,  2 users,  load average: 0.07, 0.06, 0.00

then freeze.

Heres the last bit of the syslog:

Apr 24 13:18:24 truck ntpd[1730]: configure: keyword "By" unknown, line ignored
Apr 24 13:18:27 truck /usr/sbin/cron[1751]: (CRON) INFO (pidfile fd = 3)
Apr 24 13:18:27 truck /usr/sbin/cron[1752]: (CRON) STARTUP (fork ok)
Apr 24 13:18:28 truck /usr/sbin/cron[1752]: (CRON) INFO (Running @reboot jobs)
Apr 24 13:19:17 truck snmpd[1680]: cannot open /proc/net/snmp6 ...
Apr 24 13:21:41 truck ntpd[1730]: synchronized to LOCAL(0), stratum 13
Apr 24 13:21:41 truck ntpd[1730]: kernel time sync disabled 0041
Apr 24 13:22:44 truck ntpd[1730]: synchronized to 64.5.1.130, stratum 2
Apr 24 13:25:59 truck ntpd[1730]: kernel time sync enabled 0001
Apr 24 13:38:02 truck -- MARK --
Apr 24 13:58:02 truck -- MARK --
Apr 24 14:17:01 truck /USR/SBIN/CRON[2015]: (root) CMD (   run-parts --report /etc/cron.hourly)[jimc@harpo i2c-stuff]$

Im looking into it, startng with recent presentation tweaks :-/ Ill turn on whatever debug might be relevant, mutex debug included. This is on an NFSroot setup, not that I suspect it.

Im still interested in feedback,
thanks
Jim Cromie