01 Sep, 2019

2 commits


29 Aug, 2019

1 commit

  • The RTC IRQ is requested before the struct rtc_device is allocated,
    this may lead to a NULL pointer dereference in IRQ handler.

    To fix this issue, allocating the rtc_device struct before requesting
    the RTC IRQ using devm_rtc_allocate_device, and use rtc_register_device
    to register the RTC device.

    Signed-off-by: Anson Huang
    Reviewed-by: Dong Aisheng
    Link: https://lore.kernel.org/r/20190716071858.36750-1-Anson.Huang@nxp.com
    Signed-off-by: Alexandre Belloni

    Anson Huang
     

09 May, 2019

1 commit


04 Apr, 2019

2 commits


06 Feb, 2019

1 commit

  • During system suspend, the SNVS RTC's clock will be disabled in
    noirq suspend phase, but SNVS RTC's alarm interrupt could still
    arrive, system will hang if SNVS RTC driver tries to access register
    without clock enabled, this patch fixes the issue of this scenario.

    Signed-off-by: Anson Huang
    Signed-off-by: Alexandre Belloni

    Anson Huang
     

12 Jul, 2018

1 commit

  • 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
    Cc: Alessandro Zummo
    Cc: Fabio Estevam
    Cc: Shawn Guo
    Cc: Bryan O'Donoghue
    Signed-off-by: Trent Piepho
    Signed-off-by: Alexandre Belloni

    Trent Piepho
     

22 May, 2018

1 commit


03 Apr, 2018

1 commit

  • commit 179a502f8c46 ("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] [] (__irq_svc) from [] (_raw_spin_unlock_irqrestore+0x34/0x44)
    [ 36.102122] [] (_raw_spin_unlock_irqrestore) from [] (regmap_read+0x4c/0x5c)
    [ 36.110938] [] (regmap_read) from [] (rtc_write_sync_lp+0x6c/0x98)
    [ 36.118881] [] (rtc_write_sync_lp) from [] (snvs_rtc_alarm_irq_enable+0x40/0x4c)
    [ 36.128041] [] (snvs_rtc_alarm_irq_enable) from [] (rtc_timer_do_work+0xd8/0x1a8)
    [ 36.137291] [] (rtc_timer_do_work) from [] (process_one_work+0x28c/0x76c)
    [ 36.145840] [] (process_one_work) from [] (worker_thread+0x34/0x58c)
    [ 36.153961] [] (worker_thread) from [] (kthread+0x138/0x150)
    [ 36.161388] [] (kthread) from [] (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] [] (__schedule) from [] (schedule+0x3c/0xa0)
    [ 36.192739] [] (schedule) from [] (schedule_timeout+0x78/0x4e0)
    [ 36.200422] [] (schedule_timeout) from [] (rcu_gp_kthread+0x648/0x1864)
    [ 36.208800] [] (rcu_gp_kthread) from [] (kthread+0x138/0x150)
    [ 36.216309] [] (kthread) from [] (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: 179a502f8c46 ("rtc: snvs: add Freescale rtc-snvs driver")
    Signed-off-by: Bryan O'Donoghue
    Acked-by: Shawn Guo
    Signed-off-by: Alexandre Belloni

    Bryan O'Donoghue
     

05 May, 2017

1 commit


01 Feb, 2017

1 commit

  • The clear of the LPTA_EN flag should be synced before writing to the
    alarm register. Omitting this synchronization creates a race when
    trying to change existing alarm.

    Signed-off-by: Guy Shapiro
    Signed-off-by: Alexandre Belloni

    Guy Shapiro
     

20 May, 2016

1 commit


15 Jul, 2015

1 commit


25 Jun, 2015

1 commit

  • 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: 7654e9d4fd8f ("drivers/rtc/rtc-snvs: fix suspend/resume")
    Cc: # 3.19
    Signed-off-by: Stefan Agner
    Signed-off-by: Alexandre Belloni

    Stefan Agner
     

15 Dec, 2014

1 commit

  • Pull driver core update from Greg KH:
    "Here's the set of driver core patches for 3.19-rc1.

    They are dominated by the removal of the .owner field in platform
    drivers. They touch a lot of files, but they are "simple" changes,
    just removing a line in a structure.

    Other than that, a few minor driver core and debugfs changes. There
    are some ath9k patches coming in through this tree that have been
    acked by the wireless maintainers as they relied on the debugfs
    changes.

    Everything has been in linux-next for a while"

    * tag 'driver-core-3.19-rc1' of git://git.kernel.org/pub/scm/linux/kernel/git/gregkh/driver-core: (324 commits)
    Revert "ath: ath9k: use debugfs_create_devm_seqfile() helper for seq_file entries"
    fs: debugfs: add forward declaration for struct device type
    firmware class: Deletion of an unnecessary check before the function call "vunmap"
    firmware loader: fix hung task warning dump
    devcoredump: provide a one-way disable function
    device: Add dev__once variants
    ath: ath9k: use debugfs_create_devm_seqfile() helper for seq_file entries
    ath: use seq_file api for ath9k debugfs files
    debugfs: add helper function to create device related seq_file
    drivers/base: cacheinfo: remove noisy error boot message
    Revert "core: platform: add warning if driver has no owner"
    drivers: base: support cpu cache information interface to userspace via sysfs
    drivers: base: add cpu_device_create to support per-cpu devices
    topology: replace custom attribute macros with standard DEVICE_ATTR*
    cpumask: factor out show_cpumap into separate helper function
    driver core: Fix unbalanced device reference in drivers_probe
    driver core: fix race with userland in device_add()
    sysfs/kernfs: make read requests on pre-alloc files use the buffer.
    sysfs/kernfs: allow attributes to request write buffer be pre-allocated.
    fs: sysfs: return EGBIG on write if offset is larger than file size
    ...

    Linus Torvalds
     

14 Dec, 2014

1 commit

  • Commit 7654e9d4fd8f ("drivers/rtc/rtc-snvs: fix suspend/resume")
    replaces SIMPLE_DEV_PM_OPS with direct declaration of snvs_rtc_pm_ops,
    but does so outside #ifdef CONFIG_PM_SLEEP. This causes the driver
    build to fail if CONFIG_PM_SLEEP is not configured.

    Fixes: 7654e9d4fd8f ("drivers/rtc/rtc-snvs: fix suspend/resume")
    Signed-off-by: Guenter Roeck
    Cc: Sanchayan Maity
    Cc: Alessandro Zummo
    Signed-off-by: Andrew Morton
    Signed-off-by: Linus Torvalds

    Guenter Roeck
     

11 Dec, 2014

2 commits

  • The alarm interrupt handler also reads registers which are part of SNVS
    and need clocks enabled. However, the resume function is called after
    IRQ's have been enabled, hence this leads to a abort:

    Unhandled fault: external abort on non-linefetch (0x1008) at 0x908c604c
    Internal error: : 1008 [#1] ARM
    Modules linked in:
    CPU: 0 PID: 421 Comm: sh Not tainted 3.18.0-rc5-00135-g0689c67-dirty #1592
    task: 8e03e800 ti: 8cad8000 task.ti: 8cad8000
    PC is at snvs_rtc_irq_handler+0x14/0x74
    LR is at handle_irq_event_percpu+0x3c/0x144

    Fix this by using the .{suspend/resume}_noirq callbacks instead of
    .{suspend/resume} .

    Signed-off-by: Sanchayan Maity
    Cc: Shawn Guo
    Cc: Stefan Agner
    Cc: Alessandro Zummo
    Signed-off-by: Andrew Morton
    Signed-off-by: Linus Torvalds

    Sanchayan Maity
     
  • Add clock enable and disable support for the SNVS peripheral, which is
    required for using the RTC within the SNVS block.

    The clock is not strictly enforced, as this would break the i.MX devices.
    The clocking for the i.MX devices seems to be enabled elsewhere and
    enabling RTC SNVS for Vybrid results in a crash. This patch adds the
    clock support but also makes it optional so Vybrid platform can use the
    clock if defined while making sure not to break i.MX.

    Signed-off-by: Sanchayan Maity
    Cc: Shawn Guo
    Acked-by: Stefan Agner
    Acked-by: Alessandro Zummo
    Signed-off-by: Andrew Morton
    Signed-off-by: Linus Torvalds

    Sanchayan Maity
     

20 Oct, 2014

1 commit


13 Nov, 2013

1 commit


04 Jul, 2013

1 commit


30 Apr, 2013

1 commit


22 Feb, 2013

2 commits

  • Merge misc patches from Andrew Morton:

    - Florian has vanished so I appear to have become fbdev maintainer
    again :(

    - Joel and Mark are distracted to welcome to the new OCFS2 maintainer

    - The backlight queue

    - Small core kernel changes

    - lib/ updates

    - The rtc queue

    - Various random bits

    * akpm: (164 commits)
    rtc: rtc-davinci: use devm_*() functions
    rtc: rtc-max8997: use devm_request_threaded_irq()
    rtc: rtc-max8907: use devm_request_threaded_irq()
    rtc: rtc-da9052: use devm_request_threaded_irq()
    rtc: rtc-wm831x: use devm_request_threaded_irq()
    rtc: rtc-tps80031: use devm_request_threaded_irq()
    rtc: rtc-lp8788: use devm_request_threaded_irq()
    rtc: rtc-coh901331: use devm_clk_get()
    rtc: rtc-vt8500: use devm_*() functions
    rtc: rtc-tps6586x: use devm_request_threaded_irq()
    rtc: rtc-imxdi: use devm_clk_get()
    rtc: rtc-cmos: use dev_warn()/dev_dbg() instead of printk()/pr_debug()
    rtc: rtc-pcf8583: use dev_warn() instead of printk()
    rtc: rtc-sun4v: use pr_warn() instead of printk()
    rtc: rtc-vr41xx: use dev_info() instead of printk()
    rtc: rtc-rs5c313: use pr_err() instead of printk()
    rtc: rtc-at91rm9200: use dev_dbg()/dev_err() instead of printk()/pr_debug()
    rtc: rtc-rs5c372: use dev_dbg()/dev_warn() instead of printk()/pr_debug()
    rtc: rtc-ds2404: use dev_err() instead of printk()
    rtc: rtc-efi: use dev_err()/dev_warn()/pr_err() instead of printk()
    ...

    Linus Torvalds
     
  • This eliminates having an #ifdef returning NULL for the case when OF is
    disabled. Maintains consistency in cases where OF is always selected.

    Signed-off-by: Sachin Kamat
    Cc: Alessandro Zummo
    Signed-off-by: Andrew Morton
    Signed-off-by: Linus Torvalds

    Sachin Kamat
     

23 Jan, 2013

1 commit

  • Convert all uses of devm_request_and_ioremap() to the newly introduced
    devm_ioremap_resource() which provides more consistent error handling.

    devm_ioremap_resource() provides its own error messages so all explicit
    error messages can be removed from the failure code paths.

    Signed-off-by: Thierry Reding
    Acked-by: Viresh Kumar
    Cc: Alessandro Zummo
    Signed-off-by: Greg Kroah-Hartman

    Thierry Reding
     

04 Jan, 2013

1 commit

  • 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
    Cc: Alessandro Zummo
    Cc: Srinidhi Kasagar
    Cc: Linus Walleij
    Cc: Mike Frysinger
    Cc: Wan ZongShun
    Cc: Guan Xuetao
    Cc: Mark Brown
    Signed-off-by: Greg Kroah-Hartman

    Greg Kroah-Hartman
     

06 Oct, 2012

1 commit

  • Add an RTC driver for Freescale Secure Non-Volatile Storage (SNVS)
    Low Power (LP) RTC.

    Signed-off-by: Shawn Guo
    Reviewed-by: Stephen Boyd
    Cc: Alessandro Zummo
    Cc: Kim Phillips
    Cc: Sascha Hauer
    Signed-off-by: Andrew Morton
    Signed-off-by: Linus Torvalds

    Shawn Guo