diff mbox

[RESEND,net-next] phy: keep the BCMR_LOOPBACK bit while setup forced mode

Message ID 570E3488.9060403@huawei.com
State Changes Requested, archived
Delegated to: David Miller
Headers show

Commit Message

wangweidong April 13, 2016, 11:59 a.m. UTC
When tested the PHY SGMII Loopback,:
1.set the LOOPBACK bit,
2.set the autoneg to AUTONEG_DISABLE, it calls the
genphy_setup_forced which will clear the bit.

So just keep the LOOPBACK bit while setup forced mode.

Signed-off-by: Weidong Wang <wangweidong1@huawei.com>
---
 drivers/net/phy/phy_device.c | 2 ++
 1 file changed, 2 insertions(+)

-- 2.7.0

Comments

Sergei Shtylyov April 13, 2016, 2:19 p.m. UTC | #1
Hello.

On 4/13/2016 2:59 PM, Weidong Wang wrote:

> When tested the PHY SGMII Loopback,:
> 1.set the LOOPBACK bit,
> 2.set the autoneg to AUTONEG_DISABLE, it calls the
> genphy_setup_forced which will clear the bit.
>
> So just keep the LOOPBACK bit while setup forced mode.
>
> Signed-off-by: Weidong Wang <wangweidong1@huawei.com>
> ---
>   drivers/net/phy/phy_device.c | 2 ++
>   1 file changed, 2 insertions(+)
>
> diff --git a/drivers/net/phy/phy_device.c b/drivers/net/phy/phy_device.c
> index e551f3a..8da4b80 100644
> --- a/drivers/net/phy/phy_device.c
> +++ b/drivers/net/phy/phy_device.c
> @@ -1124,7 +1124,9 @@ static int genphy_config_advert(struct phy_device *phydev)
>   int genphy_setup_forced(struct phy_device *phydev)
>   {
>   	int ctl = 0;
> +	int val = phy_read(phydev, MII_BMCR);

    Please place this declaration first, DaveM prefers declarations to be 
sorted from longest to shortest.

>
> +	ctl |= val & BMCR_LOOPBACK;

    Just =, removing the 'ctl' initializer, please.

[...]

MBR, Sergei
Florian Fainelli April 13, 2016, 6:41 p.m. UTC | #2
On 13/04/16 04:59, Weidong Wang wrote:
> When tested the PHY SGMII Loopback,:
> 1.set the LOOPBACK bit,
> 2.set the autoneg to AUTONEG_DISABLE, it calls the
> genphy_setup_forced which will clear the bit.
> 
> So just keep the LOOPBACK bit while setup forced mode.

Humm, it makes sense why we want this one, but maybe we want other bits
to be preserved too, like MII_ISOLATE for instance?

Or maybe we should have a separate way to put the PHY into loopback mode
which is deterministic and takes care of forcing the link at the same time?

> 
> Signed-off-by: Weidong Wang <wangweidong1@huawei.com>
> ---
>  drivers/net/phy/phy_device.c | 2 ++
>  1 file changed, 2 insertions(+)
> 
> diff --git a/drivers/net/phy/phy_device.c b/drivers/net/phy/phy_device.c
> index e551f3a..8da4b80 100644
> --- a/drivers/net/phy/phy_device.c
> +++ b/drivers/net/phy/phy_device.c
> @@ -1124,7 +1124,9 @@ static int genphy_config_advert(struct phy_device *phydev)
>  int genphy_setup_forced(struct phy_device *phydev)
>  {
>  	int ctl = 0;
> +	int val = phy_read(phydev, MII_BMCR);
> 
> +	ctl |= val & BMCR_LOOPBACK;
>  	phydev->pause = 0;
>  	phydev->asym_pause = 0;
> 
> -- 2.7.0
>
wangweidong April 14, 2016, 2:18 a.m. UTC | #3
On 2016/4/13 22:19, Sergei Shtylyov wrote:
> Hello.
> 
> On 4/13/2016 2:59 PM, Weidong Wang wrote:
> 
>> When tested the PHY SGMII Loopback,:
>> 1.set the LOOPBACK bit,
>> 2.set the autoneg to AUTONEG_DISABLE, it calls the
>> genphy_setup_forced which will clear the bit.
>>
>> So just keep the LOOPBACK bit while setup forced mode.
>>
>> Signed-off-by: Weidong Wang <wangweidong1@huawei.com>
>> ---
>>   drivers/net/phy/phy_device.c | 2 ++
>>   1 file changed, 2 insertions(+)
>>
>> diff --git a/drivers/net/phy/phy_device.c b/drivers/net/phy/phy_device.c
>> index e551f3a..8da4b80 100644
>> --- a/drivers/net/phy/phy_device.c
>> +++ b/drivers/net/phy/phy_device.c
>> @@ -1124,7 +1124,9 @@ static int genphy_config_advert(struct phy_device *phydev)
>>   int genphy_setup_forced(struct phy_device *phydev)
>>   {
>>       int ctl = 0;
>> +    int val = phy_read(phydev, MII_BMCR);
> 
>    Please place this declaration first, DaveM prefers declarations to be sorted from longest to shortest.
> 
>>
>> +    ctl |= val & BMCR_LOOPBACK;
> 
>    Just =, removing the 'ctl' initializer, please.
> 
> [...]
> 
> MBR, Sergei
> 
Got it.

Regards,
Weidong
> 
>
wangweidong April 14, 2016, 3:42 a.m. UTC | #4
On 2016/4/14 2:41, Florian Fainelli wrote:
> On 13/04/16 04:59, Weidong Wang wrote:
>> When tested the PHY SGMII Loopback,:
>> 1.set the LOOPBACK bit,
>> 2.set the autoneg to AUTONEG_DISABLE, it calls the
>> genphy_setup_forced which will clear the bit.
>>
>> So just keep the LOOPBACK bit while setup forced mode.
> 
> Humm, it makes sense why we want this one, but maybe we want other bits
> to be preserved too, like MII_ISOLATE for instance?
> 

I will add the  MII_ISOLATE as well.

> Or maybe we should have a separate way to put the PHY into loopback mode
> which is deterministic and takes care of forcing the link at the same time?
> 

I test with the loopback mode, and the link status is undeterminable.

>>
>> Signed-off-by: Weidong Wang <wangweidong1@huawei.com>
>> ---
>>  drivers/net/phy/phy_device.c | 2 ++
>>  1 file changed, 2 insertions(+)
>>
>> diff --git a/drivers/net/phy/phy_device.c b/drivers/net/phy/phy_device.c
>> index e551f3a..8da4b80 100644
>> --- a/drivers/net/phy/phy_device.c
>> +++ b/drivers/net/phy/phy_device.c
>> @@ -1124,7 +1124,9 @@ static int genphy_config_advert(struct phy_device *phydev)
>>  int genphy_setup_forced(struct phy_device *phydev)
>>  {
>>  	int ctl = 0;
>> +	int val = phy_read(phydev, MII_BMCR);
>>
>> +	ctl |= val & BMCR_LOOPBACK;
>>  	phydev->pause = 0;
>>  	phydev->asym_pause = 0;
>>
>> -- 2.7.0
>>
> 
>
diff mbox

Patch

diff --git a/drivers/net/phy/phy_device.c b/drivers/net/phy/phy_device.c
index e551f3a..8da4b80 100644
--- a/drivers/net/phy/phy_device.c
+++ b/drivers/net/phy/phy_device.c
@@ -1124,7 +1124,9 @@  static int genphy_config_advert(struct phy_device *phydev)
 int genphy_setup_forced(struct phy_device *phydev)
 {
 	int ctl = 0;
+	int val = phy_read(phydev, MII_BMCR);

+	ctl |= val & BMCR_LOOPBACK;
 	phydev->pause = 0;
 	phydev->asym_pause = 0;