Message ID | 20231129021219.20914-3-ansuelsmth@gmail.com |
---|---|
State | New |
Headers |
Return-Path: <linux-kernel-owner@vger.kernel.org> Delivered-To: ouuuleilei@gmail.com Received: by 2002:a59:a5a7:0:b0:403:3b70:6f57 with SMTP id d7csp68279vqn; Tue, 28 Nov 2023 18:12:50 -0800 (PST) X-Google-Smtp-Source: AGHT+IEwrocZ520bU+PKXk51xZAqpX7V1O8i0ouuesZaAnBG3NGm5+NANQ7wiXmphFiWW9RmDaMT X-Received: by 2002:a05:6808:1304:b0:3ae:126b:8c2b with SMTP id y4-20020a056808130400b003ae126b8c2bmr22652790oiv.30.1701223970420; Tue, 28 Nov 2023 18:12:50 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1701223970; cv=none; d=google.com; s=arc-20160816; b=QwdojGe3adqLNjeL6rBG9G0nW0eE6RPLeIQWnk+BSTWc1qHGGXwADJOdmUCSl32TvH ppDKpem357lWcV7Uh73qNASzlsgKnbmw3vXF3d6HoLoo8G63gLwNZpYGT9BV4TaT5RZw pZVjg9g0FZj2QWZd2MteHgp6JZUU5weKFEfIohLjNWNhuOni6J4oVsr4xbPbsErsNB34 IYwTESVEAtS8NMWpv+TWPnHOOO0JdMckGH3e/rTt9ngx2j7fNijyCQfPbqTyPwdNpJwx rk6PNiBBM/12uxX+luKPtqcUqUXGRAcIsAMa/SFNIyy8kSh/edJFVt67z9IaJpzvCFdF aDpA== 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 :references:in-reply-to:message-id:date:subject:cc:to:from :dkim-signature; bh=dt4PyFm7vz4PSs/CMN+Td9iZ3kGYAxZdlYsWr/1duKY=; fh=M/Mg9TtngevyqXgZJCTwFV5p5//1sl9LEorA0JOhC3o=; b=O3oD2yyx4Rbcydj3eN2q+GaC1QHJ/6f8Vl4zWE6wu69ZG2tkYxQYl8q9J3uc9Fv5Yx eqmihB1Qr/JVlL4YUixyapbbNzmgRdTQKqkrdk1Pq2rPb9vAon6ksOAQv89SfiVWq+S7 oEkuv+jHxJv1LVUaPiTMxmguVy62qTdUb3hXu6LnNAfRs/5ylji4yldVopUdrBM/TcEB tTfE5tFpAOuIji+ELEsi74vQMCE3Rx1zdCAv8eux4Rtshd6kiJaTKBiu3k6alBlRrX+t 6VRpkbR6co7XK5rOy7jeVSxZ72g3Vif6B8y17W843H049BdHeaxLZI67TX+NMpKUy8HF XlmQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@gmail.com header.s=20230601 header.b=myTKw3P9; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::3:7 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 snail.vger.email (snail.vger.email. [2620:137:e000::3:7]) by mx.google.com with ESMTPS id o66-20020a634145000000b005b91a58721esi13292829pga.316.2023.11.28.18.12.50 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 28 Nov 2023 18:12:50 -0800 (PST) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::3:7 as permitted sender) client-ip=2620:137:e000::3:7; Authentication-Results: mx.google.com; dkim=pass header.i=@gmail.com header.s=20230601 header.b=myTKw3P9; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::3:7 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 snail.vger.email (Postfix) with ESMTP id 6C93A80C0376; Tue, 28 Nov 2023 18:12:48 -0800 (PST) X-Virus-Status: Clean X-Virus-Scanned: clamav-milter 0.103.11 at snail.vger.email Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1376759AbjK2CMa (ORCPT <rfc822;toshivichauhan@gmail.com> + 99 others); Tue, 28 Nov 2023 21:12:30 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:42640 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1376750AbjK2CM0 (ORCPT <rfc822;linux-kernel@vger.kernel.org>); Tue, 28 Nov 2023 21:12:26 -0500 Received: from mail-wm1-x329.google.com (mail-wm1-x329.google.com [IPv6:2a00:1450:4864:20::329]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 7E10519AE; Tue, 28 Nov 2023 18:12:32 -0800 (PST) Received: by mail-wm1-x329.google.com with SMTP id 5b1f17b1804b1-40b397793aaso2298335e9.0; Tue, 28 Nov 2023 18:12:32 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20230601; t=1701223951; x=1701828751; darn=vger.kernel.org; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:from:to:cc:subject:date :message-id:reply-to; bh=dt4PyFm7vz4PSs/CMN+Td9iZ3kGYAxZdlYsWr/1duKY=; b=myTKw3P9yLweJySHRcUsNdISUyaqcUFm1Wws7m20QUkiQ67XLXjysYKARUkRACMtpj WcUO+2FM/2e2IHfZQIM9WnHz2IJKBXX9Oh1CDTIg2cFJH77Y1pqV+oDl3ArdAeJjEilp 4tTsoQ7mQtWUqJXK99lQNdjDWbgwmzLjKlTpmEHxU7x9SkXwotkFixkJN4Bo6ushriAt DLTI1X79kut7M4L6qbBBjbjbHrSHAkq13BPK15VnxxZykIwz/XdkMawiLgdZTA/Kzrq3 DqRDyfGuNdbzaZY+TrWEvSbVxxPt1dNBq97g8yGWJjg9egsBR5szThkbn4hJq2Vpww0i 1+0A== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1701223951; x=1701828751; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=dt4PyFm7vz4PSs/CMN+Td9iZ3kGYAxZdlYsWr/1duKY=; b=lA+QNNWri/QblZ8Cb7nwcEjjJCgL0Tte9AyTsawWSgAPp3dUvt50X/yV5oTC4CxK2D 2s7wMZQcnlYSxIvb82Z6S96rxaFYJuFqRTO9OYcqhj9toCq09KkkjUSfKtjStonQPyvs tXiLJX7/1/Rs5bVBNuy7DcaxCRidHE3m6in3Mxb0uWjZtFKqNODF5jCywRSmV6hj8jVD RnkV1Rmr8zQ7n2RNQc5D4fEQbKWfLwhKDT2+PijTijfvgKH2bwu4ZEcb3Eaiwtl+UwID REZHPTlmFhZis20V197ccpVbY9yMaHjhgwQ0MXDh30qO8PGrmhuot7iPl0G3ReS6ETNa d0dQ== X-Gm-Message-State: AOJu0Ywg7cmopcYjE++CqJfIQixOeyMBJQfG1qkVpPEkeLZdZSqSTQ11 oT/tDw3AGYkU57oSYxQ/M0sY4/uSOUI= X-Received: by 2002:a05:600c:1d08:b0:40b:2a62:a2b6 with SMTP id l8-20020a05600c1d0800b0040b2a62a2b6mr14429504wms.1.1701223950657; Tue, 28 Nov 2023 18:12:30 -0800 (PST) Received: from localhost.localdomain (93-34-89-13.ip49.fastwebnet.it. [93.34.89.13]) by smtp.googlemail.com with ESMTPSA id b19-20020a05600c4e1300b0040648217f4fsm321406wmq.39.2023.11.28.18.12.29 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 28 Nov 2023 18:12:30 -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>, Andy Gross <agross@kernel.org>, Bjorn Andersson <andersson@kernel.org>, Konrad Dybcio <konrad.dybcio@linaro.org>, linux-kernel@vger.kernel.org, netdev@vger.kernel.org, linux-arm-msm@vger.kernel.org Cc: Christian Marangi <ansuelsmth@gmail.com> Subject: [net-next PATCH 02/14] net: phy: at803x: move disable WOL for 8031 from probe to config Date: Wed, 29 Nov 2023 03:12:07 +0100 Message-Id: <20231129021219.20914-3-ansuelsmth@gmail.com> X-Mailer: git-send-email 2.40.1 In-Reply-To: <20231129021219.20914-1-ansuelsmth@gmail.com> References: <20231129021219.20914-1-ansuelsmth@gmail.com> MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Spam-Status: No, score=-2.1 required=5.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,FREEMAIL_FROM, RCVD_IN_DNSWL_BLOCKED,SPF_HELO_NONE,SPF_PASS,T_SCC_BODY_TEXT_LINE autolearn=ham autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on lindbergh.monkeyblade.net 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 (snail.vger.email [0.0.0.0]); Tue, 28 Nov 2023 18:12:48 -0800 (PST) X-getmail-retrieved-from-mailbox: INBOX X-GMAIL-THRID: 1783862626116931458 X-GMAIL-MSGID: 1783862626116931458 |
Series |
net: phy: at803x: cleanup + split
|
|
Commit Message
Christian Marangi
Nov. 29, 2023, 2:12 a.m. UTC
Probe should be used only for DT parsing and allocate required priv, it
shouldn't touch regs, there is config_init for that.
Move the WOL disable call from probe to config_init to follow this rule
and keep code tidy.
No behaviour is done as the mode was disabled only if phy_read succeeded
in probe and this is translated as the first action done in config_init
(called only if probe returns 0)
Signed-off-by: Christian Marangi <ansuelsmth@gmail.com>
---
drivers/net/phy/at803x.c | 18 +++++++++---------
1 file changed, 9 insertions(+), 9 deletions(-)
Comments
On Wed, Nov 29, 2023 at 03:12:07AM +0100, Christian Marangi wrote: > Probe should be used only for DT parsing and allocate required priv, it > shouldn't touch regs, there is config_init for that. I'm not sure where you get that idea from. PHY driver probe() functions are permitted to access registers to do any setup that they wish to. config_init() is to configure the PHY for use with the network interface. I think this patch is just noise rather than a cleanup.
On Wed, Nov 29, 2023 at 09:24:32AM +0000, Russell King (Oracle) wrote: > On Wed, Nov 29, 2023 at 03:12:07AM +0100, Christian Marangi wrote: > > Probe should be used only for DT parsing and allocate required priv, it > > shouldn't touch regs, there is config_init for that. > > I'm not sure where you get that idea from. PHY driver probe() functions > are permitted to access registers to do any setup that they wish to. > > config_init() is to configure the PHY for use with the network > interface. > > I think this patch is just noise rather than a cleanup. > I got it from here [1] Also on every other driver probe was always used for allocation and parsing so why deviates from this pattern here? Also I think it was wrong from the start as on reset I think WoL is not disabled again. (probe is not called) [1] https://elixir.bootlin.com/linux/latest/source/include/linux/phy.h#L916
On Wed, Nov 29, 2023 at 10:36:31AM +0100, Christian Marangi wrote: > On Wed, Nov 29, 2023 at 09:24:32AM +0000, Russell King (Oracle) wrote: > > On Wed, Nov 29, 2023 at 03:12:07AM +0100, Christian Marangi wrote: > > > Probe should be used only for DT parsing and allocate required priv, it > > > shouldn't touch regs, there is config_init for that. > > > > I'm not sure where you get that idea from. PHY driver probe() functions > > are permitted to access registers to do any setup that they wish to. > > > > config_init() is to configure the PHY for use with the network > > interface. > > > > I think this patch is just noise rather than a cleanup. > > > > I got it from here [1] > > Also on every other driver probe was always used for allocation and > parsing so why deviates from this pattern here? Untrue. bcm54140_enable_monitoring() is called from bcm54140_probe_once() which in turn is called from bcm54140_probe(). dp83869_probe() calls dp83869_config_init(), rightly or wrongly. lxt973_probe() fixes up the BMCR. mv3310_probe() configures power-down modes, modifying registers. mt7988_phy_probe() calls mt7988_phy_fix_leds_polarities() which modifies registers. lan8814_probe() calls lan8814_ptp_init() which does a whole load of register writes. lan88xx_probe() configures LEDs via register writes. yt8521_probe() configures clocks via register modification. I'm afraid this means your comment is demonstrably false. > Also I think it was wrong from the start as on reset I think WoL is > not disabled again. (probe is not called) On hardware reset, the 1588 register will re-enable the WoL pin, but that needs a hardware reset of the PHY to happen after probe() is called. However, phy_probe() will only assert the reset signal _if_ an error occured during probing, not if probing was successful. So, a successful probe of this driver will not cause a hardware reset. Also, hardware reset is optional. Do you know whether the platforms that use the separate WoL pin which this 1588 register controls also wire the reset signal such that it can be controlled by Linux? Probably not. So, this register write will not be cleared by a hardware reset after a successful probe.
On Wed, Nov 29, 2023 at 10:45:11AM +0000, Russell King (Oracle) wrote: > On Wed, Nov 29, 2023 at 10:36:31AM +0100, Christian Marangi wrote: > > On Wed, Nov 29, 2023 at 09:24:32AM +0000, Russell King (Oracle) wrote: > > > On Wed, Nov 29, 2023 at 03:12:07AM +0100, Christian Marangi wrote: > > > > Probe should be used only for DT parsing and allocate required priv, it > > > > shouldn't touch regs, there is config_init for that. > > > > > > I'm not sure where you get that idea from. PHY driver probe() functions > > > are permitted to access registers to do any setup that they wish to. > > > > > > config_init() is to configure the PHY for use with the network > > > interface. > > > > > > I think this patch is just noise rather than a cleanup. > > > > > > > I got it from here [1] > > > > Also on every other driver probe was always used for allocation and > > parsing so why deviates from this pattern here? > > Untrue. > > bcm54140_enable_monitoring() is called from bcm54140_probe_once() > which in turn is called from bcm54140_probe(). > > dp83869_probe() calls dp83869_config_init(), rightly or wrongly. > > lxt973_probe() fixes up the BMCR. > > mv3310_probe() configures power-down modes, modifying registers. > > mt7988_phy_probe() calls mt7988_phy_fix_leds_polarities() which > modifies registers. > > lan8814_probe() calls lan8814_ptp_init() which does a whole load of > register writes. > > lan88xx_probe() configures LEDs via register writes. > > yt8521_probe() configures clocks via register modification. > > I'm afraid this means your comment is demonstrably false. > Don't want to start a discussion and thanks a lot for pointing this out. This is really to talk about this and not contradict you. Yes it's not true, and I was wrong but still I watch other driver outside PHY and normally probe should not do that kind of stuff. (even the comments describing the use in phy.h doesn't say that it should be used for configuring the PHY only once on discovery) Watching some of the thing, I feel all of this is done in probe as it's not called again on software reset (as it will call config_init again). This looks like there is a missing feature here and maybe a chance to improve this? Wonder if adding an additional OP would be beneficial to this? Was thinking to something like .config_once ? And add some comments that it's called only on PHY discovery? It would be put right after the probe call in phy_core. > > Also I think it was wrong from the start as on reset I think WoL is > > not disabled again. (probe is not called) > > On hardware reset, the 1588 register will re-enable the WoL pin, but > that needs a hardware reset of the PHY to happen after probe() is > called. > > However, phy_probe() will only assert the reset signal _if_ an error > occured during probing, not if probing was successful. So, a successful > probe of this driver will not cause a hardware reset. > > Also, hardware reset is optional. Do you know whether the platforms > that use the separate WoL pin which this 1588 register controls also > wire the reset signal such that it can be controlled by Linux? > Probably not. > > So, this register write will not be cleared by a hardware reset after > a successful probe. > I just checked Datasheet, on HW reset it's enabled again and on SW reset value is retained. So yes it must stay in probe as it will cause side effect if WoL get enabled after... Really hope the config_once thing is OK since it will make things much cleaner.
On Wed, Nov 29, 2023 at 12:03:14PM +0100, Christian Marangi wrote: > On Wed, Nov 29, 2023 at 10:45:11AM +0000, Russell King (Oracle) wrote: > > On Wed, Nov 29, 2023 at 10:36:31AM +0100, Christian Marangi wrote: > > > On Wed, Nov 29, 2023 at 09:24:32AM +0000, Russell King (Oracle) wrote: > > > > On Wed, Nov 29, 2023 at 03:12:07AM +0100, Christian Marangi wrote: > > > > > Probe should be used only for DT parsing and allocate required priv, it > > > > > shouldn't touch regs, there is config_init for that. > > > > > > > > I'm not sure where you get that idea from. PHY driver probe() functions > > > > are permitted to access registers to do any setup that they wish to. > > > > > > > > config_init() is to configure the PHY for use with the network > > > > interface. > > > > > > > > I think this patch is just noise rather than a cleanup. > > > > > > > > > > I got it from here [1] > > > > > > Also on every other driver probe was always used for allocation and > > > parsing so why deviates from this pattern here? > > > > Untrue. > > > > bcm54140_enable_monitoring() is called from bcm54140_probe_once() > > which in turn is called from bcm54140_probe(). > > > > dp83869_probe() calls dp83869_config_init(), rightly or wrongly. > > > > lxt973_probe() fixes up the BMCR. > > > > mv3310_probe() configures power-down modes, modifying registers. > > > > mt7988_phy_probe() calls mt7988_phy_fix_leds_polarities() which > > modifies registers. > > > > lan8814_probe() calls lan8814_ptp_init() which does a whole load of > > register writes. > > > > lan88xx_probe() configures LEDs via register writes. > > > > yt8521_probe() configures clocks via register modification. > > > > I'm afraid this means your comment is demonstrably false. > > > > Don't want to start a discussion and thanks a lot for pointing this > out. This is really to talk about this and not contradict you. > > Yes it's not true, and I was wrong but still I watch other driver > outside PHY and normally probe should not do that kind of stuff. > (even the comments describing the use in phy.h doesn't say that it > should be used for configuring the PHY only once on discovery) > > Watching some of the thing, I feel all of this is done in probe as it's > not called again on software reset (as it will call config_init again). > > This looks like there is a missing feature here and maybe a chance to > improve this? > > Wonder if adding an additional OP would be beneficial to this? > Was thinking to something like > > .config_once ? > > And add some comments that it's called only on PHY discovery? > It would be put right after the probe call in phy_core. > > > > Also I think it was wrong from the start as on reset I think WoL is > > > not disabled again. (probe is not called) > > > > On hardware reset, the 1588 register will re-enable the WoL pin, but > > that needs a hardware reset of the PHY to happen after probe() is > > called. > > > > However, phy_probe() will only assert the reset signal _if_ an error > > occured during probing, not if probing was successful. So, a successful > > probe of this driver will not cause a hardware reset. > > > > Also, hardware reset is optional. Do you know whether the platforms > > that use the separate WoL pin which this 1588 register controls also > > wire the reset signal such that it can be controlled by Linux? > > Probably not. > > > > So, this register write will not be cleared by a hardware reset after > > a successful probe. > > > > I just checked Datasheet, on HW reset it's enabled again and on SW reset > value is retained. So yes it must stay in probe as it will cause side > effect if WoL get enabled after... Really hope the config_once thing is > OK since it will make things much cleaner. The phylib comment deviates from standard practice elsewhere in the kernel, where it is totally fine to do hardware setup in the probe() function. So I would suggest just updating the comment on probe() to remove the idea that one shouldn't be doing this. I think it's totally fine to be doing setup in probe().
> if (phydev->drv->phy_id == ATH8031_PHY_ID) { > + /* Disable WoL in 1588 register which is enabled > + * by default > + */ > + ret = phy_modify_mmd(phydev, MDIO_MMD_PCS, > + AT803X_PHY_MMD3_WOL_CTRL, > + AT803X_WOL_EN, 0); > + if (ret) > + return ret; > + Maybe it comes later in the patch series, but i would actually add a at8031_probe() which calls the common at803x_probe() and then does this WoL stuff. I don't see any reason to have just one probe, with if (phydev->drv->phy_id == ATH8031_PHY_ID) { in it. Andrew
diff --git a/drivers/net/phy/at803x.c b/drivers/net/phy/at803x.c index ef203b0807e5..b32ff82240dc 100644 --- a/drivers/net/phy/at803x.c +++ b/drivers/net/phy/at803x.c @@ -886,15 +886,6 @@ static int at803x_probe(struct phy_device *phydev) priv->is_fiber = true; break; } - - /* Disable WoL in 1588 register which is enabled - * by default - */ - ret = phy_modify_mmd(phydev, MDIO_MMD_PCS, - AT803X_PHY_MMD3_WOL_CTRL, - AT803X_WOL_EN, 0); - if (ret) - return ret; } return 0; @@ -1008,6 +999,15 @@ static int at803x_config_init(struct phy_device *phydev) int ret; if (phydev->drv->phy_id == ATH8031_PHY_ID) { + /* Disable WoL in 1588 register which is enabled + * by default + */ + ret = phy_modify_mmd(phydev, MDIO_MMD_PCS, + AT803X_PHY_MMD3_WOL_CTRL, + AT803X_WOL_EN, 0); + if (ret) + return ret; + /* Some bootloaders leave the fiber page selected. * Switch to the appropriate page (fiber or copper), as otherwise we * read the PHY capabilities from the wrong page.