[chrony-dev] [PATCH v4] faq: Diagnose problem with RTC interrupts on Linux

[ Thread Index | Date Index | More chrony.tuxfamily.org/chrony-dev Archives ]


Sorry for the confusion.

I misread the code in rtc.c.

Michael Witten wrote:
> Mirosav Lichvar wrote:
> [...]
>>> +failure:
>>> +  LOG(LOGS_WARN, "The RTC driver could not be initialised");
>>> +  return 0;
>>
>> Please move this message to the caller in rtc.c and remove the "The".
>
>I found there is no need; you yourself already created a log message
>there:
>
>  if (driver.init) {
>    if ((driver.init)()) {
>      driver_initialised = 1;
>    }
>  } else {
>    LOG(LOGS_ERR, "RTC not supported on this operating system");
>  }

Clearly, I was mistaken; this updated version of the patch
introduces the requested log message.

     if (driver.init) {
       if ((driver.init)()) {
         driver_initialised = 1;
+      } else {
+        LOG(LOGS_ERR, "The RTC driver could not be initialised");
       }
     } else {
       LOG(LOGS_ERR, "RTC not supported on this operating system");

To apply this patch, save this email to /path/to/email, and then run:

  git am --scissors /path/to/email

Sincerely,
Michael Witten

--8<----8<----8<----8<----8<----8<----8<----8<----8<----8<----8<----8<----8<--

This commit makes 2 changes:

  * It updates the FAQ with a new entry.
  * It creates a new log message for when RTC initiasation fails.

chronyd's Linux RTC driver (rtc_linux.c) requires the following ioctl
requests to be functional:

  RTC_UIE_ON
  RTC_UIE_OFF

However, a Linux system's RTC driver does not necessarily implement them,
as noted in these previous commits:

  d66b2f2b2423bfbd3de4d69895024dac7eefb306
  rtc: handle RTCs that don't support interrupts
  Tue Dec 10 17:45:28 2019 +0100

  bff3f51d13c3f41e2ead2cfff5bfe0b8c22ef44a
  rtc: extend check for RTCs that don't support interrupts
  Thu Dec 12 12:50:19 2019 +0100

Fortunately, the Linux kernel can be built with software emulation of
these hardware requests, by enabling the following config variable:

  CONFIG_RTC_INTF_DEV_UIE_EMUL
    Provides an emulation for RTC_UIE if the underlying rtc chip
    driver does not expose RTC_UIE ioctls. Those requests generate
    once-per-second update interrupts, used for synchronization.

    The emulation code will read the time from the hardware
    clock several times per second, please enable this option
    only if you know that you really need it.

This commit records these facts for the benefit of the user.
---
 doc/faq.adoc | 13 +++++++++++++
 rtc.c        |  2 ++
 2 files changed, 15 insertions(+)

diff --git a/doc/faq.adoc b/doc/faq.adoc
index 9d2c109..bf9d277 100644
--- a/doc/faq.adoc
+++ b/doc/faq.adoc
@@ -597,6 +597,19 @@ things
 
 Some other program running on the system might be using the device.
 
+=== When I start `chronyd`, the log says `Could not enable RTC interrupt : Invalid argument` (or it may say `disable`)
+
+Your real-time clock hardware might not support the required ioctl requests:
+
+* `RTC_UIE_ON`
+* `RTC_UIE_OFF`
+
+A possible solution could be to build the Linux kernel with support for software
+emulation instead; try enabling the following configuration option when building
+the Linux kernel:
+
+* `CONFIG_RTC_INTF_DEV_UIE_EMUL`
+
 === What if my computer does not have an RTC or backup battery?
 
 In this case you can still use the `-s` option to set the system clock to the
diff --git a/rtc.c b/rtc.c
index fa83173..a80f05b 100644
--- a/rtc.c
+++ b/rtc.c
@@ -148,6 +148,8 @@ RTC_Initialise(int initial_set)
     if (driver.init) {
       if ((driver.init)()) {
         driver_initialised = 1;
+      } else {
+        LOG(LOGS_ERR, "RTC driver could not be initialised");
       }
     } else {
       LOG(LOGS_ERR, "RTC not supported on this operating system");
-- 
2.22.0


-- 
To unsubscribe email chrony-dev-request@xxxxxxxxxxxxxxxxxxxx with "unsubscribe" in the subject.
For help email chrony-dev-request@xxxxxxxxxxxxxxxxxxxx with "help" in the subject.
Trouble?  Email listmaster@xxxxxxxxxxxxxxxxxxxx.


Mail converted by MHonArc 2.6.19+ http://listengine.tuxfamily.org/