1. 13 Sep, 2018 1 commit
  2. 02 Aug, 2018 1 commit
  3. 26 Jul, 2018 4 commits
  4. 13 Jul, 2018 1 commit
  5. 07 Jun, 2018 1 commit
  6. 17 Mar, 2018 3 commits
    • Baolin Wang's avatar
      rtc: Add one offset seconds to expand RTC range · 98951564
      Baolin Wang authored
      From our investigation for all RTC drivers, 1 driver will be expired before
      year 2017, 7 drivers will be expired before year 2038, 23 drivers will be
      expired before year 2069, 72 drivers will be expired before 2100 and 104
      drivers will be expired before 2106. Especially for these early expired
      drivers, we need to expand the RTC range to make the RTC can still work
      after the expired year.
      
      So we can expand the RTC range by adding one offset to the time when reading
      from hardware, and subtracting it when writing back. For example, if you have
      an RTC that can do 100 years, and currently is configured to be based in
      Jan 1 1970, so it can represents times from 1970 to 2069. Then if you change
      the start year from 1970 to 2000, which means it can represents times from
      2000 to 2099. By adding or subtracting the offset produced by moving the wrap
      point, all times between 1970 and 1999 from RTC hardware could get interpreted
      as times from 2070 to 2099, but the interpretation of dates between 2000 and
      2069 would not change.
      Signed-off-by: default avatarBaolin Wang <baolin.wang@linaro.org>
      Signed-off-by: default avatarAlexandre Belloni <alexandre.belloni@bootlin.com>
      98951564
    • Baolin Wang's avatar
      rtc: Factor out the RTC range validation into rtc_valid_range() · 4c4e5df1
      Baolin Wang authored
      The RTC range validation code can be factored into rtc_valid_range()
      function to avoid duplicate code.
      Signed-off-by: default avatarBaolin Wang <baolin.wang@linaro.org>
      Signed-off-by: default avatarAlexandre Belloni <alexandre.belloni@bootlin.com>
      4c4e5df1
    • Alexandre Belloni's avatar
      rtc: Add RTC range · 71db049e
      Alexandre Belloni authored
      Add a way for drivers to inform the core of the supported date/time range.
      The core can then check whether the date/time or alarm is in the range
      before calling ->set_time, ->set_mmss or ->set_alarm. It returns -ERANGE
      when the time is out of range.
      Signed-off-by: default avatarAlexandre Belloni <alexandre.belloni@bootlin.com>
      71db049e
  7. 13 Feb, 2018 1 commit
    • Baolin Wang's avatar
      rtc: Add tracepoints for RTC system · 29a1f599
      Baolin Wang authored
      It will be more helpful to add some tracepoints to track RTC actions when
      debugging RTC driver. Below sample is that we set/read the RTC time, then
      set 2 alarms, so we can see the trace logs:
      
      set/read RTC time:
      kworker/0:1-67 [000] 21.814245: rtc_set_time: UTC (1510301580) (0)
      kworker/0:1-67 [000] 21.814312: rtc_read_time: UTC (1510301580) (0)
      
      set the first alarm timer:
      kworker/0:1-67 [000] 21.829238: rtc_timer_enqueue: RTC timer:(ffffffc15eb49bc8) expires:1510301700000000000 period:0
      kworker/0:1-67 [000] 22.018279: rtc_set_alarm: UTC (1510301700) (0)
      
      set the second alarm timer:
      kworker/0:1-67 [000] 22.230284: rtc_timer_enqueue: RTC timer:(ffffff80088e6430) expires:1510301820000000000 period:0
      
      the first alarm timer was expired:
      kworker/0:1-67 [000] 145.155584: rtc_timer_dequeue: RTC timer:(ffffffc15eb49bc8) expires:1510301700000000000 period:0
      kworker/0:1-67 [000] 145.155593: rtc_timer_fired: RTC timer:(ffffffc15eb49bc8) expires:1510301700000000000 period:0
      kworker/0:1-67 [000] 145.172504: rtc_set_alarm: UTC (1510301820) (0)
      
      the second alarm timer was expired:
      kworker/0:1-67 [000] 269.102353: rtc_timer_dequeue: RTC timer:(ffffff80088e6430) expires:1510301820000000000 period:0
      kworker/0:1-67 [000] 269.102360: rtc_timer_fired: RTC timer:(ffffff80088e6430) expires:1510301820000000000 period:0
      
      disable alarm irq:
      kworker/0:1-67 [000] 269.102469: rtc_alarm_irq_enable: disable RTC alarm IRQ (0)
      Signed-off-by: default avatarBaolin Wang <baolin.wang@linaro.org>
      Signed-off-by: default avatarAlexandre Belloni <alexandre.belloni@bootlin.com>
      29a1f599
  8. 25 Oct, 2017 1 commit
  9. 28 Sep, 2017 1 commit
  10. 31 May, 2017 1 commit
    • Vaibhav Jain's avatar
      rtc: interface: Validate alarm-time before handling rollover · da96aea0
      Vaibhav Jain authored
      In function __rtc_read_alarm() its possible for an alarm time-stamp to
      be invalid even after replacing missing components with current
      time-stamp. The condition 'alarm->time.tm_year < 70' will trigger this
      case and will cause the call to 'rtc_tm_to_time64(&alarm->time)'
      return a negative value for variable t_alm.
      
      While handling alarm rollover this negative t_alm (assumed to seconds
      offset from '1970-01-01 00:00:00') is converted back to rtc_time via
      rtc_time64_to_tm() which results in this error log with seemingly
      garbage values:
      
      "rtc rtc0: invalid alarm value: -2-1--1041528741
      2005511117:71582844:32"
      
      This error was generated when the rtc driver (rtc-opal in this case)
      returned an alarm time-stamp of '00-00-00 00:00:00' to indicate that
      the alarm is disabled. Though I have submitted a separate fix for the
      rtc-opal driver, this issue may potentially impact other
      existing/future rtc drivers.
      
      To fix this issue the patch validates the alarm time-stamp just after
      filling up the missing datetime components and if rtc_valid_tm() still
      reports it to be invalid then bails out of the function without
      handling the rollover.
      Reported-by: default avatarSteve Best <sbest@redhat.com>
      Signed-off-by: default avatarVaibhav Jain <vaibhav@linux.vnet.ibm.com>
      Signed-off-by: default avatarAlexandre Belloni <alexandre.belloni@free-electrons.com>
      da96aea0
  11. 25 Dec, 2016 2 commits
    • Thomas Gleixner's avatar
      ktime: Cleanup ktime_set() usage · 8b0e1953
      Thomas Gleixner authored
      ktime_set(S,N) was required for the timespec storage type and is still
      useful for situations where a Seconds and Nanoseconds part of a time value
      needs to be converted. For anything where the Seconds argument is 0, this
      is pointless and can be replaced with a simple assignment.
      Signed-off-by: default avatarThomas Gleixner <tglx@linutronix.de>
      Cc: Peter Zijlstra <peterz@infradead.org>
      8b0e1953
    • Thomas Gleixner's avatar
      ktime: Get rid of the union · 2456e855
      Thomas Gleixner authored
      ktime is a union because the initial implementation stored the time in
      scalar nanoseconds on 64 bit machine and in a endianess optimized timespec
      variant for 32bit machines. The Y2038 cleanup removed the timespec variant
      and switched everything to scalar nanoseconds. The union remained, but
      become completely pointless.
      
      Get rid of the union and just keep ktime_t as simple typedef of type s64.
      
      The conversion was done with coccinelle and some manual mopping up.
      Signed-off-by: default avatarThomas Gleixner <tglx@linutronix.de>
      Cc: Peter Zijlstra <peterz@infradead.org>
      2456e855
  12. 11 Jul, 2016 1 commit
  13. 04 Jun, 2016 1 commit
    • Colin Ian King's avatar
      rtc: interface: ignore expired timers when enqueuing new timers · 2b2f5ff0
      Colin Ian King authored
      This patch fixes a RTC wakealarm issue, namely, the event fires during
      hibernate and is not cleared from the list, causing hwclock to block.
      
      The current enqueuing does not trigger an alarm if any expired timers
      already exist on the timerqueue. This can occur when a RTC wake alarm
      is used to wake a machine out of hibernate and the resumed state has
      old expired timers that have not been removed from the timer queue.
      This fix skips over any expired timers and triggers an alarm if there
      are no pending timers on the timerqueue. Note that the skipped expired
      timer will get reaped later on, so there is no need to clean it up
      immediately.
      
      The issue can be reproduced by putting a machine into hibernate and
      waking it with the RTC wakealarm.  Running the example RTC test program
      from tools/testing/selftests/timers/rtctest.c after the hibernate will
      block indefinitely.  With the fix, it no longer blocks after the
      hibernate resume.
      
      BugLink: http://bugs.launchpad.net/bugs/1333569Signed-off-by: default avatarColin Ian King <colin.king@canonical.com>
      Signed-off-by: default avatarAlexandre Belloni <alexandre.belloni@free-electrons.com>
      2b2f5ff0
  14. 29 May, 2016 1 commit
  15. 14 Mar, 2016 1 commit
    • Joshua Clayton's avatar
      rtc: Add functions to set and read rtc offset · b3967067
      Joshua Clayton authored
      A number of rtc devices, such as the NXP pcf2123 include a facility
      to adjust the clock in order to compensate for temperature or a
      crystal, capacitor, etc, that results in the rtc clock not running
      at exactly 32.768 kHz.
      
      Data sheets I have seen refer to this as a clock offset, and measure it
      in parts per million, however they often reference ppm to 2 digits of
      precision, which makes integer ppm less than ideal.
      
      We use parts per billion, which more than covers the precision needed
      and works nicely within 32 bits
      Signed-off-by: default avatarJoshua Clayton <stillcompiling@gmail.com>
      Signed-off-by: default avatarAlexandre Belloni <alexandre.belloni@free-electrons.com>
      b3967067
  16. 05 Sep, 2015 1 commit
  17. 24 Jun, 2015 1 commit
  18. 19 Jun, 2015 1 commit
  19. 17 Apr, 2015 1 commit
  20. 03 Apr, 2015 1 commit
  21. 24 Jan, 2015 1 commit
  22. 11 Dec, 2014 2 commits
  23. 08 Aug, 2014 1 commit
  24. 06 Jun, 2014 1 commit
  25. 03 Apr, 2014 1 commit
  26. 22 Jul, 2013 1 commit
    • Zoran Markovic's avatar
      rtc: Keep system awake until all expired RTC timers are handled · 14d0e347
      Zoran Markovic authored
      Current implementation of RTC interface allows for system suspend to
      occur in the following cases:
      (a) if a timer is set in the past and rtc_timer_do_work() is scheduled
      to handle it, and
      (b) if rtc_timer_do_work() is called to handle expired timers whose
      handlers implement a preemption point.
      
      A pending suspend request may be honoured in the above cases causing
      timer handling to be delayed until after the next resume. This is
      undesirable since timer handlers may have time-critical code to execute.
      
      This patch makes sure that the system stays awake until all expired
      timers are handled.
      
      Note that all calls to pm_stay_awake() are eventually paired with
      the single pm_relax() call in rtc_timer_do_work(), which is launched
      using schedule_work().
      
      Cc: Alessandro Zummo <a.zummo@towertech.it>
      Cc: John Stultz <john.stultz@linaro.org>
      Cc: Arve Hjonnevag <arve@android.com>
      Cc: Todd Poynor <toddpoynor@google.com>
      Signed-off-by: default avatarZoran Markovic <zoran.markovic@linaro.org>
      Signed-off-by: default avatarJohn Stultz <john.stultz@linaro.org>
      14d0e347
  27. 03 Jul, 2013 2 commits
  28. 06 Feb, 2013 1 commit
  29. 08 Aug, 2012 1 commit
    • NeilBrown's avatar
      RTC: Avoid races between RTC alarm wakeup and suspend. · 7523ceed
      NeilBrown authored
      If an RTC alarm fires just as suspend is happening, it is possible for
      suspend to complete and the alarm to be missed.
      
      To avoid the race, we must register the event with the PM core.
      
      As the event is made visible to userspace through a thread which is
      only scheduled by the interrupt, we need a pm_stay_awake/pm_relax
      pair preventing suspend from the interrupt until the thread completes
      its work.
      
      This makes the pm_wakeup_event() call in cmos_interrupt unnecessary as
      it provides suspend protection for all RTCs that use rtc_update_irq.
      Signed-off-by: default avatarNeilBrown <neilb@suse.de>
      Signed-off-by: default avatarRafael J. Wysocki <rjw@sisk.pl>
      7523ceed
  30. 16 Mar, 2012 1 commit
  31. 27 Jan, 2012 2 commits
    • Rabin Vincent's avatar
      rtc: Disable the alarm in the hardware (v2) · 41c7f742
      Rabin Vincent authored
      Currently, the RTC code does not disable the alarm in the hardware.
      
      This means that after a sequence such as the one below (the files are in the
      RTC sysfs), the box will boot up after 2 minutes even though we've
      asked for the alarm to be turned off.
      
      	# echo $((`cat since_epoch`)+120) > wakealarm
      	# echo 0 > wakealarm
      	# poweroff
      
      Fix this by disabling the alarm when there are no timers to run.
      
      The original version of this patch was reverted. This version
      disables the irq directly instead of setting a disabled timer
      in the future.
      
      Cc: stable@kernel.org
      Cc: John Stultz <john.stultz@linaro.org>
      Signed-off-by: default avatarRabin Vincent <rabin.vincent@stericsson.com>
      [Merged in the second revision from Rabin]
      Signed-off-by: default avatarJohn Stultz <john.stultz@linaro.org>
      41c7f742
    • NeilBrown's avatar
      rtc: Expire alarms after the time is set. (v2) · 5f9679d2
      NeilBrown authored
      If the alarm time programming in the rtc is ever in the past, it won't fire,
      and any other alarm will be queued after it so they won't fire either.
      
      So any time that the alarm might be in the past, we need to trigger
      the irq handler to ensure the old alarm is cleared and the timer queue
      is fully in the future.
      
      This is done whenever the RTC clock is set.
      
      This is the second revision of this patch, which was earlier reverted.
      This version avoids the initialization problem, which is handled by
      a different patch.
      Tested-by: default avatarSander Eikelenboom <linux@eikelenboom.it>
      Signed-off-by: default avatarNeilBrown <neilb@suse.de>
      [Remove problematic initialization change, update commit log, also
      catch set_mmss case -jstultz]
      Signed-off-by: default avatarJohn Stultz <john.stultz@linaro.org>
      5f9679d2