From mboxrd@z Thu Jan 1 00:00:00 1970 Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.remote-ip=100.103.45.18 ARC-Seal: i=1; d=subspace.kernel.org; s=arc20261015; a=rsa-sha256; cv=none; t=1796392715; b=IWPfVqgs93q7qbNaZJsSjRse5oqEhuI1AhVkxqdEhtTuC21AbljrmVM/b09wyxhJ720+ RMUlwKLvNcKOOrgAkInoJga5Rt/RXBYuAwP/dDDtXXokxFNnonI979dSpFi6QOXGL+UsY rLbxOIZ3EtRajShSHRT3iaAdsE2EeeIqKrd/ILT4kOsiqEU8PRsGv4nahVTf1nM2DPAvK Qk6eL3qFE6nNajDHGcMHN82MHtG+velvroWQB+Jw4cXTkgFFIXQ3DZMVvKqZYfJnvPBJ3 eRyCW1zJFD1qnHyWmbleLbwiDIwbruTG8FvWqq0mcfmfkVcf7FHZ/JgskDmult8stvw== ARC-Message-Signature: i=1; d=subspace.kernel.org; s=arc20261015; a=rsa-sha256; c=relaxed/relaxed; t=1796392715; h=Received:DKIM-Signature:Message-ID:From:Subject:Reply-To:To:Cc: In-Reply-To:References:Content-Type:Content-Transfer-Encoding:Date; bh=U17Ax+TbrpigqJD6i9ymT6ZgMaTsdDqw0TB7zSYqzZg=; b=4+A4DglDBPNYrGBMh4vMmvhbH+6igHCzLxfLJzTj9vWlS3mAzaFeJQjmrBJlpfeKwsRt XV+VvJ57ZhX+r0FRutHRBVwYBzzkXne3SP6kxl4rtxjyxvmdhO5kXDTrusfdcVHdbjbzp xiSXjucoFmiPKV4OFgD2UFAkSlcNH9MKyK74yiTWdPZRoX/zX5/FjnaZ2Ync0ptNHkLwT V+hubG3sD8jbS7uxSrQWWv04bLvHgBZ0nfX9tn5jxQqQHX07sjOB7kKIsi7+sw6sMLcyS Bd8MhxGx40D2Cet8Ha/03vEUYLPjsg9V/LdFHUWifRrcMEbwlhbeRZlCpk/Gl6B+3Mg== ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dkim=pass header.d=kernel.org header.i=@kernel.org header.a=rsa-sha256 header.s=k20260515 header.b="kFpy93U/"; arc=none smtp.remote-ip=100.103.45.18 Received: from smtp.kernel.org (quasi.space.kernel.org [100.103.45.18]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature ECDSA (prime256v1)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 7C631606A335; Fri, 4 Dec 2026 13:58:35 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=kernel.org header.i=@kernel.org header.a=rsa-sha256 header.s=k20260515 header.b=kFpy93U/ Received: by smtp.kernel.org (Postfix) with ESMTPSA id 998A21F0092C; Fri, 4 Dec 2026 13:58:33 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=kernel.org; s=k20260515; t=1796392715; bh=U17Ax+TbrpigqJD6i9ymT6ZgMaTsdDqw0TB7zSYqzZg=; h=From:Subject:Reply-To:To:Cc:In-Reply-To:References:Date; b=kFpy93U/LKwbCB7VyXfqombb95TtCt/xEMDtIBMQhx9iI7c1OdlWvbrX7i6A7NR7J 1T3pn+JRxQa7785lYPk6stIneKaxvgXzf405GxxkplLGZg6MdXOHwgDVGMDwogc2bW Aik4TpToQrqJIGigQCsnqNfIbEdKJ1cZCYHtnV6Ka/imjF7raEy8VljLjd2qG2s34+ rri3H2ClEdEuHN+GCBysI0EaO3wOA9mYSDCZPOBCq0oN/0kXgsiAuzLDpSCNv5ncUV DzV1d5WRH5bZ8z/tyzSCVF/T5Z+gaBlpmK4ld3fpT7pwi4KX/VB2+chMTGZFi+wYDH VyGTa1Bd5AS2Q== Message-ID: From: sashiko-bot@kernel.org Subject: Re: [PATCH 02/14] platform/x86: add backend for macsmc in intel macs Reply-To: sashiko-reviews@lists.linux.dev To: "Atharva Tiwari" Cc: "Ihor Odainyi" , "Antoine Sidem" , "Aditya Garg" , "Bjorn Helgaas" , "Thomas Gleixner" , "Ingo Molnar" , "Borislav Petkov" , "Dave Hansen" , x86@kernel.org, "H. Peter Anvin" , "Rafael J. Wysocki" , "Len Brown" , "Linus Walleij" , "Bartosz Golaszewski" , "Sven Peter" , "Janne Grunau" , "Neal Gompa" , "Guenter Roeck" , "Jonathan Cameron" , "David Lechner" , =?utf-8?b?TnVubyBTw6E=?= , "Andy Shevchenko" , "Lee Jones" , "Pavel Machek" , "Griffin Kroah-Hartman" , "Hans de Goede" , =?utf-8?b?SWxwbyBKw6RydmluZW4=?= , "Sebastian Reichel" , "Alexandre Belloni" , "Wim Van Sebroeck" , "Jarkko Sakkinen" , "Mimi Zohar" , "Roberto Sassu" , "Dmitry Kasatkin" , "Eric Snowberg" , "Paul Moore" , "James Morris" , "Serge E. Hallyn" , 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 In-Reply-To: <20261204131619.5059-3-atharvatiwarilinuxdev@gmail.com> References: <20261204131619.5059-1-atharvatiwarilinuxdev@gmail.com> <20261204131619.5059-3-atharvatiwarilinuxdev@gmail.com> Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: quoted-printable Date: Fri, 04 Dec 2026 13:58:33 +0000 X-Mailing-List: linux-security-module@vger.kernel.org List-Id: List-Post: List-Help: List-Subscribe: List-Unsubscribe: List-Owner: Precedence: list Thank you for your contribution! Sashiko AI review found 20 potential issues to consider: - [High] platform/x86: macsmc-acpi: I/O port conflict with applesmc lacks Kconfig exclusion - [High] platform/x86: macsmc-acpi: broken cmd_done completion wait in apple_smc_acpi_port_wait() - [Medium] platform/x86: macsmc-acpi: completion race and missing status check in MMIO wait - [Medium] platform/x86: macsmc-acpi: 1 ms poll interval inflates PIO/MMIO wait latency - [Medium] platform/x86: macsmc-acpi: broken status check in apple_smc_acpi_irq() - [Medium] platform/x86: macsmc-acpi: NTOK left enabled on early apple_smc_probe() fail - [Medium] platform/x86: macsmc-acpi: unlocked flag read in apple_smc_acpi_resume() - [Medium] platform/x86: macsmc-acpi: unchecked ACPI_COMPANION() in apple_smc_acpi_probe() - [Medium] platform/x86: macsmc-acpi: omit PIO data flush in apple_smc_acpi_port_read() - [Medium] platform/x86: apple_smc_acpi_resume() can skip restoring NTOK after resume - [Medium] platform/x86: raw ACPI IRQ and missing flags in apple_smc_acpi_probe() - [Medium] platform/x86: unchecked ACPI_COMPANION() in apple_smc_acpi_probe() - [Medium] platform/x86: macsmc-acpi races with applesmc on SMC I/O ports - [Low] platform/x86: macsmc-acpi: undocumented multi-value plimit sysfs attribute - [Low] platform/x86: __be32 to u32 in apple_smc_acpi_mmio_get_key_info() - [Low] platform/x86: void return expression in apple_smc_acpi_mmio_clear() - [Low] platform/x86: macsmc-acpi: apple_smc_acpi_write() returns size instead of 0 - [Low] platform/x86: macsmc-acpi: devm_ioremap() without devm_request_mem_region() - [Low] platform/x86: macsmc-acpi exposes undocumented plimit sysfs attribute - [Low] platform/x86: raw byte array kept in apple_smc_acpi_port_get_key_info() -- commit eb95b0b0da7b2552eb2f4941cef2db07a98b0710 Author: Atharva Tiwari platform/x86: add backend for macsmc in intel macs This commit adds an ACPI backend driver for the Apple SMC on Intel Macs, supporting I/O port and MMIO transfers as well as interrupt-driven completion with polling fallback. > diff --git a/drivers/platform/x86/Kconfig b/drivers/platform/x86/Kconfig > index 9ce384e0475ea..7a061e48465b4 100644 > --- a/drivers/platform/x86/Kconfig > +++ b/drivers/platform/x86/Kconfig > @@ -202,6 +202,16 @@ config ADV_SWBUTTON > To compile this driver as a module, choose M here. The module will > be called adv_swbutton. > =20 > +config MACSMC_ACPI > + tristate "Apple SMC (System Management Controller) ACPI Backend" > + depends on MFD_MACSMC_CORE && ACPI [Severity: High] Can CONFIG_MACSMC_ACPI and CONFIG_SENSORS_APPLESMC be enabled at the same time without mutual exclusion? Both drivers auto-load on Intel Macs and claim the same 32-byte I/O port region (0x300-0x31f). When both are built-in, drivers/Makefile links hwmon/ before platform/, so applesmc_init() always reserves the ports first and apple_smc_acpi_probe() fails with -EBUSY; when built as modules, they race at boot. Because later patches in this series disable acpi-sbs, ACPI battery/AC, rtc-cmos, and acpi-tad whenever CONFIG_MACSMC_ACPI is enabled, applesmc winning the port claim leaves those devices without any driver. [ ... ] > diff --git a/drivers/platform/x86/macsmc-acpi.c b/drivers/platform/x86/ma= csmc-acpi.c > new file mode 100644 > index 0000000000000..8a93245c9d293 > --- /dev/null > +++ b/drivers/platform/x86/macsmc-acpi.c [ ... ] > +static int apple_smc_acpi_port_wait(struct apple_smc_acpi *smc, u8 val, = u8 mask) > +{ > + u8 status; > + int ret; > + > + if (smc->interrupt_enabled) { > + reinit_completion(&smc->cmd_done); > + if (wait_for_completion_timeout(&smc->cmd_done, > + msecs_to_jiffies(SMC_TIMEOUT_MS)) > 0) > + return 0; > + > + smc->interrupt_enabled =3D 0; > + dev_dbg(smc->dev, "mmio/wait: interrupt missed, reverting to polling\n= "); > + } [Severity: High] Does apple_smc_acpi_port_wait() unconditionally block on cmd_done without checking the port status register first? Every PIO read and write begins with apple_smc_acpi_port_valid() -> apple_smc_acpi_port_wait(smc, 0, SMC_IO_STATUS_BUSY) while the SMC is idle and no command is in flight, so the first PIO transaction on an interrupt-capable PIO Mac always stalls for 1000 ms under smc->mutex and permanently clears smc->interrupt_enabled. In addition, calling reinit_completion(&smc->cmd_done) after outb() races with complete(&smc->cmd_done) in apple_smc_acpi_irq() and can lose the wakeup. Returning 0 on wakeup also skips verifying (status & mask) =3D=3D = val, and the fallback debug message says "mmio/wait" in the PIO path. > + ret =3D read_poll_timeout(inb, status, (status & mask) =3D=3D val, > + USEC_PER_MSEC, SMC_TIMEOUT_MS * USEC_PER_MSEC, > + false, smc->port_base + SMC_IO_CMD_PORT); [Severity: Medium] Does polling with a 1 ms sleep interval inflate PIO and MMIO wait latency? read_poll_timeout() with USEC_PER_MSEC sleeps 251-1000 us on the first failed status check, both here and in apple_smc_acpi_mmio_wait(). Because each PIO key access performs ~10-13 byte-level status handshakes while holding smc->mutex, per-key latency grows from ~0.1-0.5 ms in applesmc (which starts at 8 us with backoff in wait_status()) to several milliseconds per key, stalling multi-key hwmon and power_supply queries. [ ... ] > + for (ret =3D 0; ret < len; ret++) { > + if (apple_smc_acpi_port_wait(smc, > + SMC_IO_STATUS_AWAITING_DATA | SMC_IO_STATUS_BUSY, > + SMC_IO_STATUS_AWAITING_DATA | SMC_IO_STATUS_BUSY)) { > + dev_dbg(smc->dev, "port/read: read failed, key: 0x%X\n", key); > + return -EIO; > + } > + buffer[ret] =3D inb(smc->port_base + SMC_IO_DATA_PORT); > + } > + > + return apple_smc_acpi_port_wait(smc, 0, SMC_IO_STATUS_BUSY); [Severity: Medium] Should apple_smc_acpi_port_read() drain unread bytes while SMC_IO_STATUS_AWAITING_DATA is set before waiting for SMC_IO_STATUS_BUSY to clear? As described in commit 25f2bd7f5add ("hwmon: (applesmc) Always read until end of data"), 2012+ Intel SMCs can leave trailing bytes in the output FIFO, keeping SMC_IO_STATUS_BUSY asserted until drained. Without the flush loop from applesmc.c read_smc(), waiting directly for BUSY to clear times out after 1000 ms and leaves the SMC PIO state machine desynchronized, especially since apple_smc_read() does not validate the caller's length against key info.size. [ ... ] > +static int apple_smc_acpi_port_get_key_info(struct apple_smc_acpi *smc, > + smc_key key, struct apple_smc_key_info *info) > +{ > + u8 buf[6]; > + > + if (apple_smc_acpi_port_read(smc, SMC_MSG_GET_KEY_INFO, key, buf, sizeo= f(buf))) > + return -EIO; > + > + if (!info) > + return 0; > + > + info->size =3D buf[0]; > + info->type_code =3D get_unaligned_be32(&buf[1]); > + info->flags =3D buf[5]; > + > + return 0; > +} [Severity: Low] As reported by Ilpo J=C3=A4rvinen on RFC [1], this still reads into a raw u8 buf[6] array with magic offsets instead of a __packed struct with named members and a __be32 type_code field. The #include at the top of the file is also unused (__packed comes from linux/compiler_attributes.h), and the commit message still wraps lines early at 51-60 columns instead of 72-75 columns. > +static void apple_smc_acpi_mmio_clear(struct apple_smc_acpi *smc) > +{ > + if (ioread8(smc->iomem_base + SMC_MMIO_KEY_STATUS)) > + return iowrite8(0, smc->iomem_base + SMC_MMIO_KEY_STATUS); > +} [Severity: Low] Returning the void result of iowrite8() from a void function violates ISO C and triggers sparse/pedantic warnings; dropping the return keyword fixes it. Also, dev_dbg(smc->dev, "mmio/wait: timeout"); in apple_smc_acpi_mmio_wait() is missing a trailing newline. > +static int apple_smc_acpi_mmio_wait(struct apple_smc_acpi *smc) > +{ > + u8 status; > + int ret; > + > + if (smc->interrupt_enabled) { > + if (wait_for_completion_timeout(&smc->cmd_done, > + msecs_to_jiffies(SMC_TIMEOUT_MS)) > 0) > + return 0; > + > + smc->interrupt_enabled =3D 0; > + dev_dbg(smc->dev, "mmio/wait: interrupt missed, reverting to polling\n= "); > + } [Severity: Medium] Can a delayed or spurious SMC_INT_CMD_DONE wake apple_smc_acpi_mmio_wait() before the in-flight MMIO command finishes? apple_smc_acpi_try_enable_interrupts() polls the NTOK=3D1 write while the IRQ handler is already active and sets smc->interrupt_enabled =3D 1 without draining any resulting SMC_INT_CMD_DONE. Because apple_smc_acpi_mmio_wait() returns 0 immediately on wakeup without checking SMC_MMIO_STATUS_DONE, an early wakeup causes apple_smc_acpi_mmio_result() to read an unfinished command opcode (-EIO) or stale SMC_MMIO_KEY_DATA. In addition, once a timeout clears smc->interrupt_enabled =3D 0, NTOK stays enabled in hardware, so the IRQ handler still calls complete() while the polled MMIO paths unconditionally call unlocked reinit_completion(): CPU0 (polled MMIO) CPU1 () apple_smc_acpi_mmio_read() reinit_completion(&smc->cmd_done) cmd_done.done =3D 0; apple_smc_acpi_irq() complete(&smc->cmd_done) cmd_done.done++; <-- data race Disabling NTOK (or gating complete() and reinit_completion() on interrupt_enabled) and verifying SMC_MMIO_STATUS_DONE after wakeup would avoid both issues. [ ... ] > + info->type_code =3D cpu_to_be32(ioread32(smc->iomem_base + SMC_MMIO_KEY= _DATA)); [Severity: Low] Does assigning cpu_to_be32() to host-order u32 info->type_code trigger a sparse endianness warning? Using ioread32be() reads the big-endian MMIO register directly into u32 and matches iowrite32be() above. [ ... ] > + if (smc->is_mmio) { > + status =3D ioread8(smc->iomem_base + SMC_MMIO_KEY_INTERRUPT_STATUS); > + if (!(status & SMC_MMIO_IRQ_PENDING) && status) > + return IRQ_NONE; > + } else { > + status =3D inb(smc->port_base + SMC_IO_CMD_PORT); > + if (!(status & SMC_IO_STATUS_IRQ_PENDING) && status) > + return IRQ_NONE; > + } [Severity: Medium] Why do both status checks include "&& status"? When no SMC interrupt is pending and the status register reads 0, the condition evaluates to false and apple_smc_acpi_irq() does not return IRQ_NONE. On a spurious or shared interrupt, it falls through to read SMC_IO_INT_ID_PORT (risking re-dispatching a stale ID such as SMC_INT_SHUTDOWN or SMC_INT_CMD_DONE) and unconditionally returns IRQ_HANDLED even for unknown or zero int_id values. Conversely, if an event arrives without IRQ_PENDING while another status bit such as SMC_IO_STATUS_BUSY is set, this check drops it with IRQ_NONE. [ ... ] > + case ACPI_RESOURCE_TYPE_IRQ: > + smc->irq =3D res->data.irq.interrupts[0]; > + return AE_OK; [Severity: Medium] Does storing the raw ACPI IRQ number from _CRS bypass Linux IRQ translation and ignore ExtendedIrq descriptors and IRQ flags? acpi_create_platform_device() already translates both ACPI_RESOURCE_TYPE_IRQ and ACPI_RESOURCE_TYPE_EXTENDED_IRQ into IORESOURCE_IRQ resources with trigger and shareability flags. Passing the raw GSI to devm_request_irq() with hardcoded flags 0 in apple_smc_acpi_probe() can register on the wrong Linux IRQ when the GSI does not map 1:1, fail with -EBUSY on shared lines, or miss ExtendedIrq descriptors and disable SMC notifications. Using platform_get_irq_optional() handles translation and trigger setup. [ ... ] > + smc->iomem_base =3D devm_ioremap(smc->dev, smc->iomem_base_addr, > + smc->iomem_base_size); [Severity: Low] Should this claim the MMIO window with devm_request_mem_region() (or devm_ioremap_resource()) before mapping it, as apple_smc_acpi_probe() does for the PIO ports with devm_request_region()? Without an IORESOURCE_BUSY reservation, conflicting drivers will not get -EBUSY, CONFIG_IO_STRICT_DEVMEM protection is bypassed, and /proc/iomem does not show macsmc-acpi owning the window. [ ... ] > + if (ret < 0) > + return ret; > + > + return size; > +} [Severity: Low] Should apple_smc_acpi_write() return 0 on success instead of size? include/linux/mfd/macsmc.h documents apple_smc_write() as returning 0 on success (matching macsmc-rtkit), and APPLE_SMC_TYPE_OPS passes its return value directly through. Returning size leaks positive byte counts out of callbacks documented to return 0 or negative errno, such as macsmc_hwmon_write_fan() (hwmon_ops.write) and macsmc_battery_set_property(). [ ... ] > +static ssize_t plimit_show(struct device *dev, struct device_attribute *= attr, char *buf) > +{ > + struct apple_smc *smc =3D dev_get_drvdata(dev); > + struct apple_smc_acpi *smc_acpi =3D smc->be_cookie; > + > + return sysfs_emit(buf, "%08x %02x\n", > + inl(smc_acpi->port_base + SMC_IO_INT_PLIMIT), > + inb(smc_acpi->port_base + SMC_IO_INT_PLIMIT_GPU)); > +} > +static DEVICE_ATTR_RO(plimit); [Severity: Low] This adds a new userspace sysfs attribute that formats two values in one file (violating the sysfs one-value-per-file convention), has no Documentation/ABI/ entry, and is not mentioned in the commit message. plimit_show() and apple_smc_acpi_resume() also reach directly into core struct apple_smc internals (smc->be_cookie and smc->mutex) instead of using core helpers. [ ... ] > +static int apple_smc_acpi_probe(struct platform_device *pdev) > +{ > + struct acpi_device *adev =3D ACPI_COMPANION(&pdev->dev); [Severity: Medium] Can ACPI_COMPANION(&pdev->dev) return NULL here? Because platform_bus_type allows driver_override, binding a non-ACPI platform device to macsmc-acpi via sysfs enters apple_smc_acpi_probe() with a NULL adev, causing a NULL pointer dereference oops when adev->handle is evaluated below. [ ... ] > + status =3D acpi_walk_resources(adev->handle, METHOD_NAME__CRS, > + apple_smc_acpi_walk_resources, smc); [Severity: Medium] Is adev->handle dereferenced without checking if adev is non-NULL? Checking if (!adev) return -ENODEV; or passing ACPI_HANDLE(&pdev->dev) avoids a NULL pointer dereference if a non-ACPI platform device is bound to this driver. [ ... ] > + if (!devm_request_region(smc->dev, smc->port_base, SMC_IO_NR_PORTS, "ma= csmc-acpi")) > + return -EBUSY; [Severity: Medium] Can macsmc-acpi and applesmc race for this 32-byte I/O port region at boot? Both drivers auto-load on Intel Macs (APP0001 ACPI modalias vs applesmc DMI whitelist) and request 0x300-0x31f. When both are built as modules, udev loads them concurrently, non-deterministically switching userspace between the legacy applesmc ABI and the macsmc MFD ABIs across boots; when both are built-in, applesmc always claims the region first. [ ... ] > + apple_smc_acpi_try_enable_interrupts(smc); > + > + return apple_smc_probe(smc->dev, &apple_smc_acpi_be_ops, smc, &smc->eve= nt_handlers, true); [Severity: Medium] Does enabling NTOK=3D1 before apple_smc_probe() leave hardware notifications armed if apple_smc_probe() fails early? apple_smc_probe() does not register devm_add_action_or_reset(..., apple_smc_disable_notifications, ...) until after devm_kzalloc() and the initial #KEY, first_key, and last_key reads. If any of those fail, devres unregisters apple_smc_acpi_irq() while NTOK remains 1 in SMC hardware. Also, during normal teardown, apple_smc_acpi_notifications() writes NTOK=3D0 while smc->interrupt_enabled is still 1, which risks a 1000 ms timeout if clearing NTOK suppresses its own CMD_DONE interrupt. > +static int apple_smc_acpi_resume(struct device *dev) > +{ > + struct apple_smc *smc =3D dev_get_drvdata(dev); > + struct apple_smc_acpi *smc_acpi =3D smc->be_cookie; > + > + /* NTOK may be set to 0 on resume */ > + if (smc_acpi->interrupt_enabled) { > + mutex_lock(&smc->mutex); > + smc_acpi->interrupt_enabled =3D 0; > + apple_smc_acpi_try_enable_interrupts(smc_acpi); > + mutex_unlock(&smc->mutex); > + } > + return 0; > +} [Severity: Medium] Is checking smc_acpi->interrupt_enabled before acquiring smc->mutex a data race and TOCTOU? There is no .suspend callback and IRQs are re-enabled before dpm_resume() runs, so a concurrent SMC transaction on a non-freezable workqueue can clear interrupt_enabled under smc->mutex while apple_smc_acpi_resume() reads it unlocked: CPU0 (dpm_resume) CPU1 (kworker) apple_smc_acpi_resume() if (smc_acpi->interrupt_enabled) apple_smc_read() mutex_lock(&smc->mutex) apple_smc_acpi_mmio_wait() smc->interrupt_enabled =3D 0; mutex_unlock(&smc->mutex) mutex_lock(&smc->mutex) smc_acpi->interrupt_enabled =3D 0; apple_smc_acpi_try_enable_interrupts() <-- TOCTOU / data race Acquiring smc->mutex before checking smc_acpi->interrupt_enabled closes the race. [Severity: Medium] Can apple_smc_acpi_resume() permanently skip restoring NTOK=3D1 after suspend/resume? ACPI runtime GPEs are re-enabled in platform_resume_early() or platform_resume_finish() before dpm_resume() runs apple_smc_acpi_resume(). If a non-freezable ACPI notification (such as ACPI0003 triggering power_supply_changed() -> apple_smc_read*()) accesses the SMC while firmware has reset NTOK to 0, apple_smc_acpi_mmio_wait() stalls for 1000 ms and clears smc->interrupt_enabled =3D 0. When apple_smc_acpi_resume() then runs, it sees interrupt_enabled =3D=3D 0 and skips apple_smc_acpi_try_enable_interrupts(), leaving SMC accesses stuck in polling mode and all asynchronous SMC notifications disabled across subsequent resumes. The same occurs after any single transient missed IRQ followed by suspend/resume. [ ... ] > + .dev_groups =3D apple_smc_acpi_groups, [Severity: Low] Registering apple_smc_acpi_groups exposes the undocumented plimit sysfs attribute to userspace without a Documentation/ABI/ entry or commit message description; once merged, it becomes permanent kernel ABI. [1] https://lore.kernel.org/r/0cba7eea-ed39-d4d8-8587-f1c07cb5b03f@linux.in= tel.com --=20 Sashiko AI review =C2=B7 https://sashiko.dev/#/patchset/20261204131619.5059= -1-atharvatiwarilinuxdev@gmail.com?part=3D2