1. 13 9月, 2014 2 次提交
    • R
      alarmtimer: Do not signal SIGEV_NONE timers · 265b81d2
      Richard Larocque 提交于
      Avoids sending a signal to alarm timers created with sigev_notify set to
      SIGEV_NONE by checking for that special case in the timeout callback.
      
      The regular posix timers avoid sending signals to SIGEV_NONE timers by
      not scheduling any callbacks for them in the first place.  Although it
      would be possible to do something similar for alarm timers, it's simpler
      to handle this as a special case in the timeout.
      
      Prior to this patch, the alarm timer would ignore the sigev_notify value
      and try to deliver signals to the process anyway.  Even worse, the
      sanity check for the value of sigev_signo is skipped when SIGEV_NONE was
      specified, so the signal number could be bogus.  If sigev_signo was an
      unitialized value (as it often would be if SIGEV_NONE is used), then
      it's hard to predict which signal will be sent.
      
      Cc: stable@vger.kernel.org
      Cc: Thomas Gleixner <tglx@linutronix.de>
      Cc: Ingo Molnar <mingo@kernel.org>
      Cc: Richard Cochran <richardcochran@gmail.com>
      Cc: Prarit Bhargava <prarit@redhat.com>
      Cc: Sharvil Nanavati <sharvil@google.com>
      Signed-off-by: NRichard Larocque <rlarocque@google.com>
      Signed-off-by: NJohn Stultz <john.stultz@linaro.org>
      265b81d2
    • R
      alarmtimer: Return relative times in timer_gettime · e86fea76
      Richard Larocque 提交于
      Returns the time remaining for an alarm timer, rather than the time at
      which it is scheduled to expire.  If the timer has already expired or it
      is not currently scheduled, the it_value's members are set to zero.
      
      This new behavior matches that of the other posix-timers and the POSIX
      specifications.
      
      This is a change in user-visible behavior, and may break existing
      applications.  Hopefully, few users rely on the old incorrect behavior.
      
      Cc: stable@vger.kernel.org
      Cc: Thomas Gleixner <tglx@linutronix.de>
      Cc: Ingo Molnar <mingo@kernel.org>
      Cc: Richard Cochran <richardcochran@gmail.com>
      Cc: Prarit Bhargava <prarit@redhat.com>
      Cc: Sharvil Nanavati <sharvil@google.com>
      Signed-off-by: NRichard Larocque <rlarocque@google.com>
      [jstultz: minor style tweak]
      Signed-off-by: NJohn Stultz <john.stultz@linaro.org>
      e86fea76
  2. 08 7月, 2014 1 次提交
  3. 20 6月, 2014 1 次提交
  4. 19 10月, 2013 1 次提交
    • K
      alarmtimer: return EINVAL instead of ENOTSUPP if rtcdev doesn't exist · 98d6f4dd
      KOSAKI Motohiro 提交于
      Fedora Ruby maintainer reported latest Ruby doesn't work on Fedora Rawhide
      on ARM. (http://bugs.ruby-lang.org/issues/9008)
      
      Because of, commit 1c6b39ad (alarmtimers: Return -ENOTSUPP if no
      RTC device is present) intruduced to return ENOTSUPP when
      clock_get{time,res} can't find a RTC device. However this is incorrect.
      
      First, ENOTSUPP isn't exported to userland (ENOTSUP or EOPNOTSUP are the
      closest userland equivlents).
      
      Second, Posix and Linux man pages agree that clock_gettime and
      clock_getres should return EINVAL if clk_id argument is invalid.
      While the arugment that the clockid is valid, but just not supported
      on this hardware could be made, this is just a technicality that
      doesn't help userspace applicaitons, and only complicates error
      handling.
      
      Thus, this patch changes the code to use EINVAL.
      
      Cc: Thomas Gleixner <tglx@linutronix.de>
      Cc: Frederic Weisbecker <fweisbec@gmail.com>
      Cc: stable <stable@vger.kernel.org>  #3.0 and up
      Reported-by: NVit Ondruch <v.ondruch@tiscali.cz>
      Signed-off-by: NKOSAKI Motohiro <kosaki.motohiro@jp.fujitsu.com>
      [jstultz: Tweaks to commit message to include full rational]
      Signed-off-by: NJohn Stultz <john.stultz@linaro.org>
      98d6f4dd
  5. 13 6月, 2013 1 次提交
  6. 30 5月, 2013 1 次提交
    • T
      alarmtimer: Add functions for timerfd support · 6cffe00f
      Todd Poynor 提交于
      Add functions needed for hooking up alarmtimer to timerfd:
      
      * alarm_restart: Similar to hrtimer_restart, restart an alarmtimer after
        the expires time has already been updated (as with alarm_forward).
      
      * alarm_forward_now: Similar to hrtimer_forward_now, move the expires
        time forward to an interval from the current time of the associated clock.
      
      * alarm_start_relative: Start an alarmtimer with an expires time relative to
        the current time of the associated clock.
      
      * alarm_expires_remaining: Similar to hrtimer_expires_remaining, return the
        amount of time remaining until alarm expiry.
      Signed-off-by: NTodd Poynor <toddpoynor@google.com>
      Signed-off-by: NJohn Stultz <john.stultz@linaro.org>
      6cffe00f
  7. 25 9月, 2012 3 次提交
    • J
      alarmtimer: Rename alarmtimer_remove to alarmtimer_dequeue · a65bcc12
      John Stultz 提交于
      Now that alarmtimer_remove has been simplified, change
      its name to _dequeue to better match its paired _enqueue
      function.
      
      Cc: Arve Hjønnevåg <arve@android.com>
      Cc: Colin Cross <ccross@android.com>
      Cc: Thomas Gleixner <tglx@linutronix.de>
      Signed-off-by: NJohn Stultz <john.stultz@linaro.org>
      a65bcc12
    • J
      alarmtimer: Use hrtimer per-alarm instead of per-base · dae373be
      John Stultz 提交于
      Arve Hjønnevåg reported numerous crashes from the
      "BUG_ON(timer->state != HRTIMER_STATE_CALLBACK)" check
      in __run_hrtimer after it called alarmtimer_fired.
      
      It ends up the alarmtimer code was not properly handling
      possible failures of hrtimer_try_to_cancel, and because
      these faulres occur when the underlying base hrtimer is
      being run, this limits the ability to properly handle
      modifications to any alarmtimers on that base.
      
      Because much of the logic duplicates the hrtimer logic,
      it seems that we might as well have a per-alarmtimer
      hrtimer, and avoid the extra complextity of trying to
      multiplex many alarmtimers off of one hrtimer.
      
      Thus this patch moves the hrtimer to the alarm structure
      and simplifies the management logic.
      
      Changelog:
      v2:
      * Includes a fix for double alarm_start calls found by
        Arve
      
      Cc: Arve Hjønnevåg <arve@android.com>
      Cc: Colin Cross <ccross@android.com>
      Cc: Thomas Gleixner <tglx@linutronix.de>
      Reported-by: NArve Hjønnevåg <arve@android.com>
      Tested-by: NArve Hjønnevåg <arve@android.com>
      Signed-off-by: NJohn Stultz <john.stultz@linaro.org>
      dae373be
    • T
      alarmtimer: Implement minimum alarm interval for allowing suspend · 59a93c27
      Todd Poynor 提交于
      alarmtimer suspend return -EBUSY if the next alarm will fire in less
      than 2 seconds.  This allows one RTC seconds tick to occur subsequent
      to this check before the alarm wakeup time is set, ensuring the wakeup
      time is still in the future (assuming the RTC does not tick one more
      second prior to setting the alarm).
      
      If suspend is rejected due to an imminent alarm, hold a wakeup source
      for 2 seconds to process the alarm prior to reattempting suspend.
      
      If setting the alarm incurs an -ETIME for an alarm set in the past,
      or any other problem setting the alarm, abort suspend and hold a
      wakelock for 1 second while the alarm is allowed to be serviced or
      other hopefully transient conditions preventing the alarm clear up.
      Signed-off-by: NTodd Poynor <toddpoynor@google.com>
      Signed-off-by: NJohn Stultz <john.stultz@linaro.org>
      59a93c27
  8. 21 4月, 2012 1 次提交
  9. 24 3月, 2012 2 次提交
  10. 06 12月, 2011 1 次提交
  11. 14 9月, 2011 1 次提交
  12. 11 8月, 2011 9 次提交
  13. 10 8月, 2011 2 次提交
  14. 22 6月, 2011 2 次提交
    • J
      alarmtimers: Return -ENOTSUPP if no RTC device is present · 1c6b39ad
      John Stultz 提交于
      Toralf Förster and Richard Weinberger noted that if there is
      no RTC device, the alarm timers core prints out an annoying
      "ALARM timers will not wake from suspend" message.
      
      This warning has been removed in a previous patch, however
      the issue still remains:  The original idea was to support
      alarm timers even if there was no rtc device, as long as the
      system didn't go into suspend.
      
      However, after further consideration, communicating to the application
      that alarmtimers are not fully functional seems like the better
      solution.
      
      So this patch makes it so we return -ENOTSUPP to any posix _ALARM
      clockid calls if there is no backing RTC device on the system.
      
      Further this changes the behavior where when there is no rtc device
      we will check for one on clock_getres, clock_gettime, timer_create,
      and timer_nsleep instead of on suspend.
      
      CC: Toralf Förster <toralf.foerster@gmx.de>
      CC: Richard Weinberger <richard@nod.at
      CC: Peter Zijlstra <peterz@infradead.org>
      CC: Thomas Gleixner <tglx@linutronix.de>
      Reported-by: NToralf Förster <toralf.foerster@gmx.de>
      Reported by: Richard Weinberger <richard@nod.at>
      Signed-off-by: NJohn Stultz <john.stultz@linaro.org>
      1c6b39ad
    • J
      alarmtimers: Handle late rtc module loading · c008ba58
      John Stultz 提交于
      The alarmtimers code currently picks a rtc device to use at
      late init time. However, if your rtc driver is loaded as a module,
      it may be registered after the alarmtimers late init code, leaving
      the alarmtimers nonfunctional.
      
      This patch moves the the rtcdevice selection to when we actually try
      to use it, allowing us to make use of rtc modules that may have been
      loaded at any point since bootup.
      
      CC: Thomas Gleixner <tglx@linutronix.de>
      CC: Meelis Roos <mroos@ut.ee>
      Reported-by: NMeelis Roos <mroos@ut.ee>
      Signed-off-by: NJohn Stultz <john.stultz@linaro.org>
      c008ba58
  15. 23 5月, 2011 1 次提交
  16. 04 5月, 2011 2 次提交
    • T
      alarmtimer: Drop device refcount after rtc_open() · 179eb032
      Thomas Gleixner 提交于
      class_find_device() takes a refcount on the rtc device. rtc_open()
      takes another one, so we can drop it after the rtc_open() call.
      Signed-off-by: NThomas Gleixner <tglx@linutronix.de>
      Cc: John Stultz <john.stultz@linaro.org>
      179eb032
    • T
      alarmtimer: Check return value of class_find_device() · ce788f93
      Thomas Gleixner 提交于
      alarmtimer_late_init() uses class_find_device() to find a alarm
      capable rtc device. The match callback stores a pointer to the name in
      the char pointer handed in from the call site. alarmtimer_late_init()
      checks the char pointer for NULL, but the pointer is on the stack and
      not initialized to NULL before the call. So it can have random content
      when the match function did not identify a device, which leads to
      random access in the following rtc_open() call where the pointer is
      dereferenced
      
      Instead of relying on the char pointer, check the return value of
      class_find_device. If a device is found then the name pointer is valid
      as well.
      Reported-by: NIngo Molnar <mingo@elte.hu>
      Cc: John Stultz <john.stultz@linaro.org>
      Signed-off-by: NThomas Gleixner <tglx@linutronix.de>
      ce788f93
  17. 03 5月, 2011 1 次提交
  18. 29 4月, 2011 2 次提交
    • J
      timers: Remove delayed irqwork from alarmtimers implementation · 7068b7a1
      John Stultz 提交于
      Thomas asked about the delayed irq work in the alarmtimers code,
      and I realized that it was a legacy from when the alarmtimer base
      lock was a mutex (due to concerns that we'd be interacting with
      the RTC device, which is protected by mutexes).
      
      Since the alarmtimer base is now protected by a spinlock, we can
      simply execute alarmtimer functions directly from the hrtimer
      callback. Should any future alarmtimer functions sleep, they can
      simply manage scheduling any delayed work themselves.
      
      CC: Thomas Gleixner <tglx@linutronix.de>
      Signed-off-by: NJohn Stultz <john.stultz@linaro.org>
      7068b7a1
    • J
      timers: Improve alarmtimer comments and minor fixes · 180bf812
      John Stultz 提交于
      This patch addresses a number of minor comment improvements and
      other minor issues from Thomas' review of the alarmtimers code.
      
      CC: Thomas Gleixner <tglx@linutronix.de>
      Signed-off-by: NJohn Stultz <john.stultz@linaro.org>
      180bf812
  19. 27 4月, 2011 2 次提交
    • J
      timers: Posix interface for alarm-timers · 9a7adcf5
      John Stultz 提交于
      This patch exposes alarm-timers to userland via the posix clock
      and timers interface, using two new clockids: CLOCK_REALTIME_ALARM
      and CLOCK_BOOTTIME_ALARM. Both clockids behave identically to
      CLOCK_REALTIME and CLOCK_BOOTTIME, respectively, but timers
      set against the _ALARM suffixed clockids will wake the system if
      it is suspended.
      
      Some background can be found here:
      	https://lwn.net/Articles/429925/
      
      The concept for Alarm-timers was inspired by the Android Alarm
      driver (by Arve Hjønnevåg) found in the Android kernel tree.
      
      See: http://android.git.kernel.org/?p=kernel/common.git;a=blob;f=drivers/rtc/alarm.c;h=1250edfbdf3302f5e4ea6194847c6ef4bb7beb1c;hb=android-2.6.36
      
      While the in-kernel interface is pretty similar between
      alarm-timers and Android alarm driver, the user-space interface
      for the Android alarm driver is via ioctls to a new char device.
      As mentioned above, I've instead chosen to export this functionality
      via the posix interface, as it seemed a little simpler and avoids
      creating duplicate interfaces to things like CLOCK_REALTIME and
      CLOCK_MONOTONIC under alternate names (ie:ANDROID_ALARM_RTC and
      ANDROID_ALARM_SYSTEMTIME).
      
      The semantics of the Android alarm driver are different from what
      this posix interface provides. For instance, threads other then
      the thread waiting on the Android alarm driver are able to modify
      the alarm being waited on. Also this interface does not allow
      the same wakelock semantics that the Android driver provides
      (ie: kernel takes a wakelock on RTC alarm-interupt, and holds it
      through process wakeup, and while the process runs, until the
      process either closes the char device or calls back in to wait
      on a new alarm).
      
      One potential way to implement similar semantics may be via
      the timerfd infrastructure, but this needs more research.
      
      There may also need to be some sort of sysfs system level policy
      hooks that allow alarm timers to be disabled to keep them
      from firing at inappropriate times (ie: laptop in a well insulated
      bag, mid-flight).
      
      CC: Arve Hjønnevåg <arve@android.com>
      CC: Thomas Gleixner <tglx@linutronix.de>
      CC: Alessandro Zummo <a.zummo@towertech.it>
      Acked-by: NArnd Bergmann <arnd@arndb.de>
      Signed-off-by: NJohn Stultz <john.stultz@linaro.org>
      9a7adcf5
    • J
      timers: Introduce in-kernel alarm-timer interface · ff3ead96
      John Stultz 提交于
      This provides the in kernel interface and infrastructure for
      alarm-timers.
      
      Alarm-timers are a hybrid style timer, similar to hrtimers,
      but when the system is suspended, the RTC device is set to
      fire and wake the system for when the soonest alarm-timer
      expires.
      
      The concept for Alarm-timers was inspired by the Android Alarm
      driver (by Arve Hjønnevåg) found in the Android kernel tree.
      
      See: http://android.git.kernel.org/?p=kernel/common.git;a=blob;f=drivers/rtc/alarm.c;h=1250edfbdf3302f5e4ea6194847c6ef4bb7beb1c;hb=android-2.6.36
      
      This in-kernel interface should be fairly compatible with the
      Android alarm driver in-kernel interface, but has the advantage
      of utilizing the new RTC timerqueue code instead of doing direct
      RTC manipulation.
      
      CC: Arve Hjønnevåg <arve@android.com>
      CC: Thomas Gleixner <tglx@linutronix.de>
      CC: Alessandro Zummo <a.zummo@towertech.it>
      Acked-by: NArnd Bergmann <arnd@arndb.de>
      Signed-off-by: NJohn Stultz <john.stultz@linaro.org>
      ff3ead96