Skip to contentSkip to conversation

x86, rtc, ntp, Enable full rtc synchronization

PATCH In review Prarit Bhargava 3 participants 14 messages Feb 14, 2013 – Feb 28, 2013

Subsystems (3)
lore
Share & tools
lore
#0 lore raw

cover x86, rtc, ntp, Enable full rtc synchronization

This patchset enables a full rtc synchronization via ntp on x86. The current codebase (plus http://marc.info/?l=linux-kernel&m=136036689219340&w=2, which is queued for tip), will attempt to synchronize the rtc to the system time every 11 minutes if ntp is running.

The problem in the current code is that the synchronization will only occur if the system time is within +/-15 minutes of the current rtc time. ie) we only do a "partial" synchronization of the rtc. Other architectures do full synchronizations and the partial sync appears to be a software limitation.

This patchset introduces a full synchronization of the rtc, and allows the writing of the rtc date and time via sysfs (read for date and time is already implemented).

I tested this patch by using the write capability introduced in 2/2 to write in older and newer dates into the rtc, and then rebooting with ntpdate, and/or ntpdate enabled and verifying the correct setting of the hwclock (and system time) via calls to date and hwclock (all on 64-bit x86)

I have not tested the mrst/vrtc.c code, however, code inspection indicates that the only change required is the year offset of 1972. I booted 32-bit Fedora 18 on an UEFI system and confirmed that the system time and hwclock were now correct at boot.

Cc Thomas Gleixner <[email protected]>
Cc John Stultz <[email protected]>
Cc Matt Fleming <[email protected]>
Cc David Vrabel <[email protected]>
Cc Andrew Morton <akpm-de/[email protected]>
Cc Andi Kleen <ak-VuQAYsv1563Yd54FQh9/[email protected]>

Prarit Bhargava (2):
x86, rtc, ntp, Do full rtc synchronization with ntp rtc, add write functionality to sysfs

 arch/x86/kernel/rtc.c         | 69 ++++++----------------------------
 arch/x86/platform/efi/efi.c   | 24 ++++++++----
 arch/x86/platform/mrst/vrtc.c | 41 ++++++++++++---------
 drivers/rtc/rtc-sysfs.c       | 86 ++++++++++++++++++++++++++++++++++++++++++-
 4 files changed, 136 insertions(+), 84 deletions(-)
Signature · 1 line
1.8.1.2
#1 lore raw

PATCH 1/2 x86, rtc, ntp, Do full rtc synchronization with ntp

Every 11 minutes ntp attempts to update the x86 rtc with the current system time. Currently, the x86 code only updates the rtc if the system time is within +/-15 minutes of the current value of the rtc. Other architectures do a full synchronization and there is no reason that x86 should be software limited to a 30 minute window.

This patch changes the behavior of the kernel to do a full synchronization (year, month, day, hour, minute, and second) of the rtc when ntp requests a synchronization between the system time and the rtc.

I've used the RTC library functions in this patchset as they do all the required bounds checking.

Cc Thomas Gleixner <[email protected]>
Cc John Stultz <[email protected]>
Cc Matt Fleming <[email protected]>
Cc David Vrabel <[email protected]>
Cc Andrew Morton <[email protected]>
Cc Andi Kleen <[email protected]>
---
 arch/x86/kernel/rtc.c         | 69 ++++++++-----------------------------------
 arch/x86/platform/efi/efi.c   | 24 ++++++++++-----
 arch/x86/platform/mrst/vrtc.c | 41 ++++++++++++++-----------
 3 files changed, 52 insertions(+), 82 deletions(-)
arch/x86/kernel/rtc.c +12 -57
index 801602b..44e6c3a 100644
@@ -13,6 +13,7 @@
 #include <asm/x86_init.h>
 #include <asm/time.h>
 #include <asm/mrst.h>
+#include <asm/rtc.h>
 
 #ifdef CONFIG_X86_32
 /*
@@ -36,70 +37,24 @@ EXPORT_SYMBOL(rtc_lock);
  * nowtime is written into the registers of the CMOS clock, it will
  * jump to the next second precisely 500 ms later. Check the Motorola
  * MC146818A or Dallas DS12887 data sheet for details.
- *
- * BUG: This routine does not handle hour overflow properly; it just
- *      sets the minutes. Usually you'll only notice that after reboot!
  */
 int mach_set_rtc_mmss(unsigned long nowtime)
 {
-	int real_seconds, real_minutes, cmos_minutes;
-	unsigned char save_control, save_freq_select;
-	unsigned long flags;
+	struct rtc_time tm;
 	int retval = 0;
 
-	spin_lock_irqsave(&rtc_lock, flags);
-
-	 /* tell the clock it's being set */
-	save_control = CMOS_READ(RTC_CONTROL);
-	CMOS_WRITE((save_control|RTC_SET), RTC_CONTROL);
-
-	/* stop and reset prescaler */
-	save_freq_select = CMOS_READ(RTC_FREQ_SELECT);
-	CMOS_WRITE((save_freq_select|RTC_DIV_RESET2), RTC_FREQ_SELECT);
-
-	cmos_minutes = CMOS_READ(RTC_MINUTES);
-	if (!(save_control & RTC_DM_BINARY) || RTC_ALWAYS_BCD)
-		cmos_minutes = bcd2bin(cmos_minutes);
-
-	/*
-	 * since we're only adjusting minutes and seconds,
-	 * don't interfere with hour overflow. This avoids
-	 * messing with unknown time zones but requires your
-	 * RTC not to be off by more than 15 minutes
-	 */
-	real_seconds = nowtime % 60;
-	real_minutes = nowtime / 60;
-	/* correct for half hour time zone */
-	if (((abs(real_minutes - cmos_minutes) + 15)/30) & 1)
-		real_minutes += 30;
-	real_minutes %= 60;
-
-	if (abs(real_minutes - cmos_minutes) < 30) {
-		if (!(save_control & RTC_DM_BINARY) || RTC_ALWAYS_BCD) {
-			real_seconds = bin2bcd(real_seconds);
-			real_minutes = bin2bcd(real_minutes);
-		}
-		CMOS_WRITE(real_seconds, RTC_SECONDS);
-		CMOS_WRITE(real_minutes, RTC_MINUTES);
+	rtc_time_to_tm(nowtime, &tm);
+	if (!rtc_valid_tm(&tm)) {
+		retval = set_rtc_time(&tm);
+		if (retval)
+			printk(KERN_ERR "%s: RTC write failed with error %d\n",
+			       __FUNCTION__, retval);
 	} else {
-		printk_once(KERN_NOTICE
-		       "set_rtc_mmss: can't update from %d to %d\n",
-		       cmos_minutes, real_minutes);
-		retval = -1;
+		printk(KERN_ERR
+		       "%s: Invalid RTC value: write of %lx to RTC failed\n",
+			__FUNCTION__, nowtime);
+		retval = -EINVAL;
 	}
-
-	/* The following flags have to be released exactly in this order,
-	 * otherwise the DS12887 (popular MC146818A clone with integrated
-	 * battery and quartz) will not reset the oscillator and will not
-	 * update precisely 500 ms later. You won't find this mentioned in
-	 * the Dallas Semiconductor data sheets, but who believes data
-	 * sheets anyway ...                           -- Markus Kuhn
-	 */
-	CMOS_WRITE(save_control, RTC_CONTROL);
-	CMOS_WRITE(save_freq_select, RTC_FREQ_SELECT);
-
-	spin_unlock_irqrestore(&rtc_lock, flags);
-
 	return retval;
 }
 
arch/x86/platform/efi/efi.c +16 -8
index 77cf009..6ca930e 100644
@@ -48,6 +48,7 @@
 #include <asm/cacheflush.h>
 #include <asm/tlbflush.h>
 #include <asm/x86_init.h>
+#include <asm/rtc.h>
 
 #define EFI_DEBUG	1
 
@@ -262,10 +263,10 @@ static efi_status_t __init phys_efi_get_time(efi_time_t *tm,
 
 int efi_set_rtc_mmss(unsigned long nowtime)
 {
-	int real_seconds, real_minutes;
 	efi_status_t 	status;
 	efi_time_t 	eft;
 	efi_time_cap_t 	cap;
+	struct rtc_time	tm;
 
 	status = efi.get_time(&eft, &cap);
 	if (status != EFI_SUCCESS) {
@@ -273,13 +274,20 @@ int efi_set_rtc_mmss(unsigned long nowtime)
 		return -1;
 	}
 
-	real_seconds = nowtime % 60;
-	real_minutes = nowtime / 60;
-	if (((abs(real_minutes - eft.minute) + 15)/30) & 1)
-		real_minutes += 30;
-	real_minutes %= 60;
-	eft.minute = real_minutes;
-	eft.second = real_seconds;
+	rtc_time_to_tm(nowtime, &tm);
+	if (!rtc_valid_tm(&tm)) {
+		eft.year = tm.tm_year + 1900;
+		eft.month = tm.tm_mon + 1;
+		eft.day = tm.tm_mday;
+		eft.minute = tm.tm_min;
+		eft.second = tm.tm_sec;
+		eft.nanosecond = 0;
+	} else {
+		printk(KERN_ERR
+		       "%s: Invalid EFI RTC value: write of %lx to EFI RTC failed\n",
+		       __FUNCTION__, nowtime);
+		return -1;
+	}
 
 	status = efi.set_time(&eft);
 	if (status != EFI_SUCCESS) {
arch/x86/platform/mrst/vrtc.c +24 -17

50 lines not on this page · raw message

Signature · 1 line
1.8.1.2
#2 lore raw

Re: [RFE PATCH 1/2] x86, rtc, ntp, Do full rtc synchronization with ntp

Quoted 13 lines · Prarit Bhargava

Every 11 minutes ntp attempts to update the x86 rtc with the current system time. Currently, the x86 code only updates the rtc if the system time is within +/-15 minutes of the current value of the rtc. Other architectures do a full synchronization and there is no reason that x86 should be software limited to a 30 minute window.

This patch changes the behavior of the kernel to do a full synchronization (year, month, day, hour, minute, and second) of the rtc when ntp requests a synchronization between the system time and the rtc.

I've used the RTC library functions in this patchset as they do all the required bounds checking.

Quoted 9 lines
Cc Thomas Gleixner <[email protected]>
Cc John Stultz <[email protected]>
Cc Matt Fleming <[email protected]>
Cc David Vrabel <[email protected]>
Cc Andrew Morton <akpm-de/[email protected]>
Cc Andi Kleen <ak-VuQAYsv1563Yd54FQh9/[email protected]>

This looks reasonable to me.

Though I want to make sure we get this thoroughly tested by the various distros so we don't surprise anyone, since it has to potential to cause problems where folks are dualbooting windows (using a localtime RTC) and do not have their OS setup to trigger warp_clock to adjust for the localtime rtc (instead getting a time correction later via NTP).

I'll queue it and see about getting it merged to -tip & -next. Then we'll have to decide if 3.10 or 3.11 is the right time frame to land it.

thanks
-john

#3 lore raw

Re: [RFE PATCH 1/2] x86, rtc, ntp, Do full rtc synchronization with ntp

Quoted 4 lines · John Stultz

This looks reasonable to me.

Quoted 9 lines

Though I want to make sure we get this thoroughly tested by the various distros so we don't surprise anyone, since it has to potential to cause problems where folks are dualbooting windows (using a localtime RTC) and do not have their OS setup to trigger warp_clock to adjust for the localtime rtc (instead getting a time correction later via NTP).

I'll queue it and see about getting it merged to -tip & -next. Then we'll have to decide if 3.10 or 3.11 is the right time frame to land it.

cc'ing Alessandro as well.

John, I've been testing this across various systems (including those known to have some wonkiness with the RTC in BIOS ... see comment below) to see if this code impacts anything.

I've tested mainly using Fedora 18 (with the latest kernel -tip obviously), but I also installed Ubuntu on a system to see if there was any noticeable impact there too. I have not seen any unusual testing failures on AMD or Intel systems.

On the one system which I know to have "weak" battery such that the RTC doesn't "stick" on the system shutdown the clock resets itself in BIOS reboot to "Jan 1 1970". When I tested previously I could not get the RTC written to the current date; after my changes, the RTC does at least reflect the current date through a reboot. It should be noted that if I do replace the battery on this system I can get the RTC to properly "stick" through a reboot.

Given the test results I think this should go in earlier rather than later; I'd like to target 3.10 for the full sync, and possibly 3.11 for the HCTOSYS stuff.

... unless anyone has a strenuous objection ;)

P.

#4 lore raw

Re: [RFE PATCH 1/2] x86, rtc, ntp, Do full rtc synchronization with ntp

Quoted 4 lines · On Sun, 24 Feb 2013 12:12:57 -0500 Prarit Bhargava…

Given the test results I think this should go in earlier rather than later; I'd like to target 3.10 for the full sync, and possibly 3.11 for the HCTOSYS stuff.

... unless anyone has a strenuous objection ;)

looks reasonable.

I prefer == 0 instead of !rtc_valid_tm(&tm),
but it's just a cosmetic issue.

Signature · 6 lines
 Best regards,

 Alessandro Zummo,
  Tower Technologies - Torino, Italy

  http://www.towertech.it
#5 lore raw

PATCH 2/2 rtc, add write functionality to sysfs

In reply to Prarit Bhargava

/sys/class/rtc/rtcX/date and /sys/class/rtc/rtcX/time currently have read-only access. This patch introduces write functionality which will set the rtc time.

Usage: echo YYYY-MM-DD > /sys/class/rtc/rtcX/date
echo HH:MM:SS > /sys/class/rtc/rtcX/time

Cc Thomas Gleixner <[email protected]>
Cc John Stultz <[email protected]>
Cc Matt Fleming <[email protected]>
Cc David Vrabel <[email protected]>
Cc Andrew Morton <akpm-de/[email protected]>
Cc Andi Kleen <ak-VuQAYsv1563Yd54FQh9/[email protected]>
---
 drivers/rtc/rtc-sysfs.c | 86 +++++++++++++++++++++++++++++++++++++++++++++++--
 1 file changed, 84 insertions(+), 2 deletions(-)
drivers/rtc/rtc-sysfs.c +84 -2
index b70e2bb..87d63d7 100644
@@ -48,6 +48,46 @@ rtc_sysfs_show_date(struct device *dev, struct device_attribute *attr,
 }
 
 static ssize_t
+rtc_sysfs_store_date(struct device *dev, struct device_attribute *attr,
+		     const char *buf, size_t count)
+{
+	ssize_t retval;
+	struct rtc_time tm;
+	char tmp[11] = "\0", *tmpptr = tmp;
+	char *cyear, *cmonth, *cday;
+	int year, month, day;
+
+	if (!capable(CAP_SYS_TIME))
+		return -EPERM;
+
+	/* from rtc_sysfs_show_date(): date string format is YYYY-MM-DD */
+	if (strlen(buf) != 11)
+		return -EINVAL;
+
+	strncpy(tmp, buf, 11);
+	cyear = strsep(&tmpptr, "-");
+	sscanf(cyear, "%i", &year);
+	cmonth = strsep(&tmpptr, "-");
+	sscanf(cmonth, "%i", &month);
+	cday = strsep(&tmpptr, "-");
+	sscanf(cday, "%i", &day);
+
+	retval = rtc_read_time(to_rtc_device(dev), &tm);
+	if (retval)
+		return -ENODEV;
+
+	tm.tm_year = year - 1900;
+	tm.tm_mon = month - 1;
+	tm.tm_mday = day;
+
+	retval = rtc_set_time(to_rtc_device(dev), &tm);
+	if (retval)
+		return retval;
+
+	return count;
+}
+
+static ssize_t
 rtc_sysfs_show_time(struct device *dev, struct device_attribute *attr,
 		char *buf)
 {
@@ -64,6 +104,46 @@ rtc_sysfs_show_time(struct device *dev, struct device_attribute *attr,
 }
 
 static ssize_t
+rtc_sysfs_store_time(struct device *dev, struct device_attribute *attr,
+		     const char *buf, size_t count)
+{
+	ssize_t retval;
+	struct rtc_time tm;
+	char tmp[9] = "\0", *tmpptr = tmp;
+	char *chour, *cmin, *csec;
+	int hour, min, sec;
+
+	if (!capable(CAP_SYS_TIME))
+		return -EPERM;
+
+	/* from rtc_sysfs_show_time(): time string format is HH:MM:SS */
+	if (strlen(buf) != 9)
+		return -EINVAL;
+
+	strncpy(tmp, buf, 9);
+	chour = strsep(&tmpptr, ":");
+	sscanf(chour, "%i", &hour);
+	cmin = strsep(&tmpptr, ":");
+	sscanf(cmin, "%i", &min);
+	csec = strsep(&tmpptr, ":");
+	sscanf(csec, "%i", &sec);
+
+	retval = rtc_read_time(to_rtc_device(dev), &tm);
+	if (retval)
+		return -ENODEV;
+
+	tm.tm_hour = hour;
+	tm.tm_min = min;
+	tm.tm_sec = sec;
+
+	retval = rtc_set_time(to_rtc_device(dev), &tm);
+	if (retval)
+		return retval;
+
+	return count;
+}
+
+static ssize_t
 rtc_sysfs_show_since_epoch(struct device *dev, struct device_attribute *attr,
 		char *buf)
 {
@@ -124,8 +204,10 @@ rtc_sysfs_show_hctosys(struct device *dev, struct device_attribute *attr,
 
 static struct device_attribute rtc_attrs[] = {
 	__ATTR(name, S_IRUGO, rtc_sysfs_show_name, NULL),
-	__ATTR(date, S_IRUGO, rtc_sysfs_show_date, NULL),
-	__ATTR(time, S_IRUGO, rtc_sysfs_show_time, NULL),
+	__ATTR(date, S_IRUGO | S_IWUGO, rtc_sysfs_show_date,
+	       rtc_sysfs_store_date),
+	__ATTR(time, S_IRUGO | S_IWUGO, rtc_sysfs_show_time,
+	       rtc_sysfs_store_time),
 	__ATTR(since_epoch, S_IRUGO, rtc_sysfs_show_since_epoch, NULL),
 	__ATTR(max_user_freq, S_IRUGO | S_IWUSR, rtc_sysfs_show_max_user_freq,
 			rtc_sysfs_set_max_user_freq),
Signature · 1 line
1.8.1.2
#6 lore raw

Re: [RFE PATCH 2/2] rtc, add write functionality to sysfs

Quoted 6 lines · Prarit Bhargava

/sys/class/rtc/rtcX/date and /sys/class/rtc/rtcX/time currently have read-only access. This patch introduces write functionality which will set the rtc time.

Usage: echo YYYY-MM-DD > /sys/class/rtc/rtcX/date
echo HH:MM:SS > /sys/class/rtc/rtcX/time

Why do we want to add a new interface here?

thanks
-john

#7 lore raw

Re: [RFE PATCH 2/2] rtc, add write functionality to sysfs

Quoted 9 lines · John Stultz
Quoted 6 lines · Prarit Bhargava

/sys/class/rtc/rtcX/date and /sys/class/rtc/rtcX/time currently have read-only access. This patch introduces write functionality which will set the rtc time.

Usage: echo YYYY-MM-DD > /sys/class/rtc/rtcX/date
echo HH:MM:SS > /sys/class/rtc/rtcX/time

Why do we want to add a new interface here?

John,

I'm not adding a new interface. The current date/time interface only handles read and I'm introducing write.

Sorry -- maybe my description was too short ...

P.

Quoted 4 lines

thanks
-john

#8 lore raw

Re: [RFE PATCH 2/2] rtc, add write functionality to sysfs

Quoted 7 lines · Prarit Bhargava
Quoted 5 lines · John Stultz
Quoted 4 lines · Prarit Bhargava

/sys/class/rtc/rtcX/date and /sys/class/rtc/rtcX/time currently have read-only access. This patch introduces write functionality which will set the rtc time.

Quoted 8 lines
Quoted 3 lines
Quoted 2 lines

Usage: echo YYYY-MM-DD > /sys/class/rtc/rtcX/date
echo HH:MM:SS > /sys/class/rtc/rtcX/time

Why do we want to add a new interface here?

John,

I'm not adding a new interface. The current date/time interface only handles read and I'm introducing write.

Right, but what benefit does that provide?
(I'm not saying there isn't any, its just not clear from your patch why this is a good thing.)

Also CC'ing Alessandro for his input.

thanks
-john

#9 lore raw

Re: [RFE PATCH 2/2] rtc, add write functionality to sysfs

Quoted 13 lines · John Stultz
Quoted 12 lines · Prarit Bhargava
Quoted 8 lines · John Stultz
Quoted 6 lines · Prarit Bhargava

/sys/class/rtc/rtcX/date and /sys/class/rtc/rtcX/time currently have read-only access. This patch introduces write functionality which will set the rtc time.

Usage: echo YYYY-MM-DD > /sys/class/rtc/rtcX/date
echo HH:MM:SS > /sys/class/rtc/rtcX/time

Why do we want to add a new interface here?

John,

Quoted 8 lines
Quoted 3 lines

I'm not adding a new interface. The current date/time interface only handles read and I'm introducing write.

Right, but what benefit does that provide?
(I'm not saying there isn't any, its just not clear from your patch why this is a good thing.)

Also CC'ing Alessandro for his input.

I'd like to keep the interfaces as simple as possible but I'm open to improvements if there are good use cases.

#10 lore raw

Re: [RFE PATCH 2/2] rtc, add write functionality to sysfs

Quoted 15 lines · Alessandro Zummo
Quoted 13 lines · John Stultz
Quoted 12 lines · Prarit Bhargava
Quoted 8 lines · John Stultz
Quoted 6 lines · Prarit Bhargava

/sys/class/rtc/rtcX/date and /sys/class/rtc/rtcX/time currently have read-only access. This patch introduces write functionality which will set the rtc time.

Usage: echo YYYY-MM-DD > /sys/class/rtc/rtcX/date
echo HH:MM:SS > /sys/class/rtc/rtcX/time

Why do we want to add a new interface here?

John,

Quoted 7 lines
Quoted 7 lines
Quoted 3 lines

I'm not adding a new interface. The current date/time interface only handles read and I'm introducing write.

Right, but what benefit does that provide?
(I'm not saying there isn't any, its just not clear from your patch why this is a good thing.)

Sorry John, I misunderstood your question.

Quoted 4 lines
Quoted 1 line

Also CC'ing Alessandro for his input.

I'd like to keep the interfaces as simple as possible but I'm open to improvements if there are good use cases.

AFAICT there is no way for me to "test" or use the write from userspace. hwclock uses the SET_TIME ioctl, which is a different code path AFAICT.

I'd like to be at least able to test this stuff when we make changes to it so I think having write functionality for date & time is worthwhile.

For me, I'm using these to heavily test ntp and ntpdate over system reboots.

OOC, Alessandro, why is the date & time split into two fields?

P.

#11 lore raw

Re: [RFE PATCH 2/2] rtc, add write functionality to sysfs

Quoted 8 lines · On Sun, 24 Feb 2013 12:03:01 -0500 Prarit Bhargava…

AFAICT there is no way for me to "test" or use the write from userspace. hwclock uses the SET_TIME ioctl, which is a different code path AFAICT.

I'd like to be at least able to test this stuff when we make changes to it so I think having write functionality for date & time is worthwhile.

For me, I'm using these to heavily test ntp and ntpdate over system reboots.

the point is: who will benefit from this patch? users? distributions? embedded distributions? if it's useful, then just go for it.

Quoted 1 line

OOC, Alessandro, why is the date & time split into two fields?

because date and time are two different things and we expect sysfs to preferably have one value for each entry.

Signature · 6 lines
 Best regards,

 Alessandro Zummo,
  Tower Technologies - Torino, Italy

  http://www.towertech.it
#12 lore raw

Re: [RFE PATCH 2/2] rtc, add write functionality to sysfs

Quoted 7 lines · Alessandro Zummo
Quoted 4 lines · On Sun, 24 Feb 2013 12:03:01 -0500 Prarit Bhargava…

AFAICT there is no way for me to "test" or use the write from userspace. hwclock uses the SET_TIME ioctl, which is a different code path AFAICT.

Quoted 7 lines
Quoted 4 lines

I'd like to be at least able to test this stuff when we make changes to it so I think having write functionality for date & time is worthwhile.

For me, I'm using these to heavily test ntp and ntpdate over system reboots.

the point is: who will benefit from this patch? users? distributions? embedded distributions? if it's useful, then just go for it.

This can be dropped IMO.

P.

Quoted 7 lines
Quoted 3 lines

OOC, Alessandro, why is the date & time split into two fields?

because date and time are two different things and we expect sysfs to preferably have one value for each entry.

#13 lore raw

Re: [RFE PATCH 2/2] rtc, add write functionality to sysfs

In reply to Prarit Bhargava
Quoted 22 lines · Prarit Bhargava
Quoted 12 lines · Alessandro Zummo
Quoted 10 lines · John Stultz
Quoted 9 lines · Prarit Bhargava
Quoted 8 lines · John Stultz
Quoted 6 lines · Prarit Bhargava

/sys/class/rtc/rtcX/date and /sys/class/rtc/rtcX/time currently have read-only access. This patch introduces write functionality which will set the rtc time.

Usage: echo YYYY-MM-DD > /sys/class/rtc/rtcX/date
echo HH:MM:SS > /sys/class/rtc/rtcX/time

Why do we want to add a new interface here?

Quoted 8 lines
Quoted 8 lines
Quoted 5 lines

John,

I'm not adding a new interface. The current date/time interface only handles read and I'm introducing write.

Right, but what benefit does that provide?
(I'm not saying there isn't any, its just not clear from your patch why this is a good thing.)

Quoted 7 lines

Sorry John, I misunderstood your question.

Quoted 3 lines
Quoted 1 line

Also CC'ing Alessandro for his input.

I'd like to keep the interfaces as simple as possible but I'm open to improvements if there are good use cases.

AFAICT there is no way for me to "test" or use the write from userspace. hwclock uses the SET_TIME ioctl, which is a different code path AFAICT.

Yea, per your other email, I'd rather we drop this change for now.

If possible, instead of adding redundant userland interfaces, I'd rather we consolidate the redundant internal code paths.

thanks
-john