Subject: Re: DSA: external phy address and port number of switch conflicts

From: John Rama <[email-masked]>
Date: Tue, 18 Dec 2018 13:55:50 -0500

Hi Florian, 

On 2018/12/17 18:03, Florian Fainelli wrote:
> On 12/17/18 2:55 PM, John Rama wrote:
>> Hi, Andrew, Florian and Viven
>>
>> thank you your feedback !!
>>
>>>> I would recommend checking a newer kernel anyway which would have
>>>> support for the mv88e6xxx internal MDIO bus as it might allow you to
>>>> solve that specific problem. A kernel that contains
>>>> a3c53be55c955b7150cda17874c3fcb4eeb97a89 ("net: dsa: mv88e6xxx: Support
>>>> multiple MDIO busses") might work better and actually help here, though
>>>> I don't know enough about that specific switch model, Andrew or Vivien
>>>> would.
>>>>
>>>>>
>>
>> I tried with kernel 4.9.0, and confirmed that same problem happens.
>> (I wanted to try more latest one, but newer version is using phylink,
>>  which I need couple of time to understand how it works)
>> I think this is not the driver side issue, maybe dsa side (but not sure for newer kernel)
>> or I misunderstanding some concept.
>>  
>>> Since you have the switch in single address mode, i don't see why this
>>> should not work.
>>
>> Why conflicts happens is because of the code at slave.c (@kernel 4.9.0)
>>
>> /* pseudo code */
>> dsa_slave_phy_setup() {                                     
>>   phy_dn = of_parse_phandle(port_dn, "phy-handle", 0);      
>>     if (phy_dn) {                                             
>> 	phy_id = of_mdio_parse_addr(&slave_dev->dev, phy_dn); 
>> 	dsa_slave_phy_connect(p, slave_dev, phy_id); <= register with phy_id
>>     }
>>     if (!p->phy) {
>> 	dsa_slave_phy_connect(p, slave_dev, p->port); <= register with port number
>>     }
>> }
> 
> That was later fixed with this commit:
> 
> https://git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git/commit/?id=399ba77a94e1ee01f747b168c429a121164ac962
> 
> can you try to backport that change and see if that helps?
> 

Yes, that's the one !!
I confirmed that the problem is solved by backporting this patch to both kernel 4.9.0 and 4.1.15.

Thanks a lot.

John