linux-kernel.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
From: Alexander Holler <holler@ahsoftware.de>
To: linux-kernel@vger.kernel.org
Cc: Andrew Morton <akpm@linux-foundation.org>,
	John Stultz <john.stultz@linaro.org>,
	Thomas Gleixner <tglx@linutronix.de>,
	Alessandro Zummo <a.zummo@towertech.it>,
	rtc-linux@googlegroups.com
Subject: [PATCH 0/3] RFC: timekeeping: rtc: change hctosys mechanism
Date: Wed,  5 Jun 2013 19:15:37 +0200	[thread overview]
Message-ID: <1370452540-3319-1-git-send-email-holler@ahsoftware.de> (raw)
In-Reply-To: <51ADEE76.7090504@ahsoftware.de>

Hello,

because it wasn't that much work, I've already rewritten the hctosys
mechanism without discussing the changes further before.

So the following patches are RFC (and incomplete but imho perfectly,
usable) see below under missing) and I hope they will find friends and at
least one reviewer which doesn't had a bad day.


To describe the changes, I first quote what I've added to
Documentation/kernel-parameters.txt:

	hctosys=	[KNL] Specifies the driver (RTC) name which sets the
			time at	boot, if and only if userspace hasn't set the
			time before the driver will be loaded. If hctosys will
			not be specified, the first available hardware clock
			with a valid time will be used.
			Use a non-existent name (e.g. hctosys=none) if you want
			to avoid that a hardware clock will set the time.
			Currently there exist a special name "persistent" for
			the persistent clock found on some systems (e.g. the
			CMOS clock on x86 platforms which might be handled
			by the driver named rtc_cmos too).

What the patches do change:

- Default functionality: hopefully nothing changes.
  The only user visible change is that /proc/dev/rtc doesn't appear on
  systems on which a "persistent" clock still is used. But I think this
  is logically more correct, than what currently happens:
  /proc/dev/rtc outputs data from an RTC which doesn't have to be what
  is really used (persistent clock).
  Therefor /proc/dev/rtc now only appears, if a RTC-driver is used for
  hctosys and not if a "persistent" clock is used. Unfortunately the later
  is still true on most systems (at least for x86*).

- CONFIG_RTC_HCTOSYS is gone.
  On systems with a "persistent" clock, CONFIG_RTC_HCTOSYS was meaningless,
  because those systems always used the "persistent" clock and so already
  ignored CONFIG_RTC_HCTOSYS. Now this functionality is always on, if a
  hardware clock ("persistent" clock or RTC-driver) is used for hctosys.

- CONFIG_RTC_HCTOSYS_DEVICE is gone.
  This config option never really specified which RTC is used, it only
  specified which RTC is used in kind of the order of their appearance
  to the system. With the new kernel-parameter hctosys= it is now at least
  possible to specify the type of the used RTC. Of course, if more RTCs of
  the same type (same driver) are available, the first of them will be used.

- The hctosys functionality works even when userspace alreads has started.
  Without these changes, hctosys was invoked either at initialization of
  the timekeeping system (for "persistent" clock) or at late_init, both
  happens before userspace is started.
  To avoid problems with that change there is now an additional rule:
  Userspace comes first. If the userspace sets the system clock before
  any hardware clock was available, the hardware clock will not change
  the system clock.

The last point above is also the reason why I did those changes at all
(to support USB RTCs).


What's missing:

I don't know much about those "persistent" clocks and I haven't had a
deep look at them. That's especially true for the suspend/resume
mechanism used by them. The mechanism I want to use is the following:
The RTC subsystem now maintains the ID of the RTC device which was used
for hctosys (in rtc_hctosys_dev_id) and therefor specifies the device
which should be used to adjust the time after resume. Additionaly the
(new) flag systime_was_set will be set to false at suspend and on resume
this flag will be set to true if either the clock will be adjusted by
the device used for hctosys or by userspace (through do_settimeofday()).

That all should already work as expected for RTCs, what's missing for
"persistent" clocks is that the flag systime_was_set is set to false on
suspend and set to true on resume. Currently it just stays at true
(which is set through hctosys if a "persistent" clock is found.
But because "persistent" clocks don't go away (as it is possible with
RTCs by removing the driver or the RTC itself), nor do "persistent"
clocks might have two instances, this shouldn't be a problem at all.


And last but not least, I have to add a disclaimer:

This changes aren't company driven. That means until now I was the only
person who has seen, reviewed and tested them and I spend only a limited
amount of (my spare) time for that. I did (quick) tests with x86 and ARM
systems, with and without RTCs, with and without "persistent" clocks.
I also tested suspend/resume on x86. But in any case, don't expect I
didn't make failures. I did those changes in my "private" mode and not in
my "professional" mode, which makes a difference (at least in the amount
of time I spend for review and testing). But don't be scared, even my
"private" mode might spend more time for QA than many companies (are able
and willing to) do. ;)


Regards,

Alexander Holler

PS: Parts of the above documentation might be added to one of the following
patches to document them better in git too. I've written the above
documentation after I've done the patches and will wait for feedback before
I change them again. I've already done more than I initially wanted to do.

PPS: The new hctosys mechanism provides an additional feature some people
might like: HA for RTCs. If a system has two hardware clocks and one of
them will fail such that it provides an invalid time (in regard to
rtc_valid_tm()), the second one will be used.


  reply	other threads:[~2013-06-05 17:16 UTC|newest]

Thread overview: 77+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2013-04-19 15:14 [PATCH 0/3] rtc: rtc-hid-sensor-time Alexander Holler
2013-04-19 15:14 ` [PATCH 1/3 RESEND] rtc: rtc-hid-sensor-time: allow full years (16bit) in HID reports Alexander Holler
2013-04-19 15:14 ` [PATCH 2/3] rtc: rtc-hid-sensor-time: allow 16 and 32 bit values for all attributes Alexander Holler
2013-04-19 15:14 ` [PATCH 3/3] rtc: rtc-hid-sensor-time; add option hctosys to set time at boot Alexander Holler
2013-04-22 23:38   ` Andrew Morton
2013-04-23  8:51     ` Alexander Holler
2013-04-23 10:08       ` Alexander Holler
2013-04-23 10:13         ` Alexander Holler
2013-04-23 10:17           ` Alexander Holler
2013-04-23 15:47             ` Alexander Holler
2013-04-24 21:14               ` Andrew Morton
2013-04-25  6:55                 ` Alexander Holler
2013-05-05 11:21             ` [PATCH 0/4] rtc: rtc-hid-sensor-time: some changes Alexander Holler
2013-05-05 11:21               ` [PATCH 1/4] rtc: rtc-hid-sensor-time: allow full years (16bit) in HID reports Alexander Holler
2013-05-05 11:21               ` [PATCH 2/4] rtc: rtc-hid-sensor-time: allow 16 and 32 bit values for all attributes Alexander Holler
2013-05-05 11:21               ` [PATCH 3/4] rtc: rtc-hid-sensor-time: add option hctosys to set time at boot Alexander Holler
2013-05-21 21:42                 ` Andrew Morton
2013-05-21 22:02                 ` John Stultz
2013-05-21 23:15                   ` Alexander Holler
2013-05-28 19:37                     ` John Stultz
2013-05-29  4:42                       ` Alexander Holler
2013-06-04 13:41                         ` Alexander Holler
2013-06-05 17:15                           ` Alexander Holler [this message]
2013-06-05 17:15                             ` [PATCH 1/3] RFC: timekeeping: introduce flag systime_was_set Alexander Holler
2013-06-05 17:15                             ` [PATCH 2/3] RFC: timekeeping: rtc: Introduce new kernel parameter hctosys Alexander Holler
2013-06-05 17:15                             ` [PATCH 3/3] RFC: timekeeping: rtc: remove CONFIG_RTC_HCTOSYS and RTC_HCTOSYS_DEVICE Alexander Holler
2013-06-06 10:51                             ` [PATCH 0/3 v2] RFC: timekeeping: rtc: change hctosys mechanism Alexander Holler
2013-06-06 10:51                               ` [PATCH 1/3 RESEND] RFC: timekeeping: introduce flag systime_was_set Alexander Holler
2013-06-06 10:51                               ` [PATCH 2/3 v2] RFC: timekeeping: rtc: Introduce new kernel parameter hctosys Alexander Holler
2013-06-13 19:39                                 ` Alexander Holler
2013-06-14 16:52                                   ` [PATCH 0/9 v3] RFC: timekeeping: rtc: change hctosys mechanism Alexander Holler
2013-06-14 16:52                                     ` [PATCH 1/9 RESEND] rtc: rtc-hid-sensor-time: allow full years (16bit) in HID reports Alexander Holler
2013-06-14 16:52                                     ` [PATCH 2/9 RESEND] rtc: rtc-hid-sensor-time: allow 16 and 32 bit values for all attributes Alexander Holler
2013-06-14 16:52                                     ` [PATCH 3/9] rtc: rtc-hid-sensor-time: delay registering as rtc into a work Alexander Holler
2013-06-20 10:39                                       ` [PATCH 3/9 v2] " Alexander Holler
2013-06-26 19:55                                         ` Andrew Morton
2013-06-26 21:34                                           ` [rtc-linux] " Alexander Holler
2013-06-26 22:07                                             ` Greg KH
2013-06-26 23:51                                               ` Alexander Holler
2013-07-06  8:55                                                 ` Alexander Holler
2013-07-06 18:21                                                   ` Jiri Kosina
2013-07-07  7:35                                                     ` Alexander Holler
2013-07-08  9:12                                                       ` [PATCH 0/2] rtc: rtc-hid-sensor-time: enable HID input processing early Alexander Holler
2013-07-08  9:12                                                         ` [PATCH 1/2] rtc: rtc-hid-sensor-time: improve error handling when rtc register fails Alexander Holler
2013-07-08  9:12                                                         ` [PATCH 2/2] rtc: rtc-hid-sensor-time: enable HID input processing early Alexander Holler
2013-06-28  1:29                                             ` [rtc-linux] Re: [PATCH 3/9 v2] rtc: rtc-hid-sensor-time: delay registering as rtc into a work Alexander Holler
2013-06-14 16:52                                     ` [PATCH 4/9 RESEND] RFC: timekeeping: introduce flag systime_was_set Alexander Holler
2013-06-14 17:41                                       ` John Stultz
2013-06-14 18:05                                         ` [rtc-linux] " Alexander Holler
2013-06-14 18:28                                           ` John Stultz
2013-06-15  6:01                                             ` Alexander Holler
2013-06-17 18:10                                               ` John Stultz
2013-06-20 10:15                                                 ` Alexander Holler
2013-06-20 17:27                                                   ` John Stultz
2013-06-20 18:45                                                     ` Alexander Holler
2013-06-20 19:28                                                       ` John Stultz
2013-06-20 23:10                                                         ` Alexander Holler
2013-06-14 16:52                                     ` [PATCH 5/9 v3] RFC: timekeeping: rtc: Introduce new kernel parameter hctosys Alexander Holler
2013-06-14 19:24                                       ` John Stultz
2013-06-14 16:52                                     ` [PATCH 6/9 v3] RFC: timekeeping: rtc: remove CONFIG_RTC_HCTOSYS and RTC_HCTOSYS_DEVICE Alexander Holler
2013-06-14 19:11                                       ` John Stultz
2013-06-22  8:00                                         ` Alexander Holler
2013-06-14 16:52                                     ` [PATCH 7/9] RFC: rtc: implement rtc_read_timeval() Alexander Holler
2013-06-14 17:23                                       ` John Stultz
2013-06-14 17:43                                         ` Alexander Holler
2013-06-14 19:18                                           ` John Stultz
2013-06-14 17:28                                       ` John Stultz
2013-06-14 16:52                                     ` [PATCH 8/9] RFC: rtc: hctosys: support rtc_read_timeval() for high precision clocks Alexander Holler
2013-06-14 19:20                                       ` John Stultz
2013-06-14 16:52                                     ` [PATCH 9/9] RFC: rtc: rtc-hid-sensor-time: add support for rtc_read_timeval() Alexander Holler
2013-06-14 17:27                                     ` [PATCH 0/9 v3] RFC: timekeeping: rtc: change hctosys mechanism John Stultz
2013-06-06 10:51                               ` [PATCH 3/3 v2] RFC: timekeeping: rtc: remove CONFIG_RTC_HCTOSYS and RTC_HCTOSYS_DEVICE Alexander Holler
2013-06-04  9:38                 ` [PATCH] rtc: rtc-hid-sensor-time: fix possible bug on driver_remove Alexander Holler
2013-06-08  8:56                   ` Alexander Holler
2013-05-05 11:21               ` [PATCH 4/4] rtc: rtc-hid-sensor-time: add support for milliseconds Alexander Holler
2013-04-20 23:46 ` [PATCH 0/3] rtc: rtc-hid-sensor-time Jiri Kosina
2013-04-21  6:38   ` Alexander Holler

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=1370452540-3319-1-git-send-email-holler@ahsoftware.de \
    --to=holler@ahsoftware.de \
    --cc=a.zummo@towertech.it \
    --cc=akpm@linux-foundation.org \
    --cc=john.stultz@linaro.org \
    --cc=linux-kernel@vger.kernel.org \
    --cc=rtc-linux@googlegroups.com \
    --cc=tglx@linutronix.de \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).