[chrony-dev] [PATCH v2] rtc (linux): Help the user diagnose a problem with RTC UIE ioctl requests |
[ Thread Index |
Date Index
| More chrony.tuxfamily.org/chrony-dev Archives
]
- To: Miroslav Lichvar <mlichvar@xxxxxxxxxx>
- Subject: [chrony-dev] [PATCH v2] rtc (linux): Help the user diagnose a problem with RTC UIE ioctl requests
- From: Michael Witten <mfwitten@xxxxxxxxx>
- Date: Sat, 12 Dec 2020 19:56:00 -0000
- Cc: chrony-dev@xxxxxxxxxxxxxxxxxxxx
- Dkim-signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=subject:date:from:to:cc:message-id:in-reply-to:references; bh=Nq+SKXTGcMB2vJdEMfVkuNAHw/RciOp/mCNL/I7XN2A=; b=OiOk7xjIT8gSmNC0fJIY5U6CLrNvVo6LtpU2wvkB2DUSzMYEgRgcdlsW7/UpqaX2s2 Ssd2kKtqWU2om/l9A/lIccnwDuKnrWpIBCutR0oj/UL6Cw8+SCvwC87rerWGYspWyspA UxO4UXhNyXKCJYyW5d312I1jQGHf5DrrJBLEZIFXnMHit4Bwl9TwBcte3Fg7vephRcW7 xH7GEZkH5sNsvIHLyL8ttv3YA4Kgpwvt5us4i5ABHfxTPUiYylrR7jy3yN8tEpGiRBe0 LfWaL9MIc0EKVvtSB7cKAgDuw8yS6Cd1CcEr2kI/xjBRAV9FC7M2DitSHb8pPfB6UGu1 hzBA==
Miroslav Lichvar wrote:
> The switch_interrupts() function should log an error message when the
> driver doesn't support interrupts. Instead of adding more log messages
> to explain the error, I'd prefer a new question in the FAQ
> specifically for the error message.
The function switch_interrupts() does indeed currently log an error
message when an error is detected; however, an error could occur
when enabling or disabling interrupts, so this updated patch still
produces a consolidated error message:
"Interrupts not supported by RTC device /path/to/rtc"
A new FAQ entry has been added for that particular error message.
Also, if initialisation of chrony's RTC driver fails for any reason,
a definitive warning is also still logged:
"The RTC driver could not be initialised."
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 updates the FAQ to point the user towards a solution; it
also updates the RTC driver code (rtc_linux.c:RTC_Linux_Initialise())
to provide diagnostic messages that explicitly inform the user of
a problem:
* "Interrupts not supported by RTC device /path/to/rtc"
* "The RTC driver could not be initialised."
chrony'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_linux.c | 15 +++++++++++----
2 files changed, 24 insertions(+), 4 deletions(-)
diff --git a/doc/faq.adoc b/doc/faq.adoc
index 9d2c109..74598be 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 `chrony`, the log says `Interrupts not supported by RTC device`
+
+Your real-time clock hardware might not support the required ioctl requests:
+
+* `RTC_UIE_ON`
+* `RTC_UIE_OFF`
+
+A possible solution might 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_linux.c b/rtc_linux.c
index 08c2a19..29c5a9f 100644
--- a/rtc_linux.c
+++ b/rtc_linux.c
@@ -507,18 +507,21 @@ switch_interrupts(int on_off)
int
RTC_Linux_Initialise(void)
{
+ const char *const rtc_path = CNF_GetRtcDevice();
+
/* Try to open the device */
- fd = open(CNF_GetRtcDevice(), O_RDWR);
+ fd = open(rtc_path, O_RDWR);
if (fd < 0) {
LOG(LOGS_ERR, "Could not open RTC device %s : %s",
- CNF_GetRtcDevice(), strerror(errno));
- return 0;
+ rtc_path, strerror(errno));
+ goto failure;
}
/* Make sure the RTC supports interrupts */
if (!switch_interrupts(1) || !switch_interrupts(0)) {
close(fd);
- return 0;
+ LOG(LOGS_ERR, "Interrupts not supported by RTC device %s", rtc_path);
+ goto failure;
}
/* Close on exec */
@@ -553,6 +556,10 @@ RTC_Linux_Initialise(void)
" Date (UTC) Time RTC fast (s) Val Est fast (s) Slope (ppm) Ns Nr Meas")
: -1;
return 1;
+
+failure:
+ LOG(LOGS_WARN, "The RTC driver could not be initialised");
+ return 0;
}
/* ================================================== */
--
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.