netdev.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
From: "Russell King (Oracle)" <linux@armlinux.org.uk>
To: Michael Sit Wei Hong <michael.wei.hong.sit@intel.com>
Cc: Giuseppe Cavallaro <peppe.cavallaro@st.com>,
	Alexandre Torgue <alexandre.torgue@foss.st.com>,
	Jose Abreu <joabreu@synopsys.com>,
	"David S . Miller" <davem@davemloft.net>,
	Eric Dumazet <edumazet@google.com>,
	Jakub Kicinski <kuba@kernel.org>, Paolo Abeni <pabeni@redhat.com>,
	Maxime Coquelin <mcoquelin.stm32@gmail.com>,
	Ong Boon Leong <boon.leong.ong@intel.com>,
	netdev@vger.kernel.org, linux-stm32@st-md-mailman.stormreply.com,
	linux-arm-kernel@lists.infradead.org,
	linux-kernel@vger.kernel.org, hkallweit1@gmail.com,
	andrew@lunn.ch,
	Martin Blumenstingl <martin.blumenstingl@googlemail.com>,
	Shahab Vahedi <Shahab.Vahedi@synopsys.com>,
	Marek Szyprowski <m.szyprowski@samsung.com>,
	Looi Hong Aun <hong.aun.looi@intel.com>,
	Voon Weifeng <weifeng.voon@intel.com>,
	Lai Peter Jun Ann <peter.jun.ann.lai@intel.com>,
	Zulkifli Muhammad Husaini <muhammad.husaini.zulkifli@intel.com>,
	Tan Tee Min <tee.min.tan@intel.com>,
	hock.leong.kweh@intel.com
Subject: Re: [PATCH net 1/1] net: stmmac: check fwnode for phy device before scanning for phy
Date: Wed, 5 Apr 2023 11:18:14 +0100	[thread overview]
Message-ID: <ZC1K5mLAkkO7bjA4@shell.armlinux.org.uk> (raw)
In-Reply-To: <20230405093945.3549491-1-michael.wei.hong.sit@intel.com>

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@googlemail.com>

Suggested-by: Russell King (Oracle) <rmk+kernel@armlinux.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@intel.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!

  parent reply	other threads:[~2023-04-05 10:18 UTC|newest]

Thread overview: 8+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2023-04-05  9:39 [PATCH net 1/1] net: stmmac: check fwnode for phy device before scanning for phy Michael Sit Wei Hong
2023-04-05 10:07 ` Shahab Vahedi
2023-04-05 10:10   ` Shahab Vahedi
2023-04-05 10:53   ` Marek Szyprowski
2023-04-05 13:03     ` Looi, Hong Aun
2023-04-05 10:18 ` Russell King (Oracle) [this message]
2023-04-05 10:39 ` Martin Blumenstingl
2023-04-05 19:02 ` Guenter Roeck

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=ZC1K5mLAkkO7bjA4@shell.armlinux.org.uk \
    --to=linux@armlinux.org.uk \
    --cc=Shahab.Vahedi@synopsys.com \
    --cc=alexandre.torgue@foss.st.com \
    --cc=andrew@lunn.ch \
    --cc=boon.leong.ong@intel.com \
    --cc=davem@davemloft.net \
    --cc=edumazet@google.com \
    --cc=hkallweit1@gmail.com \
    --cc=hock.leong.kweh@intel.com \
    --cc=hong.aun.looi@intel.com \
    --cc=joabreu@synopsys.com \
    --cc=kuba@kernel.org \
    --cc=linux-arm-kernel@lists.infradead.org \
    --cc=linux-kernel@vger.kernel.org \
    --cc=linux-stm32@st-md-mailman.stormreply.com \
    --cc=m.szyprowski@samsung.com \
    --cc=martin.blumenstingl@googlemail.com \
    --cc=mcoquelin.stm32@gmail.com \
    --cc=michael.wei.hong.sit@intel.com \
    --cc=muhammad.husaini.zulkifli@intel.com \
    --cc=netdev@vger.kernel.org \
    --cc=pabeni@redhat.com \
    --cc=peppe.cavallaro@st.com \
    --cc=peter.jun.ann.lai@intel.com \
    --cc=tee.min.tan@intel.com \
    --cc=weifeng.voon@intel.com \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).