CONFIG_RTC_DRV_PL031=m stops the kernel from setting the system time from the RTC automatically, which userspace expects

Bug #1252242 reported by Robie Basak on 2013-11-18
This bug affects 1 person
Affects Status Importance Assigned to Milestone
linux (Ubuntu)
Paolo Pisati

Bug Description

SRU Justification:

Impact: the Linux kernel resets the wall clock (RTC_HCTOSYS=y) using the value read from a specific rtc device (RTC_HCTOSYS_DEVICE=rtc0) as a late_initcall() (see drivers/rtc/hctosys.c::rtc_hctosys()). That implies that the RTC_HCTOSYS_DEVICE must be available when rtc_hctosys() is called, making all the rtc drivers that are built as a module unsuitanle for this task.


[ 5.396605] /home/ppisati/ubuntu-saucy/drivers/rtc/hctosys.c: unable to open rtc device (rtc0)
# rtc_hctosys() is called, it tries to open rtc0 but the driver is unavailable at this time so it fails to set the system time
[ 10.609622] rtc-pl031 fff35000.rtc: rtc core: registered pl031 as rtc0
# later on the rtc driver is loaded, but it's too late
ubuntu@m01:~$ date
Wed Dec 31 19:25:24 EST 1969

Fix: compile in the rtc driver that your board uses to set the wall clock (pl031 on calxeda) - see the attached patch

Test case:

[ 5.303860] rtc-pl031 fff35000.rtc: rtc core: registered pl031 as rtc0
[ 5.421639] rtc-pl031 fff35000.rtc: setting system clock to 2013-11-19 16:47:18 UTC (1384879638)

when the rtc driver is correctly build-in, you should see something like this in your bootlog.


Working on MAAS, I see midway machines boot on Saucy with an incorrect system time (close to epoch). I have tried various things, including using MAAS to make sure that the hardware clock was set correctly before installation. Despite this, I find that the hardware clock (as reported by "hwclock --utc") is correct, yet the system time ("date --utc") is close to epoch.

Affects: Saucy linux-image-3.11.0-13-generic-lpae 3.11.0-13.20, util-linux 2.20.1-5.1ubuntu9.

Below is my current understanding of the root cause and possible solutions. My understanding may not be accurate. Please correct any inaccuracies. This is just my current understanding; all I know is that it doesn't work :)

In userspace, util-linux via /etc/init/hwclock.conf is involved with the RTC. But it doesn't use --hctosys. I can find nothing in userspace that takes responsibility for setting up the system time from the RTC.

hwclock(8) says that --hctosys is "a good option to use in one of the system startup scripts.", but also that --systz is "is an alternate option to --hctosys that does not read the hardware clock, and may be used in system startup scripts for recent 2.6 kernels where you know the System Time contains the Hardware Clock time."

So it appears to me that it is the kernel that is supposed to make sure the RTC is copied to the system clock on boot, or at least that this is the assumption that userspace is making. It's my understanding that this isn't happening because rtc_pl031 is a module.

I assume that an RTC module load doesn't reset the system time. Or should it? It sounds like an evil side effect to me if it doesn't happen on boot. Perhaps there should be or there is a module parameter to make it do that, though? If so, I am unaware of it, or any userspace implementation of using that.

I can see two broad solutions to this:

1) The kernel takes responsibility for doing this task, which AIUI we can do with CONFIG_RTC_DRV_PL031=y. This was the case with the linux-highbank package in Quantal, which I believe is why this appears to be a regression from MAAS' perspective.

2) Userspace takes responsibility for running "hwclock --hctosys", which case we need logic to figure out when this is necessary (AIUI, it isn't necessary for Intel, as the RTC driver is compiled in?) and how to arrange this.

Other options:

3) Some kind of definition of the semantics (perhaps there is one and I'm missing it) and userspace asking the module to do it on module load, or an hwclock command after module load or something. I am concerned about coordinating the timing involved in this option, though.

4) fixrtc on the command line as a workaround for MAAS. This would need us to amend flash-kernel. But this doesn't really fix the problem; a --hctosys would still be needed to make the clock properly accurate.

ProblemType: Bug
DistroRelease: Ubuntu 13.10
Package: linux-image-3.11.0-13-generic-lpae 3.11.0-13.20
ProcVersionSignature: User Name 3.11.0-13.20-generic-lpae 3.11.6
Uname: Linux 3.11.0-13-generic-lpae armv7l
 total 0
 crw-rw---- 1 root audio 116, 1 Dec 31 1969 seq
 crw-rw---- 1 root audio 116, 33 Dec 31 1969 timer
AlsaVersion: Advanced Linux Sound Architecture Driver Version k3.11.0-13-generic-lpae.
AplayDevices: Error: [Errno 2] No such file or directory: 'aplay'
ApportVersion: 2.12.5-0ubuntu2.1
Architecture: armhf
ArecordDevices: Error: [Errno 2] No such file or directory: 'arecord'
AudioDevicesInUse: Error: command ['fuser', '-v', '/dev/snd/seq', '/dev/snd/timer'] failed with exit code 1:
CRDA: Error: [Errno 2] No such file or directory: 'iw'
Date: Mon Nov 18 06:33:34 2013
HibernationDevice: RESUME=UUID=1337d4f1-3df8-4589-9008-a47a197b579f
IwConfig: Error: [Errno 2] No such file or directory: 'iwconfig'
Lsusb: Error: command ['lsusb'] failed with exit code 1: unable to initialize libusb: -99
MarkForUpload: True


ProcKernelCmdLine: console=ttyAMA0 nosplash
 binfmt_misc 7197 1 - Live 0x00000000 (F)
 rtc_pl031 4594 0 - Live 0x00000000 (F)
 uio 8483 1 uio_pdrv_genirq, Live 0x00000000 (F)
 uio_pdrv_genirq 3441 0 - Live 0x00000000 (F)
 xgmac 18035 0 - Live 0x00000000 (F)
 linux-restricted-modules-3.11.0-13-generic-lpae N/A
 linux-backports-modules-3.11.0-13-generic-lpae N/A
 linux-firmware 1.116
RfKill: Error: [Errno 2] No such file or directory: 'rfkill'
SourcePackage: linux
UpgradeStatus: No upgrade log present (probably fresh install)
 Nov 18 06:26:32 m22 dhclient: DHCPREQUEST of on eth0 to port 67 (xid=0xb672694)
 Nov 18 06:26:32 m22 dhclient: DHCPACK of from
 Nov 18 06:26:32 m22 dhclient: bound to -- renewal in 3558 seconds.

Robie Basak (racb) wrote :
tags: added: bot-stop-nagging
description: updated

This bug is missing log files that will aid in diagnosing the problem. From a terminal window please run:

apport-collect 1252242

and then change the status of the bug to 'Confirmed'.

If, due to the nature of the issue you have encountered, you are unable to run this command, please add a comment stating that fact and change the bug status to 'Confirmed'.

This change has been made by an automated script, maintained by the Ubuntu Kernel Team.

Changed in linux (Ubuntu):
status: New → Incomplete
Robie Basak (racb) on 2013-11-18
Changed in linux (Ubuntu):
status: Incomplete → Confirmed
Changed in linux (Ubuntu):
importance: Undecided → Medium
Paolo Pisati (p-pisati) on 2013-11-20
description: updated
description: updated
description: updated
description: updated
description: updated
Brad Figg (brad-figg) wrote :

This bug is awaiting verification that the kernel in -proposed solves the problem. Please test the kernel and update this bug with the results. If the problem is solved, change the tag 'verification-needed-saucy' to 'verification-done-saucy'.

If verification is not done by 5 working days from today, this fix will be dropped from the source code, and this bug will be closed.

See for documentation how to enable and use -proposed. Thank you!

tags: added: verification-needed-saucy
Robie Basak (racb) wrote :

Dec 10 04:58:52 m14 kernel: [ 4.864611] rtc-pl031 fff35000.rtc: setting system clock to 2013-12-10 09:58:44 UTC (1386669524)

Thanks Paulo!

Robie Basak (racb) wrote :

Err...Paolo. Sorry.

tags: added: verification-done-saucy
removed: verification-needed-saucy
Launchpad Janitor (janitor) wrote :
Download full text (13.3 KiB)

This bug was fixed in the package linux - 3.11.0-15.23

linux (3.11.0-15.23) saucy; urgency=low

  [Brad Figg]

  * Release Tracking Bug
    - LP: #1259259

  [ Tim Gardner ]

  * [Config] Build-in ohci-pci
    - LP: #1244176

linux (3.11.0-15.22) saucy; urgency=low

  [Brad Figg]

  * Release Tracking Bug
    - LP: #1257092

  [ Andy Whitcroft ]

    - LP: #1252353

  [ Benjamin Tissoires ]

  * SAUCE: (no-up) HID: appleir: force input to be set
    - LP: #1244505

  [ John Johansen ]

  * SAUCE: (no-up) apparmor: Fix tasks not subject to, reloaded policy
    - LP: #1236455

  [ Kamal Mostafa ]

  * SAUCE: (no-up) drm/i915: i915.disable_pch_pwm overrides PCH_PWM_ENABLE
    - LP: #1163720

  [ Manoj Iyer ]

  * SAUCE: Enable earlyprintk via the PL011.
    - LP: #1248233

  [ Paolo Pisati ]

  * [Config] armhf: RTC_DRV_PL031=y
    - LP: #1252242
  * [Config] armhf: CPU_FREQ=y && ARM_HIGHBANK_CPUFREQ=y
    - LP: #1249397

  [ Rob Herring ]

  * [Config] armhf: PSTORE_RAM=y and PSTORE_CONSOLE=y
    - LP: #1248492
  * SAUCE: net: calxedaxgmac: add mac address learning
    - LP: #1248233

  [ Tim Gardner ]

  * [Debian] Re-sign modules after debug objcopy
    - LP: #1253155

  [ Upstream Kernel Changes ]

  * Revert "rt2x00pci: Use PCI MSIs whenever possible"
    - LP: #1257037
  * Revert "epoll: use freezable blocking call"
    - LP: #1257037
  * Revert "select: use freezable blocking call"
    - LP: #1257037
  * Revert "ima: policy for RAMFS"
    - LP: #1257037
  * ARM: tlb: don't perform inner-shareable invalidation for local TLB ops
    - LP: #1239800
  * ARM: 7855/1: Add check for Cortex-A15 errata 798181 ECO
    - LP: #1239800
  * mfd: rtsx: Modify rts5249_optimize_phy
    - LP: #1255297
  * usb: musb: start musb on the udc side, too
    - LP: #1257037
  * usb-storage: add quirk for mandatory READ_CAPACITY_16
    - LP: #1257037
  * USB: support new huawei devices in option.c
    - LP: #1257037
  * USB: quirks.c: add one device that cannot deal with suspension
    - LP: #1257037
  * USB: quirks: add touchscreen that is dazzeled by remote wakeup
    - LP: #1257037
  * USB: serial: ftdi_sio: add id for Z3X Box device
    - LP: #1257037
  * xhci: Don't enable/disable RWE on bus suspend/resume.
    - LP: #1257037
  * cifs: Fix inability to write files >2GB to SMB2/3 shares
    - LP: #1257037
  * x86: Update UV3 hub revision ID
    - LP: #1257037
  * cpufreq: s3c64xx: Rename index to driver_data
    - LP: #1257037
  * cpufreq / intel_pstate: Fix max_perf_pct on resume
    - LP: #1257037
  * bcache: Fixed incorrect order of arguments to bio_alloc_bioset()
    - LP: #1257037
  * HID: wiimote: add LEGO-wiimote VID
    - LP: #1257037
  * cgroup: fix to break the while loop in cgroup_attach_task() correctly
    - LP: #1257037
  * mac80211: correctly close cancelled scans
    - LP: #1257037
  * mac80211: drop spoofed packets in ad-hoc mode
    - LP: #1257037
  * mac80211: use sta_info_get_bss() for nl80211 tx and client probing
    - LP: #1257037
  * mac80211: update sta->last_rx on acked tx frames
    - LP: #1257037
  * mac80211: fix crash if bitrate calculation goes wrong
    - LP: #1257...

Changed in linux (Ubuntu Saucy):
status: New → Fix Released
tags: removed: bot-stop-nagging
tags: added: patch
To post a comment you must log in.
This report contains Public information  Edit
Everyone can see this information.

Other bug subscribers