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=1796391296; b=uMLzcKi619rMg8HSFcGsNfBtnWMBwhgbztLTeBDFsbuclJfDpAGDPkgnnmouEBHfXPj6 BKSs4syQfAaLCuHcqhPjFbxLiZbECgqvpj4qE6SuYdxy934NWqn52C3ZtH8Fh/H77nfSV o98GU+WjPpGCAxmH33X+XviHHCehmfYoo8r1LrB3ys9Kefy6igoyI2hT7Sy82HcTop3of hC4IvftcWA4dqwaP4QQVL1JOhy1lQab4FMmQOVst9HhWA22+dMPaVe2svnAe3vUyvRYrT xN4VYDexY8JsBvBbwnhKuRHblNfYWFofAGz4nZX9zMftnzURJjIwWl0KGR/M+cL4xRw== ARC-Message-Signature: i=1; d=subspace.kernel.org; s=arc20261015; a=rsa-sha256; c=relaxed/relaxed; t=1796391296; h=Received:DKIM-Signature:Message-ID:From:Subject:Reply-To:To:Cc: In-Reply-To:References:Content-Type:Content-Transfer-Encoding:Date; bh=3eywzUbkedQCkPpoMWon2adCecjsAI6euTjQ4EbhUn4=; b=ABUGVLIiVf+McwH+4hOkkpxFw9g0g9tdrRmEiTDB+UYpzG4CmaYEXN1t/eXV3Ut+6V6r Htdlp/WVBcoB8g6E5fboTkCAn/f479m6c6ofoPh47B02wBYyU6LuZ1iykQXpzv85FTKrs qi4EVtbUPynI8jbiZpDN+KG/SecapSo0TFHEdFSylBqkPUopePVHsOVrJ+Lqxt3Xzie0B SxzpBeOzQSPqt9hxfC5xUtXiErBiHaJddVxYWP/Gbtodd0YYoNEmuwe+vo0MvfAV9r2s9 wN1XtPz5Fag8gyWANF6abLX3Fp+I2KOhSYEUMkkT8Y/XM+mci4/jSF/jBLnviN1oFeQ== 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="K/OpMH1u"; 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 DE08D606A681; Fri, 4 Dec 2026 13:34:56 +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=K/OpMH1u Received: by smtp.kernel.org (Postfix) with ESMTPSA id 2717A1F00A08; Fri, 4 Dec 2026 13:34:56 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=kernel.org; s=k20260515; t=1796391296; bh=3eywzUbkedQCkPpoMWon2adCecjsAI6euTjQ4EbhUn4=; h=From:Subject:Reply-To:To:Cc:In-Reply-To:References:Date; b=K/OpMH1uB90rQdLQQutSzGQIYlRFTd7aq5UCxgrSGsQHYP/nJn3Sahr4ueybxxMI+ aC8DdnxkZbSidK8uksNhF5f7O7nXgt6jYnff7tz2qYtS1saPWbvc6YQKQBQIJsfBip TiT0m0wzjoQTROpqCWXMGRWXSL1nH7aZqULJeZeWFwLXDNvE4o/yfKoH9Gx0F7n8Wp ILiU4OueYs7K2FxMFgMmjRiP6k3+kkex96qjupn7sKbukYd+b/kJnWYd9ylIUgBRP7 VFxNOSgeSH393u1hOS2qI0PwtOihZ4E4X6KaqIng9RniUE3wi9D93faaWMRwf/EcsX MmZaFBIMJM/jw== Message-ID: From: sashiko-bot@kernel.org Subject: Re: [PATCH v19 2/2] platform: Add initial synology microp driver 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_microp_initial-v19-2-33fd992bf049@posteo.de> References: <20261204-synology_microp_initial-v19-0-33fd992bf049@posteo.de> <20261204-synology_microp_initial-v19-2-33fd992bf049@posteo.de> Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: quoted-printable Date: Fri, 04 Dec 2026 13:34:55 +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 8 potential issues to consider: - [High] platform: synology_microp: unbounded serdev wait in Command::write() - [Medium] platform/synology_microp: Kconfig allows modular LEDS_CLASS breaking Rust build - [Medium] platform/synology_microp: Command::write() ignores short writes from write_all() - [Medium] platform/synology_microp: blink state and delays mutated before write succeeds - [Medium] platform/synology_microp: multi_intensity turns off blinking status LED - [Medium] rust: led: aliasing &mut usize in blink_set_callback() from ledtrig-timer - [Low] platform/synology_microp: deprecated vendor prefix and non-standard LED name - [Low] platform/synology_microp: commit message omits supported eSATA LED -- commit 5e1e8cacbaf185da4acf3731fa20dd161b67fc7a Author: Markus Probst platform: Add initial synology microp driver This commit adds an initial Rust serdev driver for the Synology NAS microcontroller, exposing its power, status, alert, USB, and eSATA LEDs through the kernel LED class abstractions. > It currently only supports controlling of the power led, status led, alert > led and usb led. [Severity: Low] This isn't a bug, but the commit message omits the eSATA LED, which this patch also implements for synology,ds710p-microp. [ ... ] > diff --git a/drivers/platform/synology_microp/Kconfig b/drivers/platform/= synology_microp/Kconfig > new file mode 100644 > index 0000000000000..8878cfb7bcddb > --- /dev/null > +++ b/drivers/platform/synology_microp/Kconfig > @@ -0,0 +1,13 @@ > +# SPDX-License-Identifier: GPL-2.0 > + > +config SYNOLOGY_MICROP > + tristate "Synology Microp driver" > + depends on LEDS_CLASS && LEDS_CLASS_MULTICOLOR [Severity: Medium] Can this break the build when CONFIG_LEDS_CLASS=3Dm or CONFIG_LEDS_CLASS_MULTICOLOR=3Dm with CONFIG_SYNOLOGY_MICROP=3Dm? Both LEDS_CLASS and LEDS_CLASS_MULTICOLOR are tristate, but rust/kernel/lib.rs gates pub mod led on CONFIG_LEDS_CLASS=3D"y" and rust/kernel/led.rs gates mod multicolor on CONFIG_LEDS_CLASS_MULTICOLOR=3D"y". In modular configs such as allmodconfig, the driver fails to compile with unresolved kernel::led imports. Changing the dependency to LEDS_CLASS=3Dy && LEDS_CLASS_MULTICOLOR=3Dy prevents the broken configuration. [ ... ] > diff --git a/drivers/platform/synology_microp/command.rs b/drivers/platfo= rm/synology_microp/command.rs > new file mode 100644 > index 0000000000000..490719490391c > --- /dev/null > +++ b/drivers/platform/synology_microp/command.rs > @@ -0,0 +1,54 @@ [ ... ] > +impl Command { > + pub(crate) fn write(self, dev: &serdev::Device) -> Result { > + dev.write_all( > + match self { [ ... ] > + Self::AlertLed(led::State::On) =3D> &[0x4C, 0x41, 0x31], > + Self::AlertLed(led::State::Blink) =3D> &[0x4C, 0x41, 0x3= 2], > + Self::AlertLed(led::State::Off) =3D> &[0x4C, 0x41, 0x33], > + > + Self::UsbLed(led::State::On) =3D> &[0x40], > + Self::UsbLed(led::State::Blink) =3D> &[0x41], > + Self::UsbLed(led::State::Off) =3D> &[0x42], > + > + Self::EsataLed(led::State::On) =3D> &[0x4C, 0x45, 0x31], > + Self::EsataLed(led::State::Blink) =3D> &[0x4C, 0x45, 0x3= 2], > + Self::EsataLed(led::State::Off) =3D> &[0x4C, 0x45, 0x33], > + }, > + 0, > + )?; [Severity: Medium] Can Command::write() silently treat a short write of a 3-byte AlertLed or EsataLed command as success? serdev::Device::write_all() wraps serdev_device_write(), which returns the positive partial byte count as Ok(written) if a signal interrupts the wait after at least one byte is accepted. Discarding that count leaves a truncated prefix on the serial line and releases serdev->write_lock, allowing subsequent LED commands to interleave and desynchronize the microcontroller parser. Checking that the returned count equals the slice length (and retrying or returning an error otherwise) avoids silent truncation. > + dev.wait_until_sent(0); [Severity: High] Can passing timeout 0 to dev.write_all() and dev.wait_until_sent() deadlock the global leds_wq workqueue when the parent UART is unbound or removed? Timeout 0 is translated to MAX_SCHEDULE_TIMEOUT in both serdev_device_write() and tty_wait_until_sent(). During UART removal, serial_core_unregister_port() marks the port UPF_DEAD before unregistering the serdev child, and PrivateData::drop() drops SynologyMicropDriver before calling serdev_device_close(): UART removal thread leds_wq kworker ------------------- --------------- serial_core_unregister_port() port->flags |=3D UPF_DEAD serial_core_remove_one_port() ... -> led_classdev_unregister() led_set_brightness(LED_OFF) flush_work(set_brightness_work) set_brightness_delayed() Command::write() uart_write() -> kfifo_in() __uart_start() (skips, UPF_DEAD) tty_wait_until_sent(tty, 0) <-- sleeps forever Because __uart_start() returns early on UPF_DEAD, the queued byte never drains and tty_wait_until_sent() sleeps indefinitely while the removal thread waits in flush_work(), wedging leds_wq and holding serial_core's port_mutex. The same unbounded wait applies to dev.write_all(..., 0) if the FIFO fills, or if an LED trigger fires while the parent UART is suspended. Passing finite timeouts to both dev.write_all() and dev.wait_until_sent() prevents the permanent hang. > diff --git a/drivers/platform/synology_microp/led.rs b/drivers/platform/s= ynology_microp/led.rs > new file mode 100644 > index 0000000000000..170e385548fc3 > --- /dev/null > +++ b/drivers/platform/synology_microp/led.rs > @@ -0,0 +1,300 @@ [ ... ] > + status <- led::DeviceBuilder::new() > + .color(led::Color::Multi) > + .name(c"synology:multicolor:status") [ ... ] > + .name(c"synology:green:esata") [Severity: Low] Should these LED names drop the synology: vendor prefix and use a standard LED_FUNCTION_* name instead of esata? Documentation/leds/leds-class.rst deprecates vendor prefixes in LED device names and expects the function part to come from include/dt-bindings/leds/common.h, which does not define esata. All five LEDs registered in Data::register() currently use the synology: prefix. [ ... ] > + fn blink_set<'bound>( > + self: &led::Device<'bound, Self>, > + delay_on: &mut usize, > + delay_off: &mut usize, > + ) -> Result<()> { [Severity: Medium] Does implementing LedOps::blink_set() here expose aliasing &mut usize undefined behavior in rust/kernel/led/? This driver adds the first in-tree implementations of LedOps::blink_set() (in LedHandler and StatusLedHandler), instantiating Adapter::blink_set_callback() in rust/kernel/led/normal.rs and rust/kernel/led/multicolor.rs. Both callbacks form unsafe { &mut *delay_on } and unsafe { &mut *delay_off } assuming exclusive access, but led_delay_on_store() and led_delay_off_store() in drivers/leds/trigger/ledtrig-timer.c pass &led_cdev->blink_delay_off and &led_cdev->blink_delay_on to led_blink_set() without locking. Two concurrent writes to delay_on (or a write racing with a sysfs read) create aliasing &mut usize references and data races on those fields before self.blink.lock() is acquired. > + let mut blink =3D self.blink.lock(); > + > + (self.command)(if *delay_on =3D=3D 0 && *delay_off !=3D 0 { > + *blink =3D false; > + > + State::Off > + } else if *delay_on !=3D 0 && *delay_off =3D=3D 0 { > + *blink =3D false; > + > + State::On > + } else { > + *blink =3D true; > + *delay_on =3D BLINK_DELAY.as_millis() as usize; > + *delay_off =3D BLINK_DELAY.as_millis() as usize; > + > + State::Blink > + }) > + .write(self.dev) > + } [Severity: Medium] Does mutating *blink, *delay_on, and *delay_off before .write(self.dev) succeeds corrupt software-blink fallback on write errors? If Command::write() fails (for example with -ERESTARTSYS), led_blink_setup() in drivers/leds/led-core.c falls back to led_set_software_blink() using the already-overwritten 167 ms delays instead of the requested or default delays. Because *blink was already set to true, each software-blink ON tick then calls brightness_set(1) and sends State::Blink instead of State::On. StatusLedHandler::blink_set() has the same issue, and both LedHandler::brightness_set() and StatusLedHandler::brightness_set() clear *blink before .write(self.dev) succeeds. Updating *blink and the delay out-parameters only after .write(self.dev)? returns Ok(()) keeps driver state in sync with the hardware. [ ... ] > + 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; > + } > + > + let amber_brightness =3D self.subleds()[1].brightness(); [ ... ] > + 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(); > + > + let amber_intensity =3D self.subleds()[1].intensity(); > + > + let (color, subled_intensity) =3D if amber_intensity =3D=3D 0 { > + (StatusLedColor::Green, self.subleds()[0].intensity()) > + } else { > + (StatusLedColor::Amber, amber_intensity) > + }; [Severity: Medium] Does writing multi_intensity turn off the status LED when hardware blinking was started from brightness 0? Data::register() leaves the status LED's initial brightness at 0 with Green intensity 1. When the timer trigger starts hardware blinking, StatusLedHandler::blink_set() uses the subled intensities to start blinking while led_cdev->brightness stays 0. If userspace then writes multi_intensity to switch the blinking color to amber, multi_intensity_store() calls led_set_brightness(led_cdev, 0), which runs brightness_set(0), clears *blink, and sends State::Off. --=20 Sashiko AI review =C2=B7 https://sashiko.dev/#/patchset/20261204-synology_m= icrop_initial-v19-0-33fd992bf049@posteo.de?part=3D2