06 Dec, 2011

1 commit

  • The expiry function compares the timer against current time and does
    not expire the timer when the expiry time is >= now. That's wrong. If
    the timer is set for now, then it must expire.

    Make the condition expiry > now for breaking out the loop.

    Signed-off-by: Thomas Gleixner
    Acked-by: John Stultz
    Cc: stable@kernel.org

    Thomas Gleixner
     

14 Sep, 2011

1 commit


11 Aug, 2011

9 commits


10 Aug, 2011

2 commits


22 Jun, 2011

2 commits

  • 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
    CC: Richard Weinberger
    CC: Thomas Gleixner
    Reported-by: Toralf Förster
    Reported by: Richard Weinberger
    Signed-off-by: John Stultz

    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
    CC: Meelis Roos
    Reported-by: Meelis Roos
    Signed-off-by: John Stultz

    John Stultz
     

23 May, 2011

1 commit


04 May, 2011

2 commits

  • 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: Thomas Gleixner
    Cc: John Stultz

    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: Ingo Molnar
    Cc: John Stultz
    Signed-off-by: Thomas Gleixner

    Thomas Gleixner
     

03 May, 2011

1 commit


29 Apr, 2011

2 commits

  • 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
    Signed-off-by: John Stultz

    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
    Signed-off-by: John Stultz

    John Stultz
     

27 Apr, 2011

2 commits

  • 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
    CC: Thomas Gleixner
    CC: Alessandro Zummo
    Acked-by: Arnd Bergmann
    Signed-off-by: John Stultz

    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
    CC: Thomas Gleixner
    CC: Alessandro Zummo
    Acked-by: Arnd Bergmann
    Signed-off-by: John Stultz

    John Stultz