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=1796225916; b=sONbQxZYFwCtFGKLMcBp6tJCf31qZjd0g+BWuWO/27K31fYrJIR6AKQqiYByt9VEW8UV 0x+lz34CoFDTDORBufmgKsWZHoACFawrNcx+tf0uVgFPSvW+HRjIRUVnkvaDKowWczPGg zdI0rNT7qTfMuhtm9dcMMp0m+Eq4ZUHrgbO6lyx15r+Bj12xPqiqUA+Pi2WsRQ47rGt0W qqxM4p7l3oyuJibWq5E6xFw22vgHFZMjPCELHBVYhxL9jYcVp+CBQiCVXe7XxmtmhRWmb 2RG+KqbtY1GeDJB4H+Sz3y7eFNSTq3XasgQCDrdImyeeSRw9aPo8R4RddHbZMjVHaLQ== ARC-Message-Signature: i=1; d=subspace.kernel.org; s=arc20261015; a=rsa-sha256; c=relaxed/relaxed; t=1796225916; h=Received:DKIM-Signature:Message-ID:From:Subject:Reply-To:To:Cc: In-Reply-To:References:Content-Type:Content-Transfer-Encoding:Date; bh=4D2wKmf3Re4a2rHUHpFLFsUDPEp+F7zHupI1r5lQzmw=; b=26GpjGcKUKFal0HVgz2A0XyuoYlNMm813kaBtUb6SR/6ZDDnpFqzucKsTCzSfK6p7d73 vo4lJF8csnis/tejt2IIXAXJLyulgyUWrOJoXlWd06ArTIDUyIRkIGDsKsTfZq0/H4NoN y7iFvAcX53hzy9fpnZJhqvm6YeVoGKgQ720TzbEOwPBSvFjRQleniYvFjG1evXEbDuhp4 qPmFB7NTeiOii4PFOECfe/nSENe8uBdL2L39JnDlTdkmVdb4xzd+YpBqTZKXY1M0zVWfk X7VgmreWrpPqgvW85dbsmVmEPL58tDbLtpw7GslgQU8cxq5hbme6mGuBBTH8RVl5BJw== 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=hWA3Gf4p; 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 C2F64606A33D; Wed, 2 Dec 2026 15:38:36 +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=hWA3Gf4p Received: by smtp.kernel.org (Postfix) with ESMTPSA id 07DF51F00931; Wed, 2 Dec 2026 15:38:35 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=kernel.org; s=k20260515; t=1796225916; bh=4D2wKmf3Re4a2rHUHpFLFsUDPEp+F7zHupI1r5lQzmw=; h=From:Subject:Reply-To:To:Cc:In-Reply-To:References:Date; b=hWA3Gf4pIadJD/SvMqdUtXppO4coUiO9L3qe3sBv7GNqZfruhDn02litcWhD8F6Lz jitQm8HCiiSWwf4tCkCcfWMlbfhkQdh/+dKdwGrwNLzZZRtBa2ioW/YnujhB2fUL4q wcW+z/kW905lvWxnMoobd3nGwp8WxA845hAuKM8+GdpzVMkqMnar3pTHz0c+wxBYL/ E6cZFzn4pz4bUhqXmoNCLdfpHsmzrFEGGw0mh7nfuYN8OoRTfBnwFt+5jSpNGYKnnF F3d049Sv70RSzO9xllKUI/vIKlXeoanbek3hR2xwEvP3HdgBiRav3/0adAkgE7CCkl O+PUucnzzTJsQ== Message-ID: From: sashiko-bot@kernel.org Subject: Re: [PATCH 2/2] 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: <20261202-synology_disk_leds-v1-2-53249fd3a2ad@posteo.de> References: <20261202-synology_disk_leds-v1-0-53249fd3a2ad@posteo.de> <20261202-synology_disk_leds-v1-2-53249fd3a2ad@posteo.de> Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: quoted-printable Date: Wed, 02 Dec 2026 15:38:35 +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: - [Medium] leds: synology_disk: missing I2C=3Dy Kconfig dependency breaks modular I2C build - [Medium] leds: synology_disk: uninitialized mode registers desync cache in probe() - [Medium] leds: synology_disk: premature register clear in unbind() before LED drop - [Medium] leds: synology_disk: multi_intensity write cancels hardware blink_set() - [Low] leds: synology_disk: unsorted Makefile entry and non-standard commit subject -- commit 89384e625f4f23cc76bff85dcf0243a699d6bc61 Author: Markus Probst leds: add driver for disk leds in synology devices This commit adds a Rust I2C LED driver for the Atmega1608 disk LED controller used in Synology NAS devices. > diff --git a/drivers/leds/Kconfig b/drivers/leds/Kconfig > index 7ec2c8d785426..34cf2a3f0baca 100644 > --- a/drivers/leds/Kconfig > +++ b/drivers/leds/Kconfig > @@ -332,6 +332,15 @@ config LEDS_WRAP > help > This option enables support for the PCEngines WRAP programmable LEDs. > =20 > +config LEDS_SYNOLOGY_DISK > + tristate "LED Support for disk leds used in Synology devices" > + depends on LEDS_CLASS && LEDS_CLASS_MULTICOLOR > + depends on I2C [Severity: Medium] Should this depend on I2C=3Dy rather than I2C? The Rust I2C abstractions in rust/kernel/lib.rs are only built when CONFIG_I2C=3Dy: rust/kernel/lib.rs { ... #[cfg(CONFIG_I2C =3D "y")] pub mod i2c; ... } When CONFIG_I2C=3Dm and CONFIG_LEDS_SYNOLOGY_DISK=3Dm, compiling this driver fails with unresolved imports for kernel::i2c and kernel::module_i2c_driver!. > diff --git a/drivers/leds/Makefile b/drivers/leds/Makefile > index 4d4b089156e24..466549f65f9ca 100644 > --- a/drivers/leds/Makefile > +++ b/drivers/leds/Makefile > @@ -101,6 +101,7 @@ obj-$(CONFIG_LEDS_UPBOARD) +=3D leds-upboard.o > obj-$(CONFIG_LEDS_WM831X_STATUS) +=3D leds-wm831x-status.o > obj-$(CONFIG_LEDS_WM8350) +=3D leds-wm8350.o > obj-$(CONFIG_LEDS_WRAP) +=3D leds-wrap.o > +obj-$(CONFIG_LEDS_SYNOLOGY_DISK) +=3D leds_synology_disk.o [Severity: Low] This isn't a bug, but the LED Platform Drivers section of drivers/leds/Makefile asks to be kept sorted alphabetically (between CONFIG_LEDS_SUNFIRE and CONFIG_LEDS_SYSCON). Also, LED subsystem commit subjects normally follow the "leds: : " convention. > diff --git a/drivers/leds/leds_synology_disk.rs b/drivers/leds/leds_synol= ogy_disk.rs > new file mode 100644 > index 0000000000000..1f339e2e429e5 > --- /dev/null > +++ b/drivers/leds/leds_synology_disk.rs [ ... ] > + fn probe<'bound>( > + idev: &'bound I2cClient>, > + _id_info: Option<&'bound Self::IdInfo>, > + ) -> impl PinInit, Error> + 'bound { [ ... ] > + let addr =3D Arc::new( > + KBox::pin_slice::<_, _, Error, Error>( > + |index| { > + try_pin_init!(LedAddressData { > + addr: LedAddress::VALUES[index], > + data <- new_mutex!(0u8), > + }) > + }, > + LedAddress::VALUES.len(), > + GFP_KERNEL, > + )?, > + GFP_KERNEL, > + )?; [ ... ] > + idev.smbus_io() > + .try_write8(0, 0x01) > + .inspect_err(|err| dev_err!(dev, "unable to remove led mask:= {err:?}\n"))?; > + > + Ok(SynologyDiskLedDriver { _leds: leds }) > + } [Severity: Medium] Can LedAddressData::data start out of sync with the hardware mode registers 0x06..=3D0x0B in probe()? LedAddressData::data is initialized to 0u8, and probe() unmasks register 0x01 without clearing or reading registers 0x06..=3D0x0B. If the bootloader or a previous boot left non-zero mode bits in 0x06..=3D0x0B, those physical LEDs turn on or blink as soon as 0x01 is unmasked while their LED class devices report brightness 0. Calling brightness_set(0) then cannot turn them off because update_modes() skips the SMBus write when goal =3D=3D *current (0 =3D=3D 0). > + > + fn unbind<'bound>(dev: &'bound I2cClient>, _this: Pin<&Self= ::Data<'bound>>) { > + let _ =3D dev > + .smbus_io() > + .try_write8(1, 0x01) > + .inspect_err(|err| dev_err!(dev.as_ref(), "unable to set led= mask: {err:?}\n")); > + > + for addr in LedAddress::VALUES { > + let _ =3D dev > + .smbus_io() > + .try_write8(0, addr as usize) > + .inspect_err(|err| { > + dev_err!( > + dev.as_ref(), > + "Unable to turn off leds at address {:#2x}: {err= :?}\n", > + (addr as u8) > + ) > + }); > + } > + } > +} [Severity: Medium] Does unbind() clear hardware registers before _leds are unregistered? In the Rust driver lifecycle, i2c::Adapter::remove_callback() runs unbind() before Registration::post_unbind_callback() drops SynologyDiskLedDriver and its _leds vector. While unbind() writes registers 0x01 and 0x06..=3D0x0B without locking or updating LedAddressData::data, active triggers or sysfs writes can still call update_modes() concurrently. Then, when post_unbind_callback() drops each MultiColorDevice, led_classdev_unregister() calls brightness_set(0) -> update_modes(), which compares against the stale pre-unbind cache in LedAddressData::data and writes stale non-zero bits of sibling LEDs sharing a register back to hardware. [ ... ] > +#[vtable] > +impl led::LedOps for Led<'_> { > + type Mode =3D led::MultiColor; > + const BLOCKING: bool =3D true; > + const MAX_BRIGHTNESS: u32 =3D 1; > + > + 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] Does writing to multi_intensity while hardware blinking is active turn the LED off instead of changing its color? When blink_set() enables hardware blinking (for example when the timer trigger is attached), led_blink_setup() does not set LED_BLINK_SW and leaves led_cdev->brightness at 0. A later write to multi_intensity runs: 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); ... } Because led_cdev->brightness is 0, this calls Led::brightness_set(0), which sets *blink =3D false and turns all sub-LEDs off. Likewise, handling *delay_on =3D=3D 0 or *delay_off =3D=3D 0 directly in blink_set() instead of letting led_set_software_blink() update led_cdev->brightness leaves led_cdev->brightness stale when multi_intensity is written later. --=20 Sashiko AI review =C2=B7 https://sashiko.dev/#/patchset/20261202-synology_d= isk_leds-v1-0-53249fd3a2ad@posteo.de?part=3D2