RTC subsystem
Hello,
I've posted a proposal for a new RTC subsystem
on lkml ( http://lkml.org/lkml/2005/12/20/220 ) .
I'd appreciate having feedback from anyone that could
be interested in this matter.
Thanks in advance.
Signature · 6 lines
Best regards, Alessandro Zummo, Tower Technologies - Turin, Italy http://www.towertech.it
Hi,
Quoted 2 lines · Alessandro Zummo
I've posted a proposal for a new RTC subsystem
on lkml ( http://lkml.org/lkml/2005/12/20/220 ) .
I agree that there is room for improvement. Do you have a specific structure in mind? Specifically,
- which functions do you believe to be generic,
- how should multiple RTCs be handled,
- are read-only (radio controlled) RTCs taken care of?
At present, I don't have time to help the cause, but I can provide hosting for a git tree if desired.
Simon
Quoted 5 lines · On Wed, 21 Dec 2005 13:18:25 +0100 Simon Richter <Simon.Richter at hogyros.de>…
Quoted 2 lines
I've posted a proposal for a new RTC subsystem
on lkml ( http://lkml.org/lkml/2005/12/20/220 ) .I agree that there is room for improvement. Do you have a specific structure in mind? Specifically,
Hi Simon,
the proposal actually had a fully-working patch attached :)
Quoted 2 lines
- which functions do you believe to be generic,
- how should multiple RTCs be handled,
In my code, the first rtc that register is bound to /proc/driver/rtc and /dev/rtc (if those interfaces are compiled in, as they are all selectable).
The other RTCs are available thru /sys/class/rtc/rtcX (again, if compiled in).
Quoted 1 line
- are read-only (radio controlled) RTCs taken care of?
You have full control of which functions you will provide to the upper layer. Obivously if you try to set the time on a read-only rtc, you will get an error.
Quoted 2 lines
At present, I don't have time to help the cause, but I can provide hosting for a git tree if desired.
Thanks, I'll consider it if the need arises.
Signature · 6 lines
Best regards, Alessandro Zummo, Tower Technologies - Turin, Italy http://www.towertech.it
Hello,
Quoted 1 line · Alessandro Zummo
the proposal actually had a fully-working patch attached :)
Ah, didn't see that, as I just skimmed over the web archive page you linked to, which has no link to the actual patch (or I'm too stupid to find it).
Quoted 3 lines
In my code, the first rtc that register is bound to
/proc/driver/rtcand/dev/rtc(if those interfaces are compiled in, as they are all selectable).
It would be good to have a way to change which clock is the "primary" one from userspace later (userspace because this is clearly site policy).
Quoted 3 lines
You have full control of which functions you will provide to the upper layer. Obivously if you try to set the time on a read-only rtc, you will get an error.
Sure. I was thinking of the question which error that should be.
Simon
Quoted 5 lines · On Wed, 21 Dec 2005 17:02:55 +0100 Simon Richter <[email protected]>…
Quoted 1 line
the proposal actually had a fully-working patch attached :)
Ah, didn't see that, as I just skimmed over the web archive page you linked to, which has no link to the actual patch (or I'm too stupid to find it).
right.. the link was to 0/6 of the patchset, which is actually only the introduction. real patch was in subsequent messages.
Quoted 6 lines
Quoted 3 lines
In my code, the first rtc that register is bound to
/proc/driver/rtcand/dev/rtc(if those interfaces are compiled in, as they are all selectable).It would be good to have a way to change which clock is the "primary" one from userspace later (userspace because this is clearly site policy).
If I'm not wrong, the RTC is usually queried at bootup and written to on shutdown. If NTP mode is active, it is also written every 11 minutes.
So my intention was to emulate that interface as a starting point. Then we can update the userspace utilities (hwclock) to let the user choose which clock he want to use.
I guess /proc/driver/rtc will be deprecated sooner or later. The /dev/rtc interface only supports one clock. It can either be extended to have /dev/rtcX or we can extend the sysfs one to allow clock updating.
NTP mode could then be adjusted to update one or more of the rtcs. Maybe each RTC could have an attribute (let's say /sys/class/rtc/rtcX/ntp) which tells the kernel whether to update it or not.
This way we will not have a primary clock anymore.
Quoted 5 lines
Quoted 3 lines
You have full control of which functions you will provide to the upper layer. Obivously if you try to set the time on a read-only rtc, you will get an error.
Sure. I was thinking of the question which error that should be.
-EPERM ? -EACCESS? :)
Signature · 6 lines
Best regards, Alessandro Zummo, Tower Technologies - Turin, Italy http://www.towertech.it
Hello,
Quoted 6 lines · Alessandro Zummo
Quoted 2 lines
It would be good to have a way to change which clock is the "primary" one from userspace later (userspace because this is clearly site policy).
If I'm not wrong, the RTC is usually queried at bootup and written to on shutdown. If NTP mode is active, it is also written every 11 minutes.
A good ntpd will adjust the speed rather than write to the clock; the ntpd shipped by most distributions can already handle multiple time sources.
I'm thinking of the case where a computer is not attached to a network but needs accurate tim; in this case I'd give it a battery powered RTC and a time signal receiver. As most time signals are low-bandwidth, they may not carry full time information in each tick so it may take several minutes to fully synchronize. In this case I'd like to use the battery backed up clock first and switch later on when synchronized.
Quoted 4 lines
I guess
/proc/driver/rtcwill be deprecated sooner or later. The/dev/rtcinterface only supports one clock. It can either be extended to have/dev/rtcXor we can extend the sysfs one to allow clock updating.
/dev is the way to go IMO. As far as I've understood sysfs, it carries meta information about devices and drivers only, the actual communication then happens through device nodes still.
Quoted 4 lines
NTP mode could then be adjusted to update one or more of the rtcs. Maybe each RTC could have an attribute (let's say
/sys/class/rtc/rtcX/ntp) which tells the kernel whether to update it or not.
That's entirely a userspace thing. What the userspace needs to know from the kernel is whether the clock is writable and whether its speed can be adjusted.
Quoted 1 line
-EPERM?-EACCESS? :)
-EIO or -ENOSYS would also be possible options.
Simon
Quoted 2 lines · On Thu, 22 Dec 2005 00:18:33 +0100 Simon Richter <[email protected]>…
A good ntpd will adjust the speed rather than write to the clock; the ntpd shipped by most distributions can already handle multiple time sources.
Yes, but there's the kernel who writes to the clock,
for example http://lxr.linux.no/source/arch/arm/kernel/time.c?a=arm#L103 .
Quoted 7 lines
Quoted 3 lines
later. The
/dev/rtcinterface only supports one clock. It can either be extended to have/dev/rtcXor we can extend the sysfs one to allow clock updating./dev is the way to go IMO. As far as I've understood sysfs, it carries meta information about devices and drivers only, the actual communication then happens through device nodes still.
Ok. We can use dynamic device numbers and go for the /dev interface.
Quoted 9 lines
Quoted 5 lines
NTP mode could then be adjusted to update one or more of the rtcs. Maybe each RTC could have an attribute (let's say
/sys/class/rtc/rtcX/ntp) which tells the kernel whether to update it or not.That's entirely a userspace thing. What the userspace needs to know from the kernel is whether the clock is writable and whether its speed can be adjusted.
agreed. there are are also some variables of interest in
http://lxr.linux.no/source/include/linux/timex.h?a=arm#L188
some of them may be usefully exported in sysfs.
Signature · 6 lines
Best regards, Alessandro Zummo, Tower Technologies - Turin, Italy http://www.towertech.it