public inbox for linux-kernel@vger.kernel.org
 help / color / mirror / Atom feed
* [PATCH] rtc: rtc-efi: Add an enable parameter and make it false for X86 by default
@ 2017-05-02  8:51 Ocean HY1 He
  2017-05-05 21:07 ` Matt Fleming
  0 siblings, 1 reply; 2+ messages in thread
From: Ocean HY1 He @ 2017-05-02  8:51 UTC (permalink / raw)
  To: matt.fleming@intel.com, a.zummo@towertech.it,
	alexandre.belloni@free-electrons.com, msalter@redhat.com
  Cc: rtc-linux@googlegroups.com, linux-kernel@vger.kernel.org,
	Ocean HY1 He

The commit 7efe665903d0 ("rtc: Disable EFI rtc for x86") turns off rtc-efi
option completely for x86 in rtc/Kconfig, to avoid possible crash caused by
buggy implementations of the time-related EFI runtime services.

In fact, there are more and more UEFI firmware has time-related EFI runtime
services well done. To meet EFI rtc request for X86, here adds an enable
parameter which could be explicitly set as true when load rtc-efi module.
To keep consistency, make this enable parameter false for X86 by default.

The test passes on Lenovo ThinkServer RD350 while the UEFI/BIOS version is
VB3TS424 and processor is Intel(R) Xeon(R) CPU E5-2660 v3.
#modprobe rtc_efi enable=1
#cat /sys/class/rtc/rtc1/name
rtc-efi
#hwclock --rtc=/dev/rtc1 -w
#hwclock --rtc=/dev/rtc1 -r

Signed-off-by: Ocean He <hehy1@lenovo.com>
---
 drivers/rtc/Kconfig   |  2 +-
 drivers/rtc/rtc-efi.c | 11 +++++++++++
 2 files changed, 12 insertions(+), 1 deletion(-)

diff --git a/drivers/rtc/Kconfig b/drivers/rtc/Kconfig
index ee1b0e9..482200a 100644
--- a/drivers/rtc/Kconfig
+++ b/drivers/rtc/Kconfig
@@ -1037,7 +1037,7 @@ config RTC_DRV_DA9063
 
 config RTC_DRV_EFI
 	tristate "EFI RTC"
-	depends on EFI && !X86
+	depends on EFI
 	help
 	  If you say yes here you will get support for the EFI
 	  Real Time Clock.
diff --git a/drivers/rtc/rtc-efi.c b/drivers/rtc/rtc-efi.c
index 0130afd..5a8427f 100644
--- a/drivers/rtc/rtc-efi.c
+++ b/drivers/rtc/rtc-efi.c
@@ -23,6 +23,14 @@
 #include <linux/rtc.h>
 #include <linux/efi.h>
 
+/*
+ * Disable the use of rtc-efi as a RTC for X86 by default. This setting can be
+ * overridden using this module's enable parameter.
+ */
+static bool efi_rtc_enable = !IS_ENABLED(CONFIG_X86);
+
+module_param_named(enable, efi_rtc_enable, bool, 0644);
+
 #define EFI_ISDST (EFI_TIME_ADJUST_DAYLIGHT|EFI_TIME_IN_DAYLIGHT)
 
 /*
@@ -262,6 +270,9 @@ static int __init efi_rtc_probe(struct platform_device *dev)
 	efi_time_t eft;
 	efi_time_cap_t cap;
 
+	if (!efi_rtc_enable)
+		return -ENODEV;
+
 	/* First check if the RTC is usable */
 	if (efi.get_time(&eft, &cap) != EFI_SUCCESS)
 		return -ENODEV;
-- 
1.8.3.1

^ permalink raw reply related	[flat|nested] 2+ messages in thread

end of thread, other threads:[~2017-05-05 21:07 UTC | newest]

Thread overview: 2+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2017-05-02  8:51 [PATCH] rtc: rtc-efi: Add an enable parameter and make it false for X86 by default Ocean HY1 He
2017-05-05 21:07 ` Matt Fleming

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox