lists.openwall.net   lists  /  announce  owl-users  owl-dev  john-users  john-dev  passwdqc-users  yescrypt  popa3d-users  /  oss-security  kernel-hardening  musl  sabotage  tlsify  passwords  /  crypt-dev  xvendor  /  Bugtraq  Full-Disclosure  linux-kernel  linux-netdev  linux-ext4  linux-hardening  linux-cve-announce  PHC 
Open Source and information security mailing list archives
 
Hash Suite: Windows password security audit tool. GUI, reports in PDF.
[<prev] [next>] [<thread-prev] [thread-next>] [day] [month] [year] [list]
Date:   Fri, 26 Jul 2019 20:14:28 +0200
From:   Heiner Kallweit <hkallweit1@...il.com>
To:     Yonglong Liu <liuyonglong@...wei.com>, andrew@...n.ch,
        davem@...emloft.net
Cc:     netdev@...r.kernel.org, linux-kernel@...r.kernel.org,
        linuxarm@...wei.com, salil.mehta@...wei.com,
        yisen.zhuang@...wei.com, shiju.jose@...wei.com
Subject: Re: [RFC] net: phy: read link status twice when
 phy_check_link_status()

On 26.07.2019 11:53, Yonglong Liu wrote:
> According to the datasheet of Marvell phy and Realtek phy, the
> copper link status should read twice, or it may get a fake link
> up status, and cause up->down->up at the first time when link up.
> This happens more oftem at Realtek phy.
> 
This is not correct, there is no fake link up status.
Read the comment in genphy_update_link, only link-down events
are latched. Means if the first read returns link up, then there
is no need for a second read. And in polling mode we don't do a
second read because we want to detect also short link drops.

It would be helpful if you could describe your actual problem
and whether you use polling or interrupt mode.

> I add a fake status read, and can solve this problem.
> 
> I also see that in genphy_update_link(), had delete the fake
> read in polling mode, so I don't know whether my solution is
> correct.
> 
> Or provide a phydev->drv->read_status functions for the phy I
> used is more acceptable?
> 
> Signed-off-by: Yonglong Liu <liuyonglong@...wei.com>
> ---
>  drivers/net/phy/phy.c | 8 ++++++++
>  1 file changed, 8 insertions(+)
> 
> diff --git a/drivers/net/phy/phy.c b/drivers/net/phy/phy.c
> index ef7aa73..0c03edc 100644
> --- a/drivers/net/phy/phy.c
> +++ b/drivers/net/phy/phy.c
> @@ -1,4 +1,7 @@
>  // SPDX-License-Identifier: GPL-2.0+
> +	err = phy_read_status(phydev);
> +	if (err)
> +		return err;

This seems to be completely wrong at that place.

>  /* Framework for configuring and reading PHY devices
>   * Based on code in sungem_phy.c and gianfar_phy.c
>   *
> @@ -525,6 +528,11 @@ static int phy_check_link_status(struct phy_device *phydev)
>  
>  	WARN_ON(!mutex_is_locked(&phydev->lock));
>  
> +	/* Do a fake read */
> +	err = phy_read(phydev, MII_BMSR);
> +	if (err < 0)
> +		return err;
> +
>  	err = phy_read_status(phydev);
>  	if (err)
>  		return err;
> 

Powered by blists - more mailing lists