From: Alexander Holler <holler@ahsoftware.de>
To: Andrew Morton <akpm@linux-foundation.org>
Cc: linux-kernel@vger.kernel.org, rtc-linux@googlegroups.com,
Alessandro Zummo <a.zummo@towertech.it>,
Lars-Peter Clausen <lars@metafoo.de>,
Jonathan Cameron <jic23@cam.ac.uk>, Jiri Kosina <jkosina@suse.cz>,
John Stultz <john.stultz@linaro.org>
Subject: Re: [PATCH 3/3] rtc: rtc-hid-sensor-time; add option hctosys to set time at boot
Date: Thu, 25 Apr 2013 08:55:35 +0200 [thread overview]
Message-ID: <5178D367.4050905@ahsoftware.de> (raw)
In-Reply-To: <20130424141459.df581d79e6e296f90eb1369c@linux-foundation.org>
Am 24.04.2013 23:14, schrieb Andrew Morton:
> On Tue, 23 Apr 2013 17:47:20 +0200 Alexander Holler <holler@ahsoftware.de> wrote:
>
>>>>> "time_was_set_once" and have choosen one day just in case something
>>>>> needs really long to boot (e.g. because of some lengthy fsck or whatever
>>>>> else).
>>>>>
>>>>> A solution to both problems might be to change the logic for hctosys
>>>>> completly to read the time when the first RTC device appears (or when
>>>>> the device mentioned in CONFIG_RTC_HCTOSYS_DEVICE appears). But that
>>>>> would require a change to hctosys or the RTC subsystem, which would
>>>>> involve more patches and discussion. As rtc-hid-sensor-time currently
>>>>> seems to be the only RTC with the above problems, I've gone the easy
>>>>> route and only modified this driver.
>>>>
>>>> Oh, damn. I've forgotten my example above with NTP. In that case setting
>>>> the time when the first RTC appears doesn't work.
>>>
>>> So a general solution might be to set the system time when the first RTC
>>> (or the one mentioned in CONFIG_RTC_HCTOSYS_DEVICE) appears AND nothing
>>> else did set the time before.
>>
>> To extend that idea a bit further, I think an option timewait (similiar
>> to rootwait) would be a nice to have.
>>
>> If just time wouldn't be that rare ... ;)
>
> Yes, some sort of notifier callout when the CONFIG_RTC_HCTOSYS_DEVICE
> device is registered seems appropriate. I didn't understand why that
> is problematic for NTP.
>
> Getting all the lifetime/reference stuff right will be tricky :( Can't
> shut down or unload a driver when it is on that notification list.
>
> And it assumes that the CONFIG_RTC_HCTOSYS_DEVICE driver is all ready
> to go when it registers itself. Hopefully that is true, but they
> should be reviewed.
>
> Adding the timewait thing sounds unpleasant - how to reliably tune the
> interval for all possible users of your distro? We should aim to make
> things synchronous, deterministic and
> stuff-happens-in-the-correct-order.
>
> It all sounds like a moderate amount of work, but it would be great
> to be able to fix this for all drivers, not just hid-sensor-time. That's
> assuming that other drivers have the same issue - perhaps they don't,
> but perhaps things can go wrong if the module loading order is wrong?
>
I've added John Stultz to cc as he seems to work on a similiar problem
(to not set the time twice on resume).
I'm not sure what you meant with the notifiers, but wouldn't be a
function which sets the time if nothing else did that before a solution?
I think about something like that (not real code):
static bool timeWasSet; // = 0
int setTimeIfNotSet(time, devicename)
{
if (timeWasSet || (devicename && CONFIG_RTC_HCTOSYS_DEVICE &&
devicename != CONFIG_RTC_HCTOSYS_DEVICE )
return -1;
timeWasSet = 1;
do_settimeofday(time);
return 0;
}
That "timewait" kernel option I mentioned above then would be easy too:
void timewait(void)
{
while (!timeWasSet)
sleepOrSimiliar();
}
That setTimeIfNotSet() function could be called by the RTC subsystem
whenever a new RTC will be registered and CONFIG_RTC_HCTOSYS is enabled
(or on resume).
In regard to the persistent_clocks on x86 I know almost nothing. I
didn't even knew they do exist before I've seen a discussion about
HCTOSYS yesterday. I thought the RTC_CMOS driver is responsible for the
time on x86. ;) Therfor I can't say anything about how things do work there.
Whats missing above is something which sets timeWasSet to 1 if userland
(NTP or similiar) does set the time. That could be done always (in
do_settimeofday) or e.g. by using a function pointer to
do_settimeofday() which first points to a function which sets timeWasSet
and later on points to do_settimeofday() directly.
Maybe it's all silly (I'm missing the big overview over time in the
kernel), but thats what first entered my mind while thinking about how
to avoid changing a time by an HID device if it was already set by
userland/NTP or another clock (besides that trick in testing for system
date < 1970-01-02 I've then used in my patch because it was easy to
implement while not doing changes to timekeeping itself).
Regards,
Alexander
next prev parent reply other threads:[~2013-04-25 6:56 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 [this message]
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 ` [PATCH 0/3] RFC: timekeeping: rtc: change hctosys mechanism Alexander Holler
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=5178D367.4050905@ahsoftware.de \
--to=holler@ahsoftware.de \
--cc=a.zummo@towertech.it \
--cc=akpm@linux-foundation.org \
--cc=jic23@cam.ac.uk \
--cc=jkosina@suse.cz \
--cc=john.stultz@linaro.org \
--cc=lars@metafoo.de \
--cc=linux-kernel@vger.kernel.org \
--cc=rtc-linux@googlegroups.com \
/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).