public inbox for linux-rtc@vger.kernel.org
 help / color / mirror / Atom feed
From: "Rafael J. Wysocki" <rafael@kernel.org>
To: Linux ACPI <linux-acpi@vger.kernel.org>
Cc: LKML <linux-kernel@vger.kernel.org>,
	x86 Maintainers <x86@kernel.org>,
	linux-rtc@vger.kernel.org,
	Alexandre Belloni <alexandre.belloni@bootlin.com>
Subject: [PATCH v1 2/8] ACPI: x86: cmos_rtc: Improve coordination with ACPI TAD driver
Date: Mon, 23 Feb 2026 16:28:57 +0100	[thread overview]
Message-ID: <2415111.ElGaqSPkdT@rafael.j.wysocki> (raw)
In-Reply-To: <5983325.DvuYhMxLoT@rafael.j.wysocki>

From: "Rafael J. Wysocki" <rafael.j.wysocki@intel.com>

If a CMOS RTC (PNP0B00/PNP0B01/PNP0B02) device coexists with an ACPI
TAD (timer and event alarm device, ACPI000E), the ACPI TAD driver will
attempt to install the CMOS RTC address space hanlder that has been
installed already and the TAD probing will fail.

Avoid that by changing acpi_install_cmos_rtc_space_handler() to return
zero and acpi_remove_cmos_rtc_space_handler() to do nothing if the CMOS
RTC address space handler has been installed already.

Fixes: 596ca52a56da ("ACPI: TAD: Install SystemCMOS address space handler for ACPI000E")
Signed-off-by: Rafael J. Wysocki <rafael.j.wysocki@intel.com>
---
 drivers/acpi/x86/cmos_rtc.c | 18 +++++++++++++++++-
 1 file changed, 17 insertions(+), 1 deletion(-)

diff --git a/drivers/acpi/x86/cmos_rtc.c b/drivers/acpi/x86/cmos_rtc.c
index 977234da9fc1..45db7e51cbe6 100644
--- a/drivers/acpi/x86/cmos_rtc.c
+++ b/drivers/acpi/x86/cmos_rtc.c
@@ -24,6 +24,8 @@ static const struct acpi_device_id acpi_cmos_rtc_ids[] = {
 	{}
 };
 
+static bool cmos_rtc_space_handler_present __read_mostly;
+
 static acpi_status acpi_cmos_rtc_space_handler(u32 function,
 					       acpi_physical_address address,
 					       u32 bits, u64 *value64,
@@ -59,6 +61,9 @@ int acpi_install_cmos_rtc_space_handler(acpi_handle handle)
 {
 	acpi_status status;
 
+	if (cmos_rtc_space_handler_present)
+		return 0;
+
 	status = acpi_install_address_space_handler(handle,
 						    ACPI_ADR_SPACE_CMOS,
 						    acpi_cmos_rtc_space_handler,
@@ -68,6 +73,8 @@ int acpi_install_cmos_rtc_space_handler(acpi_handle handle)
 		return -ENODEV;
 	}
 
+	cmos_rtc_space_handler_present = true;
+
 	return 1;
 }
 EXPORT_SYMBOL_GPL(acpi_install_cmos_rtc_space_handler);
@@ -76,6 +83,9 @@ void acpi_remove_cmos_rtc_space_handler(acpi_handle handle)
 {
 	acpi_status status;
 
+	if (cmos_rtc_space_handler_present)
+		return;
+
 	status = acpi_remove_address_space_handler(handle,
 						   ACPI_ADR_SPACE_CMOS,
 						   acpi_cmos_rtc_space_handler);
@@ -87,7 +97,13 @@ EXPORT_SYMBOL_GPL(acpi_remove_cmos_rtc_space_handler);
 static int acpi_cmos_rtc_attach(struct acpi_device *adev,
 				const struct acpi_device_id *id)
 {
-	return acpi_install_cmos_rtc_space_handler(adev->handle);
+	int ret;
+
+	ret = acpi_install_cmos_rtc_space_handler(adev->handle);
+	if (ret < 0)
+		return ret;
+
+	return 1;
 }
 
 static struct acpi_scan_handler cmos_rtc_handler = {
-- 
2.51.0





  parent reply	other threads:[~2026-02-23 15:34 UTC|newest]

Thread overview: 20+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2026-02-23 15:27 [PATCH v1 0/8] ACPI: x86/rtc-cmos: Bind rtc-cmos to platform devices Rafael J. Wysocki
2026-02-23 15:28 ` [PATCH v1 1/8] ACPI: x86: cmos_rtc: Clean up address space handler driver Rafael J. Wysocki
2026-02-23 15:28 ` Rafael J. Wysocki [this message]
2026-02-23 15:29 ` [PATCH v1 3/8] ACPI: x86: cmos_rtc: Create a CMOS RTC platform device Rafael J. Wysocki
2026-02-25 18:01   ` Dave Hansen
2026-02-23 15:30 ` [PATCH v1 4/8] ACPI: x86/rtc-cmos: Use platform device for driver binding Rafael J. Wysocki
2026-02-26 13:01   ` Alexandre Belloni
2026-03-03  6:07   ` Nathan Chancellor
2026-03-03 12:51     ` Rafael J. Wysocki
2026-03-03 17:52       ` Nathan Chancellor
2026-03-03 18:47         ` Rafael J. Wysocki
2026-03-03 21:17           ` Nathan Chancellor
2026-03-04 12:42             ` Rafael J. Wysocki
2026-02-23 15:31 ` [PATCH v1 5/8] ACPI: PNP: Drop CMOS RTC PNP device support Rafael J. Wysocki
2026-02-23 15:31 ` [PATCH v1 6/8] x86: rtc: Drop PNP device check Rafael J. Wysocki
2026-02-25 18:01   ` Dave Hansen
2026-02-25 18:10     ` Rafael J. Wysocki
2026-02-23 15:32 ` [PATCH v1 7/8] rtc: cmos: Drop PNP device support Rafael J. Wysocki
2026-02-26 13:02   ` Alexandre Belloni
2026-02-23 15:33 ` [PATCH v1 8/8] ACPI: TAD/x86: cmos_rtc: Consolidate address space handler setup Rafael J. Wysocki

Reply instructions:

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

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

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

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

  git send-email \
    --in-reply-to=2415111.ElGaqSPkdT@rafael.j.wysocki \
    --to=rafael@kernel.org \
    --cc=alexandre.belloni@bootlin.com \
    --cc=linux-acpi@vger.kernel.org \
    --cc=linux-kernel@vger.kernel.org \
    --cc=linux-rtc@vger.kernel.org \
    --cc=x86@kernel.org \
    /path/to/YOUR_REPLY

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

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