1. 11 4月, 2013 1 次提交
  2. 09 4月, 2013 2 次提交
    • D
      hrtimer: Fix ktime_add_ns() overflow on 32bit architectures · 51fd36f3
      David Engraf 提交于
      One can trigger an overflow when using ktime_add_ns() on a 32bit
      architecture not supporting CONFIG_KTIME_SCALAR.
      
      When passing a very high value for u64 nsec, e.g. 7881299347898368000
      the do_div() function converts this value to seconds (7881299347) which
      is still to high to pass to the ktime_set() function as long. The result
      in is a negative value.
      
      The problem on my system occurs in the tick-sched.c,
      tick_nohz_stop_sched_tick() when time_delta is set to
      timekeeping_max_deferment(). The check for time_delta < KTIME_MAX is
      valid, thus ktime_add_ns() is called with a too large value resulting in
      a negative expire value. This leads to an endless loop in the ticker code:
      
      time_delta: 7881299347898368000
      expires = ktime_add_ns(last_update, time_delta)
      expires: negative value
      
      This fix caps the value to KTIME_MAX.
      
      This error doesn't occurs on 64bit or architectures supporting
      CONFIG_KTIME_SCALAR (e.g. ARM, x86-32).
      
      Cc: stable@vger.kernel.org
      Signed-off-by: NDavid Engraf <david.engraf@sysgo.com>
      [jstultz: Minor tweaks to commit message & header]
      Signed-off-by: NJohn Stultz <john.stultz@linaro.org>
      51fd36f3
    • P
      hrtimer: Add expiry time overflow check in hrtimer_interrupt · 8f294b5a
      Prarit Bhargava 提交于
      The settimeofday01 test in the LTP testsuite effectively does
      
              gettimeofday(current time);
              settimeofday(Jan 1, 1970 + 100 seconds);
              settimeofday(current time);
      
      This test causes a stack trace to be displayed on the console during the
      setting of timeofday to Jan 1, 1970 + 100 seconds:
      
      [  131.066751] ------------[ cut here ]------------
      [  131.096448] WARNING: at kernel/time/clockevents.c:209 clockevents_program_event+0x135/0x140()
      [  131.104935] Hardware name: Dinar
      [  131.108150] Modules linked in: sg nfsv3 nfs_acl nfsv4 auth_rpcgss nfs dns_resolver fscache lockd sunrpc nf_conntrack_netbios_ns nf_conntrack_broadcast ipt_MASQUERADE ip6table_mangle ip6t_REJECT nf_conntrack_ipv6 nf_defrag_ipv6 iptable_nat nf_nat_ipv4 nf_nat iptable_mangle ipt_REJECT nf_conntrack_ipv4 nf_defrag_ipv4 xt_conntrack nf_conntrack ebtable_filter ebtables ip6table_filter ip6_tables iptable_filter ip_tables kvm_amd kvm sp5100_tco bnx2 i2c_piix4 crc32c_intel k10temp fam15h_power ghash_clmulni_intel amd64_edac_mod pcspkr serio_raw edac_mce_amd edac_core microcode xfs libcrc32c sr_mod sd_mod cdrom ata_generic crc_t10dif pata_acpi radeon i2c_algo_bit drm_kms_helper ttm drm ahci pata_atiixp libahci libata usb_storage i2c_core dm_mirror dm_region_hash dm_log dm_mod
      [  131.176784] Pid: 0, comm: swapper/28 Not tainted 3.8.0+ #6
      [  131.182248] Call Trace:
      [  131.184684]  <IRQ>  [<ffffffff810612af>] warn_slowpath_common+0x7f/0xc0
      [  131.191312]  [<ffffffff8106130a>] warn_slowpath_null+0x1a/0x20
      [  131.197131]  [<ffffffff810b9fd5>] clockevents_program_event+0x135/0x140
      [  131.203721]  [<ffffffff810bb584>] tick_program_event+0x24/0x30
      [  131.209534]  [<ffffffff81089ab1>] hrtimer_interrupt+0x131/0x230
      [  131.215437]  [<ffffffff814b9600>] ? cpufreq_p4_target+0x130/0x130
      [  131.221509]  [<ffffffff81619119>] smp_apic_timer_interrupt+0x69/0x99
      [  131.227839]  [<ffffffff8161805d>] apic_timer_interrupt+0x6d/0x80
      [  131.233816]  <EOI>  [<ffffffff81099745>] ? sched_clock_cpu+0xc5/0x120
      [  131.240267]  [<ffffffff814b9ff0>] ? cpuidle_wrap_enter+0x50/0xa0
      [  131.246252]  [<ffffffff814b9fe9>] ? cpuidle_wrap_enter+0x49/0xa0
      [  131.252238]  [<ffffffff814ba050>] cpuidle_enter_tk+0x10/0x20
      [  131.257877]  [<ffffffff814b9c89>] cpuidle_idle_call+0xa9/0x260
      [  131.263692]  [<ffffffff8101c42f>] cpu_idle+0xaf/0x120
      [  131.268727]  [<ffffffff815f8971>] start_secondary+0x255/0x257
      [  131.274449] ---[ end trace 1151a50552231615 ]---
      
      When we change the system time to a low value like this, the value of
      timekeeper->offs_real will be a negative value.
      
      It seems that the WARN occurs because an hrtimer has been started in the time
      between the releasing of the timekeeper lock and the IPI call (via a call to
      on_each_cpu) in clock_was_set() in the do_settimeofday() code.  The end result
      is that a REALTIME_CLOCK timer has been added with softexpires = expires =
      KTIME_MAX.  The hrtimer_interrupt() fires/is called and the loop at
      kernel/hrtimer.c:1289 is executed.  In this loop the code subtracts the
      clock base's offset (which was set to timekeeper->offs_real in
      do_settimeofday()) from the current hrtimer_cpu_base->expiry value (which
      was KTIME_MAX):
      
      	KTIME_MAX - (a negative value) = overflow
      
      A simple check for an overflow can resolve this problem.  Using KTIME_MAX
      instead of the overflow value will result in the hrtimer function being run,
      and the reprogramming of the timer after that.
      
      Cc: Thomas Gleixner <tglx@linutronix.de>
      Cc: stable@vger.kernel.org
      Reviewed-by: NRik van Riel <riel@redhat.com>
      Signed-off-by: NPrarit Bhargava <prarit@redhat.com>
      [jstultz: Tweaked commit subject]
      Signed-off-by: NJohn Stultz <john.stultz@linaro.org>
      8f294b5a
  3. 05 4月, 2013 12 次提交
  4. 03 4月, 2013 1 次提交
  5. 29 3月, 2013 1 次提交
    • C
      ARM: bcm281xx: Add timer driver (driver portion) · 8011657b
      Christian Daudt 提交于
      This adds support for the Broadcom timer, used in the following SoCs:
      BCM11130, BCM11140, BCM11351, BCM28145, BCM28155
      
      Updates from V6:
      - Split DT portion into a separate patch
      
      Updates from V5:
      - Rebase to latest arm-soc/for-next
      
      Updates from V4:
      - Switch code to use CLOCKSOURCE_OF_DECLARE
      
      Updates from V3:
      - Migrate to 3.9 timer framework updates
      
      Updates from V2:
      - prepend static fns + fields with kona_
      
      Updates from V1:
      - Rename bcm_timer.c to bcm_kona_timer.c
      - Pull .h into bcm_kona_timer.c
      - Make timers static
      - Clean up comment block
      - Switched to using clockevents_config_and_register
      - Added an error to the get_timer loop if it repeats too much
      - Added to Documentation/devicetree/bindings/arm/bcm/bcm,kona-timer.txt
      - Added missing readl to timer_disable_and_clear
      
      Note: bcm,kona-timer was kept as the 'compatible' field to make it
      specific enough for when there are multiple bcm timers (bcm,timer is
      too generic).
      Signed-off-by: NChristian Daudt <csd@broadcom.com>
      Acked-by: NArnd Bergmann <arnd@arndb.de>
      Acked-by: NJohn Stultz <john.stultz@linaro.org>
      Reviewed-by: NStephen Warren <swarren@nvidia.com>
      Signed-off-by: NJohn Stultz <john.stultz@linaro.org>
      8011657b
  6. 26 3月, 2013 1 次提交
  7. 25 3月, 2013 2 次提交
  8. 23 3月, 2013 7 次提交
  9. 22 3月, 2013 1 次提交
  10. 16 3月, 2013 7 次提交
    • F
      timekeeping: utilize the suspend-nonstop clocksource to count suspended time · e445cf1c
      Feng Tang 提交于
      There are some new processors whose TSC clocksource won't stop during
      suspend. Currently, after system resumes, kernel will use persistent
      clock or RTC to compensate the sleep time, but with these nonstop
      clocksources, we could skip the special compensation from external
      sources, and just use current clocksource for time recounting.
      
      This can solve some time drift bugs caused by some not-so-accurate or
      error-prone RTC devices.
      
      The current way to count suspended time is first try to use the persistent
      clock, and then try the RTC if persistent clock can't be used. This
      patch will change the trying order to:
      	suspend-nonstop clocksource -> persistent clock -> RTC
      
      When counting the sleep time with nonstop clocksource, use an accurate way
      suggested by Jason Gunthorpe to cover very large delta cycles.
      Signed-off-by: NFeng Tang <feng.tang@intel.com>
      [jstultz: Small optimization, avoiding re-reading the clocksource]
      Signed-off-by: NJohn Stultz <john.stultz@linaro.org>
      e445cf1c
    • F
      x86: tsc: Add support for new S3_NONSTOP feature · 82f9c080
      Feng Tang 提交于
      Add support for new S3_NONSTOP feature
      Signed-off-by: NFeng Tang <feng.tang@intel.com>
      Signed-off-by: NJohn Stultz <john.stultz@linaro.org>
      82f9c080
    • F
      clocksource: Add new feature flag CLOCK_SOURCE_SUSPEND_NONSTOP · 5caf4636
      Feng Tang 提交于
      Some x86 processors have a TSC clocksource, which continues to run
      even when system is suspended. Also most OMAP platforms have a
      32 KHz timer which has similar capability. Add a feature flag so that
      it could be utilized.
      Signed-off-by: NFeng Tang <feng.tang@intel.com>
      Signed-off-by: NJohn Stultz <john.stultz@linaro.org>
      5caf4636
    • F
      x86: Add cpu capability flag X86_FEATURE_NONSTOP_TSC_S3 · c54fdbb2
      Feng Tang 提交于
      On some new Intel Atom processors (Penwell and Cloverview), there is
      a feature that the TSC won't stop in S3 state, say the TSC value
      won't be reset to 0 after resume. This feature makes TSC a more reliable
      clocksource and could benefit the timekeeping code during system
      suspend/resume cycle, so add a flag for it.
      Signed-off-by: NFeng Tang <feng.tang@intel.com>
      [jstultz: Fix checkpatch warning]
      Signed-off-by: NJohn Stultz <john.stultz@linaro.org>
      c54fdbb2
    • P
      x86: Do full rtc synchronization with ntp · 3195ef59
      Prarit Bhargava 提交于
      Every 11 minutes ntp attempts to update the x86 rtc with the current
      system time.  Currently, the x86 code only updates the rtc if the system
      time is within +/-15 minutes of the current value of the rtc. This
      was done originally to avoid setting the RTC if the RTC was in localtime
      mode (common with Windows dualbooting).  Other architectures do a full
      synchronization and now that we have better infrastructure to detect
      when the RTC is in localtime, there is no reason that x86 should be
      software limited to a 30 minute window.
      
      This patch changes the behavior of the kernel to do a full synchronization
      (year, month, day, hour, minute, and second) of the rtc when ntp requests
      a synchronization between the system time and the rtc.
      
      I've used the RTC library functions in this patchset as they do all the
      required bounds checking.
      
      Cc: Thomas Gleixner <tglx@linutronix.de>
      Cc: John Stultz <john.stultz@linaro.org>
      Cc: x86@kernel.org
      Cc: Matt Fleming <matt.fleming@intel.com>
      Cc: David Vrabel <david.vrabel@citrix.com>
      Cc: Andrew Morton <akpm@linux-foundation.org>
      Cc: Andi Kleen <ak@linux.intel.com>
      Cc: linux-efi@vger.kernel.org
      Signed-off-by: NPrarit Bhargava <prarit@redhat.com>
      [jstultz: Tweak commit message, fold in build fix found by fengguang
      Also add select RTC_LIB to X86, per new dependency, as found by prarit]
      Signed-off-by: NJohn Stultz <john.stultz@linaro.org>
      3195ef59
    • J
      timekeeping: Use inject_offset in warp_clock · 7859e404
      John Stultz 提交于
      When warping the clock (from a local time RTC), use
      timekeeping_inject_offset() to atomically add the offset.
      
      This avoids any minor time error caused by the delay between
      reading the time, and then setting the adjusted time.
      Signed-off-by: NJohn Stultz <john.stultz@linaro.org>
      7859e404
    • D
      timekeeping: Avoid adjust kernel time once hwclock kept in UTC time · c30bd099
      Dong Zhu 提交于
      If the Hardware Clock kept in local time,kernel will adjust the time
      to be UTC time.But if Hardware Clock kept in UTC time,system will make
      a dummy settimeofday call first (sys_tz.tz_minuteswest = 0) to make sure
      the time is not shifted,so at this point I think maybe it is not necessary
      to set the kernel time once the sys_tz.tz_minuteswest is zero.
      Signed-off-by: NDong Zhu <bluezhudong@gmail.com>
      [jstultz: Updated to merge with conflicting changes ]
      Signed-off-by: NJohn Stultz <john.stultz@linaro.org>
      c30bd099
  11. 13 3月, 2013 5 次提交