lists.openwall.net   lists  /  announce  owl-users  owl-dev  john-users  john-dev  passwdqc-users  yescrypt  popa3d-users  /  oss-security  kernel-hardening  musl  sabotage  tlsify  passwords  /  crypt-dev  xvendor  /  Bugtraq  Full-Disclosure  linux-kernel  linux-netdev  linux-ext4  linux-hardening  linux-cve-announce  PHC 
Open Source and information security mailing list archives
 
Hash Suite: Windows password security audit tool. GUI, reports in PDF.
[<prev] [next>] [<thread-prev] [thread-next>] [day] [month] [year] [list]
Message-ID: <ZC1K5mLAkkO7bjA4@shell.armlinux.org.uk>
Date:   Wed, 5 Apr 2023 11:18:14 +0100
From:   "Russell King (Oracle)" <linux@...linux.org.uk>
To:     Michael Sit Wei Hong <michael.wei.hong.sit@...el.com>
Cc:     Giuseppe Cavallaro <peppe.cavallaro@...com>,
        Alexandre Torgue <alexandre.torgue@...s.st.com>,
        Jose Abreu <joabreu@...opsys.com>,
        "David S . Miller" <davem@...emloft.net>,
        Eric Dumazet <edumazet@...gle.com>,
        Jakub Kicinski <kuba@...nel.org>,
        Paolo Abeni <pabeni@...hat.com>,
        Maxime Coquelin <mcoquelin.stm32@...il.com>,
        Ong Boon Leong <boon.leong.ong@...el.com>,
        netdev@...r.kernel.org, linux-stm32@...md-mailman.stormreply.com,
        linux-arm-kernel@...ts.infradead.org, linux-kernel@...r.kernel.org,
        hkallweit1@...il.com, andrew@...n.ch,
        Martin Blumenstingl <martin.blumenstingl@...glemail.com>,
        Shahab Vahedi <Shahab.Vahedi@...opsys.com>,
        Marek Szyprowski <m.szyprowski@...sung.com>,
        Looi Hong Aun <hong.aun.looi@...el.com>,
        Voon Weifeng <weifeng.voon@...el.com>,
        Lai Peter Jun Ann <peter.jun.ann.lai@...el.com>,
        Zulkifli Muhammad Husaini <muhammad.husaini.zulkifli@...el.com>,
        Tan Tee Min <tee.min.tan@...el.com>,
        hock.leong.kweh@...el.com
Subject: Re: [PATCH net 1/1] net: stmmac: check fwnode for phy device before
 scanning for phy

On Wed, Apr 05, 2023 at 05:39:45PM +0800, Michael Sit Wei Hong wrote:
> Some DT devices already have phy device configured in the DT/ACPI.
> Current implementation scans for a phy unconditionally even though
> there is a phy listed in the DT/ACPI and already attached.
> 
> We should check the fwnode if there is any phy device listed in
> fwnode and decide whether to scan for a phy to attach to.y
> 
> Reported-by: Martin Blumenstingl <martin.blumenstingl@...glemail.com>

Suggested-by: Russell King (Oracle) <rmk+kernel@...linux.org.uk>

> Fixes: fe2cfbc96803 ("net: stmmac: check if MAC needs to attach to a PHY")
> Signed-off-by: Michael Sit Wei Hong <michael.wei.hong.sit@...el.com>
> ---
>  drivers/net/ethernet/stmicro/stmmac/stmmac_main.c | 15 +++++++++++----
>  1 file changed, 11 insertions(+), 4 deletions(-)
> 
> diff --git a/drivers/net/ethernet/stmicro/stmmac/stmmac_main.c b/drivers/net/ethernet/stmicro/stmmac/stmmac_main.c
> index d41a5f92aee7..7ca9be7bec06 100644
> --- a/drivers/net/ethernet/stmicro/stmmac/stmmac_main.c
> +++ b/drivers/net/ethernet/stmicro/stmmac/stmmac_main.c
> @@ -1134,22 +1134,26 @@ static void stmmac_check_pcs_mode(struct stmmac_priv *priv)
>  static int stmmac_init_phy(struct net_device *dev)
>  {
>  	struct stmmac_priv *priv = netdev_priv(dev);
> +	struct fwnode_handle *phy_fwnode;
>  	struct fwnode_handle *fwnode;
> -	bool phy_needed;
>  	int ret;
>  
> +	if (!phylink_expects_phy(priv->phylink))
> +		return 0;
> +
>  	fwnode = of_fwnode_handle(priv->plat->phylink_node);
>  	if (!fwnode)
>  		fwnode = dev_fwnode(priv->device);
>  
>  	if (fwnode)
> -		ret = phylink_fwnode_phy_connect(priv->phylink, fwnode, 0);
> +		phy_fwnode = fwnode_get_phy_node(fwnode);
> +	else
> +		phy_fwnode = NULL;
>  
> -	phy_needed = phylink_expects_phy(priv->phylink);
>  	/* Some DT bindings do not set-up the PHY handle. Let's try to
>  	 * manually parse it
>  	 */
> -	if (!fwnode || phy_needed || ret) {
> +	if (!phy_fwnode || IS_ERR(phy_fwnode)) {
>  		int addr = priv->plat->phy_addr;
>  		struct phy_device *phydev;
>  
> @@ -1165,6 +1169,9 @@ static int stmmac_init_phy(struct net_device *dev)
>  		}
>  
>  		ret = phylink_connect_phy(priv->phylink, phydev);
> +	} else {
> +		fwnode_handle_put(phy_fwnode);
> +		ret = phylink_fwnode_phy_connect(priv->phylink, fwnode, 0);
>  	}
>  
>  	if (!priv->plat->pmt) {

LGTM, thanks for taking on board my suggestion.

-- 
RMK's Patch system: https://www.armlinux.org.uk/developer/patches/
FTTP is here! 80Mbps down 10Mbps up. Decent connectivity at last!

Powered by blists - more mailing lists

Powered by Openwall GNU/*/Linux Powered by OpenVZ