Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]


Groups > linux.kernel > #1502943 > unrolled thread

[PATCH] net: dsa: properly disconnect the slave PHYs

Started byJohn Crispin <john@phrozen.org>
First post2016-10-18 14:20 +0200
Last post2016-10-18 15:30 +0200
Articles 5 — 2 participants

Back to article view | Back to linux.kernel


Contents

  [PATCH] net: dsa: properly disconnect the slave PHYs John Crispin <john@phrozen.org> - 2016-10-18 14:20 +0200
    Re: [PATCH] net: dsa: properly disconnect the slave PHYs Andrew Lunn <andrew@lunn.ch> - 2016-10-18 14:30 +0200
      Re: [PATCH] net: dsa: properly disconnect the slave PHYs John Crispin <john@phrozen.org> - 2016-10-18 15:00 +0200
        Re: [PATCH] net: dsa: properly disconnect the slave PHYs Andrew Lunn <andrew@lunn.ch> - 2016-10-18 15:30 +0200
          Re: [PATCH] net: dsa: properly disconnect the slave PHYs John Crispin <john@phrozen.org> - 2016-10-18 15:30 +0200

#1502943 — [PATCH] net: dsa: properly disconnect the slave PHYs

FromJohn Crispin <john@phrozen.org>
Date2016-10-18 14:20 +0200
Subject[PATCH] net: dsa: properly disconnect the slave PHYs
Message-ID<stBx7-1xw-7@gated-at.bofh.it>
The shutdown code only stopped the PHYs but does not diconnect them
properly. This could lead to null pointer deref related kernel oopses
during reboot. Fix this by calling phy_disconnect() after the PHYs are
stopped.

Signed-off-by: John Crispin <john@phrozen.org>
---
 net/dsa/slave.c |    4 +++-
 1 file changed, 3 insertions(+), 1 deletion(-)

diff --git a/net/dsa/slave.c b/net/dsa/slave.c
index 68714a5..725d9f7 100644
--- a/net/dsa/slave.c
+++ b/net/dsa/slave.c
@@ -154,8 +154,10 @@ static int dsa_slave_close(struct net_device *dev)
 	struct net_device *master = p->parent->dst->master_netdev;
 	struct dsa_switch *ds = p->parent;
 
-	if (p->phy)
+	if (p->phy) {
 		phy_stop(p->phy);
+		phy_disconnect(p->phy);
+	}
 
 	dev_mc_unsync(master, dev);
 	dev_uc_unsync(master, dev);
-- 
1.7.10.4

[toc] | [next] | [standalone]


#1502945

FromAndrew Lunn <andrew@lunn.ch>
Date2016-10-18 14:30 +0200
Message-ID<stBGN-1Bc-3@gated-at.bofh.it>
In reply to#1502943
On Tue, Oct 18, 2016 at 02:12:40PM +0200, John Crispin wrote:
> The shutdown code only stopped the PHYs but does not diconnect them
> properly. This could lead to null pointer deref related kernel oopses
> during reboot. Fix this by calling phy_disconnect() after the PHYs are
> stopped.

Humm, i don't follow this.

The phy is disconnected in dsa_slave_destroy(). Why is that not
sufficient?

Also, after calling dsa_slave_close(), dsa_slave_open() can be
called. But with your change, the phy has gone, so we are going to
have trouble.

	Andrew

> 
> Signed-off-by: John Crispin <john@phrozen.org>
> ---
>  net/dsa/slave.c |    4 +++-
>  1 file changed, 3 insertions(+), 1 deletion(-)
> 
> diff --git a/net/dsa/slave.c b/net/dsa/slave.c
> index 68714a5..725d9f7 100644
> --- a/net/dsa/slave.c
> +++ b/net/dsa/slave.c
> @@ -154,8 +154,10 @@ static int dsa_slave_close(struct net_device *dev)
>  	struct net_device *master = p->parent->dst->master_netdev;
>  	struct dsa_switch *ds = p->parent;
>  
> -	if (p->phy)
> +	if (p->phy) {
>  		phy_stop(p->phy);
> +		phy_disconnect(p->phy);
> +	}
>  
>  	dev_mc_unsync(master, dev);
>  	dev_uc_unsync(master, dev);
> -- 
> 1.7.10.4
> 

[toc] | [prev] | [next] | [standalone]


#1502966

FromJohn Crispin <john@phrozen.org>
Date2016-10-18 15:00 +0200
Message-ID<stC9P-1M3-23@gated-at.bofh.it>
In reply to#1502945

On 18/10/2016 14:29, Andrew Lunn wrote:
> On Tue, Oct 18, 2016 at 02:12:40PM +0200, John Crispin wrote:
>> The shutdown code only stopped the PHYs but does not diconnect them
>> properly. This could lead to null pointer deref related kernel oopses
>> during reboot. Fix this by calling phy_disconnect() after the PHYs are
>> stopped.
> 
> Humm, i don't follow this.
> 
> The phy is disconnected in dsa_slave_destroy(). Why is that not
> sufficient?
> 
> Also, after calling dsa_slave_close(), dsa_slave_open() can be
> called. But with your change, the phy has gone, so we are going to
> have trouble.
> 
> 	Andrew
> 

Hi Andrew

i am testing on v4.4 which did not have a phy_disconnect() call. this
seems to have been fixed by cda5c15b so please ignore this patch

	John

>>
>> Signed-off-by: John Crispin <john@phrozen.org>
>> ---
>>  net/dsa/slave.c |    4 +++-
>>  1 file changed, 3 insertions(+), 1 deletion(-)
>>
>> diff --git a/net/dsa/slave.c b/net/dsa/slave.c
>> index 68714a5..725d9f7 100644
>> --- a/net/dsa/slave.c
>> +++ b/net/dsa/slave.c
>> @@ -154,8 +154,10 @@ static int dsa_slave_close(struct net_device *dev)
>>  	struct net_device *master = p->parent->dst->master_netdev;
>>  	struct dsa_switch *ds = p->parent;
>>  
>> -	if (p->phy)
>> +	if (p->phy) {
>>  		phy_stop(p->phy);
>> +		phy_disconnect(p->phy);
>> +	}
>>  
>>  	dev_mc_unsync(master, dev);
>>  	dev_uc_unsync(master, dev);
>> -- 
>> 1.7.10.4
>>

[toc] | [prev] | [next] | [standalone]


#1502989

FromAndrew Lunn <andrew@lunn.ch>
Date2016-10-18 15:30 +0200
Message-ID<stCCR-2dp-11@gated-at.bofh.it>
In reply to#1502966
> Hi Andrew
> 
> i am testing on v4.4 which did not have a phy_disconnect() call. this
> seems to have been fixed by cda5c15b so please ignore this patch

Hi John

All patches must be against net-next, or net if it is a fix. Anything
else is wrong....

     Andrew

[toc] | [prev] | [next] | [standalone]


#1502990

FromJohn Crispin <john@phrozen.org>
Date2016-10-18 15:30 +0200
Message-ID<stCCS-2dp-39@gated-at.bofh.it>
In reply to#1502989

On 18/10/2016 15:24, Andrew Lunn wrote:
>> Hi Andrew
>>
>> i am testing on v4.4 which did not have a phy_disconnect() call. this
>> seems to have been fixed by cda5c15b so please ignore this patch
> 
> Hi John
> 
> All patches must be against net-next, or net if it is a fix. Anything
> else is wrong....
> 
>      Andrew
> 

Hi Andrew,

i know. i was testing on v4.4 and then rebased the patch against
net-next without noticing that a similar patch had already been merged.

regardless, using the latest net-next tree, the oops is gone without
adding any patches.

	John

[toc] | [prev] | [standalone]


Back to top | Article view | linux.kernel


csiph-web