17 Oct, 2016

1 commit

  • Remove the set but unused variable base in alarm_clock_get to fix the
    following warning when building with 'W=1':

    kernel/time/alarmtimer.c: In function ‘alarm_timer_create’:
    kernel/time/alarmtimer.c:545:21: warning: variable ‘base’ set but not used [-Wunused-but-set-variable]

    Signed-off-by: Tobias Klauser
    Cc: John Stultz
    Link: http://lkml.kernel.org/r/20161017094702.10873-1-tklauser@distanz.ch
    Signed-off-by: Thomas Gleixner

    Tobias Klauser
     

21 Jun, 2016

1 commit


04 Dec, 2015

1 commit

  • Before the system go to suspend (S3), if user create a timer
    with clockid CLOCK_REALTIME_ALARM/CLOCK_BOOTTIME_ALARM and set a
    "large" timeout value to this timer. The function
    alarmtimer_suspend will be called to setup a timeout value to
    RTC timer to avoid the system sleep over time. However, if the
    system wakeup early than RTC timeout, the RTC timer will not be
    cleared. And this will cause the hpet_rtc_interrupt come
    unexpectedly until the RTC timeout. To fix this problem, just
    adding alarmtimer_resume to cancel the RTC timer.

    This was noticed because the HPET RTC emulation fires an
    interrupt every 16ms(=1/2^DEFAULT_RTC_SHIFT) up to the point
    where the alarm time is reached.

    This program always hits this situation
    (https://lkml.org/lkml/2015/11/8/326), if system wake up earlier
    than alarm time.

    Cc: Thomas Gleixner
    Cc: John Stultz
    Signed-off-by: Zhuo-hao Lee
    [jstultz: Tweak commit subject & formatting slightly]
    Signed-off-by: John Stultz

    zhuo-hao
     

22 Apr, 2015

2 commits

  • We want to get rid of the hrtimer_start() return value and the alarm
    timer return value is nowhere used. Remove it.

    Signed-off-by: Thomas Gleixner
    Acked-by: Peter Zijlstra
    Cc: Preeti U Murthy
    Cc: Viresh Kumar
    Cc: Marcelo Tosatti
    Cc: Frederic Weisbecker
    Cc: John Stultz
    Link: http://lkml.kernel.org/r/20150414203503.243910615@linutronix.de
    Signed-off-by: Thomas Gleixner

    Thomas Gleixner
     
  • The resolution is directly accessible now. So its simpler just to fill
    in the values of the timespec and be done with it.

    Text size reduction (combined with "hrtimer: Get rid of the resolution
    field in hrtimer_clock_base"):
    x8664 -61, i386 -221, ARM -60, power64 -48

    Signed-off-by: Thomas Gleixner
    Acked-by: Peter Zijlstra
    Cc: Preeti U Murthy
    Cc: Viresh Kumar
    Cc: Marcelo Tosatti
    Cc: Frederic Weisbecker
    Link: http://lkml.kernel.org/r/20150414203500.879888080@linutronix.de
    Signed-off-by: Thomas Gleixner

    Thomas Gleixner
     

13 Feb, 2015

1 commit

  • If an attacker can cause a controlled kernel stack overflow, overwriting
    the restart block is a very juicy exploit target. This is because the
    restart_block is held in the same memory allocation as the kernel stack.

    Moving the restart block to struct task_struct prevents this exploit by
    making the restart_block harder to locate.

    Note that there are other fields in thread_info that are also easy
    targets, at least on some architectures.

    It's also a decent simplification, since the restart code is more or less
    identical on all architectures.

    [james.hogan@imgtec.com: metag: align thread_info::supervisor_stack]
    Signed-off-by: Andy Lutomirski
    Cc: Thomas Gleixner
    Cc: Al Viro
    Cc: "H. Peter Anvin"
    Cc: Ingo Molnar
    Cc: Kees Cook
    Cc: David Miller
    Acked-by: Richard Weinberger
    Cc: Richard Henderson
    Cc: Ivan Kokshaysky
    Cc: Matt Turner
    Cc: Vineet Gupta
    Cc: Russell King
    Cc: Catalin Marinas
    Cc: Will Deacon
    Cc: Haavard Skinnemoen
    Cc: Hans-Christian Egtvedt
    Cc: Steven Miao
    Cc: Mark Salter
    Cc: Aurelien Jacquiot
    Cc: Mikael Starvik
    Cc: Jesper Nilsson
    Cc: David Howells
    Cc: Richard Kuo
    Cc: "Luck, Tony"
    Cc: Geert Uytterhoeven
    Cc: Michal Simek
    Cc: Ralf Baechle
    Cc: Jonas Bonn
    Cc: "James E.J. Bottomley"
    Cc: Helge Deller
    Cc: Benjamin Herrenschmidt
    Cc: Paul Mackerras
    Acked-by: Michael Ellerman (powerpc)
    Tested-by: Michael Ellerman (powerpc)
    Cc: Martin Schwidefsky
    Cc: Heiko Carstens
    Cc: Chen Liqin
    Cc: Lennox Wu
    Cc: Chris Metcalf
    Cc: Guan Xuetao
    Cc: Chris Zankel
    Cc: Max Filippov
    Cc: Oleg Nesterov
    Cc: Guenter Roeck
    Signed-off-by: James Hogan
    Signed-off-by: Andrew Morton
    Signed-off-by: Linus Torvalds

    Andy Lutomirski
     

13 Sep, 2014

3 commits

  • Locks the k_itimer's it_lock member when handling the alarm timer's
    expiry callback.

    The regular posix timers defined in posix-timers.c have this lock held
    during timout processing because their callbacks are routed through
    posix_timer_fn(). The alarm timers follow a different path, so they
    ought to grab the lock somewhere else.

    Cc: stable@vger.kernel.org
    Cc: Thomas Gleixner
    Cc: Ingo Molnar
    Cc: Richard Cochran
    Cc: Prarit Bhargava
    Cc: Sharvil Nanavati
    Signed-off-by: Richard Larocque
    Signed-off-by: John Stultz

    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
    Cc: Ingo Molnar
    Cc: Richard Cochran
    Cc: Prarit Bhargava
    Cc: Sharvil Nanavati
    Signed-off-by: Richard Larocque
    Signed-off-by: John Stultz

    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
    Cc: Ingo Molnar
    Cc: Richard Cochran
    Cc: Prarit Bhargava
    Cc: Sharvil Nanavati
    Signed-off-by: Richard Larocque
    [jstultz: minor style tweak]
    Signed-off-by: John Stultz

    Richard Larocque
     

05 Aug, 2014

1 commit

  • Pull staging driver updates from Greg KH:
    "Here's the big pull request for the staging driver tree for 3.17-rc1.

    Lots of things in here, over 2000 patches, but the best part is this:
    1480 files changed, 39070 insertions(+), 254659 deletions(-)

    Thanks to the great work of Kristina Martšenko, 14 different staging
    drivers have been removed from the tree as they were obsolete and no
    one was willing to work on cleaning them up. Other than the driver
    removals, loads of cleanups are in here (comedi, lustre, etc.) as well
    as the usual IIO driver updates and additions.

    All of this has been in the linux-next tree for a while"

    * tag 'staging-3.17-rc1' of git://git.kernel.org/pub/scm/linux/kernel/git/gregkh/staging: (2199 commits)
    staging: comedi: addi_apci_1564: remove diagnostic interrupt support code
    staging: comedi: addi_apci_1564: add subdevice to check diagnostic status
    staging: wlan-ng: coding style problem fix
    staging: wlan-ng: fixing coding style problems
    staging: comedi: ii_pci20kc: request and ioremap memory
    staging: lustre: bitwise vs logical typo
    staging: dgnc: Remove unneeded dgnc_trace.c and dgnc_trace.h
    staging: dgnc: rephrase comment
    staging: comedi: ni_tio: remove some dead code
    staging: rtl8723au: Fix static symbol sparse warning
    staging: rtl8723au: usb_dvobj_init(): Remove unused variable 'pdev_desc'
    staging: rtl8723au: Do not duplicate kernel provided USB macros
    staging: rtl8723au: Remove never set struct pwrctrl_priv.bHWPowerdown
    staging: rtl8723au: Remove two never set variables
    staging: rtl8723au: RSSI_test is never set
    staging:r8190: coding style: Fixed checkpatch reported Error
    staging:r8180: coding style: Fixed too long lines
    staging:r8180: coding style: Fixed commenting style
    staging: lustre: ptlrpc: lproc_ptlrpc.c - fix dereferenceing user space buffer
    staging: lustre: ldlm: ldlm_resource.c - fix dereferenceing user space buffer
    ...

    Linus Torvalds
     

08 Jul, 2014

1 commit

  • Sharvil noticed with the posix timer_settime interface, using the
    CLOCK_REALTIME_ALARM or CLOCK_BOOTTIME_ALARM clockid, if the users
    tried to specify a relative time timer, it would incorrectly be
    treated as absolute regardless of the state of the flags argument.

    This patch corrects this, properly checking the absolute/relative flag,
    as well as adds further error checking that no invalid flag bits are set.

    Reported-by: Sharvil Nanavati
    Signed-off-by: John Stultz
    Cc: Thomas Gleixner
    Cc: Ingo Molnar
    Cc: Prarit Bhargava
    Cc: Sharvil Nanavati
    Cc: stable #3.0+
    Link: http://lkml.kernel.org/r/1404767171-6902-1-git-send-email-john.stultz@linaro.org
    Signed-off-by: Thomas Gleixner

    John Stultz
     

20 Jun, 2014

1 commit


19 Oct, 2013

1 commit

  • Fedora Ruby maintainer reported latest Ruby doesn't work on Fedora Rawhide
    on ARM. (http://bugs.ruby-lang.org/issues/9008)

    Because of, commit 1c6b39ad3f (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
    Cc: Frederic Weisbecker
    Cc: stable #3.0 and up
    Reported-by: Vit Ondruch
    Signed-off-by: KOSAKI Motohiro
    [jstultz: Tweaks to commit message to include full rational]
    Signed-off-by: John Stultz

    KOSAKI Motohiro
     

13 Jun, 2013

1 commit


30 May, 2013

1 commit

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

    Todd Poynor
     

25 Sep, 2012

3 commits

  • Now that alarmtimer_remove has been simplified, change
    its name to _dequeue to better match its paired _enqueue
    function.

    Cc: Arve Hjønnevåg
    Cc: Colin Cross
    Cc: Thomas Gleixner
    Signed-off-by: John Stultz

    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
    Cc: Colin Cross
    Cc: Thomas Gleixner
    Reported-by: Arve Hjønnevåg
    Tested-by: Arve Hjønnevåg
    Signed-off-by: John Stultz

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

    Todd Poynor
     

21 Apr, 2012

1 commit

  • The Android alarm interface provides a settime call that sets both
    the alarmtimer RTC device and CLOCK_REALTIME to the same value.

    Since there may be multiple rtc devices, provide a hook to access the
    one the alarmtimer infrastructure is using.

    CC: Colin Cross
    CC: Thomas Gleixner
    CC: Android Kernel Team
    Signed-off-by: John Stultz
    Signed-off-by: Greg Kroah-Hartman

    John Stultz
     

24 Mar, 2012

2 commits


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