Re: [systemd-devel] Support machines with multiple RTCs?

2012-01-20 Thread Kay Sievers
On Wed, Nov 23, 2011 at 04:04, Martin Langhoff
martin.langh...@gmail.com wrote:
 On Nov 22, 2011 5:58 PM, Kay Sievers kay.siev...@vrfy.org wrote:

 On Tue, Nov 22, 2011 at 23:42, Martin Langhoff
 martin.langh...@gmail.com wrote:
  On Tue, Nov 22, 2011 at 3:21 PM, Kay Sievers kay.siev...@vrfy.org
  wrote:
  Yeah, that's intentional. Udev on other platforms can't know which rtc
  should be the preferred one.
 
  Well, now you can: if it says hctosys == 1, it means that the kernel
  config told it to pick that one, and that it's sync'd the system time
  to it.

 You have rtc1 set in the kernel config for your box?

 Correct. And rtc0 is only good for rtcwake -- won't hold real clock time,
 because it isn't battery-backed.

 My box is the XO-1.75 platform, of which we expect a few million will be
 produced starting soon.

 Future kernels may bring them up in different order, but that's a different
 pile of pain.

  This link is mainly for backwards compat, because in earlier days it
  was a real kernel device.
 
  Well, the symlink has a very practical use! If you have several RTCs,
  you can use udev to symlink rtc to it, and it gets htclock to DTRT.
 
  On our XO-1.75, the real rtc is rtc1.
 
  Next, we got to get src/utils.c to prefer rtc if it finds it ;-)

 I guess udev should claim /dev/rtc for the rtc device that has hctosys ==
 1 set?

 Yep. It's a trivial udev rule, perhaps belongs to Fedora's initscripts?

Nah, 'initscripts' needs a radical diet, not more random stuff in it. :)

Todo lists are there to remember things. Seems that worked well in this case. :)

Here is the systemd fix:
  
http://cgit.freedesktop.org/systemd/systemd/commit/?id=51122dc9e36cdafe76a07d1ddf1a3a7e4726bb7b

and the udev fix:
  
http://git.kernel.org/?p=linux/hotplug/udev.git;a=commitdiff;h=6102188c93e55eba1b5dad54d27ea1ac2e8c7e73

Both use the 'system rtc' now.

Kay
___
systemd-devel mailing list
systemd-devel@lists.freedesktop.org
http://lists.freedesktop.org/mailman/listinfo/systemd-devel


Re: [systemd-devel] Support machines with multiple RTCs?

2011-11-22 Thread Martin Langhoff
On Tue, Nov 22, 2011 at 12:28 PM, Kay Sievers kay.siev...@vrfy.org wrote:
  #1 -- check for the hctosys property. If _any_ rtc present in the
 system has sysfs attribute hctosys == 1, it means that the kernel took
 care of it all, and userland doesn't need to call hwclock, at all.

 Systemd requires that the time was set by the kernel. It does not
 support any other config natively, that would be done by plugging-in
 hwclock like it was on non-systemd systems.

Cool. That's very appropriate given a minimally modern linux kernel...

 The kernel's hctosys is hard coded in the kernel config, right?

It is set by the kernel to 1, only when CONFIG_RTC_HCTOSYS_DEVICE is
set, and when the device is the device named in this config var.

If you don't have CONFIG_RTC_HCTOSYS_DEVICE, then the kernel won't
sync system time during boot, and your rtc device will have
hctosys==0.

So if systemd counts on the kernel to set system time during boot,
then you already depend on CONFIG_RTC_HCTOSYS_DEVICE, and you should
be all set :-)

  #2 -- is customary to prefer /dev/rtc if present -- so that we can
 symlink to the right rtc from udev. src/util.c seems to hardcode rtc0.

 Udev does that by default today:
  SUBSYSTEM==rtc, DRIVERS==rtc_cmos, SYMLINK+=rtc

Yes, but that means that it expects other programs to first try to
open /dev/rtc . So to complete the picture, I think src/util.c should
try /dev/rtc first :-)

 If possible, we could invent a /dev/rtc-systemtime symlink and use
 that, if its not needed during bootup before udev is started and has
 created the symlink?

that be the same as /dev/rtc I think... so no need for it that I can see.



m
-- 
 martin.langh...@gmail.com
 mar...@laptop.org -- Software Architect - OLPC
 - ask interesting questions
 - don't get distracted with shiny stuff  - working code first
 - http://wiki.laptop.org/go/User:Martinlanghoff
___
systemd-devel mailing list
systemd-devel@lists.freedesktop.org
http://lists.freedesktop.org/mailman/listinfo/systemd-devel


Re: [systemd-devel] Support machines with multiple RTCs?

2011-11-22 Thread Koen Kooi

Op 22 nov. 2011, om 18:28 heeft Kay Sievers het volgende geschreven:

 On Tue, Nov 22, 2011 at 18:10, Martin Langhoff
 martin.langh...@gmail.com wrote:
 I have just been perusing the systemd code, and wondering whether it
 supports systems that have two RTCs (where usually only one of them is
 the battery-backed clock, the other isn't battery backed but can wake
 the system up).
 
 Background: OLPC's new laptop, XO-1.75, is an ARM SoC that has exactly
 that configuration. Linux kernels from 2.6.32 (and maybe earlier) can
 handle multiple RTCs, and let you configure which one to use to sync
 the clock in early boot (so userland doesn't have to).
 
 I have just reported a related bug in Fedora's initscripts (
 https://bugzilla.redhat.com/show_bug.cgi?id=756089 ), and a quick
 check of systemd sources hints at similar trouble here...
 
 Two key things seem to be missing:
 
  #1 -- check for the hctosys property. If _any_ rtc present in the
 system has sysfs attribute hctosys == 1, it means that the kernel took
 care of it all, and userland doesn't need to call hwclock, at all.
 
 Systemd requires that the time was set by the kernel. It does not
 support any other config natively, that would be done by plugging-in
 hwclock like it was on non-systemd systems.
 
 The kernel's hctosys is hard coded in the kernel config, right?
 
  #2 -- is customary to prefer /dev/rtc if present -- so that we can
 symlink to the right rtc from udev. src/util.c seems to hardcode rtc0.
 
 Udev does that by default today:
  SUBSYSTEM==rtc, DRIVERS==rtc_cmos, SYMLINK+=rtc

That looks to be specific to x86 RTCs, in my case when using the RTC of the 
PMIC on omap3/4 I get:

  looking at device 
'/devices/platform/omap/omap_i2c.1/i2c-1/1-004b/twl_rtc/rtc/rtc0':
KERNEL==rtc0
SUBSYSTEM==rtc
DRIVER==
ATTR{name}==twl_rtc
ATTR{date}==2011-11-22
ATTR{time}==20:17:03
ATTR{since_epoch}==1321993023
ATTR{max_user_freq}==64
ATTR{hctosys}==1
ATTR{wakealarm}==

regards,

Koen

signature.asc
Description: Message signed with OpenPGP using GPGMail
___
systemd-devel mailing list
systemd-devel@lists.freedesktop.org
http://lists.freedesktop.org/mailman/listinfo/systemd-devel


Re: [systemd-devel] Support machines with multiple RTCs?

2011-11-22 Thread Kay Sievers
On Tue, Nov 22, 2011 at 21:18, Koen Kooi k...@dominion.thruhere.net wrote:
 Op 22 nov. 2011, om 18:28 heeft Kay Sievers het volgende geschreven:
 On Tue, Nov 22, 2011 at 18:10, Martin Langhoff

  #2 -- is customary to prefer /dev/rtc if present -- so that we can
 symlink to the right rtc from udev. src/util.c seems to hardcode rtc0.

 Udev does that by default today:
  SUBSYSTEM==rtc, DRIVERS==rtc_cmos, SYMLINK+=rtc

 That looks to be specific to x86 RTCs, in my case when using the RTC of the 
 PMIC
 on omap3/4 I get:

  looking at device 
 '/devices/platform/omap/omap_i2c.1/i2c-1/1-004b/twl_rtc/rtc/rtc0':
    KERNEL==rtc0
    SUBSYSTEM==rtc
    DRIVER==

Yeah, that's intentional. Udev on other platforms can't know which rtc
should be the preferred one.

This link is mainly for backwards compat, because in earlier days it
was a real kernel device.

Kay
___
systemd-devel mailing list
systemd-devel@lists.freedesktop.org
http://lists.freedesktop.org/mailman/listinfo/systemd-devel


Re: [systemd-devel] Support machines with multiple RTCs?

2011-11-22 Thread Martin Langhoff
On Tue, Nov 22, 2011 at 3:21 PM, Kay Sievers kay.siev...@vrfy.org wrote:
 Yeah, that's intentional. Udev on other platforms can't know which rtc
 should be the preferred one.

Well, now you can: if it says hctosys == 1, it means that the kernel
config told it to pick that one, and that it's sync'd the system time
to it.

 This link is mainly for backwards compat, because in earlier days it
 was a real kernel device.

Well, the symlink has a very practical use! If you have several RTCs,
you can use udev to symlink rtc to it, and it gets htclock to DTRT.

On our XO-1.75, the real rtc is rtc1.

Next, we got to get src/utils.c to prefer rtc if it finds it ;-)




m
-- 
 martin.langh...@gmail.com
 mar...@laptop.org -- Software Architect - OLPC
 - ask interesting questions
 - don't get distracted with shiny stuff  - working code first
 - http://wiki.laptop.org/go/User:Martinlanghoff
___
systemd-devel mailing list
systemd-devel@lists.freedesktop.org
http://lists.freedesktop.org/mailman/listinfo/systemd-devel


Re: [systemd-devel] Support machines with multiple RTCs?

2011-11-22 Thread Kay Sievers
On Tue, Nov 22, 2011 at 23:42, Martin Langhoff
martin.langh...@gmail.com wrote:
 On Tue, Nov 22, 2011 at 3:21 PM, Kay Sievers kay.siev...@vrfy.org wrote:
 Yeah, that's intentional. Udev on other platforms can't know which rtc
 should be the preferred one.

 Well, now you can: if it says hctosys == 1, it means that the kernel
 config told it to pick that one, and that it's sync'd the system time
 to it.

You have rtc1 set in the kernel config for your box?

 This link is mainly for backwards compat, because in earlier days it
 was a real kernel device.

 Well, the symlink has a very practical use! If you have several RTCs,
 you can use udev to symlink rtc to it, and it gets htclock to DTRT.

 On our XO-1.75, the real rtc is rtc1.

 Next, we got to get src/utils.c to prefer rtc if it finds it ;-)

I guess udev should claim /dev/rtc for the rtc device that has hctosys == 1 set?

Kay
___
systemd-devel mailing list
systemd-devel@lists.freedesktop.org
http://lists.freedesktop.org/mailman/listinfo/systemd-devel