1. 20 10月, 2017 3 次提交
  2. 15 4月, 2017 1 次提交
    • N
      clockevents/drivers/sh_cmt: Set ->min_delta_ticks and ->max_delta_ticks · bb2e94ac
      Nicolai Stange 提交于
      In preparation for making the clockevents core NTP correction aware,
      all clockevent device drivers must set ->min_delta_ticks and
      ->max_delta_ticks rather than ->min_delta_ns and ->max_delta_ns: a
      clockevent device's rate is going to change dynamically and thus, the
      ratio of ns to ticks ceases to stay invariant.
      
      Make the sh_cmt clockevent driver initialize these fields properly.
      
      This patch alone doesn't introduce any change in functionality as the
      clockevents core still looks exclusively at the (untouched) ->min_delta_ns
      and ->max_delta_ns. As soon as this has changed, a followup patch will
      purge the initialization of ->min_delta_ns and ->max_delta_ns from this
      driver.
      
      Cc: Ingo Molnar <mingo@redhat.com>
      Cc: Thomas Gleixner <tglx@linutronix.de>
      Cc: Daniel Lezcano <daniel.lezcano@linaro.org>
      Cc: Richard Cochran <richardcochran@gmail.com>
      Cc: Prarit Bhargava <prarit@redhat.com>
      Cc: Stephen Boyd <sboyd@codeaurora.org>
      Acked-by: NDaniel Lezcano <daniel.lezcano@linaro.org>
      Signed-off-by: NNicolai Stange <nicstange@gmail.com>
      Signed-off-by: NJohn Stultz <john.stultz@linaro.org>
      bb2e94ac
  3. 24 3月, 2017 1 次提交
    • N
      clocksource: sh_cmt: Compute rate before registration again · 890f423b
      Nicolai Stange 提交于
      With the upcoming NTP correction related rate adjustments to be implemented
      in the clockevents core, the latter needs to get informed about every rate
      change of a clockevent device made after its registration.
      
      Currently, sh_cmt violates this requirement in that it registers its
      clockevent device with a dummy rate and sets its final ->mult and ->shift
      values from its ->set_state_oneshot() and ->set_state_periodic() functions
      respectively.
      
      This patch moves the setting of the clockevent device's ->mult and ->shift
      values to before its registration.
      
      Note that there has been some back and forth regarding this question with
      respect to the clocksource also provided by this driver:
        commit f4d7c356 ("clocksource: sh_cmt: compute mult and shift before
                              registration")
      moves the rate determination from the clocksource's ->enable() function to
      before its registration. OTOH, the later
        commit 3593f5fe ("clocksource: sh_cmt: __clocksource_updatefreq_hz()
                              update")
      basically reverts this, saying
        "Without this patch the old code uses clocksource_register() together
         with a hack that assumes a never changing clock rate."
      
      However, I checked all current sh_cmt users in arch/sh as well as in
      arch/arm/mach-shmobile carefully and right now, none of them changes any
      rate in any clock tree relevant to sh_cmt after their respective
      time_init(). Since all sh_cmt instances are created after time_init(), none
      of them should ever observe any clock rate changes.
      
      What's more, both, a clocksource as well as a clockevent device, can
      immediately get selected for use at their registration and thus, enabled
      at this point already. So it's probably safer to assume a "never changing
      clock rate" here.
      
      - Move the struct sh_cmt_channel's ->rate member to struct sh_cmt_device:
        it's a property of the underlying clock which is in turn specific to
        the sh_cmt_device.
      - Determine the ->rate value in sh_cmt_setup() at device probing rather
        than at first usage.
      - Set the clockevent device's ->mult and ->shift values right before its
        registration.
      - Although not strictly necessary for the upcoming clockevent core changes,
        set the clocksource's rate at its registration for consistency.
      Signed-off-by: NNicolai Stange <nicstange@gmail.com>
      Signed-off-by: NJohn Stultz <john.stultz@linaro.org>
      890f423b
  4. 25 12月, 2016 1 次提交
  5. 15 10月, 2015 1 次提交
  6. 10 8月, 2015 4 次提交
  7. 08 8月, 2015 1 次提交
    • G
      clockevents/drivers/sh_cmt: Only perform clocksource suspend/resume if enabled · 54d46b7f
      Geert Uytterhoeven 提交于
      Currently the sh_cmt clocksource timer is disabled or enabled
      unconditionally on clocksource suspend resp. resume, even if a
      better clocksource is present (e.g. arch_sys_counter) and the
      sh_cmt clocksource is not enabled.
      
      As sh_cmt is a syscore device when its timer is enabled, this
      may lead to a genpd.prepared_count imbalance in the presence of
      PM Domains, which may cause a lock-up during reboot after s2ram.
      
      During suspend:
        - pm_genpd_prepare() is called for all non-syscore devices (incl.
          sh_cmt), increasing genpd.prepared_count for each device,
        - clocksource.suspend() is called for all clocksource devices,
        - sh_cmt_clocksource_suspend() calls sh_cmt_stop(), which is a no-op
          as the clocksource was not enabled.
      
      During resume:
        - clocksource.resume() is called for all clocksource devices,
        - sh_cmt_clocksource_resume() calls sh_cmt_start(), which enables the
          clocksource timer, and turns sh_cmt into a syscore device,
        - pm_genpd_complete() is called for all non-syscore devices (excl.
          sh_cmt now!), decreasing genpd.prepared_count for each device but
          sh_cmt.
      
      Now genpd.prepared_count of the PM Domain containing sh_cmt is
      still 1 instead of zero.  On subsequent suspend/resume cycles,
      sh_cmt is still a syscore device, hence it's skipped for
      pm_genpd_{prepare,complete}(), keeping the imbalance of
      genpd.prepared_count at 1.
      
      During reboot:
      
        - platform_drv_shutdown() is called for any platform device that has
          a driver with a .shutdown() method (only rcar-dmac on R-Car Gen2),
      
        - platform_drv_shutdown() calls dev_pm_domain_detach(), which
          calls genpd_dev_pm_detach(),
      
        - genpd_dev_pm_detach() keeps calling pm_genpd_remove_device() until
          it doesn't return -EAGAIN[*],
      
        - If the device is part of the same PM Domain as sh_cmt,
          pm_genpd_remove_device() always fails with -EAGAIN due to
          genpd.prepared_count > 0.
      
        - Infinite loop in genpd_dev_pm_detach()[*].
      
      [*] Commit 93af5e93 ("PM / Domains: Avoid infinite loops in
          attach/detach code") already limited the number of loop iterations,
          avoiding the lock-up.
      
      To fix this, only disable or enable the clocksource timer on
      clocksource suspend resp. resume if the clocksource was enabled.
      
      This was tested on r8a7791/koelsch with the CPG Clock Domain:
      
        - using arch_sys_counter as the clocksource, which is the default, and
          which showed the problem,
      
        - using sh_cmt as a clocksource ("echo ffca0000.timer > \
          /sys/devices/system/clocksource/clocksource0/current_clocksource"),
          which behaves the same as before.
      Signed-off-by: NGeert Uytterhoeven <geert+renesas@glider.be>
      Signed-off-by: NDaniel Lezcano <daniel.lezcano@linaro.org>
      Acked-by: NLaurent Pinchart <laurent.pinchart@ideasonboard.com>
      Cc: Peter Zijlstra <peterz@infradead.org>
      Cc: Thomas Gleixner <tglx@linutronix.de>
      Link: http://lkml.kernel.org/r/1438875126-12596-2-git-send-email-daniel.lezcano@linaro.orgSigned-off-by: NIngo Molnar <mingo@kernel.org>
      54d46b7f
  8. 13 3月, 2015 1 次提交
  9. 04 7月, 2014 1 次提交
  10. 02 7月, 2014 2 次提交
  11. 23 5月, 2014 1 次提交
  12. 16 4月, 2014 20 次提交
  13. 18 12月, 2013 1 次提交
  14. 11 12月, 2013 1 次提交
  15. 22 8月, 2013 1 次提交