1. 21 Dec, 2018 1 commit
    • Trent Piepho's avatar
      rtc: snvs: Add timeouts to avoid kernel lockups · f1e1eb5c
      Trent Piepho authored
      [ Upstream commit cd7f3a24 ]
      
      In order to read correctly from asynchronously updated RTC registers,
      it's necessary to read repeatedly until their values do not change from
      read to read.  It's also necessary to wait for three RTC clock ticks for
      certain operations.  There are no timeouts in this code and these
      operations could possibly loop forever.
      
      To avoid kernel hangs, put in timeouts.
      
      The iMX7d can be configured to stop the SRTC on a tamper event, which
      will lockup the kernel inside this driver as described above.
      
      These hangs can happen when running under qemu, which doesn't emulate
      the SNVS RTC, though currently the driver will refuse to load on qemu
      due to a timeout in the driver probe method.
      
      It could also happen if the SRTC block where somehow placed into reset
      or the slow speed clock that drives the SRTC counter (but not the CPU)
      were to stop.
      
      The symptoms on a two core iMX7d are a work queue hang on
      rtc_timer_do_work(), which eventually blocks a systemd fsnotify
      operation that triggers a work queue flush, causing systemd to hang and
      thus causing all services that should be started by systemd, like a
      console getty, to fail to start or stop.
      
      Also optimize the wait code to wait less.  It only needs to wait for the
      clock to advance three ticks, not to see it change three times.
      
      Cc: Alexandre Belloni <alexandre.belloni@free-electrons.com>
      Cc: Alessandro Zummo <a.zummo@towertech.it>
      Cc: Fabio Estevam <fabio.estevam@nxp.com>
      Cc: Shawn Guo <shawn.guo@linaro.org>
      Cc: Bryan O'Donoghue <pure.logic@nexus-software.ie>
      Signed-off-by: default avatarTrent Piepho <tpiepho@impinj.com>
      Signed-off-by: default avatarAlexandre Belloni <alexandre.belloni@bootlin.com>
      Signed-off-by: default avatarSasha Levin <sashal@kernel.org>
      f1e1eb5c
  2. 25 May, 2018 1 commit
    • Bryan O'Donoghue's avatar
      rtc: snvs: Fix usage of snvs_rtc_enable · 731d965a
      Bryan O'Donoghue authored
      [ Upstream commit 1485991c ]
      
      commit 179a502f ("rtc: snvs: add Freescale rtc-snvs driver") introduces
      the SNVS RTC driver with a function snvs_rtc_enable().
      
      snvs_rtc_enable() can return an error on the enable path however this
      driver does not currently trap that failure on the probe() path and
      consequently if enabling the RTC fails we encounter a later error spinning
      forever in rtc_write_sync_lp().
      
      [   36.093481] [<c010d630>] (__irq_svc) from [<c0c2e9ec>] (_raw_spin_unlock_irqrestore+0x34/0x44)
      [   36.102122] [<c0c2e9ec>] (_raw_spin_unlock_irqrestore) from [<c072e32c>] (regmap_read+0x4c/0x5c)
      [   36.110938] [<c072e32c>] (regmap_read) from [<c085d0f4>] (rtc_write_sync_lp+0x6c/0x98)
      [   36.118881] [<c085d0f4>] (rtc_write_sync_lp) from [<c085d160>] (snvs_rtc_alarm_irq_enable+0x40/0x4c)
      [   36.128041] [<c085d160>] (snvs_rtc_alarm_irq_enable) from [<c08567b4>] (rtc_timer_do_work+0xd8/0x1a8)
      [   36.137291] [<c08567b4>] (rtc_timer_do_work) from [<c01441b8>] (process_one_work+0x28c/0x76c)
      [   36.145840] [<c01441b8>] (process_one_work) from [<c01446cc>] (worker_thread+0x34/0x58c)
      [   36.153961] [<c01446cc>] (worker_thread) from [<c014aee4>] (kthread+0x138/0x150)
      [   36.161388] [<c014aee4>] (kthread) from [<c0107e14>] (ret_from_fork+0x14/0x20)
      [   36.168635] rcu_sched kthread starved for 2602 jiffies! g496 c495 f0x2 RCU_GP_WAIT_FQS(3) ->state=0x0 ->cpu=0
      [   36.178564] rcu_sched       R  running task        0     8      2 0x00000000
      [   36.185664] [<c0c288b0>] (__schedule) from [<c0c29134>] (schedule+0x3c/0xa0)
      [   36.192739] [<c0c29134>] (schedule) from [<c0c2db80>] (schedule_timeout+0x78/0x4e0)
      [   36.200422] [<c0c2db80>] (schedule_timeout) from [<c01a7ab0>] (rcu_gp_kthread+0x648/0x1864)
      [   36.208800] [<c01a7ab0>] (rcu_gp_kthread) from [<c014aee4>] (kthread+0x138/0x150)
      [   36.216309] [<c014aee4>] (kthread) from [<c0107e14>] (ret_from_fork+0x14/0x20)
      
      This patch fixes by parsing the result of rtc_write_sync_lp() and
      propagating both in the probe and elsewhere. If the RTC doesn't start we
      don't proceed loading the driver and don't get into this loop mess later
      on.
      
      Fixes: 179a502f ("rtc: snvs: add Freescale rtc-snvs driver")
      Signed-off-by: default avatarBryan O'Donoghue <pure.logic@nexus-software.ie>
      Acked-by: default avatarShawn Guo <shawn.guo@linaro.org>
      Signed-off-by: default avatarAlexandre Belloni <alexandre.belloni@bootlin.com>
      Signed-off-by: default avatarSasha Levin <alexander.levin@microsoft.com>
      Signed-off-by: default avatarGreg Kroah-Hartman <gregkh@linuxfoundation.org>
      731d965a
  3. 04 May, 2017 1 commit
  4. 01 Feb, 2017 1 commit
  5. 20 May, 2016 1 commit
  6. 15 Jul, 2015 1 commit
  7. 24 Jun, 2015 1 commit
    • Stefan Agner's avatar
      rtc: snvs: fix wakealarm by call enable_irq_wake earlier · 119434f4
      Stefan Agner authored
      When entering suspend while an wakeup alarm is set, enable_set_wake
      should make sure that the RTC interrupt keep being enabled and the
      .irq_set_wake for the RTC interrupt get called. However, since the
      driver uses the suspend_noirq callback, the call to enable_irq_wake
      has been made after disabling the interrupts. While .irq_set_wake
      has been called properly, the interrupt remained disabled.
      
      Use the suspend callback to call enable_irq_wake early enough to
      ensure the RTC interrupt remains enabled.
      
      Fixes: 7654e9d4 ("drivers/rtc/rtc-snvs: fix suspend/resume")
      Cc:  <stable@vger.kernel.org> # 3.19
      Signed-off-by: default avatarStefan Agner <stefan@agner.ch>
      Signed-off-by: default avatarAlexandre Belloni <alexandre.belloni@free-electrons.com>
      119434f4
  8. 13 Dec, 2014 1 commit
  9. 11 Dec, 2014 2 commits
  10. 20 Oct, 2014 1 commit
  11. 13 Nov, 2013 1 commit
  12. 03 Jul, 2013 1 commit
  13. 30 Apr, 2013 1 commit
  14. 22 Feb, 2013 1 commit
  15. 22 Jan, 2013 1 commit
  16. 03 Jan, 2013 1 commit
    • Greg Kroah-Hartman's avatar
      Drivers: rtc: remove __dev* attributes. · 5a167f45
      Greg Kroah-Hartman authored
      CONFIG_HOTPLUG is going away as an option.  As a result, the __dev*
      markings need to be removed.
      
      This change removes the use of __devinit, __devexit_p, __devinitdata,
      __devinitconst, and __devexit from these drivers.
      
      Based on patches originally written by Bill Pemberton, but redone by me
      in order to handle some of the coding style issues better, by hand.
      
      Cc: Bill Pemberton <wfp5p@virginia.edu>
      Cc: Alessandro Zummo <a.zummo@towertech.it>
      Cc: Srinidhi Kasagar <srinidhi.kasagar@stericsson.com>
      Cc: Linus Walleij <linus.walleij@linaro.org>
      Cc: Mike Frysinger <vapier.adi@gmail.com>
      Cc: Wan ZongShun <mcuos.com@gmail.com>
      Cc: Guan Xuetao <gxt@mprc.pku.edu.cn>
      Cc: Mark Brown <broonie@opensource.wolfsonmicro.com>
      Signed-off-by: default avatarGreg Kroah-Hartman <gregkh@linuxfoundation.org>
      5a167f45
  17. 05 Oct, 2012 1 commit