Support timezone of ACPI TAD and EFI TIME
Subsystems (7)
cover Support timezone of ACPI TAD and EFI TIME
This patchset add the timezone support of ACPI TAD and EFI TIME, it also add codes for adjusting system time base on the timezone value from EFI TIME services when system boot.
Those patches bring the following changes:
+ Add ACPI driver against ACPI000E ACPI Time and Alarm Device.
+ Add RTC driver of ACPI TAD.
+ Add rtc ioctl functions, RTC_RD_GMTOFF and RTC_SET_GMTOFF, provide interface to user space for maintain timezone value in BIOS. The GMTOFF names of ioctl functions match with the tm_gmtoff field in rtc_time and tm structure in GNU C library.
+ Add rtc ioctl function, RTC_CAPS_READ, provide to user space for grab the capabilities value to timezone and daylight of interface.
+ Moved duplicate functions to efi.h header for convert EFI Time.
+ When "CMOS RTC not Present" flag set in FADT, block CMOS RTC interface and switch to EFI time services.
+ Adjusting system time base on timezone from EFI time when system boot.
+ Add rtc-tz.txt document.
Please set CONFIG_RTC_DRV_EFI=m and CONFIG_RTC_ACPI_TAD=m to build RTC ACPI TAD and EFI TIME drivers.For testing, please use "acpi_no_cmos_rtc=1" to set CMOST RTC not Present flag in FADT to trigger the mechanism for adjust system time and block CMOS interface.
About the definition of timezone and the format transformation between ACPI, EFI and tm_gmtoff of GNU. Please check the rtc-tz.txt document in patch.
Jan Beulich (1):
x86-64/efi: Use EFI to deal with platform wall clock (again)
Lee, Chun-Yi (13):
rtc-efi: fix decrease day twice when computing year days
rtc: block registration of rtc-cmos when CMOS RTC Not Present
ACPI: Add ACPI 5.0 Time and Alarm Device driver
rtc: Add RTC driver of ACPI Time and Alarm Device
rtc-efi: register rtc-efi device when EFI enabled
rtc-efi: add GMTOFF support to rtc_efi
rtc-efi: set uie_unsupported for indicate rtc-efi doesn't support UIE
efi: move functions of access efi time to header file for sharing
rtc: improve and move week day computing function to rtc header
rtc: switch to get/set rtc time to efi functions if CMOS RTC Not
efi: adjust system time base on timezone from EFI time services Documentation/RTC: add document of ACPI TAD and EFI TIME driver
acpi: add early parameter to set CMOS RTC Not Present bit for testing
Documentation/rtc-tz.txt | 510 +++++++++++++++++++++++++++++++++++++++++++ arch/x86/kernel/acpi/boot.c | 17 ++ arch/x86/kernel/rtc.c | 28 ++- arch/x86/mm/pageattr.c | 10 +- arch/x86/platform/efi/efi.c | 89 ++++++-- drivers/acpi/Makefile | 3 + drivers/acpi/acpi_tad.c | 176 +++++++++++++++ drivers/acpi/bus.c | 3 + drivers/acpi/internal.h | 5 + drivers/char/efirtc.c | 98 --------- drivers/rtc/Kconfig | 12 +- drivers/rtc/Makefile | 1 + drivers/rtc/rtc-acpitad.c | 283 ++++++++++++++++++++++++ drivers/rtc/rtc-cmos.c | 9 + drivers/rtc/rtc-dev.c | 4 + drivers/rtc/rtc-efi.c | 177 +++++++--------- drivers/rtc/rtc-sysfs.c | 8 + include/asm-generic/rtc.h | 22 ++ include/linux/acpi.h | 31 +++ include/linux/efi.h | 127 +++++++++++- include/linux/rtc.h | 43 ++++ include/uapi/linux/rtc.h | 5 + init/main.c | 13 +- kernel/time.c | 2 +- 24 files changed, 1439 insertions(+), 237 deletions(-) create mode 100644 Documentation/rtc-tz.txt create mode 100644 drivers/acpi/acpi_tad.c create mode 100644 drivers/rtc/rtc-acpitad.c
PATCH 1/14 rtc-efi: fix decrease day twice when computing year days
Compared with the logic in rtc_year_days of efirtc.c, the code in rtc-efi decreases value of day twice when it computing year days. That's becase rtc_year_days in rtc-lib.c already decrease day for return the year days from 0 to 365.
--- drivers/rtc/rtc-efi.c | 2 +- 1 files changed, 1 insertions(+), 1 deletions(-)
drivers/rtc/rtc-efi.c +1 -1
@@ -35,7 +35,7 @@ static inline int compute_yday(efi_time_t *eft) {/* efi_time_t.month is in the [1-12] so, we need -1 */ -return rtc_year_days (eft->day -1 , eft->month -1 , eft->year); +return rtc_year_days (eft->day, eft->month -1 , eft->year); }/* * returns day of the week [0-6] 0=Sunday
Signature · 1 line
1.6.4.2
PATCH 3/14 rtc: block registration of rtc-cmos when CMOS RTC Not Present
In reply to Lee, Chun-YiWe should not acess CMOS address when CMOS RTC Not Present bit set in FADT. The ee5872be patch didn't avoid rtc-cmos driver loaded when system support ACPI PNP PNP0B0* devices.
So this patch block the registion of rtc-cmos driver to avoid
user space access RTC through CMOS interface.
--- arch/x86/kernel/rtc.c | 20 ++++++++++++++++---- drivers/rtc/rtc-cmos.c | 9 +++++++++ 2 files changed, 25 insertions(+), 4 deletions(-)
arch/x86/kernel/rtc.c +16 -4
@@ -174,16 +174,27 @@ static __init int add_rtc_cmos(void) { "PNP0b00", "PNP0b01", "PNP0b02", }; struct pnp_dev *dev; struct pnp_id *id; - int i; + int i = 0; + bool found_pnp; pnp_for_each_dev(dev) { for (id = dev->id; id; id = id->next) { for (i = 0; i < ARRAY_SIZE(ids); i++) { - if (compare_pnp_id(id, ids[i]) != 0) - return 0; + if (compare_pnp_id(id, ids[i]) != 0) { + found_pnp = true; + goto found_pnp; + } } } } + +found_pnp: + if (found_pnp) { + if (acpi_gbl_FADT.header.revision >= 5 && + acpi_gbl_FADT.boot_flags & ACPI_FADT_NO_CMOS_RTC) + pr_err(FW_BUG "Found %s device but CMOS RTC Not Present flag set\n", ids[i]); + return 0; + } #endif if (of_have_populated_dt()) return 0;
@@ -193,7 +204,8 @@ static __init int add_rtc_cmos(void)return -ENODEV ;#ifdef CONFIG_ACPI -if (acpi_gbl_FADT.boot_flags &ACPI_FADT_NO_CMOS_RTC ) { +if (acpi_gbl_FADT.header.revision >=5 && + acpi_gbl_FADT.boot_flags &ACPI_FADT_NO_CMOS_RTC ) {/* This warning can likely go away again in a year or two. */ pr_info ("ACPI: not registering RTC platform device\n" );return -ENODEV ;
drivers/rtc/rtc-cmos.c +9 -0
@@ -28,6 +28,9 @@* interrupts disabled, holding the global rtc_lock, to exclude those * other drivers and utilities on correctly configured systems. */ + +#define pr_fmt (fmt) KBUILD_MODNAME ": " fmt +#include <linux/kernel.h> #include <linux/module.h> #include <linux/init.h>
@@ -1144,6 +1147,12 @@ static int __init cmos_init(void) {int retval =0 ; +if (acpi_gbl_FADT.header.revision >=5 && + acpi_gbl_FADT.boot_flags &ACPI_FADT_NO_CMOS_RTC ) { +pr_info ("ACPI CMOS RTC Not Present detected - not loading\n" ); +return 0 ; + } +#ifdef CONFIG_PNP retval =pnp_register_driver (&cmos_pnp_driver);if (retval ==0 )
Signature · 1 line
1.6.4.2
RFC PATCH 4/14 ACPI: Add ACPI 5.0 Time and Alarm Device driver
In reply to Lee, Chun-YiThis patch add the driver of Time and Alarm Device in ACPI 5.0. Currently it only implemented get/set time functions and grab the capabilities of device when driver initial.
This driver also register rtc-acpitad platform device for RTC ACPITAD stub driver using.
--- drivers/acpi/Makefile | 3 + drivers/acpi/acpi_tad.c | 176 +++++++++++++++++++++++++++++++++++++++++++++++ drivers/acpi/bus.c | 3 + drivers/acpi/internal.h | 5 ++ include/linux/acpi.h | 31 ++++++++ 5 files changed, 218 insertions(+), 0 deletions(-) create mode 100644 drivers/acpi/acpi_tad.c
drivers/acpi/Makefile +3 -0
@@ -50,6 +50,9 @@ acpi-$(CONFIG_ACPI_NUMA) += numa.o ifdef CONFIG_ACPI_VIDEO acpi-y += video_detect.o endif +ifdef CONFIG_X86 +acpi-y += acpi_tad.o +endif # These are (potentially) separate modules
drivers/acpi/acpi_tad.c new file +176 -0
176 lines not on this page · raw message
drivers/acpi/bus.c +3 -0
@@ -689,6 +689,9 @@ static int __init acpi_init(void)pci_mmcfg_late_init ();acpi_scan_init ();acpi_ec_init (); +#ifdef CONFIG_X86 +acpi_tad_init (); +#endif acpi_debugfs_init ();acpi_sleep_proc_init ();acpi_wakeup_device_init ();
drivers/acpi/internal.h +5 -0
@@ -134,6 +134,11 @@ void acpi_ec_block_transactions(void);void acpi_ec_unblock_transactions (void );void acpi_ec_unblock_transactions_early (void ); +/* -------------------------------------------------------------------------- +Time and Alarm Device +-------------------------------------------------------------------------- */ +int acpi_tad_init (void ); +/*-------------------------------------------------------------------------- Suspend/Resume -------------------------------------------------------------------------- */
include/linux/acpi.h +31 -0
@@ -173,6 +173,37 @@ extern int ec_transaction(u8 command, u8 *rdata, unsigned rdata_len);extern acpi_handle ec_get_handle (void ); +/* +* Time and Alarm device capability flags +*/ +#define TAD_CAP_ACWAKE (1<<0) +#define TAD_CAP_DCWAKE (1<<1) +#define TAD_CAP_GETSETTIME (1<<2) +#define TAD_CAP_ACCURACY (1<<3) + +#define ACPI_TIME_AFFECTED_BY_DAYLIGHT (1<<0) +#define ACPI_TIME_ADJUSTED_FOR_DAYLIGHT (1<<1) +#define ACPI_ISDST (ACPI_TIME_AFFECTED_BY_DAYLIGHT|ACPI_TIME_ADJUSTED_FOR_DAYLIGHT) +#define ACPI_UNSPECIFIED_TIMEZONE 2047 + +struct acpi_time { +u16 year; +u8 month; +u8 day; +u8 hour; +u8 minute; +u8 second; +u8 pad1; +u16 milliseconds; +s16 timezone; +u8 daylight; +u8 pad2[3 ]; +}; + +extern int acpi_read_time (struct acpi_time *acpit); +extern int acpi_set_time (struct acpi_time *acpit); +extern int acpi_tad_get_capability (unsigned long *output); +#if defined(CONFIG_ACPI_WMI ) || defined(CONFIG_ACPI_WMI_MODULE )typedef void (*wmi_notify_handler ) (u32 value,void *context);
Signature · 1 line
1.6.4.2
H. Peter Anvin
reviewerRe: [RFC PATCH 04/14] ACPI: Add ACPI 5.0 Time and Alarm Device driver
Quoted 8 lines · Chun-Yi
This patch add the driver of Time and Alarm Device in ACPI 5.0. Currently it only implemented get/set time functions and grab the capabilities of device when driver initial.
This driver also register rtc-acpitad platform device for RTC ACPITAD stub driver using.
Signed-off-by Lee, Chun-Yi <jlee-IBi9RG/[email protected]>
What platform do you have that has TAD support? I am wondering how this was tested.
-hpa
Re: [RFC PATCH 04/14] ACPI: Add ACPI 5.0 Time and Alarm Device driver
於 四,2013-12-19 於 07:22 -0800,H. Peter Anvin 提到:
Quoted 8 lines · Chun-Yi
Quoted 7 lines
This patch add the driver of Time and Alarm Device in ACPI 5.0. Currently it only implemented get/set time functions and grab the capabilities of device when driver initial.
This driver also register rtc-acpitad platform device for RTC ACPITAD stub driver using.
Quoted 7 lines
Quoted 1 line
Signed-off-by Lee, Chun-Yi <jlee-IBi9RG/[email protected]>What platform do you have that has TAD support? I am wondering how this was tested.
-hpa
It's a testing platform that's only support get/set time functions of ACPI TAD.
Thanks
Joey Lee
H. Peter Anvin
reviewerRe: [RFC PATCH 04/14] ACPI: Add ACPI 5.0 Time and Alarm Device driver
Quoted 8 lines · joeyli
Quoted 4 lines
What platform do you have that has TAD support? I am wondering how this was tested.
It's a testing platform that's only support get/set time functions of ACPI TAD.
It would be really, really good to get this into Qemu (either SeaBIOS or OVMF, or ideally both) so we can have anyone test.
-hpa
Re: [RFC PATCH 04/14] ACPI: Add ACPI 5.0 Time and Alarm Device driver
於 二,2013-12-31 於 16:42 -0800,H. Peter Anvin 提到:
Quoted 6 lines · joeyli
Quoted 5 lines
Quoted 4 lines
What platform do you have that has TAD support? I am wondering how this was tested.
Quoted 9 lines
Quoted 3 lines
It's a testing platform that's only support get/set time functions of ACPI TAD.
It would be really, really good to get this into Qemu (either SeaBIOS or OVMF, or ideally both) so we can have anyone test.
-hpa
I will try to add to OVMF first.
Thanks
Joey Lee
H. Peter Anvin
reviewerRe: [RFC PATCH 04/14] ACPI: Add ACPI 5.0 Time and Alarm Device driver
Quoted 11 lines · joeyli
於 二,2013-12-31 於 16:42 -0800,H. Peter Anvin 提到:
Quoted 10 lines · joeyli
Quoted 8 lines
Quoted 4 lines
What platform do you have that has TAD support? I am wondering how this was tested.
It's a testing platform that's only support get/set time functions of ACPI TAD.
Quoted 7 lines
Quoted 4 lines
It would be really, really good to get this into Qemu (either SeaBIOS or OVMF, or ideally both) so we can have anyone test.
-hpa
I will try to add to OVMF first.
For the record, I posted a patch to Qemu about a year ago to store the timezone in the CMOS, which might be useful for this implementation. It was rejected because of no firmware support, so if you implement it for OVMF we can (update and) push this patch again.
-hpa
From: "H. Peter Anvin" <[email protected]>
There is no standard method for storing timezone information associated with the classic PC/AT RTC, however, there are standard methods in ACPI (Time and Alarm Device) and EFI (GetTime/SetTime) for getting this information.
Since these are abstract methods, it is qreally firmware-specific how it is stored, however, since Qemu initializes the RTC in the virtual environment that information needs to come from Qemu in the first place.
Non-PC platforms that use the MC146181 RTC may have their own firmware-specific methods as well.
The most logical place to stash this information is in the RTC CMOS; not only is it logically co-located with the relevant information, but it is also very easy to access from ACPI bytecode. Thus, save the timezone information in two bytes in CMOS that have no known standard definition, but are yet within the 64 bytes that even the most basic RTC CMOS implementations including the original MC146181 support.
Note: all timezones currently in use in the world are on 15-minutes boundaries, which would allow this information to be stored in a single signed byte. However, both EFI and ACPI use a minute-granular interface (specified as -1440 to +1440 with 2047 used to mean "unknown", this requires a minimum of 12 bits to represent); this follows that model.
--- hw/mc146818rtc.c | 6 ++++++ hw/mc146818rtc_regs.h | 2 ++ 2 files changed, 8 insertions(+)
hw/mc146818rtc.c +6 -0
@@ -681,6 +681,7 @@ static void rtc_set_date_from_host(ISADevice *dev) {RTCState *s =DO_UPCAST (RTCState, dev, dev);struct tm tm; +int minuteseast;qemu_get_timedate (&tm,0 );
@@ -690,6 +691,11 @@ static void rtc_set_date_from_host(ISADevice *dev)/* set the CMOS date */ rtc_set_cmos (s, &tm); + +/* Set the timezone information as a signed 16-bit number of minutes */ + minuteseast = ((int64_t )s->base_rtc - (int64_t )mktime (&tm)) /60 ; + s->cmos_data[RTC_TIMEZONE_L ] = (uint8_t )(minuteseast); + s->cmos_data[RTC_TIMEZONE_H ] = (uint8_t )(minuteseast >>8 ); }static int rtc_post_load (void *opaque,int version_id)
hw/mc146818rtc_regs.h +2 -0
@@ -47,6 +47,8 @@/* PC cmos mappings */ #define RTC_CENTURY 0x32#define RTC_IBM_PS2_CENTURY_BYTE 0x37 +#define RTC_TIMEZONE_L 0x3e +#define RTC_TIMEZONE_H 0x3f#define REG_A_UIP 0x80
Signature · 1 line
1.7.11.7
Re: [RFC PATCH 04/14] ACPI: Add ACPI 5.0 Time and Alarm Device driver
於 一,2014-01-06 於 21:37 -0800,H. Peter Anvin 提到:
Quoted 20 lines · joeyli
Quoted 11 lines
於 二,2013-12-31 於 16:42 -0800,H. Peter Anvin 提到:
Quoted 10 lines · joeyli
Quoted 8 lines
Quoted 4 lines
What platform do you have that has TAD support? I am wondering how this was tested.
It's a testing platform that's only support get/set time functions of ACPI TAD.
Quoted 7 lines
Quoted 4 lines
It would be really, really good to get this into Qemu (either SeaBIOS or OVMF, or ideally both) so we can have anyone test.
-hpa
I will try to add to OVMF first.
Quoted 7 lines
For the record, I posted a patch to Qemu about a year ago to store the timezone in the CMOS, which might be useful for this implementation. It was rejected because of no firmware support, so if you implement it for OVMF we can (update and) push this patch again.
-hpa
Thanks for your patch.
Due to accessing CMOS through ASL need enable SMM support in OVMF, I am looking Laszlo's OVMF S3 patches:
https://www.mail-archive.com/[email protected]/msg04969.html
Honestly I am not good on this area, I need to spend more time to understand it.
Regards
Joey Lee
--
To unsubscribe from this list: send the line "unsubscribe linux-acpi" in the body of a message to [email protected]
More majordomo info at http://vger.kernel.org/majordomo-info.html
H. Peter Anvin
reviewerRe: [RFC PATCH 04/14] ACPI: Add ACPI 5.0 Time and Alarm Device driver
Quoted 2 lines · joeyli
Due to accessing CMOS through ASL need enable SMM support in OVMF,
Why? The CMOS is its own ASL address space, and you need that anyway to be able to access the RTC proper. If you don't want to use it because you don't want to export any indication of a legacy RTC you should be able to just do I/O port references directly in your ASL.
-hpa
Re: [RFC PATCH 04/14] ACPI: Add ACPI 5.0 Time and Alarm Device driver
於 二,2014-01-07 於 08:35 -0800,H. Peter Anvin 提到:
Quoted 12 lines · joeyli
Quoted 2 lines
Due to accessing CMOS through ASL need enable SMM support in OVMF,
Why? The CMOS is its own ASL address space, and you need that anyway to be able to access the RTC proper. If you don't want to use it because you don't want to export any indication of a legacy RTC you should be able to just do I/O port references directly in your ASL.
-hpa
ACPICA denied AML access RTC ports.
I tried to access 0x70, 0x71 ports in ASL on a real machine, ACPICA denied AML access to those ports. I got the following dmesg:
hwvalid-0188 hw_validate_io_request: Denied AML access to port 0x0000000000000071/1
The code in acpica denied it:
linux/drivers/acpi/acpica/hwvalid.c
* This provides ACPICA with the desired port protections and
* Microsoft compatibility.
*
* Description of port entries:
[...]
* RTC: Real-time clock * CMOS: Extended CMOS
[...]
*/
static const struct acpi_port_info acpi_protected_ports[] = { [...]
{"RTC", 0x0070, 0x0071, ACPI_OSI_WIN_XP},
{"CMOS", 0x0074, 0x0076, ACPI_OSI_WIN_XP},Document of Windows XP:
http://www.freelists.org/post/windows_errors/what-error-messages-really-mean-WinXP-IO-Ports-Blocked-from-Bios-AML-on-Windows-XP
If just for ACPI TAD testing, we can remove the port protection check of RTC ports in hwvalid.c. I have read 0x70/0x71 port success after removed the checking in acpica/hwvalid.c.
I will try to write RTC port in AML after remove acpica check, maybe have other unpredictable situation.
Thanks a lot!
Joey Lee
--
To unsubscribe from this list: send the line "unsubscribe linux-acpi" in the body of a message to [email protected]
More majordomo info at http://vger.kernel.org/majordomo-info.html
H. Peter Anvin
reviewerRe: [RFC PATCH 04/14] ACPI: Add ACPI 5.0 Time and Alarm Device driver
Quoted 31 lines · joeyli
ACPICA denied AML access RTC ports.
I tried to access
0x70,0x71ports in ASL on a real machine, ACPICA denied AML access to those ports. I got the following dmesg:hwvalid-0188
hw_validate_io_request: Denied AML access to port 0x0000000000000071/1The code in acpica denied it:
linux/drivers/acpi/acpica/hwvalid.c* This provides ACPICA with the desired port protections and
* Microsoft compatibility.
*
* Description of port entries:
[...]* RTC: Real-time clock * CMOS: Extended CMOS[...]
*/
static const structacpi_port_infoacpi_protected_ports[] = { [...]{"RTC", 0x0070, 0x0071, ACPI_OSI_WIN_XP}, {"CMOS", 0x0074, 0x0076, ACPI_OSI_WIN_XP},Document of Windows XP:
http://www.freelists.org/post/windows_errors/what-error-messages-really-mean-WinXP-IO-Ports-Blocked-from-Bios-AML-on-Windows-XP
Quoted 7 lines
If just for ACPI TAD testing, we can remove the port protection check of RTC ports in
hwvalid.c. I have read 0x70/0x71 port success after removed the checking inacpica/hwvalid.c.I will try to write RTC port in AML after remove acpica check, maybe have other unpredictable situation.
Now *THERE* is a good use of the "no RTC bit". In the case that bit is set we should presumably remove these ports from the block list.
Otherwise we should use the CMOS address space, not the I/O port address space.
-hpa
Re: [RFC PATCH 04/14] ACPI: Add ACPI 5.0 Time and Alarm Device driver
於 三,2014-01-08 於 09:56 -0800,H. Peter Anvin 提到:
[...]
Quoted 10 lines
Quoted 2 lines
Document of Windows XP:
Quoted 2 lines
If just for ACPI TAD testing, we can remove the port protection
check of
Quoted 1 line
RTC ports in
hwvalid.c. I have read 0x70/0x71 port success afterremoved
Quoted 2 lines
the checking in
acpica/hwvalid.c.
Quoted 7 lines
Quoted 3 lines
I will try to write RTC port in AML after remove acpica check, maybe have other unpredictable situation.
Now *THERE* is a good use of the "no RTC bit". In the case that bit is
set we should presumably remove these ports from the block list.
Thanks for your suggestion, I will put a testing patch on this.
Quoted 6 lines
Otherwise we should use the CMOS address space, not the I/O port address
space.-hpa
Unfortunately current acpica leaks the SystemCMOS handler:
ACPI Error: Region SystemCMOS (ID=5) has no handler (20131115/exfldio-299)
Regards
Joey Lee
H. Peter Anvin
reviewerRe: [RFC PATCH 04/14] ACPI: Add ACPI 5.0 Time and Alarm Device driver
Quoted 5 lines · joeyli
Unfortunately current acpica leaks the SystemCMOS handler:
ACPI Error: Region SystemCMOS (ID=5) has no handler (20131115/exfldio-299)
I'm sorry, I can't parse either your statement or the error message... sounds like there is a bug here, too.
-hpa
Re: [RFC PATCH 04/14] ACPI: Add ACPI 5.0 Time and Alarm Device driver
In reply to joeyliQuoted 27 lines · joeyli
於 三,2014-01-08 於 09:56 -0800,H. Peter Anvin 提到:
[...]Quoted 10 lines
Quoted 2 lines
Document of Windows XP:
Quoted 2 lines
If just for ACPI TAD testing, we can remove the port protection
check of
Quoted 1 line
RTC ports in
hwvalid.c. I have read 0x70/0x71 port success afterremoved
Quoted 2 lines
the checking in
acpica/hwvalid.c.Quoted 7 lines
Quoted 3 lines
I will try to write RTC port in AML after remove acpica check, maybe have other unpredictable situation.
Now *THERE* is a good use of the "no RTC bit". In the case that bit is
set we should presumably remove these ports from the block list.Thanks for your suggestion, I will put a testing patch on this.
Quoted 5 lines
Otherwise we should use the CMOS address space, not the I/O port address
space.
Quoted 5 lines
Quoted 1 line
-hpa
Unfortunately current acpica leaks the SystemCMOS handler:
ACPI Error: Region SystemCMOS (ID=5) has no handler (20131115/exfldio-299)
This is not an ACPICA problem. We have no CMOS address space handler in Linux and arguably there should be one. So I'd suggest implementing that to start with or we risk conflicts between kernel code and AML accessing registers in that space.
Thanks!
Signature · 6 lines
I speak only for myself. Rafael J. Wysocki, Intel Open Source Technology Center. -- To unsubscribe from this list: send the line "unsubscribe linux-acpi" in the body of a message to [email protected] More majordomo info at http://vger.kernel.org/majordomo-info.html
Re: [RFC PATCH 04/14] ACPI: Add ACPI 5.0 Time and Alarm Device driver
In reply to Lee, Chun-Yi2013/12/19 Lee, Chun-Yi <[email protected]>:
Quoted 218 lines
This patch add the driver of Time and Alarm Device in ACPI 5.0. Currently it only implemented get/set time functions and grab the capabilities of device when driver initial.
This driver also register rtc-acpitad platform device for RTC ACPITAD stub driver using.
Signed-off-by Lee, Chun-Yi <jlee-IBi9RG/[email protected]>--- drivers/acpi/Makefile | 3 + drivers/acpi/acpi_tad.c | 176 +++++++++++++++++++++++++++++++++++++++++++++++ drivers/acpi/bus.c | 3 + drivers/acpi/internal.h | 5 ++ include/linux/acpi.h | 31 ++++++++ 5 files changed, 218 insertions(+), 0 deletions(-) create mode 100644 drivers/acpi/acpi_tad.cdrivers/acpi/Makefile +3
-0@@ -50,6 +50,9 @@ acpi-$(CONFIG_ACPI_NUMA) += numa.o ifdef CONFIG_ACPI_VIDEO acpi-y += video_detect.o endif +ifdef CONFIG_X86 +acpi-y += acpi_tad.o +endif # These are (potentially) separate modulesdrivers/acpi/acpi_tad.c new file +176
-0@@ -0,0 +1,176 @@ +/* rtc.c - ACPI 5.0 Time and Alarm Driver +* +* Copyright (C) 2013 SUSE Linux Products GmbH. All rights reserved. +* Written by Lee, Chun-Yi (jlee-IBi9RG/[email protected]) +* +* This program is free software; you can redistribute it and/or +* modify it under the terms of the GNU General Public Licence +* as published by the Free Software Foundation; either version +* 2 of the Licence, or (at your option) any later version. +*/ +#include <linux/module.h> +#include <linux/platform_device.h> +#include <acpi/acpi_drivers.h> + +#include <asm/time.h> + +#define ACPI_TIME_ALARM_NAME "Time and Alarm" +ACPI_MODULE_NAME (ACPI_TIME_ALARM_NAME ); +#define ACPI_TIME_ALARM_CLASS "time_alarm" + +static const struct acpi_device_id time_alarm_ids[] = { + {"ACPI000E" ,0 }, + {"" ,0 }, +}; +MODULE_DEVICE_TABLE (acpi, time_alarm_ids); + +static struct platform_device rtc_acpitad_dev = { + .name ="rtc-acpitad" , + .id =-1 , +}; + +static struct acpi_device *acpi_tad_dev; +static unsigned long long cap; + +int acpi_read_time (struct acpi_time *output) +{ +unsigned long flags; +struct acpi_buffer result = {ACPI_ALLOCATE_BUFFER ,NULL }; +union acpi_object *obj; +struct acpi_time *acpit; +acpi_status status; + +if (!acpi_tad_dev) +return -ENODEV ; + +if (!(cap &TAD_CAP_GETSETTIME )) +return -EINVAL ; + +if (!output) +return -EINVAL ; + +spin_lock_irqsave (&rtc_lock, flags); + status =acpi_evaluate_object (acpi_tad_dev->handle,"_GRT" ,NULL , &result); +spin_unlock_irqrestore (&rtc_lock, flags); +if (ACPI_FAILURE (status)) { +ACPI_EXCEPTION ((AE_INFO , status,"Evaluating _GRT" )); +return -ENODEV ; + } + + obj = result.pointer; +if (!obj || + obj->type !=ACPI_TYPE_BUFFER || + obj->buffer.length >sizeof (struct acpi_time ) || + obj->buffer.length < offsetof(struct acpi_time , pad2)) { +dev_err (&acpi_tad_dev->dev,ACPI_TIME_ALARM_NAME +" Invalid _GRT data\n" ); +return -EINVAL ; + } + + acpit = (struct acpi_time *) obj->buffer.pointer; +if (acpit) { + output->year = acpit->year; + output->month = acpit->month; + output->day = acpit->day; + output->hour = acpit->hour; + output->minute = acpit->minute; + output->second = acpit->second; + output->milliseconds = acpit->milliseconds; + output->timezone = acpit->timezone; + output->daylight = acpit->daylight; + } + +return 0 ; +} +EXPORT_SYMBOL (acpi_read_time); + +int acpi_set_time (struct acpi_time *acpit) +{ +unsigned long flags; +struct acpi_object_list input; +union acpi_object params[1 ]; +unsigned long long output; +acpi_status status; + +if (!acpi_tad_dev) +return -ENODEV ; + +if (!(cap &TAD_CAP_GETSETTIME )) +return -EINVAL ; + +if (!acpit) +return -EINVAL ; + + input.count =1 ; + input.pointer = params; + params[0 ].type =ACPI_TYPE_BUFFER ; + params[0 ].buffer.length =sizeof (struct acpi_time ); + params[0 ].buffer.pointer = (void *) acpit; + +spin_lock_irqsave (&rtc_lock, flags); + status =acpi_evaluate_integer (acpi_tad_dev->handle,"_SRT" , &input, &output); +spin_unlock_irqrestore (&rtc_lock, flags); +if (ACPI_FAILURE (status)) { +ACPI_EXCEPTION ((AE_INFO , status,"Evaluating _SRT" )); +return -ENODEV ; + } + +return 0 ; +} +EXPORT_SYMBOL (acpi_set_time); + +int acpi_tad_get_capability (unsigned long *output) +{ +if (!acpi_tad_dev) +return -ENODEV ; + + *output = cap; + +return 0 ; +} +EXPORT_SYMBOL (acpi_tad_get_capability); + +static int acpi_time_alarm_add (struct acpi_device *device) +{ +acpi_status status; + +if (!device) +return -EINVAL ; + + acpi_tad_dev = device; + +/* evaluate _GCP */ + status =acpi_evaluate_integer (device->handle,"_GCP" ,NULL , &cap); +if (ACPI_FAILURE (status)) { +ACPI_EXCEPTION ((AE_INFO , status,"Evaluating _GCP" )); +return -ENODEV ; + } + +if (!(cap &TAD_CAP_GETSETTIME )) +pr_warn (FW_INFO "Get/Set real time features not available.\n" ); + +if (platform_device_register (&rtc_acpitad_dev) <0 ) +pr_err ("Unable to register rtc-acpitad device\n" ); + +return 0 ; +} + +static struct acpi_driver acpi_time_alarm_driver = { + .name ="time_and_alarm" , + .class =ACPI_TIME_ALARM_CLASS , + .ids = time_alarm_ids, + .ops = { + .add = acpi_time_alarm_add, + }, +}; + +int __init acpi_tad_init (void ) +{ +int result =0 ; + + result =acpi_bus_register_driver (&acpi_time_alarm_driver); +if (result <0 ) +return -ENODEV ; + +return result; +}drivers/acpi/bus.c +0
-0
drivers/acpi/bus.c static int __init acpi_init(void) · line 694
Quoted 6 lines
drivers/acpi/bus.c +3
-0@@ -689,6 +689,9 @@ static int __init acpi_init(void)pci_mmcfg_late_init ();acpi_scan_init ();acpi_ec_init (); +#ifdef CONFIG_X86 +acpi_tad_init (); +#endif
Why calling acpi_tad_init() directly here rather than using module_initcall? Is there dependency?
Quoted 68 lines
drivers/acpi/bus.c +0
-0acpi_debugfs_init ();acpi_sleep_proc_init ();acpi_wakeup_device_init ();drivers/acpi/internal.h +5
-0@@ -134,6 +134,11 @@ void acpi_ec_block_transactions(void);void acpi_ec_unblock_transactions (void );void acpi_ec_unblock_transactions_early (void ); +/* -------------------------------------------------------------------------- +Time and Alarm Device +-------------------------------------------------------------------------- */ +int acpi_tad_init (void ); +/*-------------------------------------------------------------------------- Suspend/Resume -------------------------------------------------------------------------- */ include/linux/acpi.h +31
-1@@ -173,6 +173,37 @@ extern int ec_transaction(u8 command, u8 *rdata, unsigned rdata_len);extern acpi_handle ec_get_handle (void ); +/* +* Time and Alarm device capability flags +*/ +#define TAD_CAP_ACWAKE (1<<0) +#define TAD_CAP_DCWAKE (1<<1) +#define TAD_CAP_GETSETTIME (1<<2) +#define TAD_CAP_ACCURACY (1<<3) + +#define ACPI_TIME_AFFECTED_BY_DAYLIGHT (1<<0) +#define ACPI_TIME_ADJUSTED_FOR_DAYLIGHT (1<<1) +#define ACPI_ISDST (ACPI_TIME_AFFECTED_BY_DAYLIGHT|ACPI_TIME_ADJUSTED_FOR_DAYLIGHT) +#define ACPI_UNSPECIFIED_TIMEZONE 2047 + +struct acpi_time { +u16 year; +u8 month; +u8 day; +u8 hour; +u8 minute; +u8 second; +u8 pad1; +u16 milliseconds; +s16 timezone; +u8 daylight; +u8 pad2[3 ]; +}; + +extern int acpi_read_time (struct acpi_time *acpit); +extern int acpi_set_time (struct acpi_time *acpit); +extern int acpi_tad_get_capability (unsigned long *output); +#if defined(CONFIG_ACPI_WMI ) || defined(CONFIG_ACPI_WMI_MODULE )typedef void (*wmi_notify_handler ) (u32 value,void *context); --1.6.4.2
--
To unsubscribe from this list: send the line "unsubscribe linux-acpi" in the body of a message to [email protected] More majordomo info at http://vger.kernel.org/majordomo-info.html
Signature · 2 lines
Best regards Tianyu Lan
Re: [RFC PATCH 04/14] ACPI: Add ACPI 5.0 Time and Alarm Device driver
於 四,2014-01-02 於 16:09 +0800,Lan Tianyu 提到:
Quoted 7 lines
Quoted 7 lines
drivers/acpi/bus.c +0
-0@@ -689,6 +689,9 @@ static int __init acpi_init(void)pci_mmcfg_late_init ();acpi_scan_init ();
Quoted 9 lines
drivers/acpi/bus.c static int __init acpi_init(void) · line 694
Quoted 4 lines
drivers/acpi/bus.c +3
-0acpi_ec_init (); +#ifdef CONFIG_X86 +acpi_tad_init (); +#endif Why calling
acpi_tad_init()directly here rather than usingmodule_initcall?
Is there dependency?
The rtc-acpitad RTC driver depend on acpi_read/set_time functions in acpi_tad.
On the other hand, if we adapt to ACPI time device when "CMOS RTC Not Present" set, then acpi_read/set_time will used to replace CMOS functions that's called by other drivers. So, I direct call acpi_tad_init() here.
Thanks a lot!
Joey Lee
--
To unsubscribe from this list: send the line "unsubscribe linux-acpi" in the body of a message to [email protected]
More majordomo info at http://vger.kernel.org/majordomo-info.html
RFC PATCH 5/14 rtc: Add RTC driver of ACPI Time and Alarm Device
In reply to Lee, Chun-YiThis patch add the RTC driver of ACPI TAD to provide userspace access ACPI time through RTC interface.
--- drivers/rtc/Kconfig | 10 ++ drivers/rtc/Makefile | 1 + drivers/rtc/rtc-acpitad.c | 294 +++++++++++++++++++++++++++++++++++++++++++++ drivers/rtc/rtc-dev.c | 4 + drivers/rtc/rtc-sysfs.c | 8 ++ include/linux/rtc.h | 5 + include/uapi/linux/rtc.h | 5 + 7 files changed, 327 insertions(+), 0 deletions(-) create mode 100644 drivers/rtc/rtc-acpitad.c
drivers/rtc/Kconfig +10 -0
@@ -878,6 +878,16 @@ config RTC_DRV_NUC900 If you say yes here you get support for the RTC subsystem of the NUC910/NUC920 used in embedded systems. +config RTC_ACPI_TAD + tristate "RTC ACPI Time and Alarm Device driver" + help + This driver exposes ACPI 5.0 Time and Alarm Device as RTC device. + Say Y (or M) if you have a computer with ACPI 5.0 firmware that + implemented Time and Alarm Device. + + To compile this driver as a module, choose M here: + the module will be called rtc_acpitad. + comment "on-CPU RTC drivers" config RTC_DRV_DAVINCI
drivers/rtc/Makefile +1 -0
@@ -20,6 +20,7 @@ obj-$(CONFIG_RTC_DRV_88PM860X) += rtc-88pm860x.o obj-$(CONFIG_RTC_DRV_88PM80X) += rtc-88pm80x.o obj-$(CONFIG_RTC_DRV_AB3100) += rtc-ab3100.o obj-$(CONFIG_RTC_DRV_AB8500) += rtc-ab8500.o +obj-$(CONFIG_RTC_ACPI_TAD) += rtc-acpitad.o obj-$(CONFIG_RTC_DRV_AS3722) += rtc-as3722.o obj-$(CONFIG_RTC_DRV_AT32AP700X)+= rtc-at32ap700x.o obj-$(CONFIG_RTC_DRV_AT91RM9200)+= rtc-at91rm9200.o
drivers/rtc/rtc-acpitad.c new file +294 -0
294 lines not on this page · raw message
drivers/rtc/rtc-dev.c +4 -0
@@ -398,6 +398,10 @@ static long rtc_dev_ioctl(struct file *file, err = -EFAULT ;return err; +case RTC_CAPS_READ : + err =put_user (rtc->caps, (unsigned int __user *)uarg); +break ; +default :/* Finally try the driver's ioctl interface */ if (ops->ioctl) {
drivers/rtc/rtc-sysfs.c +8 -0
@@ -122,6 +122,13 @@ hctosys_show(struct device *dev, struct device_attribute *attr, char *buf) }static DEVICE_ATTR_RO (hctosys); +static ssize_t +caps_show (struct device *dev,struct device_attribute *attr,char *buf) +{ +return sprintf (buf,"%d\n" ,to_rtc_device (dev)->caps); +} +static DEVICE_ATTR_RO (caps); +static struct attribute *rtc_attrs[] = { &dev_attr_name.attr, &dev_attr_date.attr,
@@ -129,6 +136,7 @@ static struct attribute *rtc_attrs[] = { &dev_attr_since_epoch.attr, &dev_attr_max_user_freq.attr, &dev_attr_hctosys.attr, + &dev_attr_caps.attr,NULL , };ATTRIBUTE_GROUPS (rtc);
include/linux/rtc.h +5 -0
@@ -116,6 +116,11 @@ struct rtc_device/* Some hardware can't support UIE mode */ int uie_unsupported; +/* Time Zone and Daylight capabilities */ +#define RTC_TZ_CAP (1 << 0) +#define RTC_DST_CAP (1 << 1) +int caps; +#ifdef CONFIG_RTC_INTF_DEV_UIE_EMUL struct work_struct uie_task;struct timer_list uie_timer;
include/uapi/linux/rtc.h +5 -0
@@ -94,6 +94,11 @@ struct rtc_pll_info {#define RTC_VL_READ _IOR('p', 0x13, int)/* Voltage low detector */ #define RTC_VL_CLR _IO('p', 0x14)/* Clear voltage low information */ +#define RTC_RD_GMTOFF _IOR('p', 0x15, long int)/* Read time zone return seconds east of UTC */ +#define RTC_SET_GMTOFF _IOW('p', 0x16, long int)/* Set time zone input seconds east of UTC */ + +#define RTC_CAPS_READ _IOR('p', 0x17, unsigned int)/* Get capabilities, e.g. TZ, DST */ +/* interrupt flags */ #define RTC_IRQF 0x80/* Any of the following is active */ #define RTC_PF 0x40/* Periodic interrupt */
Signature · 1 line
1.6.4.2
RFC PATCH 6/14 rtc-efi: register rtc-efi device when EFI enabled
In reply to Lee, Chun-YiUEFI time services, GetTime(), SetTime(), GetWakeupTime(), SetWakeupTime() are also supported by other non-IA64 architecutre with UEFI BIOS, e.g. x86.
This patch changed RTC_DRV_EFI configuration to depend on EFI but not just IA64. It checks efi_enabled flag and efi-rtc driver should enabled.
--- arch/x86/platform/efi/efi.c | 17 +++++++++++++++++ drivers/rtc/Kconfig | 2 +- 2 files changed, 18 insertions(+), 1 deletions(-)
arch/x86/platform/efi/efi.c +17 -0
@@ -42,6 +42,7 @@#include <linux/io.h> #include <linux/reboot.h> #include <linux/bcd.h> +#include <linux/platform_device.h> #include <asm/setup.h> #include <asm/efi.h>
@@ -876,6 +877,22 @@ void __init efi_enter_virtual_mode(void) 0, NULL); } +static struct platform_device rtc_efi_dev = { + .name ="rtc-efi" , + .id =-1 , +}; + +static int __init rtc_init (void ) +{ +if (efi_enabled (EFI_RUNTIME_SERVICES ) && +platform_device_register (&rtc_efi_dev) <0 ) +pr_err ("unable to register rtc-efi device...\n" ); + +/* not necessarily an error */ +return 0 ; +} +arch_initcall (rtc_init); +/* * Convenience functions to obtain memory types and attributes */
drivers/rtc/Kconfig +1 -1
@@ -726,7 +726,7 @@ config RTC_DRV_DA9055 config RTC_DRV_EFI tristate "EFI RTC" - depends on IA64 + depends on EFI help If you say yes here you will get support for the EFI Real Time Clock.
Signature · 1 line
1.6.4.2
Re: [RFC PATCH 06/14] rtc-efi: register rtc-efi device when EFI enabled
Quoted 13 lines · Chun-Yi
UEFI time services,
GetTime(),SetTime(),GetWakeupTime(),SetWakeupTime()are also supported by other non-IA64 architecutre with UEFI BIOS, e.g. x86.This patch changed
RTC_DRV_EFIconfiguration to depend on EFI but not just IA64. It checksefi_enabledflag and efi-rtc driver should enabled.Cc Matt Fleming <[email protected]>Cc H. Peter Anvin <[email protected]>Cc Matthew Garrett <[email protected]>Cc Thomas Gleixner <[email protected]>Cc Ingo Molnar <[email protected]>Cc Jan Beulich <[email protected]>Signed-off-by Lee, Chun-Yi <[email protected]>
Quoted 4 lines
--- arch/x86/platform/efi/efi.c | 17 +++++++++++++++++ drivers/rtc/Kconfig | 2 +- 2 files changed, 18 insertions(+), 1 deletions(-)
This patch needs to be justified. Enabling the EFI runtime *Time functions just because they're available isn't good enough. We need to know why this patch improves things, what use case does it solve?
The general attitude has been that we want to invoke the runtime services less, not more, due to the huge variety of runtime implementation bugs.
Signature · 1 line
Matt Fleming, Intel Open Source Technology Center
Re: [RFC PATCH 06/14] rtc-efi: register rtc-efi device when EFI enabled
於 四,2013-12-19 於 14:09 +0000,Matt Fleming 提到:
Quoted 19 lines · Chun-Yi
Quoted 13 lines
UEFI time services,
GetTime(),SetTime(),GetWakeupTime(),SetWakeupTime()are also supported by other non-IA64 architecutre with UEFI BIOS, e.g. x86.This patch changed
RTC_DRV_EFIconfiguration to depend on EFI but not just IA64. It checksefi_enabledflag and efi-rtc driver should enabled.Cc Matt Fleming <[email protected]>Cc H. Peter Anvin <[email protected]>Cc Matthew Garrett <[email protected]>Cc Thomas Gleixner <[email protected]>Cc Ingo Molnar <[email protected]>Cc Jan Beulich <[email protected]>Signed-off-by Lee, Chun-Yi <[email protected]>Quoted 4 lines
--- arch/x86/platform/efi/efi.c | 17 +++++++++++++++++ drivers/rtc/Kconfig | 2 +- 2 files changed, 18 insertions(+), 1 deletions(-)
Quoted 4 lines
This patch needs to be justified. Enabling the EFI runtime *Time functions just because they're available isn't good enough. We need to know why this patch improves things, what use case does it solve?
The main purpose of enable efi-rtc driver is providing interface to userspace access timezone field in EFI time services.
Currently have two BIOS interfaces provided the timezone field accessing ability, ACPI TAD and EFI. I hope can enable them on x86_64 machines.
Quoted 4 lines
The general attitude has been that we want to invoke the runtime services less, not more, due to the huge variety of runtime implementation bugs.
I agreed, but userspace application should not be too often to access RTC. Maybe only when system boot and set timezone.
Thanks a lot!
Joey Lee
--
To unsubscribe from this list: send the line "unsubscribe linux-acpi" in the body of a message to [email protected]
More majordomo info at http://vger.kernel.org/majordomo-info.html
H. Peter Anvin
reviewerRe: [RFC PATCH 06/14] rtc-efi: register rtc-efi device when EFI enabled
Quoted 4 lines · joeyli
I agreed, but userspace application should not be too often to access RTC. Maybe only when system boot and set timezone.
This is, quite frankly, an idiotic argument. Userspace doesn't access the RTC, the kernel does, and if the underlying implementation is broken it doesn't matter if it is accessed one time or a thousand. For the record, in most cases the RTC gets accessed about every 15 minutes to update the time based on network time.
-hpa
Borislav Petkov
maintainerRe: [RFC PATCH 06/14] rtc-efi: register rtc-efi device when EFI enabled
Quoted 5 lines · H. Peter Anvin
Quoted 2 lines · joeyli
I agreed, but userspace application should not be too often to access RTC. Maybe only when system boot and set timezone.
This is, quite frankly, an idiotic argument.
TBH, I've been struggling with the question too - and it might even be a stupid question - but what is that absolute need to be able to get the TZ in userspace? Why should I care?
Can we get some use cases for stupid people like me please?
Thanks.
Signature · 5 lines
Regards/Gruss,
Boris.
Sent from a fat crate under my desk. Formatting is fine.
--Re: [RFC PATCH 06/14] rtc-efi: register rtc-efi device when EFI enabled
Quoted 5 lines · Borislav Petkov
Quoted 4 lines · H. Peter Anvin
Quoted 2 lines · joeyli
I agreed, but userspace application should not be too often to access RTC. Maybe only when system boot and set timezone.
Quoted 7 lines
Quoted 1 line
This is, quite frankly, an idiotic argument.
TBH, I've been struggling with the question too - and it might even be a stupid question - but what is that absolute need to be able to get the TZ in userspace? Why should I care?
Can we get some use cases for stupid people like me please?
Dual-boot environments will tend to have the RTC in local time, not UTC. That means that userspace has to reprogram the clock over daylight savings changes, and to do that it must know whether another OS has already done so.
Signature · 1 line
Matthew Garrett <[email protected]>
H. Peter Anvin
reviewerRe: [RFC PATCH 06/14] rtc-efi: register rtc-efi device when EFI enabled
Quoted 12 lines · Matthew Garrett
Quoted 11 lines · Borislav Petkov
Quoted 5 lines · H. Peter Anvin
Quoted 2 lines · joeyli
I agreed, but userspace application should not be too often to access RTC. Maybe only when system boot and set timezone.
This is, quite frankly, an idiotic argument.
TBH, I've been struggling with the question too - and it might even be a stupid question - but what is that absolute need to be able to get the TZ in userspace? Why should I care?
Quoted 7 lines
Quoted 1 line
Can we get some use cases for stupid people like me please?
Dual-boot environments will tend to have the RTC in local time, not UTC. That means that userspace has to reprogram the clock over daylight savings changes, and to do that it must know whether another OS has already done so.
Actually, it doesn't have to reprogram the clock ... it just needs to know if another OS has already done so. All Linux needs to do is to be able to derive UTC from whatever the RTC is set to and to be able to keep it consistent.
-hpa
Re: [RFC PATCH 06/14] rtc-efi: register rtc-efi device when EFI enabled
於 五,2013-12-20 於 13:04 -0800,H. Peter Anvin 提到:
Quoted 21 lines · Matthew Garrett
Quoted 12 lines · Borislav Petkov
Quoted 11 lines · H. Peter Anvin
Quoted 5 lines · joeyli
Quoted 2 lines
I agreed, but userspace application should not be too often to access RTC. Maybe only when system boot and set timezone.
This is, quite frankly, an idiotic argument.
TBH, I've been struggling with the question too - and it might even be a stupid question - but what is that absolute need to be able to get the TZ in userspace? Why should I care?
Quoted 7 lines
Quoted 1 line
Can we get some use cases for stupid people like me please?
Dual-boot environments will tend to have the RTC in local time, not UTC. That means that userspace has to reprogram the clock over daylight savings changes, and to do that it must know whether another OS has already done so.
Quoted 8 lines
Actually, it doesn't have to reprogram the clock ... it just needs to know if another OS has already done so. All Linux needs to do is to be able to derive UTC from whatever the RTC is set to and to be able to keep it consistent.
-hpa
It's dependent on a right boot initial priority of distribution. Here have a discussion of adjusting system clock by TZ (from ACPI or UEFI):
Discussion on BIOS/CMOS/UEFI clock in local time
http://www.spinics.net/lists/util-linux-ng/msg07639.html
and,
from Ted Ts'o in the mail thread
https://lkml.org/lkml/2008/1/8/195
If kernel use the TZ field from ACPI TAD or EFI to adjust system clock when booting, then it can avoid buggy distributions adjust system clock AFTER e2fsck is run.
Using ACPI TAD should after DSDT parsing in subsystem initial stage, so I choice EFI time services before we can move DSDT parser to start_kernel().
Thanks a lot!
Joey Lee
H. Peter Anvin
reviewerRe: [RFC PATCH 06/14] rtc-efi: register rtc-efi device when EFI enabled
Quoted 9 lines · joeyli
於 五,2013-12-20 於 13:04 -0800,H. Peter Anvin 提到:
Quoted 6 lines
Actually, it doesn't have to reprogram the clock ... it just needs to know if another OS has already done so. All Linux needs to do is to be able to derive UTC from whatever the RTC is set to and to be able to keep it consistent.
It's dependent on a right boot initial priority of distribution.
-ENOPARSE
Quoted 9 lines
Here have a discussion of adjusting system clock by TZ (from ACPI or UEFI):
Discussion on BIOS/CMOS/UEFI clock in local timehttp://www.spinics.net/lists/util-linux-ng/msg07639.htmland,
from Ted Ts'o in the mail threadhttps://lkml.org/lkml/2008/1/8/195
Quoted 8 lines
If kernel use the TZ field from ACPI TAD or EFI to adjust system clock when booting, then it can avoid buggy distributions adjust system clock AFTER e2fsck is run.
Using ACPI TAD should after DSDT parsing in subsystem initial stage, so I choice EFI time services before we can move DSDT parser to
start_kernel().
Yes, of course. That is irrelevant to needing to reprogram the clock, though.
My argument is very simple: if we have to rely on EFI, we can get the offset in the boot stub before ExitBootServices(), and then simply never change it. That way we still pick up if another operating system has changed it, and it will still reflect the proper UTC time.
-hpa
--
To unsubscribe from this list: send the line "unsubscribe linux-acpi" in the body of a message to [email protected]
More majordomo info at http://vger.kernel.org/majordomo-info.html
Re: [RFC PATCH 06/14] rtc-efi: register rtc-efi device when EFI enabled
於 五,2013-12-20 於 17:51 -0800,H. Peter Anvin 提到:
Quoted 34 lines · joeyli
Quoted 9 lines
於 五,2013-12-20 於 13:04 -0800,H. Peter Anvin 提到:
Quoted 6 lines
Actually, it doesn't have to reprogram the clock ... it just needs to know if another OS has already done so. All Linux needs to do is to be able to derive UTC from whatever the RTC is set to and to be able to keep it consistent.
It's dependent on a right boot initial priority of distribution.
-ENOPARSEQuoted 9 lines
Here have a discussion of adjusting system clock by TZ (from ACPI or UEFI):
Discussion on BIOS/CMOS/UEFI clock in local timehttp://www.spinics.net/lists/util-linux-ng/msg07639.htmland,
from Ted Ts'o in the mail threadhttps://lkml.org/lkml/2008/1/8/195Quoted 8 lines
If kernel use the TZ field from ACPI TAD or EFI to adjust system clock when booting, then it can avoid buggy distributions adjust system clock AFTER e2fsck is run.
Using ACPI TAD should after DSDT parsing in subsystem initial stage, so I choice EFI time services before we can move DSDT parser to
start_kernel().Yes, of course. That is irrelevant to needing to reprogram the clock, though.
Quoted 7 lines
My argument is very simple: if we have to rely on EFI, we can get the offset in the boot stub before
ExitBootServices(), and then simply never change it. That way we still pick up if another operating system has changed it, and it will still reflect the proper UTC time.-hpa
OK, I will add this part to next version for the UEFI system doesn't have ACPI TAD.
Thanks for your suggestion!
Joey Lee
H. Peter Anvin
reviewerRe: [RFC PATCH 06/14] rtc-efi: register rtc-efi device when EFI enabled
In reply to Borislav PetkovThe only real use case for the RTC TZ is compatibility with other operating systems that don't keep the time in UTC, at least as far as I can tell. However, that is a fairly big one, especially in VM deployments.
Quoted 16 lines · Borislav Petkov
Quoted 2 lines · H. Peter Anvin
Quoted 1 line · joeyli
I agreed, but userspace application should not be too often to
access
Quoted 3 lines
Quoted 1 line
RTC. Maybe only when system boot and set timezone.
This is, quite frankly, an idiotic argument.
TBH, I've been struggling with the question too - and it might even be a
stupid question - but what is that absolute need to be able to get the TZ in userspace? Why should I care?Can we get some use cases for stupid people like me please?
Thanks.
Signature · 1 line
Sent from my mobile phone. Please pardon brevity and lack of formatting.
RFC PATCH 7/14 rtc-efi: add GMTOFF support to rtc_efi
In reply to Lee, Chun-YiPer UEFI 2.3.1 spec, we can use SetTime() to store the timezone value to BIOS and get it back by GetTime(). It's good for installation system to gain the default timezone setting from BIOS that was set by manufacturer.
This patch adds 2 new iotrl: RTC_RD_GMTOFF and RTC_SET_GMTOFF to rtc_efi support get/set gmt offset that mapping to the GUN's tm_gmtoff extension (Seconds east of UTC).
Due the timezone definition of UEFI is "Localtime = UTC - TimeZone", rtc_efi driver will transfer the format between GNU and EFI.
The logic of timezone only affect on x86 architecture and keep the original EFI_UNSPECIFIED_TIMEZONE value on IA64.
--- drivers/rtc/rtc-efi.c | 100 ++++++++++++++++++++++++++++++++++++++++++++++++- 1 files changed, 99 insertions(+), 1 deletions(-)
drivers/rtc/rtc-efi.c +99 -1
@@ -75,7 +75,10 @@ convert_to_efi_time(struct rtc_time *wtime, efi_time_t *eft) eft->second = wtime->tm_sec; eft->nanosecond =0 ; eft->daylight = wtime->tm_isdst ?EFI_ISDST :0 ; +#ifdef CONFIG_IA64 +/* avoid overwrite timezone on non-IA64 platform. e.g. x86_64 */ eft->timezone =EFI_UNSPECIFIED_TIMEZONE ; +#endif } static void
@@ -108,6 +111,84 @@ convert_from_efi_time(efi_time_t *eft, struct rtc_time *wtime) } } +static int efi_read_gmtoff (struct device *dev,long int *arg) +{ +efi_status_t status; +efi_time_t eft; +efi_time_cap_t cap; +s16 timezone; + + status = efi.get_time (&eft, &cap); + +if (status !=EFI_SUCCESS ) { +/* should never happen */ +pr_err ("efitime: can't read time\n" ); +return -EINVAL ; + } + + timezone = (s16 )le16_to_cpu (eft.timezone); + *arg =EFI_UNSPECIFIED_TIMEZONE *60 ; +if (abs (timezone) !=EFI_UNSPECIFIED_TIMEZONE && +abs (timezone) <=1440 ) + *arg = timezone *60 *-1 ; + +return 0 ; +} + +static int efi_set_gmtoff (struct device *dev,long int arg) +{ +efi_status_t status; +efi_time_t eft; +efi_time_cap_t cap; +s16 timezone; + +/* transfer seconds east of UTC to minutes for ACPI */ + timezone = arg /60 *-1 ; +if (abs (timezone) >1440 && +abs (timezone) !=EFI_UNSPECIFIED_TIMEZONE ) +return -EINVAL ; + +/* can not use -2047 */ +if (timezone ==EFI_UNSPECIFIED_TIMEZONE *-1 ) + timezone =EFI_UNSPECIFIED_TIMEZONE ; + + status = efi.get_time (&eft, &cap); + +if (status !=EFI_SUCCESS ) { +pr_err ("efitime: can't read time\n" ); +return -EINVAL ; + } + + eft.timezone = (s16 )cpu_to_le16 (timezone); + status = efi.set_time (&eft); +if (status !=EFI_SUCCESS ) { +pr_err ("efitime: can't set timezone\n" ); +return -EINVAL ; + } + +return 0 ; +} + +static int efi_rtc_ioctl (struct device *dev,unsigned int cmd,unsigned long arg) +{ +long int gmtoff; +int err; + +switch (cmd) { +case RTC_RD_GMTOFF : + err =efi_read_gmtoff (dev, &gmtoff); +if (err) +return err; +return put_user (gmtoff, (unsigned long __user *)arg); +case RTC_SET_GMTOFF : +return efi_set_gmtoff (dev, arg); +default : +return -ENOIOCTLCMD ; + } + +return 0 ; +} +static int efi_read_alarm (struct device *dev,struct rtc_wkalrm *wkalrm) {efi_time_t eft;
@@ -172,6 +253,17 @@ static int efi_set_time(struct device *dev, struct rtc_time *tm) {efi_status_t status;efi_time_t eft; +#ifdef CONFIG_X86 +efi_time_cap_t cap; + +/* read time for grab timezone to avoid overwrite it */ + status = efi.get_time (&eft, &cap); + +if (status !=EFI_SUCCESS ) { +pr_err ("efitime: can't read time\n" ); +return -EINVAL ; + } +#endif convert_to_efi_time (tm, &eft);
@@ -181,13 +273,16 @@ static int efi_set_time(struct device *dev, struct rtc_time *tm) }static const struct rtc_class_ops efi_rtc_ops = { +#ifdef CONFIG_X86 + .ioctl = efi_rtc_ioctl, +#endif .read_time = efi_read_time, .set_time = efi_set_time, .read_alarm = efi_read_alarm, .set_alarm = efi_set_alarm, }; -static int __init efi_rtc_probe (struct platform_device *dev) +static int efi_rtc_probe (struct platform_device *dev) {struct rtc_device *rtc;
@@ -196,6 +291,8 @@ static int __init efi_rtc_probe(struct platform_device *dev)if (IS_ERR (rtc))return PTR_ERR (rtc); + rtc->caps = (RTC_TZ_CAP |RTC_DST_CAP ); +platform_set_drvdata (dev, rtc);return 0 ;
@@ -213,3 +310,4 @@ module_platform_driver_probe(efi_rtc_driver, efi_rtc_probe);MODULE_AUTHOR ("dann frazier <[email protected]>" );MODULE_LICENSE ("GPL" );MODULE_DESCRIPTION ("EFI RTC driver" ); +MODULE_ALIAS ("platform:rtc-efi" );
Signature · 1 line
1.6.4.2
Re: [RFC PATCH 07/14] rtc-efi: add GMTOFF support to rtc_efi
Quoted 3 lines · Chun-Yi
This patch adds 2 new iotrl:
RTC_RD_GMTOFFandRTC_SET_GMTOFFtortc_efisupport get/set gmt offset that mapping to the GUN'stm_gmtoffextension (Seconds east of UTC).
Shouldn't this information also be exported via the rtc-sysfs interface?
Signature · 1 line
Matthew Garrett <[email protected]>
Re: [RFC PATCH 07/14] rtc-efi: add GMTOFF support to rtc_efi
於 五,2013-12-20 於 15:11 +0000,Matthew Garrett 提到:
Quoted 7 lines · Chun-Yi
Quoted 3 lines
This patch adds 2 new iotrl:
RTC_RD_GMTOFFandRTC_SET_GMTOFFtortc_efisupport get/set gmt offset that mapping to the GUN'stm_gmtoffextension (Seconds east of UTC).Shouldn't this information also be exported via the rtc-sysfs interface?
Thanks for your suggestion, I will also export it to rtc-sysfs.
Joey Lee
RFC PATCH 8/14 rtc-efi: set uie_unsupported for indicate rtc-efi doesn't support UIE mode
In reply to Lee, Chun-YiThis patch set uie_unsupported flag when driver probed because current rtc-efi driver doesn't support UIE mode. Otherwise RTC_UIE_ON ioctl doesn't return EINVAL and it causes userspace think the RTC_UIE supported by rtc-efi.
Set uie_unsupported then We can enable CONFIG_RTC_INTF_DEV_UIE_EMUL to emulate RTC_UIE on rtc-efi.
--- drivers/rtc/rtc-efi.c | 2 ++ 1 files changed, 2 insertions(+), 0 deletions(-)
drivers/rtc/rtc-efi.c +2 -0
@@ -293,6 +293,8 @@ static int efi_rtc_probe(struct platform_device *dev) rtc->caps = (RTC_TZ_CAP |RTC_DST_CAP ); + rtc->uie_unsupported =1 ; +platform_set_drvdata (dev, rtc);return 0 ;
Signature · 1 line
1.6.4.2
RFC PATCH 9/14 efi: move functions of access efi time to header file for sharing
In reply to Lee, Chun-YiThere have some functions, e.g. compute_yday, compute_wday, convert efi time... are duplicated in efirtc, rtc-efi and will also used in rtc.c. So this patch moved those functions of access efi time to efi.h header file for sharing.
--- drivers/char/efirtc.c | 98 ------------------------------------ drivers/rtc/rtc-efi.c | 133 ++---------------------------------------------- include/linux/efi.h | 134 +++++++++++++++++++++++++++++++++++++++++++++++++ 3 files changed, 140 insertions(+), 225 deletions(-)
drivers/char/efirtc.c +0 -98
@@ -41,109 +41,11 @@#define EFI_RTC_VERSION "0.4" -#define EFI_ISDST (EFI_TIME_ADJUST_DAYLIGHT|EFI_TIME_IN_DAYLIGHT) -/* -* EFI Epoch is 1/1/1998 -*/ -#define EFI_RTC_EPOCH 1998 -static DEFINE_SPINLOCK (efi_rtc_lock);static long efi_rtc_ioctl (struct file *file,unsigned int cmd,unsigned long arg); -#define is_leap (year) \ - ((year) % 4 == 0 && ((year) % 100 != 0 || (year) % 400 == 0)) - -static const unsigned short int __mon_yday[2 ][13 ] = -{ -/* Normal years. */ - {0 ,31 ,59 ,90 ,120 ,151 ,181 ,212 ,243 ,273 ,304 ,334 ,365 }, -/* Leap years. */ - {0 ,31 ,60 ,91 ,121 ,152 ,182 ,213 ,244 ,274 ,305 ,335 ,366 } -}; - -/* -* returns day of the year [0-365] -*/ -static inline int -compute_yday (efi_time_t *eft) -{ -/* efi_time_t.month is in the [1-12] so, we need -1 */ -return __mon_yday[is_leap (eft->year)][eft->month-1 ]+ eft->day -1 ; -} -/* -* returns day of the week [0-6] 0=Sunday -* -* Don't try to provide a year that's before 1998, please ! -*/ -static int -compute_wday (efi_time_t *eft) -{ -int y; -int ndays =0 ; - -if ( eft->year <1998 ) { -printk (KERN_ERR "efirtc: EFI year < 1998, invalid date\n" ); -return -1 ; - } - -for (y=EFI_RTC_EPOCH ; y < eft->year; y++ ) { - ndays +=365 + (is_leap (y) ?1 :0 ); - } - ndays +=compute_yday (eft); - -/* -* 4=1/1/1998 was a Thursday -*/ -return (ndays +4 ) %7 ; -} - -static void -convert_to_efi_time (struct rtc_time *wtime,efi_time_t *eft) -{ - - eft->year = wtime->tm_year +1900 ; - eft->month = wtime->tm_mon +1 ; - eft->day = wtime->tm_mday; - eft->hour = wtime->tm_hour; - eft->minute = wtime->tm_min; - eft->second = wtime->tm_sec; - eft->nanosecond =0 ; - eft->daylight = wtime->tm_isdst ?EFI_ISDST :0 ; - eft->timezone =EFI_UNSPECIFIED_TIMEZONE ; -} - -static void -convert_from_efi_time (efi_time_t *eft,struct rtc_time *wtime) -{ -memset (wtime,0 ,sizeof (*wtime)); - wtime->tm_sec = eft->second; - wtime->tm_min = eft->minute; - wtime->tm_hour = eft->hour; - wtime->tm_mday = eft->day; - wtime->tm_mon = eft->month -1 ; - wtime->tm_year = eft->year -1900 ; - -/* day of the week [0-6], Sunday=0 */ - wtime->tm_wday =compute_wday (eft); - -/* day in the year [1-365]*/ - wtime->tm_yday =compute_yday (eft); - - -switch (eft->daylight &EFI_ISDST ) { -case EFI_ISDST : - wtime->tm_isdst =1 ; -break ; -case EFI_TIME_ADJUST_DAYLIGHT : - wtime->tm_isdst =0 ; -break ; -default : - wtime->tm_isdst =-1 ; - } -} -static long efi_rtc_ioctl (struct file *file,unsigned int cmd,unsigned long arg) {
drivers/rtc/rtc-efi.c +6 -127
155 lines not on this page · raw message
include/linux/efi.h +134 -0
152 lines not on this page · raw message
Signature · 1 line
1.6.4.2
RFC PATCH 10/14 rtc: improve and move week day computing function to rtc header
In reply to Lee, Chun-YiDue to rtc-acpid and efi time used the same logic for computing week day, so this patch moves code to rtc.h header file.
Additionally using a leap year algorithm to replace the for-loop block in compute_wday for improve the performance. The first version of algorithm is from Oliver Neukum.
--- drivers/rtc/rtc-acpitad.c | 13 +------------ include/linux/efi.h | 13 +------------ include/linux/rtc.h | 38 ++++++++++++++++++++++++++++++++++++++ 3 files changed, 40 insertions(+), 24 deletions(-)
drivers/rtc/rtc-acpitad.c +1 -12
@@ -32,23 +32,12 @@ compute_yday(struct acpi_time *acpit)static int compute_wday (struct acpi_time *acpit) { -int y; -int ndays =0 ; -if (acpit->year <1900 ) {pr_err ("ACPI year < 1900, invalid date\n" );return -1 ; } -for (y =1900 ; y < acpit->year; y++) - ndays +=365 + (is_leap_year (y) ?1 :0 ); - - ndays +=compute_yday (acpit); - -/* -* 1=1/1/1900 was a Monday -*/ -return (ndays +1 ) %7 ; +return rtc_wday (acpit->day, acpit->month -1 , acpit->year); } static void
include/linux/efi.h +1 -12
@@ -177,23 +177,12 @@ compute_yday(efi_time_t *eft)static inline int compute_wday (efi_time_t *eft) { -int y; -int ndays =0 ; -if (eft->year <1998 ) {pr_err ("EFI year < 1998, invalid date\n" );return -1 ; } -for (y =EFI_RTC_EPOCH ; y < eft->year; y++) - ndays +=365 + (is_leap_year (y) ?1 :0 ); - - ndays +=compute_yday (eft); - -/* -* 4=1/1/1998 was a Thursday -*/ -return (ndays +4 ) %7 ; +return rtc_wday (eft->day, eft->month -1 , eft->year); } static inline void
include/linux/rtc.h +38 -0
@@ -196,6 +196,44 @@ static inline bool is_leap_year(unsigned int year)return (!(year %4 ) && (year %100 )) || !(year %400 ); } +#define SINCE1900 25/* valid from 2000 */ + +static inline int rtc_wday (unsigned int day,unsigned int month,unsigned int year) +{ +int ndays, correction; +int base; + +if (year <1900 ) { +pr_err ("rtc: year < 1900, invalid date\n" ); +return -1 ; + } + +if (year >=2000 ) + base = year -2000 ; +else + base = year -1900 ; + + correction =0 ; +if (base >=0 ) { + correction += base /4 ; + correction -= base /100 ; + correction += base /400 ; +if (year >=2000 ) + correction +=SINCE1900 ; + +/* later rtc_year_days will add the leap day of current year */ + correction -= ((is_leap_year (year)) ?1 :0 ); + } + + ndays = (year -1900 ) *365 + correction; + ndays +=rtc_year_days (day, month, year); + +/* +* 1=1/1/1900 was a Monday +*/ +return (ndays +1 ) %7 ; +} +#ifdef CONFIG_RTC_HCTOSYS_DEVICE extern int rtc_hctosys_ret;#else
Signature · 1 line
1.6.4.2
RFC PATCH 11/14 rtc: switch to get/set rtc time to efi functions if CMOS RTC Not Present git set.
In reply to Lee, Chun-YiWhen CMOS RTC Not Present git set in FADT, system should not access CMOS interface for time. This patch move get/set rtc time function from CMOS to EFI runtime on x86_64 machine. And, it also set the BUG_ON check in rtc_cmos_read/write function to avoid access it.
--- arch/x86/kernel/rtc.c | 8 ++++++++ include/asm-generic/rtc.h | 22 ++++++++++++++++++++++ 2 files changed, 30 insertions(+), 0 deletions(-)
arch/x86/kernel/rtc.c +8 -0
@@ -117,6 +117,10 @@ unsigned char rtc_cmos_read(unsigned char addr) {unsigned char val; +BUG_ON (acpi_gbl_FADT.header.revision >=5 && + acpi_gbl_FADT.boot_flags &ACPI_FADT_NO_CMOS_RTC && + addr <=RTC_YEAR ); +lock_cmos_prefix (addr);outb (addr,RTC_PORT (0 )); val =inb (RTC_PORT (1 ));
@@ -128,6 +132,10 @@ EXPORT_SYMBOL(rtc_cmos_read);void rtc_cmos_write (unsigned char val,unsigned char addr) { +BUG_ON (acpi_gbl_FADT.header.revision >=5 && + acpi_gbl_FADT.boot_flags &ACPI_FADT_NO_CMOS_RTC && + addr <=RTC_YEAR ); +lock_cmos_prefix (addr);outb (addr,RTC_PORT (0 ));outb (val,RTC_PORT (1 ));
include/asm-generic/rtc.h +22 -0
@@ -16,6 +16,8 @@#include <linux/rtc.h> #include <linux/bcd.h> #include <linux/delay.h> +#include <linux/efi.h> +#include <linux/acpi.h> #define RTC_PIE 0x40/* periodic interrupt enable */ #define RTC_AIE 0x20/* alarm interrupt enable */
@@ -51,6 +53,16 @@ static inline unsigned int __get_rtc_time(struct rtc_time *time)unsigned int real_year;#endif +if (acpi_gbl_FADT.header.revision >=5 && + acpi_gbl_FADT.boot_flags &ACPI_FADT_NO_CMOS_RTC ) { +#if defined(CONFIG_EFI ) && defined(CONFIG_X86_64 ) +printk_once (KERN_INFO "efi: get rtc time by EFI\n" ); +return efi_read_time (time); +#else +BUG (); +#endif + } +/* * read RTC once any update in progress is done. The update * can take just over 2ms. We wait 20ms. There is no need to
@@ -123,6 +135,16 @@ static inline int __set_rtc_time(struct rtc_time *time)unsigned int real_yrs, leap_yr;#endif +if (acpi_gbl_FADT.header.revision >=5 && + acpi_gbl_FADT.boot_flags &ACPI_FADT_NO_CMOS_RTC ) { +#if defined(CONFIG_EFI ) && defined(CONFIG_X86_64 ) +printk_once (KERN_INFO "efi: set rtc time by EFI\n" ); +return efi_set_time (time); +#else +BUG (); +#endif + } + yrs = time->tm_year; mon = time->tm_mon +1 ;/* tm_mon starts at zero */ day = time->tm_mday;
Signature · 1 line
1.6.4.2
RFC PATCH 12/14 efi: adjust system time base on timezone from EFI time services
In reply to Lee, Chun-YiEFI time services provide the interface to store timezone to BIOS. The timezone value from EFI indicates the offset of RTC time in minutes from UTC.
The formula is: Localtime = UTC - TimeZone.
This patch add a efI_warp_clock() function to initial process for adjust system time base on timezone value from EFI time services. It will also set persistent_clock_is_local global variable to avoid user space adjust timezone again.
This efi warp clock mechanism will triggered on x86_64 EFI machine when timezone value is neither 0 nor 2047(UNSPECIFIED), kernel assume the value of RTC is local time. On the other hand, system just follow the old logic when timezone value from EFI is 0 or 2047, kernel assume the value of RTC is UTC time.
About the 2047(EFI_UNSPECIFIED_TIMEZONE) value, it's the default value of UEFI BIOS if there didn't have software set it through EFI interface. We can _NOT_ follow EFI spec to interpret the RTC time as a local time if timezone value is EFI_UNSPECIFIED_TIMEZONE, that's because Linux stored UTC to BIOS on shipped UEFI machines.
--- arch/x86/platform/efi/efi.c | 37 +++++++++++++++++++++++++++++++++++++ include/linux/efi.h | 2 ++ init/main.c | 5 +++++ kernel/time.c | 2 +- 4 files changed, 45 insertions(+), 1 deletions(-)
arch/x86/platform/efi/efi.c +37 -0
@@ -306,6 +306,43 @@ static void efi_get_time(struct timespec *now) now->tv_nsec =0 ; } +static int efi_read_timezone (s16 *timezone) +{ +efi_status_t status; +efi_time_t eft; +efi_time_cap_t cap; + + status = efi.get_time (&eft, &cap); + +if (status !=EFI_SUCCESS ) { +/* should never happen */ +pr_err ("efitime: can't read timezone.\n" ); +return -EINVAL ; + } + + *timezone = (s16 )le16_to_cpu (eft.timezone); +return 0 ; +} + +void __init efi_warp_clock (void ) +{ +s16 timezone; + +if (!efi_read_timezone (&timezone)) { +/* TimeZone value, 2047 or 0 means UTC */ +if (timezone !=0 && timezone !=2047 ) { +struct timespec adjust; + + persistent_clock_is_local =1 ; + adjust.tv_sec = timezone *60 ; + adjust.tv_nsec =0 ; +timekeeping_inject_offset (&adjust); +pr_info ("RTC timezone is %d mins behind of UTC.\n" , timezone); +pr_info ("Adjusted system time to UTC.\n" ); + } + } +} +/* * Tell the kernel about the EFI memory map. This might include * more than the max 128 entries that can fit in the e820 legacy
include/linux/efi.h +2 -0
@@ -715,10 +715,12 @@ extern void efi_memmap_walk (efi_freemem_callback_t callback, void *arg);extern void efi_gettimeofday (struct timespec *ts);extern void efi_enter_virtual_mode (void );/* switch EFI to virtual mode, if possible */ #ifdef CONFIG_X86 +extern void efi_warp_clock (void );extern void efi_late_init (void );extern void efi_free_boot_services (void );extern efi_status_t efi_query_variable_store (u32 attributes,unsigned long size);#else +static inline void efi_warp_clock (void ) {}static inline void efi_late_init (void ) {}static inline void efi_free_boot_services (void ) {}
init/main.c +5 -0
@@ -570,6 +570,11 @@ asmlinkage void __init start_kernel(void)hrtimers_init ();softirq_init ();timekeeping_init (); +#ifdef CONFIG_X86_64 +/* adjust system time by timezone */ +if (efi_enabled (EFI_RUNTIME_SERVICES )) +efi_warp_clock (); +#endif time_init ();sched_clock_postinit ();perf_event_init ();
kernel/time.c +1 -1
@@ -176,7 +176,7 @@ int do_sys_settimeofday(const struct timespec *tv, const struct timezone *tz)update_vsyscall_tz ();if (firsttime) { firsttime =0 ; -if (!tv) +if (!tv && !persistent_clock_is_local)warp_clock (); } }
Signature · 1 line
1.6.4.2
RFC PATCH 13/14 Documentation/RTC: add document of ACPI TAD and EFI TIME driver
In reply to Lee, Chun-YiThis patch add rtc-tz.txt document to explain the RTC driver of ACPI TAD, EFI TIME. It focus on the timezone field and CMOS RTC Not Present bit of ACPI 5.0.
--- Documentation/rtc-tz.txt | 510 ++++++++++++++++++++++++++++++++++++++++++++++ 1 files changed, 510 insertions(+), 0 deletions(-) create mode 100644 Documentation/rtc-tz.txt
Documentation/rtc-tz.txt new file +510 -0
@@ -0,0 +1,510 @@ + + ACPI TAD and EFI TIME Drivers for Timezone and Daylight + ======================================================= + +In ACPI 5.0 ACPI TAD (Time and Alram Device) and EFI, they defined +Timezone and Daylight field in time struct: + + * ACPI TAD ... INT16 TimeZone + -1440 to 1440 or 2047 (unspecified) + Time zone field is the number of minutes that + the local time lags behind the UTC time. + Follow this equation: Localtime = UTC - TimeZone + UINT8 Daylight + Daylight is a bitmask containing the daylight + savings time information for the time: + Bit0: 1 = the time is affected by daylight savings time, + 0= time is not affected by daylight savings. + Bit1: 1= the time has been adjusted for daylight savings time, + 0= the time hasn't been adjusted for daylight savings. + + * EFI TIME ... INT16 TimeZone + -1440 to 1440 or 2047 (unspecified) + Time zone field is the number of minutes that + the local time lags behind the UTC time. + Follow this equation: Localtime = UTC - TimeZone + UINT8 Daylight + EFI_TIME_ADJUST_DAYLIGHT 0x01 + indicates if the time is affected by daylight + savings time or not. + EFI_TIME_IN_DAYLIGHT 0x02 + is set, the time has been adjusted for daylight + savings time. + +Then, the Timzone and daylight definition in GNU struct tm: + + * GNU struct tm ... long int __tm_gmtoff; /* Seconds east of UTC. */ + int tm_isdst; /* DST. [-1/0/1]*/ + +For Timzone, the definition match between ACPI TAD and EFI TIME. But it +different with GNU time struct. GNU's tm_gmtoff is "Seconds east of UTC". +Simply say, the timzone of ACPI/EFI and GNU are sign difference. + +Example 1: + 'Asia/Taipei' UTC +8 + GNU: tm_gmtoff = 28800 seconds. + Taiwan is east of UTC, so it's positive number. + ACPI or EFI: TimeZone = -480 hours + Timezone = UTC - Localtime = UTC - Taipei time + So, it's negative number. +Example 2: + 'Americ/Los_Angeles' UTC -8 + GNU: tm_gmtoff = -28800 seconds. + Los Angeles is west of UTC, so it's negative number. + ACPI or EFI: TimeZone = 480 hours + Timezone = UTC - Localtime = UTC - Taipei time + So, it's positive number. + +For Daylight, due to GNU's tm_isdst is only define: '1' means current +time is in daylight savings. '0' means not. '-1' means non-available. +So, 1b is the only value from ACPI/EFI will transfer to '1' in GNU. +When ACPI or EFI value is: + + * 11b: Time is affected by daylight and has been adjusted for daylight + tm->tm_isdst = 1 + * 01b: Time is affected by daylight but hasn't been adjusted for daylight + tm->tm_isdst = 0 + * 00b(or 10b): Time is affected by daylight + tm->tm_isdst = -1 + +The above data tranfer work of Timezone and Daylight will handled by RTC driver +to ACPI TAD and EFI TIME: rtc-acpitad and rtc-efi. + +SYSFS INTERFACE +--------------- + +The sysfs interface under /sys/class/rtc/rtcN provides access to various +rtc attributes without requiring the use of ioctls. Here only have one new +sysfs interface for grab the capabilities: + +caps: This interface will return a bitmap of capabilitites to the RTC + interface. Currently it indicates the RTC has capability for + handle Timezone or Daylight: + Bit0: Timezone. Set this bit means this interface has + capability to store Timezone + Bit1: Daylight: Set this bit means this interface has + capability to store Daylight savings time. + There already have the following definition in linux/rtc.h: + #define RTC_TZ_CAP (1 << 0) + #define RTC_DST_CAP (1 << 1) + +IOCTL INTERFACE +--------------- + +Here create 3 new ioctl functions for read/set timezone and read the +capabilities of RTC interface. + + * RTC_RD_GMTOFF, RTC_SET_GMTOFF ... Used to read and set timezone value. + Due to support the GNU tm_gmtoff format, so the input/output value + is "Seconds east of UTC". RTC drivers, rtc-acpitad and rtc-efi, done + the data transfer work. + The rtc-acpitad and rtc-efi driver also avoid to overwrite the timezone + field in their time struct in RTC_SET_TIME. + + * RTC_CAPS_READ ... As the caps sysfs interface, this ioctl provides + interface to userspace application for grab capabilities of current + RTC interface. Application can early check does this interface support + Timezone or Daylight. + +CMOS RTC Not Present flag +------------------------- + +ACPI 5.0 spec defines a "CMOS RTC Not Present" flag in IA-PC Boot +Architecture Flags of FADT. If this bit set, that means OSPM need uses the +ACPI Time and Alarm device instead. Software should not access RTC through +CMOS interface. + +In Linux kernel, the defaul wallclock functions deal with RTC by CMOS, it +should move to ACPI TAD or EFI Time servcies. ACPI Time and Alarm device is +described in DSDT that need wait until DSDT parsed by kernel in subsystem +initial stage, so it can not used to deal with wallclock when system boot. + +Current solution of "CMOS RTC Not Present" is switch to EFI time services. +On x86_64 EFI machine kernel will deal with RTC by EFI time services. In +initial process, system time will adjusted base on timezone value from EFI +time services, it also set persistent_clock_is_local global variable to +avoid user space adjust system time by userland timezone again. + +The above efi warp clock mechanism will triggered on x86_64 EFI machine when +timezone value is neither 0 nor 2047(UNSPECIFIED), kernel assume the value +of RTC is local time. On the other hand, system just follow the old logic +when timezone value from EFI is 0 or 2047, kernel assume the value of RTC is +UTC time. + +About the 2047(EFI_UNSPECIFIED_TIMEZONE) value, it's the default value of +UEFI BIOS if there didn't have any software set it through EFI interface. +We can _NOT_ follow EFI spec to interpret the RTC time as a local time if +timezone value is EFI_UNSPECIFIED_TIMEZONE, that's because Linux stored +UTC to BIOS on shipped UEFI machines. + + +-------------------- 8< ---------------- 8< ----------------------------- + +/* + * Timezone of ACPI/EFI RTC Driver Test Program + * + * Compile with: + * gcc rtc-tz-test.c -o rtc-tz-test + * + * Copyright (C) 2013 SUSE Linux Products GmbH. All rights reserved. + * Written by Lee, Chun-Yi ([email protected]) + * + * This program is free software; you can redistribute it and/or + * modify it under the terms of the GNU General Public Licence + * as published by the Free Software Foundation; either version + * 2 of the Licence, or (at your option) any later version. + */ +#include <stdio.h> +#include <string.h> +#include <fcntl.h> +#include <sys/ioctl.h> +#include <linux/rtc.h> + +#ifndef RTC_RD_GMTOFF +#define RTC_RD_GMTOFF _IOR('p', 0x13, long int) /* Read time zone return seconds east of UTC */ +#define RTC_SET_GMTOFF _IOW('p', 0x14, long int) /* Set time zone input seconds east of UTC */ +#endif +#ifndef RTC_CAPS_READ +#define RTC_CAPS_READ _IOR('p', 0x15, unsigned int) /* Get capabilities, e.g. TZ, DST */ +#endif +/* Time Zone and Daylight capabilities */ +#ifndef RTC_TZ_CAP +#define RTC_TZ_CAP (1 << 0) +#define RTC_DST_CAP (1 << 1) +#endif + +#define MAX_DEV 5 +#define ADJUST_MIN 60 +#define DEFAULT_TZ 28800 /* GMT offset of Taiwan R.O.C (Seconds east of UTC)*/ +#define ADJUST_TZ -28800 /* GMT offset of Los Angeles (Seconds east of UTC) */ + +static const char dev_path[] = "/dev/rtc"; +static const char sys_path[] = "/sys/class/rtc/rtc"; + +static const struct { + const char *driver_name; + const char *name; +} names[] = { + {"rtc_cmos", "CMOS"}, + {"rtc-efi", "EFI"}, + {"rtc-acpitad", "ACPI-TAD"}, +}; + +struct rtc_dev { + char dev_path[10]; + char sys_path[21]; + char name[15]; + char driver_name[15]; + unsigned int caps; +}; + +struct rtc_dev rtc_devs[5]; + +void search_rtc_dev(void) +{ + int i, j, fd, ret; + FILE *fin; + + for (i = 0; i <= MAX_DEV; i++) + { + char path_tmp[30]; + sprintf(path_tmp, "%s%d", dev_path, i); + + fd = open(path_tmp, O_RDONLY); + if (fd != -1) { + struct rtc_dev *dev = &rtc_devs[i]; + + memcpy(dev->dev_path, path_tmp, 10); + sprintf(dev->sys_path, "%s%d/", sys_path, i); + + sprintf(path_tmp, "%s%s", dev->sys_path, "name"); + if ((fin = fopen(path_tmp, "r")) != NULL) + fscanf(fin, "%s", dev->driver_name); + fclose(fin); + + for (j = 0; j < sizeof(names)/sizeof(names[0]); j++) { + if (!strcmp(dev->driver_name, names[j].driver_name)) + memcpy(dev->name, names[j].name, strlen(names[j].name)); + } + + ioctl(fd, RTC_CAPS_READ, &dev->caps); + close(fd); + } + } +} + +void print_rtc_dev(struct rtc_dev *dev) +{ + long int gmtoff; + struct rtc_time rtc_tm; + int fd, ret; + + fd = open(dev->dev_path, O_RDONLY); + + printf("Name: %s(%s)\n", dev->name, dev->driver_name); + printf(" Device Path: %s\n", dev->dev_path); + printf(" Sysfs Path : %s\n", dev->sys_path); + + /* Read the RTC time/date */ + ret = ioctl(fd, RTC_RD_TIME, &rtc_tm); + if (ret == -1) + perror("RTC_RD_TIME ioctl"); + + printf(" RTC date/time: %d-%d-%d %02d:%02d:%02d\n", + rtc_tm.tm_mday, rtc_tm.tm_mon + 1, rtc_tm.tm_year + 1900, + rtc_tm.tm_hour, rtc_tm.tm_min, rtc_tm.tm_sec); + printf(" Is Daylight: %d (%s)\n", rtc_tm.tm_isdst, + (rtc_tm.tm_isdst)? (rtc_tm.tm_isdst < 0)? "NOT AVAILABLE":"INEFFECT":"NOT IN EFFECT"); + + printf(" Capabilities: %d (%s %s)\n", dev->caps, + (dev->caps & RTC_TZ_CAP)? "TZ":"", + (dev->caps & RTC_DST_CAP)? "DST":""); + + /* Read the GMTOFF (Seconds east of UTC) */ + ret = ioctl(fd, RTC_RD_GMTOFF, &gmtoff); + if (ret == -1) + printf(" GMTOFF: not support\n"); + else + printf(" GMTOFF: %ld TIMEZONE: %d\n", gmtoff, gmtoff / 60 * -1); + + close(fd); + printf("\n"); +} + +void print_rtc_devs(void) +{ + int i; + + for (i = 0; i <= MAX_DEV; i++) { + if(strlen(rtc_devs[i].sys_path)) + print_rtc_dev(&rtc_devs[i]); + } +} + +void print_rtc_dev_time(struct rtc_dev *dev) +{ + long int gmtoff; + struct rtc_time rtc_tm; + int fd, ret; + + fd = open(dev->dev_path, O_RDONLY); + + /* Read the RTC time/date */ + ret = ioctl(fd, RTC_RD_TIME, &rtc_tm); + if (ret == -1) + perror("RTC_RD_TIME ioctl"); + + printf(" %s: %d-%d-%d %02d:%02d:%02d\n", dev->name, + rtc_tm.tm_mday, rtc_tm.tm_mon + 1, rtc_tm.tm_year + 1900, + rtc_tm.tm_hour, rtc_tm.tm_min, rtc_tm.tm_sec); + + close(fd); +} + +void print_rtc_devs_time(void) +{ + int i; + + for (i = 0; i <= MAX_DEV; i++) { + if(strlen(rtc_devs[i].sys_path)) + print_rtc_dev_time(&rtc_devs[i]); + } +} + +void time_increase(struct rtc_dev *dev, int in_min) +{ + struct rtc_time rtc_tm; + int fd, ret; + + fd = open(dev->dev_path, O_RDONLY); + + /* Read the RTC time/date */ + ret = ioctl(fd, RTC_RD_TIME, &rtc_tm); + if (ret == -1) + perror("RTC_RD_TIME ioctl"); + + /* Increase minutes */ + rtc_tm.tm_min += in_min; + if (rtc_tm.tm_min >= 60) { + rtc_tm.tm_hour += (rtc_tm.tm_min / 60); + rtc_tm.tm_min %= 60; + if (rtc_tm.tm_hour >= 24) { + rtc_tm.tm_mday += (rtc_tm.tm_hour / 24); + rtc_tm.tm_hour %= 24; + } + /* Yes, it's not perfect, only adjust to mday level for testing */ + } + + /* Set increased time */ + ret = ioctl(fd, RTC_SET_TIME, &rtc_tm); + if (ret == -1) + perror("RTC_SET_TIME ioctl"); + + close(fd); +} + +void time_decrease(struct rtc_dev *dev, int in_min) +{ + struct rtc_time rtc_tm; + int fd, ret; + + fd = open(dev->dev_path, O_RDONLY); + + /* Read the RTC time/date */ + ret = ioctl(fd, RTC_RD_TIME, &rtc_tm); + if (ret == -1) + perror("RTC_RD_TIME ioctl"); + + /* Increase minutes */ + if ((rtc_tm.tm_min - in_min) < 0) { + rtc_tm.tm_hour -= (in_min / 60); + rtc_tm.tm_min -= in_min % 60; + if (rtc_tm.tm_hour < 0) { + rtc_tm.tm_mday += (rtc_tm.tm_hour / 24); + rtc_tm.tm_hour = (rtc_tm.tm_hour % 24) * -1; + } + /* Yes, it's not perfect, only adjust to mday level for testing */ + } + + ret = ioctl(fd, RTC_SET_TIME, &rtc_tm); + if (ret == -1) + perror("RTC_SET_TIME ioctl"); + + close(fd); +} + +void set_rtc_time_test(void) +{ + int i; + + for (i = 0; i <= MAX_DEV; i++) { + struct rtc_dev *dev = &rtc_devs[i]; + + if(strlen(dev->sys_path) && + dev->caps & RTC_TZ_CAP) { + printf("Test Target: %s(%s)\n", dev->name, dev->driver_name); + + printf(" Before Increase\n"); + print_rtc_devs_time(); + time_increase(dev, ADJUST_MIN); + printf(" After Increased %d minutes\n", ADJUST_MIN); + print_rtc_devs_time(); + printf(" Before Decrease\n"); + print_rtc_devs_time(); + time_decrease(dev, ADJUST_MIN); + printf(" After Decreased %d minutes\n", ADJUST_MIN); + print_rtc_devs_time(); + + printf("\n\n"); + } + } +} + +void print_rtc_dev_tz(struct rtc_dev *dev) +{ + long int gmtoff; + struct rtc_time rtc_tm; + int fd, ret; + + fd = open(dev->dev_path, O_RDONLY); + + /* Read the GMTOFF (Seconds east of UTC) */ + ret = ioctl(fd, RTC_RD_GMTOFF, &gmtoff); + if (ret == -1) + printf(" %s(%s): not support\n", dev->name, dev->driver_name); + else + printf(" %s(%s): GMTOFF: %ld TIMEZONE: %d\n", dev->name, dev->driver_name, gmtoff, gmtoff / 60 * -1); + + close(fd); +} + +void print_rtc_devs_tz() +{ + int i; + + for (i = 0; i <= MAX_DEV; i++) { + if(strlen(rtc_devs[i].sys_path)) + print_rtc_dev_tz(&rtc_devs[i]); + } +} + +long int change_gmtoff(struct rtc_dev *dev, long int gmtoff_in) +{ + long int gmtoff = 122820; + struct rtc_time rtc_tm; + int fd, ret; + + fd = open(dev->dev_path, O_RDONLY); + + /* Read the GMTOFF (Seconds east of UTC) */ + ret = ioctl(fd, RTC_RD_GMTOFF, &gmtoff); + if (ret == -1) { + printf("RTC_RD_GMTOFF fail.\n"); + goto read_err; + } + + ret = ioctl(fd, RTC_SET_GMTOFF, gmtoff_in); + if (ret == -1) + printf("RTC_SET_GMTOFF fail.\n"); + +read_err: + close(fd); + + return gmtoff; +} + +void access_gmtoff_test(void) +{ + int i; + + for (i = 0; i <= MAX_DEV; i++) { + struct rtc_dev *dev = &rtc_devs[i]; + + if(strlen(dev->sys_path) && + dev->caps & RTC_TZ_CAP) { + long int orig_tz; + + printf("Test Target: %s(%s)\n", dev->name, dev->driver_name); + printf("Set to Default TZ: %ld\n", DEFAULT_TZ); + change_gmtoff(dev, DEFAULT_TZ); + + printf(" Before Adjust TZ\n"); + print_rtc_devs_tz(); + orig_tz = change_gmtoff(dev, ADJUST_TZ); + printf(" After Adjusted TZ\n"); + print_rtc_devs_tz(); + orig_tz = change_gmtoff(dev, orig_tz); + printf(" Adjusted Back\n"); + print_rtc_devs_tz(); + + printf("\n\n"); + } + } +} + +int main(int argc, char **argv) +{ + search_rtc_dev(); + printf("\nThis testing program will access following ioctl interface:\n"); + printf(" RTC_RD_TIME/RTC_SET_TIME: Used to read and set RTC value.\n"); + printf(" RTC_RD_GMTOFF/RTC_SET_GMTOFF: Used to read and set timezone, input/output is \"Seconds east of UTC\".\n"); + printf(" RTC_CAPS_READ: Read the Timzone and Daylight capabilities of RTC interface.\n"); + + printf("\n======== Read Time Testing (RTC_RD_TIME/RTC_CAPS_READ) ========\n\n"); + print_rtc_devs(); + + printf("\n======== Set Time Testing (RTC_SET_TIME/RTC_RD_TIME) ========\n"); + printf("Only testing the interface supported Timezone.\n"); + printf("This testing will increase %d minutes of RTC time then decrease it back.\n\n", ADJUST_MIN); + set_rtc_time_test(); + + printf("\n======== Access TimeZone Testing (RTC_RD_GMTOFF/RTC_SET_GMTOFF) ========\n"); + printf("Only testing the interface supported Timezone.\n"); + printf("Timezone of ACPI and UEFI spec: Time zone field is the number of minutes that the local time lags behind the UTC time.\n"); + printf(" -1440 to 1440 or 2047. Localtime = UTC - TimeZone\n"); + printf("Timezone in GNU tm struct: Seconds east of UTC.\n"); + printf("This testing will set time zone to Los Angeles time (-28800 Seconds east of UTC) then set it back.\n\n", ADJUST_MIN); + access_gmtoff_test(); + + return 0; +}
Signature · 1 line
1.6.4.2
PATCH 14/14 acpi: add early parameter to set CMOS RTC Not Present bit for testing
In reply to Lee, Chun-YiThis is a patch for testing that will not go to any git tree.
Add a early kernel parameter to set CMOS RTC Not Present bit in acpi_gbl_FADT variable for testing. Use acpi_no_cmos_rtc=1 to enable this bit to block rtc cmos interface.
--- arch/x86/kernel/acpi/boot.c | 17 +++++++++++++++++ 1 files changed, 17 insertions(+), 0 deletions(-)
arch/x86/kernel/acpi/boot.c +17 -0
@@ -83,6 +83,8 @@ static u64 acpi_lapic_addr __initdata = APIC_DEFAULT_PHYS_BASE;#warning ACPI uses CMPXCHG, i486 and later hardware#endif +static bool acpi_no_cmos_rtc; +/* -------------------------------------------------------------------------- Boot-time Configuration -------------------------------------------------------------------------- */
@@ -1531,6 +1533,13 @@ int __init acpi_boot_init(void)*/ acpi_table_parse (ACPI_SIG_FADT , acpi_parse_fadt); +/* Dummy NO_CMOS_RTC enable option to fake out RTC CMOS */ +if (acpi_no_cmos_rtc) { + acpi_gbl_FADT.header.revision =5 ; + acpi_gbl_FADT.boot_flags |=ACPI_FADT_NO_CMOS_RTC ; +pr_info ("acpi: Set NO_CMOS_RTC bit in FADT for testing\n" ); + } +/* * Process the Multiple APIC Description Table (MADT), if present */
@@ -1673,3 +1682,11 @@ void __init arch_reserve_mem_area(acpi_physical_address addr, size_t size)e820_add_region (addr, size,E820_ACPI );update_e820 (); } + +/* Dummy NO_CMOS_RTC enable option to fake out RTC CMOS */ +static int __init setup_acpi_no_cmos_rtc (char *arg) +{ + acpi_no_cmos_rtc = true; +return 0 ; +} +early_param ("acpi_no_cmos_rtc" , setup_acpi_no_cmos_rtc);
Signature · 1 line
1.6.4.2
A message that is not in the archive (sent off-list or not yet received): [email protected]
Re: [PATCH 02/14] x86-64/efi: Use EFI to deal with platform wall clock (again)
Quoted 46 lines · Chun-Yi
From: Jan Beulich <JBeulich-IBi9RG/[email protected]>
Other than ix86, x86-64 on EFI so far didn't set the {g,s}et_wallclock accessors to the EFI routines, thus incorrectly using raw RTC accesses instead.
Simply removing the #ifdef around the respective code isn't enough, however: While so far early get-time calls were done in physical mode, this doesn't work properly for x86-64, as virtual addresses would still need to be set up for all runtime regions (which wasn't the case on the system I have access to), so instead the patch moves the call to
efi_enter_virtual_mode()ahead (which in turn allows to drop all code related to calling efi-get-time in physical mode).Additionally the earlier calling of
efi_set_executable()requires the CPA code to cope, i.e. during early boot it must be avoided to callcpa_flush_array(), as the first thing this function does is a BUG_ON(irqs_disabled()).Also make the two EFI functions in question here static - they're not being referenced elsewhere.
History:
This commit was originally merged as
bacef661acdb("x86-64/efi:
Use EFI to deal with platform wall clock") but it resulted in some ASUS machines no longer booting due to a firmware bug, and so was reverted inf026cfa82f62.Then a pre-emptive fix for the buggy ASUS firmware was merged in
03a1c254975e("x86, efi: 1:1 pagetable mapping for virtual EFI calls") but it causes odd bootup problems on x86-64. So this patch revoked again by11520e5e7c1.Now Borislav Petkov's "EFI runtime services virtual mapping" is merged to EFI 'next' branch. So this patch can be reapplied again.
Signed-off-by Jan Beulich <jbeulich-IBi9RG/[email protected]>Tested-by Matt Fleming <[email protected]>Acked-by Matthew Garrett <[email protected]>Cc Ingo Molnar <[email protected]>Cc Peter Zijlstra <a.p.zijlstra-/NLkJaSkS4VmR6Xm/[email protected]>Cc H. Peter Anvin <[email protected]>Signed-off-by Matt Fleming <[email protected]> [added commit history]
Quoted 6 lines
--- arch/x86/mm/pageattr.c | 10 ++++++---- arch/x86/platform/efi/efi.c | 35 +++++++++++------------------------ include/linux/efi.h | 2 -- init/main.c | 8 ++++---- 4 files changed, 21 insertions(+), 34 deletions(-)
Lee, you can't just simply resend this patch with all the tags - I haven't tested this version with any recent changes and I'm pretty sure Matthew isn't going to Ack it.
Do you know if anyone has tested this patch with Borislav's recent changes?
Signature · 1 line
Matt Fleming, Intel Open Source Technology Center
Re: [PATCH 02/14] x86-64/efi: Use EFI to deal with platform wall clock (again)
於 四,2013-12-19 於 10:49 +0000,Matt Fleming 提到:
Quoted 54 lines · Chun-Yi
Quoted 46 lines
From: Jan Beulich <JBeulich-IBi9RG/[email protected]>
Other than ix86, x86-64 on EFI so far didn't set the {g,s}et_wallclock accessors to the EFI routines, thus incorrectly using raw RTC accesses instead.
Simply removing the #ifdef around the respective code isn't enough, however: While so far early get-time calls were done in physical mode, this doesn't work properly for x86-64, as virtual addresses would still need to be set up for all runtime regions (which wasn't the case on the system I have access to), so instead the patch moves the call to
efi_enter_virtual_mode()ahead (which in turn allows to drop all code related to calling efi-get-time in physical mode).Additionally the earlier calling of
efi_set_executable()requires the CPA code to cope, i.e. during early boot it must be avoided to callcpa_flush_array(), as the first thing this function does is a BUG_ON(irqs_disabled()).Also make the two EFI functions in question here static - they're not being referenced elsewhere.
History:
This commit was originally merged as
bacef661acdb("x86-64/efi:
Use EFI to deal with platform wall clock") but it resulted in some ASUS machines no longer booting due to a firmware bug, and so was reverted inf026cfa82f62.Then a pre-emptive fix for the buggy ASUS firmware was merged in
03a1c254975e("x86, efi: 1:1 pagetable mapping for virtual EFI calls") but it causes odd bootup problems on x86-64. So this patch revoked again by11520e5e7c1.Now Borislav Petkov's "EFI runtime services virtual mapping" is merged to EFI 'next' branch. So this patch can be reapplied again.
Signed-off-by Jan Beulich <jbeulich-IBi9RG/[email protected]>Tested-by Matt Fleming <[email protected]>Acked-by Matthew Garrett <[email protected]>Cc Ingo Molnar <[email protected]>Cc Peter Zijlstra <a.p.zijlstra-/NLkJaSkS4VmR6Xm/[email protected]>Cc H. Peter Anvin <[email protected]>Signed-off-by Matt Fleming <[email protected]> [added commit history]Quoted 6 lines
--- arch/x86/mm/pageattr.c | 10 ++++++---- arch/x86/platform/efi/efi.c | 35 +++++++++++------------------------ include/linux/efi.h | 2 -- init/main.c | 8 ++++---- 4 files changed, 21 insertions(+), 34 deletions(-)
Quoted 3 lines
Lee, you can't just simply resend this patch with all the tags - I haven't tested this version with any recent changes and I'm pretty sure Matthew isn't going to Ack it.
I am very sorry for I didn't remove those tags before send it. I will remove it when send second version.
Quoted 4 lines
Do you know if anyone has tested this patch with Borislav's recent changes?
I tested Borislav's patch set on a issue BIOS and make sure it works, but I have no chance to test this patch with it. I will find a time to test it.
Thanks a lot!
Joey Lee
Re: [PATCH 02/14] x86-64/efi: Use EFI to deal with platform wall clock (again)
Quoted 7 lines · On Thu, 19 Dec 2013 21:32:19 +0800 joeyli <jlee-IBi9RG/[email protected]>…
於 四,2013-12-19 於 10:49 +0000,Matt Fleming 提到:
Quoted 6 lines · Chun-Yi
Quoted 5 lines
From: Jan Beulich <JBeulich-IBi9RG/[email protected]>
Other than ix86, x86-64 on EFI so far didn't set the {g,s}et_wallclock accessors to the EFI routines, thus incorrectly using raw RTC accesses instead.
Probably wise.
Before anyone reverts that please make sure it also works on EFI32, because right now we crash and burn on multiple EFI32 tablets querying the time.
Alan
H. Peter Anvin
reviewerRe: [PATCH 02/14] x86-64/efi: Use EFI to deal with platform wall clock (again)
Quoted 11 lines · One Thousand Gnomes
Quoted 7 lines · On Thu, 19 Dec 2013 21:32:19 +0800 joeyli <[email protected]> wrote:
於 四,2013-12-19 於 10:49 +0000,Matt Fleming 提到:
Quoted 6 lines · Chun-Yi
Quoted 5 lines
From: Jan Beulich <[email protected]>
Other than ix86, x86-64 on EFI so far didn't set the {g,s}et_wallclock accessors to the EFI routines, thus incorrectly using raw RTC accesses instead.
Quoted 6 lines
Probably wise.
Before anyone reverts that please make sure it also works on EFI32, because right now we crash and burn on multiple EFI32 tablets querying the time.
Quite -- we in fact did just the opposite (checkin 04bf9ba720fc).
-hpa
--
To unsubscribe from this list: send the line "unsubscribe linux-acpi" in the body of a message to [email protected]
More majordomo info at http://vger.kernel.org/majordomo-info.html