From: Michael Heimpold <michael.heimpold@i2se.com>
To: "Lothar Waßmann" <LW@KARO-electronics.de>,
"Andrew Lunn" <andrew@lunn.ch>,
"David S. Miller" <davem@davemloft.net>,
"Fabio Estevam" <fabio.estevam@freescale.com>,
"Kevin Hao" <haokexin@gmail.com>,
"Lucas Stach" <l.stach@pengutronix.de>,
"Nimrod Andy" <B38611@freescale.com>,
"Philippe Reynes" <tremyfr@gmail.com>,
"Russell King" <rmk+kernel@arm.linux.org.uk>,
"Uwe Kleine-König" <u.kleine-koenig@pengutronix.de>,
linux-kernel@vger.kernel.org, netdev@vger.kernel.org,
"Stefan Agner" <stefan@agner.ch>
Subject: Re: [PATCH] net: fec: fix enet_out clock handling
Date: Fri, 27 Nov 2015 16:16:49 +0100 [thread overview]
Message-ID: <565873E1.1030505@i2se.com> (raw)
In-Reply-To: <1448631550-943-1-git-send-email-LW@KARO-electronics.de>
Hi,
Am 27.11.2015 um 14:39 schrieb Lothar Waßmann:
> When ENET_OUT is being used as reference clock for an external PHY,
> the clock must not be disabled while the PHY is active. Otherwise the
> PHY may lose its internal state and require a reset to become
> functional again.
>
> A symptom for this bug is a network interface that constantly toggles
> between UP and DOWN state:
> fec 800f0000.ethernet eth0: Link is Up - 100Mbps/Full - flow control rx/tx
> fec 800f0000.ethernet eth0: Link is Down
> fec 800f0000.ethernet eth0: Link is Up - 100Mbps/Full - flow control rx/tx
> fec 800f0000.ethernet eth0: Link is Down
> [...]
I would add a sentence about the solution, e.g. moving ENET_OUT handling to driver probe etc.
> Signed-off-by: Lothar Waßmann <LW@KARO-electronics.de>
> ---
> drivers/net/ethernet/freescale/fec_main.c | 34 +++++++++++++------------------
> 1 file changed, 14 insertions(+), 20 deletions(-)
>
> diff --git a/drivers/net/ethernet/freescale/fec_main.c b/drivers/net/ethernet/freescale/fec_main.c
> index d2328fc..d9df4c5 100644
> --- a/drivers/net/ethernet/freescale/fec_main.c
> +++ b/drivers/net/ethernet/freescale/fec_main.c
> @@ -1857,11 +1857,6 @@ static int fec_enet_clk_enable(struct net_device *ndev, bool enable)
> ret = clk_prepare_enable(fep->clk_ahb);
> if (ret)
> return ret;
> - if (fep->clk_enet_out) {
> - ret = clk_prepare_enable(fep->clk_enet_out);
> - if (ret)
> - goto failed_clk_enet_out;
> - }
> if (fep->clk_ptp) {
> mutex_lock(&fep->ptp_clk_mutex);
> ret = clk_prepare_enable(fep->clk_ptp);
> @@ -1873,35 +1868,26 @@ static int fec_enet_clk_enable(struct net_device *ndev, bool enable)
> }
> mutex_unlock(&fep->ptp_clk_mutex);
> }
> - if (fep->clk_ref) {
> - ret = clk_prepare_enable(fep->clk_ref);
> - if (ret)
> - goto failed_clk_ref;
> - }
> + ret = clk_prepare_enable(fep->clk_ref);
> + if (ret)
> + goto failed_clk_ref;
This change seems unrelated to the problem. At least, I can leave this part out
and the toggle still disappear after apply the remaining parts.
However, I've only my Duckbill (iMX28) around to test with.
> } else {
> clk_disable_unprepare(fep->clk_ahb);
> - if (fep->clk_enet_out)
> - clk_disable_unprepare(fep->clk_enet_out);
> if (fep->clk_ptp) {
> mutex_lock(&fep->ptp_clk_mutex);
> clk_disable_unprepare(fep->clk_ptp);
> fep->ptp_clk_on = false;
> mutex_unlock(&fep->ptp_clk_mutex);
> }
> - if (fep->clk_ref)
> - clk_disable_unprepare(fep->clk_ref);
> + clk_disable_unprepare(fep->clk_ref);
Same as above, might be unrelated.
> }
>
> return 0;
>
> failed_clk_ref:
> - if (fep->clk_ref)
> - clk_disable_unprepare(fep->clk_ref);
> + clk_disable_unprepare(fep->clk_ref);
dito
> failed_clk_ptp:
> - if (fep->clk_enet_out)
> - clk_disable_unprepare(fep->clk_enet_out);
> -failed_clk_enet_out:
> - clk_disable_unprepare(fep->clk_ahb);
> + clk_disable_unprepare(fep->clk_ahb);
>
> return ret;
> }
> @@ -3425,6 +3411,10 @@ fec_probe(struct platform_device *pdev)
> if (ret)
> goto failed_clk;
>
> + ret = clk_prepare_enable(fep->clk_enet_out);
> + if (ret)
> + goto failed_clk_enet_out;
> +
As enet_out is optional, shouldn't this block be guarded by
if (fep->clk_enet_out)... ?
> ret = clk_prepare_enable(fep->clk_ipg);
> if (ret)
> goto failed_clk_ipg;
> @@ -3509,6 +3499,8 @@ failed_init:
> if (fep->reg_phy)
> regulator_disable(fep->reg_phy);
> failed_regulator:
> + clk_disable_unprepare(fep->clk_enet_out);
here too?
> +failed_clk_enet_out:
> clk_disable_unprepare(fep->clk_ipg);
> failed_clk_ipg:
> fec_enet_clk_enable(ndev, false);
> @@ -3531,6 +3523,8 @@ fec_drv_remove(struct platform_device *pdev)
> fec_ptp_stop(pdev);
> unregister_netdev(ndev);
> fec_enet_mii_remove(fep);
> + fec_enet_clk_enable(ndev, false);
> + clk_disable_unprepare(fep->clk_enet_out);
and here too?
> if (fep->reg_phy)
> regulator_disable(fep->reg_phy);
> of_node_put(fep->phy_node);
Mit freundlichen Grüßen / Kind regards
Michael Heimpold
--
Software Engineer
I2SE GmbH Tel: +49 (0) 341 355667-00
Friedrich-Ebert-Str. 61 Fax: +49 (0) 341 355667-02
04109 Leipzig
Germany
Web: http://www.i2se.com/ Mail: info@i2se.com
VAT No.: DE 811528334
Amtsgericht Leipzig HRB 23784
Geschäftsführer/CEO: Carsten Ziermann
*** Diese E-Mail ist allein für den bezeichneten Adressaten bestimmt. Sie kann rechtlich vertrauliche Informationen enthalten. Wenn Sie diese E-Mail irrtümlich erhalten haben, informieren Sie bitte unverzüglich den Absender per E-Mail und löschen Sie diese E-Mail von Ihrem Computer, ohne Kopien anzufertigen.
Vielen Dank. ***
*** This email is for the exclusive use of the addressee. It may contain legally privileged information. If you have received this message in error, please notify the sender by email immediately and delete the message from your computer without making any copies.
Thank you. ***
next prev parent reply other threads:[~2015-11-27 15:16 UTC|newest]
Thread overview: 10+ messages / expand[flat|nested] mbox.gz Atom feed top
2015-11-27 13:39 [PATCH] net: fec: fix enet_out clock handling Lothar Waßmann
2015-11-27 15:16 ` Michael Heimpold [this message]
2015-11-28 13:13 ` Duan Andy
2015-11-28 16:43 ` Andrew Lunn
2015-11-30 1:46 ` Duan Andy
2015-11-30 1:58 ` Andrew Lunn
2015-11-30 6:56 ` Lothar Waßmann
2015-11-30 7:31 ` Duan Andy
2015-11-30 2:07 ` Andrew Lunn
2015-11-30 5:37 ` Lothar Waßmann
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=565873E1.1030505@i2se.com \
--to=michael.heimpold@i2se.com \
--cc=B38611@freescale.com \
--cc=LW@KARO-electronics.de \
--cc=andrew@lunn.ch \
--cc=davem@davemloft.net \
--cc=fabio.estevam@freescale.com \
--cc=haokexin@gmail.com \
--cc=l.stach@pengutronix.de \
--cc=linux-kernel@vger.kernel.org \
--cc=netdev@vger.kernel.org \
--cc=rmk+kernel@arm.linux.org.uk \
--cc=stefan@agner.ch \
--cc=tremyfr@gmail.com \
--cc=u.kleine-koenig@pengutronix.de \
/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).