platform/kernel/linux-rpi.git
4 years agortc: ds1307: check for failed memory allocation on wdt
Colin Ian King [Fri, 3 Apr 2020 11:04:37 +0000 (12:04 +0100)]
rtc: ds1307: check for failed memory allocation on wdt

Currently a failed memory allocation will lead to a null pointer
dereference on point wdt.  Fix this by checking for a failed
allocation and just returning.

Addresses-Coverity: ("Dereference null return")
Fixes: fd90d48db037 ("rtc: ds1307: add support for watchdog timer on ds1388")

Signed-off-by: Colin Ian King <colin.king@canonical.com>
Link: https://lore.kernel.org/r/20200403110437.57420-1-colin.king@canonical.com
Signed-off-by: Alexandre Belloni <alexandre.belloni@bootlin.com>
4 years agortc: class: remove redundant assignment to variable err
Colin Ian King [Thu, 2 Apr 2020 11:04:11 +0000 (12:04 +0100)]
rtc: class: remove redundant assignment to variable err

The variable err is being initialized with a value that is never read
and it is being updated later with a new value. The initialization
is redundant and can be removed.

Addresses-Coverity: ("Unused value")
Signed-off-by: Colin Ian King <colin.king@canonical.com>
Link: https://lore.kernel.org/r/20200402110411.508534-1-colin.king@canonical.com
Signed-off-by: Alexandre Belloni <alexandre.belloni@bootlin.com>
4 years agortc: remove rtc_time_to_tm and rtc_tm_to_time
Alexandre Belloni [Mon, 30 Mar 2020 20:15:08 +0000 (22:15 +0200)]
rtc: remove rtc_time_to_tm and rtc_tm_to_time

There are no callers of the 32bit versions of rtc_time conversion
functions, drop them.

Link: https://lore.kernel.org/r/20200330201510.861217-1-alexandre.belloni@bootlin.com
Signed-off-by: Alexandre Belloni <alexandre.belloni@bootlin.com>
4 years agortc: sun6i: let the core handle rtc range
Alexandre Belloni [Mon, 30 Mar 2020 20:12:25 +0000 (22:12 +0200)]
rtc: sun6i: let the core handle rtc range

Let the rtc core check the date/time against the RTC range.

Tested-by: Paul Kocialkowski <paul.kocialkowski@bootlin.com>
Link: https://lore.kernel.org/r/20200330201226.860967-1-alexandre.belloni@bootlin.com
Signed-off-by: Alexandre Belloni <alexandre.belloni@bootlin.com>
4 years agortc: sun6i: switch to rtc_time64_to_tm/rtc_tm_to_time64
Alexandre Belloni [Mon, 30 Mar 2020 20:12:26 +0000 (22:12 +0200)]
rtc: sun6i: switch to rtc_time64_to_tm/rtc_tm_to_time64

Call the 64bit versions of rtc_tm time conversion.

Tested-by: Paul Kocialkowski <paul.kocialkowski@bootlin.com>
Link: https://lore.kernel.org/r/20200330201226.860967-2-alexandre.belloni@bootlin.com
Signed-off-by: Alexandre Belloni <alexandre.belloni@bootlin.com>
4 years agortc: ds1307: add support for watchdog timer on ds1388
Chris Packham [Mon, 30 Mar 2020 02:55:00 +0000 (15:55 +1300)]
rtc: ds1307: add support for watchdog timer on ds1388

The DS1388 variant has watchdog timer capabilities. When using a DS1388
and having enabled CONFIG_WATCHDOG_CORE register a watchdog device for
the DS1388.

Signed-off-by: Chris Packham <chris.packham@alliedtelesis.co.nz>
Reviewed-by: Guenter Roeck <linux@roeck-us.net>
Link: https://lore.kernel.org/r/20200330025500.6991-1-chris.packham@alliedtelesis.co.nz
Signed-off-by: Alexandre Belloni <alexandre.belloni@bootlin.com>
4 years agortc: da9052: switch to rtc_time64_to_tm/rtc_tm_to_time64
Alexandre Belloni [Fri, 6 Mar 2020 07:35:47 +0000 (08:35 +0100)]
rtc: da9052: switch to rtc_time64_to_tm/rtc_tm_to_time64

Call the 64bit versions of rtc_tm time conversion.

Acked-by: Adam Thomson <Adam.Thomson.Opensource@diasemi.com>
Link: https://lore.kernel.org/r/20200306073548.57579-3-alexandre.belloni@bootlin.com
Signed-off-by: Alexandre Belloni <alexandre.belloni@bootlin.com>
4 years agortc: da9052: set range
Alexandre Belloni [Fri, 6 Mar 2020 07:35:46 +0000 (08:35 +0100)]
rtc: da9052: set range

The da9052 is an rtc valid from 2000 to 2063 (max year is 63).

Acked-by: Adam Thomson <Adam.Thomson.Opensource@diasemi.com>
Link: https://lore.kernel.org/r/20200306073548.57579-2-alexandre.belloni@bootlin.com
Signed-off-by: Alexandre Belloni <alexandre.belloni@bootlin.com>
4 years agortc: da9052: convert to devm_rtc_allocate_device
Alexandre Belloni [Sun, 29 Mar 2020 22:42:40 +0000 (00:42 +0200)]
rtc: da9052: convert to devm_rtc_allocate_device

This allows further improvement of the driver.

Acked-by: Adam Thomson <Adam.Thomson.Opensource@diasemi.com>
Link: https://lore.kernel.org/r/20200329224240.776568-1-alexandre.belloni@bootlin.com
Signed-off-by: Alexandre Belloni <alexandre.belloni@bootlin.com>
4 years agortc: imx-sc: Align imx sc msg structs to 4
Leonard Crestez [Thu, 20 Feb 2020 16:29:38 +0000 (18:29 +0200)]
rtc: imx-sc: Align imx sc msg structs to 4

The imx SC api strongly assumes that messages are composed out of
4-bytes words but some of our message structs have odd sizeofs.

This produces many oopses with CONFIG_KASAN=y.

Fix by marking with __aligned(4).

Fixes: a3094fc1a15e ("rtc: imx-sc: add rtc alarm support")
Signed-off-by: Leonard Crestez <leonard.crestez@nxp.com>
Link: https://lore.kernel.org/r/13404bac8360852d86c61fad5ae5f0c91ffc4cb6.1582216144.git.leonard.crestez@nxp.com
Signed-off-by: Alexandre Belloni <alexandre.belloni@bootlin.com>
4 years agortc: fsl-ftm-alarm: report alarm to core
Biwen Li [Fri, 27 Mar 2020 08:44:57 +0000 (16:44 +0800)]
rtc: fsl-ftm-alarm: report alarm to core

Report interrupt state to the RTC core.

Signed-off-by: Biwen Li <biwen.li@nxp.com>
Link: https://lore.kernel.org/r/20200327084457.45161-1-biwen.li@nxp.com
Signed-off-by: Alexandre Belloni <alexandre.belloni@bootlin.com>
4 years agortc: pcf85063: Add pcf85063 clkout control to common clock framework
Michael McCormick [Fri, 24 Jan 2020 01:52:38 +0000 (14:52 +1300)]
rtc: pcf85063: Add pcf85063 clkout control to common clock framework

The PCF85063 has a configurable clock output signal. Add support for it
using in the CCF.

Signed-off-by: Michael McCormick <michael.mccormick@enatel.net>
Link: https://lore.kernel.org/r/20200124015239.24662-1-michael.mccormick@enatel.net
Signed-off-by: Alexandre Belloni <alexandre.belloni@bootlin.com>
4 years agortc: make definitions in include/uapi/linux/rtc.h actually useful for user space
Eugene Syromiatnikov [Tue, 24 Mar 2020 04:12:09 +0000 (05:12 +0100)]
rtc: make definitions in include/uapi/linux/rtc.h actually useful for user space

BIT() macro is not defined in UAPI headers; there is, however, similarly
defined _BITUL() macro present in include/uapi/linux/const.h; use it
instead and include <linux/const.h> and <linux/ioctl.h> in order to make
the definitions provided in the header useful.

Fixes: 3431ca4837bf ("rtc: define RTC_VL_READ values")
Signed-off-by: Eugene Syromiatnikov <esyr@redhat.com>
Link: https://lore.kernel.org/r/20200324041209.GA30727@asgard.redhat.com
Signed-off-by: Alexandre Belloni <alexandre.belloni@bootlin.com>
4 years agortc: class: avoid unnecessary lookup in hctosys
Alexandre Belloni [Mon, 23 Mar 2020 21:30:39 +0000 (22:30 +0100)]
rtc: class: avoid unnecessary lookup in hctosys

rtc_hctosys is only called when the relevant RTC is found, avoid looking it
up while we already have a pinter to the proper struct rtc_device.

Link: https://lore.kernel.org/r/20200323213039.297458-1-alexandre.belloni@bootlin.com
Signed-off-by: Alexandre Belloni <alexandre.belloni@bootlin.com>
4 years agodt-bindings: rtc: Convert and update jz4740-rtc doc to YAML
Paul Cercueil [Wed, 11 Mar 2020 18:23:18 +0000 (19:23 +0100)]
dt-bindings: rtc: Convert and update jz4740-rtc doc to YAML

Convert the jz4740-rtc doc to YAML, and update it to reflect the new
changes in the driver:
- More compatible strings are specified, with fallbacks if needed,
- The vendor-specific properties are now properly prefixed with the
  'ingenic,' prefix.

Signed-off-by: Paul Cercueil <paul@crapouillou.net>
Reviewed-by: Rob Herring <robh@kernel.org>
Link: https://lore.kernel.org/r/20200311182318.22154-3-paul@crapouillou.net
Signed-off-by: Alexandre Belloni <alexandre.belloni@bootlin.com>
4 years agortc: jz4740: Rename vendor-specific DT properties
Paul Cercueil [Wed, 11 Mar 2020 18:23:17 +0000 (19:23 +0100)]
rtc: jz4740: Rename vendor-specific DT properties

These properties are never set anywhere within any of the upstream
devicetree files, so I assume I'm not breaking the ABI with this change.

Rename vendor-specific DT properties to have the 'ingenic,' prefix,
which they should have had from the start.

Signed-off-by: Paul Cercueil <paul@crapouillou.net>
Link: https://lore.kernel.org/r/20200311182318.22154-2-paul@crapouillou.net
Signed-off-by: Alexandre Belloni <alexandre.belloni@bootlin.com>
4 years agortc: jz4740: Add support for JZ4760 SoC
Paul Cercueil [Wed, 11 Mar 2020 18:23:16 +0000 (19:23 +0100)]
rtc: jz4740: Add support for JZ4760 SoC

The WENR feature (set a magic value to enable RTC registers read-write)
first appeared on the JZ4760; the JZ4780 came much later.

Since it would be dangerous to specify a newer SoC's compatible string as
the fallback of an older SoC's compatible string, we add support for the
"ingenic,jz4760-rtc" compatible string in the driver.

This will permit to support the JZ4770 by having:
compatible = "ingenic,jz4770-rtc", "ingenic,jz4760-rtc";

Instead of doing:
compatible = "ingenic,jz4770-rtc", "ingenic,jz4780-rtc";

Signed-off-by: Paul Cercueil <paul@crapouillou.net>
Link: https://lore.kernel.org/r/20200311182318.22154-1-paul@crapouillou.net
Signed-off-by: Alexandre Belloni <alexandre.belloni@bootlin.com>
4 years agortc: class: support hctosys from modular RTC drivers
Steve Muckle [Wed, 6 Nov 2019 19:46:25 +0000 (11:46 -0800)]
rtc: class: support hctosys from modular RTC drivers

Due to distribution constraints it may not be possible to statically
compile the required RTC driver into the kernel.

Expand RTC_HCTOSYS support to cover all RTC devices (statically compiled
or not) by checking at the end of RTC device registration whether the
time should be synced.

Signed-off-by: Steve Muckle <smuckle@google.com>
Link: https://lore.kernel.org/r/20191106194625.116692-1-smuckle@google.com
Signed-off-by: Alexandre Belloni <alexandre.belloni@bootlin.com>
4 years agortc: pm8xxx: clear alarm register when alarm is not enabled
韩科才 [Sat, 21 Mar 2020 11:50:17 +0000 (19:50 +0800)]
rtc: pm8xxx: clear alarm register when alarm is not enabled

Clear alarm register when alarm is not enabled otherwise the consumer
may still start alarm timer if it find the alarm register is not zero.

Signed-off-by: hankecai <hankecai@vivo.com>
Link: https://lore.kernel.org/r/APoAZgAaCEiRpKG6PlzreaqE.1.1584791417367.Hmail.hankecai@vivo.com
Signed-off-by: Alexandre Belloni <alexandre.belloni@bootlin.com>
4 years agortc: omap: drop unused dt-bindings header
Uwe Kleine-König [Sat, 21 Mar 2020 20:37:37 +0000 (21:37 +0100)]
rtc: omap: drop unused dt-bindings header

The definitons in the dt-binding's gpio header only contains some
constants to be used in device trees. It is not relevant for rtc-omap
(as the gpio API hides the details) and in fact unused so it can just be
dropped.

Signed-off-by: Uwe Kleine-König <uwe@kleine-koenig.org>
Link: https://lore.kernel.org/r/20200321203737.29850-1-uwe@kleine-koenig.org
Signed-off-by: Alexandre Belloni <alexandre.belloni@bootlin.com>
4 years agortc: bd70528: Avoid double error messaging when IRQ absent
Keyur Patel [Sat, 21 Mar 2020 18:08:37 +0000 (14:08 -0400)]
rtc: bd70528: Avoid double error messaging when IRQ absent

Since the commit 7723f4c ("driver core: platform: Add an error message
to platform_get_irq*()") platform_get_irq() started issuing an error message.
Thus, there is no need to have the same in the driver.

Signed-off-by: Keyur Patel <iamkeyur96@gmail.com>
Link: https://lore.kernel.org/r/20200321180838.12729-1-iamkeyur96@gmail.com
Signed-off-by: Alexandre Belloni <alexandre.belloni@bootlin.com>
4 years agortc: max8907: add missing select REGMAP_IRQ
Corentin Labbe [Wed, 18 Mar 2020 15:26:49 +0000 (15:26 +0000)]
rtc: max8907: add missing select REGMAP_IRQ

I have hit the following build error:
armv7a-hardfloat-linux-gnueabi-ld: drivers/rtc/rtc-max8907.o: in function `max8907_rtc_probe':
rtc-max8907.c:(.text+0x400): undefined reference to `regmap_irq_get_virq'

max8907 should select REGMAP_IRQ

Fixes: 94c01ab6d7544 ("rtc: add MAX8907 RTC driver")
Cc: stable <stable@vger.kernel.org>
Signed-off-by: Corentin Labbe <clabbe@baylibre.com>
Link: https://lore.kernel.org/r/1584545209-20433-1-git-send-email-clabbe@baylibre.com
Signed-off-by: Alexandre Belloni <alexandre.belloni@bootlin.com>
4 years agortc: fsl-ftm-alarm: enable acpi support
Peng Ma [Wed, 18 Mar 2020 02:53:54 +0000 (10:53 +0800)]
rtc: fsl-ftm-alarm: enable acpi support

This patch enables ACPI support in Rtc Flex timer driver.

Signed-off-by: Peng Ma <peng.ma@nxp.com>
Link: https://lore.kernel.org/r/20200318025354.6447-1-peng.ma@nxp.com
Link: https://lore.kernel.org/r/20200323072956.38263-1-peng.ma@nxp.com
Signed-off-by: Alexandre Belloni <alexandre.belloni@bootlin.com>
4 years agortc: mxc: Use devm_add_action_or_reset() for calls to clk_disable_unprepare()
Anson Huang [Mon, 16 Mar 2020 09:09:45 +0000 (17:09 +0800)]
rtc: mxc: Use devm_add_action_or_reset() for calls to clk_disable_unprepare()

Use devm_add_action_or_reset() for calls to clk_disable_unprepare(),
which can simplify the error handling, and .remove callback can be dropped.

Signed-off-by: Anson Huang <Anson.Huang@nxp.com>
Link: https://lore.kernel.org/r/1584349785-27042-1-git-send-email-Anson.Huang@nxp.com
Signed-off-by: Alexandre Belloni <alexandre.belloni@bootlin.com>
4 years agortc: ds1307: handle oscillator failure flags for ds1388 variant
Chris Packham [Fri, 7 Feb 2020 03:18:11 +0000 (16:18 +1300)]
rtc: ds1307: handle oscillator failure flags for ds1388 variant

The FLAG register is at a different location to the other supported RTCs
so this requires an extra case in the existing switch statement.

Signed-off-by: Chris Packham <chris.packham@alliedtelesis.co.nz>
Link: https://lore.kernel.org/r/20200207031812.14424-2-chris.packham@alliedtelesis.co.nz
Signed-off-by: Alexandre Belloni <alexandre.belloni@bootlin.com>
4 years agortc: mt2712: fix build without PM_SLEEP
Alexandre Belloni [Tue, 17 Mar 2020 14:34:21 +0000 (15:34 +0100)]
rtc: mt2712: fix build without PM_SLEEP

Fix this build error when PM_SLEEP is not selected:

drivers/rtc/rtc-mt2712.c:412:10: error: ‘mt2712_pm_ops’ undeclared here (not in a function); did you mean ‘mt2712_rtc_ops’?
  412 |   .pm = &mt2712_pm_ops,
      |          ^~~~~~~~~~~~~

Link: https://lore.kernel.org/r/20200317143421.9551-1-alexandre.belloni@bootlin.com
Signed-off-by: Alexandre Belloni <alexandre.belloni@bootlin.com>
4 years agortc: 88pm860x: remove platform data support
Alexandre Belloni [Mon, 16 Mar 2020 10:25:37 +0000 (11:25 +0100)]
rtc: 88pm860x: remove platform data support

There is no users of the rtc platform data left, remove its support.

Link: https://lore.kernel.org/r/20200316102537.180398-1-alexandre.belloni@bootlin.com
Signed-off-by: Alexandre Belloni <alexandre.belloni@bootlin.com>
4 years agortc: 88pm860x: switch to rtc_time64_to_tm/rtc_tm_to_time64
Alexandre Belloni [Wed, 11 Mar 2020 22:39:56 +0000 (23:39 +0100)]
rtc: 88pm860x: switch to rtc_time64_to_tm/rtc_tm_to_time64

Call the 64bit versions of rtc_tm time conversion.

Link: https://lore.kernel.org/r/20200311223956.51352-6-alexandre.belloni@bootlin.com
Signed-off-by: Alexandre Belloni <alexandre.belloni@bootlin.com>
4 years agortc: 88pm860x: stop mangling alarm time
Alexandre Belloni [Wed, 11 Mar 2020 22:39:55 +0000 (23:39 +0100)]
rtc: 88pm860x: stop mangling alarm time

The RTC core always passes a valid alarm time there is no need to modify
it.

Link: https://lore.kernel.org/r/20200311223956.51352-5-alexandre.belloni@bootlin.com
Signed-off-by: Alexandre Belloni <alexandre.belloni@bootlin.com>
4 years agortc: 88pm860x: set range
Alexandre Belloni [Wed, 11 Mar 2020 22:39:54 +0000 (23:39 +0100)]
rtc: 88pm860x: set range

The 88pm860x RTC is a 32bit read only seconds counter with a 32bit offset.

Link: https://lore.kernel.org/r/20200311223956.51352-4-alexandre.belloni@bootlin.com
Signed-off-by: Alexandre Belloni <alexandre.belloni@bootlin.com>
4 years agortc: 88pm860x: stop calling unused callback
Alexandre Belloni [Wed, 11 Mar 2020 22:39:53 +0000 (23:39 +0100)]
rtc: 88pm860x: stop calling unused callback

pdata->sync is not defined by any platform, stop calling it.

Link: https://lore.kernel.org/r/20200311223956.51352-3-alexandre.belloni@bootlin.com
Signed-off-by: Alexandre Belloni <alexandre.belloni@bootlin.com>
4 years agortc: 88pm860x: stop setting a default time
Alexandre Belloni [Wed, 11 Mar 2020 22:39:52 +0000 (23:39 +0100)]
rtc: 88pm860x: stop setting a default time

It doesn't make sense to set the RTC to a default value at probe time. Let
the core handle invalid date and time.

Link: https://lore.kernel.org/r/20200311223956.51352-2-alexandre.belloni@bootlin.com
Signed-off-by: Alexandre Belloni <alexandre.belloni@bootlin.com>
4 years agortc: 88pm860x: fix possible race condition
Alexandre Belloni [Wed, 11 Mar 2020 22:39:51 +0000 (23:39 +0100)]
rtc: 88pm860x: fix possible race condition

The RTC IRQ is requested before the struct rtc_device is allocated,
this may lead to a NULL pointer dereference in the 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.

Also remove the unnecessary error message as the core already prints the
info.

Link: https://lore.kernel.org/r/20200311223956.51352-1-alexandre.belloni@bootlin.com
Signed-off-by: Alexandre Belloni <alexandre.belloni@bootlin.com>
4 years agortc: snvs: Use devm_add_action_or_reset() for calls to clk_disable_unprepare()
Anson Huang [Fri, 13 Mar 2020 14:30:49 +0000 (22:30 +0800)]
rtc: snvs: Use devm_add_action_or_reset() for calls to clk_disable_unprepare()

Use devm_add_action_or_reset() for calls to clk_disable_unprepare(),
which can simplify the error handling.

Signed-off-by: Anson Huang <Anson.Huang@nxp.com>
Link: https://lore.kernel.org/r/1584109849-21402-1-git-send-email-Anson.Huang@nxp.com
Link: https://lore.kernel.org/r/1584233264-26025-1-git-send-email-Anson.Huang@nxp.com
Signed-off-by: Alexandre Belloni <alexandre.belloni@bootlin.com>
4 years agoMAINTAINERS: add MT2712 RTC files
Ran Bi [Wed, 26 Feb 2020 05:13:03 +0000 (13:13 +0800)]
MAINTAINERS: add MT2712 RTC files

This patch add MT2712 RTC related files to MAINTAINERS file.

Signed-off-by: Ran Bi <ran.bi@mediatek.com>
Link: https://lore.kernel.org/r/20200226051303.22560-5-ran.bi@mediatek.com
Signed-off-by: Alexandre Belloni <alexandre.belloni@bootlin.com>
4 years agortc: add support for the MediaTek MT2712 RTC
Ran Bi [Wed, 26 Feb 2020 05:13:01 +0000 (13:13 +0800)]
rtc: add support for the MediaTek MT2712 RTC

This add support for the MediaTek MT2712 RTC. It was SoC based RTC, but
had different architecture compared with MT7622 RTC.

Signed-off-by: Ran Bi <ran.bi@mediatek.com>
Link: https://lore.kernel.org/r/20200226051303.22560-3-ran.bi@mediatek.com
Link: https://lore.kernel.org/r/20200316104701.209293-2-alexandre.belloni@bootlin.com
Signed-off-by: Alexandre Belloni <alexandre.belloni@bootlin.com>
4 years agodt-bindings: rtc: add bindings for MT2712 RTC
Ran Bi [Wed, 26 Feb 2020 05:13:00 +0000 (13:13 +0800)]
dt-bindings: rtc: add bindings for MT2712 RTC

Document the binding for MT2712 RTC implemented by rtc-mt2712.

Reviewed-by: Rob Herring <robh@kernel.org>
Signed-off-by: Ran Bi <ran.bi@mediatek.com>
Link: https://lore.kernel.org/r/20200226051303.22560-2-ran.bi@mediatek.com
Signed-off-by: Alexandre Belloni <alexandre.belloni@bootlin.com>
4 years agortc: m48t35: remove SGI-IP27 kludge
Thomas Bogendoerfer [Mon, 9 Mar 2020 12:35:14 +0000 (13:35 +0100)]
rtc: m48t35: remove SGI-IP27 kludge

With the IOC3 MFD driver it's no longer necessary to special case SGI-IP27.

Signed-off-by: Thomas Bogendoerfer <tsbogend@alpha.franken.de>
Link: https://lore.kernel.org/r/20200309123514.15543-1-tsbogend@alpha.franken.de
Signed-off-by: Alexandre Belloni <alexandre.belloni@bootlin.com>
4 years agortc: sun6i: Make external 32k oscillator optional
Jernej Skrabec [Sun, 8 Mar 2020 13:58:48 +0000 (14:58 +0100)]
rtc: sun6i: Make external 32k oscillator optional

Some boards, like OrangePi PC2 (H5), OrangePi Plus 2E (H3) and Tanix TX6
(H6) don't have external 32kHz oscillator. Till H6, it didn't really
matter if external oscillator was enabled because HW detected error and
fall back to internal one. H6 has same functionality but it's the first
SoC which have "auto switch bypass" bit documented and always enabled in
driver. This prevents RTC to work correctly if external crystal is not
present on board. There are other side effects - all peripherals which
depends on this clock also don't work (HDMI CEC for example).

Make clocks property optional. If it is present, select external
oscillator. If not, stay on internal.

Signed-off-by: Jernej Skrabec <jernej.skrabec@siol.net>
Acked-by: Maxime Ripard <mripard@kernel.org>
Link: https://lore.kernel.org/r/20200308135849.106333-2-jernej.skrabec@siol.net
Signed-off-by: Alexandre Belloni <alexandre.belloni@bootlin.com>
4 years agortc: puv3: switch to rtc_time64_to_tm/rtc_tm_to_time64
Alexandre Belloni [Fri, 6 Mar 2020 01:02:39 +0000 (02:02 +0100)]
rtc: puv3: switch to rtc_time64_to_tm/rtc_tm_to_time64

Call the 64bit versions of rtc_tm time conversion.

Link: https://lore.kernel.org/r/20200306010240.40056-2-alexandre.belloni@bootlin.com
Signed-off-by: Alexandre Belloni <alexandre.belloni@bootlin.com>
4 years agortc: puv3: set range
Alexandre Belloni [Fri, 6 Mar 2020 01:02:38 +0000 (02:02 +0100)]
rtc: puv3: set range

This RTC is a 32bit seconds counter.

Link: https://lore.kernel.org/r/20200306010240.40056-1-alexandre.belloni@bootlin.com
Signed-off-by: Alexandre Belloni <alexandre.belloni@bootlin.com>
4 years agortc: ab8500: switch to rtc_time64_to_tm/rtc_tm_to_time64
Alexandre Belloni [Fri, 6 Mar 2020 01:01:01 +0000 (02:01 +0100)]
rtc: ab8500: switch to rtc_time64_to_tm/rtc_tm_to_time64

Call the 64bit versions of rtc_tm time conversion.

Acked-by: Linus Walleij <linus.walleij@linaro.org>
Link: https://lore.kernel.org/r/20200306010101.39517-1-alexandre.belloni@bootlin.com
Signed-off-by: Alexandre Belloni <alexandre.belloni@bootlin.com>
4 years agortc: pl031: switch to rtc_time64_to_tm/rtc_tm_to_time64
Alexandre Belloni [Fri, 6 Mar 2020 00:58:09 +0000 (01:58 +0100)]
rtc: pl031: switch to rtc_time64_to_tm/rtc_tm_to_time64

Call the 64bit versions of rtc_tm time conversion to allow extending
support after 2106 and properly supporting the STv2 range.

Acked-by: Linus Walleij <linus.walleij@linaro.org>
Link: https://lore.kernel.org/r/20200306005809.38530-3-alexandre.belloni@bootlin.com
Signed-off-by: Alexandre Belloni <alexandre.belloni@bootlin.com>
4 years agortc: pl031: set range
Alexandre Belloni [Fri, 6 Mar 2020 00:58:08 +0000 (01:58 +0100)]
rtc: pl031: set range

The PL031 and ST v1 RTC are 32bit seconds counters. STv2 is a BCD RTC
apparently going from 0000 to 9999, hopefully handling the leap days
properly until then.

Reviewed-by: Linus Walleij <linus.walleij@linaro.org>
Link: https://lore.kernel.org/r/20200306005809.38530-2-alexandre.belloni@bootlin.com
Signed-off-by: Alexandre Belloni <alexandre.belloni@bootlin.com>
4 years agortc: pl031: remove useless invalid alarm handling
Alexandre Belloni [Fri, 6 Mar 2020 00:58:07 +0000 (01:58 +0100)]
rtc: pl031: remove useless invalid alarm handling

The core will never pass an invalid alarm to .set_alarm, it is not
necessary to check for its validity.

Acked-by: Linus Walleij <linus.walleij@linaro.org>
Link: https://lore.kernel.org/r/20200306005809.38530-1-alexandre.belloni@bootlin.com
Signed-off-by: Alexandre Belloni <alexandre.belloni@bootlin.com>
4 years agortc: fsl-ftm-alarm: allow COMPILE_TEST
Alexandre Belloni [Fri, 6 Mar 2020 13:16:28 +0000 (14:16 +0100)]
rtc: fsl-ftm-alarm: allow COMPILE_TEST

Allow building building the driver with COMPILE_TEST.

Link: https://lore.kernel.org/r/20200306131629.18837-1-alexandre.belloni@bootlin.com
Signed-off-by: Alexandre Belloni <alexandre.belloni@bootlin.com>
4 years agortc: mpc5121: switch to rtc_time64_to_tm/rtc_tm_to_time64
Alexandre Belloni [Fri, 6 Mar 2020 07:44:03 +0000 (08:44 +0100)]
rtc: mpc5121: switch to rtc_time64_to_tm/rtc_tm_to_time64

Call the 64bit versions of rtc_tm time conversion.

Link: https://lore.kernel.org/r/20200306074404.58909-4-alexandre.belloni@bootlin.com
Signed-off-by: Alexandre Belloni <alexandre.belloni@bootlin.com>
4 years agortc: mpc5121: set range
Alexandre Belloni [Fri, 6 Mar 2020 07:44:02 +0000 (08:44 +0100)]
rtc: mpc5121: set range

The datasheet states that 4052 is the maximum value for year. However, the
mpc5121 read_time and set_time function abuse the target time register
instead of using the broken down time so it is limited to 2106.

Link: https://lore.kernel.org/r/20200306074404.58909-3-alexandre.belloni@bootlin.com
Signed-off-by: Alexandre Belloni <alexandre.belloni@bootlin.com>
4 years agortc: mpc5121: convert to devm_rtc_allocate_device
Alexandre Belloni [Fri, 6 Mar 2020 07:44:01 +0000 (08:44 +0100)]
rtc: mpc5121: convert to devm_rtc_allocate_device

This simplifies the path for the rtc_ops selection.

Link: https://lore.kernel.org/r/20200306074404.58909-2-alexandre.belloni@bootlin.com
Signed-off-by: Alexandre Belloni <alexandre.belloni@bootlin.com>
4 years agortc: mpc5121: simplify probe
Alexandre Belloni [Fri, 6 Mar 2020 07:44:00 +0000 (08:44 +0100)]
rtc: mpc5121: simplify probe

Use devm managed function to simplify probe and remove.

Link: https://lore.kernel.org/r/20200306074404.58909-1-alexandre.belloni@bootlin.com
Signed-off-by: Alexandre Belloni <alexandre.belloni@bootlin.com>
4 years agortc: pm8xxx: stop validating valid alarm time
Alexandre Belloni [Fri, 6 Mar 2020 07:37:58 +0000 (08:37 +0100)]
rtc: pm8xxx: stop validating valid alarm time

rtc_time64_to_tm never generates an invalid rtc_tm, stop validating it.

Link: https://lore.kernel.org/r/20200306073758.58050-4-alexandre.belloni@bootlin.com
Signed-off-by: Alexandre Belloni <alexandre.belloni@bootlin.com>
4 years agortc: pm8xxx: : switch to rtc_time64_to_tm/rtc_tm_to_time64
Alexandre Belloni [Fri, 6 Mar 2020 07:37:57 +0000 (08:37 +0100)]
rtc: pm8xxx: : switch to rtc_time64_to_tm/rtc_tm_to_time64

Call the 64bit versions of rtc_tm time conversion.

Link: https://lore.kernel.org/r/20200306073758.58050-3-alexandre.belloni@bootlin.com
Signed-off-by: Alexandre Belloni <alexandre.belloni@bootlin.com>
4 years agortc: pm8xxx: set range
Alexandre Belloni [Fri, 6 Mar 2020 07:37:56 +0000 (08:37 +0100)]
rtc: pm8xxx: set range

The pm8xxx are 32bit seconds counter.

Link: https://lore.kernel.org/r/20200306073758.58050-2-alexandre.belloni@bootlin.com
Signed-off-by: Alexandre Belloni <alexandre.belloni@bootlin.com>
4 years agortc: pm8xxx: convert to devm_rtc_allocate_device
Alexandre Belloni [Fri, 6 Mar 2020 07:37:55 +0000 (08:37 +0100)]
rtc: pm8xxx: convert to devm_rtc_allocate_device

This allows further improvement of the driver. Also remove the unnecessary
error string as the core will already display error messages.

Link: https://lore.kernel.org/r/20200306073758.58050-1-alexandre.belloni@bootlin.com
Signed-off-by: Alexandre Belloni <alexandre.belloni@bootlin.com>
4 years agortc: ds1305: switch to rtc_tm_to_time64
Alexandre Belloni [Fri, 6 Mar 2020 07:34:59 +0000 (08:34 +0100)]
rtc: ds1305: switch to rtc_tm_to_time64

Call the 64bit version of rtc_tm to time conversion.

Link: https://lore.kernel.org/r/20200306073459.57197-2-alexandre.belloni@bootlin.com
Signed-off-by: Alexandre Belloni <alexandre.belloni@bootlin.com>
4 years agortc: ds1305: set range
Alexandre Belloni [Fri, 6 Mar 2020 07:34:58 +0000 (08:34 +0100)]
rtc: ds1305: set range

The ds1305 is a BCD rtc valid from 2000 to 2099.

Link: https://lore.kernel.org/r/20200306073459.57197-1-alexandre.belloni@bootlin.com
Signed-off-by: Alexandre Belloni <alexandre.belloni@bootlin.com>
4 years agortc: ds1374: switch to rtc_time64_to_tm/rtc_tm_to_time64
Alexandre Belloni [Fri, 6 Mar 2020 07:34:03 +0000 (08:34 +0100)]
rtc: ds1374: switch to rtc_time64_to_tm/rtc_tm_to_time64

Call the 64bit versions of rtc_tm time conversion.

Link: https://lore.kernel.org/r/20200306073404.56921-3-alexandre.belloni@bootlin.com
Signed-off-by: Alexandre Belloni <alexandre.belloni@bootlin.com>
4 years agortc: ds1374: set range
Alexandre Belloni [Fri, 6 Mar 2020 07:34:02 +0000 (08:34 +0100)]
rtc: ds1374: set range

The ds1374 is a 32bit seconds counter.

Link: https://lore.kernel.org/r/20200306073404.56921-2-alexandre.belloni@bootlin.com
Signed-off-by: Alexandre Belloni <alexandre.belloni@bootlin.com>
4 years agortc: ds1374: fix possible race condition
Alexandre Belloni [Fri, 6 Mar 2020 07:34:01 +0000 (08:34 +0100)]
rtc: ds1374: fix possible race condition

The RTC IRQ is requested before the struct rtc_device is allocated,
this may lead to a NULL pointer dereference in the 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.

Link: https://lore.kernel.org/r/20200306073404.56921-1-alexandre.belloni@bootlin.com
Signed-off-by: Alexandre Belloni <alexandre.belloni@bootlin.com>
4 years agortc: cpcap: switch to rtc_time64_to_tm/rtc_tm_to_time64
Alexandre Belloni [Fri, 6 Mar 2020 01:57:03 +0000 (02:57 +0100)]
rtc: cpcap: switch to rtc_time64_to_tm/rtc_tm_to_time64

Call the 64bit versions of rtc_tm time conversion.

Link: https://lore.kernel.org/r/20200306015703.42101-3-alexandre.belloni@bootlin.com
Signed-off-by: Alexandre Belloni <alexandre.belloni@bootlin.com>
4 years agortc: cpcap: set range
Alexandre Belloni [Fri, 6 Mar 2020 01:57:02 +0000 (02:57 +0100)]
rtc: cpcap: set range

The CPCAP rtc is a 14bit day counter plus a 17bit seconds counter.

Note that this failed on Nov 10 2014 so it is very likely this driver as
never been used since.

Link: https://lore.kernel.org/r/20200306015703.42101-2-alexandre.belloni@bootlin.com
Signed-off-by: Alexandre Belloni <alexandre.belloni@bootlin.com>
4 years agortc: cpcap: convert to devm_rtc_allocate_device
Alexandre Belloni [Fri, 6 Mar 2020 01:57:01 +0000 (02:57 +0100)]
rtc: cpcap: convert to devm_rtc_allocate_device

This allows further improvement of the driver.

Link: https://lore.kernel.org/r/20200306015703.42101-1-alexandre.belloni@bootlin.com
Signed-off-by: Alexandre Belloni <alexandre.belloni@bootlin.com>
4 years agortc: sa1100: switch to rtc_time64_to_tm/rtc_tm_to_time64
Alexandre Belloni [Fri, 6 Mar 2020 01:01:46 +0000 (02:01 +0100)]
rtc: sa1100: switch to rtc_time64_to_tm/rtc_tm_to_time64

Call the 64bit versions of rtc_tm time conversion.

Link: https://lore.kernel.org/r/20200306010146.39762-3-alexandre.belloni@bootlin.com
Signed-off-by: Alexandre Belloni <alexandre.belloni@bootlin.com>
4 years agortc: sa1100: set range
Alexandre Belloni [Fri, 6 Mar 2020 01:01:45 +0000 (02:01 +0100)]
rtc: sa1100: set range

The SA1100 RTC is a 32bit seconds counter.

Link: https://lore.kernel.org/r/20200306010146.39762-2-alexandre.belloni@bootlin.com
Signed-off-by: Alexandre Belloni <alexandre.belloni@bootlin.com>
4 years agortc: sa1100: fix possible race condition
Alexandre Belloni [Fri, 6 Mar 2020 01:01:44 +0000 (02:01 +0100)]
rtc: sa1100: fix possible race condition

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

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

Link: https://lore.kernel.org/r/20200306010146.39762-1-alexandre.belloni@bootlin.com
Signed-off-by: Alexandre Belloni <alexandre.belloni@bootlin.com>
4 years agortc: au1xxx: switch to rtc_time64_to_tm/rtc_tm_to_time64
Alexandre Belloni [Fri, 6 Mar 2020 00:59:58 +0000 (01:59 +0100)]
rtc: au1xxx: switch to rtc_time64_to_tm/rtc_tm_to_time64

Call the 64bit versions of rtc_tm time conversion.

Link: https://lore.kernel.org/r/20200306005958.39203-4-alexandre.belloni@bootlin.com
Signed-off-by: Alexandre Belloni <alexandre.belloni@bootlin.com>
4 years agortc: au1xxx: set range
Alexandre Belloni [Fri, 6 Mar 2020 00:59:57 +0000 (01:59 +0100)]
rtc: au1xxx: set range

The Alchemy counter0 is a 32bit seconds counter.

Link: https://lore.kernel.org/r/20200306005958.39203-3-alexandre.belloni@bootlin.com
Signed-off-by: Alexandre Belloni <alexandre.belloni@bootlin.com>
4 years agortc: au1xxx: remove goto label
Alexandre Belloni [Fri, 6 Mar 2020 00:59:56 +0000 (01:59 +0100)]
rtc: au1xxx: remove goto label

Simplify the driver by removing the goto label as it only does return ret.

Link: https://lore.kernel.org/r/20200306005958.39203-2-alexandre.belloni@bootlin.com
Signed-off-by: Alexandre Belloni <alexandre.belloni@bootlin.com>
4 years agortc: au1xxx: convert to devm_rtc_allocate_device
Alexandre Belloni [Fri, 6 Mar 2020 00:59:55 +0000 (01:59 +0100)]
rtc: au1xxx: convert to devm_rtc_allocate_device

This allows further improvement of the driver.

Link: https://lore.kernel.org/r/20200306005958.39203-1-alexandre.belloni@bootlin.com
Signed-off-by: Alexandre Belloni <alexandre.belloni@bootlin.com>
4 years agortc: starfire: switch to rtc_time64_to_tm
Alexandre Belloni [Fri, 6 Mar 2020 00:59:10 +0000 (01:59 +0100)]
rtc: starfire: switch to rtc_time64_to_tm

Call the 64bit version of rtc_tm time conversion.

Link: https://lore.kernel.org/r/20200306005910.38939-2-alexandre.belloni@bootlin.com
Signed-off-by: Alexandre Belloni <alexandre.belloni@bootlin.com>
4 years agortc: starfire: set range
Alexandre Belloni [Fri, 6 Mar 2020 00:59:09 +0000 (01:59 +0100)]
rtc: starfire: set range

The starfire RTC is a 32bit seconds counter.

Link: https://lore.kernel.org/r/20200306005910.38939-1-alexandre.belloni@bootlin.com
Signed-off-by: Alexandre Belloni <alexandre.belloni@bootlin.com>
4 years agortc: pl030: switch to rtc_time64_to_tm/rtc_tm_to_time64
Alexandre Belloni [Fri, 6 Mar 2020 00:57:30 +0000 (01:57 +0100)]
rtc: pl030: switch to rtc_time64_to_tm/rtc_tm_to_time64

Call the 64bit versions of rtc_tm time conversion to avoid the y2106 issue.

Link: https://lore.kernel.org/r/20200306005730.38268-3-alexandre.belloni@bootlin.com
Signed-off-by: Alexandre Belloni <alexandre.belloni@bootlin.com>
4 years agortc: pl030: remove useless invalid alarm handling
Alexandre Belloni [Fri, 6 Mar 2020 00:57:29 +0000 (01:57 +0100)]
rtc: pl030: remove useless invalid alarm handling

The core will never pass an invalid alarm to .set_alarm, it is not
necessary to check for its validity.

Link: https://lore.kernel.org/r/20200306005730.38268-2-alexandre.belloni@bootlin.com
Signed-off-by: Alexandre Belloni <alexandre.belloni@bootlin.com>
4 years agortc: pl030: set range
Alexandre Belloni [Fri, 6 Mar 2020 00:57:28 +0000 (01:57 +0100)]
rtc: pl030: set range

This RTC is a 32bit seconds counter.

Link: https://lore.kernel.org/r/20200306005730.38268-1-alexandre.belloni@bootlin.com
Signed-off-by: Alexandre Belloni <alexandre.belloni@bootlin.com>
4 years agortc: davinci: remove useless error handling
Alexandre Belloni [Thu, 5 Mar 2020 21:50:22 +0000 (22:50 +0100)]
rtc: davinci: remove useless error handling

convertfromdays and convert2days never return errors, stop handling non
existent errors.

Link: https://lore.kernel.org/r/20200305215022.32533-4-alexandre.belloni@bootlin.com
Signed-off-by: Alexandre Belloni <alexandre.belloni@bootlin.com>
4 years agortc: davinci: let the core handle rtc range
Alexandre Belloni [Thu, 5 Mar 2020 21:50:21 +0000 (22:50 +0100)]
rtc: davinci: let the core handle rtc range

Let the core handle offsetting and windowing the RTC range.

This rtc has hours, minutes, seconds and 16bit days. As the driver has the
RTC epoch set to year 2000, this means that the end of the range is 2^16
days minus one second later. This is Sun Jun  6 23:59:59 UTC 2179. This
is better than the currently set year 2099.

Link: https://lore.kernel.org/r/20200305215022.32533-3-alexandre.belloni@bootlin.com
Signed-off-by: Alexandre Belloni <alexandre.belloni@bootlin.com>
4 years agortc: davinci: remove useless 24h alarm handling
Alexandre Belloni [Thu, 5 Mar 2020 21:50:20 +0000 (22:50 +0100)]
rtc: davinci: remove useless 24h alarm handling

The code handling invalid alarms meaning the alarm is in the next 24 hours
is not necessary since commit f8245c26886c ("rtc: remove "RTC_ALM_SET mode"
bugs") which actually predates this driver. Since then, .set_alarm is never
called with an invalid alarm and this handling is not necessary in the
driver.

Link: https://lore.kernel.org/r/20200305215022.32533-2-alexandre.belloni@bootlin.com
Signed-off-by: Alexandre Belloni <alexandre.belloni@bootlin.com>
4 years agortc: davinci: convert to devm_rtc_allocate_device
Alexandre Belloni [Thu, 5 Mar 2020 21:50:19 +0000 (22:50 +0100)]
rtc: davinci: convert to devm_rtc_allocate_device

This allows further improvement of the driver. Also remove the unnecessary
error string as the core will already display error messages.

Link: https://lore.kernel.org/r/20200305215022.32533-1-alexandre.belloni@bootlin.com
Signed-off-by: Alexandre Belloni <alexandre.belloni@bootlin.com>
4 years agortc: sirfsoc: switch to rtc_time64_to_tm/rtc_tm_to_time64
Alexandre Belloni [Thu, 5 Mar 2020 16:04:52 +0000 (17:04 +0100)]
rtc: sirfsoc: switch to rtc_time64_to_tm/rtc_tm_to_time64

Call the 64bit versions of rtc_tm time conversion to avoid the y2106 issue.

Link: https://lore.kernel.org/r/20200305160452.27808-3-alexandre.belloni@bootlin.com
Signed-off-by: Alexandre Belloni <alexandre.belloni@bootlin.com>
4 years agortc: sirfsoc: set range
Alexandre Belloni [Thu, 5 Mar 2020 16:04:51 +0000 (17:04 +0100)]
rtc: sirfsoc: set range

This RTC is a 32bit counter running at 16Hz. This overflows every eight
years and a half. However, the driver uses the SW_VALUE register to store
the overflow, extending the counter to 64bit as long as the update happens
before the overflow.

Link: https://lore.kernel.org/r/20200305160452.27808-2-alexandre.belloni@bootlin.com
Signed-off-by: Alexandre Belloni <alexandre.belloni@bootlin.com>
4 years agortc: sirfsoc: convert to devm_rtc_allocate_device
Alexandre Belloni [Thu, 5 Mar 2020 16:04:50 +0000 (17:04 +0100)]
rtc: sirfsoc: convert to devm_rtc_allocate_device

This allows further improvement of the driver. Also remove the unnecessary
error string as the core will already display error messages.

Link: https://lore.kernel.org/r/20200305160452.27808-1-alexandre.belloni@bootlin.com
Signed-off-by: Alexandre Belloni <alexandre.belloni@bootlin.com>
4 years agortc: snvs: Improve Kconfig dependency
Anson Huang [Mon, 2 Mar 2020 08:13:05 +0000 (16:13 +0800)]
rtc: snvs: Improve Kconfig dependency

i.MX SNVS RTC should depend on ARCH_MXC or COMPILE_TEST.

Signed-off-by: Anson Huang <Anson.Huang@nxp.com>
Link: https://lore.kernel.org/r/1583136785-4973-1-git-send-email-Anson.Huang@nxp.com
Signed-off-by: Alexandre Belloni <alexandre.belloni@bootlin.com>
4 years agortc: sysfs: use kobj_to_dev
suguosong [Tue, 25 Feb 2020 02:19:23 +0000 (10:19 +0800)]
rtc: sysfs: use kobj_to_dev

use kobj_to_dev instead of open-conding it

Signed-off-by: suguosong <suguosong@xiaomi.com>
Link: https://lore.kernel.org/r/20200225021923.8570-1-guosongsu@gmail.com
Signed-off-by: Alexandre Belloni <alexandre.belloni@bootlin.com>
4 years agortc: cmos: Use spin_lock_irqsave() in cmos_interrupt()
Ville Syrjälä [Fri, 21 Feb 2020 14:47:39 +0000 (16:47 +0200)]
rtc: cmos: Use spin_lock_irqsave() in cmos_interrupt()

cmos_interrupt() isn't always called from hardirq context, so
we must use spin_lock_irqsave() & co.

================================
WARNING: inconsistent lock state
5.6.0-rc2-CI-CI_DRM_7981+ #1 Tainted: G     U
--------------------------------
inconsistent {IN-HARDIRQ-W} -> {HARDIRQ-ON-W} usage.
rtcwake/4315 [HC0[0]:SC0[0]:HE1:SE1] takes:
ffffffff82635198 (rtc_lock){?...}, at: cmos_interrupt+0x18/0x100
{IN-HARDIRQ-W} state was registered at:
  lock_acquire+0xa7/0x1c0
  _raw_spin_lock+0x2a/0x40
  cmos_interrupt+0x18/0x100
  rtc_handler+0x75/0xc0
  acpi_ev_fixed_event_detect+0xf9/0x132
  acpi_ev_sci_xrupt_handler+0xb/0x28
  acpi_irq+0x13/0x30
  __handle_irq_event_percpu+0x41/0x2c0
  handle_irq_event_percpu+0x2b/0x70
  handle_irq_event+0x2f/0x50
  handle_fasteoi_irq+0x8e/0x150
  do_IRQ+0x7e/0x160
  ret_from_intr+0x0/0x35
  mwait_idle+0x7e/0x200
  do_idle+0x1bb/0x260
  cpu_startup_entry+0x14/0x20
  start_secondary+0x15f/0x1b0
  secondary_startup_64+0xa4/0xb0
irq event stamp: 42003
hardirqs last  enabled at (42003): [<ffffffff81a36567>] _raw_spin_unlock_irqrestore+0x47/0x60
hardirqs last disabled at (42002): [<ffffffff81a362ed>] _raw_spin_lock_irqsave+0xd/0x50
softirqs last  enabled at (41848): [<ffffffff81e00385>] __do_softirq+0x385/0x47f
softirqs last disabled at (41841): [<ffffffff810bab3a>] irq_exit+0xba/0xc0

other info that might help us debug this:
 Possible unsafe locking scenario:

       CPU0
       ----
  lock(rtc_lock);
  <Interrupt>
    lock(rtc_lock);

 *** DEADLOCK ***

6 locks held by rtcwake/4315:
 #0: ffff888175dc9408 (sb_writers#5){.+.+}, at: vfs_write+0x1a4/0x1d0
 #1: ffff88817406ca80 (&of->mutex){+.+.}, at: kernfs_fop_write+0xdd/0x1b0
 #2: ffff888179be85e0 (kn->count#236){.+.+}, at: kernfs_fop_write+0xe6/0x1b0
 #3: ffffffff82641e00 (system_transition_mutex){+.+.}, at: pm_suspend+0xb3/0x3b0
 #4: ffffffff826b3ee0 (acpi_scan_lock){+.+.}, at: acpi_suspend_begin+0x47/0x80
 #5: ffff888178fc3960 (&dev->mutex){....}, at: device_resume+0x92/0x1c0

stack backtrace:
CPU: 3 PID: 4315 Comm: rtcwake Tainted: G     U            5.6.0-rc2-CI-CI_DRM_7981+ #1
Hardware name: Google Soraka/Soraka, BIOS MrChromebox-4.10 08/25/2019
Call Trace:
 dump_stack+0x71/0x9b
 mark_lock+0x49a/0x500
 ? print_shortest_lock_dependencies+0x200/0x200
 __lock_acquire+0x6d4/0x15d0
 ? __lock_acquire+0x460/0x15d0
 lock_acquire+0xa7/0x1c0
 ? cmos_interrupt+0x18/0x100
 _raw_spin_lock+0x2a/0x40
 ? cmos_interrupt+0x18/0x100
 cmos_interrupt+0x18/0x100
 cmos_resume+0x1fd/0x290
 ? __acpi_pm_set_device_wakeup+0x24/0x100
 pnp_bus_resume+0x5e/0x90
 ? pnp_bus_suspend+0x10/0x10
 dpm_run_callback+0x64/0x280
 device_resume+0xd4/0x1c0
 ? dpm_watchdog_set+0x60/0x60
 dpm_resume+0x106/0x410
 ? dpm_resume_early+0x38c/0x3e0
 dpm_resume_end+0x8/0x10
 suspend_devices_and_enter+0x16f/0xbe0
 ? rcu_read_lock_sched_held+0x4d/0x80
 pm_suspend+0x344/0x3b0
 state_store+0x78/0xe0
 kernfs_fop_write+0x112/0x1b0
 vfs_write+0xb9/0x1d0
 ksys_write+0x9f/0xe0
 do_syscall_64+0x4f/0x220
 entry_SYSCALL_64_after_hwframe+0x49/0xbe
RIP: 0033:0x7ff934307154
Code: 89 02 48 c7 c0 ff ff ff ff c3 66 2e 0f 1f 84 00 00 00 00 00 66 90 48 8d 05 b1 07 2e 00 8b 00 85 c0 75 13 b8 01 00 00 00 0f 05 <48> 3d 00 f0 ff ff 77 54 f3 c3 66 90 41 54 55 49 89 d4 53 48 89 f5
RSP: 002b:00007ffe2647c168 EFLAGS: 00000246 ORIG_RAX: 0000000000000001
RAX: ffffffffffffffda RBX: 0000000000000004 RCX: 00007ff934307154
RDX: 0000000000000004 RSI: 000055de3ec4e5a0 RDI: 000000000000000a
RBP: 000055de3ec4e5a0 R08: 000055de3ec4c5e0 R09: 00007ff9349f3740
R10: 000055de3ec4a010 R11: 0000000000000246 R12: 000055de3ec4c500
R13: 0000000000000004 R14: 00007ff9345df2a0 R15: 00007ff9345de760

Fixes: c6d3a278cc12 ("rtc: cmos: acknowledge ACPI driven wake alarms upon resume")
Fixes: 311ee9c151ad ("rtc: cmos: allow using ACPI for RTC alarm instead of HPET")
Signed-off-by: Ville Syrjälä <ville.syrjala@linux.intel.com>
Link: https://lore.kernel.org/r/20200221144739.11746-1-ville.syrjala@linux.intel.com
Signed-off-by: Alexandre Belloni <alexandre.belloni@bootlin.com>
4 years agortc: snvs: Remove unused include of of_device.h
Anson Huang [Sun, 16 Feb 2020 03:27:45 +0000 (11:27 +0800)]
rtc: snvs: Remove unused include of of_device.h

There is nothing in use from of_device.h, remove it.

Signed-off-by: Anson Huang <Anson.Huang@nxp.com>
Link: https://lore.kernel.org/r/1581823666-16944-1-git-send-email-Anson.Huang@nxp.com
Signed-off-by: Alexandre Belloni <alexandre.belloni@bootlin.com>
4 years agortc: zynqmp: Clear alarm interrupt status before interrupt enable
Srinivas Neeli [Wed, 12 Feb 2020 10:24:39 +0000 (15:54 +0530)]
rtc: zynqmp: Clear alarm interrupt status before interrupt enable

Fix multiple occurring interrupts for alarm interrupt. RTC module doesn't
clear the alarm interrupt status bit immediately after the interrupt is
triggered.This is due to the sticky nature of the alarm interrupt status
register. The alarm interrupt status register can be cleared only after
the second counter outruns the set alarm value. To fix multiple spurious
interrupts, disable alarm interrupt in the handler and clear the status
bit before enabling the alarm interrupt.

Fixes: 11143c19eb57 ("rtc: add xilinx zynqmp rtc driver")
Signed-off-by: Srinivas Neeli <srinivas.neeli@xilinx.com>
Acked-by: Michal Simek <michal.simek@xilinx.com>
Link: https://lore.kernel.org/r/1581503079-387-1-git-send-email-srinivas.neeli@xilinx.com
Signed-off-by: Alexandre Belloni <alexandre.belloni@bootlin.com>
4 years agortc: sh: Restore devm_ioremap() alignment
Geert Uytterhoeven [Wed, 12 Feb 2020 08:48:36 +0000 (09:48 +0100)]
rtc: sh: Restore devm_ioremap() alignment

The alignment of the continuation of the devm_ioremap() call in
sh_rtc_probe() was broken.  Join the lines, as all parameters can fit on
a single line.

Fixes: 4bdc0d676a643140 ("remove ioremap_nocache and devm_ioremap_nocache")
Signed-off-by: Geert Uytterhoeven <geert+renesas@glider.be>
Link: https://lore.kernel.org/r/20200212084836.9511-1-geert+renesas@glider.be
Signed-off-by: Alexandre Belloni <alexandre.belloni@bootlin.com>
4 years agoLinux 5.6-rc1
Linus Torvalds [Mon, 10 Feb 2020 00:08:48 +0000 (16:08 -0800)]
Linux 5.6-rc1

4 years agoMerge tag 'kbuild-v5.6-2' of git://git.kernel.org/pub/scm/linux/kernel/git/masahiroy...
Linus Torvalds [Mon, 10 Feb 2020 00:05:50 +0000 (16:05 -0800)]
Merge tag 'kbuild-v5.6-2' of git://git./linux/kernel/git/masahiroy/linux-kbuild

Pull more Kbuild updates from Masahiro Yamada:

 - fix randconfig to generate a sane .config

 - rename hostprogs-y / always to hostprogs / always-y, which are more
   natual syntax.

 - optimize scripts/kallsyms

 - fix yes2modconfig and mod2yesconfig

 - make multiple directory targets ('make foo/ bar/') work

* tag 'kbuild-v5.6-2' of git://git.kernel.org/pub/scm/linux/kernel/git/masahiroy/linux-kbuild:
  kbuild: make multiple directory targets work
  kconfig: Invalidate all symbols after changing to y or m.
  kallsyms: fix type of kallsyms_token_table[]
  scripts/kallsyms: change table to store (strcut sym_entry *)
  scripts/kallsyms: rename local variables in read_symbol()
  kbuild: rename hostprogs-y/always to hostprogs/always-y
  kbuild: fix the document to use extra-y for vmlinux.lds
  kconfig: fix broken dependency in randconfig-generated .config

4 years agoMerge tag 'zonefs-5.6-rc1' of git://git.kernel.org/pub/scm/linux/kernel/git/dlemoal...
Linus Torvalds [Sun, 9 Feb 2020 23:51:46 +0000 (15:51 -0800)]
Merge tag 'zonefs-5.6-rc1' of git://git./linux/kernel/git/dlemoal/zonefs

Pull new zonefs file system from Damien Le Moal:
 "Zonefs is a very simple file system exposing each zone of a zoned
  block device as a file.

  Unlike a regular file system with native zoned block device support
  (e.g. f2fs or the on-going btrfs effort), zonefs does not hide the
  sequential write constraint of zoned block devices to the user. As a
  result, zonefs is not a POSIX compliant file system. Its goal is to
  simplify the implementation of zoned block devices support in
  applications by replacing raw block device file accesses with a richer
  file based API, avoiding relying on direct block device file ioctls
  which may be more obscure to developers.

  One example of this approach is the implementation of LSM
  (log-structured merge) tree structures (such as used in RocksDB and
  LevelDB) on zoned block devices by allowing SSTables to be stored in a
  zone file similarly to a regular file system rather than as a range of
  sectors of a zoned device. The introduction of the higher level
  construct "one file is one zone" can help reducing the amount of
  changes needed in the application while at the same time allowing the
  use of zoned block devices with various programming languages other
  than C.

  Zonefs IO management implementation uses the new iomap generic code.
  Zonefs has been successfully tested using a functional test suite
  (available with zonefs userland format tool on github) and a prototype
  implementation of LevelDB on top of zonefs"

* tag 'zonefs-5.6-rc1' of git://git.kernel.org/pub/scm/linux/kernel/git/dlemoal/zonefs:
  zonefs: Add documentation
  fs: New zonefs file system

4 years agoirqchip/gic-v4.1: Avoid 64bit division for the sake of 32bit ARM
Marc Zyngier [Sun, 9 Feb 2020 22:48:50 +0000 (22:48 +0000)]
irqchip/gic-v4.1: Avoid 64bit division for the sake of 32bit ARM

In order to allow the GICv4 code to link properly on 32bit ARM,
make sure we don't use 64bit divisions when it isn't strictly
necessary.

Fixes: 4e6437f12d6e ("irqchip/gic-v4.1: Ensure L2 vPE table is allocated at RD level")
Reported-by: Stephen Rothwell <sfr@canb.auug.org.au>
Cc: Zenghui Yu <yuzenghui@huawei.com>
Signed-off-by: Marc Zyngier <maz@kernel.org>
Signed-off-by: Linus Torvalds <torvalds@linux-foundation.org>
4 years agoMerge tag '5.6-rc-smb3-plugfest-patches' of git://git.samba.org/sfrench/cifs-2.6
Linus Torvalds [Sun, 9 Feb 2020 21:27:17 +0000 (13:27 -0800)]
Merge tag '5.6-rc-smb3-plugfest-patches' of git://git.samba.org/sfrench/cifs-2.6

Pull cifs fixes from Steve French:
 "13 cifs/smb3 patches, most from testing at the SMB3 plugfest this week:

   - Important fix for multichannel and for modefromsid mounts.

   - Two reconnect fixes

   - Addition of SMB3 change notify support

   - Backup tools fix

   - A few additional minor debug improvements (tracepoints and
     additional logging found useful during testing this week)"

* tag '5.6-rc-smb3-plugfest-patches' of git://git.samba.org/sfrench/cifs-2.6:
  smb3: Add defines for new information level, FileIdInformation
  smb3: print warning once if posix context returned on open
  smb3: add one more dynamic tracepoint missing from strict fsync path
  cifs: fix mode bits from dir listing when mounted with modefromsid
  cifs: fix channel signing
  cifs: add SMB3 change notification support
  cifs: make multichannel warning more visible
  cifs: fix soft mounts hanging in the reconnect code
  cifs: Add tracepoints for errors on flush or fsync
  cifs: log warning message (once) if out of disk space
  cifs: fail i/o on soft mounts if sessionsetup errors out
  smb3: fix problem with null cifs super block with previous patch
  SMB3: Backup intent flag missing from some more ops

4 years agoMerge branch 'work.vboxsf' of git://git.kernel.org/pub/scm/linux/kernel/git/viro/vfs
Linus Torvalds [Sun, 9 Feb 2020 20:41:00 +0000 (12:41 -0800)]
Merge branch 'work.vboxsf' of git://git./linux/kernel/git/viro/vfs

Pull vboxfs from Al Viro:
 "This is the VirtualBox guest shared folder support by Hans de Goede,
  with fixups for fs_parse folded in to avoid bisection hazards from
  those API changes..."

* 'work.vboxsf' of git://git.kernel.org/pub/scm/linux/kernel/git/viro/vfs:
  fs: Add VirtualBox guest shared folder (vboxsf) support

4 years agoMerge tag 'x86-urgent-2020-02-09' of git://git.kernel.org/pub/scm/linux/kernel/git...
Linus Torvalds [Sun, 9 Feb 2020 20:11:12 +0000 (12:11 -0800)]
Merge tag 'x86-urgent-2020-02-09' of git://git./linux/kernel/git/tip/tip

Pull x86 fixes from Thomas Gleixner:
 "A set of fixes for X86:

   - Ensure that the PIT is set up when the local APIC is disable or
     configured in legacy mode. This is caused by an ordering issue
     introduced in the recent changes which skip PIT initialization when
     the TSC and APIC frequencies are already known.

   - Handle malformed SRAT tables during early ACPI parsing which caused
     an infinite loop anda boot hang.

   - Fix a long standing race in the affinity setting code which affects
     PCI devices with non-maskable MSI interrupts. The problem is caused
     by the non-atomic writes of the MSI address (destination APIC id)
     and data (vector) fields which the device uses to construct the MSI
     message. The non-atomic writes are mandated by PCI.

     If both fields change and the device raises an interrupt after
     writing address and before writing data, then the MSI block
     constructs a inconsistent message which causes interrupts to be
     lost and subsequent malfunction of the device.

     The fix is to redirect the interrupt to the new vector on the
     current CPU first and then switch it over to the new target CPU.
     This allows to observe an eventually raised interrupt in the
     transitional stage (old CPU, new vector) to be observed in the APIC
     IRR and retriggered on the new target CPU and the new vector.

     The potential spurious interrupts caused by this are harmless and
     can in the worst case expose a buggy driver (all handlers have to
     be able to deal with spurious interrupts as they can and do happen
     for various reasons).

   - Add the missing suspend/resume mechanism for the HYPERV hypercall
     page which prevents resume hibernation on HYPERV guests. This
     change got lost before the merge window.

   - Mask the IOAPIC before disabling the local APIC to prevent
     potentially stale IOAPIC remote IRR bits which cause stale
     interrupt lines after resume"

* tag 'x86-urgent-2020-02-09' of git://git.kernel.org/pub/scm/linux/kernel/git/tip/tip:
  x86/apic: Mask IOAPIC entries when disabling the local APIC
  x86/hyperv: Suspend/resume the hypercall page for hibernation
  x86/apic/msi: Plug non-maskable MSI affinity race
  x86/boot: Handle malformed SRAT tables during early ACPI parsing
  x86/timer: Don't skip PIT setup when APIC is disabled or in legacy mode

4 years agoMerge tag 'smp-urgent-2020-02-09' of git://git.kernel.org/pub/scm/linux/kernel/git...
Linus Torvalds [Sun, 9 Feb 2020 20:09:43 +0000 (12:09 -0800)]
Merge tag 'smp-urgent-2020-02-09' of git://git./linux/kernel/git/tip/tip

Pull SMP fixes from Thomas Gleixner:
 "Two fixes for the SMP related functionality:

   - Make the UP version of smp_call_function_single() match SMP
     semantics when called for a not available CPU. Instead of emitting
     a warning and assuming that the function call target is CPU0,
     return a proper error code like the SMP version does.

   - Remove a superfluous check in smp_call_function_many_cond()"

* tag 'smp-urgent-2020-02-09' of git://git.kernel.org/pub/scm/linux/kernel/git/tip/tip:
  smp/up: Make smp_call_function_single() match SMP semantics
  smp: Remove superfluous cond_func check in smp_call_function_many_cond()

4 years agoMerge tag 'perf-urgent-2020-02-09' of git://git.kernel.org/pub/scm/linux/kernel/git...
Linus Torvalds [Sun, 9 Feb 2020 20:04:09 +0000 (12:04 -0800)]
Merge tag 'perf-urgent-2020-02-09' of git://git./linux/kernel/git/tip/tip

Pull perf fixes from Thomas Gleixner:
 "A set of fixes and improvements for the perf subsystem:

  Kernel fixes:

   - Install cgroup events to the correct CPU context to prevent a
     potential list double add

   - Prevent an integer underflow in the perf mlock accounting

   - Add a missing prototype for arch_perf_update_userpage()

  Tooling:

   - Add a missing unlock in the error path of maps__insert() in perf
     maps.

   - Fix the build with the latest libbfd

   - Fix the perf parser so it does not delete parse event terms, which
     caused a regression for using perf with the ARM CoreSight as the
     sink configuration was missing due to the deletion.

   - Fix the double free in the perf CPU map merging test case

   - Add the missing ustring support for the perf probe command"

* tag 'perf-urgent-2020-02-09' of git://git.kernel.org/pub/scm/linux/kernel/git/tip/tip:
  perf maps: Add missing unlock to maps__insert() error case
  perf probe: Add ustring support for perf probe command
  perf: Make perf able to build with latest libbfd
  perf test: Fix test case Merge cpu map
  perf parse: Copy string to perf_evsel_config_term
  perf parse: Refactor 'struct perf_evsel_config_term'
  kernel/events: Add a missing prototype for arch_perf_update_userpage()
  perf/cgroups: Install cgroup events to correct cpuctx
  perf/core: Fix mlock accounting in perf_mmap()

4 years agoMerge tag 'timers-urgent-2020-02-09' of git://git.kernel.org/pub/scm/linux/kernel...
Linus Torvalds [Sun, 9 Feb 2020 20:00:12 +0000 (12:00 -0800)]
Merge tag 'timers-urgent-2020-02-09' of git://git./linux/kernel/git/tip/tip

Pull timer fixes from Thomas Gleixner:
 "Two small fixes for the time(r) subsystem:

   - Handle a subtle race between the clocksource watchdog and a
     concurrent clocksource watchdog stop/start sequence correctly to
     prevent a timer double add bug.

   - Fix the file path for the core time namespace file"

* tag 'timers-urgent-2020-02-09' of git://git.kernel.org/pub/scm/linux/kernel/git/tip/tip:
  clocksource: Prevent double add_timer_on() for watchdog_timer
  MAINTAINERS: Correct path to time namespace source file

4 years agoMerge tag 'irq-urgent-2020-02-09' of git://git.kernel.org/pub/scm/linux/kernel/git...
Linus Torvalds [Sun, 9 Feb 2020 19:56:41 +0000 (11:56 -0800)]
Merge tag 'irq-urgent-2020-02-09' of git://git./linux/kernel/git/tip/tip

Pull interrupt fixes from Thomas Gleixner:
 "A set of fixes for the interrupt subsystem:

   - Provision only ACPI enabled redistributors on GICv3

   - Use the proper command colums when building the INVALL command for
     the GICv3-ITS

   - Ensure the allocation of the L2 vPE table for GICv4.1

   - Correct the GICv4.1 VPROBASER programming so it uses the proper
     size

   - A set of small GICv4.1 tidy up patches

   - Configuration cleanup for C-SKY interrupt chip

   - Clarify the function documentation for irq_set_wake() to document
     that the wakeup functionality is orthogonal to the irq
     disable/enable mechanism"

* tag 'irq-urgent-2020-02-09' of git://git.kernel.org/pub/scm/linux/kernel/git/tip/tip:
  irqchip/gic-v3-its: Rename VPENDBASER/VPROPBASER accessors
  irqchip/gic-v3-its: Remove superfluous WARN_ON
  irqchip/gic-v4.1: Drop 'tmp' in inherit_vpe_l1_table_from_rd()
  irqchip/gic-v4.1: Ensure L2 vPE table is allocated at RD level
  irqchip/gic-v4.1: Set vpe_l1_base for all redistributors
  irqchip/gic-v4.1: Fix programming of GICR_VPROPBASER_4_1_SIZE
  genirq: Clarify that irq wake state is orthogonal to enable/disable
  irqchip/gic-v3-its: Reference to its_invall_cmd descriptor when building INVALL
  irqchip: Some Kconfig cleanup for C-SKY
  irqchip/gic-v3: Only provision redistributors that are enabled in ACPI

4 years agoMerge tag 'efi-urgent-2020-02-09' of git://git.kernel.org/pub/scm/linux/kernel/git...
Linus Torvalds [Sun, 9 Feb 2020 19:54:50 +0000 (11:54 -0800)]
Merge tag 'efi-urgent-2020-02-09' of git://git./linux/kernel/git/tip/tip

Pull EFI fix from Thomas Gleixner:
 "A single fix for a EFI boot regression on X86 which was caused by the
  recent rework of the EFI memory map parsing. On systems with invalid
  memmap entries the cleanup function uses an value which cannot be
  relied on in this stage. Use the actual EFI memmap entry instead"

* tag 'efi-urgent-2020-02-09' of git://git.kernel.org/pub/scm/linux/kernel/git/tip/tip:
  efi/x86: Fix boot regression on systems with invalid memmap entries

4 years agoMerge tag 'scsi-misc' of git://git.kernel.org/pub/scm/linux/kernel/git/jejb/scsi
Linus Torvalds [Sun, 9 Feb 2020 01:24:41 +0000 (17:24 -0800)]
Merge tag 'scsi-misc' of git://git./linux/kernel/git/jejb/scsi

Pull misc SCSI fixes from James Bottomley:
 "Five small patches, all in drivers or doc, which missed the initial
  pull request.

  The qla2xxx and megaraid_sas are actual fixes and the rest are
  spelling and doc changes"

* tag 'scsi-misc' of git://git.kernel.org/pub/scm/linux/kernel/git/jejb/scsi:
  scsi: ufs: fix spelling mistake "initilized" -> "initialized"
  scsi: pm80xx: fix spelling mistake "to" -> "too"
  scsi: MAINTAINERS: ufs: remove pedrom.sousa@synopsys.com
  scsi: megaraid_sas: fixup MSIx interrupt setup during resume
  scsi: qla2xxx: Fix unbound NVME response length