mirror of https://lore.kernel.org/lkml/
 help / color / mirror / Atom feed
From: Ocean HY1 He <hehy1@lenovo.com>
To: "matt.fleming@intel.com" <matt.fleming@intel.com>,
	"a.zummo@towertech.it" <a.zummo@towertech.it>,
	"alexandre.belloni@free-electrons.com" 
	<alexandre.belloni@free-electrons.com>,
	"msalter@redhat.com" <msalter@redhat.com>
Cc: "rtc-linux@googlegroups.com" <rtc-linux@googlegroups.com>,
	"linux-kernel@vger.kernel.org" <linux-kernel@vger.kernel.org>,
	Ocean HY1 He <hehy1@lenovo.com>
Subject: [PATCH] rtc: rtc-efi: Add an enable parameter and make it false for X86 by default
Date: Tue, 2 May 2017 08:51:47 +0000	[thread overview]
Message-ID: <1493715444-79142-1-git-send-email-hehy1@lenovo.com> (raw)

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

             reply	other threads:[~2017-05-02  8:52 UTC|newest]

Thread overview: 2+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2017-05-02  8:51 Ocean HY1 He [this message]
2017-05-05 21:07 ` Matt Fleming

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=1493715444-79142-1-git-send-email-hehy1@lenovo.com \
    --to=hehy1@lenovo.com \
    --cc=a.zummo@towertech.it \
    --cc=alexandre.belloni@free-electrons.com \
    --cc=linux-kernel@vger.kernel.org \
    --cc=matt.fleming@intel.com \
    --cc=msalter@redhat.com \
    --cc=rtc-linux@googlegroups.com \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox

all inboxes | Powered by JetHome®