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=1796122690; b=I87xb+vjabaPPlVbLmbX51Atn/XLBDWPhAZFaswRPwsh9UvkESd/eXOYpcrNzxi6bKgq Y9dotiTVraH//Az2TPwcEXRrooGtf0Q+EONss2hE9Gbr06AePCx4gb0Z+MFb5liZQWHwb QWpJheN4awj4D9JK1tVQ6JPEx+lLb01Wpp09i8bCAzKNVU6pvXBidHfvgrHT/+VRPjc78 u/HcwRJB9yWG06OsEzZzkwY43o6ef9e99bgRSYIYOpDJt6AqCq7YtjsLKZ+wxWOwnUwxC 5T+KOBTvCBtXpV2QmBFwmj6wCm9BlN4cwwQUck4vP9u8iNcaH/ZqamknoAYoDQVyhhw== ARC-Message-Signature: i=1; d=subspace.kernel.org; s=arc20261015; a=rsa-sha256; c=relaxed/relaxed; t=1796122690; 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=bSmfPF7oW7fA1FVgfIxizgN6vFA9Xh37YnDfJqXCdbI=; b=Ass+aa3tikHlixfuy8JaAmekqBTOSbAUs3z2Ob3xGDuqiEhhhKloTwt82kn00CzhylSU PxrqzCqxmn5Zd3MD8UP3rSInjK7RdBx5cMgcLk7H2zWUB0PT61i9pBCQ7cV29QAOnZJyZ +opeV9iyXJqMmM4IoG/L5snOpv3pHGh/Lrx9BbcMzH6wNA0N+AZx9yIKOjGjuh3nxbTIK 9RQcdpdFMA36n3BB9lFrXeEzEP55ka6Awg8Ghb3Fnvyn/hvr2eA/nX/lS9JpkspdYxm95 eecx0cbLlrhTIM2Ceg6ypys6iykqKBrMDuiz8wZGDpeMTS2pRpO7f77HmMqdnSSR8ag== 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=Vkz8CPfJ; 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 7CEEA606A320; Tue, 1 Dec 2026 10:58:10 +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=Vkz8CPfJ Received: by smtp.kernel.org (Postfix) with ESMTPSA id A8A2D1F00893; Tue, 1 Dec 2026 10:58:09 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=kernel.org; s=k20260515; t=1796122690; bh=bSmfPF7oW7fA1FVgfIxizgN6vFA9Xh37YnDfJqXCdbI=; h=Subject:From:To:Cc:Date:In-Reply-To:References; b=Vkz8CPfJSPbPzf3uk69DYIFPMg7HS9Vi6gyD402zxKdq4H2WyXtDyQyK+K6DSM3VX CAoH0Ob74Yd7towF1qlWtQ9Y28vaICRi/5K74ucOgh8q4eVU2trUHf4gVQRzLQSWtq UMByW4wzhlXyrED/XpxeBkjBgYBmqWJn7+RAmvgXXDDps5P1r406R1tCKFQWJgFhqA oIzCMEhhpF4PjqnbxmTLMHMLzh26FqXTd7/X1+poEz9bjgE8IyaJxvgE24c2a5VdS/ VJNoLZX9d2d4lYqbnyUHn232JM07G6vc6FD9Pu6lXZe4A2lrCPQYv/ily6c4BTb2Qy Y5PVcQh4iHjSA== Subject: Re: [PATCH net-next v3 1/2] net: phy: motorcomm: add led_brightness_set for YT8521 From: netdev-bot+sashiko@kernel.org To: amadeus@jmu.edu.cn Cc: Frank.Sae@motor-comm.com, andrew@lunn.ch, pabeni@redhat.com, kuba@kernel.org, edumazet@kernel.org, davem@davemloft.net, hkallweit1@gmail.com, linux-kernel@vger.kernel.org, netdev@vger.kernel.org Date: Tue, 01 Dec 2026 10:58:09 +0000 Message-ID: <179612268917.3146.3443593330313080426@kernel.org> In-Reply-To: <20261130100001.3346131-1-amadeus@jmu.edu.cn> References: <20261130100001.3346131-1-amadeus@jmu.edu.cn> X-sashiko-severity: High Content-Type: text/plain; charset="utf-8" Content-Transfer-Encoding: 8bit X-Mailing-List: linux-kernel@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: 1 (1) · Medium: 0 · 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). - [High] The new LED brightness path reaches the PHY's extended registers without holding the MDIO bus lock. Pre-existing issues: - [High] This problem wasn't introduced by this patch, but the existing LED hw_control callbacks have the same missing MDIO bus lock. -- net: phy: motorcomm: add led_brightness_set for YT8521 This commit adds a led_brightness_set callback for the YT8521 and YT8531 PHYs. The callback uses the force mode bits in the LED general config register (0xA00B). It also makes led_hw_control_set() clear force mode when switching to the netdev trigger. > diff --git a/drivers/net/phy/motorcomm.c b/drivers/net/phy/motorcomm.c > index a87e83fdf590c..e0c6477a53e44 100644 > --- a/drivers/net/phy/motorcomm.c > +++ b/drivers/net/phy/motorcomm.c [ ... ] > @@ -1775,6 +1779,44 @@ static int yt8531s_config_init(struct phy_device *phydev) > return phy_restore_page(phydev, old_page, ret); > } > > +static int yt8521_hw_led_on_set(struct phy_device *phydev, u8 index, > + bool value) > +{ > + int reg, val; > + u16 mask; > + > + val = ytphy_read_ext(phydev, YTPHY_LED_GENERAL_CFG_REG); > + if (val < 0) > + return val; > + > + mask = YTPHY_LED_FORCE_EN(index) | YTPHY_LED_FORCE_MODE(index); > + /* 0: force OFF, 1: force ON, same as the value */ > + reg = (val & ~mask) | (value << (index * 3)); > + if (value) > + reg |= YTPHY_LED_FORCE_EN(index); > + > + if (reg == val) > + return 0; > + > + return ytphy_write_ext(phydev, YTPHY_LED_GENERAL_CFG_REG, reg); > +} > + > +static int yt8521_led_brightness_set(struct phy_device *phydev, u8 index, > + enum led_brightness value) > +{ > + int ret; > + > + if (index >= YT8521_MAX_LEDS) > + return -EINVAL; > + > + /* clear HW LED setup */ > + ret = ytphy_write_ext(phydev, YT8521_LED0_CFG_REG + index, 0); > + if (ret < 0) > + return ret; > + > + return yt8521_hw_led_on_set(phydev, index, (value != LED_OFF)); > +} [Severity: High] Is the MDIO bus lock held on this path? ytphy_read_ext() and ytphy_write_ext() are both documented with: * NOTE:The caller must have taken the MDIO bus lock. However, phy_led_set_brightness() in drivers/net/phy/phy_device.c only takes phydev->lock before it calls the driver: mutex_lock(&phydev->lock); err = phydev->drv->led_brightness_set(phydev, phyled->index, value); The call chain looks like this: phy_led_set_brightness() yt8521_led_brightness_set() ytphy_write_ext(phydev, YT8521_LED0_CFG_REG + index, 0) yt8521_hw_led_on_set() ytphy_read_ext(phydev, YTPHY_LED_GENERAL_CFG_REG) ytphy_write_ext(phydev, YTPHY_LED_GENERAL_CFG_REG, reg) __phy_read() / __phy_write() __mdiobus_read() / __mdiobus_write() lockdep_assert_held_once(&bus->mdio_lock); With CONFIG_LOCKDEP, wouldn't the first brightness change hit this assertion? That change can come from sysfs or from a software trigger such as heartbeat. Without the bus lock, the 0x1E page select and 0x1F data pairs here are not serialized against code that holds only the bus lock. That includes phy_mii_ioctl(), other devices on the same MDIO bus, and the ytphy_*_ext_with_lock() callers in suspend/resume. Could the page select change between the select and the data access? The write would then land in a different extended register, for example 0xA000 or the WoL config. A concurrent locked modify of 0xA00B could also be lost between the read and the write in yt8521_hw_led_on_set(). The new yt8521_hw_led_on_set() call in yt8521_led_hw_control_set() has the same problem, because phy_led_hw_control_set() also holds only phydev->lock. Would it work to take phy_lock_mdio_bus() once around the LEDx_CFG clear and the GENERAL_CFG read-modify-write? The later commit "net: phy: motorcomm: add missing trigger link for YT8521" only changes yt8521_led_hw_control_get(), so it does not fix this. > @@ -1801,10 +1843,15 @@ static int yt8521_led_hw_control_set(struct phy_device *phydev, u8 index, > unsigned long rules) > { > u16 val = 0; > + int ret; > > if (index >= YT8521_MAX_LEDS) > return -EINVAL; > > + ret = yt8521_hw_led_on_set(phydev, index, false); > + if (ret < 0) > + return ret; > + [Severity: High] This is a pre-existing issue and was not introduced by this patch. The existing LED hw_control callbacks also access the extended registers without the MDIO bus lock. The end of yt8521_led_hw_control_set() does: return ytphy_write_ext(phydev, YT8521_LED0_CFG_REG + index, val); and yt8521_led_hw_control_get() does: val = ytphy_read_ext(phydev, YT8521_LED0_CFG_REG + index); Both run with only phydev->lock held, taken by phy_led_hw_control_set() and phy_led_hw_control_get(). The netdev trigger path therefore has the same lockdep assertion and the same page select/data race. This patch copies that unlocked pattern into the new brightness path. If the locking gets fixed here, should the bus lock cover all of yt8521_led_hw_control_set(), including this final write, and also yt8521_led_hw_control_get()? [ ... ] -- Sashiko AI review · https://netdev-ai.bots.linux.dev/sashiko/#/patchset/20261130100001.3346131-1-amadeus%40jmu.edu.cn