Linux GPIO subsystem development
 help / color / mirror / Atom feed
From: sashiko-bot@kernel.org
To: "Atharva Tiwari" <atharvatiwarilinuxdev@gmail.com>
Cc: "Bjorn Helgaas" <bhelgaas@google.com>,
	"Thomas Gleixner" <tglx@kernel.org>,
	"Ingo Molnar" <mingo@redhat.com>,
	"Borislav Petkov" <bp@alien8.de>,
	"Dave Hansen" <dave.hansen@linux.intel.com>,
	x86@kernel.org, "H. Peter Anvin" <hpa@zytor.com>,
	"Rafael J. Wysocki" <rafael@kernel.org>,
	"Len Brown" <lenb@kernel.org>,
	"Linus Walleij" <linusw@kernel.org>,
	"Bartosz Golaszewski" <brgl@kernel.org>,
	"Sven Peter" <sven@kernel.org>, "Janne Grunau" <j@jannau.net>,
	"Neal Gompa" <neal@gompa.dev>,
	"Guenter Roeck" <linux@roeck-us.net>,
	"Jonathan Cameron" <jic23@kernel.org>,
	"David Lechner" <dlechner@baylibre.com>,
	"Nuno Sá" <nuno.sa@analog.com>,
	"Andy Shevchenko" <andy@kernel.org>, "Lee Jones" <lee@kernel.org>,
	"Pavel Machek" <pavel@kernel.org>,
	"Griffin Kroah-Hartman" <griffin@kroah.com>,
	"Hans de Goede" <hansg@kernel.org>,
	"Ilpo Järvinen" <ilpo.jarvinen@linux.intel.com>,
	"Sebastian Reichel" <sre@kernel.org>,
	"Alexandre Belloni" <alexandre.belloni@bootlin.com>,
	"Wim Van Sebroeck" <wim@linux-watchdog.org>,
	"Jarkko Sakkinen" <jarkko@kernel.org>,
	"Mimi Zohar" <zohar@linux.ibm.com>,
	"Roberto Sassu" <roberto.sassu@huawei.com>,
	"Dmitry Kasatkin" <dmitry.kasatkin@gmail.com>,
	"Eric Snowberg" <eric.snowberg@oracle.com>,
	"Paul Moore" <paul@paul-moore.com>,
	"James Morris" <jmorris@namei.org>,
	"Serge E. Hallyn" <serge@hallyn.com>,
	linux-pci@vger.kernel.org, linux-gpio@vger.kernel.org,
	linux-hwmon@vger.kernel.org, linux-leds@vger.kernel.org,
	mfd@lists.linux.dev, linux-rtc@vger.kernel.org,
	linux-watchdog@vger.kernel.org, keyrings@vger.kernel.org,
	linux-security-module@vger.kernel.org
Subject: Re: [RFC PATCH 09/14] treewide: disable other rtc's in t2 macs
Date: Thu, 29 Oct 2026 09:16:22 +0000	[thread overview]
Message-ID: <sashiko-outbox-189014@kernel.org> (raw)
In-Reply-To: <20261029085504.3547-10-atharvatiwarilinuxdev@gmail.com>

Thank you for your contribution! Sashiko AI review found 2 potential issue(s) to consider:
- [High] rtc: acpi_tad_probe() and cmos_do_probe() miss CONFIG_MACSMC_ACPI check
- [High] rtc: cmos_do_probe() leaves x86 CMOS wallclock callbacks active on T2 Macs
--

commit 8f32ab6b5995f6b8ccbfee083b09d400a56632a7
Author: Atharva Tiwari <atharvatiwarilinuxdev@gmail.com>

treewide: disable other rtc's in t2 macs

This commit disables the ACPI TAD real-time clock capability and aborts
probing the CMOS RTC driver on Apple T2 Macs when CONFIG_RTC_DRV_MACSMC is
enabled, leaving macsmc-rtc as the active RTC.

> diff --git a/drivers/acpi/acpi_tad.c b/drivers/acpi/acpi_tad.c
> index 45459a4cafae3..a137a39e5e67f 100644
> --- a/drivers/acpi/acpi_tad.c
> +++ b/drivers/acpi/acpi_tad.c
[ ... ]
> @@ -845,6 +846,9 @@ static int acpi_tad_probe(struct platform_device *pdev)
>  		return -ENODEV;
>  	}
>  
> +	if (IS_ENABLED(CONFIG_RTC_DRV_MACSMC) && has_apple_t2_chip)
> +		caps &= ~ACPI_TAD_RT;

[Severity: High]
Could checking only IS_ENABLED(CONFIG_RTC_DRV_MACSMC) in acpi_tad_probe()
and cmos_do_probe() leave T2 Macs without any registered RTC device when
CONFIG_MACSMC_ACPI is disabled?

In drivers/rtc/Kconfig, RTC_DRV_MACSMC only depends on MFD_MACSMC_CORE:

config RTC_DRV_MACSMC
	tristate "Apple Mac System Management Controller RTC"
	depends on MFD_MACSMC_CORE

However, on x86 T2 Macs, the macsmc-rtc MFD child device is only registered
via apple_smc_acpi_probe() -> apple_smc_probe(), which requires
CONFIG_MACSMC_ACPI in drivers/platform/x86/Kconfig:

config MACSMC_ACPI
	tristate "Apple SMC (System Management Controller) ACPI Backend"
	depends on MFD_MACSMC_CORE && ACPI && !SENSORS_APPLESMC

When CONFIG_RTC_DRV_MACSMC is enabled alongside CONFIG_SENSORS_APPLESMC (or
when CONFIG_MACSMC_ACPI is otherwise disabled), macsmc-rtc is never
instantiated, yet acpi_tad_probe() and cmos_do_probe() will still disable
both the ACPI TAD RTC and the CMOS RTC.

Should both checks also verify IS_ENABLED(CONFIG_MACSMC_ACPI)?

> diff --git a/drivers/rtc/rtc-cmos.c b/drivers/rtc/rtc-cmos.c
> index fa04ece151b8b..bdb436e24bb82 100644
> --- a/drivers/rtc/rtc-cmos.c
> +++ b/drivers/rtc/rtc-cmos.c
[ ... ]
> @@ -944,6 +945,9 @@ cmos_do_probe(struct device *dev, struct resource *ports, int rtc_irq)
>  		.priv = &cmos_rtc,
>  	};
>  
> +	if (IS_ENABLED(CONFIG_RTC_DRV_MACSMC) && has_apple_t2_chip)
> +		return -ENODEV;

[Severity: High]
When cmos_do_probe() returns -ENODEV here, what happens to the x86
architectural wallclock callbacks in x86_platform?

In arch/x86/kernel/x86_init.c, x86_platform defaults to the legacy CMOS
routines:

	.get_wallclock			= mach_get_cmos_time,
	.set_wallclock			= mach_set_cmos_time,

These are invoked by read_persistent_clock64() and
update_persistent_clock64() in arch/x86/kernel/rtc.c, which call
mc146818_get_time() and mc146818_set_time() directly on CMOS I/O ports
0x70/0x71 regardless of whether the rtc-cmos driver probed.

During NTP synchronization in kernel/time/ntp.c, sync_hw_clock() tries the
persistent clock before falling back to the RTC class device:

	/* Try the legacy RTC first. */
	res = update_persistent_clock64(to_set);
	if (res != -ENODEV)
		goto rearm;

	/* Try the RTC class */
	res = update_rtc(&to_set, &offset_nsec);

Because mach_set_cmos_time() -> mc146818_set_time() writes to the CMOS ports
and returns 0 (or -EINVAL, never -ENODEV), sync_hw_clock() will take the
goto rearm path and never call update_rtc() to update macsmc-rtc.

Similarly, timekeeping_init(), timekeeping_suspend(), and
timekeeping_resume() call read_persistent_clock64(), which will still read
the non-working CMOS clock via mach_get_cmos_time(). If that returns a
non-zero timestamp, persistent_clock_exists is set to true and
timekeeping_rtc_skipsuspend() causes rtc_suspend() to skip macsmc-rtc across
suspend and resume.

Should x86_platform.get_wallclock and x86_platform.set_wallclock also be
redirected to x86_init_noop / x86_wallclock_noop on T2 Macs when macsmc-rtc
is used?

-- 
Sashiko AI review · https://sashiko.dev/#/patchset/20261029085504.3547-1-atharvatiwarilinuxdev@gmail.com?part=9

  reply	other threads:[~2026-10-29  9:16 UTC|newest]

Thread overview: 35+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2026-10-29  8:51 [RFC PATCH 00/14] Add macsmc support for Intel Macs, replacing applesmc Atharva Tiwari
2026-10-29  8:51 ` [RFC PATCH 01/14] treewide: Add backend for macsmc Atharva Tiwari
2026-10-29  9:20   ` sashiko-bot
2026-10-29  8:51 ` [RFC PATCH 02/14] platform/x86: add backend for macsmc in intel macs Atharva Tiwari
2026-10-29  9:23   ` sashiko-bot
2026-10-29 12:59   ` Ilpo Järvinen
2026-10-29  8:52 ` [RFC PATCH 03/14] watchdog: add driver for apple smc Atharva Tiwari
2026-10-29  9:17   ` sashiko-bot
2026-10-29 13:30   ` Andy Shevchenko
2026-10-29  8:52 ` [RFC PATCH 04/14] iio/light: add new driver for macsmc Atharva Tiwari
2026-10-29  9:17   ` sashiko-bot
2026-10-29  8:52 ` [RFC PATCH 05/14] iio/accel: add driver for apple SMS Atharva Tiwari
2026-10-29  9:20   ` sashiko-bot
2026-10-29  8:52 ` [RFC PATCH 06/14] leds: add support for macsmc kbl Atharva Tiwari
2026-10-29  9:16   ` sashiko-bot
2026-10-29  8:52 ` [RFC PATCH 07/14] rtc: add support for x86 macs in macsmc-rtc Atharva Tiwari
2026-10-29  9:15   ` sashiko-bot
2026-10-29  8:52 ` [RFC PATCH 08/14] treewide: Add a flag to detect the Apple T2 chip Atharva Tiwari
2026-10-29  8:52 ` [RFC PATCH 09/14] treewide: disable other rtc's in t2 macs Atharva Tiwari
2026-10-29  9:16   ` sashiko-bot [this message]
2026-10-29  8:52 ` [RFC PATCH 10/14] power/supply: add support for x86 macs in macsmc-power Atharva Tiwari
2026-10-29  9:19   ` sashiko-bot
2026-10-29  8:52 ` [RFC PATCH 11/14] acpi: disable battery and adapter for x86 apple machines Atharva Tiwari
2026-10-29  9:13   ` sashiko-bot
2026-10-29  8:52 ` [RFC PATCH 12/14] hwmon/macsmc: add more types Atharva Tiwari
2026-10-29  9:18   ` sashiko-bot
2026-10-29  8:52 ` [RFC PATCH 13/14] hwmon: add support for x86 macs in macsmc-hwmon Atharva Tiwari
2026-10-29  9:20   ` sashiko-bot
2026-10-29  8:52 ` [RFC PATCH 14/14] mfd/macsmc: add ioctl to access smc keys Atharva Tiwari
2026-10-29  9:22   ` Sasha Finkelstein
2026-10-29 14:39     ` Atharva Tiwari
2026-10-29 14:53       ` Sasha Finkelstein
2026-10-29 15:25         ` Aditya Garg
2026-10-29 15:42           ` Sasha Finkelstein
2026-10-29  9:26   ` sashiko-bot

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=sashiko-outbox-189014@kernel.org \
    --to=sashiko-bot@kernel.org \
    --cc=alexandre.belloni@bootlin.com \
    --cc=andy@kernel.org \
    --cc=atharvatiwarilinuxdev@gmail.com \
    --cc=bhelgaas@google.com \
    --cc=bp@alien8.de \
    --cc=brgl@kernel.org \
    --cc=dave.hansen@linux.intel.com \
    --cc=dlechner@baylibre.com \
    --cc=dmitry.kasatkin@gmail.com \
    --cc=eric.snowberg@oracle.com \
    --cc=griffin@kroah.com \
    --cc=hansg@kernel.org \
    --cc=hpa@zytor.com \
    --cc=ilpo.jarvinen@linux.intel.com \
    --cc=j@jannau.net \
    --cc=jarkko@kernel.org \
    --cc=jic23@kernel.org \
    --cc=jmorris@namei.org \
    --cc=keyrings@vger.kernel.org \
    --cc=lee@kernel.org \
    --cc=lenb@kernel.org \
    --cc=linusw@kernel.org \
    --cc=linux-gpio@vger.kernel.org \
    --cc=linux-hwmon@vger.kernel.org \
    --cc=linux-leds@vger.kernel.org \
    --cc=linux-pci@vger.kernel.org \
    --cc=linux-rtc@vger.kernel.org \
    --cc=linux-security-module@vger.kernel.org \
    --cc=linux-watchdog@vger.kernel.org \
    --cc=linux@roeck-us.net \
    --cc=mfd@lists.linux.dev \
    --cc=mingo@redhat.com \
    --cc=neal@gompa.dev \
    --cc=nuno.sa@analog.com \
    --cc=paul@paul-moore.com \
    --cc=pavel@kernel.org \
    --cc=rafael@kernel.org \
    --cc=roberto.sassu@huawei.com \
    --cc=sashiko-reviews@lists.linux.dev \
    --cc=serge@hallyn.com \
    --cc=sre@kernel.org \
    --cc=sven@kernel.org \
    --cc=tglx@kernel.org \
    --cc=wim@linux-watchdog.org \
    --cc=x86@kernel.org \
    --cc=zohar@linux.ibm.com \
    /path/to/YOUR_REPLY

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

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