linux-kernel.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
From: John Stultz <john.stultz@linaro.org>
To: Alexander Holler <holler@ahsoftware.de>
Cc: linux-kernel@vger.kernel.org, rtc-linux@googlegroups.com,
	Andrew Morton <akpm@linux-foundation.org>,
	Alessandro Zummo <a.zummo@towertech.it>,
	Lars-Peter Clausen <lars@metafoo.de>,
	Jonathan Cameron <jic23@cam.ac.uk>, Jiri Kosina <jkosina@suse.cz>
Subject: Re: [PATCH 3/4] rtc: rtc-hid-sensor-time: add option hctosys to set time at boot
Date: Tue, 28 May 2013 12:37:24 -0700	[thread overview]
Message-ID: <51A50774.6060400@linaro.org> (raw)
In-Reply-To: <519C0004.9000706@ahsoftware.de>

On 05/21/2013 04:15 PM, Alexander Holler wrote:
> Am 22.05.2013 00:02, schrieb John Stultz:
>
>>
>> Like Andrew, I think this feels particularly hacky.
>>
>> Why exactly is late_init too early? (I'm unfamiliar with the
>> rtc-hid-sensor-time driver)
>
> Currently it can be an USB device (and maybe Bluetooth or even i2c in 
> the future, depends on hid-sensor-hub). That has some implications:
>
> (1) Initialization might need longer (or happens later) than 
> late_init, even if everything is linked into the kernel (same problem 
> as with a boot from USB-storage)
> (2) It might not even be available at boot, but it should work if a 
> user plugs it in afterwards.
> (3) To accomplish (2) it should set the system time (by default) IFF 
> nothing else did set the time.
>
> That "nothing else" in (3) is for security reasons, because no 
> plugable HID device should be able to change the system time by default.
>
> The check if something else did set the system time can't be 
> accomplished only by the RTC subsystem because userspace, network or 
> whatever else is able to set the system time most likely doesn't use 
> the RTC subsystem (or hctosys).
>
> E.g. one of those setups could be:
>
> boot
> hctosys (fails because of no RTC)
> ntpdate/rdate/date < whatever
> load modules (rtc-hid-sensor-time)
>
> If we would use a flag in the hctosys module then rtc-hid-sensor-time 
> would be able to change the time (in the setup above).
>
> Using a module option which is by default off doesn't help too. Users 
> (or even distros) which would turn it on, might forget it and systems 
> would be at risk if no HID clock will be found at boot (but later 
> plugged in by some blackhat).
>
> A flag in the time subsystem itself would do the trick. Such a flag 
> might help with the problem if the RTC subsystem or the persistent 
> clock code did set the time too. You've mentioned in another thread 
> that you had to solve such a problem, but I'm not aware how you did that.
>
> Implementation could be as easy as a bool "time_set_at_least_once" in 
> the timer subsystem itself (e.g. in do_settimeofday() and whatever 
> similiar is available).

If it were to be done this way, it would be good to have the RTC layer 
check when RTC devices are registered and call the internal hctosys 
functionality then (rather then just at late_init). Do you want to try 
to rework the patch in this way?

I'm not totally sure I'd agree that it would be better over leaving it 
to userspace, but if we're going to go with an in-kernel policy for 
this, then it seems like a better approach then the current patch.

>
> >
> > If this is a hotplug rtc device (why I'm guessing its not available at
> > late_init), would it not be better to leave the setting of time using
> > hwclock --hctosys via a udev rule or something?
>
> I want to set the time with millisecond precision (if the HID clock 
> offers that), which currently isn't available through the RTC subsystem.

True. This is one area I'd like to see addressed at some point. A few 
RTC devices have sub-second granularity and we're not exposing it via 
the RTC subsystem to either kernel or userland consumers.


> But even if milliseconds would be available through /dev/rtcN, the 
> problem if something else did set the time still would be the same, 
> just that an udev-rule now would have that problem.

Though a udev hack to check if its 1970 would be fairly simple. And 
pushes the policy of setting or not setting clearly off to userland 
(which allows for less compile-time or boot option tweaks to manipulate).

thanks
-john


  reply	other threads:[~2013-05-28 19:37 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 [this message]
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=51A50774.6060400@linaro.org \
    --to=john.stultz@linaro.org \
    --cc=a.zummo@towertech.it \
    --cc=akpm@linux-foundation.org \
    --cc=holler@ahsoftware.de \
    --cc=jic23@cam.ac.uk \
    --cc=jkosina@suse.cz \
    --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).