public inbox for netdev@vger.kernel.org
 help / color / mirror / Atom feed
From: Simon Horman <horms@kernel.org>
To: Florian Fainelli <florian.fainelli@broadcom.com>
Cc: netdev@vger.kernel.org, Doug Berger <opendmb@gmail.com>,
	Broadcom internal kernel review list
	<bcm-kernel-feedback-list@broadcom.com>,
	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>,
	Jacob Keller <jacob.e.keller@intel.com>,
	open list <linux-kernel@vger.kernel.org>
Subject: Re: [PATCH net] net: mdio: mdio-bcm-unimac: Correct rate fallback logic
Date: Wed, 30 Jul 2025 15:33:00 +0100	[thread overview]
Message-ID: <20250730143300.GI1877762@horms.kernel.org> (raw)
In-Reply-To: <20250729213148.3403882-1-florian.fainelli@broadcom.com>

On Tue, Jul 29, 2025 at 02:31:48PM -0700, Florian Fainelli wrote:
> In case the rate for the parent clock is zero, make sure that we still
> fallback to using a fixed rate for the divider calculation, otherwise we
> simply ignore the desired MDIO bus clock frequency which can prevent us
> from interfacing with Ethernet PHYs properly.
> 
> Fixes: ee975351cf0c ("net: mdio: mdio-bcm-unimac: Manage clock around I/O accesses")
> Signed-off-by: Florian Fainelli <florian.fainelli@broadcom.com>
> ---
>  drivers/net/mdio/mdio-bcm-unimac.c | 5 ++---
>  1 file changed, 2 insertions(+), 3 deletions(-)
> 
> diff --git a/drivers/net/mdio/mdio-bcm-unimac.c b/drivers/net/mdio/mdio-bcm-unimac.c
> index b6e30bdf5325..9c0a11316cfd 100644
> --- a/drivers/net/mdio/mdio-bcm-unimac.c
> +++ b/drivers/net/mdio/mdio-bcm-unimac.c
> @@ -209,10 +209,9 @@ static int unimac_mdio_clk_set(struct unimac_mdio_priv *priv)
>  	if (ret)
>  		return ret;
>  
> -	if (!priv->clk)
> +	rate = clk_get_rate(priv->clk);
> +	if (!priv->clk || !rate)

If priv->clk is NULL then drivers/clk/clk.c:clk_get_rate()
(are there other relevant implementations?) will return 0.
So I think the condition above is tautological, and could be expressed as:

	if (!rate)

>  		rate = 250000000;
> -	else
> -		rate = clk_get_rate(priv->clk);
>  
>  	div = (rate / (2 * priv->clk_freq)) - 1;
>  	if (div & ~MDIO_CLK_DIV_MASK) {
> -- 
> 2.34.1
> 
> 

      parent reply	other threads:[~2025-07-30 14:33 UTC|newest]

Thread overview: 6+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2025-07-29 21:31 [PATCH net] net: mdio: mdio-bcm-unimac: Correct rate fallback logic Florian Fainelli
2025-07-29 22:20 ` Andrew Lunn
2025-07-29 22:22   ` Florian Fainelli
2025-07-29 22:44     ` Andrew Lunn
2025-07-29 22:50       ` Florian Fainelli
2025-07-30 14:33 ` Simon Horman [this message]

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=20250730143300.GI1877762@horms.kernel.org \
    --to=horms@kernel.org \
    --cc=andrew@lunn.ch \
    --cc=bcm-kernel-feedback-list@broadcom.com \
    --cc=davem@davemloft.net \
    --cc=edumazet@google.com \
    --cc=florian.fainelli@broadcom.com \
    --cc=hkallweit1@gmail.com \
    --cc=jacob.e.keller@intel.com \
    --cc=kuba@kernel.org \
    --cc=linux-kernel@vger.kernel.org \
    --cc=linux@armlinux.org.uk \
    --cc=netdev@vger.kernel.org \
    --cc=opendmb@gmail.com \
    --cc=pabeni@redhat.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