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=1796392103; b=G7WIxnb5XNuW5DYxxKmGEPhVeExWUKg1x4iPwtB9HoXDb4MAzsfrW9fLCaun/IyFggyn Gnrvg1q7sQtZewLYVzChK57e6/sGE+c0LEyAdOsfZfzztE9nbl3u7IylLTiLGREo6XI3m etgtNZ9PXe7I4vm/oWsrQgTKrlPLv89bICBxlmjvsszoVMWiDp+/GKxI/01l1J0VmJYaO QOuQkgVc/3D3OpoFHe7A4tqL1Rom344BAw4CYv2AllkYGdC7YL4AyMSMB8w55vL03dAgi OOnTOlXT91jYf210A+5snHo+RCzTur+xhYZHH0xpuIzoTAbynwhM0AJzsEbXhVDWwRg== ARC-Message-Signature: i=1; d=subspace.kernel.org; s=arc20261015; a=rsa-sha256; c=relaxed/relaxed; t=1796392103; h=Received:DKIM-Signature:Message-ID:From:Subject:Reply-To:To:Cc: In-Reply-To:References:Content-Type:Content-Transfer-Encoding:Date; bh=bBgzogd+af1ZvTFGTuSgghGS8uxtz/z955oxLr5c/sM=; b=2ua1UnEns8XfzuEiGG/LyYHgEJkXL4LjCpHAdvteP4MN3qiqYBOTwlc+ugp/7tL3M+xe 89i5yDTd2slvMaLchr+AxnG1tQRCztGskaG5s4aurzpg3BTKU3XT46pm6FNUTY2hcgXA5 +AeJZykUyAKnsAt5OOf8h0EZWEbH4GBliIwDCY1TsJmZPUUocsAK3iOgN5K+KT4HaJe50 /UTbykc9rCwp/xhB9Fi4gGu8WJ0bzMlrL7lLKVOqCLjfC5D5h15VJto2umkTfPeOTkvkU nRuiBGYDZ7gbXhJWHpSVZ0L7fUYLGEYd+mlqrYuy42MOpZoMgM7QiDzUIdQlykqxJ7w== 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=d0XKxsVF; 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 DD437606A322; Fri, 4 Dec 2026 13:48:23 +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=d0XKxsVF Received: by smtp.kernel.org (Postfix) with ESMTPSA id C4CD11F000C2; Fri, 4 Dec 2026 13:48:21 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=kernel.org; s=k20260515; t=1796392103; bh=bBgzogd+af1ZvTFGTuSgghGS8uxtz/z955oxLr5c/sM=; h=From:Subject:Reply-To:To:Cc:In-Reply-To:References:Date; b=d0XKxsVFVJcXoUi0qjLBL6nk3Issg7MzBrF7dq2oW+Fh4hpriyrM6SYQu/LijrUJ3 OaQrgf+58Hs0x0g3YjaY1s+R5l5/4q/enwGEedL5zrXXy1knvpoq+wsXgEPXaoUqkW 2ML4MDVgWuVL46qLi6a+1ECibqM8zAxgelOrESX6qizAIrhr9uXpjx8Cp/r2CEWUPJ uOUpoQ+pxNz34I0iy6M9N41o3ra/zxQEDUhB0rclbults7Xi8EpLKBuouHklX/0wz9 CHjdkfKmxU6g5TIVZEhkEIxgIom3g2pIyfFTLANrPPmIutsg/KwjjoePmoPVJGlPcC nbJeQhPJtO/hQ== Message-ID: From: sashiko-bot@kernel.org Subject: Re: [PATCH 03/14] watchdog: add driver for apple smc 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-4-atharvatiwarilinuxdev@gmail.com> References: <20261204131619.5059-1-atharvatiwarilinuxdev@gmail.com> <20261204131619.5059-4-atharvatiwarilinuxdev@gmail.com> Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: quoted-printable Date: Fri, 04 Dec 2026 13:48:21 +0000 X-Mailing-List: linux-hwmon@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 5 potential issues to consider: - [High] watchdog: macsmc_wdt: missing suspend/resume PM callbacks - [Medium] mfd: macsmc: apple_smc_probe() checks only NATJ for macsmc-wdt - [Medium] watchdog: macsmc_wdt: unsynchronized NATJ/NATi writes can force reset - [Medium] watchdog: macsmc_wdt: apple_smc_key_exists() causes 1s PIO timeout stalls - [Low] watchdog: macsmc_wdt uses obsolete __MODULE_STRING() and omits direct headers -- commit dd87f5854d512b3a6e66e9d3cd77fe418fb3e73a Author: Atharva Tiwari watchdog: add driver for apple smc This commit adds a watchdog driver for the Apple SMC on Intel Macs, supporting both newer OSWD and legacy NATJ/NATi SMC keys, and registers the platform device from macsmc-core. > diff --git a/drivers/mfd/macsmc-core.c b/drivers/mfd/macsmc-core.c > index b8905c834c448..1c14698285456 100644 > --- a/drivers/mfd/macsmc-core.c > +++ b/drivers/mfd/macsmc-core.c [ ... ] > @@ -147,6 +151,13 @@ int apple_smc_probe(struct device *dev, const struct= apple_smc_backend_ops *ops, > return ret; > } > =20 > + if (apple_smc_key_exists(smc, SMC_KEY(NATJ))) { > + ret =3D devm_mfd_add_devices(dev, -1, apple_smc_acpi_wdt, > + ARRAY_SIZE(apple_smc_acpi_wdt), NULL, 0, NULL); > + if (ret < 0) > + return ret; > + } > + > } else [Severity: Medium] Should this check also accept SMC_KEY(OSWD) and require SMC_KEY(NATi) alongside SMC_KEY(NATJ)? On newer Intel Macs that expose OSWD without the legacy NATJ key, apple_smc_probe() never registers macsmc-wdt. Conversely, on an SMC with NATJ but without OSWD or NATi, macsmc_wdt_probe() falls back to has_oswd =3D false and registers a watchdog whose operations fail with -EIO. Checking for OSWD or both NATJ and NATi in apple_smc_probe() and macsmc_wdt_probe() avoids both cases. [ ... ] > diff --git a/drivers/watchdog/macsmc_wdt.c b/drivers/watchdog/macsmc_wdt.c > new file mode 100644 > index 0000000000000..e2fc7f4e3e4b7 > --- /dev/null > +++ b/drivers/watchdog/macsmc_wdt.c > @@ -0,0 +1,158 @@ [ ... ] > +#include > +#include > +#include > + > +#define WATCHDOG_TIMEOUT 60 /* 60 sec default timeout */ > + > +static bool nowayout =3D WATCHDOG_NOWAYOUT; > +module_param(nowayout, bool, 0); > +MODULE_PARM_DESC(nowayout, "Watchdog cannot be stopped once started defa= ult=3D" > + __MODULE_STRING(WATCHDOG_NOWAYOUT) ")"); > + > +static int timeout =3D WATCHDOG_TIMEOUT; /* in secounds */ > +module_param(timeout, int, 0); > +MODULE_PARM_DESC(timeout, > + "Watchdog timeout in seconds. 1 <=3D timeout <=3D 255, default=3D" > + __MODULE_STRING(WATCHDOG_TIMEOUT) "."); [Severity: Low] Can __MODULE_STRING() be replaced with __stringify() here? It is marked obsolete and scheduled for removal in include/linux/module.h, and no other callers remain in the tree. The file also omits direct includes of linux/module.h and linux/stringify.h despite using module macros, and the nowayout MODULE_PARM_DESC() has an unmatched closing parenthesis before the end of the string. [ ... ] > + if (timeout =3D=3D 0) { > + ret =3D apple_smc_write_u8(drv->smc, SMC_KEY(NATJ), 0); > + if (ret < 0) > + return ret; > + } > + ret =3D apple_smc_write_u16(drv->smc, SMC_KEY(NATi), (u16)(timeout << = 8)); > + if (ret < 0) > + return ret; > + > + if (timeout !=3D 0) { > + ret =3D apple_smc_write_u8(drv->smc, SMC_KEY(NATJ), 2); > + if (ret < 0) > + return ret; > + } [Severity: Medium] Can concurrent stop and start/set_timeout calls interleave these NATJ and NATi writes into a forced reset? macsmc_wdt_probe() enables watchdog_stop_on_reboot(), which calls macsmc_wdt_stop() without wd_data->lock while userspace can still issue watchdog ioctls. Because apple_smc_write() only holds smc->mutex per key write, the two-key sequence can interleave: CPU0 (ioctl) CPU1 (reboot notifier) macsmc_wdt_set_timeout() watchdog_reboot_notifier() macsmc_wdt_write_timeout(t) macsmc_wdt_stop() write(NATi, t << 8) macsmc_wdt_write_timeout(0) write(NATJ, 0) write(NATi, 0) write(NATJ, 2) <-- NATi =3D=3D 0, NATJ =3D=3D 2: forced reset Leaving NATi =3D=3D 0 with NATJ =3D=3D 2 triggers an immediate forced resta= rt on legacy !has_oswd Macs. Serializing macsmc_wdt_write_timeout() and macsmc_wdt_ping() with a mutex in struct macsmc_wdt prevents this race. [ ... ] > + drv->smc =3D dev_get_drvdata(pdev->dev.parent); > + if (apple_smc_key_exists(drv->smc, SMC_KEY(OSWD))) > + drv->has_oswd =3D true; > + else > + drv->has_oswd =3D false; [Severity: Medium] Does probing a missing key via apple_smc_key_exists() stall for 1 second on PIO-based Intel Macs? On PIO Macs (!smc->is_mmio), apple_smc_get_key_info() dispatches to apple_smc_acpi_port_read(), which has no error-status check and only fails when apple_smc_acpi_port_wait() times out after SMC_TIMEOUT_MS (1000 ms). This deterministically stalls probe for 1 second while holding smc->mutex on every older PIO Mac without OSWD (and likewise for the NATJ check in apple_smc_probe() on PIO Macs without NATJ), blocking concurrent SMC accesses from sibling MFD drivers. [ ... ] > +static struct platform_driver macsmc_wdt_driver =3D { > + .probe =3D macsmc_wdt_probe, > + .driver =3D { > + .name =3D "macsmc-wdt", > + }, > +}; [Severity: High] Does macsmc_wdt_driver need suspend and resume PM callbacks to stop an active watchdog across system sleep? The watchdog core does not stop hardware watchdogs in watchdog_dev_suspend(), so an armed SMC watchdog (at most 255 seconds) will expire while the host CPU is suspended and force a hard reset. Conversely, if the SMC clears its watchdog keys across sleep, the lack of a resume callback leaves the hardware watchdog silently disabled after resume while WDOG_ACTIVE remains set. --=20 Sashiko AI review =C2=B7 https://sashiko.dev/#/patchset/20261204131619.5059= -1-atharvatiwarilinuxdev@gmail.com?part=3D3