linux-kernel.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* [PATCH net] net: stmmac: Fix lack of link transition for fixed PHYs
@ 2016-11-14  1:50 Florian Fainelli
  2016-11-14  7:42 ` Giuseppe CAVALLARO
  2016-11-14 21:40 ` David Miller
  0 siblings, 2 replies; 3+ messages in thread
From: Florian Fainelli @ 2016-11-14  1:50 UTC (permalink / raw)
  To: netdev
  Cc: davem, Florian Fainelli, Giuseppe Cavallaro, Alexandre Torgue, open list

Commit 52f95bbfcf72 ("stmmac: fix adjust link call in case of a switch
is attached") added some logic to avoid polling the fixed PHY and
therefore invoking the adjust_link callback more than once, since this
is a fixed PHY and link events won't be generated.

This works fine the first time, because we start with phydev->irq =
PHY_POLL, so we call adjust_link, then we set phydev->irq =
PHY_IGNORE_INTERRUPT and we stop polling the PHY.

Now, if we called ndo_close(), which calls both phy_stop() and does an
explicit netif_carrier_off(), we end up with a link down. Upon calling
ndo_open() again, despite starting the PHY state machine, we have
PHY_IGNORE_INTERRUPT set, and we generate no link event at all, so the
link is permanently down.

52f95bbfcf72 ("stmmac: fix adjust link call in case of a switch is attached")
Signed-off-by: Florian Fainelli <f.fainelli@gmail.com>
---
Alexandre, Peppe,

The original patch is already a hack, but since this is a bugfix, I took the
same approach that you did here to backport this to -stable kernels.

 drivers/net/ethernet/stmicro/stmmac/stmmac_main.c | 7 +++++++
 1 file changed, 7 insertions(+)

diff --git a/drivers/net/ethernet/stmicro/stmmac/stmmac_main.c b/drivers/net/ethernet/stmicro/stmmac/stmmac_main.c
index 10909c9c0033..03dbf8e89c4c 100644
--- a/drivers/net/ethernet/stmicro/stmmac/stmmac_main.c
+++ b/drivers/net/ethernet/stmicro/stmmac/stmmac_main.c
@@ -882,6 +882,13 @@ static int stmmac_init_phy(struct net_device *dev)
 		return -ENODEV;
 	}
 
+	/* stmmac_adjust_link will change this to PHY_IGNORE_INTERRUPT to avoid
+	 * subsequent PHY polling, make sure we force a link transition if
+	 * we have a UP/DOWN/UP transition
+	 */
+	if (phydev->is_pseudo_fixed_link)
+		phydev->irq = PHY_POLL;
+
 	pr_debug("stmmac_init_phy:  %s: attached to PHY (UID 0x%x)"
 		 " Link = %d\n", dev->name, phydev->phy_id, phydev->link);
 
-- 
2.9.3

^ permalink raw reply related	[flat|nested] 3+ messages in thread

* Re: [PATCH net] net: stmmac: Fix lack of link transition for fixed PHYs
  2016-11-14  1:50 [PATCH net] net: stmmac: Fix lack of link transition for fixed PHYs Florian Fainelli
@ 2016-11-14  7:42 ` Giuseppe CAVALLARO
  2016-11-14 21:40 ` David Miller
  1 sibling, 0 replies; 3+ messages in thread
From: Giuseppe CAVALLARO @ 2016-11-14  7:42 UTC (permalink / raw)
  To: Florian Fainelli, netdev; +Cc: davem, Alexandre Torgue, open list

On 11/14/2016 2:50 AM, Florian Fainelli wrote:
> Commit 52f95bbfcf72 ("stmmac: fix adjust link call in case of a switch
> is attached") added some logic to avoid polling the fixed PHY and
> therefore invoking the adjust_link callback more than once, since this
> is a fixed PHY and link events won't be generated.
>
> This works fine the first time, because we start with phydev->irq =
> PHY_POLL, so we call adjust_link, then we set phydev->irq =
> PHY_IGNORE_INTERRUPT and we stop polling the PHY.
>
> Now, if we called ndo_close(), which calls both phy_stop() and does an
> explicit netif_carrier_off(), we end up with a link down. Upon calling
> ndo_open() again, despite starting the PHY state machine, we have
> PHY_IGNORE_INTERRUPT set, and we generate no link event at all, so the
> link is permanently down.
>
> 52f95bbfcf72 ("stmmac: fix adjust link call in case of a switch is attached")
> Signed-off-by: Florian Fainelli <f.fainelli@gmail.com>
> ---
> Alexandre, Peppe,
>
> The original patch is already a hack, but since this is a bugfix, I took the
> same approach that you did here to backport this to -stable kernels.


Acked-by: Giuseppe Cavallaro <peppe.cavallaro@st.com>

>
>  drivers/net/ethernet/stmicro/stmmac/stmmac_main.c | 7 +++++++
>  1 file changed, 7 insertions(+)
>
> diff --git a/drivers/net/ethernet/stmicro/stmmac/stmmac_main.c b/drivers/net/ethernet/stmicro/stmmac/stmmac_main.c
> index 10909c9c0033..03dbf8e89c4c 100644
> --- a/drivers/net/ethernet/stmicro/stmmac/stmmac_main.c
> +++ b/drivers/net/ethernet/stmicro/stmmac/stmmac_main.c
> @@ -882,6 +882,13 @@ static int stmmac_init_phy(struct net_device *dev)
>  		return -ENODEV;
>  	}
>
> +	/* stmmac_adjust_link will change this to PHY_IGNORE_INTERRUPT to avoid
> +	 * subsequent PHY polling, make sure we force a link transition if
> +	 * we have a UP/DOWN/UP transition
> +	 */
> +	if (phydev->is_pseudo_fixed_link)
> +		phydev->irq = PHY_POLL;
> +
>  	pr_debug("stmmac_init_phy:  %s: attached to PHY (UID 0x%x)"
>  		 " Link = %d\n", dev->name, phydev->phy_id, phydev->link);
>
>

^ permalink raw reply	[flat|nested] 3+ messages in thread

* Re: [PATCH net] net: stmmac: Fix lack of link transition for fixed PHYs
  2016-11-14  1:50 [PATCH net] net: stmmac: Fix lack of link transition for fixed PHYs Florian Fainelli
  2016-11-14  7:42 ` Giuseppe CAVALLARO
@ 2016-11-14 21:40 ` David Miller
  1 sibling, 0 replies; 3+ messages in thread
From: David Miller @ 2016-11-14 21:40 UTC (permalink / raw)
  To: f.fainelli; +Cc: netdev, peppe.cavallaro, alexandre.torgue, linux-kernel

From: Florian Fainelli <f.fainelli@gmail.com>
Date: Sun, 13 Nov 2016 17:50:35 -0800

> Commit 52f95bbfcf72 ("stmmac: fix adjust link call in case of a switch
> is attached") added some logic to avoid polling the fixed PHY and
> therefore invoking the adjust_link callback more than once, since this
> is a fixed PHY and link events won't be generated.
> 
> This works fine the first time, because we start with phydev->irq =
> PHY_POLL, so we call adjust_link, then we set phydev->irq =
> PHY_IGNORE_INTERRUPT and we stop polling the PHY.
> 
> Now, if we called ndo_close(), which calls both phy_stop() and does an
> explicit netif_carrier_off(), we end up with a link down. Upon calling
> ndo_open() again, despite starting the PHY state machine, we have
> PHY_IGNORE_INTERRUPT set, and we generate no link event at all, so the
> link is permanently down.
> 
> 52f95bbfcf72 ("stmmac: fix adjust link call in case of a switch is attached")

I added the missing "Fixes: " here.

> Signed-off-by: Florian Fainelli <f.fainelli@gmail.com>

Applied and queued up for -stable, thanks Florian.

^ permalink raw reply	[flat|nested] 3+ messages in thread

end of thread, other threads:[~2016-11-14 21:41 UTC | newest]

Thread overview: 3+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2016-11-14  1:50 [PATCH net] net: stmmac: Fix lack of link transition for fixed PHYs Florian Fainelli
2016-11-14  7:42 ` Giuseppe CAVALLARO
2016-11-14 21:40 ` David Miller

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).