Message ID | 20231119151258.20201-1-ansuelsmth@gmail.com |
---|---|
State | New |
Headers |
Return-Path: <linux-kernel-owner@vger.kernel.org> Delivered-To: ouuuleilei@gmail.com Received: by 2002:a59:9910:0:b0:403:3b70:6f57 with SMTP id i16csp1696594vqn; Sun, 19 Nov 2023 07:13:50 -0800 (PST) X-Google-Smtp-Source: AGHT+IH4CxHLq3WvVviymUyUf70qlry3iwC45bTVQEdEmRV1EK2NW+BBnaGoIw4Wu4KbiCwIYkLA X-Received: by 2002:a05:6a21:3a93:b0:148:f952:552b with SMTP id zv19-20020a056a213a9300b00148f952552bmr6526019pzb.51.1700406830552; Sun, 19 Nov 2023 07:13:50 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1700406830; cv=none; d=google.com; s=arc-20160816; b=0WUsmK0vXHd/rTjwh4s0T7FUhAafKLO3BcxdtpKwZE0A9tsORiS0vjNoiEarGPUgIa 0VDKofagnCOiOJUegV3I4jshzZJeYg4qjqxYN9tRBxSdHt2Wazk/5Aw2o5OAusMudYH4 W2vyeRFYESswupb0KWEm+FfhwG+eQj+vSktMOUgl2TSURV6ftdOxFFpa8SY5mokLgJIm 2fyfg/xJkWNXPGWvr5XgJAF70yOj9ck2CAjI9LSqJ9Q3NOMlqGKKQIUeWfKZ1jOIEEy0 OphAEPriVlpQhcwY+SqGGokANFRm/yN34H7rRVx+dcQzWCLRWdWx9KCDB6sQ4K2WkyBE 2FZg== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:content-transfer-encoding:mime-version :message-id:date:subject:cc:to:from:dkim-signature; bh=EDtSNkcu3n6VEBL6cX5/6KUOPyj6eJV5oYhNMI3f5+A=; fh=/7Yc5+aq/i5SAJ1V5MhpMuzF/+HS6hsuabkxAhaVpuw=; b=p0ipsOBwOjK39hNHLX9PKoha422ejrotAcAomV48pv4AQsfCNkplH85rcxS5SUZPsI yDkw3dRAn2aMlytgywIKSFJbYC1oGA+lEpIAXnXMQQFUJbUjmUn0u0S16DB4c7sxDT99 ueRblqMEnV4AmDbn5CLMgdEDhO76M2tFTl88HpE8Tt3PQxnsdwsPjKhP4YJRybSvdbgr oGWAHdbUU5eMLaK/ElNgS6eo2WQzkh+70NyK/v9mossYWB22LFt7rLnvT2eu+QtMhFwM v1vK5m0g9TtfGLxnJOyMXt4U6k43NmwjUFGrHezxAMAFS4Cvv7V8a1rCy0sRQLKnBEFa TIQw== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@gmail.com header.s=20230601 header.b=O9uUDLMD; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::3:2 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=QUARANTINE dis=NONE) header.from=gmail.com Received: from agentk.vger.email (agentk.vger.email. [2620:137:e000::3:2]) by mx.google.com with ESMTPS id p17-20020a635b11000000b005b804d972a2si6575273pgb.490.2023.11.19.07.13.20 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Sun, 19 Nov 2023 07:13:50 -0800 (PST) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::3:2 as permitted sender) client-ip=2620:137:e000::3:2; Authentication-Results: mx.google.com; dkim=pass header.i=@gmail.com header.s=20230601 header.b=O9uUDLMD; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::3:2 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=QUARANTINE dis=NONE) header.from=gmail.com Received: from out1.vger.email (depot.vger.email [IPv6:2620:137:e000::3:0]) by agentk.vger.email (Postfix) with ESMTP id CAAB8805ADD5; Sun, 19 Nov 2023 07:13:13 -0800 (PST) X-Virus-Status: Clean X-Virus-Scanned: clamav-milter 0.103.11 at agentk.vger.email Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S230027AbjKSPNO (ORCPT <rfc822;ouuuleilei@gmail.com> + 99 others); Sun, 19 Nov 2023 10:13:14 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:50756 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S229508AbjKSPNN (ORCPT <rfc822;linux-kernel@vger.kernel.org>); Sun, 19 Nov 2023 10:13:13 -0500 Received: from mail-wr1-x42f.google.com (mail-wr1-x42f.google.com [IPv6:2a00:1450:4864:20::42f]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 205ECB3; Sun, 19 Nov 2023 07:13:10 -0800 (PST) Received: by mail-wr1-x42f.google.com with SMTP id ffacd0b85a97d-32deb2809daso2345978f8f.3; Sun, 19 Nov 2023 07:13:10 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20230601; t=1700406788; x=1701011588; darn=vger.kernel.org; h=content-transfer-encoding:mime-version:message-id:date:subject:cc :to:from:from:to:cc:subject:date:message-id:reply-to; bh=EDtSNkcu3n6VEBL6cX5/6KUOPyj6eJV5oYhNMI3f5+A=; b=O9uUDLMDJhtz2sX/JQZW1VmB/mLps+faHLhVsh2xBMCpH9AusoOsJgf8ZZKG8XfsEz cdv+SiQBFPUA5Tl7dj0hhtzRA+v3XitkcymeMH+dyqYvhPgQpAbUKGM9dOVmwCtuUnrq sT8OZswoQeOh4DoXXh3VOSXdABdJilvXBkgll4vEfsE2gMosmf/6yMp0NY5FJG9q7EZf GpZttwjc6SViC/oJ2kt7tIWhEt12ySmHoWwQMi1nEuGnSdAa8TY6ymXrp4+RJQErNStN X7Ij9i4UvNzihQ4gdrCDaS/TaIqpfoz0/0Ti2ffDizRXR1+QFFUABxoh7Pq8yX7eShxR 3+og== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1700406788; x=1701011588; h=content-transfer-encoding:mime-version:message-id:date:subject:cc :to:from:x-gm-message-state:from:to:cc:subject:date:message-id :reply-to; bh=EDtSNkcu3n6VEBL6cX5/6KUOPyj6eJV5oYhNMI3f5+A=; b=V81Hehkaa4+f4dI6JxhGXs7WKIapPZd1bzC0dywWmHpTL2jjvRG8PaTw6LbggMaG+H fyUC6Kg/wHzEMLQY0wNfhvTKtfMt1y5f8v59zWlvAC20cqbjpa2O3iwtlq1iO3zfkkq9 QFVUeh0tKxP7I/KQp56FanasNNz6kXaOAsho0ohZvMRxMOsPR7Tu4rrkjLjQOFAK8ZnB QNAKXVkOTOIKBqeQRpmhWyi4bH+e03+oXoqfTQodUn9+Bf0k00HsUXeIBaXTHwl1+SQ2 0+Oxs+4qwXjXEnw1ppsG7nKL/SLBLPuCDZ1oCqK0YCgAXq2xBV8kw/096vUP1JGkvXAh bghA== X-Gm-Message-State: AOJu0YzDHlcp1xgaGknPDJg7laM3Vt6DGgMY20MB5MVf4GvLKYYIsSlu 1oJHMkNLBtN+ASEgEwxHsg4e03Unk6Q= X-Received: by 2002:a5d:64ab:0:b0:31a:d9bc:47a2 with SMTP id m11-20020a5d64ab000000b0031ad9bc47a2mr3160376wrp.53.1700406788088; Sun, 19 Nov 2023 07:13:08 -0800 (PST) Received: from localhost.localdomain (93-34-89-13.ip49.fastwebnet.it. [93.34.89.13]) by smtp.googlemail.com with ESMTPSA id m3-20020adffa03000000b00323293bd023sm8321441wrr.6.2023.11.19.07.13.07 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Sun, 19 Nov 2023 07:13:07 -0800 (PST) From: Christian Marangi <ansuelsmth@gmail.com> To: Andrew Lunn <andrew@lunn.ch>, Heiner Kallweit <hkallweit1@gmail.com>, Russell King <linux@armlinux.org.uk>, "David S. Miller" <davem@davemloft.net>, Eric Dumazet <edumazet@google.com>, Jakub Kicinski <kuba@kernel.org>, Paolo Abeni <pabeni@redhat.com>, Florian Fainelli <f.fainelli@gmail.com>, netdev@vger.kernel.org, linux-kernel@vger.kernel.org Cc: Christian Marangi <ansuelsmth@gmail.com>, stable@vger.kernel.org Subject: [net PATCH] net: phy: correctly check soft_reset ret ONLY if defined for PHY Date: Sun, 19 Nov 2023 16:12:58 +0100 Message-Id: <20231119151258.20201-1-ansuelsmth@gmail.com> X-Mailer: git-send-email 2.40.1 MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Spam-Status: No, score=-0.6 required=5.0 tests=DKIM_SIGNED,DKIM_VALID, DKIM_VALID_AU,FREEMAIL_FORGED_FROMDOMAIN,FREEMAIL_FROM, HEADER_FROM_DIFFERENT_DOMAINS,MAILING_LIST_MULTI,SPF_HELO_NONE, SPF_PASS,T_SCC_BODY_TEXT_LINE autolearn=unavailable autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on agentk.vger.email Precedence: bulk List-ID: <linux-kernel.vger.kernel.org> X-Mailing-List: linux-kernel@vger.kernel.org X-Greylist: Sender passed SPF test, not delayed by milter-greylist-4.6.4 (agentk.vger.email [0.0.0.0]); Sun, 19 Nov 2023 07:13:14 -0800 (PST) X-getmail-retrieved-from-mailbox: INBOX X-GMAIL-THRID: 1783005792400473189 X-GMAIL-MSGID: 1783005792400473189 |
Series |
[net] net: phy: correctly check soft_reset ret ONLY if defined for PHY
|
|
Commit Message
Christian Marangi
Nov. 19, 2023, 3:12 p.m. UTC
soft_reset call for phy_init_hw had multiple revision across the years
and the implementation goes back to 2014. Originally was a simple call
to write the generic PHY reset BIT, it was then moved to a dedicated
function. It was then added the option for PHY driver to define their
own special way to reset the PHY. Till this change, checking for ret was
correct as it was always filled by either the generic reset or the
custom implementation. This changed tho with commit 6e2d85ec0559 ("net:
phy: Stop with excessive soft reset"), as the generic reset call to PHY
was dropped but the ret check was never made entirely optional and
dependent whether soft_reset was defined for the PHY driver or not.
Luckly nothing was ever added before the soft_reset call so the ret
check (in the case where a PHY didn't had soft_reset defined) although
wrong, never caused problems as ret was init 0 at the start of
phy_init_hw.
To prevent any kind of problem and to make the function cleaner and more
robust, correctly move the ret check if the soft_reset section making it
optional and needed only with the function defined.
Cc: stable@vger.kernel.org # v5.8+
Fixes: 6e2d85ec0559 ("net: phy: Stop with excessive soft reset")
Signed-off-by: Christian Marangi <ansuelsmth@gmail.com>
---
drivers/net/phy/phy_device.c | 9 ++++-----
1 file changed, 4 insertions(+), 5 deletions(-)
Comments
On Sun, Nov 19, 2023 at 04:12:58PM +0100, Christian Marangi wrote: > soft_reset call for phy_init_hw had multiple revision across the years > and the implementation goes back to 2014. Originally was a simple call > to write the generic PHY reset BIT, it was then moved to a dedicated > function. It was then added the option for PHY driver to define their > own special way to reset the PHY. Till this change, checking for ret was > correct as it was always filled by either the generic reset or the > custom implementation. This changed tho with commit 6e2d85ec0559 ("net: > phy: Stop with excessive soft reset"), as the generic reset call to PHY > was dropped but the ret check was never made entirely optional and > dependent whether soft_reset was defined for the PHY driver or not. > > Luckly nothing was ever added before the soft_reset call so the ret > check (in the case where a PHY didn't had soft_reset defined) although > wrong, never caused problems as ret was init 0 at the start of > phy_init_hw. > > To prevent any kind of problem and to make the function cleaner and more > robust, correctly move the ret check if the soft_reset section making it > optional and needed only with the function defined. I think this should target net-next, not net. It does not appear to be an problem which actually affects somebody using stable kernels. The change itself looks O.K. Andrew
On Sun, Nov 19, 2023 at 05:24:00PM +0100, Andrew Lunn wrote: > On Sun, Nov 19, 2023 at 04:12:58PM +0100, Christian Marangi wrote: > > soft_reset call for phy_init_hw had multiple revision across the years > > and the implementation goes back to 2014. Originally was a simple call > > to write the generic PHY reset BIT, it was then moved to a dedicated > > function. It was then added the option for PHY driver to define their > > own special way to reset the PHY. Till this change, checking for ret was > > correct as it was always filled by either the generic reset or the > > custom implementation. This changed tho with commit 6e2d85ec0559 ("net: > > phy: Stop with excessive soft reset"), as the generic reset call to PHY > > was dropped but the ret check was never made entirely optional and > > dependent whether soft_reset was defined for the PHY driver or not. > > > > Luckly nothing was ever added before the soft_reset call so the ret > > check (in the case where a PHY didn't had soft_reset defined) although > > wrong, never caused problems as ret was init 0 at the start of > > phy_init_hw. > > > > To prevent any kind of problem and to make the function cleaner and more > > robust, correctly move the ret check if the soft_reset section making it > > optional and needed only with the function defined. > > I think this should target net-next, not net. It does not appear to be > an problem which actually affects somebody using stable kernels. > > The change itself looks O.K. > Ok to resubmit or should I wait 24h? (asking as it's a very simple change) Also is the stable Cc ok? (that was the main reason I added the net tag to this)
On Sun, Nov 19, 2023 at 06:55:47PM +0100, Christian Marangi wrote: > On Sun, Nov 19, 2023 at 05:24:00PM +0100, Andrew Lunn wrote: > > On Sun, Nov 19, 2023 at 04:12:58PM +0100, Christian Marangi wrote: > > > soft_reset call for phy_init_hw had multiple revision across the years > > > and the implementation goes back to 2014. Originally was a simple call > > > to write the generic PHY reset BIT, it was then moved to a dedicated > > > function. It was then added the option for PHY driver to define their > > > own special way to reset the PHY. Till this change, checking for ret was > > > correct as it was always filled by either the generic reset or the > > > custom implementation. This changed tho with commit 6e2d85ec0559 ("net: > > > phy: Stop with excessive soft reset"), as the generic reset call to PHY > > > was dropped but the ret check was never made entirely optional and > > > dependent whether soft_reset was defined for the PHY driver or not. > > > > > > Luckly nothing was ever added before the soft_reset call so the ret > > > check (in the case where a PHY didn't had soft_reset defined) although > > > wrong, never caused problems as ret was init 0 at the start of > > > phy_init_hw. > > > > > > To prevent any kind of problem and to make the function cleaner and more > > > robust, correctly move the ret check if the soft_reset section making it > > > optional and needed only with the function defined. > > > > I think this should target net-next, not net. It does not appear to be > > an problem which actually affects somebody using stable kernels. > > > > The change itself looks O.K. > > > > Ok to resubmit or should I wait 24h? (asking as it's a very simple > change) Please wait 24 hours. > Also is the stable Cc ok? > (that was the main reason I added the net tag to this) No drop the Cc: Stable. Your description of the problem does not fit the rules for stable. Andrew
diff --git a/drivers/net/phy/phy_device.c b/drivers/net/phy/phy_device.c index 2ce74593d6e4..478126f6b5bc 100644 --- a/drivers/net/phy/phy_device.c +++ b/drivers/net/phy/phy_device.c @@ -1235,14 +1235,13 @@ int phy_init_hw(struct phy_device *phydev) if (phydev->drv->soft_reset) { ret = phydev->drv->soft_reset(phydev); + if (ret < 0) + return ret; + /* see comment in genphy_soft_reset for an explanation */ - if (!ret) - phydev->suspended = 0; + phydev->suspended = 0; } - if (ret < 0) - return ret; - ret = phy_scan_fixups(phydev); if (ret < 0) return ret;