1. 25 8月, 2020 1 次提交
  2. 28 6月, 2020 2 次提交
    • S
      clocksource: dw_apb_timer_of: Fix missing clockevent timers · c685febe
      Serge Semin 提交于
      [ Upstream commit 6d2e16a3181bafb77b535095c39ad1c8b9558c8c ]
      
      Commit 10021488 ("clocksource: dw_apb_timer_of: use
      clocksource_of_init") replaced a publicly available driver
      initialization method with one called by the timer_probe() method
      available after CLKSRC_OF. In current implementation it traverses
      all the timers available in the system and calls their initialization
      methods if corresponding devices were either in dtb or in acpi. But
      if before the commit any number of available timers would be installed
      as clockevent and clocksource devices, after that there would be at most
      two. The rest are just ignored since default case branch doesn't do
      anything. I don't see a reason of such behaviour, neither the commit
      message explains it. Moreover this might be wrong if on some platforms
      these timers might be used for different purpose, as virtually CPU-local
      clockevent timers and as an independent broadcast timer. So in order
      to keep the compatibility with the platforms where the order of the
      timers detection has some meaning, lets add the secondly discovered
      timer to be of clocksource/sched_clock type, while the very first and
      the others would provide the clockevents service.
      
      Fixes: 10021488 ("clocksource: dw_apb_timer_of: use clocksource_of_init")
      Signed-off-by: NSerge Semin <Sergey.Semin@baikalelectronics.ru>
      Cc: Alexey Malahov <Alexey.Malahov@baikalelectronics.ru>
      Cc: Thomas Bogendoerfer <tsbogend@alpha.franken.de>
      Cc: Paul Burton <paulburton@kernel.org>
      Cc: Ralf Baechle <ralf@linux-mips.org>
      Cc: Alessandro Zummo <a.zummo@towertech.it>
      Cc: Alexandre Belloni <alexandre.belloni@bootlin.com>
      Cc: Arnd Bergmann <arnd@arndb.de>
      Cc: Rob Herring <robh+dt@kernel.org>
      Cc: linux-mips@vger.kernel.org
      Cc: linux-rtc@vger.kernel.org
      Cc: devicetree@vger.kernel.org
      Signed-off-by: NDaniel Lezcano <daniel.lezcano@linaro.org>
      Link: https://lore.kernel.org/r/20200521204818.25436-7-Sergey.Semin@baikalelectronics.ruSigned-off-by: NSasha Levin <sashal@kernel.org>
      Signed-off-by: NYang Yingliang <yangyingliang@huawei.com>
      c685febe
    • S
      clocksource: dw_apb_timer: Make CPU-affiliation being optional · b32b31cd
      Serge Semin 提交于
      [ Upstream commit cee43dbf2ee3f430434e2b66994eff8a1aeda889 ]
      
      Currently the DW APB Timer driver binds each clockevent timers to a
      particular CPU. This isn't good for multiple reasons. First of all seeing
      the device is placed on APB bus (which makes it accessible from any CPU
      core), accessible over MMIO and having the DYNIRQ flag set we can be sure
      that manually binding the timer to any CPU just isn't correct. By doing
      so we just set an extra limitation on device usage. This also doesn't
      reflect the device actual capability, since by setting the IRQ affinity
      we can make it virtually local to any CPU. Secondly imagine if you had a
      real CPU-local timer with the same rating and the same CPU-affinity.
      In this case if DW APB timer was registered first, then due to the
      clockevent framework tick-timer selection procedure we'll end up with the
      real CPU-local timer being left unselected for clock-events tracking. But
      on most of the platforms (MIPS/ARM/etc) such timers are normally embedded
      into the CPU core and are accessible with much better performance then
      devices placed on APB. For instance in MIPS architectures there is
      r4k-timer, which is CPU-local, assigned with the same rating, and normally
      its clockevent device is registered after the platform-specific one.
      
      So in order to fix all of these issues let's make the DW APB Timer CPU
      affinity being optional and deactivated by passing a negative CPU id,
      which will effectively set the DW APB clockevent timer cpumask to
      'cpu_possible_mask'.
      Signed-off-by: NSerge Semin <Sergey.Semin@baikalelectronics.ru>
      Cc: Alexey Malahov <Alexey.Malahov@baikalelectronics.ru>
      Cc: Thomas Bogendoerfer <tsbogend@alpha.franken.de>
      Cc: Paul Burton <paulburton@kernel.org>
      Cc: Ralf Baechle <ralf@linux-mips.org>
      Cc: Alessandro Zummo <a.zummo@towertech.it>
      Cc: Alexandre Belloni <alexandre.belloni@bootlin.com>
      Cc: Arnd Bergmann <arnd@arndb.de>
      Cc: Rob Herring <robh+dt@kernel.org>
      Cc: linux-mips@vger.kernel.org
      Cc: linux-rtc@vger.kernel.org
      Cc: devicetree@vger.kernel.org
      Signed-off-by: NDaniel Lezcano <daniel.lezcano@linaro.org>
      Link: https://lore.kernel.org/r/20200521204818.25436-5-Sergey.Semin@baikalelectronics.ruSigned-off-by: NSasha Levin <sashal@kernel.org>
      Signed-off-by: NYang Yingliang <yangyingliang@huawei.com>
      b32b31cd
  3. 17 4月, 2020 1 次提交
  4. 16 4月, 2020 3 次提交
  5. 15 4月, 2020 2 次提交
  6. 14 4月, 2020 2 次提交
    • T
      clocksource/drivers/fttmr010: Fix invalid interrupt register access · 4acd2201
      Tao Ren 提交于
      [ Upstream commit 86fe57fc47b17b3528fa5497fc57e158d846c4ea ]
      
      TIMER_INTR_MASK register (Base Address of Timer + 0x38) is not designed
      for masking interrupts on ast2500 chips, and it's not even listed in
      ast2400 datasheet, so it's not safe to access TIMER_INTR_MASK on aspeed
      chips.
      
      Similarly, TIMER_INTR_STATE register (Base Address of Timer + 0x34) is
      not interrupt status register on ast2400 and ast2500 chips. Although
      there is no side effect to reset the register in fttmr010_common_init(),
      it's just misleading to do so.
      
      Besides, "count_down" is renamed to "is_aspeed" in "fttmr010" structure,
      and more comments are added so the code is more readble.
      Signed-off-by: NTao Ren <taoren@fb.com>
      Reviewed-by: NLinus Walleij <linus.walleij@linaro.org>
      Signed-off-by: NDaniel Lezcano <daniel.lezcano@linaro.org>
      Signed-off-by: NSasha Levin <sashal@kernel.org>
      Signed-off-by: NYang Yingliang <yangyingliang@huawei.com>
      4acd2201
    • F
      clocksource/drivers/mediatek: Fix error handling · 3ea8be1f
      Fabien Parent 提交于
      [ Upstream commit 41d49e7939de5ec532d86494185b2ca2e99c848a ]
      
      When timer_of_init fails, it cleans up after itself by undoing
      everything it did during the initialization function.
      
      mtk_syst_init and mtk_gpt_init both call timer_of_cleanup if
      timer_of_init fails. timer_of_cleanup try to release the resource
      taken.  Since these resources have already been cleaned up by
      timer_of_init, we end up getting a few warnings printed:
      
      [    0.001935] WARNING: CPU: 0 PID: 0 at __clk_put+0xe8/0x128
      [    0.002650] Modules linked in:
      [    0.003058] CPU: 0 PID: 0 Comm: swapper/0 Not tainted 4.19.67+ #1
      [    0.003852] Hardware name: MediaTek MT8183 (DT)
      [    0.004446] pstate: 20400085 (nzCv daIf +PAN -UAO)
      [    0.005073] pc : __clk_put+0xe8/0x128
      [    0.005555] lr : clk_put+0xc/0x14
      [    0.005988] sp : ffffff80090b3ea0
      [    0.006422] x29: ffffff80090b3ea0 x28: 0000000040e20018
      [    0.007121] x27: ffffffc07bfff780 x26: 0000000000000001
      [    0.007819] x25: ffffff80090bda80 x24: ffffff8008ec5828
      [    0.008517] x23: ffffff80090bd000 x22: ffffff8008d8b2e8
      [    0.009216] x21: 0000000000000001 x20: fffffffffffffdfb
      [    0.009914] x19: ffffff8009166180 x18: 00000000002bffa8
      [    0.010612] x17: ffffffc012996980 x16: 0000000000000000
      [    0.011311] x15: ffffffbf004a6800 x14: 3536343038393334
      [    0.012009] x13: 2079726576652073 x12: 7eb9c62c5c38f100
      [    0.012707] x11: ffffff80090b3ba0 x10: ffffff80090b3ba0
      [    0.013405] x9 : 0000000000000004 x8 : 0000000000000040
      [    0.014103] x7 : ffffffc079400270 x6 : 0000000000000000
      [    0.014801] x5 : ffffffc079400248 x4 : 0000000000000000
      [    0.015499] x3 : 0000000000000000 x2 : 0000000000000000
      [    0.016197] x1 : ffffff80091661c0 x0 : fffffffffffffdfb
      [    0.016896] Call trace:
      [    0.017218]  __clk_put+0xe8/0x128
      [    0.017654]  clk_put+0xc/0x14
      [    0.018048]  timer_of_cleanup+0x60/0x7c
      [    0.018551]  mtk_syst_init+0x8c/0x9c
      [    0.019020]  timer_probe+0x6c/0xe0
      [    0.019469]  time_init+0x14/0x44
      [    0.019893]  start_kernel+0x2d0/0x46c
      [    0.020378] ---[ end trace 8c1efabea1267649 ]---
      [    0.020982] ------------[ cut here ]------------
      [    0.021586] Trying to vfree() nonexistent vm area ((____ptrval____))
      [    0.022427] WARNING: CPU: 0 PID: 0 at __vunmap+0xd0/0xd8
      [    0.023119] Modules linked in:
      [    0.023524] CPU: 0 PID: 0 Comm: swapper/0 Tainted: G        W         4.19.67+ #1
      [    0.024498] Hardware name: MediaTek MT8183 (DT)
      [    0.025091] pstate: 60400085 (nZCv daIf +PAN -UAO)
      [    0.025718] pc : __vunmap+0xd0/0xd8
      [    0.026176] lr : __vunmap+0xd0/0xd8
      [    0.026632] sp : ffffff80090b3e90
      [    0.027066] x29: ffffff80090b3e90 x28: 0000000040e20018
      [    0.027764] x27: ffffffc07bfff780 x26: 0000000000000001
      [    0.028462] x25: ffffff80090bda80 x24: ffffff8008ec5828
      [    0.029160] x23: ffffff80090bd000 x22: ffffff8008d8b2e8
      [    0.029858] x21: 0000000000000000 x20: 0000000000000000
      [    0.030556] x19: ffffff800800d000 x18: 00000000002bffa8
      [    0.031254] x17: 0000000000000000 x16: 0000000000000000
      [    0.031952] x15: ffffffbf004a6800 x14: 3536343038393334
      [    0.032651] x13: 2079726576652073 x12: 7eb9c62c5c38f100
      [    0.033349] x11: ffffff80090b3b40 x10: ffffff80090b3b40
      [    0.034047] x9 : 0000000000000005 x8 : 5f5f6c6176727470
      [    0.034745] x7 : 5f5f5f5f28282061 x6 : ffffff80091c86ef
      [    0.035443] x5 : ffffff800852b690 x4 : 0000000000000000
      [    0.036141] x3 : 0000000000000002 x2 : 0000000000000002
      [    0.036839] x1 : 7eb9c62c5c38f100 x0 : 7eb9c62c5c38f100
      [    0.037536] Call trace:
      [    0.037859]  __vunmap+0xd0/0xd8
      [    0.038271]  vunmap+0x24/0x30
      [    0.038664]  __iounmap+0x2c/0x34
      [    0.039088]  timer_of_cleanup+0x70/0x7c
      [    0.039591]  mtk_syst_init+0x8c/0x9c
      [    0.040060]  timer_probe+0x6c/0xe0
      [    0.040507]  time_init+0x14/0x44
      [    0.040932]  start_kernel+0x2d0/0x46c
      
      This commit remove the calls to timer_of_cleanup when timer_of_init
      fails since it is unnecessary and actually cause warnings to be printed.
      
      Fixes: a0858f93 ("mediatek: Convert the driver to timer-of")
      Signed-off-by: NFabien Parent <fparent@baylibre.com>
      Signed-off-by: NDaniel Lezcano <daniel.lezcano@linaro.org>
      Link: https://lore.kernel.org/linux-arm-kernel/20190919191315.25190-1-fparent@baylibre.com/Signed-off-by: NSasha Levin <sashal@kernel.org>
      Signed-off-by: NYang Yingliang <yangyingliang@huawei.com>
      3ea8be1f
  7. 27 12月, 2019 15 次提交
    • S
      clocksource/drivers/sh_cmt: Fix clocksource width for 32-bit machines · debe0740
      Sergei Shtylyov 提交于
      [ Upstream commit 37e7742c55ba856eaec7e35673ee370f36eb17f3 ]
      
      The driver seems to abuse *unsigned long* not only for the (32-bit)
      register values but also for the 'sh_cmt_channel::total_cycles' which
      needs to always be 64-bit -- as a result, the clocksource's mask is
      needlessly clamped down to 32-bits on the 32-bit machines...
      
      Fixes: 19bdc9d0 ("clocksource: sh_cmt clocksource support")
      Reported-by: NGeert Uytterhoeven <geert@linux-m68k.org>
      Signed-off-by: NSergei Shtylyov <sergei.shtylyov@cogentembedded.com>
      Reviewed-by: NSimon Horman <horms+renesas@verge.net.au>
      Reviewed-by: NGeert Uytterhoeven <geert+renesas@glider.be>
      Signed-off-by: NDaniel Lezcano <daniel.lezcano@linaro.org>
      Signed-off-by: NSasha Levin <sashal@kernel.org>
      Signed-off-by: NYang Yingliang <yangyingliang@huawei.com>
      debe0740
    • S
      clocksource/drivers/sh_cmt: Fixup for 64-bit machines · 43c29618
      Sergei Shtylyov 提交于
      [ Upstream commit 22627c6f3ed3d9d0df13eec3c831b08f8186c38e ]
      
      When trying to use CMT for clockevents on R-Car gen3 SoCs, I noticed
      that 'max_delta_ns' for the broadcast timer (CMT) was shown as 1000 in
      /proc/timer_list. It turned out that when calculating it, the driver did
      1 << 32 (causing what I think was undefined behavior) resulting in a zero
      delta, later clamped to 1000 by cev_delta2ns(). The root cause turned out
      to be that the driver abused *unsigned long* for the CMT register values
      (which are 16/32-bit), so that the calculation of 'ch->max_match_value'
      in sh_cmt_setup_channel() used the wrong branch. Using more proper 'u32'
      instead fixed 'max_delta_ns' and even fixed the switching an active
      clocksource to CMT (which caused the system to turn non-interactive
      before).
      Signed-off-by: NSergei Shtylyov <sergei.shtylyov@cogentembedded.com>
      Reviewed-by: NGeert Uytterhoeven <geert+renesas@glider.be>
      Signed-off-by: NDaniel Lezcano <daniel.lezcano@linaro.org>
      Signed-off-by: NSasha Levin <sashal@kernel.org>
      Signed-off-by: NYang Yingliang <yangyingliang@huawei.com>
      43c29618
    • Y
      arm64: vdso: move vdso_fix into struct vdso_data · d6b00d6c
      Yang Yingliang 提交于
      hulk inclusion
      category: bugfix
      bugzilla: 16082
      CVE: NA
      
      -------------------------------------------------
      
      Using static key type may cause segmentation fault in bionic,
      change type of vdso_fix to bool and move it int struct vdso_data.
      
      On Hi1620,
      without this patch, gettimeofday costs 0.02775:
      ./gettimeofday -E -C 200 -L -S -W -N "gettimeofday"
      Running:        gettimeofday# ./gettimeofday -E -C 200 -L -S -W -N gettimeofday
                   prc thr   usecs/call      samples   errors cnt/samp
      gettimeofday   1   1      0.02775          174        0    20000
      
      with this patch, gettimeofday costs 0.02701:
      ./gettimeofday -E -C 200 -L -S -W -N "gettimeofday"
      Running:        gettimeofday# ./gettimeofday -E -C 200 -L -S -W -N gettimeofday
                   prc thr   usecs/call      samples   errors cnt/samp
      gettimeofday   1   1      0.02701          170        0    20000
      
      On Hi1616,
      without this patch, gettimeofday costs 0.03396:
      ./gettimeofday -E -C 200 -L -S -W -N "gettimeofday"
      Running:        gettimeofday# ./gettimeofday -E -C 200 -L -S -W -N gettimeofday
                   prc thr   usecs/call      samples   errors cnt/samp
      gettimeofday   1   1      0.03396          194        0    20000
      
      with this patch, gettimeofday costs 0.03660:
      ./gettimeofday -E -C 200 -L -S -W -N "gettimeofday"
      Running:        gettimeofday# ./gettimeofday -E -C 200 -L -S -W -N gettimeofday
                   prc thr   usecs/call      samples   errors cnt/samp
      gettimeofday   1   1      0.03660          200        0    20000
      Signed-off-by: NYang Yingliang <yangyingliang@huawei.com>
      Reviewed-by: NXuefeng Wang <wxf.wang@hisilicon.com>
      Signed-off-by: NYang Yingliang <yangyingliang@huawei.com>
      d6b00d6c
    • M
      clocksource/drivers/exynos_mct: Increase priority over ARM arch timer · 4f5e9691
      Marek Szyprowski 提交于
      [ Upstream commit 6282edb72bed5324352522d732080d4c1b9dfed6 ]
      
      Exynos SoCs based on CA7/CA15 have 2 timer interfaces: custom Exynos MCT
      (Multi Core Timer) and standard ARM Architected Timers.
      
      There are use cases, where both timer interfaces are used simultanously.
      One of such examples is using Exynos MCT for the main system timer and
      ARM Architected Timers for the KVM and virtualized guests (KVM requires
      arch timers).
      
      Exynos Multi-Core Timer driver (exynos_mct) must be however started
      before ARM Architected Timers (arch_timer), because they both share some
      common hardware blocks (global system counter) and turning on MCT is
      needed to get ARM Architected Timer working properly.
      
      To ensure selecting Exynos MCT as the main system timer, increase MCT
      timer rating. To ensure proper starting order of both timers during
      suspend/resume cycle, increase MCT hotplug priority over ARM Archictected
      Timers.
      Signed-off-by: NMarek Szyprowski <m.szyprowski@samsung.com>
      Reviewed-by: NKrzysztof Kozlowski <krzk@kernel.org>
      Reviewed-by: NChanwoo Choi <cw00.choi@samsung.com>
      Signed-off-by: NDaniel Lezcano <daniel.lezcano@linaro.org>
      Signed-off-by: NSasha Levin <sashal@kernel.org>
      Signed-off-by: NYang Yingliang <yangyingliang@huawei.com>
      4f5e9691
    • Y
      arm64: arch_timer: Disable CNTVCT_EL0 trap if workaround is enabled · bb6a8bef
      Yang Yingliang 提交于
      hulk inclusion
      category: performance
      bugzilla: 16082
      CVE: NA
      
      -------------------------------------------------
      
      It costs very much time to read CNTVCT_EL0, if a cntvct workaround
      and CNTVCT_EL0 trap is enabled. To decrease the read time, we disable
      CNTVCT_EL0 trap and do the cntvct workaround in the VDSO by adding
      vdso_fix.
      Signed-off-by: NYang Yingliang <yangyingliang@huawei.com>
      Reviewed-by: NXuefeng Wang <wxf.wang@hisilicon.com>
      Signed-off-by: NYang Yingliang <yangyingliang@huawei.com>
      bb6a8bef
    • Y
      Revert "arm64: arch_timer: Disable CNTVCT_EL0 trap if workaround is enabled" · 8a34e087
      Yang Yingliang 提交于
      hulk inclusion
      category: performance
      bugzilla: 16082
      CVE: NA
      
      -------------------------------------------------
      
      This reverts commit 47819486652f2dc95ad1fe6a1a862a3c2971d657.
      487f18a5f1cf ("arm64: vdso: do cntvct workaround in the VDSO") and
      47819486652f ("arm64: arch_timer: Disable CNTVCT_EL0 trap if workaround is enabled")
      are not needed for now. Apply these two patches later.
      Signed-off-by: NYang Yingliang <yangyingliang@huawei.com>
      8a34e087
    • Y
      arm64: arch_timer: Disable CNTVCT_EL0 trap if workaround is enabled · 60b42e93
      Yang Yingliang 提交于
      hulk inclusion
      category: performance
      bugzilla: 16082
      CVE: NA
      
      -------------------------------------------------
      
      It costs very much time to read CNTVCT_EL0, if a cntvct workaround
      and CNTVCT_EL0 trap is enabled. To decrease the read time, we disable
      CNTVCT_EL0 trap and do the cntvct workaround in the VDSO by adding
      vdso_fix.
      Signed-off-by: NYang Yingliang <yangyingliang@huawei.com>
      60b42e93
    • N
      clocksource/drivers/oxnas: Fix OX820 compatible · 8a3c39ce
      Neil Armstrong 提交于
      [ Upstream commit fbc87aa0f7c429999dc31f1bac3b2615008cac32 ]
      
      The OX820 compatible is wrong is the driver, fix it.
      
      Fixes: 2ea3401e ("clocksource/drivers/oxnas: Add OX820 compatible")
      Reported-by: NDaniel Golle <daniel@makrotopia.org>
      Signed-off-by: NNeil Armstrong <narmstrong@baylibre.com>
      Signed-off-by: NDaniel Lezcano <daniel.lezcano@linaro.org>
      Signed-off-by: NSasha Levin <sashal@kernel.org>
      Signed-off-by: NYang Yingliang <yangyingliang@huawei.com>
      8a3c39ce
    • A
      clocksource/drivers/npcm: select TIMER_OF · 4fc52409
      Arnd Bergmann 提交于
      [ Upstream commit 99834eead2a04e93a120abb112542b87c42ff5e1 ]
      
      When this is disabled, we get a link failure:
      
      drivers/clocksource/timer-npcm7xx.o: In function `npcm7xx_timer_init':
      timer-npcm7xx.c:(.init.text+0xf): undefined reference to `timer_of_init'
      
      Fixes: 1c00289e ("clocksource/drivers/npcm: Add NPCM7xx timer driver")
      Signed-off-by: NArnd Bergmann <arnd@arndb.de>
      Signed-off-by: NDaniel Lezcano <daniel.lezcano@linaro.org>
      Signed-off-by: NSasha Levin <sashal@kernel.org>
      Signed-off-by: NYang Yingliang <yangyingliang@huawei.com>
      4fc52409
    • S
      clocksource/drivers/arch_timer: Workaround for Allwinner A64 timer instability · a1846213
      Samuel Holland 提交于
      commit c950ca8c35eeb32224a63adc47e12f9e226da241 upstream.
      
      The Allwinner A64 SoC is known[1] to have an unstable architectural
      timer, which manifests itself most obviously in the time jumping forward
      a multiple of 95 years[2][3]. This coincides with 2^56 cycles at a
      timer frequency of 24 MHz, implying that the time went slightly backward
      (and this was interpreted by the kernel as it jumping forward and
      wrapping around past the epoch).
      
      Investigation revealed instability in the low bits of CNTVCT at the
      point a high bit rolls over. This leads to power-of-two cycle forward
      and backward jumps. (Testing shows that forward jumps are about twice as
      likely as backward jumps.) Since the counter value returns to normal
      after an indeterminate read, each "jump" really consists of both a
      forward and backward jump from the software perspective.
      
      Unless the kernel is trapping CNTVCT reads, a userspace program is able
      to read the register in a loop faster than it changes. A test program
      running on all 4 CPU cores that reported jumps larger than 100 ms was
      run for 13.6 hours and reported the following:
      
       Count | Event
      -------+---------------------------
        9940 | jumped backward      699ms
         268 | jumped backward     1398ms
           1 | jumped backward     2097ms
       16020 | jumped forward       175ms
        6443 | jumped forward       699ms
        2976 | jumped forward      1398ms
           9 | jumped forward    356516ms
           9 | jumped forward    357215ms
           4 | jumped forward    714430ms
           1 | jumped forward   3578440ms
      
      This works out to a jump larger than 100 ms about every 5.5 seconds on
      each CPU core.
      
      The largest jump (almost an hour!) was the following sequence of reads:
          0x0000007fffffffff → 0x00000093feffffff → 0x0000008000000000
      
      Note that the middle bits don't necessarily all read as all zeroes or
      all ones during the anomalous behavior; however the low 10 bits checked
      by the function in this patch have never been observed with any other
      value.
      
      Also note that smaller jumps are much more common, with backward jumps
      of 2048 (2^11) cycles observed over 400 times per second on each core.
      (Of course, this is partially explained by lower bits rolling over more
      frequently.) Any one of these could have caused the 95 year time skip.
      
      Similar anomalies were observed while reading CNTPCT (after patching the
      kernel to allow reads from userspace). However, the CNTPCT jumps are
      much less frequent, and only small jumps were observed. The same program
      as before (except now reading CNTPCT) observed after 72 hours:
      
       Count | Event
      -------+---------------------------
          17 | jumped backward      699ms
          52 | jumped forward       175ms
        2831 | jumped forward       699ms
           5 | jumped forward      1398ms
      
      Further investigation showed that the instability in CNTPCT/CNTVCT also
      affected the respective timer's TVAL register. The following values were
      observed immediately after writing CNVT_TVAL to 0x10000000:
      
       CNTVCT             | CNTV_TVAL  | CNTV_CVAL          | CNTV_TVAL Error
      --------------------+------------+--------------------+-----------------
       0x000000d4a2d8bfff | 0x10003fff | 0x000000d4b2d8bfff | +0x00004000
       0x000000d4a2d94000 | 0x0fffffff | 0x000000d4b2d97fff | -0x00004000
       0x000000d4a2d97fff | 0x10003fff | 0x000000d4b2d97fff | +0x00004000
       0x000000d4a2d9c000 | 0x0fffffff | 0x000000d4b2d9ffff | -0x00004000
      
      The pattern of errors in CNTV_TVAL seemed to depend on exactly which
      value was written to it. For example, after writing 0x10101010:
      
       CNTVCT             | CNTV_TVAL  | CNTV_CVAL          | CNTV_TVAL Error
      --------------------+------------+--------------------+-----------------
       0x000001ac3effffff | 0x1110100f | 0x000001ac4f10100f | +0x1000000
       0x000001ac40000000 | 0x1010100f | 0x000001ac5110100f | -0x1000000
       0x000001ac58ffffff | 0x1110100f | 0x000001ac6910100f | +0x1000000
       0x000001ac66000000 | 0x1010100f | 0x000001ac7710100f | -0x1000000
       0x000001ac6affffff | 0x1110100f | 0x000001ac7b10100f | +0x1000000
       0x000001ac6e000000 | 0x1010100f | 0x000001ac7f10100f | -0x1000000
      
      I was also twice able to reproduce the issue covered by Allwinner's
      workaround[4], that writing to TVAL sometimes fails, and both CVAL and
      TVAL are left with entirely bogus values. One was the following values:
      
       CNTVCT             | CNTV_TVAL  | CNTV_CVAL
      --------------------+------------+--------------------------------------
       0x000000d4a2d6014c | 0x8fbd5721 | 0x000000d132935fff (615s in the past)
      Reviewed-by: NMarc Zyngier <marc.zyngier@arm.com>
      
      ========================================================================
      
      Because the CPU can read the CNTPCT/CNTVCT registers faster than they
      change, performing two reads of the register and comparing the high bits
      (like other workarounds) is not a workable solution. And because the
      timer can jump both forward and backward, no pair of reads can
      distinguish a good value from a bad one. The only way to guarantee a
      good value from consecutive reads would be to read _three_ times, and
      take the middle value only if the three values are 1) each unique and
      2) increasing. This takes at minimum 3 counter cycles (125 ns), or more
      if an anomaly is detected.
      
      However, since there is a distinct pattern to the bad values, we can
      optimize the common case (1022/1024 of the time) to a single read by
      simply ignoring values that match the error pattern. This still takes no
      more than 3 cycles in the worst case, and requires much less code. As an
      additional safety check, we still limit the loop iteration to the number
      of max-frequency (1.2 GHz) CPU cycles in three 24 MHz counter periods.
      
      For the TVAL registers, the simple solution is to not use them. Instead,
      read or write the CVAL and calculate the TVAL value in software.
      
      Although the manufacturer is aware of at least part of the erratum[4],
      there is no official name for it. For now, use the kernel-internal name
      "UNKNOWN1".
      
      [1]: https://github.com/armbian/build/commit/a08cd6fe7ae9
      [2]: https://forum.armbian.com/topic/3458-a64-datetime-clock-issue/
      [3]: https://irclog.whitequark.org/linux-sunxi/2018-01-26
      [4]: https://github.com/Allwinner-Homlet/H6-BSP4.9-linux/blob/master/drivers/clocksource/arm_arch_timer.c#L272Acked-by: NMaxime Ripard <maxime.ripard@bootlin.com>
      Tested-by: NAndre Przywara <andre.przywara@arm.com>
      Signed-off-by: NSamuel Holland <samuel@sholland.org>
      Cc: stable@vger.kernel.org
      Signed-off-by: NDaniel Lezcano <daniel.lezcano@linaro.org>
      Signed-off-by: NGreg Kroah-Hartman <gregkh@linuxfoundation.org>
      Signed-off-by: NYang Yingliang <yangyingliang@huawei.com>
      a1846213
    • S
      clocksource/drivers/exynos_mct: Clear timer interrupt when shutdown · a88f8df6
      Stuart Menefy 提交于
      commit d2f276c8d3c224d5b493c42b6cf006ae4e64fb1c upstream.
      
      When shutting down the timer, ensure that after we have stopped the
      timer any pending interrupts are cleared. This fixes a problem when
      suspending, as interrupts are disabled before the timer is stopped,
      so the timer interrupt may still be asserted, preventing the system
      entering a low power state when the wfi is executed.
      Signed-off-by: NStuart Menefy <stuart.menefy@mathembedded.com>
      Reviewed-by: NKrzysztof Kozlowski <krzk@kernel.org>
      Tested-by: NMarek Szyprowski <m.szyprowski@samsung.com>
      Cc: <stable@vger.kernel.org> # v4.3+
      Signed-off-by: NDaniel Lezcano <daniel.lezcano@linaro.org>
      Signed-off-by: NGreg Kroah-Hartman <gregkh@linuxfoundation.org>
      Signed-off-by: NYang Yingliang <yangyingliang@huawei.com>
      a88f8df6
    • S
      clocksource/drivers/exynos_mct: Move one-shot check from tick clear to ISR · c33c62c2
      Stuart Menefy 提交于
      commit a5719a40aef956ba704f2aa1c7b977224d60fa96 upstream.
      
      When a timer tick occurs and the clock is in one-shot mode, the timer
      needs to be stopped to prevent it triggering subsequent interrupts.
      Currently this code is in exynos4_mct_tick_clear(), but as it is
      only needed when an ISR occurs move it into exynos4_mct_tick_isr(),
      leaving exynos4_mct_tick_clear() just doing what its name suggests it
      should.
      Signed-off-by: NStuart Menefy <stuart.menefy@mathembedded.com>
      Reviewed-by: NKrzysztof Kozlowski <krzk@kernel.org>
      Tested-by: NMarek Szyprowski <m.szyprowski@samsung.com>
      Cc: stable@vger.kernel.org # v4.3+
      Signed-off-by: NDaniel Lezcano <daniel.lezcano@linaro.org>
      Signed-off-by: NGreg Kroah-Hartman <gregkh@linuxfoundation.org>
      Signed-off-by: NYang Yingliang <yangyingliang@huawei.com>
      c33c62c2
    • T
      clocksource: timer-ti-dm: Fix pwm dmtimer usage of fck reparenting · cef366bc
      Tony Lindgren 提交于
      [ Upstream commit 983a5a43ec254cd5ddf3254db80ca96e8f8bb2a4 ]
      
      Commit 84badc5e ("ARM: dts: omap4: Move l4 child devices to probe
      them with ti-sysc") moved some omap4 timers to probe with ti-sysc
      interconnect target module. Turns out this broke pwm-omap-dmtimer
      where we now try to reparent the clock to itself with the following:
      
      omap_dm_timer_of_set_source: failed to set parent
      
      With ti-sysc, we can now configure the clock sources in the dts
      with assigned-clocks and assigned-clock-parents. So we should be able
      to remove omap_dm_timer_of_set_source with clean-up patches later on.
      But for now, let's just fix it first by checking if parent and fck
      are the same and bail out of so.
      
      Fixes: 84badc5e ("ARM: dts: omap4: Move l4 child devices to probe them with ti-sysc")
      Cc: Bartosz Golaszewski <bgolaszewski@baylibre.com>
      Cc: Daniel Lezcano <daniel.lezcano@linaro.org>
      Cc: H. Nikolaus Schaller <hns@goldelico.com>
      Cc: Keerthy <j-keerthy@ti.com>
      Cc: Ladislav Michl <ladis@linux-mips.org>
      Cc: Pavel Machek <pavel@ucw.cz>
      Cc: Sebastian Reichel <sre@kernel.org>
      Cc: Tero Kristo <t-kristo@ti.com>
      Cc: Thierry Reding <thierry.reding@gmail.com>
      Cc: Thomas Gleixner <tglx@linutronix.de>
      Reported-by: NH. Nikolaus Schaller <hns@goldelico.com>
      Tested-By: NAndreas Kemnade <andreas@kemnade.info>
      Tested-By: NH. Nikolaus Schaller <hns@goldelico.com>
      Signed-off-by: NTony Lindgren <tony@atomide.com>
      Signed-off-by: NSasha Levin <sashal@kernel.org>
      Signed-off-by: NYang Yingliang <yangyingliang@huawei.com>
      cef366bc
    • Y
      clocksource/drivers/integrator-ap: Add missing of_node_put() · 771cbd85
      Yangtao Li 提交于
      [ Upstream commit 5eb73c831171115d3b4347e1e7124a5a35d8086c ]
      
      The function of_find_node_by_path() acquires a reference to the node
      returned by it and that reference needs to be dropped by its caller.
      
      integrator_ap_timer_init_of() doesn't do that.  The pri_node and the
      sec_node are used as an identifier to compare against the current
      node, so we can directly drop the refcount after getting the node from
      the path as it is not used as pointer.
      
      By dropping the refcount right after getting it, a single variable is
      needed instead of two.
      
      Fix this by use a single variable and drop the refcount right after
      of_find_node_by_path().
      Signed-off-by: NYangtao Li <tiny.windzz@gmail.com>
      Signed-off-by: NDaniel Lezcano <daniel.lezcano@linaro.org>
      Signed-off-by: NSasha Levin <sashal@kernel.org>
      Signed-off-by: NYang Yingliang <yangyingliang@huawei.com>
      771cbd85
    • A
      clocksource/drivers/arc_timer: Utilize generic sched_clock · f3966840
      Alexey Brodkin 提交于
      commit bf287607c80f24387fedb431a346dc67f25be12c upstream.
      
      It turned out we used to use default implementation of sched_clock()
      from kernel/sched/clock.c which was as precise as 1/HZ, i.e.
      by default we had 10 msec granularity of time measurement.
      
      Now given ARC built-in timers are clocked with the same frequency as
      CPU cores we may get much higher precision of time tracking.
      
      Thus we switch to generic sched_clock which really reads ARC hardware
      counters.
      
      This is especially helpful for measuring short events.
      That's what we used to have:
      ------------------------------>8------------------------
      $ perf stat /bin/sh -c /root/lmbench-master/bin/arc/hello > /dev/null
      
       Performance counter stats for '/bin/sh -c /root/lmbench-master/bin/arc/hello':
      
               10.000000      task-clock (msec)         #    2.832 CPUs utilized
                       1      context-switches          #    0.100 K/sec
                       1      cpu-migrations            #    0.100 K/sec
                      63      page-faults               #    0.006 M/sec
                 3049480      cycles                    #    0.305 GHz
                 1091259      instructions              #    0.36  insn per cycle
                  256828      branches                  #   25.683 M/sec
                   27026      branch-misses             #   10.52% of all branches
      
             0.003530687 seconds time elapsed
      
             0.000000000 seconds user
             0.010000000 seconds sys
      ------------------------------>8------------------------
      
      And now we'll see:
      ------------------------------>8------------------------
      $ perf stat /bin/sh -c /root/lmbench-master/bin/arc/hello > /dev/null
      
       Performance counter stats for '/bin/sh -c /root/lmbench-master/bin/arc/hello':
      
                3.004322      task-clock (msec)         #    0.865 CPUs utilized
                       1      context-switches          #    0.333 K/sec
                       1      cpu-migrations            #    0.333 K/sec
                      63      page-faults               #    0.021 M/sec
                 2986734      cycles                    #    0.994 GHz
                 1087466      instructions              #    0.36  insn per cycle
                  255209      branches                  #   84.947 M/sec
                   26002      branch-misses             #   10.19% of all branches
      
             0.003474829 seconds time elapsed
      
             0.003519000 seconds user
             0.000000000 seconds sys
      ------------------------------>8------------------------
      
      Note how much more meaningful is the second output - time spent for
      execution pretty much matches number of cycles spent (we're runnign
      @ 1GHz here).
      Signed-off-by: NAlexey Brodkin <abrodkin@synopsys.com>
      Cc: Daniel Lezcano <daniel.lezcano@linaro.org>
      Cc: Vineet Gupta <vgupta@synopsys.com>
      Cc: Thomas Gleixner <tglx@linutronix.de>
      Cc: stable@vger.kernel.org
      Acked-by: NVineet Gupta <vgupta@synopsys.com>
      Signed-off-by: NDaniel Lezcano <daniel.lezcano@linaro.org>
      Signed-off-by: NGreg Kroah-Hartman <gregkh@linuxfoundation.org>
      Signed-off-by: NYang Yingliang <yangyingliang@huawei.com>
      f3966840
  8. 21 11月, 2018 1 次提交
    • M
      clockevents/drivers/i8253: Add support for PIT shutdown quirk · ebbc6fce
      Michael Kelley 提交于
      commit 35b69a420bfb56b7b74cb635ea903db05e357bec upstream.
      
      Add support for platforms where pit_shutdown() doesn't work because of a
      quirk in the PIT emulation. On these platforms setting the counter register
      to zero causes the PIT to start running again, negating the shutdown.
      
      Provide a global variable that controls whether the counter register is
      zero'ed, which platform specific code can override.
      Signed-off-by: NMichael Kelley <mikelley@microsoft.com>
      Signed-off-by: NThomas Gleixner <tglx@linutronix.de>
      Cc: "gregkh@linuxfoundation.org" <gregkh@linuxfoundation.org>
      Cc: "devel@linuxdriverproject.org" <devel@linuxdriverproject.org>
      Cc: "daniel.lezcano@linaro.org" <daniel.lezcano@linaro.org>
      Cc: "virtualization@lists.linux-foundation.org" <virtualization@lists.linux-foundation.org>
      Cc: "jgross@suse.com" <jgross@suse.com>
      Cc: "akataria@vmware.com" <akataria@vmware.com>
      Cc: "olaf@aepfle.de" <olaf@aepfle.de>
      Cc: "apw@canonical.com" <apw@canonical.com>
      Cc: vkuznets <vkuznets@redhat.com>
      Cc: "jasowang@redhat.com" <jasowang@redhat.com>
      Cc: "marcelo.cerri@canonical.com" <marcelo.cerri@canonical.com>
      Cc: KY Srinivasan <kys@microsoft.com>
      Cc: stable@vger.kernel.org
      Link: https://lkml.kernel.org/r/1541303219-11142-2-git-send-email-mikelley@microsoft.comSigned-off-by: NGreg Kroah-Hartman <gregkh@linuxfoundation.org>
      ebbc6fce
  9. 27 9月, 2018 1 次提交
  10. 24 9月, 2018 1 次提交
    • T
      clocksource/drivers/fttmr010: Fix set_next_event handler · 4451d3f5
      Tao Ren 提交于
      Currently, the aspeed MATCH1 register is updated to <current_count -
      cycles> in set_next_event handler, with the assumption that COUNT
      register value is preserved when the timer is disabled and it continues
      decrementing after the timer is enabled. But the assumption is wrong:
      RELOAD register is loaded into COUNT register when the aspeed timer is
      enabled, which means the next event may be delayed because timer
      interrupt won't be generated until <0xFFFFFFFF - current_count +
      cycles>.
      
      The problem can be fixed by updating RELOAD register to <cycles>, and
      COUNT register will be re-loaded when the timer is enabled and interrupt
      is generated when COUNT register overflows.
      
      The test result on Facebook Backpack-CMM BMC hardware (AST2500) shows
      the issue is fixed: without the patch, usleep(100) suspends the process
      for several milliseconds (and sometimes even over 40 milliseconds);
      after applying the fix, usleep(100) takes averagely 240 microseconds to
      return under the same workload level.
      Signed-off-by: NTao Ren <taoren@fb.com>
      Reviewed-by: NLinus Walleij <linus.walleij@linaro.org>
      Tested-by: NLei YU <mine260309@gmail.com>
      Signed-off-by: NDaniel Lezcano <daniel.lezcano@linaro.org>
      4451d3f5
  11. 13 9月, 2018 1 次提交
  12. 13 8月, 2018 1 次提交
  13. 02 8月, 2018 2 次提交
  14. 26 7月, 2018 6 次提交
  15. 20 7月, 2018 1 次提交
    • P
      ARM/time: Remove read_boot_clock64() · 227e3958
      Pavel Tatashin 提交于
      read_boot_clock64() is deleted, and replaced with
      read_persistent_wall_and_boot_offset().
      
      The default implementation of read_persistent_wall_and_boot_offset()
      provides a better fallback than the current stubs for read_boot_clock64()
      that arm has with no users, so remove the old code.
      Signed-off-by: NPavel Tatashin <pasha.tatashin@oracle.com>
      Signed-off-by: NThomas Gleixner <tglx@linutronix.de>
      Cc: steven.sistare@oracle.com
      Cc: daniel.m.jordan@oracle.com
      Cc: linux@armlinux.org.uk
      Cc: schwidefsky@de.ibm.com
      Cc: heiko.carstens@de.ibm.com
      Cc: john.stultz@linaro.org
      Cc: sboyd@codeaurora.org
      Cc: hpa@zytor.com
      Cc: douly.fnst@cn.fujitsu.com
      Cc: peterz@infradead.org
      Cc: prarit@redhat.com
      Cc: feng.tang@intel.com
      Cc: pmladek@suse.com
      Cc: gnomes@lxorguk.ukuu.org.uk
      Cc: linux-s390@vger.kernel.org
      Cc: boris.ostrovsky@oracle.com
      Cc: jgross@suse.com
      Cc: pbonzini@redhat.com
      Link: https://lkml.kernel.org/r/20180719205545.16512-19-pasha.tatashin@oracle.com
      227e3958