Linux LED subsystem development
 help / color / mirror / Atom feed
From: sashiko-bot@kernel.org
To: "Atharva Tiwari" <atharvatiwarilinuxdev@gmail.com>
Cc: "Aditya Garg" <aditya.garg@linux.dev>,
	"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: [PATCH 09/14] treewide: disable other rtc's in t2 macs
Date: Fri, 04 Dec 2026 14:27:32 +0000	[thread overview]
Message-ID: <sashiko-outbox-249970@kernel.org> (raw)
In-Reply-To: <20261204131619.5059-10-atharvatiwarilinuxdev@gmail.com>

Thank you for your contribution! Sashiko AI review found 5 potential
issues to consider:
- [High] x86/rtc: read_persistent_clock64() still reads broken CMOS RTC
  on T2 Macs
- [Medium] rtc: compile-time IS_ENABLED() disables T2 Mac RTCs if
  macsmc-rtc fails
- [Low] ACPI: TAD: acpi_tad_probe() clears ACPI_TAD_RT without
  ACPI_TAD_RT_IN_MS
- [Low] treewide: duplicated leaf-driver Kconfig guard across x86, ACPI,
  and RTC
- [Low] treewide: commit message reverses NTP-to-RTC synchronization
  direction
--

commit 4cff46337e95a353ab01666127ac4401097aabbb
Author: Atharva Tiwari <atharvatiwarilinuxdev@gmail.com>

treewide: disable other rtc's in t2 macs

This commit disables the CMOS RTC, the ACPI TAD real-time clock capability,
and legacy x86 persistent clock updates on Apple T2 Macs when
CONFIG_MACSMC_ACPI and CONFIG_RTC_DRV_MACSMC are enabled.

> Apple also uses RTC to update NTP instead of wallclock so we
> do that also.

[Severity: Low]
Does this sentence have the synchronization direction reversed?  Returning
-ENODEV from update_persistent_clock64() causes sync_hw_clock() in
kernel/time/ntp.c to fall back to update_rtc(), so NTP updates the RTC
class device instead of the legacy x86 wallclock, rather than the RTC
updating NTP.

> diff --git a/arch/x86/kernel/rtc.c b/arch/x86/kernel/rtc.c
> index 314b062a15de9..90f24e6cebfda 100644
> --- a/arch/x86/kernel/rtc.c
> +++ b/arch/x86/kernel/rtc.c

[ ... ]

> @@ -101,6 +102,10 @@ EXPORT_SYMBOL(rtc_cmos_write);
>  
>  int update_persistent_clock64(struct timespec64 now)
>  {
> +	if (IS_ENABLED(CONFIG_MACSMC_ACPI) &&
> +			IS_ENABLED(CONFIG_RTC_DRV_MACSMC) && has_apple_t2_chip)
> +		return -ENODEV;
> +
>  	return x86_platform.set_wallclock(&now);
>  }

[Severity: High]
Should read_persistent_clock64() also bypass the CMOS RTC on T2 Macs?
Right now it still calls x86_platform.get_wallclock(ts), which invokes
mach_get_cmos_time() on the broken CMOS clock that NTP will no longer
update.

On boot, if that read returns any valid non-zero timestamp,
timekeeping_init() initializes wall time from it and sets
persistent_clock_exists = true.  That makes timekeeping_rtc_skipsuspend()
return true, so rtc_suspend() skips snapshotting macsmc-rtc.

On S3 resume, timekeeping_resume() then either injects a bogus CMOS delta
and skips rtc_resume(), or leaves rtc_resume() to compute sleep time
against zeroed old_rtc and old_system snapshots.  If CMOS UIP is stuck,
mc146818_get_time() also busy-waits for 1000 ms on boot, suspend, and
resume.

Returning early from read_persistent_clock64() with ts->tv_sec and
ts->tv_nsec zeroed under the same T2 guard keeps persistent_clock_exists
false so boot and suspend/resume use macsmc-rtc.

> diff --git a/drivers/acpi/acpi_tad.c b/drivers/acpi/acpi_tad.c
> index 45459a4cafae3..a137164511f7b 100644
> --- a/drivers/acpi/acpi_tad.c
> +++ b/drivers/acpi/acpi_tad.c

[ ... ]

> @@ -845,6 +846,10 @@ static int acpi_tad_probe(struct platform_device *pdev)
>  		return -ENODEV;
>  	}
>  
> +	if (IS_ENABLED(CONFIG_MACSMC_ACPI) &&
> +			IS_ENABLED(CONFIG_RTC_DRV_MACSMC) && has_apple_t2_chip)
> +		caps &= ~ACPI_TAD_RT;
> +
>  	if (!acpi_has_method(handle, "_PRW")) {
>  		dev_info(dev, "Missing _PRW\n");
>  		caps &= ~(ACPI_TAD_AC_WAKE | ACPI_TAD_DC_WAKE);

[Severity: Low]
Should this also clear ACPI_TAD_RT_IN_MS?  Leaving it set in
dd->capabilities lets caps_show() report millisecond real-time accuracy in
sysfs even though ACPI_TAD_RT has been disabled, unlike the
ACPI_TAD_AC_WAKE / ACPI_TAD_DC_WAKE handling just below.

> diff --git a/drivers/rtc/rtc-cmos.c b/drivers/rtc/rtc-cmos.c
> index 209aa4ec732c8..9a6cecc192955 100644
> --- a/drivers/rtc/rtc-cmos.c
> +++ b/drivers/rtc/rtc-cmos.c

[ ... ]

> @@ -968,6 +969,10 @@ cmos_do_probe(struct device *dev, struct resource *ports, int rtc_irq)
>  		.priv = &cmos_rtc,
>  	};
>  
> +	if (IS_ENABLED(CONFIG_MACSMC_ACPI) &&
> +			IS_ENABLED(CONFIG_RTC_DRV_MACSMC) && has_apple_t2_chip)
> +		return -ENODEV;
> +
>  	/* there can be only one ... */
>  	if (cmos_rtc.dev)
>  		return -EBUSY;

[Severity: Medium]
Can gating these checks on compile-time IS_ENABLED() leave a T2 Mac with
no working RTC when CONFIG_MACSMC_ACPI=m and CONFIG_RTC_DRV_MACSMC=m?

drivers/hwmon/applesmc.c still matches all T2 Macs via
applesmc_whitelist[] with no exclusion against macsmc-acpi, and reserves
the same SMC I/O ports (0x300..0x31f).  If applesmc loads first,
apple_smc_acpi_probe() fails with -EBUSY in devm_request_region(), so
macsmc-rtc is never instantiated.

Because cmos_do_probe(), acpi_tad_probe(), and update_persistent_clock64()
already returned early, the system ends up with no /dev/rtc* device (and
no cmos_nvram or acpi_cmos_wake_setup()), and sync_hw_clock() fails with
-ENODEV.

Either the broken T2 RTCs should be quirked directly while resolving the
applesmc port conflict, or the fallback should not be disabled based
solely on tristate Kconfig symbols.

[Severity: Low]
This isn't a bug, but repeating the leaf-driver Kconfig check across
arch/x86, ACPI, and RTC couples generic drivers to downstream symbol
names.  Moving it to a static inline helper in
include/linux/platform_data/x86/apple.h (and splitting the changes per
subsystem) would keep the checks consistent and easier to review.

The commit message would also benefit from explaining how the CMOS RTC
and ACPI TAD fail on T2 Macs, and why disabling all of rtc-cmos
(including cmos_nvram and acpi_cmos_wake_setup()) is safe there.

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

  reply	other threads:[~2026-12-04 14:27 UTC|newest]

Thread overview: 55+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2026-12-04 13:12 [PATCH 00/14] Add macsmc support for Intel Macs, replacing applesmc Atharva Tiwari
2026-12-04 13:12 ` [PATCH 01/14] treewide: Add backend for macsmc Atharva Tiwari
2026-12-04 13:56   ` sashiko-bot
2026-12-04 14:07   ` Andy Shevchenko
2026-12-04 16:45   ` Sven Peter
2026-12-04 13:12 ` [PATCH 02/14] platform/x86: add backend for macsmc in intel macs Atharva Tiwari
2026-12-04 13:58   ` sashiko-bot
2026-12-04 14:19   ` Andy Shevchenko
2026-12-04 14:52     ` Aditya Garg
2026-12-04 17:23       ` Andy Shevchenko
2026-12-04 18:34         ` Aditya Garg
2026-12-04 19:57     ` Atharva Tiwari
2026-12-04 20:23       ` Andy Shevchenko
2026-12-04 13:12 ` [PATCH 03/14] watchdog: add driver for apple smc Atharva Tiwari
2026-12-04 13:48   ` sashiko-bot
2026-12-04 13:12 ` [PATCH 04/14] iio/light: add new driver for macsmc Atharva Tiwari
2026-12-04 13:47   ` sashiko-bot
2026-12-04 13:12 ` [PATCH 05/14] iio/accel: add driver for apple SMS Atharva Tiwari
2026-12-04 14:11   ` sashiko-bot
2026-12-04 13:12 ` [PATCH 06/14] leds: add support for macsmc kbl Atharva Tiwari
2026-12-04 14:07   ` sashiko-bot
2026-12-04 13:12 ` [PATCH 07/14] rtc: add support for x86 macs in macsmc-rtc Atharva Tiwari
2026-12-04 14:12   ` Andy Shevchenko
2026-12-04 14:48     ` Aditya Garg
2026-12-04 17:06       ` Andy Shevchenko
2026-12-04 17:10         ` Aditya Garg
2026-12-04 17:18           ` Andy Shevchenko
2026-12-04 17:26       ` Sven Peter
2026-12-04 14:16   ` sashiko-bot
2026-12-04 13:12 ` [PATCH 08/14] treewide: Add a flag to detect the Apple T2 chip Atharva Tiwari
2026-12-04 14:11   ` sashiko-bot
2026-12-04 13:12 ` [PATCH 09/14] treewide: disable other rtc's in t2 macs Atharva Tiwari
2026-12-04 14:27   ` sashiko-bot [this message]
2026-12-04 13:12 ` [PATCH 10/14] power/supply: add support for x86 macs in macsmc-power Atharva Tiwari
2026-12-04 14:39   ` sashiko-bot
2026-12-04 13:12 ` [PATCH 11/14] acpi: disable battery and adapter for x86 apple machines Atharva Tiwari
2026-12-04 14:08   ` Andy Shevchenko
2026-12-04 14:56     ` Aditya Garg
2026-12-04 17:14       ` Andy Shevchenko
2026-12-04 18:51         ` Aditya Garg
2026-12-04 20:02           ` Andy Shevchenko
2026-12-04 20:13             ` Andy Shevchenko
2026-12-04 14:25   ` sashiko-bot
2026-12-04 13:12 ` [PATCH 12/14] hwmon/macsmc: add more types Atharva Tiwari
2026-12-04 14:37   ` sashiko-bot
2026-12-04 18:44     ` Guenter Roeck
2026-12-04 13:12 ` [PATCH 13/14] hwmon: add support for x86 macs in macsmc-hwmon Atharva Tiwari
2026-12-04 14:48   ` sashiko-bot
2026-12-04 18:45     ` Guenter Roeck
2026-12-04 20:13       ` Jarkko Sakkinen
2026-12-04 13:12 ` [PATCH 14/14] mfd/macsmc: add ioctl to access smc keys Atharva Tiwari
2026-12-04 13:40   ` Sasha Finkelstein
2026-12-04 19:43     ` Atharva Tiwari
2026-12-04 14:48   ` sashiko-bot
2026-12-04 14:20 ` [PATCH 00/14] Add macsmc support for Intel Macs, replacing applesmc Andy Shevchenko

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-249970@kernel.org \
    --to=sashiko-bot@kernel.org \
    --cc=aditya.garg@linux.dev \
    --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