1. 07 2月, 2013 1 次提交
  2. 09 8月, 2012 1 次提交
    • N
      RTC: Avoid races between RTC alarm wakeup and suspend. · 7523ceed
      NeilBrown 提交于
      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: NNeilBrown <neilb@suse.de>
      Signed-off-by: NRafael J. Wysocki <rjw@sisk.pl>
      7523ceed
  3. 16 3月, 2012 1 次提交
  4. 27 1月, 2012 3 次提交
    • R
      rtc: Disable the alarm in the hardware (v2) · 41c7f742
      Rabin Vincent 提交于
      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: NRabin Vincent <rabin.vincent@stericsson.com>
      [Merged in the second revision from Rabin]
      Signed-off-by: NJohn Stultz <john.stultz@linaro.org>
      41c7f742
    • N
      rtc: Expire alarms after the time is set. (v2) · 5f9679d2
      NeilBrown 提交于
      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: NSander Eikelenboom <linux@eikelenboom.it>
      Signed-off-by: NNeilBrown <neilb@suse.de>
      [Remove problematic initialization change, update commit log, also
      catch set_mmss case -jstultz]
      Signed-off-by: NJohn Stultz <john.stultz@linaro.org>
      5f9679d2
    • J
      rtc: Avoid setting alarm to a time in the past · bd729d72
      John Stultz 提交于
      In some cases at boot up, the RTC alarm may be set in the past,
      but still have the enabled flag on. This was causing problems,
      because we would then enqueue the alarm into the timerqueue,
      but it would never fire. This would clog up the timerqueue
      and keep other alarms from working.
      
      The fix is to check the alarm against the current rtc time at
      boot and avoid enqueueing the alarm if it is in the past.
      Reported-by: NNeilBrown <neilb@suse.de>
      Tested-by: NNeilBrown <neilb@suse.de>
      Tested-by: NSander Eikelenboom <linux@eikelenboom.it>
      Signed-off-by: NJohn Stultz <john.stultz@linaro.org>
      bd729d72
  5. 11 1月, 2012 1 次提交
  6. 04 1月, 2012 2 次提交
    • L
      Revert "rtc: Expire alarms after the time is set." · f423fc62
      Linus Torvalds 提交于
      This reverts commit 93b2ec01.
      
      The call to "schedule_work()" in rtc_initialize_alarm() happens too
      early, and can cause oopses at bootup
      
      Neil Brown explains why we do it:
      
        "If you set an alarm in the future, then shutdown and boot again after
         that time, then you will end up with a timer_queue node which is in
         the past.
      
         When this happens the queue gets stuck.  That entry-in-the-past won't
         get removed until and interrupt happens and an interrupt won't happen
         because the RTC only triggers an interrupt when the alarm is "now".
      
         So you'll find that e.g.  "hwclock" will always tell you that
         'select' timed out.
      
         So we force the interrupt work to happen at the start just in case."
      
      and has a patch that convert it to do things in-process rather than with
      the worker thread, but right now it's too late to play around with this,
      so we just revert the patch that caused problems for now.
      Reported-by: NSander Eikelenboom <linux@eikelenboom.it>
      Requested-by: NKonrad Rzeszutek Wilk <konrad.wilk@oracle.com>
      Requested-by: NJohn Stultz <john.stultz@linaro.org>
      Cc: Neil Brown <neilb@suse.de>
      Signed-off-by: NLinus Torvalds <torvalds@linux-foundation.org>
      f423fc62
    • L
      Revert "rtc: Disable the alarm in the hardware" · 157e8bf8
      Linus Torvalds 提交于
      This reverts commit c0afabd3.
      
      It causes failures on Toshiba laptops - instead of disabling the alarm,
      it actually seems to enable it on the affected laptops, resulting in
      (for example) the laptop powering on automatically five minutes after
      shutdown.
      
      There's a patch for it that appears to work for at least some people,
      but it's too late to play around with this, so revert for now and try
      again in the next merge window.
      
      See for example
      
      	http://bugs.debian.org/652869
      
      Reported-and-bisected-by: Andreas Friedrich <afrie@gmx.net> (Toshiba Tecra)
      Reported-by: Antonio-M. Corbi Bellot <antonio.corbi@ua.es> (Toshiba Portege R500)
      Reported-by: Marco Santos <marco.santos@waynext.com> (Toshiba Portege Z830)
      Reported-by: Christophe Vu-Brugier <cvubrugier@yahoo.fr>  (Toshiba Portege R830)
      Cc: Jonathan Nieder <jrnieder@gmail.com>
      Requested-by: NJohn Stultz <john.stultz@linaro.org>
      Cc: stable@kernel.org  # for the versions that applied this
      Signed-off-by: NLinus Torvalds <torvalds@linux-foundation.org>
      157e8bf8
  7. 14 12月, 2011 1 次提交
    • N
      rtc: Expire alarms after the time is set. · 93b2ec01
      NeilBrown 提交于
      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 can happen:
       - when we first initialise the alarm
       - when we set the time in the rtc.
      
      so follow both of these by scheduling the timer work function.
      
      CC: stable@kernel.org
      Signed-off-by: NNeilBrown <neilb@suse.de>
      [Also catch set_mmss case -jstultz]
      Signed-off-by: NJohn Stultz <john.stultz@linaro.org>
      93b2ec01
  8. 23 11月, 2011 1 次提交
    • R
      rtc: Disable the alarm in the hardware · c0afabd3
      Rabin Vincent 提交于
      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.
      
      Cc: stable@kernel.org
      Cc: John Stultz <john.stultz@linaro.org>
      Signed-off-by: NRabin Vincent <rabin.vincent@stericsson.com>
      Signed-off-by: NJohn Stultz <john.stultz@linaro.org>
      c0afabd3
  9. 01 11月, 2011 1 次提交
  10. 11 8月, 2011 1 次提交
    • J
      rtc: Fix RTC PIE frequency limit · 938f97bc
      John Stultz 提交于
      Thomas earlier submitted a fix to limit the RTC PIE freq, but
      picked 5000Hz out of the air. Willy noticed that we should
      instead use the 8192Hz max from the rtc man documentation.
      
      Cc: Willy Tarreau <w@1wt.eu>
      Cc: stable@kernel.org
      Cc: Thomas Gleixner <tglx@linutronix.de>
      Signed-off-by: NJohn Stultz <john.stultz@linaro.org>
      938f97bc
  11. 27 7月, 2011 6 次提交
  12. 02 6月, 2011 1 次提交
  13. 31 3月, 2011 1 次提交
  14. 30 3月, 2011 1 次提交
    • J
      RTC: Fix early irqs caused by calling rtc_set_alarm too early · f6d5b331
      John Stultz 提交于
      When we register an rtc device at boot, we read the alarm value
      in hardware and set the rtc device's aie_timer to that value.
      
      The initial method to do this was to simply call rtc_set_alarm()
      with the value read from hardware. However, this may cause problems
      as rtc_set_alarm may enable interupts, and the RTC alarm might fire,
      which can cause invalid pointer dereferencing since the RTC registration
      is not complete.
      
      This patch solves the issue by initializing the rtc_device.aie_timer
      y hand via rtc_initialize_alarm(). This avoids any calls to the RTC
      hardware which might enable interrupts too early.
      
      CC: Thomas Gleixner <tglx@linutronix.de>
      CC: Alessandro Zummo <a.zummo@towertech.it>
      Reported-by: NKonrad Rzeszutek Wilk <konrad.wilk@oracle.com>
      Tested-by: NKonrad Rzeszutek Wilk <konrad.wilk@oracle.com>
      Signed-off-by: NJohn Stultz <john.stultz@linaro.org>
      f6d5b331
  15. 10 3月, 2011 1 次提交
    • J
      RTC: Initialize kernel state from RTC · f44f7f96
      John Stultz 提交于
      Mark Brown pointed out a corner case: that RTC alarms should
      be allowed to be persistent across reboots if the hardware
      supported it.
      
      The rework of the generic layer to virtualize the RTC alarm
      virtualized much of the alarm handling, and removed the
      code used to read the alarm time from the hardware.
      
      Mark noted if we want the alarm to be persistent across
      reboots, we need to re-read the alarm value into the
      virtualized generic layer at boot up, so that the generic
      layer properly exposes that value.
      
      This patch restores much of the earlier removed
      rtc_read_alarm code and wires it in so that we
      set the kernel's alarm value to what we find in the
      hardware at boot time.
      
      NOTE: Not all hardware supports persistent RTC alarm state across
      system reset. rtc-cmos for example will keep the alarm time, but
      disables the AIE mode irq. Applications should not expect the RTC
      alarm to be valid after a system reset. We will preserve what
      we can, to represent the hardware state at boot, but its not
      guarenteed.
      
      Further, in the future, with multiplexed RTC alarms, the
      soonest alarm to fire may not be the one set via the /dev/rt
      ioctls. So an application may set the alarm with RTC_ALM_SET,
      but after a reset find that RTC_ALM_READ returns an earlier
      time. Again, we preserve what we can, but applications should
      not expect the RTC alarm state to persist across a system reset.
      
      Big thanks to Mark for pointing out the issue!
      Thanks also to Marcelo for helping think through the solution.
      
      CC: Mark Brown <broonie@opensource.wolfsonmicro.com>
      CC: Marcelo Roberto Jimenez <mroberto@cpti.cetuc.puc-rio.br>
      CC: Thomas Gleixner <tglx@linutronix.de>
      CC: Alessandro Zummo <a.zummo@towertech.it>
      CC: rtc-linux@googlegroups.com
      Reported-by: NMark Brown <broonie@opensource.wolfsonmicro.com>
      Signed-off-by: NJohn Stultz <john.stultz@linaro.org>
      f44f7f96
  16. 18 2月, 2011 2 次提交
  17. 04 2月, 2011 1 次提交
  18. 22 1月, 2011 2 次提交
  19. 14 12月, 2010 1 次提交
  20. 11 12月, 2010 1 次提交
    • J
      RTC: Rework RTC code to use timerqueue for events · 6610e089
      John Stultz 提交于
      This patch reworks a large portion of the generic RTC code
      to in-effect virtualize the rtc interrupt code.
      
      The current RTC interface is very much a raw hardware interface.
      Via the proc, /dev/, or sysfs interfaces, applciations can set
      the hardware to trigger interrupts in one of three modes:
      
      AIE: Alarm interrupt
      UIE: Update interrupt (ie: once per second)
      PIE: Periodic interrupt (sub-second irqs)
      
      The problem with this interface is that it limits the RTC hardware
      so it can only be used by one application at a time.
      
      The purpose of this patch is to extend the RTC code so that we can
      multiplex multiple applications event needs onto a single RTC device.
      This is done by utilizing the timerqueue infrastructure to manage
      a list of events, which cause the RTC hardware to be programmed
      to fire an interrupt for the next event in the list.
      
      In order to preserve the functionality of the exsting proc,/dev/ and
      sysfs interfaces, we emulate the different interrupt modes as follows:
      
      AIE: We create a rtc_timer dedicated to AIE mode interrupts. There is
      only one per device, so we don't change existing interface semantics.
      
      UIE: Again, a dedicated rtc_timer, set for periodic mode, is used
      to emulate UIE interrupts. Again, only one per device.
      
      PIE: Since PIE mode interrupts fire faster then the RTC's clock read
      granularity, we emulate PIE mode interrupts using a hrtimer. Again,
      one per device.
      
      With this patch, the rtctest.c application in Documentation/rtc.txt
      passes fine on x86 hardware. However, there may very well still be
      bugs, so greatly I'd appreciate any feedback or testing!
      Signed-off-by: NJohn Stultz <john.stultz@linaro.org>
      LKML Reference: <1290136329-18291-4-git-send-email-john.stultz@linaro.org>
      Acked-by: NAlessandro Zummo <a.zummo@towertech.it>
      Reviewed-by: NThomas Gleixner <tglx@linutronix.de>
      CC: Alessandro Zummo <a.zummo@towertech.it>
      CC: Thomas Gleixner <tglx@linutronix.de>
      CC: Richard Cochran <richardcochran@gmail.com>
      6610e089
  21. 12 10月, 2009 1 次提交
  22. 20 6月, 2009 1 次提交
  23. 07 1月, 2009 3 次提交
  24. 05 1月, 2009 1 次提交
  25. 07 11月, 2008 1 次提交
  26. 31 7月, 2008 1 次提交
  27. 22 7月, 2008 1 次提交
  28. 05 7月, 2008 1 次提交
    • D
      rtc: rtc_read_alarm() handles wraparound · a01cc657
      David Brownell 提交于
      While 0e36a9a4 ("rtc: fix readback from
      /sys/class/rtc/rtc?/wakealarm") made sure that active alarms were never
      returned with invalid "wildcard" fields (negative), it can still report
      (wrongly) that the alarm triggers in the past.
      
      Example, if it's now 10am, an alarm firing at 5am will be triggered
      TOMORROW not today.  (Which may also be next month or next year...)
      
      This updates that alarm handling in three ways:
      
        * Handle alarm rollover in the common cases of RTCs that don't
          support matching on all date fields.
      
        * Skip the invalid-field logic when it's not needed.
      
        * Minor bugfix ... tm_isdst should be ignored, it's one of the
          fields Linux doesn't maintain.
      
      A warning is emitted for some of the unhandled rollover cases, but the
      possible combinations are a bit too numerous to handle every bit of
      potential hardware and firmware braindamage.
      Signed-off-by: NDavid Brownell <dbrownell@users.sourceforge.net>
      Cc: Mark Lord <lkml@rtr.ca>
      Acked-by: NAlessandro Zummo <a.zummo@towertech.it>
      Signed-off-by: NAndrew Morton <akpm@linux-foundation.org>
      Signed-off-by: NLinus Torvalds <torvalds@linux-foundation.org>
      a01cc657