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=1796460406; b=iRO4qX8eKjmkw0QL1CoOTTooHcHcL4HGzdxOico7cbrMHOs3w9Q1P/u3yPKPFbt8GVI3 /ohPbXePaNYj585mSiT24V6dSA6yORYE5VDZLcypIZvbR6MeNNO02fGTTN4XsCIriPQpE CCghpd+X4I9gg243SILLD2I0v8fXbMoppeeqZBjDNqp2pX7KcjAuliy4azv8dGI7y+/Jt wi0RIqxe9Gn8PAVbAVJlMGW0FIRogROOdIPIeiKfub5gnVN3kg+qCy90BtAbi8tq7iAaY 1Y/Yoaz0lClq+blk71VOIPH5HXnPeGInmQUFVgidUxK5Gv7wJyVdztRMO/GbWQFhbqw== ARC-Message-Signature: i=1; d=subspace.kernel.org; s=arc20261015; a=rsa-sha256; c=relaxed/relaxed; t=1796460406; h=Received:DKIM-Signature:Subject:From:To:Cc:Date:Message-ID: In-Reply-To:References:X-sashiko-severity:Content-Type: Content-Transfer-Encoding:MIME-Version; bh=aZWs10Lg4XaYeqoFiDPKbd2q4bopyjVoHIlJ7ldv6gM=; b=Eq8BrMtVHabYoQQPx4LncYaHBo5RAI7Iss/ih6WFqwlOZpHKZYLtsSc5XAAkNMEX5bks 3IEQ4PueWoca8xcIRFq9g2QRSnI86MMH3nuDioicSzgNEjh3+X3nq6Um1PwoYkne1U+HI gc6L0BE5mmwUGEEb3iucosAcVVS0hknn22RypEYIoPWVwbsyFt/FMdY9GE9XwwSrqOEA8 qOz9Z2Ov7zDtlYRxtYnZixGfuCcXuuWBt2a5WEksDoXmb7Fl4oUOWhoRHbbjOeGGShHxO QOh3UeteNRmi/d6BNiTNDAnzasv6Gqv/7iraKLnniVxeRb4x95gM0ywP0g5DIZmbFGQ== 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=JpFkBwBT; 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 66AC4606A322; Sat, 5 Dec 2026 08:46:46 +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=JpFkBwBT Received: by smtp.kernel.org (Postfix) with ESMTPSA id 344861F0092B; Sat, 5 Dec 2026 08:46:45 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=kernel.org; s=k20260515; t=1796460406; bh=aZWs10Lg4XaYeqoFiDPKbd2q4bopyjVoHIlJ7ldv6gM=; h=Subject:From:To:Cc:Date:In-Reply-To:References; b=JpFkBwBT2wb20xmNOMO9EUiy6eysqL1ymUAzpkKLTH5sNqBvEWnbtcz9sekcSWwbh +lVYaJCtGQ5wjh7MM2mJHehxi8dkpdiNPbzGssM/JEf2+PfFyiUTfh1tIlpey0oDGr kvgRMApJrh2sGzU/IfODW2+UWaH9cuDBn8OnTaIItvsPyZf+9AoTMTodMsMTUyrXAM BG6wu2JVFbNAaEvblh0I/rLaY/52+NLvaxYXYc1v07NseuCWR/5jwwDkL3/+/1GvR9 m8WmxrUPPF7tsMXR+aH8vbsVIrjvCD2imWEV06C/QsPhb1eTGu6P9cxR35jB04Pdui mcz5VkwpV9/mg== Subject: Re: [PATCH net-next v9 2/2] net: phy: dap8211r: add PHY LED control support From: netdev-bot+sashiko@kernel.org To: a.shimko.dev@gmail.com Cc: andrew@lunn.ch, hkallweit1@gmail.com, linux@armlinux.org.uk, davem@davemloft.net, edumazet@google.com, kuba@kernel.org, pabeni@redhat.com, robh@kernel.org, krzk+dt@kernel.org, conor+dt@kernel.org, maxime.chevallier@bootlin.com, pavel@ucw.cz, linux-kernel@vger.kernel.org, devicetree@vger.kernel.org, linux-leds@vger.kernel.org, netdev@vger.kernel.org Date: Sat, 05 Dec 2026 08:46:44 +0000 Message-ID: <179646040477.3146.15286579704926683101@kernel.org> In-Reply-To: <20261204081448.3199171-3-a.shimko.dev@gmail.com> References: <20261204081448.3199171-3-a.shimko.dev@gmail.com> X-sashiko-severity: Medium Content-Type: text/plain; charset="utf-8" Content-Transfer-Encoding: 8bit X-Mailing-List: netdev@vger.kernel.org List-Id: List-Post: List-Help: List-Subscribe: List-Unsubscribe: List-Owner: Precedence: list MIME-Version: 1.0 Thank you for your contribution! Sashiko AI review found 1 potential issue(s) to consider. Critical: 0 · High: 0 · Medium: 1 · Low: 0 If you believe none of the issues are legitimate, please reply to each issue of Medium severity or higher and explain why the AI is wrong. If any of them are legitimate and you plan to respin, please let patchwork know by including "pw-bot: cr" as a separate line at the end of your reply (one such reply per series is enough). - [Medium] dap8211r_led_hw_control_get() (drivers/net/phy/dap8211r.c:343) can return a set of hardware-control rules that the hardware is not… -- net: phy: dap8211r: add PHY LED control support This adds LED support for the three LEDs on the DAP8211R PHY. It adds a dap8211r_write_ext() helper and the led_brightness_set, led_hw_is_supported, led_hw_control_set and led_hw_control_get callbacks. Brightness is driven through the force mode bits in LED_COMCON, and hardware control is driven through the per-LED LED_x_CON rule registers. > diff --git a/drivers/net/phy/dap8211r.c b/drivers/net/phy/dap8211r.c > index 1fe20efd394d7..c6d18312c8c34 100644 > --- a/drivers/net/phy/dap8211r.c > +++ b/drivers/net/phy/dap8211r.c [ ... ] > @@ -114,6 +190,196 @@ static int dap8211r_modify_ext(struct phy_device *phydev, u16 reg, u16 mask, u16 > return ret; > } > [ ... ] > +static int dap8211r_led_hw_control_get(struct phy_device *phydev, u8 index, unsigned long *rules) > +{ > + u16 led_reg; > + int led_mode = 0; > + > + switch (index) { > + case DAP8211R_LED_ID_0 ... DAP8211R_LED_ID_2: > + led_reg = DAP8211R_LED_0_CON + index; > + break; > + default: > + return -EINVAL; > + } > + > + led_mode = dap8211r_read_ext(phydev, led_reg); > + if (led_mode < 0) > + return led_mode; [Severity: Medium] Can this return rules that the hardware is not actually following? This function only reads LED_x_CON. It never checks FORCE_EN(index) in DAP8211R_LED_COMCON. So when the LED is in force mode, it still returns 0 along with whatever LED_x_CON happens to hold. The led_hw_control_get description in include/linux/phy.h says the callback should "Set *@rules to how the HW is currently blinking" and return an error "if the current blinking cannot be represented in rules". The kernel-doc above this function also promises -EOPNOTSUPP for that case. netdev_trig_activate() trusts a 0 return: drivers/leds/trigger/ledtrig-netdev.c:netdev_trig_activate() { ... trigger_data->hw_control = true; set_device_name(trigger_data, name, strlen(name)); rc = led_cdev->hw_control_get(led_cdev, &mode); if (!rc) trigger_data->mode = mode; ... } On this path, set_device_name() skips set_baseline_state(). That means hw_control_set() is never called and FORCE_EN is never cleared. This sequence looks like it would hit the problem: echo none > trigger echo 1 > brightness dap8211r_led_brightness_set() LED_x_CON = 0, FORCE_EN | FORCE_ON set echo netdev > trigger (PHY attached) netdev_trig_activate() hw_control_get() reads LED_x_CON = 0, returns 0 with mode = 0 After that, the trigger reports hardware control with no rules, but the LED stays forced on. This lasts until a later mode, device_name or netdev event calls hw_control_set(). The same thing would happen if firmware or a bootloader leaves FORCE_EN set with non-zero LED_x_CON rules. Those rules would be reported as active while the LED is forced. Would it make sense to also read DAP8211R_LED_COMCON here and return -EOPNOTSUPP when FORCE_EN(index) is set? A related question is what happens when only half of a two-register update succeeds. In dap8211r_led_hw_control_set(): ret = dap8211r_write_ext(phydev, led_reg, led_mode); if (ret) return ret; return dap8211r_modify_ext(phydev, DAP8211R_LED_COMCON, DAP8211R_LED_FORCE_EN(index), 0); If the COMCON modify fails, the LED stays forced, but hw_control_get() reports the new rules. set_baseline_state() also ignores the return value of hw_control_set(). In dap8211r_led_brightness_set(), LED_x_CON is zeroed before the COMCON modify. If that modify fails, the LED has lost its rules and is not in force mode either. Should either of these restore the first register when the second access fails? -- Sashiko AI review · https://netdev-ai.bots.linux.dev/sashiko/#/patchset/20261204081448.3199171-1-a.shimko.dev%40gmail.com