* [PATCH v3 2/2] rtc: efi: defer to the ACPI TAD if it can drive the RTC
2026-10-26 15:21 [PATCH v3 1/2] ACPI: TAD: introduce acpi_has_rtc() Hamza Mahfooz
@ 2026-10-26 15:21 ` Hamza Mahfooz
2026-10-26 15:26 ` sashiko-bot
2026-10-26 15:30 ` [PATCH v3 1/2] ACPI: TAD: introduce acpi_has_rtc() sashiko-bot
` (2 subsequent siblings)
3 siblings, 1 reply; 6+ messages in thread
From: Hamza Mahfooz @ 2026-10-26 15:21 UTC (permalink / raw)
To: linux-acpi, linux-rtc
Cc: Rafael J. Wysocki, Len Brown, Alexandre Belloni, Hamza Mahfooz,
Ard Biesheuvel
EFI runtime services are best avoided where possible, and ACPI defines a
standard interface to the RTC in the form of the Time and Alarm Device
(TAD), which the acpi-tad driver has been exposing as an RTC class
device since commit 8a1e7f4b1764 ("ACPI: TAD: Add RTC class device
interface").
So, make rtc-efi decline to probe, before calling GetTime(), if
acpi_has_rtc() says that the RTC can be driven via the TAD.
Also, to ensure that acpi_has_rtc() is always reachable from rtc-efi
when ACPI_TAD is enabled, make RTC_DRV_EFI depend on
ACPI_TAD || !ACPI_TAD.
Suggested-by: Ard Biesheuvel <ardb@kernel.org>
Signed-off-by: Hamza Mahfooz <hamzamahfooz@linux.microsoft.com>
---
v1: https://lore.kernel.org/all/20261022211304.2285792-2-hamzamahfooz@linux.microsoft.com/
v2:
- Make rtc-efi decline to probe instead of not registering the device in
efisubsys_init(). (Ard)
- Make RTC_DRV_EFI depend on !ACPI || ACPI_TAD. (Ard)
v3: Make RTC_DRV_EFI depend on ACPI_TAD || !ACPI_TAD. (Sashiko)
---
drivers/rtc/Kconfig | 5 +++++
drivers/rtc/rtc-efi.c | 4 ++++
2 files changed, 9 insertions(+)
diff --git a/drivers/rtc/Kconfig b/drivers/rtc/Kconfig
index 1e863f1d3..5b7e9d2a8 100644
--- a/drivers/rtc/Kconfig
+++ b/drivers/rtc/Kconfig
@@ -1262,10 +1262,15 @@ config RTC_DRV_DA9063
config RTC_DRV_EFI
tristate "EFI RTC"
depends on EFI && !X86
+ depends on ACPI_TAD || !ACPI_TAD
help
If you say yes here you will get support for the EFI
Real Time Clock.
+ On ACPI systems, the ACPI Time and Alarm Device (TAD) driver
+ is used instead of this one if the TAD can drive the RTC (assuming
+ it's enabled).
+
This driver can also be built as a module. If so, the module
will be called rtc-efi.
diff --git a/drivers/rtc/rtc-efi.c b/drivers/rtc/rtc-efi.c
index b4f44999e..545b21b17 100644
--- a/drivers/rtc/rtc-efi.c
+++ b/drivers/rtc/rtc-efi.c
@@ -10,6 +10,7 @@
#define pr_fmt(fmt) KBUILD_MODNAME ": " fmt
+#include <linux/acpi.h>
#include <linux/kernel.h>
#include <linux/module.h>
#include <linux/stringify.h>
@@ -192,6 +193,9 @@ static int __init efi_rtc_probe(struct platform_device *dev)
efi_time_t eft;
efi_time_cap_t cap;
+ if (acpi_has_rtc())
+ return -ENODEV;
+
/* First check if the RTC is usable */
if (efi.get_time(&eft, &cap) != EFI_SUCCESS)
return -ENODEV;
--
2.56.0
^ permalink raw reply related [flat|nested] 6+ messages in thread* Re: [PATCH v3 1/2] ACPI: TAD: introduce acpi_has_rtc()
2026-10-26 15:21 [PATCH v3 1/2] ACPI: TAD: introduce acpi_has_rtc() Hamza Mahfooz
2026-10-26 15:21 ` [PATCH v3 2/2] rtc: efi: defer to the ACPI TAD if it can drive the RTC Hamza Mahfooz
@ 2026-10-26 15:30 ` sashiko-bot
2026-10-27 11:02 ` Ard Biesheuvel
2026-10-27 11:53 ` Rafael J. Wysocki (Intel)
3 siblings, 0 replies; 6+ messages in thread
From: sashiko-bot @ 2026-10-26 15:30 UTC (permalink / raw)
To: Hamza Mahfooz, linux-rtc; +Cc: Alexandre Belloni
> The same RTC may also be accessible by other means, like the EFI
> GetTime() and SetTime() runtime services used by rtc-efi, which are best
> avoided if there is a native ACPI interface to the RTC.
>
> To allow other RTC drivers to stand down in that case, add an exported
> helper, acpi_has_rtc(), that returns true if there is a TAD the driver
> will register an RTC class device for.
>
> The helper looks for a platform device matching the driver's ID table
> whose _GCP indicates real time support, like acpi_tad_probe() checks,
> instead of checking whether the driver has bound to such a device, so
> that callers need not depend on the order in which drivers are probed.
>
> Suggested-by: Ard Biesheuvel <ardb@kernel.org>
> Signed-off-by: Hamza Mahfooz <hamzamahfooz@linux.microsoft.com>
Sashiko has reviewed this patch and found no issues.
--
Sashiko AI review · https://sashiko.dev/#/patchset/20261026152103.3109313-1-hamzamahfooz@linux.microsoft.com?part=1
^ permalink raw reply [flat|nested] 6+ messages in thread
* Re: [PATCH v3 1/2] ACPI: TAD: introduce acpi_has_rtc()
2026-10-26 15:21 [PATCH v3 1/2] ACPI: TAD: introduce acpi_has_rtc() Hamza Mahfooz
2026-10-26 15:21 ` [PATCH v3 2/2] rtc: efi: defer to the ACPI TAD if it can drive the RTC Hamza Mahfooz
2026-10-26 15:30 ` [PATCH v3 1/2] ACPI: TAD: introduce acpi_has_rtc() sashiko-bot
@ 2026-10-27 11:02 ` Ard Biesheuvel
2026-10-27 11:53 ` Rafael J. Wysocki (Intel)
3 siblings, 0 replies; 6+ messages in thread
From: Ard Biesheuvel @ 2026-10-27 11:02 UTC (permalink / raw)
To: Hamza Mahfooz, Linux ACPI, linux-rtc
Cc: Rafael J . Wysocki, Len Brown, Alexandre Belloni
Hello Hamza,
On Mon, 26 Oct 2026, at 16:21, Hamza Mahfooz wrote:
> The same RTC may also be accessible by other means, like the EFI
> GetTime() and SetTime() runtime services used by rtc-efi, which are best
> avoided if there is a native ACPI interface to the RTC.
>
> To allow other RTC drivers to stand down in that case, add an exported
> helper, acpi_has_rtc(), that returns true if there is a TAD the driver
> will register an RTC class device for.
>
> The helper looks for a platform device matching the driver's ID table
> whose _GCP indicates real time support, like acpi_tad_probe() checks,
> instead of checking whether the driver has bound to such a device, so
> that callers need not depend on the order in which drivers are probed.
>
> Suggested-by: Ard Biesheuvel <ardb@kernel.org>
> Signed-off-by: Hamza Mahfooz <hamzamahfooz@linux.microsoft.com>
> ---
> v1:
> https://lore.kernel.org/r/20261022211304.2285792-1-hamzamahfooz@linux.microsoft.com/
> v2:
> - Rename acpi_tad_rtc_available() to acpi_has_rtc(), move it to within
> acpi-tad (which allows us to simplify it quite a bit) and declare it
> in linux/acpi.h. (Ard)
> - Add acpi_disabled check. (Ard)
Next time, please use a cover latter when sending a series, so that you
can capture these changelogs in one place.
The series looks good to me:
Reviewed-by: Ard Biesheuvel <ardb@kernel.org>
I'll let Rafael and Alexandre decide how to queue this, once they are
happy with the patches as well.
^ permalink raw reply [flat|nested] 6+ messages in thread
* Re: [PATCH v3 1/2] ACPI: TAD: introduce acpi_has_rtc()
2026-10-26 15:21 [PATCH v3 1/2] ACPI: TAD: introduce acpi_has_rtc() Hamza Mahfooz
` (2 preceding siblings ...)
2026-10-27 11:02 ` Ard Biesheuvel
@ 2026-10-27 11:53 ` Rafael J. Wysocki (Intel)
3 siblings, 0 replies; 6+ messages in thread
From: Rafael J. Wysocki (Intel) @ 2026-10-27 11:53 UTC (permalink / raw)
To: Hamza Mahfooz
Cc: linux-acpi, linux-rtc, Rafael J. Wysocki, Len Brown,
Alexandre Belloni, Ard Biesheuvel
On Mon, Oct 26, 2026 at 4:21 PM Hamza Mahfooz
<hamzamahfooz@linux.microsoft.com> wrote:
>
> The same RTC may also be accessible by other means, like the EFI
> GetTime() and SetTime() runtime services used by rtc-efi, which are best
> avoided if there is a native ACPI interface to the RTC.
>
> To allow other RTC drivers to stand down in that case, add an exported
> helper, acpi_has_rtc(), that returns true if there is a TAD the driver
> will register an RTC class device for.
>
> The helper looks for a platform device matching the driver's ID table
> whose _GCP indicates real time support, like acpi_tad_probe() checks,
> instead of checking whether the driver has bound to such a device, so
> that callers need not depend on the order in which drivers are probed.
>
> Suggested-by: Ard Biesheuvel <ardb@kernel.org>
> Signed-off-by: Hamza Mahfooz <hamzamahfooz@linux.microsoft.com>
> ---
> v1: https://lore.kernel.org/r/20261022211304.2285792-1-hamzamahfooz@linux.microsoft.com/
> v2:
> - Rename acpi_tad_rtc_available() to acpi_has_rtc(), move it to within
> acpi-tad (which allows us to simplify it quite a bit) and declare it
> in linux/acpi.h. (Ard)
> - Add acpi_disabled check. (Ard)
> ---
> drivers/acpi/acpi_tad.c | 38 ++++++++++++++++++++++++++++++++++++++
> include/linux/acpi.h | 6 ++++++
> 2 files changed, 44 insertions(+)
>
> diff --git a/drivers/acpi/acpi_tad.c b/drivers/acpi/acpi_tad.c
> index 45459a4ca..eea4d2123 100644
> --- a/drivers/acpi/acpi_tad.c
> +++ b/drivers/acpi/acpi_tad.c
> @@ -899,6 +899,44 @@ static const struct acpi_device_id acpi_tad_ids[] = {
> {}
> };
>
> +static int acpi_tad_rtc_match(struct device *dev, const void *data)
> +{
> + unsigned long long caps;
> + acpi_status status;
> +
> + if (!acpi_match_device(acpi_tad_ids, dev))
> + return 0;
> +
> + status = acpi_evaluate_integer(ACPI_HANDLE(dev), "_GCP", NULL, &caps);
> +
> + return ACPI_SUCCESS(status) && (caps & ACPI_TAD_RT);
> +}
> +
> +/**
> + * acpi_has_rtc - Check if the RTC should be driven via the ACPI TAD
> + *
> + * Check if there is a TAD implementing the real time methods that this driver
> + * will register an RTC class device for.
> + *
> + * Return: %true if the RTC should be driven via the ACPI TAD, %false otherwise.
> + */
> +bool acpi_has_rtc(void)
> +{
> + struct device *dev;
> +
> + if (acpi_disabled || !IS_ENABLED(CONFIG_RTC_CLASS))
> + return false;
You may as well put these new functions under the existing
CONFIG_RTC_CLASS #ifdef so they don't get compiled unnecessarily, and
add an empty stub for acpi_has_rtc() in the !CONFIG_RTC_CLASS case.
The IS_ENABLED(CONFIG_RTC_CLASS) check above will not be necessary any
more then.
Apart from the above, the patch looks fine to me.
> +
> + dev = bus_find_device(&platform_bus_type, NULL, NULL,
> + acpi_tad_rtc_match);
> + if (!dev)
> + return false;
> +
> + put_device(dev);
> + return true;
> +}
> +EXPORT_SYMBOL_GPL(acpi_has_rtc);
> +
> static struct platform_driver acpi_tad_driver = {
> .driver = {
> .name = "acpi-tad",
> diff --git a/include/linux/acpi.h b/include/linux/acpi.h
> index ddacac812..71524a821 100644
> --- a/include/linux/acpi.h
> +++ b/include/linux/acpi.h
> @@ -1553,6 +1553,12 @@ extern bool acpi_has_watchdog(void);
> static inline bool acpi_has_watchdog(void) { return false; }
> #endif
>
> +#if IS_REACHABLE(CONFIG_ACPI_TAD)
> +bool acpi_has_rtc(void);
> +#else
> +static inline bool acpi_has_rtc(void) { return false; }
> +#endif
> +
> #ifdef CONFIG_ACPI_SPCR_TABLE
> extern bool qdf2400_e44_present;
> int acpi_parse_spcr(bool enable_earlycon, bool enable_console);
> --
> 2.56.0
>
^ permalink raw reply [flat|nested] 6+ messages in thread