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=1796391164; b=ZH16uklZFyEWnZLAozDBbZMT5e9zA4KClPD6aDuD38q9vfWwotLITirw8gqoKIujxiFq yEm8K9tED7o073wAAf4VfZ04pkMalN/AXcB2tPB9PUjJYutMFfp/RFrjypk6088JVpaYY /U3R5u1f/XK9wAXZZ9KbegN6CoABoJpBf35XGVzRk9+44TgQY3QN5ub/ZXfcKzux2TXaQ felC/m+nv9SZ+cEd/8QPURxGktFFjcmOmRKD0VJNfzGZov8BbbDs9Ir2LN57xnylzdBjx hEiEwEbyK6GhimGxpaccgNQP7F4deOvdie9njigzwpLqckWOGWsoi6aYQlBLTB225BQ== ARC-Message-Signature: i=1; d=subspace.kernel.org; s=arc20261015; a=rsa-sha256; c=relaxed/relaxed; t=1796391164; h=Received:DKIM-Signature:Message-ID:From:Subject:Reply-To:To:Cc: In-Reply-To:References:Content-Type:Content-Transfer-Encoding:Date; bh=mJSj0v5SgnM9pQ7+7eI6hsZyW9i97aPFBYUhBm/4LPY=; b=Mh+VZAMjkOHsfS/rJ3O6zKCI+rw4szZ1p4e7tst1G3KFQxUHkuIhyqrQXS2ZDV/+KiKw aTaJyo7o2L8dwPbh5p/NeQD9r6d5gkGlCTUWnIL58wGYldmRzlA7HS942tWy7Nqa9OqYp hhuj5hQA6LgvWIzPdrMU7z/MvZo7Sa4wm2vY7hNz2WwyRIFJTDqofyp0Gg4d0daSPLMh1 +a2M0XhwXNSfH7tPTitegFzOroXQm5x25+BOfQJhmQl7CnVUNJWkC7wk56CBzml9G3Rbj tvp5ZXXr2JLVJvBVJKVUBFLjq6Dw5wAV66zHa+vDtVWO6+OIv+Md+xtpWM59nB6Zy0Q== 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=eZkp9F+A; 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 50560606A322; Fri, 4 Dec 2026 13:32:44 +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=eZkp9F+A Received: by smtp.kernel.org (Postfix) with ESMTPSA id 57BA41F000CE; Fri, 4 Dec 2026 13:32:43 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=kernel.org; s=k20260515; t=1796391164; bh=mJSj0v5SgnM9pQ7+7eI6hsZyW9i97aPFBYUhBm/4LPY=; h=From:Subject:Reply-To:To:Cc:In-Reply-To:References:Date; b=eZkp9F+AEHxtyVhAP7EPr/muG2O8wsV5SOCqIVHl8nQ8NX/C+sF3WJFedMuROkiBP R+MfvL4VFbyukmw43/uAXgTnP+7SkKfWfkRW2/94Mfu5fdYSO/Vk7Cpy6GZyHRKMHm gde7IIyCPrc2AiAZbt5jDkjzsC0lYZCqJi1qM/QFYuzWIkjTz/+WocdweGiyStdSUI JCm+qeQHvldE2z5K66GCmjfvtkDyVs4zVQ98JidoksP9uaGXRr03kojhuRgT8acC0s T5sjmwWx5uatiuySoeqOF4R/If3Fl3rT0jQcZhiYqzaEfpJZLI6OLTHTO3Uu7CJZrQ 6DvgaOSqVPNvw== Message-ID: From: sashiko-bot@kernel.org Subject: Re: [PATCH v2 4/4] leds: Add driver for disk leds in synology devices Reply-To: sashiko-reviews@lists.linux.dev To: "Markus Probst" Cc: linux-leds@vger.kernel.org, devicetree@vger.kernel.org, robh@kernel.org, conor+dt@kernel.org, lee@kernel.org, ojeda@kernel.org, gary@garyguo.net In-Reply-To: <20261204-synology_disk_leds-v2-4-12815785ff8b@posteo.de> References: <20261204-synology_disk_leds-v2-0-12815785ff8b@posteo.de> <20261204-synology_disk_leds-v2-4-12815785ff8b@posteo.de> Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: quoted-printable Date: Fri, 04 Dec 2026 13:32:42 +0000 X-Mailing-List: linux-leds@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] leds: synology_disk: AB-BA deadlock and lockdep violation in update_modes() - [Medium] leds: synology_disk: unused DIM1 register constants fail CONFIG_WERROR builds - [Medium] leds: synology_disk: stale brightness after blink_set() breaks multi_intensity - [Medium] leds: synology_disk: premature delay and blink state mutation on SMBus error - [Low] leds: synology_disk: broken rustdoc link to nonexistent LedAddress symbol -- commit 060d1125420b5346ac2845d99faa8ee654c4996c Author: Markus Probst leds: Add driver for disk leds in synology devices This commit adds a Rust I2C multicolor LED driver for the ATmega1608 disk LED controller used in Synology NAS devices, along with Kconfig, Makefile, and MAINTAINERS entries. > diff --git a/drivers/leds/leds_synology_disk.rs b/drivers/leds/leds_synol= ogy_disk.rs > new file mode 100644 > index 0000000000000..6ae60bc89cac8 > --- /dev/null > +++ b/drivers/leds/leds_synology_disk.rs [ ... ] > +//! The controller has 6 8-bit i2c registers for led modes. See [`LedAdd= ress`]. [Severity: Low] This rustdoc link points to LedAddress, which does not exist in this module and triggers a broken_intra_doc_links warning. Should this reference Modes or LedAddressData instead? [ ... ] > + DIM0_DELAY: u8 @ 0x02; > + DIM0_BRIGHTNESS: u8 @ 0x03; > + DIM1_DELAY: u8 @ 0x04; > + DIM1_BRIGHTNESS: u8 @ 0x05; [Severity: Medium] Will DIM1_DELAY and DIM1_BRIGHTNESS break builds with CONFIG_WERROR=3Dy or W=3De? The register! macro expands these into private const items without #[allow(dead_code)], and neither constant is referenced in the driver. Adding #[expect(dead_code)] (as done on LedMode::Dim1) or removing them would avoid dead_code warnings becoming build errors. [ ... ] > + fn brightness_set<'bound>( > + self: &led::MultiColorDevice<'bound, Self>, > + brightness: u32, > + ) -> Result<()> { > + let mut blink =3D self.blink.lock(); > + > + if brightness =3D=3D 0 { > + *blink =3D false; > + } > + > + self.update_modes(|subled_info| { > + if subled_info.brightness() =3D=3D 0 { > + LedMode::Off > + } else if *blink { > + LedMode::Dim0 > + } else { > + LedMode::On > + } > + })?; > + > + Ok(()) > + } > + > + fn blink_set<'bound>( > + self: &led::MultiColorDevice<'bound, Self>, > + delay_on: &mut usize, > + delay_off: &mut usize, > + ) -> Result<()> { > + let mut blink =3D self.blink.lock(); > + if *delay_on =3D=3D 0 && *delay_off !=3D 0 { > + *blink =3D false; > + self.update_modes(|_subled_info| LedMode::Off)?; > + return Ok(()); > + } > + if *delay_off =3D=3D 0 && *delay_on !=3D 0 { > + *blink =3D false; > + self.update_modes(|subled_info| { > + if subled_info.intensity() =3D=3D 0 { > + LedMode::Off > + } else { > + LedMode::On > + } > + })?; > + return Ok(()); > + } > + > + *delay_on =3D 90; > + *delay_off =3D 90; > + > + self.update_modes(|subled_info| { > + if subled_info.intensity() =3D=3D 0 { > + LedMode::Off > + } else { > + LedMode::Dim0 > + } > + })?; > + *blink =3D true; > + > + Ok(()) > + } [Severity: Medium] Can writing multi_intensity cancel hardware blinking and turn the LED off when blinking starts from brightness 0? After probe (or after switching triggers in __led_trigger_set()), led_cdev->brightness is 0. When blink_set() enables hardware blinking and returns Ok(()), led_blink_setup() leaves LED_BLINK_SW clear and does not update led_cdev->brightness. A later sysfs write to multi_intensity then re-applies that stale brightness: drivers/leds/led-class-multicolor.c:multi_intensity_store() { ... if (!test_bit(LED_BLINK_SW, &led_cdev->work_flags)) led_set_brightness(led_cdev, led_cdev->brightness); ... } That calls brightness_set(0), which clears *blink and turns all subleds off. The same desynchronization happens in the delay_on =3D=3D 0 and delay_off =3D=3D 0 branches above, since returning Ok(()) without updating led_cdev->brightness leaves subsequent multi_intensity writes replaying the old on/off state. [Severity: Medium] Should *delay_on and *delay_off in blink_set() only be overwritten after update_modes() succeeds? When blink_set() returns an error, led_blink_setup() falls back to led_set_software_blink(led_cdev, *delay_on, *delay_off). Setting both to 90 before the fallible SMBus write discards the caller's requested delays (and the 500 ms default when both were 0), driving a 90 ms software blink timer onto an already failing I2C bus. Similarly, clearing *blink =3D false before update_modes()? in brightness_set() and the two zero-delay branches of blink_set() leaves the cached blink flag out of sync with the hardware registers if the SMBus write fails. [ ... ] > + fn update_modes LedMode>( > + self: &led::MultiColorDevice<'_, Self>, > + mut func: F, > + ) -> Result<()> { > + let mut guards =3D core::array::from_fn::<_, LED_ADDRESSES, _>(|= _| None); > + > + for (subled, subled_info) in self.subleds.iter().zip(self.subled= s()) { > + let (_, goal, _) =3D guards[subled.addr.addr.index()].get_or= _insert_with(|| { > + let guard =3D subled.addr.data.lock(); > + (subled.addr.addr, *guard, guard) > + }); > + let mode =3D (func)(subled_info); > + > + *goal =3D match *subled.id { > + 0 =3D> goal.with_led1(mode), > + 1 =3D> goal.with_led2(mode), > + 2 =3D> goal.with_led3(mode), > + 3 =3D> goal.with_led4(mode), > + _ =3D> unreachable!(), > + }; > + } > + > + let io =3D self.client.smbus_io(); > + for (addr, goal, mut current) in guards.into_iter().flatten() { > + if goal !=3D *current { > + io.try_write(addr, goal).inspect_err(|err| { > + dev_err!( > + self.client.as_ref(), > + "failed to write {:#2x}: {err:?}\n", > + addr.offset() > + ); > + })?; > + *current =3D goal; > + } > + } > + Ok(()) > + } [Severity: High] Can update_modes() cause an ABBA deadlock and trigger a lockdep recursive locking splat when a multicolor LED spans two mode registers? probe() stores subleds in raw DT child order without sorting by register index, and update_modes() holds every acquired LedAddressData::data mutex simultaneously across the blocking SMBus writes. Because LED callbacks can run concurrently (for example led_delay_on_store() calling led_blink_set() synchronously in sysfs context while leds_wq runs set_brightness_delayed()), two LEDs referencing the same two registers in opposite DT order deadlock: CPU0 CPU1 ---- ---- lock(&addrs[0].data) lock(&addrs[1].data) lock(&addrs[1].data) lock(&addrs[0].data) *** DEADLOCK *** CPU0: led_delay_on_store() -> led_blink_set() -> update_modes() CPU1: set_brightness_delayed() -> brightness_set() -> update_modes() In addition, init() creates all six mutexes with a single new_mutex!() call in a loop, so they share one static lockdep class; even a single multicolor LED spanning two registers will trigger a lockdep recursive locking warning on the second lock(). Since each register is written in an independent SMBus transfer, using a single shared Mutex<[Modes; LED_ADDRESSES]> (or locking and writing one register at a time) avoids the deadlock, the lockdep warning, and holding multiple register locks across blocking I/O. --=20 Sashiko AI review =C2=B7 https://sashiko.dev/#/patchset/20261204-synology_d= isk_leds-v2-0-12815785ff8b@posteo.de?part=3D4