[<prev] [next>] [thread-next>] [day] [month] [year] [list]
Message-ID: <20250611062025.3243732-1-wangming01@loongson.cn>
Date: Wed, 11 Jun 2025 14:20:25 +0800
From: Ming Wang <wangming01@...ngson.cn>
To: Alexandre Belloni <alexandre.belloni@...tlin.com>,
linux-rtc@...r.kernel.org,
linux-kernel@...r.kernel.org
Cc: Huacai Chen <chenhuacai@...nel.org>,
lixuefeng@...ngson.cn,
chenhuacai@...ngson.cn,
gaojuxin@...ngson.cn
Subject: [PATCH] rtc: efi: Defer driver initialization to prioritize more capable RTCs
The EFI GetWakeupTime call, used by efi_read_alarm() to fetch RTC
wakeup alarm information, is specified to return EFI_UNSUPPORTED on
EFI firmware v1.10 and later. This effectively means that on most
modern systems, the efi-rtc driver cannot provide working RTC alarm
functionality.
If efi-rtc registers early during boot, it might become the primary
RTC device (e.g., /dev/rtc0). This can lead to a situation where the
system appears to have an RTC, but userspace utilities cannot set or
get RTC alarms, even if other RTC hardware (like rtc-cmos, which
typically supports alarms) is present but registers later.
To address this, change the efi-rtc driver initialization from
module_init() to late_initcall(). By deferring its initialization,
we give other, potentially more capable RTC drivers (such as rtc-cmos)
a better chance to register first and become the primary RTC.
This change increases the likelihood that systems with multiple RTC
sources will use the one with the most complete feature set (including
alarms) as the primary RTC. The efi-rtc driver can still serve as a
time source or a fallback RTC if no other RTC is available or preferred.
Signed-off-by: Ming Wang <wangming01@...ngson.cn>
---
drivers/rtc/rtc-efi.c | 13 ++++++++++++-
1 file changed, 12 insertions(+), 1 deletion(-)
diff --git a/drivers/rtc/rtc-efi.c b/drivers/rtc/rtc-efi.c
index fa8bf82df948..f97a228510f4 100644
--- a/drivers/rtc/rtc-efi.c
+++ b/drivers/rtc/rtc-efi.c
@@ -286,9 +286,20 @@ static struct platform_driver efi_rtc_driver = {
.driver = {
.name = "rtc-efi",
},
+ .probe = efi_rtc_probe,
};
-module_platform_driver_probe(efi_rtc_driver, efi_rtc_probe);
+static int __init efi_rtc_driver_init(void)
+{
+ return platform_driver_register(&efi_rtc_driver);
+}
+late_initcall(efi_rtc_driver_init);
+
+static void __exit efi_rtc_driver_exit(void)
+{
+ platform_driver_unregister(&efi_rtc_driver);
+}
+module_exit(efi_rtc_driver_exit);
MODULE_AUTHOR("dann frazier <dannf@...nf.org>");
MODULE_LICENSE("GPL");
--
2.43.0
Powered by blists - more mailing lists